FreeCalypso > hg > fc-tourmaline
comparison src/ui/bmi/mmiBlkManager.c @ 140:1c4536a30e32
mmiBlkManager.c: bogotab fixes
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 14 Nov 2020 04:27:10 +0000 |
parents | c0052fe355d3 |
children |
comparison
equal
deleted
inserted
replaced
139:66e0b6a40e09 | 140:1c4536a30e32 |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 | 2 |
3 CONDAT (UK) | 3 CONDAT (UK) |
4 | 4 |
5 ******************************************************************************** | 5 ******************************************************************************** |
6 | 6 |
7 This software product is the property of Condat (UK) Ltd and may not be | 7 This software product is the property of Condat (UK) Ltd and may not be |
8 disclosed to any third party without the express permission of the owner. | 8 disclosed to any third party without the express permission of the owner. |
9 | 9 |
10 ******************************************************************************** | 10 ******************************************************************************** |
11 | 11 |
12 $Project name: Basic MMI | 12 $Project name: Basic MMI |
13 $Project code: BMI (6349) | 13 $Project code: BMI (6349) |
14 $Module: PhoneBook | 14 $Module: PhoneBook |
15 $File: MmiBlkManager.c | 15 $File: MmiBlkManager.c |
16 $Revision: 1.0 | 16 $Revision: 1.0 |
17 | 17 |
18 $Author: Condat(UK) | 18 $Author: Condat(UK) |
19 $Date: 25/10/00 | 19 $Date: 25/10/00 |
20 | 20 |
21 ******************************************************************************** | 21 ******************************************************************************** |
22 | 22 |
23 Description: | 23 Description: |
24 | 24 |
25 This module, in conjunction with the MmiBlkResources module, | 25 This module, in conjunction with the MmiBlkResources module, |
26 provides the access to block resources for the MMI. | 26 provides the access to block resources for the MMI. |
27 | 27 |
28 The block manager is responsible for creating and initialising | 28 The block manager is responsible for creating and initialising |
29 the structures and tables to allow access to the strings, icons | 29 the structures and tables to allow access to the strings, icons |
30 sounds and vibrations required by the MMI. | 30 sounds and vibrations required by the MMI. |
31 | 31 |
35 | 35 |
36 ******************************************************************************** | 36 ******************************************************************************** |
37 | 37 |
38 $History: MmiBlkManager.c | 38 $History: MmiBlkManager.c |
39 | 39 |
40 25/10/00 Original Condat(UK) BMI version. | 40 25/10/00 Original Condat(UK) BMI version. |
41 | 41 |
42 $End | 42 $End |
43 | 43 |
44 *******************************************************************************/ | 44 *******************************************************************************/ |
45 | 45 |
91 #define BLOCK_MANAGER_KEY 0x00BABE01L | 91 #define BLOCK_MANAGER_KEY 0x00BABE01L |
92 #define BLOCK_MANAGER_ENTRY_COUNT 0x00000010L | 92 #define BLOCK_MANAGER_ENTRY_COUNT 0x00000010L |
93 | 93 |
94 typedef struct _tManagerEntry_ | 94 typedef struct _tManagerEntry_ |
95 { | 95 { |
96 tBlkId Id; | 96 tBlkId Id; |
97 int NumEntries; | 97 int NumEntries; |
98 tBlkHandle EntryBase; | 98 tBlkHandle EntryBase; |
99 } tManagerEntry, *pManagerEntry; | 99 } tManagerEntry, *pManagerEntry; |
100 | 100 |
101 typedef struct _tManagerControl_ | 101 typedef struct _tManagerControl_ |
102 { | 102 { |
103 long int BlkKey; | 103 long int BlkKey; |
104 tBlkHandle BaseAddress; | 104 tBlkHandle BaseAddress; |
105 int BlkLength; | 105 int BlkLength; |
106 tBlkHandle RsrcList[BLOCK_MANAGER_ENTRY_COUNT]; | 106 tBlkHandle RsrcList[BLOCK_MANAGER_ENTRY_COUNT]; |
107 pManagerEntry EntryPtr; | 107 pManagerEntry EntryPtr; |
108 } tManagerControl, *pManagerControl; | 108 } tManagerControl, *pManagerControl; |
109 | 109 |
110 | 110 |
111 /******************************************************************************* | 111 /******************************************************************************* |
112 | 112 |
114 | 114 |
115 *******************************************************************************/ | 115 *******************************************************************************/ |
116 | 116 |
117 /******************************************************************************* | 117 /******************************************************************************* |
118 | 118 |
119 $Function: ValidManagerResource | 119 $Function: ValidManagerResource |
120 | 120 |
121 $Description: Determines if the resource indicated by the handle is valid | 121 $Description: Determines if the resource indicated by the handle is valid |
122 | 122 |
123 $Returns: Zero if failure, non-zero if valid resource | 123 $Returns: Zero if failure, non-zero if valid resource |
124 | 124 |
125 $Arguments: ManagerRsrc, handle of resource manager | 125 $Arguments: ManagerRsrc, handle of resource manager |
126 | 126 |
127 *******************************************************************************/ | 127 *******************************************************************************/ |
128 | 128 |
129 static int ValidManagerResource( tBlkHandle ManagerRsrc ) | 129 static int ValidManagerResource( tBlkHandle ManagerRsrc ) |
130 { | 130 { |
131 pManagerControl ManagerControl = (pManagerControl) ManagerRsrc; | 131 pManagerControl ManagerControl = (pManagerControl) ManagerRsrc; |
132 | 132 |
133 if ( ManagerControl == NULL ) | 133 if ( ManagerControl == NULL ) |
134 return 0; | 134 return 0; |
135 | 135 |
136 return ( ManagerControl->BlkKey == BLOCK_MANAGER_KEY ); | 136 return ( ManagerControl->BlkKey == BLOCK_MANAGER_KEY ); |
137 } | 137 } |
138 | 138 |
139 | 139 |
140 /******************************************************************************* | 140 /******************************************************************************* |
141 | 141 |
144 *******************************************************************************/ | 144 *******************************************************************************/ |
145 | 145 |
146 | 146 |
147 /******************************************************************************* | 147 /******************************************************************************* |
148 | 148 |
149 $Function: mmibm_Initialise | 149 $Function: mmibm_Initialise |
150 | 150 |
151 $Description: Initialise a block manager object | 151 $Description: Initialise a block manager object |
152 | 152 |
153 $Returns: Handle of block manager object, NULL if failure | 153 $Returns: Handle of block manager object, NULL if failure |
154 | 154 |
155 $Arguments: BlkBase, base address of the block manager data | 155 $Arguments: BlkBase, base address of the block manager data |
156 NumEntries, number of entries to be dealt with by the | 156 NumEntries, number of entries to be dealt with by the |
157 block manager | 157 block manager |
158 | 158 |
159 *******************************************************************************/ | 159 *******************************************************************************/ |
160 | 160 |
161 tBlkHandle mmibm_Initialise( tBlkHandle BlkBase, int NumEntries ) | 161 tBlkHandle mmibm_Initialise( tBlkHandle BlkBase, int NumEntries ) |
162 { | 162 { |
163 pManagerControl MyControl; | 163 pManagerControl MyControl; |
164 tBlkId Entry; | 164 tBlkId Entry; |
165 int i; | 165 int i; |
166 | 166 |
167 if ( ( MyControl = (pManagerControl) ALLOC_MEMORY( sizeof(tManagerControl) ) ) != NULL ) | 167 if ( ( MyControl = (pManagerControl) ALLOC_MEMORY( sizeof(tManagerControl) ) ) != NULL ) |
168 { | 168 { |
169 /* Fill in the bits we know are pretty constant | 169 /* Fill in the bits we know are pretty constant |
170 */ | 170 */ |
171 MyControl->BlkKey = BLOCK_MANAGER_KEY; | 171 MyControl->BlkKey = BLOCK_MANAGER_KEY; |
172 MyControl->BaseAddress = BlkBase; | 172 MyControl->BaseAddress = BlkBase; |
173 MyControl->BlkLength = NumEntries; | 173 MyControl->BlkLength = NumEntries; |
174 MyControl->EntryPtr = (pManagerEntry) BlkBase; | 174 MyControl->EntryPtr = (pManagerEntry) BlkBase; |
175 | 175 |
176 /* Initialise the handle array to empty initially | 176 /* Initialise the handle array to empty initially |
177 */ | 177 */ |
178 for ( i = 0; i < BLOCK_MANAGER_ENTRY_COUNT; i++ ) | 178 for ( i = 0; i < BLOCK_MANAGER_ENTRY_COUNT; i++ ) |
179 MyControl->RsrcList[i] = NULL; | 179 MyControl->RsrcList[i] = NULL; |
180 | 180 |
181 /* Now for each entry in the incoming block list we can create | 181 /* Now for each entry in the incoming block list we can create |
182 a handler instance | 182 a handler instance |
183 */ | 183 */ |
184 for ( i = 0; i < NumEntries; i++ ) | 184 for ( i = 0; i < NumEntries; i++ ) |
185 if ( ( Entry = MyControl->EntryPtr[i].Id ) < BLOCK_MANAGER_ENTRY_COUNT ) | 185 if ( ( Entry = MyControl->EntryPtr[i].Id ) < BLOCK_MANAGER_ENTRY_COUNT ) |
186 MyControl->RsrcList[ Entry ] = mmibr_Initialise( | 186 MyControl->RsrcList[ Entry ] = mmibr_Initialise( |
187 MyControl->EntryPtr[i].EntryBase, MyControl->EntryPtr[i].NumEntries ); | 187 MyControl->EntryPtr[i].EntryBase, MyControl->EntryPtr[i].NumEntries ); |
188 } | 188 } |
189 | 189 |
190 return MyControl; | 190 return MyControl; |
191 } | 191 } |
192 | 192 |
193 | 193 |
194 /******************************************************************************* | 194 /******************************************************************************* |
195 | 195 |
196 $Function: mmibm_ShutDown | 196 $Function: mmibm_ShutDown |
197 | 197 |
198 $Description: Shutdown routine to deallocate resources ina controlled manner | 198 $Description: Shutdown routine to deallocate resources ina controlled manner |
199 | 199 |
200 $Returns: none. | 200 $Returns: none. |
201 | 201 |
202 $Arguments: *BlkHandle, pointer to resource manager handle | 202 $Arguments: *BlkHandle, pointer to resource manager handle |
203 | 203 |
204 *******************************************************************************/ | 204 *******************************************************************************/ |
205 | 205 |
206 void mmibm_ShutDown( tBlkHandle *BlkHandle ) | 206 void mmibm_ShutDown( tBlkHandle *BlkHandle ) |
207 { | 207 { |
208 /* Convert and verify the incoming handle | 208 /* Convert and verify the incoming handle |
209 */ | 209 */ |
210 pManagerControl MyControl = (pManagerControl) *BlkHandle; | 210 pManagerControl MyControl = (pManagerControl) *BlkHandle; |
211 int i; | 211 int i; |
212 | 212 |
213 if ( ValidManagerResource( *BlkHandle ) ) | 213 if ( ValidManagerResource( *BlkHandle ) ) |
214 { | 214 { |
215 /* Clear down the allocated resource managers | 215 /* Clear down the allocated resource managers |
216 */ | 216 */ |
217 for ( i = 0; i < BLOCK_MANAGER_ENTRY_COUNT; i++ ) | 217 for ( i = 0; i < BLOCK_MANAGER_ENTRY_COUNT; i++ ) |
218 if ( MyControl->RsrcList[i] != NULL ) | 218 if ( MyControl->RsrcList[i] != NULL ) |
219 mmibr_ShutDown( &MyControl->RsrcList[i] ); | 219 mmibr_ShutDown( &MyControl->RsrcList[i] ); |
220 | 220 |
221 /* and free the resource manager handle | 221 /* and free the resource manager handle |
222 */ | 222 */ |
223 free( *BlkHandle ); | 223 free( *BlkHandle ); |
224 *BlkHandle = NULL; | 224 *BlkHandle = NULL; |
225 } | 225 } |
226 } | 226 } |
227 | 227 |
228 | 228 |
229 /******************************************************************************* | 229 /******************************************************************************* |
230 | 230 |
231 $Function: mmibm_SupplyResourceHandler | 231 $Function: mmibm_SupplyResourceHandler |
232 | 232 |
233 $Description: | 233 $Description: |
234 | 234 |
235 Since this module will be managing each of the block handlers | 235 Since this module will be managing each of the block handlers |
236 for each of the resources, we need to be able to supply the | 236 for each of the resources, we need to be able to supply the |
237 appropriate handle for any given type to the calling routine. | 237 appropriate handle for any given type to the calling routine. |
238 | 238 |
239 $Returns: Handle to requesteb block resource handler, NULL if failure | 239 $Returns: Handle to requesteb block resource handler, NULL if failure |
240 | 240 |
241 $Arguments: ManagerHandle, handle of the block manager | 241 $Arguments: ManagerHandle, handle of the block manager |
242 Id, identifier of the resource table for which the resource | 242 Id, identifier of the resource table for which the resource |
243 handler is required | 243 handler is required |
244 | 244 |
245 *******************************************************************************/ | 245 *******************************************************************************/ |
246 | 246 |
247 tBlkHandle mmibm_SupplyResourceHandler( tBlkHandle ManagerHandle, tBlkId Id ) | 247 tBlkHandle mmibm_SupplyResourceHandler( tBlkHandle ManagerHandle, tBlkId Id ) |
248 { | 248 { |
249 /* Convert and verify the incoming handle | 249 /* Convert and verify the incoming handle |
250 */ | 250 */ |
251 pManagerControl MyControl = (pManagerControl) ManagerHandle; | 251 pManagerControl MyControl = (pManagerControl) ManagerHandle; |
252 if ( ! ValidManagerResource( ManagerHandle ) ) | 252 if ( ! ValidManagerResource( ManagerHandle ) ) |
253 return NULL; | 253 return NULL; |
254 | 254 |
255 /* Verify the id is within the range we expect | 255 /* Verify the id is within the range we expect |
256 */ | 256 */ |
257 if ( ( Id >= 0 ) && ( Id < BLOCK_MANAGER_ENTRY_COUNT ) ) | 257 if ( ( Id >= 0 ) && ( Id < BLOCK_MANAGER_ENTRY_COUNT ) ) |
258 return MyControl->RsrcList[Id]; | 258 return MyControl->RsrcList[Id]; |
259 | 259 |
260 /* Okay, we have something invalid, so return NULL | 260 /* Okay, we have something invalid, so return NULL |
261 */ | 261 */ |
262 return NULL; | 262 return NULL; |
263 } | 263 } |
264 | 264 |
265 | 265 |
266 | 266 |
267 /******************************************************************************* | 267 /******************************************************************************* |
268 | 268 |
269 End of File | 269 End of File |
270 | 270 |
271 *******************************************************************************/ | 271 *******************************************************************************/ |
272 |