VirtualBox

Ignore:
Timestamp:
Nov 23, 2023 12:40:38 AM (12 months ago)
Author:
vboxsync
Message:

bs3kit: Fixed some issues with loading of a fake 63.5 MB floppy. Added optional checksumming of the images we load (disabled by default, as it's slow in IEM). bugref:10371

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-rm-InitAll.c

    r102157 r102270  
    4242#include "bs3kit-template-header.h"
    4343#include "bs3-cmn-test.h"
     44#include "bs3kit-linker.h"
    4445#include <iprt/asm-amd64-x86.h>
    4546
     47
    4648BS3_MODE_PROTO_NOSB(void, Bs3EnteredMode,(void));
     49
     50
     51#ifdef BS3_WITH_LOAD_CHECKSUMS
     52/**
     53 * Verifies the base image checksum.
     54 */
     55static 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 */
    4787
    4888
     
    5191    uint8_t volatile BS3_FAR  *pcTicksFlpyOff;
    5292
     93#ifdef BS3_WITH_LOAD_CHECKSUMS
     94    /* This must be done before we modify anything in the loaded image. */
     95    bs3InitVerifyChecksum();
     96#endif
     97
    5398    /*
    5499     * Detect CPU first as the memory init code will otherwise use 386
     
    56101     */
    57102    Bs3CpuDetect_rm_far();
     103Bs3TestPrintf("#1\n");
    58104    Bs3InitMemory_rm_far();
     105Bs3TestPrintf("#2\n");
    59106    Bs3InitGdt_rm_far();
     107Bs3TestPrintf("#3\n");
    60108
    61109#ifdef BS3_INIT_ALL_WITH_HIGH_DLLS
     
    66114    Bs3InitHighDlls_rm_far();
    67115#endif
     116Bs3TestPrintf("#4\n");
    68117
    69118    /*
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette