source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm@ 394

Last change on this file since 394 was 392, checked in by aitotat@…, 13 years ago

Changes to XTIDE Universal BIOS:

  • Greatly improved Hotkey Bar is displayed during drive detection.
  • 8k builds no longer include boot menu.
  • Boot menu is displayed only if F2 is pressed during drive detection.
  • Some changes to directory structure.


File size: 6.2 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Int 19h Handler (Boot Loader).
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
12;
13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16; GNU General Public License for more details.
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; Int19h_BootLoaderHandler
25; Parameters:
26; Nothing
27; Returns:
28; Never returns (loads operating system)
29;--------------------------------------------------------------------
30Int19h_BootLoaderHandler:
31 sti ; Allow timer interrupts
32 LOAD_BDA_SEGMENT_TO es, ax ; Load BDA segment (zero) to ES
33 ; Fall to .PrepareBootLoaderStack
34
35
36;--------------------------------------------------------------------
37; Drive detection and boot menu use lots of stack so it is
38; wise to relocate stack. Otherwise something important from
39; interrupt vectors are likely corrupted, likely our own DPTs if
40; they are located to 30:0h.
41;
42; .PrepareBootLoaderStack
43; Parameters:
44; ES: BDA and interrupt vector segment (zero)
45; Returns:
46; Never returns (loads operating system)
47;--------------------------------------------------------------------
48.PrepareBootLoaderStack:
49 STORE_POST_STACK_POINTER
50 SWITCH_TO_BOOT_MENU_STACK
51 ; Fall to .InitializeDisplay
52
53
54;--------------------------------------------------------------------
55; .InitializeDisplay
56; Parameters:
57; ES: BDA and interrupt vector segment (zero)
58; Returns:
59; Never returns (loads operating system)
60;--------------------------------------------------------------------
61.InitializeDisplay:
62 ; Change display mode if necessary
63 mov ax, [cs:ROMVARS.wDisplayMode] ; AH 00h = Set Video Mode
64 cmp al, DEFAULT_TEXT_MODE
65 je SHORT .InitializeDisplayLibrary
66 int BIOS_VIDEO_INTERRUPT_10h
67.InitializeDisplayLibrary:
68 call DetectPrint_InitializeDisplayContext
69 ; Fall to .InitializeBiosAndDetectDrives
70
71
72;--------------------------------------------------------------------
73; .InitializeBiosAndDetectDrives
74; Parameters:
75; ES: BDA and interrupt vector segment (zero)
76; Returns:
77; DS: RAMVARS segment
78;--------------------------------------------------------------------
79 call Initialize_AndDetectDrives
80 ; Fall to SelectDriveToBootFrom
81
82
83;--------------------------------------------------------------------
84; SelectDriveToBootFrom
85; Parameters:
86; DS: RAMVARS segment
87; ES: BDA and interrupt vector segment (zero)
88; Returns:
89; Never returns (loads operating system)
90;--------------------------------------------------------------------
91SelectDriveToBootFrom:
92 call HotkeyBar_UpdateDuringDriveDetection
93
94%ifdef MODULE_BOOT_MENU
95 mov di, BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode
96 cmp BYTE [es:di], BOOT_MENU_HOTKEY_SCANCODE
97 jne SHORT .DoNotDisplayBootMenu
98
99 ; Stop blinking the Boot Menu hotkey and display menu
100 mov BYTE [es:di], 0
101 call HotkeyBar_DrawToTopOfScreen
102 call BootMenu_DisplayAndStoreSelectionAsHotkey
103.DoNotDisplayBootMenu:
104%endif
105
106 ; Check if ROM boot (INT 18h) wanted
107 cmp BYTE [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode], ROM_BOOT_HOTKEY_SCANCODE
108 je SHORT JumpToBootSector_or_RomBoot ; CF clear so ROM boot
109
110 ; Try to boot from Primary boot drive (00h by default)
111 call HotkeyBar_GetPrimaryBootDriveNumberToDL
112 call TryToBootFromPrimaryOrSecondaryBootDevice
113 jc SHORT JumpToBootSector_or_RomBoot
114
115 ; Try to boot from Secondary boot device (80h by default)
116 call HotkeyBar_GetSecondaryBootDriveNumberToDL
117 call TryToBootFromPrimaryOrSecondaryBootDevice
118
119%ifdef MODULE_BOOT_MENU
120 ; Force Boot Menu hotkey to display boot menu
121 mov BYTE [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode], BOOT_MENU_HOTKEY_SCANCODE
122 jnc SHORT SelectDriveToBootFrom
123%endif
124 ; Fall to JumpToBootSector_or_RomBoot
125
126
127;--------------------------------------------------------------------
128; JumpToBootSector_or_RomBoot
129;
130; Switches back to the POST stack, clears the DS and ES registers,
131; and either jumps to the MBR (Master Boot Record) that was just read,
132; or calls the ROM's boot routine on interrupt 18.
133;
134; Parameters:
135; DL: Drive to boot from (translated, 00h or 80h)
136; CF: Set for Boot Sector Boot
137; Clear for ROM Boot
138; ES:BX: (if CF set) Ptr to boot sector
139;
140; Returns:
141; Never returns
142;--------------------------------------------------------------------
143JumpToBootSector_or_RomBoot:
144 mov cx, es ; Preserve MBR segment (can't push because of stack change)
145 mov ax, 0 ; NOTE: can't use XOR (LOAD_BDA_SEGMENT_TO) as it impacts CF
146 SWITCH_BACK_TO_POST_STACK
147
148; clear segment registers before boot sector or rom call
149 mov ds, ax
150 mov es, ax
151%ifdef USE_386
152 mov fs, ax
153 mov gs, ax
154%endif
155 jnc SHORT .romboot
156
157; jump to boot sector
158 push cx ; sgment address for MBR
159 push bx ; offset address for MBR
160 retf ; NOTE: DL is set to the drive number
161
162; Boot by calling INT 18h (ROM Basic of ROM DOS)
163.romboot:
164 int BIOS_BOOT_FAILURE_INTERRUPT_18h ; Never returns
165
166
167;--------------------------------------------------------------------
168; TryToBootFromPrimaryOrSecondaryBootDevice
169; Parameters
170; DL: Drive selected as boot device
171; DS: RAMVARS segment
172; ES: BDA and interrupt vector segment (zero)
173; Returns:
174; DL: Drive to boot from (translated, 00h or 80h)
175; CF: Set for Boot Sector Boot
176; Clear for ROM Boot
177; ES:BX: (if CF set) Ptr to boot sector
178; Corrupts registers:
179; AX, CX, DH, SI, DI, (DL if failed to read boot sector)
180;--------------------------------------------------------------------
181TryToBootFromPrimaryOrSecondaryBootDevice:
182 call DriveXlate_SetDriveToSwap
183 call DriveXlate_ToOrBack
184 jmp BootSector_TryToLoadFromDriveDL
Note: See TracBrowser for help on using the repository browser.