comparison src/cs/drivers/drv_app/fchg/fchg_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 eacfad198b8b
comparison
equal deleted inserted replaced
-1:000000000000 0:4e78acac3d88
1 /*
2 * This module provides the glue to the RiViera environment
3 * for our FCHG SWE.
4 */
5
6 #include "fchg/fchg_env.h"
7 #include "rv/rv_general.h"
8 #include "rvf/rvf_api.h"
9 #include "rvm/rvm_priorities.h"
10 #include "rvm/rvm_api.h"
11 #include "rvm/rvm_use_id_list.h"
12 #include <string.h>
13
14 /* Define a pointer to the PWR environment control block */
15 T_PWR_CTRL_BLOCK *pwr_ctrl = NULL;
16
17 /* Define global pointer to the error function */
18 static T_RVM_RETURN (*pwr_error_ft) (T_RVM_NAME swe_name,
19 T_RVM_RETURN error_cause,
20 T_RVM_ERROR_TYPE error_type,
21 T_RVM_STRING error_msg);
22
23 T_RVM_RETURN fchg_get_info (T_RVM_INFO_SWE *infoSWE)
24 {
25 /* SWE info */
26
27 infoSWE->swe_type = RVM_SWE_TYPE_4;
28 infoSWE->type_info.type4.swe_use_id = FCHG_USE_ID;
29 memcpy( infoSWE->type_info.type4.swe_name, "FCHG", 5 );
30
31 infoSWE->type_info.type4.stack_size = FCHG_STACK_SIZE;
32 infoSWE->type_info.type4.priority = RVM_LCC_TASK_PRIORITY;
33
34 /* memory bank info */
35 infoSWE->type_info.type4.nb_mem_bank = 1;
36
37 memcpy ((UINT8 *) infoSWE->type_info.type4.mem_bank[0].bank_name, "FCHG_PRIM", 10);
38 infoSWE->type_info.type4.mem_bank[0].initial_params.size = FCHG_MB_PRIM_SIZE;
39 infoSWE->type_info.type4.mem_bank[0].initial_params.watermark = FCHG_MB_PRIM_WATERMARK;
40
41 /* linked SWE info: we use FFS */
42 infoSWE->type_info.type4.nb_linked_swe = 1;
43 infoSWE->type_info.type4.linked_swe_id[0] = FFS_USE_ID;
44
45 /* generic functions */
46 infoSWE->type_info.type4.set_info = fchg_set_info;
47 infoSWE->type_info.type4.init = fchg_init;
48 infoSWE->type_info.type4.core = fchg_core;
49 infoSWE->type_info.type4.stop = fchg_stop;
50 infoSWE->type_info.type4.kill = fchg_kill;
51
52 /* Set the return path */
53 infoSWE->type_info.type4.return_path.callback_func = NULL;
54 infoSWE->type_info.type4.return_path.addr_id = 0;
55
56 return RV_OK;
57 }
58
59 T_RVM_RETURN fchg_set_info(T_RVF_ADDR_ID addr_id,
60 T_RV_RETURN return_path[],
61 T_RVF_MB_ID mbId[],
62 T_RVM_RETURN (*callBackFct) (T_RVM_NAME SWEntName,
63 T_RVM_RETURN errorCause,
64 T_RVM_ERROR_TYPE errorType,
65 T_RVM_STRING errorMsg))
66 {
67
68 T_RVF_MB_STATUS mb_status;
69
70 mb_status = rvf_get_buf(mbId[0],sizeof(T_PWR_CTRL_BLOCK),(void **) &pwr_ctrl);
71 if (mb_status == RVF_RED)
72 {
73 rvf_send_trace("fchg_set_info: rvf_get_buf() failed", 35,
74 NULL_PARAM,
75 RV_TRACE_LEVEL_ERROR,
76 FCHG_USE_ID);
77 return (RVM_MEMORY_ERR);
78 }
79 memset(pwr_ctrl, 0, sizeof(T_PWR_CTRL_BLOCK));
80
81 /* store the pointer to the error function */
82 pwr_error_ft = callBackFct ;
83
84 /* Store the addr id */
85 pwr_ctrl->addr_id = addr_id;
86
87 /* Store the memory bank id */
88 pwr_ctrl->prim_id = mbId[0];
89
90 return RV_OK;
91 }
92
93 T_RVM_RETURN fchg_init(void)
94 {
95 return RV_OK;
96 }
97
98 T_RVM_RETURN fchg_stop(void)
99 {
100 return RV_OK;
101 }
102
103 T_RVM_RETURN fchg_kill(void)
104 {
105 /* free all memory buffer previously allocated */
106 rvf_free_buf ((void *) pwr_ctrl);
107
108 return RV_OK;
109 }