comparison src/cs/drivers/drv_app/rtc/rtc_env.c @ 0:4e78acac3d88

src/{condat,cs,gpf,nucleus}: import from Selenite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:23:26 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4e78acac3d88
1 /********************************************************************************/
2 /* */
3 /* File Name: rtc_env.c */
4 /* */
5 /* Purpose: This file contains routines that will be called in order */
6 /* to: */
7 /* - notify the Riviera manager of the RTC's Memory */
8 /* Banks requirements, */
9 /* - initialize all the RTC's data structures, */
10 /* */
11 /* Note: None. */
12 /* */
13 /* Revision History: */
14 /* 03/22/01 Laurent Sollier Create. */
15 /* */
16 /* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved */
17 /* */
18 /********************************************************************************/
19
20 #include "rvm/rvm_priorities.h"
21 #include "rvm/rvm_use_id_list.h"
22 #include "rtc/rtc_env.h"
23 #include "rtc/rtc_i.h"
24 #include "rtc/rtc_api.h"
25 #include <string.h>
26
27
28 /* Define a pointer to the RTC environment control block */
29 T_RTC_ENV_CTRL_BLK *rtc_env_ctrl_blk = NULL;
30
31 /* External declaration */
32 extern T_RV_RET rtc_core(void);
33
34 /* Define global pointer to the error function */
35
36 static T_RVM_RETURN (*rtc_error_ft) (T_RVM_NAME swe_name,
37 T_RVM_RETURN error_cause,
38 T_RVM_ERROR_TYPE error_type,
39 T_RVM_STRING error_msg);
40
41
42 /******************************************************************************
43 * Function : rtc_get_info
44 *
45 * Description : This function is called by the RV manager to learn
46 * rtc requirements in terms of memory, SWEs...
47 *
48 * Parameters : T_RVM_INFO_SWE * swe_info: pointer to the structure to fill
49 * containing infos related to the rtc SWE.
50 *
51 * Return : T_RVM_RETURN
52 *
53 * History : 0.1 (22-March-2001)
54 *
55 *
56 ******************************************************************************/
57 T_RVM_RETURN rtc_get_info(T_RVM_INFO_SWE* swe_info)
58 {
59 /* SWE info */
60 swe_info->swe_type = RVM_SWE_TYPE_4;
61 swe_info->type_info.type4.swe_use_id = RTC_USE_ID;
62 memcpy( swe_info->type_info.type4.swe_name, "RTC", sizeof("RTC") );
63
64 swe_info->type_info.type4.stack_size = RTC_STACK_SIZE;
65 swe_info->type_info.type4.priority = RVM_RTC_TASK_PRIORITY;
66
67 /* Set the return path */
68 swe_info->type_info.type4.return_path.callback_func = NULL;
69 swe_info->type_info.type4.return_path.addr_id = 0;
70
71
72 /* memory bank info */
73 swe_info->type_info.type4.nb_mem_bank = 1;
74
75 memcpy ((UINT8 *) swe_info->type_info.type4.mem_bank[0].bank_name, "RTC_PRIM", 9);
76 swe_info->type_info.type4.mem_bank[0].initial_params.size = RTC_MB_PRIM_SIZE;
77 swe_info->type_info.type4.mem_bank[0].initial_params.watermark = RTC_MB_PRIM_WATERMARK;
78
79 /* linked SWE info */
80 /* this SWE does not require any SWE to run */
81 swe_info->type_info.type4.nb_linked_swe = 0;
82
83 /* generic functions */
84 swe_info->type_info.type4.set_info = rtc_set_info;
85 swe_info->type_info.type4.init = rtc_init;
86 swe_info->type_info.type4.core = rtc_core;
87 swe_info->type_info.type4.stop = rtc_stop;
88 swe_info->type_info.type4.kill = rtc_kill;
89
90 return RV_OK;
91 }
92
93
94 /******************************************************************************
95 * Function : rtc_set_info
96 *
97 * Description : This function is called by the RV manager to inform
98 * the rtc SWE about task_id, mb_id and error function.
99 *
100 * Parameters : - T_RVF_ADDR_ID addrId: Address id.
101 * - T_RVF_MB_ID mbId[]: array of memory bank ids.
102 * - callback function to call in case of unrecoverable error.
103 *
104 * Return : T_RVM_RETURN
105 *
106 * History : 0.1 (22-March-2001)
107 *
108 *
109 ******************************************************************************/
110 T_RVM_RETURN rtc_set_info(T_RVF_ADDR_ID addrId,
111 T_RV_RETURN return_path[],
112 T_RVF_MB_ID mbId[],
113 T_RVM_RETURN (*callBackFct) (T_RVM_NAME SWEntName,
114 T_RVM_RETURN errorCause,
115 T_RVM_ERROR_TYPE errorType,
116 T_RVM_STRING errorMsg) )
117 {
118 T_RVF_MB_STATUS mb_status;
119
120
121 rvf_send_trace("RTC : rtc_set_info: try to init GLOBAL INFO RTC structure ... ",62,
122 NULL_PARAM,
123 RV_TRACE_LEVEL_DEBUG_HIGH,
124 RTC_USE_ID);
125
126 mb_status = rvf_get_buf(mbId[0],sizeof(T_RTC_ENV_CTRL_BLK),(void **) &rtc_env_ctrl_blk);
127
128 if (mb_status == RVF_RED)
129 {
130 rvf_send_trace("RTC : rtc_set_info: Not enough memory to initiate GLOBAL INFO RTC structure ... ",86,
131 NULL_PARAM,
132 RV_TRACE_LEVEL_ERROR,
133 RTC_USE_ID);
134
135 return (RVM_MEMORY_ERR);
136 }
137
138
139 /* store the pointer to the error function */
140 rtc_error_ft = callBackFct ;
141
142 rtc_env_ctrl_blk->prim_id = mbId[0];
143 rtc_env_ctrl_blk->addr_id = addrId;
144
145
146 return RV_OK;
147 }
148
149
150 /******************************************************************************
151 * Function : rtc_init
152 *
153 * Description : This function is called by the RV manager to initialize the
154 * rtc SWE before creating the task and calling rtc_start.
155 *
156 * Parameters : None
157 *
158 * Return : T_RVM_RETURN
159 *
160 * History : 0.1 (22-March-2001)
161 *
162 *
163 ******************************************************************************/
164 T_RVM_RETURN rtc_init(void)
165 {
166 return RTC_Initialize();
167 }
168
169
170 /******************************************************************************
171 * Function : rtc_stop
172 *
173 * Description : This function is called by the RV manager to stop the rtc SWE.
174 *
175 * Parameters : None
176 *
177 * Return : T_RVM_RETURN
178 *
179 * History : 0.1 (22-March-2001)
180 *
181 *
182 ******************************************************************************/
183 T_RVM_RETURN rtc_stop(void)
184 {
185 /* other SWEs have not been killed yet, rtc can send messages to other SWEs */
186
187 return RV_OK;
188 }
189
190
191 /******************************************************************************
192 * Function : rtc_kill
193 *
194 * Description : This function is called by the RV manager to kill the rtc
195 * SWE, after the rtc_stop function has been called.
196 *
197 * Parameters : None
198 *
199 * Return : T_RVM_RETURN
200 *
201 * History : 0.1 (22-March-2001)
202 *
203 *
204 ******************************************************************************/
205 T_RVM_RETURN rtc_kill (void)
206 {
207 /* free all memory buffer previously allocated */
208 rvf_free_buf ((void *) rtc_env_ctrl_blk->msg_alarm_event);
209 rvf_free_buf ((void *) rtc_env_ctrl_blk);
210
211 return RV_OK;
212 }