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

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

More fun with resets: It turns out to be important to reset our drives too, if for not other reason then to have the proper return code set for xlat'd drives (consider the case that we reset foreign drives with dl=80h, and at the same time we have one of our drives mapped to 80h). Fixed bug with polarity of ther iteration routine in ahDh for the return value for ah9h. Update signature in Configurator.

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