comparison chipsetsw/drivers/drv_app/kpd/kpd_env.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 /**
2 * @file kpd_env.c
3 *
4 * Coding of the Riviera Generic Functions
5 * (except handle message and handle timer).
6 *
7 * @author Laurent Sollier (l-sollier@ti.com)
8 * @version 0.1
9 */
10
11 /*
12 * History:
13 *
14 * Date Author Modification
15 * ----------------------------------------
16 * 10/10/2001 L Sollier Create
17 *
18 *
19 * (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved
20 */
21
22
23
24 #include "kpd/kpd_env.h"
25 #include "kpd/kpd_i.h"
26
27 #include "rvm/rvm_priorities.h"
28 #include "rvm/rvm_use_id_list.h"
29
30 #include <string.h>
31
32
33 /* External declaration */
34 extern T_RV_RET kpd_core(void);
35
36
37 /**
38 * Pointer on the structure gathering all the global variables
39 * used by KPD instance.
40 */
41 T_KPD_ENV_CTRL_BLK* kpd_env_ctrl_blk = NULL;
42
43
44 /**
45 * @name Riviera generic functions implementation
46 *
47 */
48 /*@{*/
49
50 /**
51 * function: kpd_get_info
52 */
53 T_RVM_RETURN kpd_get_info(T_RVM_INFO_SWE* swe_info)
54 {
55 /* SWE info */
56 swe_info->swe_type = RVM_SWE_TYPE_4;
57 swe_info->type_info.type4.swe_use_id = KPD_USE_ID;
58
59 memcpy( swe_info->type_info.type4.swe_name, "KPD", sizeof("KPD") );
60
61 swe_info->type_info.type4.stack_size = KPD_STACK_SIZE;
62 swe_info->type_info.type4.priority = RVM_KPD_TASK_PRIORITY;
63
64
65 /* Set the return path */
66 swe_info->type_info.type4.return_path.callback_func = NULL;
67 swe_info->type_info.type4.return_path.addr_id = 0;
68
69
70 /* memory bank info */
71 swe_info->type_info.type4.nb_mem_bank = 1;
72
73 memcpy ((UINT8 *) swe_info->type_info.type4.mem_bank[0].bank_name, "KPD_PRIM", 9);
74 swe_info->type_info.type4.mem_bank[0].initial_params.size = KPD_MB_PRIM_SIZE;
75 swe_info->type_info.type4.mem_bank[0].initial_params.watermark = KPD_MB_PRIM_WATERMARK;
76
77 /* linked SWE info */
78 /* this SWE does not require any SWE to run */
79 swe_info->type_info.type4.nb_linked_swe = 0;
80
81 /* generic functions */
82 swe_info->type_info.type4.set_info = kpd_set_info;
83 swe_info->type_info.type4.init = kpd_init;
84 swe_info->type_info.type4.core = kpd_core;
85 swe_info->type_info.type4.stop = kpd_stop;
86 swe_info->type_info.type4.kill = kpd_kill;
87
88 return RVM_OK;
89
90 }
91
92
93 /**
94 * function: kpd_set_info
95 */
96 T_RVM_RETURN kpd_set_info (T_RVF_ADDR_ID addr_id,
97 T_RV_RETURN return_path[],
98 T_RVF_MB_ID bk_id[],
99 T_RVM_RETURN (*rvm_error_ft)(T_RVM_NAME swe_name,
100 T_RVM_RETURN error_cause,
101 T_RVM_ERROR_TYPE error_type,
102 T_RVM_STRING error_msg))
103 {
104 /* Create instance gathering all the variable used by EXPL instance */
105 if (rvf_get_buf(bk_id[0],
106 sizeof(T_KPD_ENV_CTRL_BLK),
107 (T_RVF_BUFFER**)&kpd_env_ctrl_blk) != RVF_GREEN)
108 {
109 /* The environemnt will cancel the EXPL instance creation. */
110 return RVM_MEMORY_ERR;
111 }
112
113 /* Store the pointer to the error function */
114 kpd_env_ctrl_blk->error_ft = rvm_error_ft ;
115 /* Store the mem bank id. */
116 kpd_env_ctrl_blk->prim_id = bk_id[0];
117 /* Store the address id */
118 kpd_env_ctrl_blk->addr_id = addr_id;
119 kpd_env_ctrl_blk->swe_is_initialized = FALSE;
120
121
122 /* return_path of linked SWE -> not used */
123
124 return RVM_OK;
125 }
126
127
128 /**
129 * function: kpd_init
130 */
131 T_RVM_RETURN kpd_init(void)
132 {
133 T_RV_RET ret = RV_OK;
134
135 /* Initialise keypad driver */
136 ret = kpd_initialize_keypad_driver();
137
138 /* Note that the (kpd_env_ctrl_blk != 0) check is normally
139 useless because if kpd_set_info fail, kpd_init will not
140 be called */
141 if ( (ret == RV_OK) && (kpd_env_ctrl_blk != 0))
142 {
143 kpd_env_ctrl_blk->swe_is_initialized = TRUE;
144 }
145
146 return ret;
147 }
148
149
150 /**
151 * function: kpd_stop
152 */
153 T_RVM_RETURN kpd_stop(void)
154 {
155 /* NB: Other SWEs have not been killed yet, kpd can send messages to other SWEs. */
156
157 return RVM_OK;
158 }
159
160
161 /**
162 * function: kpd_kill
163 */
164 T_RVM_RETURN kpd_kill (void)
165 {
166 /*
167 * DO NOT SEND MESSAGES
168 */
169 rvf_free_buf(kpd_env_ctrl_blk);
170
171 kpd_kill_keypad_driver();
172
173 return RVM_OK;
174 }
175
176
177 /*@}*/