Changeset 212 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Handlers


Ignore:
Timestamp:
Jan 16, 2012, 8:50:39 PM (12 years ago)
Author:
gregli@…
google:author:
gregli@hotmail.com
Message:

Fixed a bug where DL was always zero when transitioning control to the MBR (boot sector), where it should have been the drive number. This was preventing FreeDOS from booting. Also took the opportunity to fold two code paths together, jump to boot sector and jump to rom boot, resulting in a savings of 20 bytes for the XT build.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19hMenu.asm

    r152 r212  
    5555    call    BootSector_TryToLoadFromDriveDL
    5656    jnc     SHORT .ProcessMenuSelectionsUntilBootable   ; Boot failure, show menu again
    57     SWITCH_BACK_TO_POST_STACK
    58     ; Fall to JumpToBootSector
     57    ; Fall to Int19hMenu_JumpToBootSector_or_RomBoot
     58    ; (CF is set or we wouldn't be here, see "jnc" immediately above)
    5959
    6060;--------------------------------------------------------------------
    61 ; JumpToBootSector
     61; Int19hMenu_JumpToBootSector_or_RomBoot
     62;
     63; Switches back to the POST stack, clears the DS and ES registers,
     64; and either jumps to the MBR (Master Boot Record) that was just read,
     65; or calls the ROM's boot routine on interrupt 18.
     66;
    6267;   Parameters:
    6368;       DL:     Drive to boot from (translated, 00h or 80h)
    64 ;       ES:BX:  Ptr to boot sector
     69;       CF:     Set for Boot Sector Boot
     70;               Clear for Rom Boot
     71;       ES:BX:  (if CF set) Ptr to boot sector
     72;
    6573;   Returns:
    6674;       Never returns
    6775;--------------------------------------------------------------------
    6876ALIGN JUMP_ALIGN
    69 JumpToBootSector:
    70     push    es                              ; Push boot sector segment
    71     push    bx                              ; Push boot sector offset
    72     call    ClearSegmentsForBoot
    73     retf
     77Int19hMenu_JumpToBootSector_or_RomBoot:
     78        mov     cx,es       ; preserve MBR segment
     79;
     80; inline of SWITCH_BACK_TO_POST_STACK macro, so that we can preserve CF
     81; and reuse zero value in ax for clearing segment registers
     82;
     83        mov     ax,0        ; NOTE: can't use XOR as it impacts CF
     84%ifndef USE_386
     85        cli
     86        mov     ss,ax
     87        mov     sp,[ss:BOOTVARS.dwPostStack]
     88        mov     ss,[ss:BOOTVARS.dwPostStack+2]
     89        sti
     90%else
     91        mov     ss,ax
     92        lss     sp,[ss:BOOTVARS.dwPostStack]
     93%endif 
     94;
     95; end inline of SWITCH_BACK_TO_POST_STACK
     96;
    7497
     98; clear segment registers before boot sector or rom call
     99; (old ClearSegmentsForBoot routine)
     100;
     101        mov     ds,ax       
     102        mov     es,ax
    75103
    76 ;--------------------------------------------------------------------
    77 ; Int19hMenu_RomBoot
    78 ;   Parameters:
    79 ;       DS:     RAMVARS segment
    80 ;   Returns:
    81 ;       Never returns
    82 ;--------------------------------------------------------------------
    83 ALIGN JUMP_ALIGN
    84 Int19hMenu_RomBoot:
    85     SWITCH_BACK_TO_POST_STACK
    86     call    ClearSegmentsForBoot
    87     int     BIOS_BOOT_FAILURE_INTERRUPT_18h ; Never returns
     104        jnc     .romboot
    88105
     106; jump to boot sector
     107; (old JumpToBootSector routine)
     108;
     109        push    cx          ; sgment address for MBR
     110        push    bx          ; offset address for MBR
     111        retf                ; NOTE: DL is set to the drive number
    89112
    90 ;--------------------------------------------------------------------
    91 ; ClearSegmentsForBoot
    92 ;   Parameters:
    93 ;       Nothing
    94 ;   Returns:
    95 ;       DX:     Zero
    96 ;       DS=ES:  Zero
    97 ;   Corrupts registers:
    98 ;       Nothing
    99 ;--------------------------------------------------------------------
    100 ALIGN JUMP_ALIGN
    101 ClearSegmentsForBoot:
    102     xor     dx, dx                  ; Device supported by INT 13h
    103     mov     ds, dx
    104     mov     es, dx
    105     ret
     113; (old Int19hMenu_RomBoot routine)
     114;
     115.romboot:       
     116        int     BIOS_BOOT_FAILURE_INTERRUPT_18h ; Never returns     
Note: See TracChangeset for help on using the changeset viewer.