VirtualBox

Changeset 95387 in vbox


Ignore:
Timestamp:
Jun 27, 2022 11:47:22 AM (2 years ago)
Author:
vboxsync
Message:

ValKit/bs3kit: Workaround for the FDC thinking 180K and 160K images are single sided and making them impossible to load (BIOS returns misleading drive parameters, and even if adjusted for we end up with a garbled image seemingly because we've been 'skipping' a side). bugref:9898

Location:
trunk/src/VBox/ValidationKit/bootsectors/bs3kit
Files:
2 edited

Legend:

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

    r93115 r95387  
    316316    free(paInputs);
    317317
     318    /* Avoid output sizes that makes the FDC code think it's a single sided
     319       floppy.  The BIOS always report double sided floppies, and even if we
     320       the bootsector adjust it's bMaxHeads value when getting a 20h error
     321       we end up with a garbaged image (seems somewhere in the BIOS/FDC it is
     322       still treated as a double sided floppy and we get half the data we want and
     323       with gaps). */
     324    uint32_t cbOutput = ftell(pOutput);
     325    if (   cbOutput == 512 * 8 * 40 /* 160kB 5"1/4 */
     326        || cbOutput == 512 * 9 * 40 /* 180kB 5"1/4 */)
     327    {
     328        static uint8_t const s_abZeroSector[512] = { 0 };
     329        if (fwrite(s_abZeroSector, sizeof(uint8_t), sizeof(s_abZeroSector), pOutput) != sizeof(s_abZeroSector))
     330        {
     331            fprintf(stderr, "error: fwrite failed (padding)\n");
     332            rcExit = 1;
     333        }
     334    }
     335
    318336    /* Finally, close the output file (can fail because of buffered data). */
    319     if (fclose(stderr) != 0)
     337    if (fclose(pOutput) != 0)
    320338    {
    321339        fprintf(stderr, "error: Error closing '%s'.\n", pszOutput);
     
    323341    }
    324342
    325     fclose(pOutput);
     343    fclose(stderr);
    326344    return rcExit;
    327345}
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-bootsector.asm

    r93115 r95387  
    4545;; Enabled load progress dots.
    4646%define BS3KIT_BOOTSECTOR_LOAD_DOTS
     47
     48;; Halts on failure location. For debugging.
     49;%define HLT_ON_FAILURE 1
    4750
    4851
     
    252255%if 0
    253256        mov     al, '='
    254         call    NAME(bs3PrintChrInAl)
     257        call    bs3PrintChrInAl
    255258%endif
    256259
     
    319322        mov     ah, 08h
    320323        int     13h
     324%ifndef HLT_ON_FAILURE
    321325        jc      .failure
     326%else
     327        jnc     .ok_geometry_call
     328        cli
     329        hlt
     330.ok_geometry_call:
     331%endif
    322332        and     cl, 63                  ; only the sector count.
    323333        mov     bMaxSector, cl
     
    376386        mov     ax, 0201h               ; al=1 sector; ah=read function
    377387        int     13h
     388%ifndef HLT_ON_FAILURE
    378389        jc      .failure
     390%else
     391        jnc     .read_ok
     392        cli
     393        hlt
     394.read_ok:
     395%endif
    379396
    380397        ; advance to the next sector/head/cylinder.
     
    442459
    443460        cmp     ah, 9                   ; DMA 64KB crossing error
     461%if 0 ; This hack doesn't work. If the FDC is in single sided mode we end up with a garbled image. Probably "missing" sides.
     462        je      .read_one
     463
     464        cmp     ah, 20h                 ; Controller error, probably because we're reading side 1 on a single sided floppy
    444465        jne     .failure
     466        cmp     bMaxHead, 0
     467        je      .failure
     468        cmp     dh, 1
     469        jne     .failure
     470        xor     dh, dh
     471        mov     bMaxHead, dh
     472        inc     ch
     473        jmp     .the_load_loop
     474.read_one
     475%else
     476        jne     .failure
     477%endif
    445478        mov     ax, 1                   ; Retry reading a single sector.
    446         jmp .read_again
     479        jmp     .read_again
    447480
    448481        ; advance to the next sector/head/cylinder and address.
     
    486519        ret
    487520
     521%ifndef HLT_ON_FAILURE
    488522        ;
    489523        ; Something went wrong, display a message.
    490524        ;
    491525.failure:
    492 %if 1 ; Disable to save space for debugging.
     526 %if 1 ; Disable to save space for debugging.
     527  %if 1
    493528        push    ax
     529  %endif
    494530
    495531        ; print message
     
    502538
    503539        ; panic
     540  %if 1
    504541        pop     ax
    505  %if 1
    506542        mov     al, ah
    507543        push    bs3PrintHexInAl
    508  %endif
     544  %endif
    509545        call    Bs3Panic
    510546.s_szErrMsg:
    511547        db 13, 10, 'rd err! '
    512 %else
     548 %else
    513549        hlt
    514550        jmp .failure
     551 %endif
    515552%endif
    516553.s_szErrMsgEnd:
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