Tiny fix found while looking for mistakes that might have been causing Mike trouble...
[freeems-vanilla.git] / src / blockDetailsLookup.c
blobde9617fdb03f76c01c18dda4385cb0335e068c6d
1 /* FreeEMS - the open source engine management system
3 * Copyright 2008-2012 Fred Cooke
5 * This file is part of the FreeEMS project.
7 * FreeEMS software is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * FreeEMS software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with any FreeEMS software. If not, see http://www.gnu.org/licenses/
20 * We ask that if you make any changes to this file you email them upstream to
21 * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
23 * Thank you for choosing FreeEMS to run your engine!
27 /** @file
29 * @ingroup communicationsFiles
31 * @brief Memory block details lookup
33 * This file holds the single function lookupBlockDetails() which
34 * functions as a sort of address book for logical blocks of memory.
36 * @author Fred Cooke
40 #define BLOCK_DETAILS_LOOKUP_C
41 #include "inc/freeEMS.h"
42 #include "inc/interrupts.h"
43 #include "inc/locationIDs.h"
44 #include "inc/pagedLocationBuffers.h"
45 #include "inc/blockDetailsLookup.h"
48 /** @brief Lookup memory block details.
50 * Flash only blocks leave the RAM address and page values
51 * set to zero. ID's that don't exist leave all set to zero.
52 * Error handling is to be done externally based on that.
54 * @author Fred Cooke
56 * @note This function is an exception to the style rule switch statement
57 * blocks of using a {} pair for each case statement. Readability is better
58 * without them in this case.
60 * @param locationID is the ID of the memory location for which details are required.
61 * @param details is a pointer to the blockDetails struct to populate with the details.
63 * @return An error code. Zero means success, anything else is a failure.
65 unsigned short lookupBlockDetails(unsigned short locationID, blockDetails* details){
66 /* Initialise the four values needed for operations on memory at 0 for error checking */
67 details->RAMPage = 0;
68 details->FlashPage = 0;
69 details->RAMAddress = 0;
70 details->FlashAddress = 0;
72 /* Initialise the block size to 1024 to save code space and increase readability */
73 details->size = sizeof(mainTable);
75 // No need to set parent value to zero as ignored unless flag set, done for clarity in hex stream.
76 details->parent = 0;
78 /* Look up the locations and set non default sizes */
79 switch (locationID) {
80 /* flash only fixed conf full blocks */
81 case FixedConfig1LocationID:
82 details->FlashPage = PPAGE;
83 details->FlashAddress = (void*)&fixedConfigs1;
84 break;
85 case FixedConfig2LocationID:
86 details->FlashPage = PPAGE;
87 details->FlashAddress = (void*)&fixedConfigs2;
88 break;
90 /* lookup tables */
91 case IATTransferTableLocationID:
92 details->size = sizeof(IATTransferTable);
93 details->FlashPage = LOOKUP_PPAGE;
94 details->FlashAddress = IATTransferTableLocation;
95 break;
96 case CHTTransferTableLocationID:
97 details->size = sizeof(CHTTransferTable);
98 details->FlashPage = LOOKUP_PPAGE;
99 details->FlashAddress = CHTTransferTableLocation;
100 break;
101 case MAFTransferTableLocationID:
102 details->size = sizeof(MAFTransferTable);
103 details->FlashPage = LOOKUP_PPAGE;
104 details->FlashAddress = MAFTransferTableLocation;
105 break;
106 case TestTransferTableLocationID:
107 details->size = sizeof(TestTransferTable);
108 details->FlashPage = LOOKUP_PPAGE;
109 details->FlashAddress = TestTransferTableLocation;
110 break;
112 /* fuel tables */
113 case VETableMainLocationID:
114 details->RAMPage = RPAGE_FUEL_ONE;
115 details->FlashPage = FUELTABLES_PPAGE;
116 details->RAMAddress = (void*)&TablesA;
117 details->FlashAddress = VETableMainFlashLocation;
118 break;
119 case VETableMain2LocationID:
120 details->RAMPage = RPAGE_FUEL_TWO;
121 details->FlashPage = FUELTABLES_PPAGE;
122 details->RAMAddress = (void*)&TablesA;
123 details->FlashAddress = VETableMainFlash2Location;
124 break;
125 case VETableSecondaryLocationID:
126 details->RAMPage = RPAGE_FUEL_ONE;
127 details->FlashPage = FUELTABLES_PPAGE;
128 details->RAMAddress = (void*)&TablesB;
129 details->FlashAddress = VETableSecondaryFlashLocation;
130 break;
131 case VETableSecondary2LocationID:
132 details->RAMPage = RPAGE_FUEL_TWO;
133 details->FlashPage = FUELTABLES_PPAGE;
134 details->RAMAddress = (void*)&TablesB;
135 details->FlashAddress = VETableSecondaryFlash2Location;
136 break;
137 case VETableTertiaryLocationID:
138 details->RAMPage = RPAGE_FUEL_ONE;
139 details->FlashPage = FUELTABLES_PPAGE;
140 details->RAMAddress = (void*)&TablesC;
141 details->FlashAddress = VETableTertiaryFlashLocation;
142 break;
143 case VETableTertiary2LocationID:
144 details->RAMPage = RPAGE_FUEL_TWO;
145 details->FlashPage = FUELTABLES_PPAGE;
146 details->RAMAddress = (void*)&TablesC;
147 details->FlashAddress = VETableTertiaryFlash2Location;
148 break;
149 case LambdaTableLocationID:
150 details->RAMPage = RPAGE_FUEL_ONE;
151 details->FlashPage = FUELTABLES_PPAGE;
152 details->RAMAddress = (void*)&TablesD;
153 details->FlashAddress = LambdaTableFlashLocation;
154 break;
155 case LambdaTable2LocationID:
156 details->RAMPage = RPAGE_FUEL_TWO;
157 details->FlashPage = FUELTABLES_PPAGE;
158 details->RAMAddress = (void*)&TablesD;
159 details->FlashAddress = LambdaTableFlash2Location;
160 break;
162 /* timing tables */
163 case IgnitionAdvanceTableMainLocationID:
164 details->RAMPage = RPAGE_TIME_ONE;
165 details->FlashPage = TIMETABLES_PPAGE;
166 details->RAMAddress = (void*)&TablesA;
167 details->FlashAddress = IgnitionAdvanceTableMainFlashLocation;
168 break;
169 case IgnitionAdvanceTableMain2LocationID:
170 details->RAMPage = RPAGE_TIME_TWO;
171 details->FlashPage = TIMETABLES_PPAGE;
172 details->RAMAddress = (void*)&TablesA;
173 details->FlashAddress = IgnitionAdvanceTableMainFlash2Location;
174 break;
175 case IgnitionAdvanceTableSecondaryLocationID:
176 details->RAMPage = RPAGE_TIME_ONE;
177 details->FlashPage = TIMETABLES_PPAGE;
178 details->RAMAddress = (void*)&TablesB;
179 details->FlashAddress = IgnitionAdvanceTableSecondaryFlashLocation;
180 break;
181 case IgnitionAdvanceTableSecondary2LocationID:
182 details->RAMPage = RPAGE_TIME_TWO;
183 details->FlashPage = TIMETABLES_PPAGE;
184 details->RAMAddress = (void*)&TablesB;
185 details->FlashAddress = IgnitionAdvanceTableSecondaryFlash2Location;
186 break;
187 case InjectionAdvanceTableMainLocationID:
188 details->RAMPage = RPAGE_TIME_ONE;
189 details->FlashPage = TIMETABLES_PPAGE;
190 details->RAMAddress = (void*)&TablesC;
191 details->FlashAddress = InjectionAdvanceTableMainFlashLocation;
192 break;
193 case InjectionAdvanceTableMain2LocationID:
194 details->RAMPage = RPAGE_TIME_TWO;
195 details->FlashPage = TIMETABLES_PPAGE;
196 details->RAMAddress = (void*)&TablesC;
197 details->FlashAddress = InjectionAdvanceTableMainFlash2Location;
198 break;
199 case InjectionAdvanceTableSecondaryLocationID:
200 details->RAMPage = RPAGE_TIME_ONE;
201 details->FlashPage = TIMETABLES_PPAGE;
202 details->RAMAddress = (void*)&TablesD;
203 details->FlashAddress = InjectionAdvanceTableSecondaryFlashLocation;
204 break;
205 case InjectionAdvanceTableSecondary2LocationID:
206 details->RAMPage = RPAGE_TIME_TWO;
207 details->FlashPage = TIMETABLES_PPAGE;
208 details->RAMAddress = (void*)&TablesD;
209 details->FlashAddress = InjectionAdvanceTableSecondaryFlash2Location;
210 break;
212 /* small table full blocks */
213 case SmallTablesALocationID:
214 details->RAMPage = RPAGE_TUNE_ONE;
215 details->FlashPage = TUNETABLES_PPAGE;
216 details->RAMAddress = (void*)&TablesA;
217 details->FlashAddress = SmallTablesAFlashLocation;
218 break;
219 case SmallTablesA2LocationID:
220 details->RAMPage = RPAGE_TUNE_TWO;
221 details->FlashPage = TUNETABLES_PPAGE;
222 details->RAMAddress = (void*)&TablesA;
223 details->FlashAddress = SmallTablesAFlash2Location;
224 break;
225 case SmallTablesBLocationID:
226 details->RAMPage = RPAGE_TUNE_ONE;
227 details->FlashPage = TUNETABLES_PPAGE;
228 details->RAMAddress = (void*)&TablesB;
229 details->FlashAddress = SmallTablesBFlashLocation;
230 break;
231 case SmallTablesB2LocationID:
232 details->RAMPage = RPAGE_TUNE_TWO;
233 details->FlashPage = TUNETABLES_PPAGE;
234 details->RAMAddress = (void*)&TablesB;
235 details->FlashAddress = SmallTablesBFlash2Location;
236 break;
237 case SmallTablesCLocationID:
238 details->RAMPage = RPAGE_TUNE_ONE;
239 details->FlashPage = TUNETABLES_PPAGE;
240 details->RAMAddress = (void*)&TablesC;
241 details->FlashAddress = SmallTablesCFlashLocation;
242 break;
243 case SmallTablesC2LocationID:
244 details->RAMPage = RPAGE_TUNE_TWO;
245 details->FlashPage = TUNETABLES_PPAGE;
246 details->RAMAddress = (void*)&TablesC;
247 details->FlashAddress = SmallTablesCFlash2Location;
248 break;
249 case SmallTablesDLocationID:
250 details->RAMPage = RPAGE_TUNE_ONE;
251 details->FlashPage = TUNETABLES_PPAGE;
252 details->RAMAddress = (void*)&TablesD;
253 details->FlashAddress = SmallTablesDFlashLocation;
254 break;
255 case SmallTablesD2LocationID:
256 details->RAMPage = RPAGE_TUNE_TWO;
257 details->FlashPage = TUNETABLES_PPAGE;
258 details->RAMAddress = (void*)&TablesD;
259 details->FlashAddress = SmallTablesDFlash2Location;
260 break;
262 /* TablesA small tables */
263 case dwellDesiredVersusVoltageTableLocationID:
264 details->size = sizeof(twoDTableUS);
265 details->RAMPage = RPAGE_TUNE_ONE;
266 details->FlashPage = TUNETABLES_PPAGE;
267 details->RAMAddress = (void*)&TablesA.SmallTablesA.dwellDesiredVersusVoltageTable;
268 details->FlashAddress = dwellDesiredVersusVoltageTableLocation;
269 details->parent = SmallTablesALocationID;
270 break;
271 case dwellDesiredVersusVoltageTable2LocationID:
272 details->size = sizeof(twoDTableUS);
273 details->RAMPage = RPAGE_TUNE_TWO;
274 details->FlashPage = TUNETABLES_PPAGE;
275 details->RAMAddress = (void*)&TablesA.SmallTablesA.dwellDesiredVersusVoltageTable;
276 details->FlashAddress = dwellDesiredVersusVoltageTable2Location;
277 details->parent = SmallTablesA2LocationID;
278 break;
279 case injectorDeadTimeTableLocationID:
280 details->size = sizeof(twoDTableUS);
281 details->RAMPage = RPAGE_TUNE_ONE;
282 details->FlashPage = TUNETABLES_PPAGE;
283 details->RAMAddress = (void*)&TablesA.SmallTablesA.injectorDeadTimeTable;
284 details->FlashAddress = injectorDeadTimeTableLocation;
285 details->parent = SmallTablesALocationID;
286 break;
287 case injectorDeadTimeTable2LocationID:
288 details->size = sizeof(twoDTableUS);
289 details->RAMPage = RPAGE_TUNE_TWO;
290 details->FlashPage = TUNETABLES_PPAGE;
291 details->RAMAddress = (void*)&TablesA.SmallTablesA.injectorDeadTimeTable;
292 details->FlashAddress = injectorDeadTimeTable2Location;
293 details->parent = SmallTablesA2LocationID;
294 break;
295 case postStartEnrichmentTableLocationID:
296 details->size = sizeof(twoDTableUS);
297 details->RAMPage = RPAGE_TUNE_ONE;
298 details->FlashPage = TUNETABLES_PPAGE;
299 details->RAMAddress = (void*)&TablesA.SmallTablesA.postStartEnrichmentTable;
300 details->FlashAddress = postStartEnrichmentTableLocation;
301 details->parent = SmallTablesALocationID;
302 break;
303 case postStartEnrichmentTable2LocationID:
304 details->size = sizeof(twoDTableUS);
305 details->RAMPage = RPAGE_TUNE_TWO;
306 details->FlashPage = TUNETABLES_PPAGE;
307 details->RAMAddress = (void*)&TablesA.SmallTablesA.postStartEnrichmentTable;
308 details->FlashAddress = postStartEnrichmentTable2Location;
309 details->parent = SmallTablesA2LocationID;
310 break;
311 case engineTempEnrichmentTableFixedLocationID:
312 details->size = sizeof(twoDTableUS);
313 details->RAMPage = RPAGE_TUNE_ONE;
314 details->FlashPage = TUNETABLES_PPAGE;
315 details->RAMAddress = (void*)&TablesA.SmallTablesA.engineTempEnrichmentTableFixed;
316 details->FlashAddress = engineTempEnrichmentTableFixedLocation;
317 details->parent = SmallTablesALocationID;
318 break;
319 case engineTempEnrichmentTableFixed2LocationID:
320 details->size = sizeof(twoDTableUS);
321 details->RAMPage = RPAGE_TUNE_TWO;
322 details->FlashPage = TUNETABLES_PPAGE;
323 details->RAMAddress = (void*)&TablesA.SmallTablesA.engineTempEnrichmentTableFixed;
324 details->FlashAddress = engineTempEnrichmentTableFixed2Location;
325 details->parent = SmallTablesA2LocationID;
326 break;
327 case primingVolumeTableLocationID:
328 details->size = sizeof(twoDTableUS);
329 details->RAMPage = RPAGE_TUNE_ONE;
330 details->FlashPage = TUNETABLES_PPAGE;
331 details->RAMAddress = (void*)&TablesA.SmallTablesA.primingVolumeTable;
332 details->FlashAddress = primingVolumeTableLocation;
333 details->parent = SmallTablesALocationID;
334 break;
335 case primingVolumeTable2LocationID:
336 details->size = sizeof(twoDTableUS);
337 details->RAMPage = RPAGE_TUNE_TWO;
338 details->FlashPage = TUNETABLES_PPAGE;
339 details->RAMAddress = (void*)&TablesA.SmallTablesA.primingVolumeTable;
340 details->FlashAddress = primingVolumeTable2Location;
341 details->parent = SmallTablesA2LocationID;
342 break;
343 case engineTempEnrichmentTablePercentLocationID:
344 details->size = sizeof(twoDTableUS);
345 details->RAMPage = RPAGE_TUNE_ONE;
346 details->FlashPage = TUNETABLES_PPAGE;
347 details->RAMAddress = (void*)&TablesA.SmallTablesA.engineTempEnrichmentTablePercent;
348 details->FlashAddress = engineTempEnrichmentTablePercentLocation;
349 details->parent = SmallTablesALocationID;
350 break;
351 case engineTempEnrichmentTablePercent2LocationID:
352 details->size = sizeof(twoDTableUS);
353 details->RAMPage = RPAGE_TUNE_TWO;
354 details->FlashPage = TUNETABLES_PPAGE;
355 details->RAMAddress = (void*)&TablesA.SmallTablesA.engineTempEnrichmentTablePercent;
356 details->FlashAddress = engineTempEnrichmentTablePercent2Location;
357 details->parent = SmallTablesA2LocationID;
358 break;
359 case dwellMaxVersusRPMTableLocationID:
360 details->size = sizeof(twoDTableUS);
361 details->RAMPage = RPAGE_TUNE_ONE;
362 details->FlashPage = TUNETABLES_PPAGE;
363 details->RAMAddress = (void*)&TablesA.SmallTablesA.dwellMaxVersusRPMTable;
364 details->FlashAddress = dwellMaxVersusRPMTableLocation;
365 details->parent = SmallTablesALocationID;
366 break;
367 case dwellMaxVersusRPMTable2LocationID:
368 details->size = sizeof(twoDTableUS);
369 details->RAMPage = RPAGE_TUNE_TWO;
370 details->FlashPage = TUNETABLES_PPAGE;
371 details->RAMAddress = (void*)&TablesA.SmallTablesA.dwellMaxVersusRPMTable;
372 details->FlashAddress = dwellMaxVersusRPMTable2Location;
373 details->parent = SmallTablesA2LocationID;
374 break;
376 /* TablesB small tables */
377 case loggingSettingsLocationID:
378 details->size = sizeof(loggingSetting);
379 details->RAMPage = RPAGE_TUNE_ONE;
380 details->FlashPage = TUNETABLES_PPAGE;
381 details->RAMAddress = (void*)&TablesB.SmallTablesB.loggingSettings;
382 details->FlashAddress = loggingSettingsLocation;
383 details->parent = SmallTablesBLocationID;
384 break;
385 case loggingSettings2LocationID:
386 details->size = sizeof(loggingSetting);
387 details->RAMPage = RPAGE_TUNE_TWO;
388 details->FlashPage = TUNETABLES_PPAGE;
389 details->RAMAddress = (void*)&TablesB.SmallTablesB.loggingSettings;
390 details->FlashAddress = loggingSettings2Location;
391 details->parent = SmallTablesB2LocationID;
392 break;
394 /* TablesC small tables */
395 // TODO add data chunks from TablesC when some are put in
397 /* TablesD small tables */
398 // TODO add data chunks from TablesD when some are put in
400 /* filler block entries */
401 case fillerALocationID:
402 details->size = SMALL_TABLES_1_FILLER_SIZE;
403 details->RAMPage = RPAGE_TUNE_ONE;
404 details->FlashPage = TUNETABLES_PPAGE;
405 details->RAMAddress = (void*)&TablesA.SmallTablesA.filler;
406 details->FlashAddress = fillerALocation;
407 details->parent = SmallTablesALocationID;
408 break;
409 case fillerA2LocationID:
410 details->size = SMALL_TABLES_1_FILLER_SIZE;
411 details->RAMPage = RPAGE_TUNE_TWO;
412 details->FlashPage = TUNETABLES_PPAGE;
413 details->RAMAddress = (void*)&TablesA.SmallTablesA.filler;
414 details->FlashAddress = fillerA2Location;
415 details->parent = SmallTablesA2LocationID;
416 break;
417 case fillerBLocationID:
418 details->size = SMALL_TABLES_2_FILLER_SIZE;
419 details->RAMPage = RPAGE_TUNE_ONE;
420 details->FlashPage = TUNETABLES_PPAGE;
421 details->RAMAddress = (void*)&TablesB.SmallTablesB.filler;
422 details->FlashAddress = fillerBLocation;
423 details->parent = SmallTablesBLocationID;
424 break;
425 case fillerB2LocationID:
426 details->size = SMALL_TABLES_2_FILLER_SIZE;
427 details->RAMPage = RPAGE_TUNE_TWO;
428 details->FlashPage = TUNETABLES_PPAGE;
429 details->RAMAddress = (void*)&TablesB.SmallTablesB.filler;
430 details->FlashAddress = fillerB2Location;
431 details->parent = SmallTablesB2LocationID;
432 break;
433 case fillerCLocationID:
434 details->size = SMALL_TABLES_3_FILLER_SIZE;
435 details->RAMPage = RPAGE_TUNE_ONE;
436 details->FlashPage = TUNETABLES_PPAGE;
437 details->RAMAddress = (void*)&TablesC.SmallTablesC.filler;
438 details->FlashAddress = fillerCLocation;
439 details->parent = SmallTablesCLocationID;
440 break;
441 case fillerC2LocationID:
442 details->size = SMALL_TABLES_3_FILLER_SIZE;
443 details->RAMPage = RPAGE_TUNE_TWO;
444 details->FlashPage = TUNETABLES_PPAGE;
445 details->RAMAddress = (void*)&TablesC.SmallTablesC.filler;
446 details->FlashAddress = fillerC2Location;
447 details->parent = SmallTablesC2LocationID;
448 break;
449 case fillerDLocationID:
450 details->size = SMALL_TABLES_4_FILLER_SIZE;
451 details->RAMPage = RPAGE_TUNE_ONE;
452 details->FlashPage = TUNETABLES_PPAGE;
453 details->RAMAddress = (void*)&TablesD.SmallTablesD.filler;
454 details->FlashAddress = fillerDLocation;
455 details->parent = SmallTablesDLocationID;
456 break;
457 case fillerD2LocationID:
458 details->size = SMALL_TABLES_4_FILLER_SIZE;
459 details->RAMPage = RPAGE_TUNE_TWO;
460 details->FlashPage = TUNETABLES_PPAGE;
461 details->RAMAddress = (void*)&TablesD.SmallTablesD.filler;
462 details->FlashAddress = fillerD2Location;
463 details->parent = SmallTablesD2LocationID;
464 break;
466 /* Fixed conf 1 small chunks */
467 case engineSettingsLocationID:
468 details->size = sizeof(engineSetting);
469 details->FlashPage = PPAGE;
470 details->FlashAddress = (void*)&(fixedConfigs1.engineSettings);
471 details->parent = FixedConfig1LocationID;
472 break;
473 case serialSettingsLocationID:
474 details->size = sizeof(serialSetting);
475 details->FlashPage = PPAGE;
476 details->FlashAddress = (void*)&(fixedConfigs1.serialSettings);
477 details->parent = FixedConfig1LocationID;
478 break;
479 case coarseBBSettingsLocationID:
480 details->size = sizeof(coarseBitBangSetting);
481 details->FlashPage = PPAGE;
482 details->FlashAddress = (void*)&(fixedConfigs1.coarseBitBangSettings);
483 details->parent = FixedConfig1LocationID;
484 break;
485 case userTextFieldLocationID:
486 details->size = userTextFieldArrayLength1;
487 details->FlashPage = PPAGE;
488 details->FlashAddress = (void*)&(fixedConfigs1.userTextField);
489 details->parent = FixedConfig1LocationID;
490 break;
492 /* Fixed conf 2 small chunks */
493 case sensorRangesLocationID:
494 details->size = sizeof(sensorRange);
495 details->FlashPage = PPAGE;
496 details->FlashAddress = (void*)&(fixedConfigs2.sensorRanges);
497 details->parent = FixedConfig2LocationID;
498 break;
499 case sensorPresetsLocationID:
500 details->size = sizeof(sensorPreset);
501 details->FlashPage = PPAGE;
502 details->FlashAddress = (void*)&(fixedConfigs2.sensorPresets);
503 details->parent = FixedConfig2LocationID;
504 break;
505 case sensorSettingsLocationID:
506 details->size = sizeof(sensorSetting);
507 details->FlashPage = PPAGE;
508 details->FlashAddress = (void*)&(fixedConfigs2.sensorSettings);
509 details->parent = FixedConfig2LocationID;
510 break;
511 case userTextField2LocationID:
512 details->size = userTextFieldArrayLength2;
513 details->FlashPage = PPAGE;
514 details->FlashAddress = (void*)&(fixedConfigs2.userTextField2);
515 details->parent = FixedConfig2LocationID;
516 break;
518 // Internal blocks of variables that are sometimes useful to read out
519 case ADCRegistersLocationID:
520 details->size = sizeof(ADCBuffer);
521 details->RAMPage = RPAGE_LINEAR;
522 details->RAMAddress = (void*)ADCBuffers;
523 break;
524 case coreVarsLocationID:
525 details->size = sizeof(CoreVar);
526 details->RAMPage = RPAGE_LINEAR;
527 details->RAMAddress = (void*)CoreVars;
528 break;
529 case DerivedVarsLocationID:
530 details->size = sizeof(DerivedVar);
531 details->RAMPage = RPAGE_LINEAR;
532 details->RAMAddress = (void*)DerivedVars;
533 break;
534 case CountersLocationID:
535 details->size = sizeof(Counter);
536 details->RAMPage = RPAGE_LINEAR;
537 details->RAMAddress = &Counters;
538 break;
539 case ClocksLocationID:
540 details->size = sizeof(Clock);
541 details->RAMPage = RPAGE_LINEAR;
542 details->RAMAddress = &Clocks;
543 break;
544 case FlaggablesLocationID:
545 details->size = sizeof(Flaggable);
546 details->RAMPage = RPAGE_LINEAR;
547 details->RAMAddress = &Flaggables;
548 break;
550 default:
551 /* Return early if locationID is not valid. */
552 return locationIDNotFound;
556 // Setup all of the flags for various groups here
557 // Setting flags above is wrong, keep it all in one place, here!
559 // Initialise the flags to having flash, everything does at the moment, and indexable, most is, negate at end for those that don't.
560 details->flags = block_is_in_flash | block_is_indexable;
562 if(locationID < MainTable_TwoDTableUS_Border){
563 details->flags |= block_is_main_table | block_is_in_ram | block_gets_verified | block_for_backup_restore;
564 }else if(locationID < TwoDTableUS_SmallTableFullBlocks_Border){
565 details->flags |= block_is_2dus_table | block_is_in_ram | block_has_parent | block_gets_verified;
566 }else if(locationID < SmallTableFullBlocks_SmallTableFillers_Border){
567 details->flags |= block_is_in_ram | block_for_backup_restore;
568 details->flags &= ~block_is_indexable;
569 }else if(locationID < SmallTableFillers_FlashLookupTables_Border){
570 details->flags |= block_has_parent | block_is_in_ram;
571 details->flags &= ~block_is_indexable;
572 }else if(locationID < FlashLookupTables_SmallTableConfigs_Border){
573 details->flags |= block_is_lookup_data | block_for_backup_restore;
574 details->flags &= ~block_is_indexable;
575 }else if(locationID < SmallTableConfigs_FixedConfigBlocks_Border){
576 details->flags |= block_has_parent | block_is_in_ram | block_is_configuration;
577 }else if(locationID < FixedConfigBlocks_FixedConfigSubBlocks_Border){
578 details->flags |= block_for_backup_restore;
579 }else if(locationID < FixedConfigSubBlocks_Border_ReadOnlyVarBlocks){
580 details->flags |= block_has_parent | block_is_configuration;
581 }else{ // RO variable blocks exposed polling and streaming
582 details->flags |= block_is_read_only | block_is_in_ram;
583 details->flags &= ~block_is_in_flash;
586 /* Fall through to not return error */
587 return 0;