annotate gsm-fw/services/ffs/cfgffs.c @ 210:1d87b335fc50

gsm-fw/services/ffs: cfgffs.c integrated
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Thu, 26 Dec 2013 04:37:10 +0000
parents
children fee45482aa2a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
210
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /******************************************************************************
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * Flash File System (ffs)
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * Idea, design and coding by Mads Meisner-Jensen, mmj@ti.com
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 *
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 * FFS configuration
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 *
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 * $Id: cfgffs.c 1.27 Fri, 19 Dec 2003 12:00:13 +0100 tsj $
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 *
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 ******************************************************************************/
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "../../include/config.h"
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "ffs.h"
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "drv.h"
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 #include "ramffs.h"
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 #include <string.h>
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 #if FFS_IN_RAM
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 extern struct block_info_s ramffs_block_info[RAMFFS_NBLOCKS];
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 struct dev_s dev = {
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 .base = _RAMFFS_area,
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 .binfo = ramffs_block_info,
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 .blocksize = RAMFFS_BLKSIZE_BYTES,
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 .blocksize_ld = RAMFFS_BLKSIZE_LOG2,
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 .driver = FFS_DRIVER_RAM,
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 .numblocks = RAMFFS_NBLOCKS,
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 };
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 #elif CONFIG_MOKOFFS
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 static struct block_info_s mokoffs_blocks[7] = {
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 { 0x00000, 16 },
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 { 0x10000, 16 },
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 { 0x20000, 16 },
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 { 0x30000, 16 },
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 { 0x40000, 16 },
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 { 0x50000, 16 },
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 { 0x60000, 16 }
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 };
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 struct dev_s dev = {
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 .base = (char *) 0x380000,
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 .binfo = mokoffs_blocks,
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 .blocksize = 0x10000,
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 .blocksize_ld = 16,
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 .driver = FFS_DRIVER_AMD,
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 .numblocks = 7,
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 };
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 #elif CONFIG_PIRHACK_FFS
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 /* see ../../cfgmagic/feature.pirhack-ffs */
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 static struct block_info_s pirhack_ffs_blocks[7] = {
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 { 0x600000, 18 },
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 { 0x640000, 18 },
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 { 0x680000, 18 },
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 { 0x6C0000, 18 },
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 { 0x700000, 18 },
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 { 0x740000, 18 },
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 { 0x780000, 18 }
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 };
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 struct dev_s dev = {
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 .base = (char *) FLASH2_BASE_ADDR,
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 .binfo = pirhack_ffs_blocks,
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 .blocksize = 0x40000,
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 .blocksize_ld = 18,
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 .driver = FFS_DRIVER_AMD,
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 .numblocks = 7,
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 };
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 #else
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 #error "No valid FFS configuration defined"
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 #endif
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 /******************************************************************************
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 * ffs_is_modify_valid()
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 ******************************************************************************/
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84 // This is function to be implemented by the application programmer. It is
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85 // called by ffs when a read-only object is about to be modified or
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
86 // removed. It should return zero if the operation should be
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87 // disallowed. Returning non-zero means go ahead.
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
88 effs_t ffs_is_modifiable(const char *name)
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 {
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 // default is to allow any modification of read-only objects.
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92 /*
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93 * TI's original code (conditioned out below) disallowed changing the
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
94 * IMEI of a device. FreeCalypso follows a different philosophy:
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
95 * 100% user empowerment, hence no artificial obstacles to hacking.
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
96 */
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97 #if 0
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
98 // example of how to disallow modifying a specific object...
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
99 if (strcmp("IMEI", &name[strlen(name) - 4]) == 0)
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100 return 0;
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
101 #endif
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
102
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103 return 1;
1d87b335fc50 gsm-fw/services/ffs: cfgffs.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
104 }