Changeset 102270 in vbox for trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-rm-InitAll.c
- Timestamp:
- Nov 23, 2023 12:40:38 AM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-rm-InitAll.c
r102157 r102270 42 42 #include "bs3kit-template-header.h" 43 43 #include "bs3-cmn-test.h" 44 #include "bs3kit-linker.h" 44 45 #include <iprt/asm-amd64-x86.h> 45 46 47 46 48 BS3_MODE_PROTO_NOSB(void, Bs3EnteredMode,(void)); 49 50 51 #ifdef BS3_WITH_LOAD_CHECKSUMS 52 /** 53 * Verifies the base image checksum. 54 */ 55 static void bs3InitVerifyChecksum(void) 56 { 57 BS3BOOTSECTOR const RT_FAR *pBootSector = (BS3BOOTSECTOR const RT_FAR *)BS3_FP_MAKE(0, 0x7c00); 58 uint32_t cSectors = pBootSector->cTotalSectors; 59 uint32_t const cSectorsSaved = cSectors; 60 uint16_t uCurSeg = (BS3_ADDR_LOAD >> 4); /* ASSUMES 16 byte aligned load address! */ 61 uint32_t uChecksum = BS3_CALC_CHECKSUM_INITIAL_VALUE; 62 while (cSectors > 0) 63 { 64 uint8_t const *pbSrc = BS3_FP_MAKE(uCurSeg, 0); 65 if (cSectors >= _32K / 512) 66 { 67 uChecksum = Bs3CalcChecksum(uChecksum, pbSrc, _32K); 68 cSectors -= _32K / 512; 69 uCurSeg += 0x800; 70 } 71 else 72 { 73 uChecksum = Bs3CalcChecksum(uChecksum, pbSrc, (uint16_t)cSectors * 512); 74 break; 75 } 76 } 77 Bs3TestPrintf("base image checksum: %#RX32, expected %#RX32 over (%#RX32 sectors, uCurSeg=%#x) sizeof(size_t)=%d\n", 78 uChecksum, pBootSector->dwSerialNumber, cSectorsSaved, uCurSeg, sizeof(size_t)); 79 if (uChecksum != pBootSector->dwSerialNumber) 80 { 81 Bs3TestPrintf("base image checksum mismatch: %#RX32, expected %#RX32 over %#RX32 sectors\n", 82 uChecksum, pBootSector->dwSerialNumber, cSectorsSaved); 83 Bs3Panic(); 84 } 85 } 86 #endif /* BS3_WITH_LOAD_CHECKSUMS */ 47 87 48 88 … … 51 91 uint8_t volatile BS3_FAR *pcTicksFlpyOff; 52 92 93 #ifdef BS3_WITH_LOAD_CHECKSUMS 94 /* This must be done before we modify anything in the loaded image. */ 95 bs3InitVerifyChecksum(); 96 #endif 97 53 98 /* 54 99 * Detect CPU first as the memory init code will otherwise use 386 … … 56 101 */ 57 102 Bs3CpuDetect_rm_far(); 103 Bs3TestPrintf("#1\n"); 58 104 Bs3InitMemory_rm_far(); 105 Bs3TestPrintf("#2\n"); 59 106 Bs3InitGdt_rm_far(); 107 Bs3TestPrintf("#3\n"); 60 108 61 109 #ifdef BS3_INIT_ALL_WITH_HIGH_DLLS … … 66 114 Bs3InitHighDlls_rm_far(); 67 115 #endif 116 Bs3TestPrintf("#4\n"); 68 117 69 118 /*
Note:
See TracChangeset
for help on using the changeset viewer.