VirtualBox

Changeset 103864 in vbox


Ignore:
Timestamp:
Mar 15, 2024 9:13:46 AM (12 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
162235
Message:

Fix bs3 floppy image generation to avoid unbootable image sizes, bugref:9898

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/VBoxBs3Linker.cpp

    r102285 r103864  
    739739     * sided 5.25" floppy with 40 tracks, while the BIOS keeps reporting a
    740740     * 1.44MB 3.5" floppy. So, just avoid those sizes too.
     741     *
     742     * There are many problem sizes like 400kB, 820kB; see fd_formats[] in
     743     * src/VBox/Devices/Storage/DevFdc.cpp.  Every size in the table is an
     744     * even number of kB; let's just pad to an odd number number of kB.
     745     *
     746     * Controller-recognized sizes cause boot failure in bs3-bootsector.asm.
     747     * When avoiding 64kB DMA boundaries it tries to read a sector outside the
     748     * guessed geometry, receiving a hard I/O error.
    741749     */
    742750    uint32_t cbOutput = ftell(pOutput);
     751#if 1
     752    uint32_t uBoundary = cbOutput % (2 * 1024);
     753    if (uBoundary != 1024)
     754    {
     755        static uint8_t const s_abZeroBytes[2 * 1024] = { 0 };
     756        uint32_t cbPaddingNeeded = (uBoundary < 1024) ? 1024 - uBoundary : 3 * 1024 - uBoundary;
     757
     758        if (fwrite(s_abZeroBytes, sizeof(uint8_t), cbPaddingNeeded, pOutput) != cbPaddingNeeded)
     759            return RTMsgErrorExitFailure("fwrite failed (padding)");
     760    }
     761#else
    743762    if (   cbOutput == 512 * 8 * 40 * 1 /* 160kB 5"1/4 SS */
    744763        || cbOutput == 512 * 9 * 40 * 1 /* 180kB 5"1/4 SS */
     
    750769            return RTMsgErrorExitFailure("fwrite failed (padding)");
    751770    }
     771#endif
    752772
    753773    return RTEXITCODE_SUCCESS;
Note: See TracChangeset for help on using the changeset viewer.

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