comparison Bootloader/flash.c @ 308:ab4515606277

Fix whitespace Use a consistent standard - Tabs in front for indenting, spaces after for anything else. This way everything stays nice and lined up while also letting users change there prefered indent level. Most of the new files from Haata where already in this format.
author Rowan Decker <Smasher816@gmail.com>
date Sun, 08 Mar 2015 18:40:01 -0700
parents 596d8e300a37
children f4d4cad283c6
comparison
equal deleted inserted replaced
305:4617ef5e06f1 308:ab4515606277
31 31
32 /* This will have to live in SRAM. */ 32 /* This will have to live in SRAM. */
33 __attribute__((section(".ramtext.ftfl_submit_cmd"), long_call)) 33 __attribute__((section(".ramtext.ftfl_submit_cmd"), long_call))
34 int ftfl_submit_cmd(void) 34 int ftfl_submit_cmd(void)
35 { 35 {
36 FTFL.fstat.raw = ((struct FTFL_FSTAT_t){ 36 FTFL.fstat.raw = ((struct FTFL_FSTAT_t){
37 .ccif = 1, 37 .ccif = 1,
38 .rdcolerr = 1, 38 .rdcolerr = 1,
39 .accerr = 1, 39 .accerr = 1,
40 .fpviol = 1 40 .fpviol = 1
41 }).raw; 41 }).raw;
42 struct FTFL_FSTAT_t stat; 42 struct FTFL_FSTAT_t stat;
43 while (!(stat = FTFL.fstat).ccif) 43 while (!(stat = FTFL.fstat).ccif)
44 /* NOTHING */; /* XXX maybe WFI? */ 44 /* NOTHING */; /* XXX maybe WFI? */
45 return (!!stat.mgstat0); 45 return (!!stat.mgstat0);
46 } 46 }
47 47
48 int flash_prepare_flashing(void) 48 int flash_prepare_flashing(void)
49 { 49 {
50 /* switch to FlexRAM */ 50 /* switch to FlexRAM */
51 if (!FTFL.fcnfg.ramrdy) { 51 if (!FTFL.fcnfg.ramrdy) {
52 FTFL.fccob.set_flexram.fcmd = FTFL_FCMD_SET_FLEXRAM; 52 FTFL.fccob.set_flexram.fcmd = FTFL_FCMD_SET_FLEXRAM;
53 FTFL.fccob.set_flexram.flexram_function = FTFL_FLEXRAM_RAM; 53 FTFL.fccob.set_flexram.flexram_function = FTFL_FLEXRAM_RAM;
54 return (ftfl_submit_cmd()); 54 return (ftfl_submit_cmd());
55 } 55 }
56 return (0); 56 return (0);
57 } 57 }
58 58
59 int flash_erase_sector(uintptr_t addr) 59 int flash_erase_sector(uintptr_t addr)
60 { 60 {
61 if (addr < (uintptr_t)&_app_rom && 61 if (addr < (uintptr_t)&_app_rom &&
62 flash_ALLOW_BRICKABLE_ADDRESSES != 0x00023420) 62 flash_ALLOW_BRICKABLE_ADDRESSES != 0x00023420)
63 return (-1); 63 return (-1);
64 FTFL.fccob.erase.fcmd = FTFL_FCMD_ERASE_SECTOR; 64 FTFL.fccob.erase.fcmd = FTFL_FCMD_ERASE_SECTOR;
65 FTFL.fccob.erase.addr = addr; 65 FTFL.fccob.erase.addr = addr;
66 return (ftfl_submit_cmd()); 66 return (ftfl_submit_cmd());
67 } 67 }
68 68
69 int flash_program_section(uintptr_t addr, size_t num_words) 69 int flash_program_section(uintptr_t addr, size_t num_words)
70 { 70 {
71 FTFL.fccob.program_section.fcmd = FTFL_FCMD_PROGRAM_SECTION; 71 FTFL.fccob.program_section.fcmd = FTFL_FCMD_PROGRAM_SECTION;
72 FTFL.fccob.program_section.addr = addr; 72 FTFL.fccob.program_section.addr = addr;
73 FTFL.fccob.program_section.num_words = num_words; 73 FTFL.fccob.program_section.num_words = num_words;
74 return (ftfl_submit_cmd()); 74 return (ftfl_submit_cmd());
75 } 75 }
76 76
77 int flash_program_sector(uintptr_t addr, size_t len) 77 int flash_program_sector(uintptr_t addr, size_t len)
78 { 78 {
79 return (len != FLASH_SECTOR_SIZE || 79 return (len != FLASH_SECTOR_SIZE ||
80 (addr & (FLASH_SECTOR_SIZE - 1)) != 0 || 80 (addr & (FLASH_SECTOR_SIZE - 1)) != 0 ||
81 flash_erase_sector(addr) || 81 flash_erase_sector(addr) ||
82 flash_program_section(addr, FLASH_SECTOR_SIZE/4)); 82 flash_program_section(addr, FLASH_SECTOR_SIZE/4));
83 } 83 }
84 84
85 void *flash_get_staging_area(uintptr_t addr, size_t len) 85 void *flash_get_staging_area(uintptr_t addr, size_t len)
86 { 86 {
87 if ((addr & (FLASH_SECTOR_SIZE - 1)) != 0 || 87 if ((addr & (FLASH_SECTOR_SIZE - 1)) != 0 ||
88 len != FLASH_SECTOR_SIZE) 88 len != FLASH_SECTOR_SIZE)
89 return (NULL); 89 return (NULL);
90 return (FlexRAM); 90 return (FlexRAM);
91 } 91 }
92 92