comparison 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
comparison
equal deleted inserted replaced
293:2d7d95e7f9c2 294:e17bdedfbf2b
1 /*
2 * This module provides the glue to the RiViera environment
3 * for our VIBR SWE.
4 */
5
6 #include "vibr/vibr_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 /* global control block for our SWE */
15 struct vibr_env *vibr_env;
16
17 /* Define global pointer to the error function */
18 static T_RVM_RETURN (*xxx_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 vibr_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 = VIBR_USE_ID;
29 memcpy( infoSWE->type_info.type4.swe_name, "VIBR", 5 );
30
31 infoSWE->type_info.type4.stack_size = VIBR_STACK_SIZE;
32 infoSWE->type_info.type4.priority = RVM_VIBR_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, "VIBR_PRIM", 10);
38 infoSWE->type_info.type4.mem_bank[0].initial_params.size = VIBR_MB_PRIM_SIZE;
39 infoSWE->type_info.type4.mem_bank[0].initial_params.watermark = VIBR_MB_PRIM_WATERMARK;
40
41 /* linked SWE info: none */
42 infoSWE->type_info.type4.nb_linked_swe = 0;
43
44 /* generic functions */
45 infoSWE->type_info.type4.set_info = vibr_set_info;
46 infoSWE->type_info.type4.init = vibr_init;
47 infoSWE->type_info.type4.core = vibr_core;
48 infoSWE->type_info.type4.stop = vibr_stop;
49 infoSWE->type_info.type4.kill = vibr_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 vibr_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(struct vibr_env),(void **) &vibr_env);
70 if (mb_status == RVF_RED)
71 {
72 rvf_send_trace("vibr_set_info: rvf_get_buf() failed", 35,
73 NULL_PARAM, RV_TRACE_LEVEL_ERROR, VIBR_USE_ID);
74 return (RVM_MEMORY_ERR);
75 }
76 memset(vibr_env, 0, sizeof(struct vibr_env));
77
78 /* store the pointer to the error function */
79 xxx_error_ft = callBackFct ;
80
81 /* Store the addr id */
82 vibr_env->addr_id = addr_id;
83
84 /* Store the memory bank id */
85 vibr_env->prim_id = mbId[0];
86
87 return RV_OK;
88 }
89
90 T_RVM_RETURN vibr_init(void)
91 {
92 return RV_OK;
93 }
94
95 T_RVM_RETURN vibr_stop(void)
96 {
97 return RV_OK;
98 }
99
100 T_RVM_RETURN vibr_kill(void)
101 {
102 /* free all memory buffer previously allocated */
103 rvf_free_buf ((void *) vibr_env);
104
105 return RV_OK;
106 }