mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
bootrom: avoid pointer magic to please coverity
This commit is contained in:
parent
a5001de76c
commit
9370649861
1 changed files with 5 additions and 6 deletions
|
@ -12,7 +12,8 @@
|
||||||
|
|
||||||
struct common_area common_area __attribute__((section(".commonarea")));
|
struct common_area common_area __attribute__((section(".commonarea")));
|
||||||
unsigned int start_addr, end_addr, bootrom_unlocked;
|
unsigned int start_addr, end_addr, bootrom_unlocked;
|
||||||
extern char _bootrom_start, _bootrom_end, _flash_start, _flash_end;
|
extern char _bootrom_start, _bootrom_end, _flash_end;
|
||||||
|
extern uint32_t _flash_start[AT91C_IFLASH_NB_OF_PAGES * AT91C_IFLASH_PAGE_SIZE / sizeof(uint32_t)];
|
||||||
extern uint32_t _osimage_entry;
|
extern uint32_t _osimage_entry;
|
||||||
|
|
||||||
static int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len) {
|
static int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len) {
|
||||||
|
@ -153,19 +154,17 @@ void UsbPacketReceived(uint8_t *packet, int len) {
|
||||||
/* The temporary write buffer of the embedded flash controller is mapped to the
|
/* The temporary write buffer of the embedded flash controller is mapped to the
|
||||||
* whole memory region, only the last 8 bits are decoded.
|
* whole memory region, only the last 8 bits are decoded.
|
||||||
*/
|
*/
|
||||||
volatile uint32_t *p = (volatile uint32_t *)&_flash_start;
|
|
||||||
for (i = 0; i < 12; i++)
|
for (i = 0; i < 12; i++)
|
||||||
p[i + arg0] = c->d.asDwords[i];
|
_flash_start[i + arg0] = c->d.asDwords[i];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_FINISH_WRITE: {
|
case CMD_FINISH_WRITE: {
|
||||||
uint32_t *flash_mem = (uint32_t *)(&_flash_start);
|
|
||||||
for (int j = 0; j < 2; j++) {
|
for (int j = 0; j < 2; j++) {
|
||||||
uint32_t flash_address = arg0 + (0x100 * j);
|
uint32_t flash_address = arg0 + (0x100 * j);
|
||||||
AT91PS_EFC efc_bank = AT91C_BASE_EFC0;
|
AT91PS_EFC efc_bank = AT91C_BASE_EFC0;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
uint32_t page_n = (flash_address - ((uint32_t)flash_mem)) / AT91C_IFLASH_PAGE_SIZE;
|
uint32_t page_n = (flash_address - ((uint32_t)_flash_start)) / AT91C_IFLASH_PAGE_SIZE;
|
||||||
if (page_n >= AT91C_IFLASH_NB_OF_PAGES / 2) {
|
if (page_n >= AT91C_IFLASH_NB_OF_PAGES / 2) {
|
||||||
page_n -= AT91C_IFLASH_NB_OF_PAGES / 2;
|
page_n -= AT91C_IFLASH_NB_OF_PAGES / 2;
|
||||||
efc_bank = AT91C_BASE_EFC1;
|
efc_bank = AT91C_BASE_EFC1;
|
||||||
|
@ -173,7 +172,7 @@ void UsbPacketReceived(uint8_t *packet, int len) {
|
||||||
offset = (AT91C_IFLASH_NB_OF_PAGES / 2) * AT91C_IFLASH_PAGE_SIZE / sizeof(uint32_t);
|
offset = (AT91C_IFLASH_NB_OF_PAGES / 2) * AT91C_IFLASH_PAGE_SIZE / sizeof(uint32_t);
|
||||||
}
|
}
|
||||||
for (i = 0 + (64 * j); i < 64 + (64 * j); i++) {
|
for (i = 0 + (64 * j); i < 64 + (64 * j); i++) {
|
||||||
flash_mem[offset + i] = c->d.asDwords[i];
|
_flash_start[offset + i] = c->d.asDwords[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check that the address that we are supposed to write to is within our allowed region */
|
/* Check that the address that we are supposed to write to is within our allowed region */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue