📄 main.cod
字号:
00040 e28d1008 add r1, sp, #8
00044 e1a00004 mov r0, r4
00048 eb000000 bl BP_ReadData
0004c e3500000 cmp r0, #0
; 1037 : {
; 1038 : return(FALSE);
00050 0a00003c beq |$L44623|
; 1039 : }
; 1040 :
; 1041 : // is the partition compressed?
; 1042 : pCompHeader = (PCOMPRESSED_RAMIMAGE_HEADER) SectorData;
; 1043 : if ((pCompHeader->dwSignature == RAMIMAGE_COMPRESSION_SIGNATURE) &&
; 1044 : (pCompHeader->dwVersion == RAMIMAGE_COMPRESSION_VERSION) &&
; 1045 : (pCompHeader->dwCompressedBlockSize == RAMIMAGE_COMPRESSION_BLOCK_SIZE))
00054 e59f3110 ldr r3, [pc, #0x110]
00058 e59d2048 ldr r2, [sp, #0x48]
0005c e1520003 cmp r2, r3
00060 1a00002d bne |$L44637|
00064 e59d3038 ldr r3, [sp, #0x38]
00068 e3530005 cmp r3, #5
0006c 1a000035 bne |$L44623|
00070 e59d3044 ldr r3, [sp, #0x44]
00074 e3530a01 cmp r3, #1, 20
00078 1a000032 bne |$L44623|
; 1046 : {
; 1047 : // initialize the compressor
; 1048 : if (!InitDecompressor(hPartition, pCompHeader->dwHeaderSize))
0007c e59d103c ldr r1, [sp, #0x3C]
00080 e1a00004 mov r0, r4
00084 eb000000 bl InitDecompressor
00088 e3500000 cmp r0, #0
; 1049 : {
; 1050 : return(FALSE);
0008c 0a00002d beq |$L44623|
; 1051 : }
; 1052 :
; 1053 : // update the global "partition is compressed" flag
; 1054 : g_fCompressed = TRUE;
00090 e59f60d0 ldr r6, [pc, #0xD0]
00094 e3a02001 mov r2, #1
; 1055 :
; 1056 : // set the data pointer to the first byte after the compressed header
; 1057 : if (!BP_SetDataPointer(hPartition, g_CompressionHeader->dwHeaderSize))
00098 e1a00004 mov r0, r4
0009c e5963008 ldr r3, [r6, #8]
000a0 e5862000 str r2, [r6]
000a4 e5931034 ldr r1, [r3, #0x34]
000a8 eb000000 bl BP_SetDataPointer
000ac e3500000 cmp r0, #0
; 1058 : {
; 1059 : return(FALSE);
000b0 0a000024 beq |$L44623|
; 1060 : }
; 1061 :
; 1062 : // the compressed size of the first block is stored in pCompHeader
; 1063 : wBlockSize = g_CompressionHeader->wBlockSizeTable[0];
000b4 e5963008 ldr r3, [r6, #8]
; 1064 :
; 1065 : // read the first page into our compressed data buffer
; 1066 : if (!BP_ReadData(hPartition, CompressedData, wBlockSize))
000b8 e59f70a4 ldr r7, [pc, #0xA4]
000bc e1a00004 mov r0, r4
000c0 e1d344b4 ldrh r4, [r3, #0x44]
000c4 e1a01007 mov r1, r7
000c8 e1a02004 mov r2, r4
000cc eb000000 bl BP_ReadData
000d0 e3500000 cmp r0, #0
; 1067 : {
; 1068 : return(FALSE);
000d4 0a00001b beq |$L44623|
; 1069 : }
; 1070 :
; 1071 : // if block size = max size, this block is not compressed
; 1072 : if (wBlockSize == RAMIMAGE_COMPRESSION_BLOCK_SIZE)
000d8 e3540a01 cmp r4, #1, 20
000dc 1a000004 bne |$L44632|
; 1073 : {
; 1074 : // just copy data over into SectorData
; 1075 : memcpy(SectorData, CompressedData, PARTITION_HEADER_BYTES);
000e0 e28d0008 add r0, sp, #8
000e4 e3a0204c mov r2, #0x4C
000e8 e1a01007 mov r1, r7
000ec eb000000 bl memcpy
; 1076 : }
; 1077 : else
000f0 ea000008 b |$L45227|
000f4 |$L44632|
; 1078 : {
; 1079 : // decompress the first page back into SectorData
; 1080 : dwBytesRead = CeCompressDecode(g_DecodeStream, SectorData, RAMIMAGE_COMPRESSION_BLOCK_SIZE, PARTITION_HEADER_BYTES, CompressedData, wBlockSize);
000f4 e5960004 ldr r0, [r6, #4]
000f8 e3a0304c mov r3, #0x4C
000fc e3a02a01 mov r2, #1, 20
00100 e28d1008 add r1, sp, #8
00104 e58d4004 str r4, [sp, #4]
00108 e58d7000 str r7, [sp]
0010c eb000000 bl CeCompressDecode
; 1081 : if (dwBytesRead != PARTITION_HEADER_BYTES)
00110 e350004c cmp r0, #0x4C
; 1082 : {
; 1083 : return(FALSE);
00114 1a00000b bne |$L44623|
00118 |$L45227|
00118 e59d2048 ldr r2, [sp, #0x48]
0011c |$L44637|
; 1084 : }
; 1085 : }
; 1086 : }
; 1087 :
; 1088 : // Valid table of contents address signature?
; 1089 : if (*(UINT32 *)(&SectorData[ROM_SIGNATURE_OFFSET]) != ROM_SIGNATURE)
0011c e59f303c ldr r3, [pc, #0x3C]
00120 e1520003 cmp r2, r3
; 1090 : {
; 1091 : return(FALSE);
00124 1a000007 bne |$L44623|
; 1092 : }
; 1093 :
; 1094 : // Extract the start address, length, and jump address from the table of contents.
; 1095 : //
; 1096 : dwTocLoc = *(UINT32 *)(&SectorData[ROM_TOC_POINTER_OFFSET]);
; 1097 : dwTocOffset= *(UINT32 *)(&SectorData[ROM_TOC_OFFSET_OFFSET]);
; 1098 : *ulImageStartAddr = dwTocLoc - dwTocOffset;
00128 e59d2050 ldr r2, [sp, #0x50]
0012c e59d304c ldr r3, [sp, #0x4C]
00130 e0433002 sub r3, r3, r2
00134 e5853000 str r3, [r5]
; 1099 :
; 1100 : return(TRUE);
00138 e59d0054 ldr r0, [sp, #0x54]
0013c eb000000 bl __security_check_cookie
00140 e3a00001 mov r0, #1
00144 ea000002 b |$L44611|
00148 |$L44623|
; 1025 : {
; 1026 : return(FALSE);
00148 e59d0054 ldr r0, [sp, #0x54]
0014c eb000000 bl __security_check_cookie
00150 e3a00000 mov r0, #0
00154 |$L44611|
; 1101 :
; 1102 : }
00154 e28dd058 add sp, sp, #0x58
00158 e8bd40f0 ldmia sp!, {r4 - r7, lr}
0015c e12fff1e bx lr
00160 |$L45238|
00160 43454345 DCD 0x43454345
00164 00000000 DCD |CompressedData|
00168 00000000 DCD |g_fCompressed|
0016c 58505253 DCD 0x58505253
00170 00000000 DCD |__security_cookie|
00174 |$M45234|
ENDP ; |GetImageInfo|
EXPORT |OEMTranslateBaseAddress|
00000 AREA |.text| { |OEMTranslateBaseAddress| }, CODE, ARM, SELECTION=1 ; comdat noduplicate
00000 AREA |.pdata$$OEMTranslateBaseAddress|, PDATA, SELECTION=5, ASSOC=|.text| { |OEMTranslateBaseAddress| } ; comdat associative
|$T45252| DCD |$L45251|
DCD 0x40001b01
; Function compile flags: /Ogsy
00000 AREA |.text| { |OEMTranslateBaseAddress| }, CODE, ARM, SELECTION=1 ; comdat noduplicate
00000 |OEMTranslateBaseAddress| PROC
; 1105 : {
00000 |$L45251|
00000 e92d4070 stmdb sp!, {r4 - r6, lr}
00004 |$M45249|
00004 e1a04002 mov r4, r2
00008 e1a05001 mov r5, r1
0000c e1a06000 mov r6, r0
; 1106 : UINT32 FlashBaseVirtual = (UINT32) OALPAtoVA(MAINSTONEII_BASE_PA_SECONDARY_FLASH, TRUE);
00010 e3a01001 mov r1, #1
00014 e3a00301 mov r0, #1, 6
00018 eb000000 bl OALPAtoVA
; 1107 :
; 1108 : if (pulTransAddr == NULL)
0001c e3540000 cmp r4, #0
; 1109 : {
; 1110 : return(FALSE);
00020 03a00000 moveq r0, #0
; 1139 : }
00024 08bd4070 ldmeqia sp!, {r4 - r6, lr}
00028 012fff1e bxeq lr
; 1111 : }
; 1112 :
; 1113 : switch(ulPartType)
0002c e3560020 cmp r6, #0x20
00030 0a000008 beq |$L44658|
; 1119 : break;
; 1120 : case PART_XIP:
; 1121 : default:
; 1122 : // Flash or RAM address?
; 1123 : //
; 1124 : ulAddr &= ~0x20000000;
00034 e3c52202 bic r2, r5, #2, 4
; 1125 : if (ulAddr >= FlashBaseVirtual && (ulAddr < (FlashBaseVirtual + MAINSTONEII_SIZE_BOOT_FLASH)))
00038 e1520000 cmp r2, r0
0003c 3a000003 bcc |$L44660|
00040 e2803301 add r3, r0, #1, 6
00044 e1520003 cmp r2, r3
; 1126 : {
; 1127 : // FLASH: 0x8400.0000 virtual == 0x0000.0000 physical (flash).
; 1128 : *pulTransAddr = (ulAddr - FlashBaseVirtual);
00048 30423000 subcc r3, r2, r0
0004c 3a000002 bcc |$L45248|
00050 |$L44660|
; 1129 : }
; 1130 : else
; 1131 : {
; 1132 : // RAM: 0x8000.0000 virtual == 0xA000.0000 physical (used by IPL).
; 1133 : *pulTransAddr = (ulAddr + 0x20000000);
00050 e2823202 add r3, r2, #2, 4
; 1134 : }
; 1135 : break;
00054 ea000000 b |$L45248|
00058 |$L44658|
; 1114 : {
; 1115 : case PART_BOOTSECTION:
; 1116 : // Assume update loader partition contains an uncompressed RAM-based image.
; 1117 : // 0x8000.0000 virtual == 0xA000.0000 physical (used by IPL).
; 1118 : *pulTransAddr = (ulAddr + 0x20000000);
00058 e2853202 add r3, r5, #2, 4
0005c |$L45248|
0005c e5843000 str r3, [r4]
; 1136 : }
; 1137 :
; 1138 : return(TRUE);
00060 e3a00001 mov r0, #1
; 1139 : }
00064 e8bd4070 ldmia sp!, {r4 - r6, lr}
00068 e12fff1e bx lr
0006c |$M45250|
ENDP ; |OEMTranslateBaseAddress|
00000 AREA |.text| { |ReadTOC| }, CODE, ARM, SELECTION=1 ; comdat noduplicate
00000 AREA |.pdata$$ReadTOC|, PDATA, SELECTION=5, ASSOC=|.text| { |ReadTOC| } ; comdat associative
|$T45265| DCD |$L45264|
DCD 0x40003502
; Function compile flags: /Ogsy
00000 AREA |.text| { |ReadTOC| }, CODE, ARM, SELECTION=1 ; comdat noduplicate
00000 |ReadTOC| PROC
; 1148 : {
00000 |$L45264|
00000 e92d4030 stmdb sp!, {r4, r5, lr}
00004 e24dd050 sub sp, sp, #0x50
00008 |$M45262|
00008 e1a05001 mov r5, r1
0000c e1a04000 mov r4, r0
00010 e59f30b8 ldr r3, [pc, #0xB8]
00014 e5933000 ldr r3, [r3]
00018 e58d304c str r3, [sp, #0x4C]
; 1149 : // TODO: statically allocate some big sector buffer size on the stack...
; 1150 : BYTE SectorData[PARTITION_HEADER_BYTES];
; 1151 : UINT32 TOCoffset = 0;
; 1152 :
; 1153 : if (hPartition == INVALID_HANDLE_VALUE || pTOC == NULL)
0001c e3740001 cmn r4, #1
00020 0a000023 beq |$L44674|
00024 e3550000 cmp r5, #0
00028 0a000021 beq |$L44674|
; 1156 : }
; 1157 :
; 1158 : // Restore the file pointer to the start of the partition.
; 1159 : //
; 1160 : if (!BP_SetDataPointer(hPartition, 0))
0002c e3a01000 mov r1, #0
00030 eb000000 bl BP_SetDataPointer
00034 e3500000 cmp r0, #0
; 1161 : {
; 1162 : return(FALSE);
00038 0a00001d beq |$L44674|
; 1163 : }
; 1164 :
; 1165 : // Read the first sector - this contains the address of the table of contents.
; 1166 : //
; 1167 : if (!BP_ReadData(hPartition, SectorData, PARTITION_HEADER_BYTES))
0003c e3a0204c mov r2, #0x4C
00040 e28d1000 add r1, sp, #0
00044 e1a00004 mov r0, r4
00048 eb000000 bl BP_ReadData
0004c e3500000 cmp r0, #0
; 1168 : {
; 1169 : return(FALSE);
00050 0a000017 beq |$L44674|
; 1170 : }
; 1171 :
; 1172 : // Valid table of contents address signature?
; 1173 : //
; 1174 : if (*(UINT32 *)(&SectorData[ROM_SIGNATURE_OFFSET]) != ROM_SIGNATURE)
00054 e59d2040 ldr r2, [sp, #0x40]
00058 e59f306c ldr r3, [pc, #0x6C]
0005c e1520003 cmp r2, r3
; 1175 : {
; 1176 : return(FALSE);
00060 1a000013 bne |$L44674|
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -