comparison src/cs/services/buzm/buzm_env.c @ 297:8dfdf88d632f

BUZM SWE initial implementation
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 29 Mar 2022 03:45:41 +0000
parents
children
comparison
equal deleted inserted replaced
296:a927f030a4e0 297:8dfdf88d632f
1 /*
2 * This module provides the glue to the RiViera environment
3 * for our BUZM SWE.
4 */
5
6 #include "buzm/buzm_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 buzm_env *buzm_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 buzm_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 = BUZM_USE_ID;
29 memcpy( infoSWE->type_info.type4.swe_name, "BUZM", 5 );
30
31 infoSWE->type_info.type4.stack_size = BUZM_STACK_SIZE;
32 infoSWE->type_info.type4.priority = RVM_BUZM_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, "BUZM_PRIM", 10);
38 infoSWE->type_info.type4.mem_bank[0].initial_params.size = BUZM_MB_PRIM_SIZE;
39 infoSWE->type_info.type4.mem_bank[0].initial_params.watermark = BUZM_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 = buzm_set_info;
47 infoSWE->type_info.type4.init = buzm_init;
48 infoSWE->type_info.type4.core = buzm_core;
49 infoSWE->type_info.type4.stop = buzm_stop;
50 infoSWE->type_info.type4.kill = buzm_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 buzm_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(struct buzm_env),(void **) &buzm_env);
71 if (mb_status == RVF_RED)
72 {
73 rvf_send_trace("buzm_set_info: rvf_get_buf() failed", 35,
74 NULL_PARAM, RV_TRACE_LEVEL_ERROR, BUZM_USE_ID);
75 return (RVM_MEMORY_ERR);
76 }
77 memset(buzm_env, 0, sizeof(struct buzm_env));
78
79 /* store the pointer to the error function */
80 xxx_error_ft = callBackFct ;
81
82 /* Store the addr id */
83 buzm_env->addr_id = addr_id;
84
85 /* Store the memory bank id */
86 buzm_env->prim_id = mbId[0];
87
88 return RV_OK;
89 }
90
91 T_RVM_RETURN buzm_init(void)
92 {
93 return RV_OK;
94 }
95
96 T_RVM_RETURN buzm_stop(void)
97 {
98 return RV_OK;
99 }
100
101 T_RVM_RETURN buzm_kill(void)
102 {
103 /* free all memory buffer previously allocated */
104 rvf_free_buf ((void *) buzm_env);
105
106 return RV_OK;
107 }