annotate src/cs/services/vibr/vibr_env.c @ 294:e17bdedfbf2b

VIBR SWE initial implementation
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 27 Mar 2022 08:46:10 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
294
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module provides the glue to the RiViera environment
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * for our VIBR SWE.
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include "vibr/vibr_env.h"
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include "rv/rv_general.h"
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include "rvf/rvf_api.h"
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include "rvm/rvm_priorities.h"
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "rvm/rvm_api.h"
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "rvm/rvm_use_id_list.h"
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <string.h>
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 /* global control block for our SWE */
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 struct vibr_env *vibr_env;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 /* Define global pointer to the error function */
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 static T_RVM_RETURN (*xxx_error_ft) (T_RVM_NAME swe_name,
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 T_RVM_RETURN error_cause,
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 T_RVM_ERROR_TYPE error_type,
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 T_RVM_STRING error_msg);
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 T_RVM_RETURN vibr_get_info (T_RVM_INFO_SWE *infoSWE)
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 {
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 /* SWE info */
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 infoSWE->swe_type = RVM_SWE_TYPE_4;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 infoSWE->type_info.type4.swe_use_id = VIBR_USE_ID;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 memcpy( infoSWE->type_info.type4.swe_name, "VIBR", 5 );
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 infoSWE->type_info.type4.stack_size = VIBR_STACK_SIZE;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 infoSWE->type_info.type4.priority = RVM_VIBR_TASK_PRIORITY;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 /* memory bank info */
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 infoSWE->type_info.type4.nb_mem_bank = 1;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 memcpy ((UINT8 *) infoSWE->type_info.type4.mem_bank[0].bank_name, "VIBR_PRIM", 10);
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 infoSWE->type_info.type4.mem_bank[0].initial_params.size = VIBR_MB_PRIM_SIZE;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 infoSWE->type_info.type4.mem_bank[0].initial_params.watermark = VIBR_MB_PRIM_WATERMARK;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 /* linked SWE info: none */
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 infoSWE->type_info.type4.nb_linked_swe = 0;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 /* generic functions */
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 infoSWE->type_info.type4.set_info = vibr_set_info;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 infoSWE->type_info.type4.init = vibr_init;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 infoSWE->type_info.type4.core = vibr_core;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 infoSWE->type_info.type4.stop = vibr_stop;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 infoSWE->type_info.type4.kill = vibr_kill;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 /* Set the return path */
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 infoSWE->type_info.type4.return_path.callback_func = NULL;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 infoSWE->type_info.type4.return_path.addr_id = 0;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 return RV_OK;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 }
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 T_RVM_RETURN vibr_set_info(T_RVF_ADDR_ID addr_id,
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 T_RV_RETURN return_path[],
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 T_RVF_MB_ID mbId[],
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 T_RVM_RETURN (*callBackFct) (T_RVM_NAME SWEntName,
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 T_RVM_RETURN errorCause,
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 T_RVM_ERROR_TYPE errorType,
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 T_RVM_STRING errorMsg))
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 {
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 T_RVF_MB_STATUS mb_status;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 mb_status = rvf_get_buf(mbId[0],sizeof(struct vibr_env),(void **) &vibr_env);
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 if (mb_status == RVF_RED)
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 {
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 rvf_send_trace("vibr_set_info: rvf_get_buf() failed", 35,
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 NULL_PARAM, RV_TRACE_LEVEL_ERROR, VIBR_USE_ID);
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 return (RVM_MEMORY_ERR);
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 }
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 memset(vibr_env, 0, sizeof(struct vibr_env));
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 /* store the pointer to the error function */
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 xxx_error_ft = callBackFct ;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 /* Store the addr id */
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 vibr_env->addr_id = addr_id;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 /* Store the memory bank id */
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 vibr_env->prim_id = mbId[0];
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 return RV_OK;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 }
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 T_RVM_RETURN vibr_init(void)
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 {
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 return RV_OK;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 }
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 T_RVM_RETURN vibr_stop(void)
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 {
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 return RV_OK;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 }
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 T_RVM_RETURN vibr_kill(void)
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 {
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 /* free all memory buffer previously allocated */
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 rvf_free_buf ((void *) vibr_env);
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 return RV_OK;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 }