comparison L1/stand/l1_pei.c @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
1 /*
2 * This is a bastardized version of L1 PEI that will be used only when
3 * building FreeCalypso in the standalone L1 configuration; see README.
4 */
5
6 #define L1_PEI_C
7
8 #define ENTITY_L1
9
10 #define CUST_OS_C
11 /*==== INCLUDES =============================================================*/
12
13 #include <string.h>
14 #include "typedefs.h" /* to get Condat data types */
15 #include "vsi.h" /* to get a lot of macros */
16 #include "pei.h" /* to get PEI interface */
17 #include "tools.h" /* to get common tools */
18 #include "cust_os.h" /* to get cust_os definitions */
19
20 /*==== CONSTS ================================================================*/
21
22 /*==== TYPES =================================================================*/
23
24 typedef struct
25 {
26 char *version;
27 } T_MONITOR;
28
29 /*==== LOCALS ================================================================*/
30
31 static T_MONITOR l1_mon;
32 static USHORT first_access = TRUE;
33
34 static T_HANDLE L1_Handle;
35
36 #define VSI_CALLER L1_Handle,
37
38 static T_HANDLE hCommL1 = VSI_ERROR;
39 static T_HANDLE hCommFWD = VSI_ERROR;
40
41 /*==== PROTOTYPES ============================================================*/
42
43 void l1_create_HISR (void);
44 void l1a_task(unsigned arcg, void *argv);
45
46 /*==== PRIVATE FUNCTIONS =====================================================*/
47
48
49 /*
50 +------------------------------------------------------------------------------
51 | Function : pei_init
52 +------------------------------------------------------------------------------
53 | Description : Initialize Protocol Stack Entity
54 |
55 | Parameters : handle - task handle
56 |
57 | Return : PEI_OK - entity initialised
58 | PEI_ERROR - entity not (yet) initialised
59 +------------------------------------------------------------------------------
60 */
61 LOCAL SHORT pei_init ( T_HANDLE Handle )
62 {
63 L1_Handle = Handle;
64
65 if ( first_access == TRUE )
66 {
67 first_access = FALSE;
68 _osx_init();
69 }
70 /*
71 * Associate own "queue" handle (a task handle in the end) with L1_QUEUE,
72 * in order to be able to receive primitives.
73 */
74 if (hCommL1 < VSI_OK)
75 {
76 if ((hCommL1 = vsi_c_open (VSI_CALLER "L1")) < VSI_OK)
77 return PEI_ERROR;
78 _osx_open (VSI_CALLER L1_QUEUE, hCommL1);
79 }
80
81 /*
82 * Redirect all L1-> outbound messages to our special forwarder
83 * entity; see README for the explanation.
84 */
85
86 if (hCommFWD < VSI_OK)
87 {
88 if ((hCommFWD = vsi_c_open (VSI_CALLER "L1IF")) < VSI_OK)
89 return PEI_ERROR;
90 }
91
92 _osx_open (VSI_CALLER DL_QUEUE, hCommFWD);
93 _osx_open (VSI_CALLER RR_QUEUE, hCommFWD);
94 _osx_open (VSI_CALLER GPF_ACI_QUEUE, hCommFWD);
95 _osx_open (VSI_CALLER GRR_QUEUE, hCommFWD);
96 _osx_open (VSI_CALLER LLC_QUEUE, hCommFWD);
97 _osx_open (VSI_CALLER SNDCP_QUEUE, hCommFWD);
98
99 /*
100 * Register VSI_CALLER as generic caller entity.
101 */
102 _osx_open (VSI_CALLER 0, 0);
103
104 l1_create_HISR ();
105
106 return PEI_OK;
107 }
108
109 /*
110 +------------------------------------------------------------------------------
111 | Function : pei_run
112 +------------------------------------------------------------------------------
113 | Description : Process Primitives, main loop is located in the
114 | Protocol Stack Entity.
115 | Only needed in active body variant
116 |
117 | Parameters : taskhandle - handle of current process
118 | comhandle - queue handle of current process
119 |
120 | Return : PEI_OK - sucessful
121 | PEI_ERROR - not successful
122 +------------------------------------------------------------------------------
123 */
124 LOCAL SHORT pei_run ( T_HANDLE taskhandle, T_HANDLE comhandle )
125 {
126 hCommL1 = comhandle;
127
128 l1a_task (0, NULL);
129 return PEI_OK;
130 }
131
132 /*
133 +------------------------------------------------------------------------------
134 | Function : pei_config
135 +------------------------------------------------------------------------------
136 | Description : Dynamic Configuration.
137 |
138 | Parameters : in_string - configuration string
139 |
140 | Return : PEI_OK - sucessful
141 | PEI_ERROR - not successful
142 +------------------------------------------------------------------------------
143 */
144 LOCAL SHORT pei_config (T_PEI_CONFIG inString)
145 {
146
147
148 if ( _osx_config ( inString ) == OSX_OK )
149 return PEI_OK;
150 else
151 return PEI_ERROR;
152 }
153
154 /*
155 +------------------------------------------------------------------------------
156 | Function : pei_monitor
157 +------------------------------------------------------------------------------
158 | Description : Monitoring of physical Parameters.
159 |
160 | Parameters : out_monitor - return the address of the data to be monitored
161 |
162 | Return : PEI_OK - sucessful (address in out_monitor is valid)
163 | PEI_ERROR - not successful
164 +------------------------------------------------------------------------------
165 */
166 LOCAL SHORT pei_monitor (void ** monitor)
167 {
168 l1_mon.version = "FC standalone L1";
169 *monitor = &l1_mon;
170
171 return PEI_OK;
172 }
173
174
175 /*==== PUBLIC FUNCTIONS =====================================================*/
176
177 /*
178 +------------------------------------------------------------------------------
179 | Function : pei_create
180 +------------------------------------------------------------------------------
181 | Description : Create the Protocol Stack Entity.
182 |
183 | Parameters : info - Pointer to the structure of entity parameters
184 |
185 | Return : PEI_OK - entity created successfully
186 |
187 +------------------------------------------------------------------------------
188 */
189 GLOBAL SHORT l1_pei_create ( T_PEI_INFO **info )
190 {
191 static T_PEI_INFO pei_info =
192 {
193 "L1",
194 {
195 pei_init,
196 NULL,
197 NULL, /* no primitive function */
198 NULL, /* no timeout function */
199 NULL, /* no signal function */
200 pei_run,
201 pei_config,
202 pei_monitor,
203 },
204 2800, /* Stack Size */
205 10, /* Queue Entries */
206 235, /* Priority */
207 0, /* number of timer */
208 COPY_BY_REF|TRC_NO_SUSPEND|PRIM_NO_SUSPEND /* flags */
209 };
210
211 /*
212 * export startup configuration data
213 */
214 *info = &pei_info;
215 /*
216 * Initialize entity data
217 */
218
219 return PEI_OK;
220 }
221
222 /*==== END OF FILE ==========================================================*/