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