📄 bootdevice.cod
字号:
; 357 : {
; 358 : dwStatus = Nand_FMD_GetBlockStatus(i);
000a4 e1a00005 mov r0, r5
000a8 eb000000 bl Nand_FMD_GetBlockStatus
; 359 : if((dwStatus & BLOCK_STATUS_BAD) == 0)
000ac e3100002 tst r0, #2
; 360 : Nand_FMD_EraseBlock(i);
000b0 01a00005 moveq r0, r5
000b4 0b000000 bleq Nand_FMD_EraseBlock
000b8 e2855001 add r5, r5, #1
000bc e1550007 cmp r5, r7
000c0 3afffff7 bcc |$L40912|
000c4 |$L40914|
; 361 : }
; 362 :
; 363 : for(i = 0; i < dwNumofSect; i++)
000c4 e3560000 cmp r6, #0
000c8 0a000021 beq |$L40918|
000cc e1dd30bc ldrh r3, [sp, #0xC]
000d0 e3a05000 mov r5, #0
000d4 e1a07006 mov r7, r6
000d8 |$L40916|
; 364 : {
; 365 : dwStatus = Nand_FMD_GetBlockStatus(dwStartSect / NandFlsInfo.wSectorsPerBlock);
000d8 e1a00003 mov r0, r3
000dc e1a01004 mov r1, r4
000e0 eb000000 bl __rt_udiv
000e4 eb000000 bl Nand_FMD_GetBlockStatus
; 366 : if((dwStatus & BLOCK_STATUS_BAD) != 0)
000e8 e3100002 tst r0, #2
; 367 : {
; 368 : dwStartSect += NandFlsInfo.wSectorsPerBlock;
000ec 11dd30bc ldrneh r3, [sp, #0xC]
000f0 10844003 addne r4, r4, r3
000f4 1a000013 bne |$L40917|
; 369 : continue;
; 370 : }
; 371 : /*
; 372 : bpTempInfo = (PSectorInfo)(pData + 2048);
; 373 : if(bpTempInfo->bBadBlock != 0xff)
; 374 : {
; 375 : EdbgOutputDebugString("Sector %d, block %d is bad.\r\n", dwStartSect, dwStartSect / NandFlsInfo.wSectorsPerBlock);
; 376 : DispNand1(pData, pData + 2048);
; 377 : while(1);
; 378 : }
; 379 : if(dwStartSect == 64 * 15)
; 380 : {
; 381 : dump();
; 382 : DispNand(pData, (pData + 2048));
; 383 : EdbgOutputDebugString("Info addr %x.\r\n", pData + 2048);
; 384 : }
; 385 : */
; 386 : Nand_FMD_WriteSector(dwStartSect, pData, (PSectorInfo)(pData + 2048), 1);
000f8 e3a03001 mov r3, #1
000fc e2892b02 add r2, r9, #2, 22
00100 e1a01009 mov r1, r9
00104 e1a00004 mov r0, r4
00108 eb000000 bl Nand_FMD_WriteSector
; 387 : pData += 2056;
0010c e2893b02 add r3, r9, #2, 22
; 388 : if((i * 100 / dwNumofSect) != ((i + 1) * 100 / dwNumofSect))
00110 e1a00006 mov r0, r6
00114 e1a01005 mov r1, r5
00118 e2839008 add r9, r3, #8
0011c eb000000 bl __rt_udiv
00120 e1a08000 mov r8, r0
00124 e1a00006 mov r0, r6
00128 e2851064 add r1, r5, #0x64
0012c eb000000 bl __rt_udiv
00130 e1580000 cmp r8, r0
; 389 : EdbgOutputDebugString("%d percent.\r\n", i * 100 / dwNumofSect);
00134 159f0028 ldrne r0, [pc, #0x28]
00138 11a01008 movne r1, r8
0013c 1b000000 blne EdbgOutputDebugString
; 390 : dwStartSect++;
00140 e1dd30bc ldrh r3, [sp, #0xC]
00144 e2844001 add r4, r4, #1
00148 |$L40917|
00148 e2855064 add r5, r5, #0x64
0014c e2577001 subs r7, r7, #1
00150 1affffe0 bne |$L40916|
00154 |$L40918|
; 391 : }
; 392 :
; 393 : // Nand_FMD_ReadSector(1, buff, (PSectorInfo)info, 1);
; 394 : // DispNand(buff, info);
; 395 : return TRUE;
00154 e3a00001 mov r0, #1
; 396 : }
00158 e28dd010 add sp, sp, #0x10
0015c e8bd43f0 ldmia sp!, {r4 - r9, lr}
00160 e12fff1e bx lr
00164 |$L41259|
00164 00000000 DCD |??_C@_0O@KNNNMCMC@?$CFd?5percent?4?$AN?6?$AA@|
00168 00000000 DCD |??_C@_0BE@OILPIIKL@dwStartSect?5?$DN?5?$CFd?4?$AN?6?$AA@|
0016c 00000000 DCD |??_C@_0BF@PHJKJMJN@dwNumofBlock?5?$DN?5?$CFd?4?$AN?6?$AA@|
00170 00000000 DCD |??_C@_0BE@CKIDBGFB@dwNumofSect?5?$DN?5?$CFd?4?$AN?6?$AA@|
00174 00000000 DCD |??_C@_0DE@LFNMJDDJ@Writing?50x?$CFx?5to?5flash?5address?50x@|
00178 |$M41255|
ENDP ; |SecondaryDevice_Write|
EXPORT |??_C@_0DJ@CPAALFMA@?$AN?6ERROR?3?5FlashWrite?3?5Unable?5to?5r@| [ DATA ] ; `string'
EXPORT |??_C@_0DH@NMONLCCD@?$AN?6ERROR?3?5FlashWrite?3?5Unable?5to?5r@| [ DATA ] ; `string'
EXPORT |??_C@_0DM@CHCKFJBF@?$AN?6ERROR?3?5FlashWrite?3?5Couldn?8t?5re@| [ DATA ] ; `string'
EXPORT |??_C@_0DK@BOHIJOEK@?$AN?6ERROR?3?5FlashWrite?3?5Couldn?8t?5re@| [ DATA ] ; `string'
EXPORT |??_C@_0CB@NGJJEOHE@Writing?5to?5flash?5?$CIplease?5wait?$CJ?3?5@| [ DATA ] ; `string'
EXPORT |??_C@_0DN@KOFLADBK@?$AN?6ERROR?3?5FlashWrite?3?5FMD_WriteSe@| [ DATA ] ; `string'
EXPORT |??_C@_0EO@ELHIDNKN@?$AN?6ERROR?3?5nFlashWrite?3?5write?1veri@| [ DATA ] ; `string'
EXPORT |BootDevice_Write|
EXPORT |??_C@_0CP@JIDONMGO@BootDevice_Write?3Addr?5must?5be?5se@| [ DATA ] ; `string'
EXPORT |??_C@_0FD@JDOHFIDH@WARNING?3?5FlashWrite?3?5unable?5to?5f@| [ DATA ] ; `string'
EXPORT |??_C@_0CF@BDBFAKN@Handling?5non?9block?5aligned?5data?4@| [ DATA ] ; `string'
IMPORT |memcmp|
IMPORT |Nor_FMD_WriteSector|
00000 AREA |.text| { |BootDevice_Write| }, CODE, ARM, SELECTION=1 ; comdat noduplicate
00000 AREA |.pdata$$BootDevice_Write|, PDATA, SELECTION=5, ASSOC=|.text| { |BootDevice_Write| } ; comdat associative
|$T41327| DCD |$L41326|
DCD 0x40011b02
00000 AREA |.rdata| { |??_C@_0EO@ELHIDNKN@?$AN?6ERROR?3?5nFlashWrite?3?5write?1veri@| }, DATA, READONLY, SELECTION=2 ; comdat any
|??_C@_0EO@ELHIDNKN@?$AN?6ERROR?3?5nFlashWrite?3?5write?1veri@| DCB 0xd, 0xa
DCB "ERROR: nFlashWrite: write/verify failure (sector 0x%x, 0"
DCB "x%x, 0x%x, 0x%x).", 0xd, 0xa, 0x0 ; `string'
00000 AREA |.rdata| { |??_C@_0DN@KOFLADBK@?$AN?6ERROR?3?5FlashWrite?3?5FMD_WriteSe@| }, DATA, READONLY, SELECTION=2 ; comdat any
|??_C@_0DN@KOFLADBK@?$AN?6ERROR?3?5FlashWrite?3?5FMD_WriteSe@| DCB 0xd, 0xa
DCB "ERROR: FlashWrite: FMD_WriteSector failed (sector=0x%x)."
DCB 0xd, 0xa, 0x0 ; `string'
00000 AREA |.rdata| { |??_C@_0CB@NGJJEOHE@Writing?5to?5flash?5?$CIplease?5wait?$CJ?3?5@| }, DATA, READONLY, SELECTION=2 ; comdat any
|??_C@_0CB@NGJJEOHE@Writing?5to?5flash?5?$CIplease?5wait?$CJ?3?5@| DCB "W"
DCB "riting to flash (please wait): ", 0x0 ; `string'
00000 AREA |.rdata| { |??_C@_0DK@BOHIJOEK@?$AN?6ERROR?3?5FlashWrite?3?5Couldn?8t?5re@| }, DATA, READONLY, SELECTION=2 ; comdat any
|??_C@_0DK@BOHIJOEK@?$AN?6ERROR?3?5FlashWrite?3?5Couldn?8t?5re@| DCB 0xd, 0xa
DCB "ERROR: FlashWrite: Couldn't restore end area sectors.", 0xd
DCB 0xa, 0x0 ; `string'
00000 AREA |.rdata| { |??_C@_0DM@CHCKFJBF@?$AN?6ERROR?3?5FlashWrite?3?5Couldn?8t?5re@| }, DATA, READONLY, SELECTION=2 ; comdat any
|??_C@_0DM@CHCKFJBF@?$AN?6ERROR?3?5FlashWrite?3?5Couldn?8t?5re@| DCB 0xd, 0xa
DCB "ERROR: FlashWrite: Couldn't restore start area sectors.", 0xd
DCB 0xa, 0x0 ; `string'
00000 AREA |.rdata| { |??_C@_0DH@NMONLCCD@?$AN?6ERROR?3?5FlashWrite?3?5Unable?5to?5r@| }, DATA, READONLY, SELECTION=2 ; comdat any
|??_C@_0DH@NMONLCCD@?$AN?6ERROR?3?5FlashWrite?3?5Unable?5to?5r@| DCB 0xd, 0xa
DCB "ERROR: FlashWrite: Unable to read end area sector.", 0xd
DCB 0xa, 0x0 ; `string'
00000 AREA |.rdata| { |??_C@_0DJ@CPAALFMA@?$AN?6ERROR?3?5FlashWrite?3?5Unable?5to?5r@| }, DATA, READONLY, SELECTION=2 ; comdat any
|??_C@_0DJ@CPAALFMA@?$AN?6ERROR?3?5FlashWrite?3?5Unable?5to?5r@| DCB 0xd, 0xa
DCB "ERROR: FlashWrite: Unable to read start area sector.", 0xd
DCB 0xa, 0x0 ; `string'
00000 AREA |.rdata| { |??_C@_0CF@BDBFAKN@Handling?5non?9block?5aligned?5data?4@| }, DATA, READONLY, SELECTION=2 ; comdat any
|??_C@_0CF@BDBFAKN@Handling?5non?9block?5aligned?5data?4@| DCB "Handling "
DCB "non-block aligned data...", 0xd, 0xa, 0x0 ; `string'
00000 AREA |.rdata| { |??_C@_0FD@JDOHFIDH@WARNING?3?5FlashWrite?3?5unable?5to?5f@| }, DATA, READONLY, SELECTION=2 ; comdat any
|??_C@_0FD@JDOHFIDH@WARNING?3?5FlashWrite?3?5unable?5to?5f@| DCB "WARNING"
DCB ": FlashWrite: unable to find starting logical sector num"
DCB "ber - assuming 0.", 0xd, 0xa, 0x0 ; `string'
00000 AREA |.rdata| { |??_C@_0CP@JIDONMGO@BootDevice_Write?3Addr?5must?5be?5se@| }, DATA, READONLY, SELECTION=2 ; comdat any
|??_C@_0CP@JIDONMGO@BootDevice_Write?3Addr?5must?5be?5se@| DCB "BootDevic"
DCB "e_Write:Addr must be sector aligned", 0xd, 0xa, 0x0 ; `string'
; Function compile flags: /Ogsy
00000 AREA |.text| { |BootDevice_Write| }, CODE, ARM, SELECTION=1 ; comdat noduplicate
00000 |BootDevice_Write| PROC
; 399 : {
00000 |$L41326|
00000 e92d4ff0 stmdb sp!, {r4 - r11, lr}
00004 e24ddf9a sub sp, sp, #0x9A, 30
00008 |$M41324|
00008 e1a05002 mov r5, r2
0000c e58d1040 str r1, [sp, #0x40]
00010 e1a04000 mov r4, r0
00014 e59f344c ldr r3, [pc, #0x44C]
00018 e5933000 ldr r3, [r3]
0001c e58d3264 str r3, [sp, #0x264]
; 400 : #define BLOCK_SAVE_START 0x83E30000
; 401 :
; 402 : DWORD dwNumSects;
; 403 : DWORD dwStartBlock, dwNumBlocks;
; 404 : SECTOR_ADDR SectorAddr;
; 405 : SectorInfo SectInfo;
; 406 : BYTE SectBuff[SECTOR_SIZE];
; 407 : DWORD LogicalSectorNumber = 0;
; 408 : SECTORSAVEAREA SectorSaveArea;
; 409 : FlashInfo NorFlsInfo;
; 410 :
; 411 : EdbgOutputDebugString("Writing 0x%x to flash address 0x%x (length=0x%x).\r\n", (DWORD)pData, dwStartAddr, dwLength);
00020 e59f043c ldr r0, [pc, #0x43C]
00024 e1a03005 mov r3, r5
00028 e1a02004 mov r2, r4
0002c eb000000 bl EdbgOutputDebugString
; 412 :
; 413 : dwStartAddr = OALVAtoPA((void *)dwStartAddr);
00030 e1a00004 mov r0, r4
00034 eb000000 bl OALVAtoPA
; 414 :
; 415 : // EdbgOutputDebugString("BootDevice_Write:Addr Physical is:%x\r\n", dwStartAddr);
; 416 :
; 417 : //Addr必须以SECTOR_SIZE对齐
; 418 : if(dwStartAddr % SECTOR_SIZE != 0)
00038 e3a03f7f mov r3, #0x7F, 30
0003c e3833003 orr r3, r3, #3
00040 e1a04000 mov r4, r0
00044 e1140003 tst r4, r3
00048 0a000002 beq |$L40941|
; 419 : {
; 420 : EdbgOutputDebugString("BootDevice_Write:Addr must be sector aligned\r\n");
0004c e59f040c ldr r0, [pc, #0x40C]
00050 eb000000 bl EdbgOutputDebugString
; 421 : return FALSE;
00054 ea0000f3 b |$L41322|
00058 |$L40941|
; 422 : }
; 423 :
; 424 : Nor_FMD_GetInfo(&NorFlsInfo);
00058 e28d0014 add r0, sp, #0x14
0005c eb000000 bl Nor_FMD_GetInfo
; 425 : // RETAILMSG(1, (TEXT("[Flash Info] Type:%d dwNumBlocks:%d dwBytesPerBlock:%d wSectorsPerBlock:%d\r\n"), NorFlsInfo.flashType, NorFlsInfo.dwNumBlocks, NorFlsInfo.dwBytesPerBlock, NorFlsInfo.wSectorsPerBlock));
; 426 :
; 427 : SectorAddr = (dwStartAddr / NorFlsInfo.wDataBytesPerSector);
00060 e1dd02b2 ldrh r0, [sp, #0x22]
00064 e1a01004 mov r1, r4
00068 eb000000 bl __rt_udiv
0006c e1a06000 mov r6, r0
; 428 : dwNumSects = (dwLength / NorFlsInfo.wDataBytesPerSector);
00070 e1dd02b2 ldrh r0, [sp, #0x22]
00074 e1a01005 mov r1, r5
00078 eb000000 bl __rt_udiv
0007c e1a07000 mov r7, r0
; 429 : if (dwLength % NorFlsInfo.wDataBytesPerSector)
; 430 : ++dwNumSects;
; 431 :
; 432 : dwStartBlock = (SectorAddr / NorFlsInfo.wSectorsPerBlock);
00080 e1dd02b0 ldrh r0, [sp, #0x20]
00084 e3510000 cmp r1, #0
00088 e1a01006 mov r1, r6
0008c 12877001 addne r7, r7, #1
00090 eb000000 bl __rt_udiv
; 433 : dwNumBlocks = ((SectorAddr + dwNumSects) / NorFlsInfo.wSectorsPerBlock) - dwStartBlock;
00094 e1a04000 mov r4, r0
00098 e1dd02b0 ldrh r0, [sp, #0x20]
0009c e0875006 add r5, r7, r6
000a0 e1a01005 mov r1, r5
000a4 e58d500c str r5, [sp, #0xC]
000a8 e58d403c str r4, [sp, #0x3C]
000ac eb000000 bl __rt_udiv
000b0 e0644000 rsb r4, r4, r0
; 434 : if ((SectorAddr + dwNumSects) % NorFlsInfo.dwBytesPerBlock)
000b4 e59d001c ldr r0, [sp, #0x1C]
000b8 e1a01005 mov r1, r5
000bc e58d4028 str r4, [sp, #0x28]
000c0 eb000000 bl __rt_udiv
000c4 e3510000 cmp r1, #0
; 435 : ++dwNumBlocks;
000c8 12844001 addne r4, r4, #1
; 436 :
; 437 : // EdbgOutputDebugString("Sector=0x%x (Length=0x%x) Block=0x%x (Length=0x%x).\r\n", SectorAddr, dwNumSects, dwStartBlock, dwNumBlocks);
; 438 :
; 439 : // Determine the region's starting logical sector number.
; 440 : if (!Nor_FMD_ReadSector(SectorAddr, NULL, &SectInfo, 1))
000cc e3a03001 mov r3, #1
000d0 e28d2004 add r2, sp, #4
000d4 e3a01000 mov r1, #0
000d8 e1a00006 mov r0, r6
000dc 158d4028 strne r4, [sp, #0x28]
000e0 eb000000 bl Nor_FMD_ReadSector
000e4 e3500000 cmp r0, #0
000e8 1a000004 bne |$L40946|
; 441 : {
; 442 : EdbgOutputDebugString("WARNING: FlashWrite: unable to find starting logical sector number - assuming 0.\r\n");
000ec e59f0368 ldr r0, [pc, #0x368]
000f0 eb000000 bl EdbgOutputDebugString
; 443 : LogicalSectorNumber = 0;
000f4 e3a09000 mov r9, #0
000f8 e58d902c str r9, [sp, #0x2C]
; 444 : }
; 445 : else LogicalSectorNumber = SectInfo.dwReserved1;
000fc ea000001 b |$L40948|
00100 |$L40946|
00100 e59d3004 ldr r3, [sp, #4]
00104 e58d302c str r3, [sp, #0x2C]
00108 |$L40948|
; 446 :
; 447 : DEBUGMSG(1, (TEXT("FlashWrite: Starting logical sector number 0x%x.\r\n"), LogicalSectorNumber));
; 448 : EdbgOutputDebugString("Handling non-block aligned data...\r\n");
00108 e59f0348 ldr r0, [pc, #0x348]
0010c eb000000 bl EdbgOutputDebugString
; 449 :
; 450 : // Because flash erasure is at a block level, we may need to save sector data before and after the erase area since
; 451 : // our images aren't guaranteed to be block aligned (but they are sector aligned). Save sectors here and restore them
; 452 : // after doing the block erases.
; 453 : memset(&SectorSaveArea, 0, sizeof(SectorSaveArea));
00110 e3a02018 mov r2, #0x18
00114 e3a01000 mov r1, #0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -