comparison src/cs/drivers/drv_app/fchg/fchg_env.c @ 322:c4077830aeeb

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