1+ /**
2+ *
3+ * \file ipc_defs.h
4+ *
5+ * \brief apipc definitions.
6+ *
7+ * \author Federico David Ceccarelli
8+ *
9+ * apipc is an ipc_driver library implementation for TMS320C28x Texas
10+ * Instruments cores. The api present a bunch of routines to simplify
11+ * comunication between cores.
12+ *
13+ * The file includes all the library definitions. Some of them are only intended
14+ * to explicitly show the memory spaces used.
15+ *
16+ */
117
218#ifndef __IPC_DEFS_H__
319#define __IPC_DEFS_H__
420
5- /*
6- * Defines
7- */
8-
9- /*
21+ /**
22+ * \brief ram_func attribute definition
23+ *
1024 * The ramfunc attribute specifies that a function will be placed in and
11- * executed from RAM. The ramfunc // attribute allows the compiler to
12- * optimize functions for RAM execution.
25+ * executed from RAM. The ramfunc attribute allows the compiler to optimize
26+ * functions for RAM execution.
27+ *
1328 * Use example:
14- * __attribute__((ramfunc))
15- * void f(void) {
29+ * \code{.c}
30+ * __attribute__((ramfunc)) void f(void) {
1631 * ...
1732 * }
33+ * \endcode
34+ *
35+ * User should define rumfunc location on the corresponding .cmd command linker
36+ * file according to project needs.
1837 */
1938#if defined(_FLASH )
2039#ifndef ram_func
2645#endif
2746#endif
2847
29- // gsxm blocks that master cpu1 reserverd for ipc driver app
48+ /**
49+ * \defgroup gsxm apipc GSxM memory block use description
50+ *
51+ * \brief apipc GSxM memory block use description
52+ *
53+ * RAM blocks which are accessible from both the CPU and DMA are called global
54+ * shared RAMs (GSx RAMs).
55+ * Each shared RAM block can be owned by either CPU subsystem based on the
56+ * configuration of respective bits in the GSxMSEL register.
57+ *
58+ * Each cpu reserves three GSxM blocks to transfer data and allocate local
59+ * apipc objects.
60+ *
61+ * <b>CPU0n_TO_CPU0n_R_W_DATA</b> memory blocks are used to copy data when
62+ * variables are transfered as blocks. This memory space is dynamically
63+ * allocated with mymalloc library. \see mymalloc.
64+ *
65+ * <b>CPU0n_TO_CPU0n_R_W_ADDR</b> memory blocks are used to allocate apipc objs
66+ * to be accesible from both cores.
67+ *
68+ * --
69+ *
70+ * \subsection apipc GSxM memory space use description:
71+ *
72+ * CPU1 | CPU2
73+ * - - - - -
74+ * GSR0
75+ * ~
76+ * - - - - -
77+ * GSR2
78+ * CPU02_TO_CPU01_R_W_DATA
79+ * GSR3
80+ * - - - - -
81+ * GSR4
82+ * CPU01_TO_CPU02_R_W_DATA
83+ * GSR5
84+ *
85+ * CPU01_TO_CPU02_ADDR GSR6
86+ * - - - - -
87+ * GSR7 CPU01_TO_CPU02_ADDR
88+ * - - - - -
89+ * ~
90+ * ...
91+ * - - - - -
92+ *
93+ * @{ */
94+
95+ /** gsxm blocks reserved for ipc driver app for cpu1 - cpu1 has W/R priviledges */
3096#define APIPC_CPU01_TO_CPU02_GSxRAM GS4_ACCESS|GS5_ACCESS|GS6_ACCESS
31- // gsxm blocks that master cpu2 reserverd for ipc driver app
97+ /** gsxm blocks reserved for ipc driver app for cpu2 - cpu2 has W/R priviledges */
3298#define APIPC_CPU02_TO_CPU01_GSxRAM GS2_ACCESS|GS3_ACCESS|GS7_ACCESS
3399
34- // GS4SARAM Start Address
100+ /** GS4SARAM Start Address */
35101#define CPU01_TO_CPU02_R_W_DATA_START (uint32_t)0x00010000
36102
37- // CPU01 to CPU02 Local Addresses MSG RAM off sets
38- #define CPU01_TO_CPU02_R_W_ADDR (uint32_t)0x00012000 // for passing address
39-
40- // GS2SARAM Start Address
103+ /** CPU01 to CPU02 Local Addresses MSG RAM off sets */
104+ #define CPU01_TO_CPU02_R_W_ADDR (uint32_t)0x00012000
105+
106+ /** GS2SARAM Start Address */
41107#define CPU02_TO_CPU01_R_W_DATA_START (uint32_t)0x0000E000
42108
43- // CPU02 to CPU01 Local Addresses MSG RAM offsets
109+ /** CPU02 to CPU01 Local Addresses MSG RAM offsets */
44110#define CPU02_TO_CPU01_R_W_ADDR (uint32_t)0x00013000
45111
46- // Local R_W_DATA length space
112+ /**@}*/
113+
114+ /** CPU0n_TO_CPU0n_R_W_DATA space length*/
47115#define CL_R_W_DATA_LENGTH 4096
48116
49- // Maximum number of object apipc can handle
117+ /** Maximum number of object apipc allocates and can handle */
50118#define APIPC_MAX_OBJ 10
51119
52- /*
120+ /**
53121 * The following values extends the IPC driver command values passed between
54122 * processors in tIpcMessage.ulcommqnd register to determine what command is
55- * requested by the sending processor.
123+ * requested to be processed by the sending core.
124+ *
56125 * User should implement the corresponding function that serves the command on
57126 * the remote CPU side to interpret and use the message.
58127 */
59- #define APIPC_MESSAGE 0x0001000C
128+ #define APIPC_MESSAGE 0x0001000C
60129
130+ /**
131+ * \brief apipc app state machine's states definition
132+ */
61133enum apipc_sm
62134{
63- APIPC_SM_UNKNOWN = 0 ,
64- APIPC_SM_STARTUP_REMOTE ,
65- APIPC_SM_IDLE ,
66- APIPC_SM_STARTED
135+ APIPC_SM_UNKNOWN = 0 , /**< initial state. apipc app sm state is unknown */
136+ APIPC_SM_STARTUP_REMOTE , /**< apipc app is transmiting startup flaged
137+ objects to remote */
138+ APIPC_SM_IDLE , /**< apipc app is idle, doing nothing */
139+ APIPC_SM_STARTED /**< apipc app is ready to process objects to transmit */
67140};
68141
142+ /**
143+ * \brief apipc obj state machine's states definition
144+ *
145+ * For every obj, declared or not, his own sm will be processed
146+ */
69147enum apipc_obj_sm
70148{
71- APIPC_OBJ_SM_UNKNOWN = 0 ,
72- APIPC_OBJ_SM_FREE ,
73- APIPC_OBJ_SM_INIT ,
74- APIPC_OBJ_SM_WRITING ,
75- APIPC_OBJ_SM_WAITTING_RESPONSE ,
76- APIPC_OBJ_SM_RETRY ,
77- APIPC_OBJ_SM_IDLE ,
78- APIPC_OBJ_SM_FAIL ,
149+ APIPC_OBJ_SM_UNKNOWN = 0 , /**< initial state. obj sm state is unknown */
150+ APIPC_OBJ_SM_FREE , /**< obj is free. Wasn't registered. Do nothing */
151+ APIPC_OBJ_SM_INIT , /**< obj sm prepares to transmit */
152+ APIPC_OBJ_SM_WRITING , /**< obj sm is filling memory and writing ipc driver */
153+ APIPC_OBJ_SM_WAITTING_RESPONSE , /**< obj is waiting remote response */
154+ APIPC_OBJ_SM_RETRY , /**< obj transmition failed, retry */
155+ APIPC_OBJ_SM_IDLE , /**< obj is started and idle, ready to transmit */
156+ APIPC_OBJ_SM_FAIL , /**< obj is in fail state, catastrofic fail happened */
79157};
80158
159+ /**
160+ * \brief apipc messages commands definitions
161+ *
162+ * The following are values that are used by apipc and matchs commands values
163+ * that are passed between processors in tIpcMessage.ulmessage or in the
164+ * xTOyIPCCOM register and that determine what command is requested by the
165+ * sending processor.
166+ *
167+ * apipc uses them to identify and proccess responces from remote core
168+ */
81169enum apipc_msg_cmd
82170{
83171 APIPC_MSG_CMD_FUNC_CALL_RSP = 0x00000012 ,
@@ -94,50 +182,75 @@ enum apipc_msg_cmd
94182 APIPC_MSG_CMD_BLOCK_WRITE_PROTECTED_RSP = 0x0001000B ,
95183};
96184
185+ /**
186+ * \brief apipc funtions return codes definition
187+ */
97188enum apipc_rc
98189{
99- APIPC_RC_FAIL = -1 ,
100- APIPC_RC_SUCCESS = 0
190+ APIPC_RC_FAIL = -1 , /**< FAIL! */
191+ APIPC_RC_SUCCESS = 0 /**< SUCCESS! */
101192};
102193
194+ /**
195+ * \brief apipc private ipc flags definition
196+ *
197+ * There are 32 IPC event signals in each direction between the CPU pairs. apipc
198+ * reserves a few of those ipc flags for his private use.
199+ *
200+ * \note User should prevent occupying or using ipc flags here defined. In case
201+ * this turns inevitable apipc flags could be re-defined and re asigned with the
202+ * precaussion of the case.
203+ *
204+ */
103205enum apipc_flags
104206{
105- APIPC_FLAG_API_INITED = IPC_FLAG4 , /* Local API implementation is inited */
106- APIPC_FLAG_SRAM_ACCES = IPC_FLAG5 , /* Local (CPU1) granted GSMEM acces to CPU2 */
107- APIPC_FLAG_APP_START = IPC_FLAG6 , /* apipc_app started! */
207+ APIPC_FLAG_IRQ_IPC0 = IPC_FLAG0 , /**< g_sIpcController1 interrupt flag */
208+ APIPC_FLAG_IRQ_IPC1 = IPC_FLAG1 , /**< g_sIpcController2 interrupt flag */
108209
109- IPC_FLAG_L_R_ADDR = IPC_FLAG19 ,
110- IPC_FLAG_BLOCK_RECEIVED = IPC_FLAG21 ,
210+ APIPC_FLAG_API_INITED = IPC_FLAG4 , /**< Local apipc implementation inited */
211+ APIPC_FLAG_SRAM_ACCES = IPC_FLAG5 , /**< Local (CPU1) granted GSMEM acces to
212+ remote core (CPU2) */
213+ APIPC_FLAG_APP_START = IPC_FLAG6 , /**< apipc_app has started! */
111214};
112215
216+ /**
217+ * \brief apipc obj type definition
218+ */
113219enum apipc_obj_type
114220{
115- APIPC_OBJ_TYPE_ND = 0 ,
116- APIPC_OBJ_TYPE_BLOCK = 1 ,
117- APIPC_OBJ_TYPE_DATA = 2 ,
118- APIPC_OBJ_TYPE_FLAGS = 3 ,
119- APIPC_OBJ_TYPE_FUNC_CALL = 4 ,
221+ APIPC_OBJ_TYPE_ND = 0 , /**< obj type is undefined */
222+ APIPC_OBJ_TYPE_BLOCK = 1 , /**< obj will be treated as a block */
223+ APIPC_OBJ_TYPE_DATA = 2 , /**< obj will be treated as an unique value */
224+ APIPC_OBJ_TYPE_FLAGS = 3 , /**< obj will be treated as flags */
225+ APIPC_OBJ_TYPE_FUNC_CALL = 4 , /** obj will be treated as a funcion */
120226};
121227
228+ /**
229+ * \brief apipc obj flags definition
230+ */
122231struct apipc_obj_flag
123232{
124- uint16_t startup :1 ;
125- uint16_t error :1 ;
126- uint16_t spare :14 ;
233+ uint16_t startup :1 ; /**< transmit obj on apipc app start up */
234+ uint16_t error :1 ; /**< obj transmition failed retry times */
235+ uint16_t spare :14 ; /** not defined - available */
127236};
128237
238+ /**
239+ * \brief apipc object obj definition
240+ */
129241struct apipc_obj
130242{
131- uint16_t idx ;
132- enum apipc_obj_type type ;
133- enum apipc_obj_sm obj_sm ;
134- void * paddr ;
135- uint32_t payload ; // for func_call use to transfer de argument
136- size_t len ;
137- uint16_t * pGSxM ;
138- uint64_t timer ;
139- uint16_t retry ;
140- struct apipc_obj_flag flag ;
243+ uint16_t idx ; /**< obj index position on l_apipc_obj array */
244+ enum apipc_obj_type type ; /** obj type */
245+ enum apipc_obj_sm obj_sm ; /** actual obj sm state */
246+ void * paddr ; /**< pointer to the obj's local address */
247+ uint32_t payload ; /**< spare data. TODO: implement */
248+ size_t len ; /**< obj length in bytes */
249+ uint16_t * pGSxM ; /**< pointer to the dynamycally allocated memory space on
250+ cl_r_w_data */
251+ uint64_t timer ; /**< start timer value */
252+ uint16_t retry ; /**< retrys counts */
253+ struct apipc_obj_flag flag ; /**< obj flags */
141254};
142255
143256#endif
0 commit comments