annotate gsm-fw/services/ffs/drv.c @ 1034:405b5469abc4 default tip

top README: repository change notice
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 12 Jun 2016 19:06:34 +0000
parents 6b0b2f6dbb20
children
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
940
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
193 #if FLASH_IS_AMD_MULTIBANK
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
194
209
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 * AMD Dual/Multi Bank Driver Functions
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
197 ******************************************************************************/
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
198
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
199 // 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
200 // 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
201 // 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
202 // written.
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
203
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
204 // 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
205 // 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
206
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
207 void ffsdrv_amd_write_end(void);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
208 void ffsdrv_amd_erase_end(void);
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 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
211 {
941
6b0b2f6dbb20 gsm-fw/services/ffs/drv.c: AMD multi-bank flash driver fixed for Pirelli
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 940
diff changeset
212 volatile uint16 *flash = (volatile uint16 *)dev.base;
209
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
213 uint32 cpsr;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
214
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
215 tlw(led_on(LED_WRITE));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
216 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
217
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
218 dev.addr = addr;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
219 dev.data = value;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
220
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
221 if (~*addr & value) {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
222 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
223 return;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
224 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
225
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
226 cpsr = int_disable();
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
227 tlw(led_toggle(LED_WRITE_SUSPEND));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
228 dev.state = DEV_WRITE;
941
6b0b2f6dbb20 gsm-fw/services/ffs/drv.c: AMD multi-bank flash driver fixed for Pirelli
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 940
diff changeset
229 flash[0x555] = 0xAA; // unlock cycle 1
6b0b2f6dbb20 gsm-fw/services/ffs/drv.c: AMD multi-bank flash driver fixed for Pirelli
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 940
diff changeset
230 flash[0x2AA] = 0x55; // unlock cycle 2
6b0b2f6dbb20 gsm-fw/services/ffs/drv.c: AMD multi-bank flash driver fixed for Pirelli
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 940
diff changeset
231 flash[0x555] = 0xA0;
209
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
232 *addr = value;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
233 int_enable(cpsr);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
234 tlw(led_toggle(LED_WRITE_SUSPEND));
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 ffsdrv_amd_write_end();
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
237 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
238
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
239 #if 0
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
240 /* duplicates ffsdrv_generic_write */
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
241 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
242 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
243 uint8 *mydst = dst;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
244 const uint8 *mysrc = src;
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 (size > 0)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
247 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
248 if ((unsigned int) mydst & 1) {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
249 ffsdrv_write_byte(mydst++, *mysrc++);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
250 size--;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
251 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
252 while (size >= 2) {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
253 ffsdrv_amd_write_halfword((uint16 *) mydst,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
254 mysrc[0] | (mysrc[1] << 8));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
255 size -= 2;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
256 mysrc += 2;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
257 mydst += 2;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
258 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
259 if (size == 1)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
260 ffsdrv_write_byte(mydst++, *mysrc++);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
261 }
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 #endif
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 void ffsdrv_amd_write_end(void)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
266 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
267 while ((*dev.addr ^ dev.data) & 0x80)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
268 tlw(led_toggle(LED_WRITE_SUSPEND));
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 dev.state = DEV_READ;
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 tlw(led_off(LED_WRITE));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
273 }
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 void ffsdrv_amd_erase(uint8 block)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
276 {
941
6b0b2f6dbb20 gsm-fw/services/ffs/drv.c: AMD multi-bank flash driver fixed for Pirelli
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 940
diff changeset
277 volatile uint16 *flash = (volatile uint16 *)dev.base;
209
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
278 uint32 cpsr;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
279
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
280 tlw(led_on(LED_ERASE));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
281 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
282
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
283 dev.addr = (uint16 *) block2addr(block);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
284
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
285 cpsr = int_disable();
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
286 dev.state = DEV_ERASE;
941
6b0b2f6dbb20 gsm-fw/services/ffs/drv.c: AMD multi-bank flash driver fixed for Pirelli
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 940
diff changeset
287 flash[0x555] = 0xAA; // unlock cycle 1
6b0b2f6dbb20 gsm-fw/services/ffs/drv.c: AMD multi-bank flash driver fixed for Pirelli
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 940
diff changeset
288 flash[0x2AA] = 0x55; // unlock cycle 2
6b0b2f6dbb20 gsm-fw/services/ffs/drv.c: AMD multi-bank flash driver fixed for Pirelli
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 940
diff changeset
289 flash[0x555] = 0x80;
6b0b2f6dbb20 gsm-fw/services/ffs/drv.c: AMD multi-bank flash driver fixed for Pirelli
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 940
diff changeset
290 flash[0x555] = 0xAA; // unlock cycle 1
6b0b2f6dbb20 gsm-fw/services/ffs/drv.c: AMD multi-bank flash driver fixed for Pirelli
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 940
diff changeset
291 flash[0x2AA] = 0x55; // unlock cycle 2
209
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
292 *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
293 int_enable(cpsr);
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 ffsdrv_amd_erase_end();
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
296 }
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 void ffsdrv_amd_erase_end(void)
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 while ((*dev.addr & 0x80) == 0)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
301 ;
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 dev.state = DEV_READ;
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 tlw(led_off(LED_ERASE));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
306 }
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 void ffsdrv_amd_erase_suspend(void)
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 uint32 cpsr;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
311
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
312 tlw(led_on(LED_ERASE_SUSPEND));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
313 ttw(str(TTrDrvErase, "es" NL));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
314
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
315 // 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
316 if (*dev.addr & 0x80) {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
317 ffsdrv_amd_erase_end();
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
318 tlw(led_off(LED_ERASE_SUSPEND));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
319 return;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
320 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
321
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
322 // 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
323 // 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
324 // 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
325 // erase IS actually already finished.
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
326
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
327 cpsr = int_disable();
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
328 dev.state = DEV_ERASE_SUSPEND;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
329 *dev.addr = 0xB0;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
330
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
331 // Wait for erase suspend to finish
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
332 while ((*dev.addr & 0x80) == 0)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
333 ;
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 int_enable(cpsr);
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
336 }
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 void ffsdrv_amd_erase_resume(void)
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 uint32 cpsr;
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 ttw(str(TTrDrvErase, "er" NL));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
343
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
344 // 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
345 // 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
346 cpsr = int_disable();
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
347 dev.state = DEV_ERASE;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
348 *dev.addr = 0x30;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
349 int_enable(cpsr);
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 tlw(led_off(LED_ERASE_SUSPEND));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
352 }
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
353
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
354 const struct ffsdrv_s ffsdrv = {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
355 ffsdrv_null_init,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
356 ffsdrv_amd_erase,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
357 ffsdrv_amd_write_halfword,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
358 ffsdrv_generic_write,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
359 ffsdrv_amd_write_end,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
360 ffsdrv_amd_erase_suspend,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
361 ffsdrv_amd_erase_resume
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
362 };
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
363
940
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
364 #elif FLASH_IS_INTEL_ONEBANK
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
365
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
366 extern int ffsdrv_ram_intel_sb_init(void);
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
367 extern void ffsdrv_ram_intel_sb_write_halfword(volatile uint16 *addr,
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
368 uint16 value);
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
369 extern void ffsdrv_ram_intel_sb_erase(uint8 block);
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
370
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
371 const struct ffsdrv_s ffsdrv = {
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
372 ffsdrv_ram_intel_sb_init,
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
373 ffsdrv_ram_intel_sb_erase,
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
374 ffsdrv_ram_intel_sb_write_halfword,
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
375 ffsdrv_generic_write,
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
376 ffsdrv_null_write_end,
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
377 ffsdrv_null_erase_suspend,
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
378 ffsdrv_null_erase_resume
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
379 };
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
380
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
381 #else
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
382
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
383 #error "Flash hardware type unknown"
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
384
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
385 #endif /* flash hardware type */
0fb9b7f2ef87 gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 226
diff changeset
386
209
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
387 #else
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 /*
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
390 * 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
391 * 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
392 */
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
393
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
394 const struct ffsdrv_s ffsdrv = {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
395 ffsdrv_null_init,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
396 ffsdrv_null_erase,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
397 ffsdrv_null_write_halfword,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
398 ffsdrv_null_write,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
399 ffsdrv_null_write_end,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
400 ffsdrv_null_erase_suspend,
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
401 ffsdrv_null_erase_resume
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
402 };
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
403
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
404 #endif
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
405
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
406
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
407 /******************************************************************************
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
408 * Initialization
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
409 *
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
410 * Significantly simplified in FreeCalypso.
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
411 *
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
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
414 effs_t ffsdrv_init(void)
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
415 {
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
416 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
417 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
418 uint32 offset;
209
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
419
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
420 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
421 ttw(str(TTrDrvOther, "ffsdrv_init() {" NL));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
422
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
423 dev.state = DEV_READ;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
424 dev.atomlog2 = FFS_ATOM_LOG2;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
425 dev.atomsize = 1 << dev.atomlog2;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
426 dev.atomnotmask = dev.atomsize - 1;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
427
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
428 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
429 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
430 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
431 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
432 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
433 }
4d706a4134b0 FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
434 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
435
209
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
436 error = ffsdrv.init();
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
437
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
438 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
439 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
440 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
441 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
442 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
443 dev.atomlog2, dev.atomsize, dev.atomnotmask));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
444 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
445 ttw(ttr(TTrDrvOther, "} %d" NL, error));
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
446
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
447 return error;
6f4a12b4582f gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
448 }