📄 bootdevice.cod
字号:
00118 e28d0044 add r0, sp, #0x44
0011c eb000000 bl memset
; 454 : SectorSaveArea.pStartSaveArea = (LPBYTE)BLOCK_SAVE_START;
; 455 : SectorSaveArea.pEndSaveArea = (LPBYTE)BLOCK_SAVE_START;
; 456 : // Any non-block aligned sectors at the start of the area? Also, if this is a bad block, we needn't save the data.
; 457 : if ((SectorSaveArea.dwStartSaveSectors = SectorAddr % NorFlsInfo.wSectorsPerBlock) != 0)
00120 e1dd42b0 ldrh r4, [sp, #0x20]
00124 e3a08483 mov r8, #0x83, 8
00128 e38888e3 orr r8, r8, #0xE3, 16
0012c e1a00004 mov r0, r4
00130 e1a01006 mov r1, r6
00134 e58d8024 str r8, [sp, #0x24]
00138 e1a0b008 mov r11, r8
0013c eb000000 bl __rt_udiv
; 458 : {
; 459 : DWORD dwCount;
; 460 : SectorInfo SectInfo;
; 461 : LPBYTE pTemp = SectorSaveArea.pStartSaveArea;
; 462 : DWORD dwStartSector = (SectorAddr - SectorSaveArea.dwStartSaveSectors);
; 463 : DWORD dwNumStartSectors = SectorSaveArea.dwStartSaveSectors;
; 464 : for (dwCount = 0 ; dwCount < dwNumStartSectors ; dwCount++)
00140 e59d9044 ldr r9, [sp, #0x44]
00144 e1b0a001 movs r10, r1
00148 0a000019 beq |$L40953|
0014c e046500a sub r5, r6, r10
00150 e3a08000 mov r8, #0
00154 e35a0000 cmp r10, #0
00158 0a000014 beq |$L40961|
0015c |$L40959|
; 465 : {
; 466 : if (!Nor_FMD_ReadSector((dwStartSector + dwCount), pTemp, &SectInfo, 1))
0015c e3a03001 mov r3, #1
00160 e28d2034 add r2, sp, #0x34
00164 e1a0100b mov r1, r11
00168 e1a00005 mov r0, r5
0016c eb000000 bl Nor_FMD_ReadSector
00170 e3500000 cmp r0, #0
00174 0a00004d beq |$L41271|
; 469 : return FALSE;
; 470 : }
; 471 : SectorSaveArea.dwStartSector = (SectorSaveArea.dwStartSector ? SectorSaveArea.dwStartSector : (dwStartSector + dwCount));
; 472 : pTemp += NorFlsInfo.wDataBytesPerSector;
00178 e1dd32b2 ldrh r3, [sp, #0x22]
0017c e3590000 cmp r9, #0
; 473 : memcpy(pTemp, &SectInfo, sizeof(SectorInfo));
00180 e28d1034 add r1, sp, #0x34
00184 e08b4003 add r4, r11, r3
00188 e1a00004 mov r0, r4
0018c e3a02008 mov r2, #8
00190 01a09005 moveq r9, r5
00194 eb000000 bl memcpy
00198 e2888001 add r8, r8, #1
0019c e158000a cmp r8, r10
; 474 : pTemp += sizeof(SectorInfo);
001a0 e284b008 add r11, r4, #8
001a4 e2855001 add r5, r5, #1
001a8 3affffeb bcc |$L40959|
; 561 : }
; 562 : // This test can be removed to speed up the writes and it should be safe since this is NOR flash.
; 563 : if (!Nor_FMD_ReadSector(SectorAddr, &SectBuff[0], NULL, 1) || memcmp(&SectBuff[0], pData, NorFlsInfo.wDataBytesPerSector))
001ac e1dd42b0 ldrh r4, [sp, #0x20]
001b0 |$L40961|
; 475 : }
; 476 : SectorSaveArea.pEndSaveArea = pTemp;
001b0 e0875006 add r5, r7, r6
001b4 |$L40953|
; 477 : DEBUGMSG(1, (TEXT("\r\nFlashWrite: Saved start sector(s) First 0x%x (Length=0x%x).\r\n"), SectorSaveArea.dwStartSector, SectorSaveArea.dwStartSaveSectors));
; 478 : }
; 479 : // Any non-block aligned sectors at the end of the area? Also, if this is a bad block, we needn't save the data (there shouldn't
; 480 : // be a bad block at the end of the region).
; 481 : SectorSaveArea.dwEndSaveSectors = (NorFlsInfo.wSectorsPerBlock - ((SectorAddr + dwNumSects) % NorFlsInfo.wSectorsPerBlock));
001b4 e1a00004 mov r0, r4
001b8 e1a01005 mov r1, r5
001bc eb000000 bl __rt_udiv
001c0 e0445001 sub r5, r4, r1
; 482 : if (SectorSaveArea.dwEndSaveSectors == NorFlsInfo.wSectorsPerBlock) SectorSaveArea.dwEndSaveSectors = 0;
001c4 e1550004 cmp r5, r4
001c8 03a05000 moveq r5, #0
; 483 : if (SectorSaveArea.dwEndSaveSectors != 0)
; 484 : {
; 485 : DWORD dwCount;
; 486 : SectorInfo SectInfo;
; 487 : LPBYTE pTemp = SectorSaveArea.pEndSaveArea;
; 488 : DWORD dwEndSector = (SectorAddr + dwNumSects);
; 489 : DWORD dwNumEndSectors = SectorSaveArea.dwEndSaveSectors;
; 490 : for (dwCount = 0 ; dwCount < dwNumEndSectors ; dwCount++)
001cc e59d8050 ldr r8, [sp, #0x50]
001d0 e3550000 cmp r5, #0
001d4 0a00001b beq |$L40976|
001d8 e3a03000 mov r3, #0
001dc e58d3034 str r3, [sp, #0x34]
001e0 e1a0400b mov r4, r11
001e4 |$L40974|
; 491 : {
; 492 : if (!Nor_FMD_ReadSector((dwEndSector + dwCount), pTemp, &SectInfo, 1))
001e4 e59d000c ldr r0, [sp, #0xC]
001e8 e3a03001 mov r3, #1
001ec e28d205c add r2, sp, #0x5C
001f0 e1a01004 mov r1, r4
001f4 eb000000 bl Nor_FMD_ReadSector
001f8 e3500000 cmp r0, #0
001fc 0a00002e beq |$L41272|
; 495 : return FALSE;
; 496 : }
; 497 : SectorSaveArea.dwEndSector = (SectorSaveArea.dwEndSector ? SectorSaveArea.dwEndSector : (dwEndSector + dwCount));
00200 e3580000 cmp r8, #0
00204 059d300c ldreq r3, [sp, #0xC]
; 498 : pTemp += NorFlsInfo.wDataBytesPerSector;
; 499 : memcpy(pTemp, &SectInfo, sizeof(SectorInfo));
00208 e28d105c add r1, sp, #0x5C
0020c e3a02008 mov r2, #8
00210 01a08003 moveq r8, r3
00214 e1dd32b2 ldrh r3, [sp, #0x22]
00218 e0844003 add r4, r4, r3
0021c e1a00004 mov r0, r4
00220 eb000000 bl memcpy
00224 e59d3034 ldr r3, [sp, #0x34]
; 500 : pTemp += sizeof(SectorInfo);
00228 e2844008 add r4, r4, #8
0022c e2833001 add r3, r3, #1
00230 e58d3034 str r3, [sp, #0x34]
00234 e1530005 cmp r3, r5
00238 e59d300c ldr r3, [sp, #0xC]
0023c e2833001 add r3, r3, #1
00240 e58d300c str r3, [sp, #0xC]
00244 3affffe6 bcc |$L40974|
00248 |$L40976|
; 501 : }
; 502 : DEBUGMSG(1, (TEXT("\r\nFlashWrite: Saved end sector(s) First 0x%x (Length=0x%x).\r\n"), SectorSaveArea.dwEndSector, SectorSaveArea.dwEndSaveSectors));
; 503 : }
; 504 :
; 505 : // Erase any blocks we're going to write to.
; 506 : if (BootDevice_Erase(dwStartBlock, dwNumBlocks) == FALSE)
00248 e59d1028 ldr r1, [sp, #0x28]
0024c e59d003c ldr r0, [sp, #0x3C]
00250 eb000000 bl BootDevice_Erase
00254 e3500000 cmp r0, #0
; 507 : {
; 508 : return FALSE;
00258 0a000072 beq |$L41322|
; 509 : }
; 510 :
; 511 : // Now, restore the non-block aligned data at the start and/or end of the region.
; 512 : // Any start sectors to restore?
; 513 : if (SectorSaveArea.dwStartSaveSectors)
; 514 : {
; 515 : DWORD dwCount;
; 516 : LPBYTE pTemp = SectorSaveArea.pStartSaveArea;
; 517 :
; 518 : for (dwCount = 0 ; dwCount < SectorSaveArea.dwStartSaveSectors ; dwCount++)
0025c e1dd22b2 ldrh r2, [sp, #0x22]
00260 e35a0000 cmp r10, #0
00264 0a00001a beq |$L40988|
00268 e3a01483 mov r1, #0x83, 8
0026c e38118e3 orr r1, r1, #0xE3, 16
00270 e3a04000 mov r4, #0
00274 |$L40986|
; 519 : {
; 520 : if (!Nor_FMD_WriteSector((SectorSaveArea.dwStartSector + dwCount), pTemp, (PSectorInfo)(pTemp + NorFlsInfo.wDataBytesPerSector), 1))
00274 e3a03001 mov r3, #1
00278 e0822001 add r2, r2, r1
0027c e0840009 add r0, r4, r9
00280 eb000000 bl Nor_FMD_WriteSector
00284 e3500000 cmp r0, #0
00288 0a00000e beq |$L41273|
; 523 : break;
; 524 : }
; 525 : pTemp += NorFlsInfo.wDataBytesPerSector + sizeof(SectorInfo);
0028c e1dd22b2 ldrh r2, [sp, #0x22]
00290 e59d3024 ldr r3, [sp, #0x24]
00294 e2844001 add r4, r4, #1
00298 e154000a cmp r4, r10
0029c e0823003 add r3, r2, r3
002a0 e2831008 add r1, r3, #8
002a4 e58d1024 str r1, [sp, #0x24]
002a8 3afffff1 bcc |$L40986|
; 561 : }
; 562 : // This test can be removed to speed up the writes and it should be safe since this is NOR flash.
; 563 : if (!Nor_FMD_ReadSector(SectorAddr, &SectBuff[0], NULL, 1) || memcmp(&SectBuff[0], pData, NorFlsInfo.wDataBytesPerSector))
002ac ea000008 b |$L40988|
002b0 |$L41271|
; 467 : {
; 468 : EdbgOutputDebugString("\r\nERROR: FlashWrite: Unable to read start area sector.\r\n");
002b0 e59f019c ldr r0, [pc, #0x19C]
002b4 eb000000 bl EdbgOutputDebugString
002b8 ea00005a b |$L41322|
002bc |$L41272|
; 493 : {
; 494 : EdbgOutputDebugString("\r\nERROR: FlashWrite: Unable to read end area sector.\r\n");
002bc e59f018c ldr r0, [pc, #0x18C]
002c0 eb000000 bl EdbgOutputDebugString
002c4 ea000057 b |$L41322|
002c8 |$L41273|
; 521 : {
; 522 : EdbgOutputDebugString("\r\nERROR: FlashWrite: Couldn't restore start area sectors.\r\n");
002c8 e59f017c ldr r0, [pc, #0x17C]
002cc eb000000 bl EdbgOutputDebugString
002d0 e1dd22b2 ldrh r2, [sp, #0x22]
002d4 |$L40988|
; 526 : }
; 527 : DEBUGMSG(1, (TEXT("\r\nFlashWrite: Restored start sector(s) First 0x%x (Length=0x%x).\r\n"), SectorSaveArea.dwStartSector, SectorSaveArea.dwStartSaveSectors));
; 528 : }
; 529 : // Any end sectors to restore?
; 530 : if (SectorSaveArea.dwEndSaveSectors)
002d4 e3550000 cmp r5, #0
002d8 0a000010 beq |$L40999|
; 531 : {
; 532 : DWORD dwCount;
; 533 : LPBYTE pTemp = SectorSaveArea.pEndSaveArea;
; 534 : for (dwCount = 0 ; dwCount < SectorSaveArea.dwEndSaveSectors ; dwCount++)
002dc e3a04000 mov r4, #0
002e0 |$L40997|
; 535 : {
; 536 : if (!Nor_FMD_WriteSector((SectorSaveArea.dwEndSector + dwCount), pTemp, (PSectorInfo)(pTemp + NorFlsInfo.wDataBytesPerSector), 1))
002e0 e3a03001 mov r3, #1
002e4 e082200b add r2, r2, r11
002e8 e1a0100b mov r1, r11
002ec e0840008 add r0, r4, r8
002f0 eb000000 bl Nor_FMD_WriteSector
002f4 e3500000 cmp r0, #0
002f8 0a000006 beq |$L41274|
; 539 : break;
; 540 : }
; 541 : pTemp += NorFlsInfo.wDataBytesPerSector + sizeof(SectorInfo);
002fc e1dd22b2 ldrh r2, [sp, #0x22]
00300 e2844001 add r4, r4, #1
00304 e1540005 cmp r4, r5
00308 e082300b add r3, r2, r11
0030c e283b008 add r11, r3, #8
00310 3afffff2 bcc |$L40997|
; 561 : }
; 562 : // This test can be removed to speed up the writes and it should be safe since this is NOR flash.
; 563 : if (!Nor_FMD_ReadSector(SectorAddr, &SectBuff[0], NULL, 1) || memcmp(&SectBuff[0], pData, NorFlsInfo.wDataBytesPerSector))
00314 ea000001 b |$L40999|
00318 |$L41274|
; 537 : {
; 538 : EdbgOutputDebugString("\r\nERROR: FlashWrite: Couldn't restore end area sectors.\r\n");
00318 e59f0128 ldr r0, [pc, #0x128]
0031c eb000000 bl EdbgOutputDebugString
00320 |$L40999|
; 542 : }
; 543 : DEBUGMSG(1, (TEXT("\r\nFlashWrite: Restored end sector(s) First 0x%x (Length=0x%x).\r\n"), SectorSaveArea.dwEndSector, SectorSaveArea.dwEndSaveSectors));
; 544 : }
; 545 :
; 546 : memset(&SectInfo, 0xff, sizeof(SectorInfo));
00320 e3e03000 mvn r3, #0
00324 e58d3004 str r3, [sp, #4]
; 547 : SectInfo.wReserved2 &= ~0x4; // Write completed.
00328 e58d3008 str r3, [sp, #8]
0032c e1dd30ba ldrh r3, [sp, #0xA]
00330 e3a01cff mov r1, #0xFF, 24
00334 e38110fb orr r1, r1, #0xFB
; 548 : SectInfo.bOEMReserved &= ~OEM_BLOCK_READONLY; // Mark sectors read-only so the FAL doesn't compact them.
00338 e5dd2008 ldrb r2, [sp, #8]
; 549 : SectInfo.dwReserved1 = LogicalSectorNumber; // Starting logical sector number.
; 550 :
; 551 : EdbgOutputDebugString("Writing to flash (please wait): ");
0033c e0033001 and r3, r3, r1
00340 e1cd30ba strh r3, [sp, #0xA]
00344 e59d302c ldr r3, [sp, #0x2C]
00348 e59f00f4 ldr r0, [pc, #0xF4]
0034c e20220fd and r2, r2, #0xFD
00350 e58d3004 str r3, [sp, #4]
00354 e5cd2008 strb r2, [sp, #8]
00358 eb000000 bl EdbgOutputDebugString
; 552 :
; 553 : // Write a sector a at a time to avoid having to create a potentially large sector info buffer area.
; 554 : while (dwNumSects--)
0035c e3570000 cmp r7, #0
00360 0a00001d beq |$L41281|
; 399 : {
00364 e59d5040 ldr r5, [sp, #0x40]
; 552 :
; 553 : // Write a sector a at a time to avoid having to create a potentially large sector info buffer area.
; 554 : while (dwNumSects--)
00368 |$L41008|
; 555 : {
; 556 : // Write and verify each sector in the image.
; 557 : if (!Nor_FMD_WriteSector(SectorAddr, pData, &SectInfo, 1))
00368 e3a03001 mov r3, #1
0036c e28d2004 add r2, sp, #4
00370 e1a01005 mov r1, r5
00374 e1a00006 mov r0, r6
00378 e2477001 sub r7, r7, #1
0037c eb000000 bl Nor_FMD_WriteSector
00380 e3500000 cmp r0, #0
00384 0a00001c beq |$L41275|
; 561 : }
; 562 : // This test can be removed to speed up the writes and it should be safe since this is NOR flash.
; 563 : if (!Nor_FMD_ReadSector(SectorAddr, &SectBuff[0], NULL, 1) || memcmp(&SectBuff[0], pData, NorFlsInfo.wDataBytesPerSector))
00388 e3a03001 mov r
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -