Mercurial > ecos
comparison packages/io/flash/current/src/flash.c @ 117:bd1a71e3e476 ecos-sw-2000-08-25
Merge from eCos master repository on 2000-08-25-19:22:58-BST
| author | jlarmour |
|---|---|
| date | Fri, 25 Aug 2000 19:17:22 +0000 |
| parents | 6ed91473a1cd |
| children | 77cec8369160 |
comparison
equal
deleted
inserted
replaced
| 116:a0f9581a3a09 | 117:bd1a71e3e476 |
|---|---|
| 55 { | 55 { |
| 56 int err; | 56 int err; |
| 57 | 57 |
| 58 if (flash_info.init) return FLASH_ERR_OK; | 58 if (flash_info.init) return FLASH_ERR_OK; |
| 59 flash_info.work_space = work_space; | 59 flash_info.work_space = work_space; |
| 60 flash_info.work_space_size = flash_info.work_space_size; | 60 flash_info.work_space_size = work_space_size; |
| 61 if ((err = flash_hwr_init()) != FLASH_ERR_OK) { | 61 if ((err = flash_hwr_init()) != FLASH_ERR_OK) { |
| 62 return err; | 62 return err; |
| 63 } | 63 } |
| 64 flash_info.block_mask = ~(flash_info.block_size-1); | 64 flash_info.block_mask = ~(flash_info.block_size-1); |
| 65 flash_info.init = 1; | 65 flash_info.init = 1; |
| 119 // Copy 'erase' code to RAM for execution | 119 // Copy 'erase' code to RAM for execution |
| 120 code_len = (unsigned long)&flash_erase_block_end - (unsigned long)&flash_erase_block; | 120 code_len = (unsigned long)&flash_erase_block_end - (unsigned long)&flash_erase_block; |
| 121 _flash_erase_block = (code_fun *)flash_info.work_space; | 121 _flash_erase_block = (code_fun *)flash_info.work_space; |
| 122 memcpy(_flash_erase_block, &flash_erase_block, code_len); | 122 memcpy(_flash_erase_block, &flash_erase_block, code_len); |
| 123 HAL_DCACHE_SYNC(); // Should guarantee this code will run | 123 HAL_DCACHE_SYNC(); // Should guarantee this code will run |
| 124 HAL_ICACHE_DISABLE(); // is also required to avoid old contents | |
| 124 | 125 |
| 125 block = (unsigned short *)((unsigned long)addr & flash_info.block_mask); | 126 block = (unsigned short *)((unsigned long)addr & flash_info.block_mask); |
| 126 end_addr = (unsigned short *)((unsigned long)addr+len); | 127 end_addr = (unsigned short *)((unsigned long)addr+len); |
| 127 | 128 |
| 128 printf("... Erase from %p-%p: ", block, end_addr); | 129 printf("... Erase from %p-%p: ", block, end_addr); |
| 135 break; | 136 break; |
| 136 } | 137 } |
| 137 block += flash_info.block_size / sizeof(*block); | 138 block += flash_info.block_size / sizeof(*block); |
| 138 printf("."); | 139 printf("."); |
| 139 } | 140 } |
| 141 HAL_ICACHE_ENABLE(); | |
| 140 printf("\n"); | 142 printf("\n"); |
| 141 return (stat); | 143 return (stat); |
| 142 } | 144 } |
| 143 | 145 |
| 144 int | 146 int |
| 159 // Copy 'program' code to RAM for execution | 161 // Copy 'program' code to RAM for execution |
| 160 code_len = (unsigned long)&flash_program_buf_end - (unsigned long)&flash_program_buf; | 162 code_len = (unsigned long)&flash_program_buf_end - (unsigned long)&flash_program_buf; |
| 161 _flash_program_buf = (code_fun *)flash_info.work_space; | 163 _flash_program_buf = (code_fun *)flash_info.work_space; |
| 162 memcpy(_flash_program_buf, &flash_program_buf, code_len); | 164 memcpy(_flash_program_buf, &flash_program_buf, code_len); |
| 163 HAL_DCACHE_SYNC(); // Should guarantee this code will run | 165 HAL_DCACHE_SYNC(); // Should guarantee this code will run |
| 166 HAL_ICACHE_DISABLE(); // is also required to avoid old contents | |
| 164 | 167 |
| 165 printf("... Program from %p-%p at %p: ", data, ((unsigned long)data)+len, addr); | 168 printf("... Program from %p-%p at %p: ", data, ((unsigned long)data)+len, addr); |
| 166 | 169 |
| 167 while (len > 0) { | 170 while (len > 0) { |
| 168 size = len; | 171 size = len; |
| 176 printf("."); | 179 printf("."); |
| 177 len -= size; | 180 len -= size; |
| 178 addr += size/sizeof(*addr); | 181 addr += size/sizeof(*addr); |
| 179 data += size/sizeof(*data); | 182 data += size/sizeof(*data); |
| 180 } | 183 } |
| 184 HAL_ICACHE_ENABLE(); | |
| 181 printf("\n"); | 185 printf("\n"); |
| 182 return (stat); | 186 return (stat); |
| 183 } | 187 } |
| 184 | 188 |
| 185 char * | 189 char * |
