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