summaryrefslogtreecommitdiffstats
path: root/agl-basefiles/agldd
diff options
context:
space:
mode:
authorRiku Nomoto <riku_nomoto@mail.toyota.co.jp>2020-11-19 12:45:32 +0900
committerRiku Nomoto <riku_nomoto@mail.toyota.co.jp>2020-11-19 12:45:32 +0900
commit8e0e00d21146a84c18f9cf9409e187b4fb0248aa (patch)
treeef791689dad216ac61091a1d1bd3b928d563aba6 /agl-basefiles/agldd
parent18df6e21c6743a137e2760c52ca89d0789e90417 (diff)
Init basesystem source codes.
Signed-off-by: Riku Nomoto <riku_nomoto@mail.toyota.co.jp> Change-Id: I55aa2f1406ce7f751ae14140b613b53b68995528
Diffstat (limited to 'agl-basefiles/agldd')
-rw-r--r--agl-basefiles/agldd/ev_common.h135
-rw-r--r--agl-basefiles/agldd/ev_id.h104
-rw-r--r--agl-basefiles/agldd/evk_lib.h116
-rw-r--r--agl-basefiles/agldd/moduleid.h69
4 files changed, 424 insertions, 0 deletions
diff --git a/agl-basefiles/agldd/ev_common.h b/agl-basefiles/agldd/ev_common.h
new file mode 100644
index 0000000..1a68fea
--- /dev/null
+++ b/agl-basefiles/agldd/ev_common.h
@@ -0,0 +1,135 @@
+/**
+ * @file ev_common.h
+ * @brief Event library -- User kernel common data structure
+ *
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef _ev_common_h_
+#define _ev_common_h_
+
+#include <agldd/ev_id.h>
+
+/** @addtogroup EV
+ * @{ */
+/** @brief Maximum number of bytes for message event */
+#define EV_MAX_MESSAGE_LENGTH 2048
+
+/** @brief -Maximum number of flag queue that can be created within a thread */
+#define EV_MAX_IDS_IN_THREAD 24
+
+/** @brief -Muximum number of threads that can be registered to the EV in a process */
+#define EV_MAX_THREADS_IN_PROCESS 16
+
+/** @brief -Maximum number of flag queue that can be creat within a process
+ */
+#define EV_MAX_IDS_IN_PROCESS \
+ (EV_MAX_IDS_IN_THREAD * EV_MAX_THREADS_IN_PROCESS)
+
+/** @brief Return values for even library function
+ *
+ * @see EV_ERR
+ */
+enum ev_err
+{
+ EV_OK = 0, /**< Normal completion */
+ EV_ERR_Exist, /**< The specified flag message queue does exist */
+ EV_ERR_Invalid_ID, /**< The specified flag message queue does not exist */
+ EV_ERR_Busy, /**< Message queue full failed to send */
+ EV_ERR_Interrupted, /**< Waiting function was interrupted by an interrupt */
+ EV_ERR_Thread_Over, /**< Exceeding the number of threads in the process */
+ EV_ERR_Invalid_Thread, /**< Invalid thread ID */
+ EV_ERR_Fatal, /**< Fatal error */
+};
+/** @brief Return values type for even library function
+ *
+ * @see ev_err
+ */
+typedef INT32 EV_ERR;
+
+/** @brief Event type
+ *
+ * Use in the type of EV_Event structs
+ * @see ev_type
+ */
+typedef UINT32 EV_Type;
+
+/** @brief Bit value representing the type of event */
+enum ev_type {
+ EV_EVENT_None = 0x00000000,
+
+ /** Flag event: Judged by EV_EVENT_IS_FLAG() */
+ EV_EVENT_Flag = 0x0001,
+#define EV_EVENT_IS_FLAG(tp) (((tp) & EV_EVENT_Flag) != 0)
+
+ /** Message event: Judged by EV_EVENT_IS_MESSAGE() */
+ EV_EVENT_Message = 0x0002,
+#define EV_EVENT_IS_MESSAGE(tp) (((tp) & EV_EVENT_Message) != 0)
+
+ /** 64bit flag event: Judged by EV_EVENT_IS_FLAG64() */
+ EV_EVENT_Flag64 = 0x0003,
+#define EV_EVENT_IS_FLAG64(tp) (((tp) & EV_EVENT_Flag64) != 0)
+
+};
+
+/** @brief Flag event structure */
+typedef struct {
+ EV_ID flagID;/**< Flag ID */
+ UINT32 bits;/**< Bit pattern */
+} EV_Flag;
+
+/** @brief 64bit flag event structure */
+typedef struct {
+ EV_ID flagID;/**< Flag ID */
+ UINT64 bits;/**< Bit pattern */
+} EV_Flag64;
+
+/** @brief Message event structure */
+typedef struct {
+ EV_ID queueID;/**< queue ID */
+ UINT32 senderInfo;/**< Source information */
+ UINT32 length;/**< Number of bytes in the message */
+ UINT32 dummy;/** dummy for pading */
+ UINT8 message[EV_MAX_MESSAGE_LENGTH];/**< Message */
+} EV_Message;
+
+/** @brief Event structure */
+typedef struct {
+ EV_Type type; /**< Event type */
+ union {
+ EV_Flag flag; /**< Flag event structure */
+ EV_Flag64 flag64; /**< Flag event structure */
+ EV_Message message; /**< Message event structure */
+ } u; /**< Union of structures per event type */
+} EV_Event;
+
+/** @brief Message event queue type
+ *
+ * Specify the action to be taken when the queue overflows (more events are received when the queue is full).
+ */
+enum ev_message_queue_type {
+ EV_MESSAGE_QUEUE_TYPE_BUSY,/**< Return a BUSY to the source */
+ EV_MESSAGE_QUEUE_TYPE_FIFO,/**< Delete the oldest event */
+ EV_MESSAGE_QUEUE_TYPE_REPLACE,/**< Replace the most recent event */
+};
+
+/** @brief Messge event queue type
+ *
+ * @see ev_message_queue_type
+ */
+typedef UINT8 EV_Message_Queue_Type;
+
+/** @} */
+
+#endif /* !_ev_common_h_ */
diff --git a/agl-basefiles/agldd/ev_id.h b/agl-basefiles/agldd/ev_id.h
new file mode 100644
index 0000000..2026ef7
--- /dev/null
+++ b/agl-basefiles/agldd/ev_id.h
@@ -0,0 +1,104 @@
+/**
+ * @file ev_id.h
+ * @brief Event library(kernel) -- Defining flag queue ID
+ *
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef _ev_id_h_
+#define _ev_id_h_
+
+/** @addtogroup EV_ID_spec
+ * @{ */
+
+/** @brief Flag ID and queue ID types used when sending and receiving events
+ *
+ * Assign a 32-bit value as follows
+ *
+ * - Most significant 8 bits: Reserved
+ * - Next 16 bits: Modue ID
+ * - Lower 8 bits: Define in module
+ *
+ * Where module is the modules that creates the queue.
+ * The modules define ID according to the above assignments using EV_Flag_ID_Base and EV_Queue_ID_Base macros.
+ * @see EV_Flag_ID_Base
+ * @see EV_Queue_ID_Base
+ */
+typedef UINT32 EV_ID;
+
+#define EV_ID_BIT 0x80000000UL
+#define EV_FLAG64_BIT 0x40000000UL
+#define EV_FLAG_BIT 0x20000000UL
+#define EV_QUEUE_BIT 0x10000000UL
+#define EV_AUTO_ID_BIT 0x08000000UL
+#define EV_RESERVED_BIT 0xff000000UL
+#define EV_INVALID_ID EV_ID_BIT
+#define EV_NO_ID EV_INVALID_ID
+
+#define EV_ID_IS_FLAG(queueID) \
+ (((queueID) & (EV_ID_BIT|EV_FLAG_BIT)) == (EV_ID_BIT|EV_FLAG_BIT))
+#define EV_ID_IS_FLAG64(queueID) \
+ (((queueID) & (EV_ID_BIT|EV_FLAG64_BIT)) == (EV_ID_BIT|EV_FLAG64_BIT))
+#define EV_ID_IS_QUEUE(queueID) \
+ (((queueID) & (EV_ID_BIT|EV_QUEUE_BIT)) == (EV_ID_BIT|EV_QUEUE_BIT))
+#define EV_ID_IS_AUTO_ID(queueID) \
+ (((queueID) & (EV_ID_BIT|EV_AUTO_ID_BIT)) == (EV_ID_BIT|EV_AUTO_ID_BIT))
+#define EV_ID_IS_VALID(queueID) \
+ (EV_ID_IS_FLAG(queueID) || EV_ID_IS_FLAG64(queueID) || EV_ID_IS_QUEUE(queueID))
+
+/** @brief Macros for defining flag ID
+ *
+ * Define the module ID as an argument as follows.
+ * - #define XXX_Module_ID 1
+ * - #define XXX_Flag_ID_Base EV_Flag_ID_Base(XXX_Module_ID)
+ * -
+ * - #define XXX_Flag_foo (XXX_Flag_ID_Base + 1)
+ * - #define XXX_Flag_bar (XXX_Flag_ID_Base + 2)
+ *
+ * The module ID is 16 bits and 0 to 65535 can be specified.
+ * In addition, 0 to 255 added to Base can be defined as ID.
+ */
+#define EV_Flag_ID_Base(mod) (EV_ID_BIT|EV_FLAG_BIT|((mod)<<8))
+
+/** @brief Macros for defining 64 bits flag ID
+ *
+ * Define the module ID as an argument as follows.
+ * - #define XXX_Module_ID 1
+ * - #define XXX_Flag64_ID_Base EV_Flag64_ID_Base(XXX_Module_ID)
+ * -
+ * - #define XXX_Flag64_foo (XXX_Flag64_ID_Base + 1)
+ * - #define XXX_Flag64_bar (XXX_Flag64_ID_Base + 2)
+ *
+ * The module ID is 16 bits and 0 to 65535 can be specified.
+ * In addition, 0 to 255 added to Base can be defined as ID.
+ */
+#define EV_Flag64_ID_Base(mod) (EV_ID_BIT|EV_FLAG64_BIT|((mod)<<8))
+
+/** @brief Macros for defining mesage queue ID
+ *
+ * Define the module ID as an argument as follows.
+ * - #define XXX_Module_ID 1
+ * - #define XXX_Queue_ID_Base EV_Queue_ID_Base(XXX_Module_ID)
+ * -
+ * - #define XXX_Queue_foo (XXX_Queue_ID_Base + 1)
+ * - #define XXX_Queue_bar (XXX_Queue_ID_Base + 2)
+ *
+ * The module ID is 16 bits and 0 to 65535 can be specified.
+ * In addition, 0 to 255 added to Base can be defined as ID.
+ */
+#define EV_Queue_ID_Base(mod) (EV_ID_BIT|EV_QUEUE_BIT|((mod)<<8))
+
+/** @} */
+
+#endif /* ! _ev_id_h_ */
diff --git a/agl-basefiles/agldd/evk_lib.h b/agl-basefiles/agldd/evk_lib.h
new file mode 100644
index 0000000..378df13
--- /dev/null
+++ b/agl-basefiles/agldd/evk_lib.h
@@ -0,0 +1,116 @@
+/**
+ * @file evk_lib.h
+ * @brief Event library -- API specifications for kernel modules
+ *
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef _evk_lib_h_
+#define _evk_lib_h_
+
+#include <agldd/ev_common.h>
+#include <linux/types.h>
+#include <linux/ioctl.h>
+
+/* API definition */
+
+/** @addtogroup EV
+ * @{ */
+#ifdef __KERNEL__
+/* Flag message queue create/delete */
+EV_ERR EVK_create_flag(EV_ID flagID);
+EV_ERR EVK_create_flag64(EV_ID flagID);
+EV_ERR EVK_create_queue(EV_ID queueID,
+ UINT8 length,
+ UINT16 max_bytes,
+ EV_Message_Queue_Type type);
+
+EV_ERR EVK_create_flag_auto_id(/* OUT */EV_ID *flagID);
+EV_ERR EVK_create_flag64_auto_id(/* OUT */EV_ID *flagID);
+EV_ERR EVK_create_queue_auto_id(/* OUT */EV_ID *queueID,
+ UINT8 length,
+ UINT16 max_bytes,
+ EV_Message_Queue_Type type);
+
+EV_ERR EVK_destroy_flag(EV_ID flagID);
+EV_ERR EVK_destroy_queue(EV_ID queueID);
+
+/* Send events */
+EV_ERR EVK_set_flag(EV_ID flagID, UINT32 bits);
+EV_ERR EVK_set_flag64(EV_ID flagID, UINT64 bits);
+EV_ERR EVK_send_message(EV_ID queueID, UINT16 bytes, const void *message,
+ UINT32 senderInfo);
+
+/* Get event(with search conditions) */
+EV_ERR EVK_get_flag(EV_ID flagID, /* OUT */EV_Flag *flag);
+EV_ERR EVK_wait_flag(EV_ID flagID, /* OUT */EV_Flag *flag);/* block */
+EV_ERR EVK_peek_flag(EV_ID flagID, /* OUT */EV_Flag *flag);
+EV_ERR EVK_get_flag64(EV_ID flagID, /* OUT */EV_Flag64 *flag);
+EV_ERR EVK_wait_flag64(EV_ID flagID, /* OUT */EV_Flag64 *flag);/* block */
+EV_ERR EVK_peek_flag64(EV_ID flagID, /* OUT */EV_Flag64 *flag);
+
+EV_ERR EVK_get_message(EV_ID queueID, /* OUT */EV_Message *message);
+EV_ERR EVK_wait_message(EV_ID queueID, /* OUT */EV_Message *message);/* block */
+EV_ERR EVK_peek_message(EV_ID queueID, /* OUT */EV_Message *message);
+
+EV_ERR EVK_find_message_by_sender(EV_ID queueID, UINT32 senderInfo,
+ /* OUT */EV_Message *message);
+EV_ERR EVK_find_message_by_content(EV_ID queueID, UINT16 length,
+ const void *compare_bytes,
+ /* OUT */EV_Message *message);
+#endif
+
+/** @} */
+
+/** @addtogroup EVK_in
+ * @{ */
+#define EVK_NAME "evk"
+#define EVK_DEV_NAME "/dev/agl/"EVK_NAME
+#define EVK_DEV_MAJOR 1033
+#define EVK_IOC_MAGIC 0xE7
+
+#define EVK_IOC_CREATE_FLAG _IO(EVK_IOC_MAGIC, 0x00)
+#define EVK_IOC_CREATE_FLAG64 _IO(EVK_IOC_MAGIC, 0x01)
+#define EVK_IOC_CREATE_MESSAGE_QUEUE _IO(EVK_IOC_MAGIC, 0x02)
+#define EVK_IOC_ALLOC_FLAG_ID _IO(EVK_IOC_MAGIC, 0x03)
+#define EVK_IOC_ALLOC_FLAG64_ID _IO(EVK_IOC_MAGIC, 0x04)
+#define EVK_IOC_ALLOC_QUEUE_ID _IO(EVK_IOC_MAGIC, 0x05)
+#define EVK_IOC_DESTROY_QUEUE _IO(EVK_IOC_MAGIC, 0x06)
+#define EVK_IOC_STORE_FLAG _IO(EVK_IOC_MAGIC, 0x07)
+#define EVK_IOC_STORE_FLAG64 _IO(EVK_IOC_MAGIC, 0x08)
+#define EVK_IOC_STORE_MESSAGE _IO(EVK_IOC_MAGIC, 0x09)
+#define EVK_IOC_SET_POLL _IO(EVK_IOC_MAGIC, 0x0a)
+#define EVK_IOC_GET_EVENT _IO(EVK_IOC_MAGIC, 0x0b)
+#define EVK_IOC_PEEK_EVENT _IO(EVK_IOC_MAGIC, 0x0c)
+#define EVK_IOC_WAIT_EVENT _IO(EVK_IOC_MAGIC, 0x0d)
+#define EVK_IOC_GET_NEXT_EVENT _IO(EVK_IOC_MAGIC, 0x0e)
+#define EVK_IOC_PEEK_NEXT_EVENT _IO(EVK_IOC_MAGIC, 0x0f)
+#define EVK_IOC_DEBUG_LIST _IO(EVK_IOC_MAGIC, 0x10)
+
+typedef struct {
+ EV_ID queueID;/**< Queue ID */
+ UINT32 max_bytes;/**< Maximum number of bytes for an event */
+ UINT8 length;/**< Queue length */
+ EV_Message_Queue_Type type;/**< Type */
+} EVK_Message_Queue_Request;
+
+typedef struct {
+ INT32 num; /**< Number of queue ID of search */
+ EV_ID ids[EV_MAX_IDS_IN_PROCESS]; /**< Queue ID of search */
+ EV_Event ev; /**< [OUT] First event that occured */
+} EVK_Next_Event_Query;
+
+/** @} */
+
+#endif /* !_evk_lib_h */
diff --git a/agl-basefiles/agldd/moduleid.h b/agl-basefiles/agldd/moduleid.h
new file mode 100644
index 0000000..b18c1a1
--- /dev/null
+++ b/agl-basefiles/agldd/moduleid.h
@@ -0,0 +1,69 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <linux/autoconf.h>
+#ifndef _AGLDD_MODULEID_H_
+#define _AGLDD_MODULEID_H_
+
+/*
+ * Define module ID to be used by programs in moduleid_id.h .
+ * Define in the format of "#define XXX_MID ID number" (XXX is the module name).
+ *
+ * MID allocation policy shall be as follows.
+ * - UI Application : 0xxxh
+ * - Application Service : 1xxxh to 2xxxh
+ * + HMI : 10xxh
+ * + AV : 12xxh
+ * + Radio : 14xxh
+ * + Connectivity : 16xxh
+ * + Navigation/Location: 18xxh
+ * + Vehicle : 1Axxh
+ * + Communication : 1Cxxh
+ * + BasePF : 1Exxh
+ * + System : 20xxh
+ * + Other : 22xxh
+ * - Common Service : 3xxxh
+ * - Extension Service : 4xxxh
+ * - System/Device Driver : 5xxxh
+ */
+
+/* UI Application : 0xxxh */
+
+/* Application Service : 1xxxh to 2xxxh */
+#define MODEMANAGER_MID 0x1000
+#define ACTIVITYMANAGER_MID 0x1001
+
+/* Common Service : 3xxxh */
+#define IPMANAGER_MID 0x3000
+#define DEVICEMANAGER_MID 0x3001
+#define MSGBRK_MID 0x3002
+#define TIMERENTRYDRV_MID 0x3003
+#define SOUNDAGENT_MID 0x3004
+#define CAN_MID 0x3006
+#define _CWORD83__MID 0x3007
+#define SENSOR_MID 0x3008
+#define GPS_MID 0x3009
+#define RESMGR_MID 0x300A
+#define GRAPHICS_MID 0x300B
+
+/* Extension Service : 4xxxh */
+
+/* System/Device Driver : 5xxxh */
+#define EV_MID 0x5001
+#define RPC_MID 0x5002
+#define EVK_MID 0x5801
+
+#endif /* !_AGLDD_MODULEID_H_ */