case CMD_DEVICE_INFO:\r
dont_ack = 1;\r
c->cmd = CMD_DEVICE_INFO;\r
- c->ext1 = DEVICE_INFO_FLAG_BOOTROM_PRESENT | DEVICE_INFO_FLAG_CURRENT_MODE_BOOTROM |\r
+ c->arg[0] = DEVICE_INFO_FLAG_BOOTROM_PRESENT | DEVICE_INFO_FLAG_CURRENT_MODE_BOOTROM |\r
DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH;\r
- if(common_area.flags.osimage_present) c->ext1 |= DEVICE_INFO_FLAG_OSIMAGE_PRESENT;\r
+ if(common_area.flags.osimage_present) c->arg[0] |= DEVICE_INFO_FLAG_OSIMAGE_PRESENT;\r
UsbSendPacket(packet, len);\r
break;\r
\r
*/\r
p = (volatile DWORD *)&_flash_start;\r
for(i = 0; i < 12; i++) {\r
- p[i+c->ext1] = c->d.asDwords[i];\r
+ p[i+c->arg[0]] = c->d.asDwords[i];\r
}\r
break;\r
\r
}\r
\r
/* Check that the address that we are supposed to write to is within our allowed region */\r
- if( ((c->ext1+AT91C_IFLASH_PAGE_SIZE-1) >= end_addr) || (c->ext1 < start_addr) ) {\r
+ if( ((c->arg[0]+AT91C_IFLASH_PAGE_SIZE-1) >= end_addr) || (c->arg[0] < start_addr) ) {\r
/* Disallow write */\r
dont_ack = 1;\r
c->cmd = CMD_NACK;\r
} else {\r
/* Translate address to flash page and do flash, update here for the 512k part */\r
AT91C_BASE_EFC0->EFC_FCR = MC_FLASH_COMMAND_KEY |\r
- MC_FLASH_COMMAND_PAGEN((c->ext1-(int)&_flash_start)/AT91C_IFLASH_PAGE_SIZE) |\r
+ MC_FLASH_COMMAND_PAGEN((c->arg[0]-(int)&_flash_start)/AT91C_IFLASH_PAGE_SIZE) |\r
AT91C_MC_FCMD_START_PROG;\r
}\r
- while(!(AT91C_BASE_EFC0->EFC_FSR & MC_FLASH_STATUS_READY))\r
+ \r
+ uint32_t sr;\r
+ \r
+ while(!((sr = AT91C_BASE_EFC0->EFC_FSR) & MC_FLASH_STATUS_READY))\r
;\r
+ if(sr & (MC_FLASH_STATUS_LOCKE | MC_FLASH_STATUS_PROGE)) { \r
+ dont_ack = 1;\r
+ c->cmd = CMD_NACK;\r
+ UsbSendPacket(packet, len);\r
+ }\r
break;\r
\r
case CMD_HARDWARE_RESET:\r
break;\r
\r
case CMD_START_FLASH:\r
- if(c->ext3 == START_FLASH_MAGIC) bootrom_unlocked = 1;\r
+ if(c->arg[2] == START_FLASH_MAGIC) bootrom_unlocked = 1;\r
else bootrom_unlocked = 0;\r
{\r
int prot_start = (int)&_bootrom_start;\r
int prot_end = (int)&_bootrom_end;\r
int allow_start = (int)&_flash_start;\r
int allow_end = (int)&_flash_end;\r
- int cmd_start = c->ext1;\r
- int cmd_end = c->ext2;\r
+ int cmd_start = c->arg[0];\r
+ int cmd_end = c->arg[1];\r
\r
/* Only allow command if the bootrom is unlocked, or the parameters are outside of the protected\r
* bootrom area. In any case they must be within the flash area.\r