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

Last change on this file since 389 was 386, checked in by aitotat@…, 12 years ago

Changes to XTIDE Universal BIOS:

  • Boot menu is now an optional module (MODULE_BOOT_MENU).
File size: 5.9 KB
RevLine 
[243]1; Project name : XTIDE Universal BIOS
2; Description : Int 19h Handler (Boot Loader).
3
[376]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
[243]20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
[249]24; INT 19h handler that properly reboots the computer when
25; INT 19h is called.
26;
27; Int19h_ResetHandler
28; Parameters:
29; Nothing
30; Returns:
31; Never returns (reboots computer)
32;--------------------------------------------------------------------
33Int19h_ResetHandler:
34 mov ax, BOOT_FLAG_WARM ; Skip memory tests
35 jmp Reboot_ComputerWithBootFlagInAX
36
37
38;--------------------------------------------------------------------
[243]39; Int19h_BootLoaderHandler
40; Parameters:
41; Nothing
42; Returns:
43; Never returns (loads operating system)
44;--------------------------------------------------------------------
45Int19h_BootLoaderHandler:
[282]46 sti
[250]47 ; Install INT 19h handler for proper reboot
[243]48 LOAD_BDA_SEGMENT_TO es, ax
[258]49 mov al, BIOS_BOOT_LOADER_INTERRUPT_19h ; INT 19h interrupt vector offset
[250]50 mov si, Int19h_ResetHandler ; INT 19h handler to reboot the system
[258]51 call Interrupts_InstallHandlerToVectorInALFromCSSI
[250]52 call Initialize_AndDetectDrives ; Installs new boot menu loader
[243]53 ; Fall to .PrepareStackAndSelectDriveFromBootMenu
54
55;--------------------------------------------------------------------
56; .PrepareStackAndSelectDriveFromBootMenu
57; Parameters:
58; ES: BDA and interrupt vector segment (zero)
59; Returns:
60; Never returns (loads operating system)
61;--------------------------------------------------------------------
62.PrepareStackAndSelectDriveFromBootMenu:
63 STORE_POST_STACK_POINTER
64 SWITCH_TO_BOOT_MENU_STACK
65 ; Fall to .InitializeDisplay
66
67;--------------------------------------------------------------------
68; .InitializeDisplay
69; Parameters:
70; Nothing
71; Returns:
72; Never returns (loads operating system)
73;--------------------------------------------------------------------
74.InitializeDisplay:
75 ; Change display mode if necessary
76 mov ax, [cs:ROMVARS.wDisplayMode] ; AH 00h = Set Video Mode
77 cmp al, DEFAULT_TEXT_MODE
78 je SHORT .InitializeDisplayLibrary
79 int BIOS_VIDEO_INTERRUPT_10h
80.InitializeDisplayLibrary:
81 call BootMenuPrint_InitializeDisplayContext
82 ; Fall to .SelectDriveToBootFrom
83
84;--------------------------------------------------------------------
85; .SelectDriveToBootFrom
86; Parameters:
87; Nothing
88; Returns:
89; Never returns (loads operating system)
90;--------------------------------------------------------------------
91.SelectDriveToBootFrom:
92 call RamVars_GetSegmentToDS
[386]93%ifdef MODULE_BOOT_MENU
[243]94 cmp WORD [cs:ROMVARS.wfDisplayBootMenu], BYTE 0
95 jne SHORT ProcessBootMenuSelectionsUntilBootableDriveSelected ; Display boot menu
[386]96%endif
[243]97 ; Fall to BootFromDriveAthenTryDriveC
98
99;--------------------------------------------------------------------
100; BootFromDriveAthenTryDriveC
101; Parameters:
102; DS: RAMVARS segment
103; Returns:
104; Never returns (loads operating system)
105;--------------------------------------------------------------------
106BootFromDriveAthenTryDriveC:
107 xor dx, dx ; DL = 00h = Floppy Drive A
108 call BootSector_TryToLoadFromDriveDL
109 jc SHORT Int19hMenu_JumpToBootSector_or_RomBoot
110 mov dl, 80h ; DL = 80h = First Hard Drive (usually C)
111 call BootSector_TryToLoadFromDriveDL
112 jmp SHORT Int19hMenu_JumpToBootSector_or_RomBoot ; ROM Boot if error
113
114
[386]115%ifdef MODULE_BOOT_MENU
[243]116;--------------------------------------------------------------------
117; ProcessBootMenuSelectionsUntilBootableDriveSelected
118; Parameters:
119; DS: RAMVARS segment
120; Returns:
121; Never returns
122;--------------------------------------------------------------------
123ProcessBootMenuSelectionsUntilBootableDriveSelected:
124 call BootMenu_DisplayAndReturnSelectionInDX
125 call DriveXlate_ToOrBack ; Translate drive number
126 call BootSector_TryToLoadFromDriveDL
127 jnc SHORT ProcessBootMenuSelectionsUntilBootableDriveSelected ; Boot failure, show menu again
128 ; Fall to Int19hMenu_JumpToBootSector_or_RomBoot
129 ; (CF is set or we wouldn't be here, see "jnc" immediately above)
[386]130%endif
[243]131
132;--------------------------------------------------------------------
133; Int19hMenu_JumpToBootSector_or_RomBoot
134;
135; Switches back to the POST stack, clears the DS and ES registers,
136; and either jumps to the MBR (Master Boot Record) that was just read,
137; or calls the ROM's boot routine on interrupt 18.
138;
139; Parameters:
140; DL: Drive to boot from (translated, 00h or 80h)
141; CF: Set for Boot Sector Boot
142; Clear for Rom Boot
143; ES:BX: (if CF set) Ptr to boot sector
144;
145; Returns:
146; Never returns
147;--------------------------------------------------------------------
148Int19hMenu_JumpToBootSector_or_RomBoot:
149 mov cx, es ; Preserve MBR segment (can't push because of stack change)
150 mov ax, 0 ; NOTE: can't use XOR (LOAD_BDA_SEGMENT_TO) as it impacts CF
151 SWITCH_BACK_TO_POST_STACK
152
153; clear segment registers before boot sector or rom call
154 mov ds, ax
155 mov es, ax
156%ifdef USE_386
157 mov fs, ax
158 mov gs, ax
159%endif
160 jnc SHORT .romboot
161
162; jump to boot sector
163 push cx ; sgment address for MBR
164 push bx ; offset address for MBR
165 retf ; NOTE: DL is set to the drive number
166
167; Boot by calling INT 18h (ROM Basic of ROM DOS)
168.romboot:
169 int BIOS_BOOT_FAILURE_INTERRUPT_18h ; Never returns
Note: See TracBrowser for help on using the repository browser.