source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19hMenu.asm@ 223

Last change on this file since 223 was 212, checked in by gregli@…, 13 years ago

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 size: 3.4 KB
RevLine 
[90]1; Project name : XTIDE Universal BIOS
[3]2; Description : Int 19h BIOS functions for Boot Menu.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
[122]8; Boot Menu Loader.
[3]9;
10; Int19hMenu_BootLoader
11; Parameters:
12; Nothing
13; Returns:
14; Jumps to Int19hMenu_Display, then never returns
15;--------------------------------------------------------------------
16ALIGN JUMP_ALIGN
17Int19hMenu_BootLoader:
[121]18 ; Store POST stack pointer
[3]19 LOAD_BDA_SEGMENT_TO ds, ax
[121]20 STORE_POST_STACK_POINTER
21 SWITCH_TO_BOOT_MENU_STACK
[143]22 call RamVars_GetSegmentToDS
23 ; Fall to .InitializeDisplayForBootMenu
24
25;--------------------------------------------------------------------
26; .InitializeDisplayForBootMenu
27; Parameters:
28; Nothing
29; Returns:
30; Nothing
31; Corrupts registers:
32; AX, DI
33;--------------------------------------------------------------------
34.InitializeDisplayForBootMenu:
35 ; Change display mode if necessary
36 mov ax, [cs:ROMVARS.wDisplayMode] ; AH 00h = Set Video Mode
37 cmp al, DEFAULT_TEXT_MODE
38 je SHORT .InitializeDisplayLibrary
39 int BIOS_VIDEO_INTERRUPT_10h
40.InitializeDisplayLibrary:
[130]41 call BootMenuPrint_InitializeDisplayContext
[96]42 ; Fall to .ProcessMenuSelectionsUntilBootable
[3]43
44;--------------------------------------------------------------------
[96]45; .ProcessMenuSelectionsUntilBootable
[3]46; Parameters:
47; DS: RAMVARS segment
48; Returns:
49; Never returns
50;--------------------------------------------------------------------
51ALIGN JUMP_ALIGN
[96]52.ProcessMenuSelectionsUntilBootable:
[95]53 call BootMenu_DisplayAndReturnSelection
[130]54 call DriveXlate_ToOrBack ; Translate drive number
[96]55 call BootSector_TryToLoadFromDriveDL
56 jnc SHORT .ProcessMenuSelectionsUntilBootable ; Boot failure, show menu again
[212]57 ; Fall to Int19hMenu_JumpToBootSector_or_RomBoot
58 ; (CF is set or we wouldn't be here, see "jnc" immediately above)
[3]59
[96]60;--------------------------------------------------------------------
[212]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;
[96]67; Parameters:
68; DL: Drive to boot from (translated, 00h or 80h)
[212]69; CF: Set for Boot Sector Boot
70; Clear for Rom Boot
71; ES:BX: (if CF set) Ptr to boot sector
72;
[96]73; Returns:
74; Never returns
75;--------------------------------------------------------------------
76ALIGN JUMP_ALIGN
[212]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;
[3]97
[212]98; clear segment registers before boot sector or rom call
99; (old ClearSegmentsForBoot routine)
100;
101 mov ds,ax
102 mov es,ax
[96]103
[212]104 jnc .romboot
[96]105
[212]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
[96]112
[212]113; (old Int19hMenu_RomBoot routine)
114;
115.romboot:
116 int BIOS_BOOT_FAILURE_INTERRUPT_18h ; Never returns
Note: See TracBrowser for help on using the repository browser.