Index: embios/trunk/init.c |
— | — | @@ -34,21 +34,35 @@ |
35 | 35 | #include "usb/usb.h"
|
36 | 36 |
|
37 | 37 | static const char welcomestring[] INITCONST_ATTR = "emBIOS v" VERSION " r" VERSION_SVN "\n\n";
|
| 38 | +static const char initthreadname[] INITCONST_ATTR = "Initialisation thread";
|
| 39 | +static uint32_t initstack[0x400] INITBSS_ATTR;
|
38 | 40 |
|
39 | | -void init() INITCODE_ATTR;
|
40 | | -void init()
|
| 41 | +void initthread() INITCODE_ATTR;
|
| 42 | +void initthread()
|
41 | 43 | {
|
42 | | - scheduler_init();
|
43 | | - console_init();
|
44 | | - lcd_init();
|
45 | | - lcdconsole_init();
|
46 | | - interrupt_init();
|
47 | 44 | cputs(1, welcomestring);
|
48 | 45 | i2c_init();
|
49 | 46 | power_init();
|
50 | 47 | usb_init();
|
| 48 | + DEBUGF("Initializing storage drivers...");
|
51 | 49 | storage_init();
|
| 50 | + DEBUGF("Initializing storage subsystem...");
|
52 | 51 | disk_init_subsystem();
|
| 52 | + DEBUGF("Reading partition tables...");
|
53 | 53 | disk_init();
|
| 54 | + DEBUGF("Mounting partitions...");
|
54 | 55 | disk_mount_all();
|
55 | | -} |
\ No newline at end of file |
| 56 | + DEBUGF("Finished initialisation sequence");
|
| 57 | +}
|
| 58 | +
|
| 59 | +void init() INITCODE_ATTR;
|
| 60 | +void init()
|
| 61 | +{
|
| 62 | + scheduler_init();
|
| 63 | + console_init();
|
| 64 | + lcd_init();
|
| 65 | + lcdconsole_init();
|
| 66 | + interrupt_init();
|
| 67 | + thread_create(initthreadname, initthread, initstack,
|
| 68 | + sizeof(initstack), USER_THREAD, 127, true);
|
| 69 | +}
|
Index: embios/trunk/target/ipodnano2g/nand.c |
— | — | @@ -78,15 +78,15 @@ |
79 | 79 | {0xA555D520, 8192, 3872, 0x80, 7, 2, 1, 2, 1}
|
80 | 80 | };
|
81 | 81 |
|
82 | | -uint8_t nand_tunk1[4];
|
83 | | -uint8_t nand_twp[4];
|
84 | | -uint8_t nand_tunk2[4];
|
85 | | -uint8_t nand_tunk3[4];
|
86 | | -int nand_type[4];
|
87 | | -int nand_powered = 0;
|
88 | | -int nand_interleaved = 0;
|
89 | | -int nand_cached = 0;
|
90 | | -long nand_last_activity_value = -1;
|
| 82 | +static uint8_t nand_tunk1[4];
|
| 83 | +static uint8_t nand_twp[4];
|
| 84 | +static uint8_t nand_tunk2[4];
|
| 85 | +static uint8_t nand_tunk3[4];
|
| 86 | +static int nand_type[4];
|
| 87 | +static int nand_powered = 0;
|
| 88 | +static int nand_interleaved = 0;
|
| 89 | +static int nand_cached = 0;
|
| 90 | +static long nand_last_activity_value = -1;
|
91 | 91 | static uint32_t nand_stack[0x80];
|
92 | 92 |
|
93 | 93 | static struct mutex nand_mtx;
|
— | — | @@ -100,7 +100,7 @@ |
101 | 101 | static uint8_t nand_ecc[0x30] CACHEALIGN_ATTR;
|
102 | 102 |
|
103 | 103 |
|
104 | | -uint32_t nand_unlock(uint32_t rc)
|
| 104 | +static uint32_t nand_unlock(uint32_t rc)
|
105 | 105 | {
|
106 | 106 | nand_last_activity_value = USEC_TIMER;
|
107 | 107 | mutex_unlock(&nand_mtx);
|
— | — | @@ -107,13 +107,13 @@ |
108 | 108 | return rc;
|
109 | 109 | }
|
110 | 110 |
|
111 | | -uint32_t ecc_unlock(uint32_t rc)
|
| 111 | +static uint32_t ecc_unlock(uint32_t rc)
|
112 | 112 | {
|
113 | 113 | mutex_unlock(&ecc_mtx);
|
114 | 114 | return rc;
|
115 | 115 | }
|
116 | 116 |
|
117 | | -uint32_t nand_timeout(uint32_t timeout)
|
| 117 | +static uint32_t nand_timeout(long timeout)
|
118 | 118 | {
|
119 | 119 | if (TIME_AFTER(USEC_TIMER, timeout)) return 1;
|
120 | 120 | else
|
— | — | @@ -123,7 +123,7 @@ |
124 | 124 | }
|
125 | 125 | }
|
126 | 126 |
|
127 | | -uint32_t nand_wait_rbbdone(void)
|
| 127 | +static uint32_t nand_wait_rbbdone(void)
|
128 | 128 | {
|
129 | 129 | uint32_t timeout = USEC_TIMER + 20000;
|
130 | 130 | while (!(FMCSTAT & FMCSTAT_RBBDONE))
|
— | — | @@ -132,7 +132,7 @@ |
133 | 133 | return 0;
|
134 | 134 | }
|
135 | 135 |
|
136 | | -uint32_t nand_wait_cmddone(void)
|
| 136 | +static uint32_t nand_wait_cmddone(void)
|
137 | 137 | {
|
138 | 138 | uint32_t timeout = USEC_TIMER + 20000;
|
139 | 139 | while (!(FMCSTAT & FMCSTAT_CMDDONE))
|
— | — | @@ -141,7 +141,7 @@ |
142 | 142 | return 0;
|
143 | 143 | }
|
144 | 144 |
|
145 | | -uint32_t nand_wait_addrdone(void)
|
| 145 | +static uint32_t nand_wait_addrdone(void)
|
146 | 146 | {
|
147 | 147 | uint32_t timeout = USEC_TIMER + 20000;
|
148 | 148 | while (!(FMCSTAT & FMCSTAT_ADDRDONE))
|
— | — | @@ -150,7 +150,7 @@ |
151 | 151 | return 0;
|
152 | 152 | }
|
153 | 153 |
|
154 | | -uint32_t nand_wait_chip_ready(uint32_t bank)
|
| 154 | +static uint32_t nand_wait_chip_ready(uint32_t bank)
|
155 | 155 | {
|
156 | 156 | uint32_t timeout = USEC_TIMER + 20000;
|
157 | 157 | while (!(FMCSTAT & (FMCSTAT_BANK0READY << bank)))
|
— | — | @@ -159,19 +159,19 @@ |
160 | 160 | return 0;
|
161 | 161 | }
|
162 | 162 |
|
163 | | -void nand_set_fmctrl0(uint32_t bank, uint32_t flags)
|
| 163 | +static void nand_set_fmctrl0(uint32_t bank, uint32_t flags)
|
164 | 164 | {
|
165 | 165 | FMCTRL0 = (nand_tunk1[bank] << 16) | (nand_twp[bank] << 12)
|
166 | 166 | | (1 << 11) | 1 | (1 << (bank + 1)) | flags;
|
167 | 167 | }
|
168 | 168 |
|
169 | | -uint32_t nand_send_cmd(uint32_t cmd)
|
| 169 | +static uint32_t nand_send_cmd(uint32_t cmd)
|
170 | 170 | {
|
171 | 171 | FMCMD = cmd;
|
172 | 172 | return nand_wait_rbbdone();
|
173 | 173 | }
|
174 | 174 |
|
175 | | -uint32_t nand_send_address(uint32_t page, uint32_t offset)
|
| 175 | +static uint32_t nand_send_address(uint32_t page, uint32_t offset)
|
176 | 176 | {
|
177 | 177 | FMANUM = 4;
|
178 | 178 | FMADDR0 = (page << 16) | offset;
|
— | — | @@ -190,7 +190,7 @@ |
191 | 191 | return 0;
|
192 | 192 | }
|
193 | 193 |
|
194 | | -uint32_t nand_wait_status_ready(uint32_t bank)
|
| 194 | +static uint32_t nand_wait_status_ready(uint32_t bank)
|
195 | 195 | {
|
196 | 196 | uint32_t timeout = USEC_TIMER + 20000;
|
197 | 197 | nand_set_fmctrl0(bank, 0);
|
— | — | @@ -211,8 +211,8 @@ |
212 | 212 | return nand_send_cmd(NAND_CMD_READ);
|
213 | 213 | }
|
214 | 214 |
|
215 | | -void nand_transfer_data_start(uint32_t bank, uint32_t direction,
|
216 | | - void* buffer, uint32_t size)
|
| 215 | +static void nand_transfer_data_start(uint32_t bank, uint32_t direction,
|
| 216 | + void* buffer, uint32_t size)
|
217 | 217 | {
|
218 | 218 | nand_set_fmctrl0(bank, FMCTRL0_ENABLEDMA);
|
219 | 219 | FMDNUM = size - 1;
|
— | — | @@ -229,7 +229,7 @@ |
230 | 230 | DMACOM3 = 4;
|
231 | 231 | }
|
232 | 232 |
|
233 | | -uint32_t nand_transfer_data_collect(uint32_t direction)
|
| 233 | +static uint32_t nand_transfer_data_collect(uint32_t direction)
|
234 | 234 | {
|
235 | 235 | uint32_t timeout = USEC_TIMER + 20000;
|
236 | 236 | while ((DMAALLST & DMAALLST_DMABUSY3))
|
— | — | @@ -241,8 +241,8 @@ |
242 | 242 | return 0;
|
243 | 243 | }
|
244 | 244 |
|
245 | | -uint32_t nand_transfer_data(uint32_t bank, uint32_t direction,
|
246 | | - void* buffer, uint32_t size)
|
| 245 | +static uint32_t nand_transfer_data(uint32_t bank, uint32_t direction,
|
| 246 | + void* buffer, uint32_t size)
|
247 | 247 | {
|
248 | 248 | nand_transfer_data_start(bank, direction, buffer, size);
|
249 | 249 | uint32_t rc = nand_transfer_data_collect(direction);
|
— | — | @@ -249,7 +249,8 @@ |
250 | 250 | return rc;
|
251 | 251 | }
|
252 | 252 |
|
253 | | -void ecc_start(uint32_t size, void* databuffer, void* sparebuffer, uint32_t type)
|
| 253 | +static void ecc_start(uint32_t size, void* databuffer, void* sparebuffer,
|
| 254 | + uint32_t type)
|
254 | 255 | {
|
255 | 256 | mutex_lock(&ecc_mtx, TIMEOUT_BLOCK);
|
256 | 257 | ECC_INT_CLR = 1;
|
— | — | @@ -261,7 +262,7 @@ |
262 | 263 | ECC_CTRL = type;
|
263 | 264 | }
|
264 | 265 |
|
265 | | -uint32_t ecc_collect(void)
|
| 266 | +static uint32_t ecc_collect(void)
|
266 | 267 | {
|
267 | 268 | uint32_t timeout = USEC_TIMER + 20000;
|
268 | 269 | while (!(SRCPND & INTMSK_ECC))
|
— | — | @@ -272,7 +273,7 @@ |
273 | 274 | return ecc_unlock(ECC_RESULT);
|
274 | 275 | }
|
275 | 276 |
|
276 | | -uint32_t ecc_decode(uint32_t size, void* databuffer, void* sparebuffer)
|
| 277 | +static uint32_t ecc_decode(uint32_t size, void* databuffer, void* sparebuffer)
|
277 | 278 | {
|
278 | 279 | ecc_start(size, databuffer, sparebuffer, ECCCTRL_STARTDECODING);
|
279 | 280 | uint32_t rc = ecc_collect();
|
— | — | @@ -279,7 +280,7 @@ |
280 | 281 | return rc;
|
281 | 282 | }
|
282 | 283 |
|
283 | | -uint32_t ecc_encode(uint32_t size, void* databuffer, void* sparebuffer)
|
| 284 | +static uint32_t ecc_encode(uint32_t size, void* databuffer, void* sparebuffer)
|
284 | 285 | {
|
285 | 286 | ecc_start(size, databuffer, sparebuffer, ECCCTRL_STARTENCODING);
|
286 | 287 | ecc_collect();
|
— | — | @@ -286,7 +287,7 @@ |
287 | 288 | return 0;
|
288 | 289 | }
|
289 | 290 |
|
290 | | -uint32_t nand_check_empty(uint8_t* buffer)
|
| 291 | +static uint32_t nand_check_empty(uint8_t* buffer)
|
291 | 292 | {
|
292 | 293 | uint32_t i, count;
|
293 | 294 | count = 0;
|
— | — | @@ -295,7 +296,7 @@ |
296 | 297 | return 0;
|
297 | 298 | }
|
298 | 299 |
|
299 | | -uint32_t nand_get_chip_type(uint32_t bank)
|
| 300 | +static uint32_t nand_get_chip_type(uint32_t bank)
|
300 | 301 | {
|
301 | 302 | mutex_lock(&nand_mtx, TIMEOUT_BLOCK);
|
302 | 303 | uint32_t result;
|
— | — | @@ -431,8 +432,9 @@ |
432 | 433 | return nand_unlock(rc);
|
433 | 434 | }
|
434 | 435 |
|
435 | | -uint32_t nand_write_page_int(uint32_t bank, uint32_t page, void* databuffer,
|
436 | | - void* sparebuffer, uint32_t doecc, uint32_t wait)
|
| 436 | +static uint32_t nand_write_page_int(uint32_t bank, uint32_t page,
|
| 437 | + void* databuffer, void* sparebuffer,
|
| 438 | + uint32_t doecc, uint32_t wait)
|
437 | 439 | {
|
438 | 440 | uint8_t* data = nand_data;
|
439 | 441 | uint8_t* spare = nand_spare;
|
— | — | @@ -658,7 +660,7 @@ |
659 | 661 | return nand_wait_status_ready(bank);
|
660 | 662 | }
|
661 | 663 |
|
662 | | -uint32_t nand_block_erase_fast(uint32_t page)
|
| 664 | +static uint32_t nand_block_erase_fast(uint32_t page)
|
663 | 665 | {
|
664 | 666 | uint32_t i, rc = 0;
|
665 | 667 | mutex_lock(&nand_mtx, TIMEOUT_BLOCK);
|
Index: embios/trunk/target/ipodnano2g/ftl.c |
— | — | @@ -362,54 +362,54 @@ |
363 | 363 | uint32_t ftl_banks;
|
364 | 364 |
|
365 | 365 | /* Block map, used vor pBlock to vBlock mapping */
|
366 | | -uint16_t ftl_map[0x2000];
|
| 366 | +static uint16_t ftl_map[0x2000];
|
367 | 367 |
|
368 | 368 | /* VFL context for each bank */
|
369 | | -struct ftl_vfl_cxt_type ftl_vfl_cxt[4];
|
| 369 | +static struct ftl_vfl_cxt_type ftl_vfl_cxt[4];
|
370 | 370 |
|
371 | 371 | /* FTL context */
|
372 | | -struct ftl_cxt_type ftl_cxt;
|
| 372 | +static struct ftl_cxt_type ftl_cxt;
|
373 | 373 |
|
374 | 374 | /* Temporary data buffers for internal use by the FTL */
|
375 | | -uint8_t ftl_buffer[0x800] CACHEALIGN_ATTR;
|
| 375 | +static uint8_t ftl_buffer[0x800] CACHEALIGN_ATTR;
|
376 | 376 |
|
377 | 377 | /* Temporary spare byte buffer for internal use by the FTL */
|
378 | | -union ftl_spare_data_type ftl_sparebuffer[FTL_WRITESPARE_SIZE] CACHEALIGN_ATTR;
|
| 378 | +static union ftl_spare_data_type ftl_sparebuffer[FTL_WRITESPARE_SIZE] CACHEALIGN_ATTR;
|
379 | 379 |
|
380 | 380 |
|
381 | 381 | #ifndef FTL_READONLY
|
382 | 382 |
|
383 | 383 | /* Lowlevel BBT for each bank */
|
384 | | -uint8_t ftl_bbt[4][0x410];
|
| 384 | +static uint8_t ftl_bbt[4][0x410];
|
385 | 385 |
|
386 | 386 | /* Erase counters for the vBlocks */
|
387 | | -uint16_t ftl_erasectr[0x2000];
|
| 387 | +static uint16_t ftl_erasectr[0x2000];
|
388 | 388 |
|
389 | 389 | /* Used by ftl_log */
|
390 | | -uint16_t ftl_offsets[0x11][0x200];
|
| 390 | +static uint16_t ftl_offsets[0x11][0x200];
|
391 | 391 |
|
392 | 392 | /* Structs keeping record of scattered page blocks */
|
393 | | -struct ftl_log_type ftl_log[0x11];
|
| 393 | +static struct ftl_log_type ftl_log[0x11];
|
394 | 394 |
|
395 | 395 | /* Global cross-bank update sequence number of the VFL context */
|
396 | | -uint32_t ftl_vfl_usn;
|
| 396 | +static uint32_t ftl_vfl_usn;
|
397 | 397 |
|
398 | 398 | /* Keeps track (temporarily) of troublesome blocks */
|
399 | | -struct ftl_trouble_type ftl_troublelog[5];
|
| 399 | +static struct ftl_trouble_type ftl_troublelog[5];
|
400 | 400 |
|
401 | 401 | /* Counts erase counter page changes, after 100 of them the affected
|
402 | 402 | page will be committed to the flash. */
|
403 | | -uint8_t ftl_erasectr_dirt[8];
|
| 403 | +static uint8_t ftl_erasectr_dirt[8];
|
404 | 404 |
|
405 | 405 | /* Buffer needed for copying pages around while moving or committing blocks.
|
406 | 406 | This can't be shared with ftl_buffer, because this one could be overwritten
|
407 | 407 | during the copying operation in order to e.g. commit a CXT. */
|
408 | | -uint8_t ftl_copybuffer[FTL_COPYBUF_SIZE][0x800] CACHEALIGN_ATTR;
|
409 | | -union ftl_spare_data_type ftl_copyspare[FTL_COPYBUF_SIZE] CACHEALIGN_ATTR;
|
| 408 | +static uint8_t ftl_copybuffer[FTL_COPYBUF_SIZE][0x800] CACHEALIGN_ATTR;
|
| 409 | +static union ftl_spare_data_type ftl_copyspare[FTL_COPYBUF_SIZE] CACHEALIGN_ATTR;
|
410 | 410 |
|
411 | 411 | /* Needed to store the old scattered page offsets in order to be able to roll
|
412 | 412 | back if something fails while compacting a scattered page block. */
|
413 | | -uint16_t ftl_offsets_backup[0x200] CACHEALIGN_ATTR;
|
| 413 | +static uint16_t ftl_offsets_backup[0x200] CACHEALIGN_ATTR;
|
414 | 414 |
|
415 | 415 | #endif
|
416 | 416 |
|
— | — | @@ -420,7 +420,7 @@ |
421 | 421 |
|
422 | 422 | /* Finds a device info page for the specified bank and returns its number.
|
423 | 423 | Used to check if one is present, and to read the lowlevel BBT. */
|
424 | | -uint32_t ftl_find_devinfo(uint32_t bank)
|
| 424 | +static uint32_t ftl_find_devinfo(uint32_t bank)
|
425 | 425 | {
|
426 | 426 | /* Scan the last 10% of the flash for device info pages */
|
427 | 427 | uint32_t lowestBlock = ftl_nand_type->blocks
|
— | — | @@ -444,7 +444,7 @@ |
445 | 445 |
|
446 | 446 |
|
447 | 447 | /* Checks if all banks have proper device info pages */
|
448 | | -uint32_t ftl_has_devinfo(void)
|
| 448 | +static uint32_t ftl_has_devinfo(void)
|
449 | 449 | {
|
450 | 450 | uint32_t i;
|
451 | 451 | for (i = 0; i < ftl_banks; i++) if (ftl_find_devinfo(i) == 0) return 0;
|
— | — | @@ -454,7 +454,7 @@ |
455 | 455 |
|
456 | 456 | /* Loads the lowlevel BBT for a bank to the specified buffer.
|
457 | 457 | This is based on some cryptic disassembly and not fully understood yet. */
|
458 | | -uint32_t ftl_load_bbt(uint32_t bank, uint8_t* bbt)
|
| 458 | +static uint32_t ftl_load_bbt(uint32_t bank, uint8_t* bbt)
|
459 | 459 | {
|
460 | 460 | uint32_t i, j;
|
461 | 461 | uint32_t pagebase, page = ftl_find_devinfo(bank), page2;
|
— | — | @@ -488,8 +488,8 @@ |
489 | 489 |
|
490 | 490 |
|
491 | 491 | /* Calculates the checksums for the VFL context page of the specified bank */
|
492 | | -void ftl_vfl_calculate_checksum(uint32_t bank,
|
493 | | - uint32_t* checksum1, uint32_t* checksum2)
|
| 492 | +static void ftl_vfl_calculate_checksum(uint32_t bank,
|
| 493 | + uint32_t* checksum1, uint32_t* checksum2)
|
494 | 494 | {
|
495 | 495 | uint32_t i;
|
496 | 496 | *checksum1 = 0xAABBCCDD;
|
— | — | @@ -504,7 +504,7 @@ |
505 | 505 |
|
506 | 506 | /* Checks if the checksums of the VFL context
|
507 | 507 | of the specified bank are correct */
|
508 | | -uint32_t ftl_vfl_verify_checksum(uint32_t bank)
|
| 508 | +static uint32_t ftl_vfl_verify_checksum(uint32_t bank)
|
509 | 509 | {
|
510 | 510 | uint32_t checksum1, checksum2;
|
511 | 511 | ftl_vfl_calculate_checksum(bank, &checksum1, &checksum2);
|
— | — | @@ -519,7 +519,7 @@ |
520 | 520 |
|
521 | 521 | #ifndef FTL_READONLY
|
522 | 522 | /* Updates the checksums of the VFL context of the specified bank */
|
523 | | -void ftl_vfl_update_checksum(uint32_t bank)
|
| 523 | +static void ftl_vfl_update_checksum(uint32_t bank)
|
524 | 524 | {
|
525 | 525 | ftl_vfl_calculate_checksum(bank, &ftl_vfl_cxt[bank].checksum1,
|
526 | 526 | &ftl_vfl_cxt[bank].checksum2);
|
— | — | @@ -530,7 +530,7 @@ |
531 | 531 | #ifndef FTL_READONLY
|
532 | 532 | /* Writes 8 copies of the VFL context of the specified bank to flash,
|
533 | 533 | and succeeds if at least 4 can be read back properly. */
|
534 | | -uint32_t ftl_vfl_store_cxt(uint32_t bank)
|
| 534 | +static uint32_t ftl_vfl_store_cxt(uint32_t bank)
|
535 | 535 | {
|
536 | 536 | uint32_t i;
|
537 | 537 | ftl_vfl_cxt[bank].updatecount--;
|
— | — | @@ -574,7 +574,7 @@ |
575 | 575 | #ifndef FTL_READONLY
|
576 | 576 | /* Commits the VFL context of the specified bank to flash,
|
577 | 577 | retries until it works or all available pages have been tried */
|
578 | | -uint32_t ftl_vfl_commit_cxt(uint32_t bank)
|
| 578 | +static uint32_t ftl_vfl_commit_cxt(uint32_t bank)
|
579 | 579 | {
|
580 | 580 | DEBUGF("FTL: VFL: Committing context on bank %d", bank);
|
581 | 581 | if (ftl_vfl_cxt[bank].nextcxtpage + 8 <= ftl_nand_type->pagesperblock)
|
— | — | @@ -604,7 +604,7 @@ |
605 | 605 | /* Returns a pointer to the most recently updated VFL context,
|
606 | 606 | used to find out the current FTL context vBlock numbers
|
607 | 607 | (planetbeing's "maxthing") */
|
608 | | -struct ftl_vfl_cxt_type* ftl_vfl_get_newest_cxt(void)
|
| 608 | +static struct ftl_vfl_cxt_type* ftl_vfl_get_newest_cxt(void)
|
609 | 609 | {
|
610 | 610 | uint32_t i, maxusn;
|
611 | 611 | struct ftl_vfl_cxt_type* cxt = (struct ftl_vfl_cxt_type*)0;
|
— | — | @@ -621,7 +621,7 @@ |
622 | 622 |
|
623 | 623 | /* Checks if the specified pBlock is marked bad in the supplied lowlevel BBT.
|
624 | 624 | Only used while mounting the VFL. */
|
625 | | -uint32_t ftl_is_good_block(uint8_t* bbt, uint32_t block)
|
| 625 | +static uint32_t ftl_is_good_block(uint8_t* bbt, uint32_t block)
|
626 | 626 | {
|
627 | 627 | if ((bbt[block >> 3] & (1 << (block & 7))) == 0) return 0;
|
628 | 628 | else return 1;
|
— | — | @@ -629,7 +629,7 @@ |
630 | 630 |
|
631 | 631 |
|
632 | 632 | /* Checks if the specified vBlock could be remapped */
|
633 | | -uint32_t ftl_vfl_is_good_block(uint32_t bank, uint32_t block)
|
| 633 | +static uint32_t ftl_vfl_is_good_block(uint32_t bank, uint32_t block)
|
634 | 634 | {
|
635 | 635 | uint8_t bbtentry = ftl_vfl_cxt[bank].bbt[block >> 6];
|
636 | 636 | if ((bbtentry & (1 << ((7 - (block >> 3)) & 7))) == 0) return 0;
|
— | — | @@ -640,7 +640,7 @@ |
641 | 641 | #ifndef FTL_READONLY
|
642 | 642 | /* Sets or unsets the bad bit of the specified vBlock
|
643 | 643 | in the specified bank's VFL context */
|
644 | | -void ftl_vfl_set_good_block(uint32_t bank, uint32_t block, uint32_t isgood)
|
| 644 | +static void ftl_vfl_set_good_block(uint32_t bank, uint32_t block, uint32_t isgood)
|
645 | 645 | {
|
646 | 646 | uint8_t bit = (1 << ((7 - (block >> 3)) & 7));
|
647 | 647 | if (isgood == 1) ftl_vfl_cxt[bank].bbt[block >> 6] |= bit;
|
— | — | @@ -650,9 +650,9 @@ |
651 | 651 |
|
652 | 652 |
|
653 | 653 | /* Tries to read a VFL context from the specified bank, pBlock and page */
|
654 | | -uint32_t ftl_vfl_read_page(uint32_t bank, uint32_t block,
|
655 | | - uint32_t startpage, void* databuffer,
|
656 | | - union ftl_spare_data_type* sparebuffer)
|
| 654 | +static uint32_t ftl_vfl_read_page(uint32_t bank, uint32_t block,
|
| 655 | + uint32_t startpage, void* databuffer,
|
| 656 | + union ftl_spare_data_type* sparebuffer)
|
657 | 657 | {
|
658 | 658 | uint32_t i;
|
659 | 659 | for (i = 0; i < 8; i++)
|
— | — | @@ -670,7 +670,7 @@ |
671 | 671 |
|
672 | 672 |
|
673 | 673 | /* Translates a bank and vBlock to a pBlock, following remaps */
|
674 | | -uint32_t ftl_vfl_get_physical_block(uint32_t bank, uint32_t block)
|
| 674 | +static uint32_t ftl_vfl_get_physical_block(uint32_t bank, uint32_t block)
|
675 | 675 | {
|
676 | 676 | if (ftl_vfl_is_good_block(bank, block) == 1) return block;
|
677 | 677 |
|
— | — | @@ -689,7 +689,7 @@ |
690 | 690 |
|
691 | 691 | #ifndef FTL_READONLY
|
692 | 692 | /* Checks if remapping is scheduled for the specified bank and vBlock */
|
693 | | -uint32_t ftl_vfl_check_remap_scheduled(uint32_t bank, uint32_t block)
|
| 693 | +static uint32_t ftl_vfl_check_remap_scheduled(uint32_t bank, uint32_t block)
|
694 | 694 | {
|
695 | 695 | uint32_t i;
|
696 | 696 | for (i = 0x333; i > 0 && i > ftl_vfl_cxt[bank].scheduledstart; i--)
|
— | — | @@ -701,7 +701,7 @@ |
702 | 702 |
|
703 | 703 | #ifndef FTL_READONLY
|
704 | 704 | /* Schedules remapping for the specified bank and vBlock */
|
705 | | -void ftl_vfl_schedule_block_for_remap(uint32_t bank, uint32_t block)
|
| 705 | +static void ftl_vfl_schedule_block_for_remap(uint32_t bank, uint32_t block)
|
706 | 706 | {
|
707 | 707 | if (ftl_vfl_check_remap_scheduled(bank, block) == 1) return;
|
708 | 708 | panicf(PANIC_FATAL, "FTL: Scheduling bank %u block %u for remap!",
|
— | — | @@ -717,7 +717,7 @@ |
718 | 718 | #ifndef FTL_READONLY
|
719 | 719 | /* Removes the specified bank and vBlock combination
|
720 | 720 | from the remap scheduled list */
|
721 | | -void ftl_vfl_mark_remap_done(uint32_t bank, uint32_t block)
|
| 721 | +static void ftl_vfl_mark_remap_done(uint32_t bank, uint32_t block)
|
722 | 722 | {
|
723 | 723 | uint32_t i;
|
724 | 724 | uint32_t start = ftl_vfl_cxt[bank].scheduledstart;
|
— | — | @@ -738,7 +738,7 @@ |
739 | 739 | /* Logs that there is trouble for the specified vBlock on the specified bank.
|
740 | 740 | The vBlock will be scheduled for remap
|
741 | 741 | if there is too much trouble with it. */
|
742 | | -void ftl_vfl_log_trouble(uint32_t bank, uint32_t vblock)
|
| 742 | +static void ftl_vfl_log_trouble(uint32_t bank, uint32_t vblock)
|
743 | 743 | {
|
744 | 744 | uint32_t i;
|
745 | 745 | for (i = 0; i < 5; i++)
|
— | — | @@ -767,7 +767,7 @@ |
768 | 768 |
|
769 | 769 | #ifndef FTL_READONLY
|
770 | 770 | /* Logs a successful erase for the specified vBlock on the specified bank */
|
771 | | -void ftl_vfl_log_success(uint32_t bank, uint32_t vblock)
|
| 771 | +static void ftl_vfl_log_success(uint32_t bank, uint32_t vblock)
|
772 | 772 | {
|
773 | 773 | uint32_t i;
|
774 | 774 | for (i = 0; i < 5; i++)
|
— | — | @@ -787,7 +787,7 @@ |
788 | 788 | not caring about data in there.
|
789 | 789 | If it worked, it will return the new pBlock number,
|
790 | 790 | if not (no more spare blocks available), it will return zero. */
|
791 | | -uint32_t ftl_vfl_remap_block(uint32_t bank, uint32_t block)
|
| 791 | +static uint32_t ftl_vfl_remap_block(uint32_t bank, uint32_t block)
|
792 | 792 | {
|
793 | 793 | uint32_t i;
|
794 | 794 | uint32_t newblock = 0, newidx;
|
— | — | @@ -818,8 +818,8 @@ |
819 | 819 |
|
820 | 820 |
|
821 | 821 | /* Reads the specified vPage, dealing with all kinds of trouble */
|
822 | | -uint32_t ftl_vfl_read(uint32_t vpage, void* buffer, void* sparebuffer,
|
823 | | - uint32_t checkempty, uint32_t remaponfail)
|
| 822 | +static uint32_t ftl_vfl_read(uint32_t vpage, void* buffer, void* sparebuffer,
|
| 823 | + uint32_t checkempty, uint32_t remaponfail)
|
824 | 824 | {
|
825 | 825 | #ifdef VFL_TRACE
|
826 | 826 | DEBUGF("FTL: VFL: Reading page %d", vpage);
|
— | — | @@ -866,8 +866,8 @@ |
867 | 867 |
|
868 | 868 |
|
869 | 869 | /* Multi-bank version of ftl_vfl_read, will read ftl_banks pages in parallel */
|
870 | | -uint32_t ftl_vfl_read_fast(uint32_t vpage, void* buffer, void* sparebuffer,
|
871 | | - uint32_t checkempty, uint32_t remaponfail)
|
| 870 | +static uint32_t ftl_vfl_read_fast(uint32_t vpage, void* buffer, void* sparebuffer,
|
| 871 | + uint32_t checkempty, uint32_t remaponfail)
|
872 | 872 | {
|
873 | 873 | #ifdef VFL_TRACE
|
874 | 874 | DEBUGF("FTL: VFL: Fast reading page %d on all banks", vpage);
|
— | — | @@ -942,8 +942,8 @@ |
943 | 943 |
|
944 | 944 | #ifndef FTL_READONLY
|
945 | 945 | /* Writes the specified vPage, dealing with all kinds of trouble */
|
946 | | -uint32_t ftl_vfl_write(uint32_t vpage, uint32_t count,
|
947 | | - void* buffer, void* sparebuffer)
|
| 946 | +static uint32_t ftl_vfl_write(uint32_t vpage, uint32_t count,
|
| 947 | + void* buffer, void* sparebuffer)
|
948 | 948 | {
|
949 | 949 | uint32_t i, j;
|
950 | 950 | #ifdef VFL_TRACE
|
— | — | @@ -1019,7 +1019,7 @@ |
1020 | 1020 |
|
1021 | 1021 |
|
1022 | 1022 | /* Mounts the VFL on all banks */
|
1023 | | -uint32_t ftl_vfl_open(void)
|
| 1023 | +static uint32_t ftl_vfl_open(void)
|
1024 | 1024 | {
|
1025 | 1025 | uint32_t i, j, k;
|
1026 | 1026 | uint32_t minusn, vflcxtidx, last;
|
— | — | @@ -1112,7 +1112,7 @@ |
1113 | 1113 |
|
1114 | 1114 |
|
1115 | 1115 | /* Mounts the actual FTL */
|
1116 | | -uint32_t ftl_open(void)
|
| 1116 | +static uint32_t ftl_open(void)
|
1117 | 1117 | {
|
1118 | 1118 | uint32_t i;
|
1119 | 1119 | uint32_t ret;
|
— | — | @@ -1264,7 +1264,7 @@ |
1265 | 1265 | #ifndef FTL_READONLY
|
1266 | 1266 | /* Returns a pointer to the ftl_log entry for the specified vBlock,
|
1267 | 1267 | or null, if there is none */
|
1268 | | -struct ftl_log_type* ftl_get_log_entry(uint32_t block)
|
| 1268 | +static struct ftl_log_type* ftl_get_log_entry(uint32_t block)
|
1269 | 1269 | {
|
1270 | 1270 | uint32_t i;
|
1271 | 1271 | for (i = 0; i < 0x11; i++)
|
— | — | @@ -1365,7 +1365,7 @@ |
1366 | 1366 | #ifndef FTL_READONLY
|
1367 | 1367 | /* Performs a vBlock erase, dealing with hardware,
|
1368 | 1368 | remapping and all kinds of trouble */
|
1369 | | -uint32_t ftl_erase_block_internal(uint32_t block)
|
| 1369 | +static uint32_t ftl_erase_block_internal(uint32_t block)
|
1370 | 1370 | {
|
1371 | 1371 | uint32_t i, j;
|
1372 | 1372 | block = block + ftl_nand_type->blocks
|
— | — | @@ -1409,7 +1409,7 @@ |
1410 | 1410 |
|
1411 | 1411 | #ifndef FTL_READONLY
|
1412 | 1412 | /* Highlevel vBlock erase, that increments the erase counter for the block */
|
1413 | | -uint32_t ftl_erase_block(uint32_t block)
|
| 1413 | +static uint32_t ftl_erase_block(uint32_t block)
|
1414 | 1414 | {
|
1415 | 1415 | ftl_erasectr[block]++;
|
1416 | 1416 | if (ftl_erasectr_dirt[block >> 10] == 100) ftl_cxt.erasedirty = 1;
|
— | — | @@ -1422,7 +1422,7 @@ |
1423 | 1423 | #ifndef FTL_READONLY
|
1424 | 1424 | /* Allocates a block from the pool,
|
1425 | 1425 | returning its vBlock number, or 0xFFFFFFFF on error */
|
1426 | | -uint32_t ftl_allocate_pool_block(void)
|
| 1426 | +static uint32_t ftl_allocate_pool_block(void)
|
1427 | 1427 | {
|
1428 | 1428 | uint32_t i;
|
1429 | 1429 | uint32_t erasectr = 0xFFFFFFFF, bestidx = 0xFFFFFFFF, block;
|
— | — | @@ -1456,7 +1456,7 @@ |
1457 | 1457 |
|
1458 | 1458 | #ifndef FTL_READONLY
|
1459 | 1459 | /* Releases a vBlock back into the pool */
|
1460 | | -void ftl_release_pool_block(uint32_t block)
|
| 1460 | +static void ftl_release_pool_block(uint32_t block)
|
1461 | 1461 | {
|
1462 | 1462 | if (block >= (uint32_t)ftl_nand_type->userblocks + 0x17)
|
1463 | 1463 | panicf(PANIC_FATAL, "FTL: Tried to release block %u", (unsigned)block);
|
— | — | @@ -1470,7 +1470,7 @@ |
1471 | 1471 | #ifndef FTL_READONLY
|
1472 | 1472 | /* Commits the location of the FTL context blocks
|
1473 | 1473 | to a semi-randomly chosen VFL context */
|
1474 | | -uint32_t ftl_store_ctrl_block_list(void)
|
| 1474 | +static uint32_t ftl_store_ctrl_block_list(void)
|
1475 | 1475 | {
|
1476 | 1476 | uint32_t i;
|
1477 | 1477 | for (i = 0; i < ftl_banks; i++)
|
— | — | @@ -1483,7 +1483,7 @@ |
1484 | 1484 | #ifndef FTL_READONLY
|
1485 | 1485 | /* Saves the n-th erase counter page to the flash,
|
1486 | 1486 | because it is too dirty or needs to be moved. */
|
1487 | | -uint32_t ftl_save_erasectr_page(uint32_t index)
|
| 1487 | +static uint32_t ftl_save_erasectr_page(uint32_t index)
|
1488 | 1488 | {
|
1489 | 1489 | memset(&ftl_sparebuffer[0], 0xFF, 0x40);
|
1490 | 1490 | ftl_sparebuffer[0].meta.usn = ftl_cxt.usn;
|
— | — | @@ -1509,7 +1509,7 @@ |
1510 | 1510 | #ifndef FTL_READONLY
|
1511 | 1511 | /* Increments ftl_cxt.ftlctrlpage to the next available FTL context page,
|
1512 | 1512 | allocating a new context block if neccessary. */
|
1513 | | -uint32_t ftl_next_ctrl_pool_page(void)
|
| 1513 | +static uint32_t ftl_next_ctrl_pool_page(void)
|
1514 | 1514 | {
|
1515 | 1515 | uint32_t i;
|
1516 | 1516 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
|
— | — | @@ -1548,8 +1548,8 @@ |
1549 | 1549 |
|
1550 | 1550 | #ifndef FTL_READONLY
|
1551 | 1551 | /* Copies a vPage from one location to another */
|
1552 | | -uint32_t ftl_copy_page(uint32_t source, uint32_t destination,
|
1553 | | - uint32_t lpn, uint32_t type)
|
| 1552 | +static uint32_t ftl_copy_page(uint32_t source, uint32_t destination,
|
| 1553 | + uint32_t lpn, uint32_t type)
|
1554 | 1554 | {
|
1555 | 1555 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
|
1556 | 1556 | uint32_t rc = ftl_vfl_read(source, ftl_copybuffer[0],
|
— | — | @@ -1569,7 +1569,7 @@ |
1570 | 1570 |
|
1571 | 1571 | #ifndef FTL_READONLY
|
1572 | 1572 | /* Copies a pBlock to a vBlock */
|
1573 | | -uint32_t ftl_copy_block(uint32_t source, uint32_t destination)
|
| 1573 | +static uint32_t ftl_copy_block(uint32_t source, uint32_t destination)
|
1574 | 1574 | {
|
1575 | 1575 | uint32_t i, j;
|
1576 | 1576 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
|
— | — | @@ -1611,7 +1611,7 @@ |
1612 | 1612 |
|
1613 | 1613 | #ifndef FTL_READONLY
|
1614 | 1614 | /* Clears ftl_log.issequential, if something violating that is written. */
|
1615 | | -void ftl_check_still_sequential(struct ftl_log_type* entry, uint32_t page)
|
| 1615 | +static void ftl_check_still_sequential(struct ftl_log_type* entry, uint32_t page)
|
1616 | 1616 | {
|
1617 | 1617 | if (entry->pagesused != entry->pagescurrent
|
1618 | 1618 | || entry->pageoffsets[page] != page)
|
— | — | @@ -1628,7 +1628,7 @@ |
1629 | 1629 | space again. This is usually done when a scattered page block is being
|
1630 | 1630 | removed because it is full, but less than half of the pages in there are
|
1631 | 1631 | still in use and rest is just filled with old crap. */
|
1632 | | -uint32_t ftl_compact_scattered(struct ftl_log_type* entry)
|
| 1632 | +static uint32_t ftl_compact_scattered(struct ftl_log_type* entry)
|
1633 | 1633 | {
|
1634 | 1634 | uint32_t i, j;
|
1635 | 1635 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
|
— | — | @@ -1684,7 +1684,7 @@ |
1685 | 1685 |
|
1686 | 1686 | #ifndef FTL_READONLY
|
1687 | 1687 | /* Commits an ftl_log entry to proper blocks, no matter what's in there. */
|
1688 | | -uint32_t ftl_commit_scattered(struct ftl_log_type* entry)
|
| 1688 | +static uint32_t ftl_commit_scattered(struct ftl_log_type* entry)
|
1689 | 1689 | {
|
1690 | 1690 | uint32_t i;
|
1691 | 1691 | uint32_t error;
|
— | — | @@ -1712,7 +1712,7 @@ |
1713 | 1713 | sequentially until now, in order to be able to save a block erase by
|
1714 | 1714 | committing it without needing to copy it again.
|
1715 | 1715 | If this fails for whichever reason, it will be committed the usual way. */
|
1716 | | -uint32_t ftl_commit_sequential(struct ftl_log_type* entry)
|
| 1716 | +static uint32_t ftl_commit_sequential(struct ftl_log_type* entry)
|
1717 | 1717 | {
|
1718 | 1718 | uint32_t i;
|
1719 | 1719 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
|
— | — | @@ -1758,7 +1758,7 @@ |
1759 | 1759 | /* If a log entry is supplied, its scattered page block will be removed in
|
1760 | 1760 | whatever way seems most appropriate. Else, the oldest scattered page block
|
1761 | 1761 | will be freed by committing it. */
|
1762 | | -uint32_t ftl_remove_scattered_block(struct ftl_log_type* entry)
|
| 1762 | +static uint32_t ftl_remove_scattered_block(struct ftl_log_type* entry)
|
1763 | 1763 | {
|
1764 | 1764 | uint32_t i;
|
1765 | 1765 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
|
— | — | @@ -1794,7 +1794,7 @@ |
1795 | 1795 |
|
1796 | 1796 | #ifndef FTL_READONLY
|
1797 | 1797 | /* Initialize a log entry to the values for an empty scattered page block */
|
1798 | | -void ftl_init_log_entry(struct ftl_log_type* entry)
|
| 1798 | +static void ftl_init_log_entry(struct ftl_log_type* entry)
|
1799 | 1799 | {
|
1800 | 1800 | entry->issequential = 1;
|
1801 | 1801 | entry->pagescurrent = 0;
|
— | — | @@ -1807,7 +1807,7 @@ |
1808 | 1808 | #ifndef FTL_READONLY
|
1809 | 1809 | /* Allocates a log entry for the specified vBlock,
|
1810 | 1810 | first making space, if neccessary. */
|
1811 | | -struct ftl_log_type* ftl_allocate_log_entry(uint32_t block)
|
| 1811 | +static struct ftl_log_type* ftl_allocate_log_entry(uint32_t block)
|
1812 | 1812 | {
|
1813 | 1813 | uint32_t i;
|
1814 | 1814 | struct ftl_log_type* entry = ftl_get_log_entry(block);
|
— | — | @@ -1848,7 +1848,7 @@ |
1849 | 1849 |
|
1850 | 1850 | #ifndef FTL_READONLY
|
1851 | 1851 | /* Commits the FTL block map, erase counters, and context to flash */
|
1852 | | -uint32_t ftl_commit_cxt(void)
|
| 1852 | +static uint32_t ftl_commit_cxt(void)
|
1853 | 1853 | {
|
1854 | 1854 | uint32_t i;
|
1855 | 1855 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
|
— | — | @@ -1892,7 +1892,7 @@ |
1893 | 1893 | /* Swaps the most and least worn block on the flash,
|
1894 | 1894 | to better distribute wear. It will refuse to do anything
|
1895 | 1895 | if the wear spread is lower than 5 erases. */
|
1896 | | -uint32_t ftl_swap_blocks(void)
|
| 1896 | +static uint32_t ftl_swap_blocks(void)
|
1897 | 1897 | {
|
1898 | 1898 | uint32_t i;
|
1899 | 1899 | uint32_t min = 0xFFFFFFFF, max = 0, maxidx = 0x14;
|
— | — | @@ -2118,6 +2118,8 @@ |
2119 | 2119 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
|
2120 | 2120 | if (ftl_cxt.clean_flag == 1) return 0;
|
2121 | 2121 |
|
| 2122 | + mutex_lock(&ftl_mtx, TIMEOUT_BLOCK);
|
| 2123 | +
|
2122 | 2124 | #ifdef FTL_TRACE
|
2123 | 2125 | DEBUGF("FTL: Syncing");
|
2124 | 2126 | #endif
|
Index: embios/trunk/usb/synopsysotg.c |
— | — | @@ -51,7 +51,7 @@ |
52 | 52 | return (DSTS & 2) == 0 ? 1 : 0;
|
53 | 53 | }
|
54 | 54 |
|
55 | | -void reset_endpoints(int reinit)
|
| 55 | +static void reset_endpoints(int reinit)
|
56 | 56 | {
|
57 | 57 | unsigned int i;
|
58 | 58 | for (i = 0; i < sizeof(endpoints)/sizeof(struct ep_type); i++)
|
— | — | @@ -257,7 +257,7 @@ |
258 | 258 | DCFG = (DCFG & ~0x7F0) | (address << 4);
|
259 | 259 | }
|
260 | 260 |
|
261 | | -void ep_send(int ep, const void *ptr, int length)
|
| 261 | +static void ep_send(int ep, const void *ptr, int length)
|
262 | 262 | {
|
263 | 263 | endpoints[ep].busy = true;
|
264 | 264 | endpoints[ep].size = length;
|
— | — | @@ -273,13 +273,12 @@ |
274 | 274 | {
|
275 | 275 | DIEPTSIZ(ep) = length | (packets << 19);
|
276 | 276 | DIEPDMA(ep) = (uint32_t)ptr;
|
277 | | -// if (length > 64) panicf(PANIC_FATAL, "%08X %08X %08X\n%08X %08X %08X", ptr, length | (packets << 19), DIEPCTL(ep), DIEPDMA(ep), DIEPTSIZ(ep), DIEPINT(ep));
|
278 | 277 | }
|
279 | 278 | clean_dcache();
|
280 | 279 | DIEPCTL(ep) |= 0x84000000; /* EPx OUT ENABLE CLEARNAK */
|
281 | 280 | }
|
282 | 281 |
|
283 | | -void ep_recv(int ep, void *ptr, int length)
|
| 282 | +static void ep_recv(int ep, void *ptr, int length)
|
284 | 283 | {
|
285 | 284 | endpoints[ep].busy = true;
|
286 | 285 | endpoints[ep].size = length;
|