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