annotate gsm-fw/services/ffs/drv.c @ 422:833e8fa93330

fc-loadtool -r (reattach) option implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Thu, 19 Jun 2014 00:57:02 +0000
parents 4d706a4134b0
children 0fb9b7f2ef87
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
209
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /******************************************************************************
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * Flash File System (ffs)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * Idea, design and coding by Mads Meisner-Jensen, mmj@ti.com
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 *
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 * ffs low level flash driver
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 *
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 * $Id: drv.c 1.30.1.6.1.51.1.1.1.13.1.11 Tue, 06 Jan 2004 14:36:52 +0100 tsj $
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 *
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 ******************************************************************************/
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "../../include/config.h"
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "ffs.h"
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "drv.h"
226
4d706a4134b0 FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
14 #include "core.h" /* for FFS_BLOCKS_MAX */
209
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 #include "ffstrace.h"
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 #include "intctl.h"
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 #include "ramffs.h"
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 #include <string.h>
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 /******************************************************************************
226
4d706a4134b0 FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
22 * "Block info" stupidity
4d706a4134b0 FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
23 ******************************************************************************/
4d706a4134b0 FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
24
4d706a4134b0 FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
25 static struct block_info_s block_info[FFS_BLOCKS_MAX];
4d706a4134b0 FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
26
4d706a4134b0 FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
27
4d706a4134b0 FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
28 /******************************************************************************
209
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 * Macros
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 ******************************************************************************/
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 #define addr2offset(address) ( (int) (address) - (int) dev.base )
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 /******************************************************************************
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 * Generic Driver Functions
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 ******************************************************************************/
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 // Note: This function is designed for little-endian memory addressing!
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 void ffsdrv_write_byte(void *dst, uint8 value)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 uint16 halfword;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 tw(tr(TR_FUNC, TrDrvWrite, "ffsdrv_write_byte(0x%05x, 0x%x)\n",
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 (int) (addr2offset(dst)), value));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 ttw(str(TTrDrvWrite, "wb" NL));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 if ((int) dst & 1)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 halfword = (value << 8) | *((uint8 *) dst - 1);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 else
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 halfword = (*((uint8 *) dst + 1) << 8) | (value);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 ffsdrv.write_halfword((uint16 *) ((int) dst & ~1), halfword);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 void ffsdrv_generic_write(void *dst, const void *src, uint16 size)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 uint8 *mydst = dst;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 const uint8 *mysrc = src;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 if (size > 0)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 if ((unsigned int) mydst & 1) {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 ffsdrv_write_byte(mydst++, *mysrc++);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 size--;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 while (size >= 2) {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 ffsdrv.write_halfword((uint16 *) mydst,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 mysrc[0] | (mysrc[1] << 8));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 size -= 2;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 mysrc += 2;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 mydst += 2;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 if (size == 1)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 ffsdrv_write_byte(mydst++, *mysrc++);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 /******************************************************************************
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 * Dummy Functions
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 ******************************************************************************/
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83 int ffsdrv_null_init(void)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85 ttw(ttr(TTrDrvOther, "ffsdrv_null_init()" NL));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
86
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87 return 0;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
88 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 void ffsdrv_null_erase(uint8 block)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92 ttw(ttr(TTrDrvErase, "ffsdrv_null_erase(%d)" NL, block));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
94
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
95 void ffsdrv_null_write_halfword(volatile uint16 *addr, uint16 value)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
96 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97 ttw(ttr(TTrDrvWrite, "ffsdrv_null_write_halfword(0x%x, 0x%x)" NL, addr, value));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
98 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
99
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100 void ffsdrv_null_write(void *dst, const void *src, uint16 size)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
101 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
102 ttw(ttr(TTrDrvWrite, "ffsdrv_null_write(0x%x, 0x%x, %d)" NL, dst, src, size));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
104
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
105 void ffsdrv_null_erase_suspend(void)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
106 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
107 ttw(str(TTrDrvErase, "ffsdrv_null_erase_suspend()" NL));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
108 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
109
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110 void ffsdrv_null_erase_resume(void)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
111 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112 ttw(str(TTrDrvErase, "ffsdrv_null_erase_resume()" NL));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
113 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
115 void ffsdrv_null_write_end(void)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
117 ttw(str(TTrDrvWrite, "ffsdrv_null_write_end()" NL));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
120 void ffsdrv_null_erase_end(void)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
122 ttw(str(TTrDrvErase, "ffsdrv_null_erase_end()" NL));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
123 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
124
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
125 /*
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
126 * FreeCalypso change from TI: we only compile one flash "driver" type
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
127 * based on the build configuration.
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128 */
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
129
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
130 #if FFS_IN_RAM
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
131
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132 /******************************************************************************
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
133 * RAM Family Functions
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
134 ******************************************************************************/
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
135
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
136 void ffsdrv_ram_write_halfword(volatile uint16 *dst, uint16 value)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
137 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138 *dst = value;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
139 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141 #if 0
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
142 /* duplicates ffsdrv_generic_write */
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
143 void ffsdrv_ram_write(void *dst, const void *src, uint16 size)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
145 uint8 *mydst = dst;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
146 const uint8 *mysrc = src;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148 if (size == 0)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
149 return;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
150 else if (size == 1)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
151 ffsdrv_write_byte(mydst, *mysrc);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
152 else {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
153 if ((int) mydst & 1) {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
154 ffsdrv_write_byte(mydst++, *mysrc++);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
155 size--;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
157 while (size >= 2) {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
158 ffsdrv_ram_write_halfword((uint16 *) mydst, mysrc[0]|(mysrc[1] << 8));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
159 size -= 2;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
160 mysrc += 2;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
161 mydst += 2;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
162 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
163 if (size == 1)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
164 ffsdrv_write_byte(mydst++, *mysrc++);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
165 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
166 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
167 #endif
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
168
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
169 void ffsdrv_ram_erase(uint8 block)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
170 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
171 int i;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
172 char *addr;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
173
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
174 addr = block2addr(block);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
175
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
176 for (i = 0; i < (1 << dev.binfo[block].size_ld); i++) {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
177 *addr++ = 0xFF;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
178 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
179 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
180
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
181 const struct ffsdrv_s ffsdrv = {
218
fee45482aa2a FFS: hopefully-correct initialization for the FFS_IN_RAM configuration
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 209
diff changeset
182 ffsdrv_null_init,
209
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
183 ffsdrv_ram_erase,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
184 ffsdrv_ram_write_halfword,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
185 ffsdrv_generic_write,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
186 ffsdrv_null_write_end,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
187 ffsdrv_null_erase_suspend,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
188 ffsdrv_null_erase_resume
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
189 };
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
190
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
191 #elif CONFIG_FLASH_WRITE
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
192
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
193 /******************************************************************************
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
194 * AMD Dual/Multi Bank Driver Functions
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
195 ******************************************************************************/
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
196
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
197 // All erase and write operations are performed atomically (interrupts
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
198 // disabled). Otherwise we cannot trust the value of dev.state and we cannot
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
199 // determine exactly how many of the command words have already been
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
200 // written.
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
201
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
202 // in ffs_end() when we resume an erasure that was previously suspended, how
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
203 // does that affect multiple tasks doing that simultaneously?
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
204
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
205 void ffsdrv_amd_write_end(void);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
206 void ffsdrv_amd_erase_end(void);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
207
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
208 void ffsdrv_amd_write_halfword(volatile uint16 *addr, uint16 value)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
209 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
210 volatile char *flash = dev.base;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
211 uint32 cpsr;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
212
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
213 tlw(led_on(LED_WRITE));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
214 ttw(ttr(TTrDrvWrite, "wh(%x,%x)" NL, addr, value));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
215
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
216 dev.addr = addr;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
217 dev.data = value;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
218
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
219 if (~*addr & value) {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
220 ttw(ttr(TTrFatal, "wh(%x,%x->%x) fatal" NL, addr, *addr, value));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
221 return;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
222 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
223
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
224 cpsr = int_disable();
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
225 tlw(led_toggle(LED_WRITE_SUSPEND));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
226 dev.state = DEV_WRITE;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
227 flash[0xAAAA] = 0xAA; // unlock cycle 1
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
228 flash[0x5555] = 0x55; // unlock cycle 2
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
229 flash[0xAAAA] = 0xA0;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
230 *addr = value;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
231 int_enable(cpsr);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
232 tlw(led_toggle(LED_WRITE_SUSPEND));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
233
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
234 ffsdrv_amd_write_end();
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
235 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
236
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
237 #if 0
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
238 /* duplicates ffsdrv_generic_write */
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
239 void ffsdrv_amd_write(void *dst, const void *src, uint16 size)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
240 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
241 uint8 *mydst = dst;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
242 const uint8 *mysrc = src;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
243
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
244 if (size > 0)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
245 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
246 if ((unsigned int) mydst & 1) {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
247 ffsdrv_write_byte(mydst++, *mysrc++);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
248 size--;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
249 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
250 while (size >= 2) {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
251 ffsdrv_amd_write_halfword((uint16 *) mydst,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
252 mysrc[0] | (mysrc[1] << 8));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
253 size -= 2;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
254 mysrc += 2;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
255 mydst += 2;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
256 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
257 if (size == 1)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
258 ffsdrv_write_byte(mydst++, *mysrc++);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
259 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
260 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
261 #endif
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
262
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
263 void ffsdrv_amd_write_end(void)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
264 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
265 while ((*dev.addr ^ dev.data) & 0x80)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
266 tlw(led_toggle(LED_WRITE_SUSPEND));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
267
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
268 dev.state = DEV_READ;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
269
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
270 tlw(led_off(LED_WRITE));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
271 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
272
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
273 void ffsdrv_amd_erase(uint8 block)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
274 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
275 volatile char *flash = dev.base;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
276 uint32 cpsr;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
277
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
278 tlw(led_on(LED_ERASE));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
279 ttw(ttr(TTrDrvErase, "e(%d)" NL, block));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
280
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
281 dev.addr = (uint16 *) block2addr(block);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
282
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
283 cpsr = int_disable();
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
284 dev.state = DEV_ERASE;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
285 flash[0xAAAA] = 0xAA; // unlock cycle 1
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
286 flash[0x5555] = 0x55; // unlock cycle 2
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
287 flash[0xAAAA] = 0x80;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
288 flash[0xAAAA] = 0xAA; // unlock cycle 1
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
289 flash[0x5555] = 0x55; // unlock cycle 2
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
290 *dev.addr = 0x30; // AMD erase sector command
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
291 int_enable(cpsr);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
292
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
293 ffsdrv_amd_erase_end();
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
294 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
295
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
296 void ffsdrv_amd_erase_end(void)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
297 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
298 while ((*dev.addr & 0x80) == 0)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
299 ;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
300
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
301 dev.state = DEV_READ;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
302
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
303 tlw(led_off(LED_ERASE));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
304 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
305
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
306 void ffsdrv_amd_erase_suspend(void)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
307 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
308 uint32 cpsr;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
309
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
310 tlw(led_on(LED_ERASE_SUSPEND));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
311 ttw(str(TTrDrvErase, "es" NL));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
312
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
313 // if erase has finished then all is ok
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
314 if (*dev.addr & 0x80) {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
315 ffsdrv_amd_erase_end();
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
316 tlw(led_off(LED_ERASE_SUSPEND));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
317 return;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
318 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
319
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
320 // NOTEME: As there is no way to be absolutely certain that erase
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
321 // doesn't finish between last poll and the following erase suspend
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
322 // command, we assume that the erase suspend is safe even though the
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
323 // erase IS actually already finished.
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
324
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
325 cpsr = int_disable();
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
326 dev.state = DEV_ERASE_SUSPEND;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
327 *dev.addr = 0xB0;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
328
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
329 // Wait for erase suspend to finish
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
330 while ((*dev.addr & 0x80) == 0)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
331 ;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
332
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
333 int_enable(cpsr);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
334 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
335
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
336 void ffsdrv_amd_erase_resume(void)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
337 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
338 uint32 cpsr;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
339
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
340 ttw(str(TTrDrvErase, "er" NL));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
341
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
342 // NOTEME: See note in erase_suspend()... We assume that the erase
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
343 // resume is safe even though the erase IS actually already finished.
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
344 cpsr = int_disable();
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
345 dev.state = DEV_ERASE;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
346 *dev.addr = 0x30;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
347 int_enable(cpsr);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
348
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
349 tlw(led_off(LED_ERASE_SUSPEND));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
350 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
351
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
352 const struct ffsdrv_s ffsdrv = {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
353 ffsdrv_null_init,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
354 ffsdrv_amd_erase,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
355 ffsdrv_amd_write_halfword,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
356 ffsdrv_generic_write,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
357 ffsdrv_amd_write_end,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
358 ffsdrv_amd_erase_suspend,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
359 ffsdrv_amd_erase_resume
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
360 };
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
361
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
362 #else
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
363
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
364 /*
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
365 * This part will get compiled if we have real FFS (FFS_IN_RAM=0),
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
366 * but not allowed to write to flash (CONFIG_FLASH_WRITE=0).
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
367 */
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
368
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
369 const struct ffsdrv_s ffsdrv = {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
370 ffsdrv_null_init,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
371 ffsdrv_null_erase,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
372 ffsdrv_null_write_halfword,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
373 ffsdrv_null_write,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
374 ffsdrv_null_write_end,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
375 ffsdrv_null_erase_suspend,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
376 ffsdrv_null_erase_resume
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
377 };
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
378
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
379 #endif
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
380
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
381
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
382 /******************************************************************************
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
383 * Initialization
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
384 *
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
385 * Significantly simplified in FreeCalypso.
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
386 *
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
387 ******************************************************************************/
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
388
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
389 effs_t ffsdrv_init(void)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
390 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
391 int error;
226
4d706a4134b0 FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
392 unsigned i;
4d706a4134b0 FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
393 uint32 offset;
209
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
394
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
395 tw(tr(TR_BEGIN, TrDrvInit, "drv_init() {\n"));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
396 ttw(str(TTrDrvOther, "ffsdrv_init() {" NL));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
397
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
398 dev.state = DEV_READ;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
399 dev.atomlog2 = FFS_ATOM_LOG2;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
400 dev.atomsize = 1 << dev.atomlog2;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
401 dev.atomnotmask = dev.atomsize - 1;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
402
226
4d706a4134b0 FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
403 offset = 0;
4d706a4134b0 FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
404 for (i = 0; i < dev.numblocks; i++) {
4d706a4134b0 FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
405 block_info[i].offset = offset;
4d706a4134b0 FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
406 block_info[i].size_ld = dev.blocksize_ld;
4d706a4134b0 FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
407 offset += dev.blocksize;
4d706a4134b0 FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
408 }
4d706a4134b0 FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
409 dev.binfo = block_info;
4d706a4134b0 FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
410
209
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
411 error = ffsdrv.init();
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
412
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
413 tw(tr(TR_FUNC, TrDrvInit, "dev.binfo = 0x%x\n", (unsigned int) dev.binfo));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
414 tw(tr(TR_FUNC, TrDrvInit, "dev.base = 0x%x\n", (unsigned int) dev.base));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
415 tw(tr(TR_FUNC, TrDrvInit, "dev.numblocks = %d\n", dev.numblocks));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
416 tw(tr(TR_FUNC, TrDrvInit, "dev.blocksize = %d\n", dev.blocksize));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
417 tw(tr(TR_FUNC, TrDrvInit, "dev.atomlog2/atomsize/atomnotmask = %d/%d/%x\n",
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
418 dev.atomlog2, dev.atomsize, dev.atomnotmask));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
419 tw(tr(TR_END, TrDrvInit, "} %d\n", error));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
420 ttw(ttr(TTrDrvOther, "} %d" NL, error));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
421
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
422 return error;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
423 }