FreeCalypso > hg > freecalypso-citrine
comparison L1/cust0/pirelli.c @ 0:75a11d740a02
initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 09 Jun 2016 00:02:41 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:75a11d740a02 |
---|---|
1 /* | |
2 * This module is a FreeCalypso addition. Here we implement | |
3 * retrieval of Pirelli's factory calibration and IMEI records | |
4 * from their factory data block. | |
5 */ | |
6 | |
7 #include <string.h> | |
8 #include "config.h" | |
9 #include "sys_types.h" | |
10 #include "../../services/ffs/ffs.h" | |
11 #include "../../services/ffs/core.h" /* for ffs_begin() and ffs_end() */ | |
12 | |
13 #define FACTORY_BLOCK_BASE_ADDR 0x027F0000 | |
14 | |
15 static effs_t | |
16 pirelli_chksum(uint8 *addr, T_FFS_SIZE size) | |
17 { | |
18 uint8 accum = 0; | |
19 | |
20 for (; size; size--) | |
21 accum += *addr++; | |
22 if (accum == *addr) | |
23 return EFFS_OK; | |
24 else | |
25 return EFFS_CORRUPTED; | |
26 } | |
27 | |
28 pirelli_read_factory_record(uint32 offset, void *userbuf, T_FFS_SIZE size, | |
29 int has_chksum) | |
30 { | |
31 effs_t rc; | |
32 uint8 *flash_record = (uint8 *) FACTORY_BLOCK_BASE_ADDR + offset; | |
33 | |
34 rc = ffs_begin(); | |
35 if (rc != EFFS_OK) | |
36 return(rc); | |
37 if (has_chksum) | |
38 rc = pirelli_chksum(flash_record, size); | |
39 if (rc == EFFS_OK) | |
40 bcopy(flash_record, userbuf, size); | |
41 return ffs_end(rc); | |
42 } | |
43 | |
44 static const struct calmap { | |
45 uint32 offset; | |
46 char *ti_equiv; | |
47 } pirelli_cal_map[] = { | |
48 {0x06E5, "/sys/adccal"}, | |
49 {0x072B, "/gsm/rf/tx/ramps.900"}, | |
50 {0x092C, "/gsm/rf/tx/levels.900"}, | |
51 {0x09AD, "/gsm/rf/tx/calchan.900"}, | |
52 {0x0A2E, "/gsm/rf/tx/ramps.1800"}, | |
53 {0x0C2F, "/gsm/rf/tx/levels.1800"}, | |
54 {0x0CB0, "/gsm/rf/tx/calchan.1800"}, | |
55 {0x0D31, "/gsm/rf/tx/ramps.1900"}, | |
56 {0x0F32, "/gsm/rf/tx/levels.1900"}, | |
57 {0x0FB3, "/gsm/rf/tx/calchan.1900"}, | |
58 {0x10AF, "/gsm/rf/rx/calchan.900"}, | |
59 {0x10D8, "/gsm/rf/rx/agcparams.900"}, | |
60 {0x10E1, "/gsm/rf/rx/calchan.1800"}, | |
61 {0x110A, "/gsm/rf/rx/agcparams.1800"}, | |
62 {0x1113, "/gsm/rf/rx/calchan.1900"}, | |
63 {0x113C, "/gsm/rf/rx/agcparams.1900"}, | |
64 {0, 0} | |
65 }; | |
66 | |
67 pirelli_cal_fread(const char *name, void *userbuf, T_FFS_SIZE size) | |
68 { | |
69 int rc; | |
70 const struct calmap *map; | |
71 | |
72 /* try FFS first, so FreeCalypso user can override factory prog */ | |
73 rc = ffs_file_read(name, userbuf, size); | |
74 if (rc >= 0) | |
75 return EFFS_OK; | |
76 /* does the sought file correspond to a Pirelli factory data record? */ | |
77 for (map = pirelli_cal_map; map->ti_equiv; map++) | |
78 if (!strcmp(map->ti_equiv, name)) | |
79 break; | |
80 if (!map->offset) /* not found */ | |
81 return rc; /* return error code from FFS */ | |
82 /* found it */ | |
83 return pirelli_read_factory_record(map->offset, userbuf, size, 1); | |
84 } |