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

Last change on this file since 494 was 492, checked in by gregli@…, 12 years ago

Removed the dependency between MODULE_BOOT_MENU and MODULE_HOTKEYS. With these changes, 0, 1, or 2 of them can be included in a build. This change also means that the hotkeys don't work while the menu is up. But the most important hotkey there was for Rom Boot, and that has been added to the menu as a choice proper. Lots of changes across the board in the hotkeys code - even if we eventually back this change out (becaue, for example we want hotkeys to work in the menu) we should probably start from this base and add that functionality back in, as these changes results in approximately 120 bytes of savings and includes new functionality, such as the Rom Boot menu item and the Com Detect hotkey.

File size: 4.0 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Reading and jumping to boot sector.
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; BootSector_TryToLoadFromDriveDL
25; Parameters:
26; DL: Drive to boot from (translated, 00h or 80h)
27; DS: RAMVARS segment
28; Returns:
29; ES:BX: Ptr to boot sector (if successful)
30; CF: Set if boot sector loaded successfully
31; Cleared if failed to load boot sector
32; Corrupts registers:
33; AX, CX, DH, SI, DI, (DL if failed to read boot sector)
34;--------------------------------------------------------------------
35BootSector_TryToLoadFromDriveDL_AndBoot:
36 call DetectPrint_TryToBootFromDL
37 call LoadFirstSectorFromDriveDL
38 jc SHORT .FailedToLoadFirstSector
39
40 test dl, dl
41 jns SHORT .AlwaysBootFromFloppyDriveForBooterGames
42 cmp WORD [es:bx+510], 0AA55h ; Valid boot sector?
43 jne SHORT .FirstHardDiskSectorNotBootable
44.AlwaysBootFromFloppyDriveForBooterGames:
45 stc
46 jmp SHORT JumpToBootSector_or_RomBoot
47.FailedToLoadFirstSector:
48 call DetectPrint_FailedToLoadFirstSector
49 ret
50.FirstHardDiskSectorNotBootable:
51 mov si, g_szBootSectorNotFound
52 call DetectPrint_NullTerminatedStringFromCSSIandSetCF
53 ret
54
55%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
56 %ifdef MODULE_DRIVEXLATE
57 %if TryToBoot_FallThroughTo_BootSector_TryToLoadFromDriveDL_AndBoot <> BootSector_TryToLoadFromDriveDL_AndBoot
58 %error "TryToBoot_FallThroughTo_BootSector_TryToLoadFromDriveDL_AndBoot <> BootSector_TryToLoadFromDriveDL_AndBoot, BootSector must come immediately after int19h.asm"
59 %endif
60 %endif
61%endif
62
63;--------------------------------------------------------------------
64; LoadFirstSectorFromDriveDL
65; Parameters:
66; DL: Drive to boot from (translated, 00h or 80h)
67; Returns:
68; AH: INT 13h error code
69; ES:BX: Ptr to boot sector (if successful)
70; CF: Cleared if read successful
71; Set if any error
72; Corrupts registers:
73; AL, CX, DH, DI
74;--------------------------------------------------------------------
75LoadFirstSectorFromDriveDL:
76 LOAD_BDA_SEGMENT_TO es, bx ; ES:BX now points to...
77 mov bx, BOOTVARS.rgbBootSect ; ...boot sector location
78 mov di, BOOT_READ_RETRY_TIMES ; Initialize retry counter
79
80.ReadRetryLoop:
81 call .LoadFirstSectorFromDLtoESBX
82 jnc SHORT .Return
83 dec di ; Decrement retry counter (preserve CF)
84 jz SHORT .Return ; Loop while retries left
85
86 ; Reset drive and retry
87 xor ax, ax ; AH=0h, Disk Controller Reset
88 test dl, dl ; Floppy drive?
89 eCMOVS ah, RESET_HARD_DISK ; AH=Dh, Reset Hard Disk (Alternate reset)
90 int BIOS_DISK_INTERRUPT_13h
91 jmp SHORT .ReadRetryLoop
92
93
94;--------------------------------------------------------------------
95; .LoadFirstSectorFromDLtoESBX
96; Parameters:
97; DL: Drive to boot from (translated, 00h or 80h)
98; ES:BX: Destination buffer for boot sector
99; Returns:
100; AH: INT 13h error code
101; ES:BX: Ptr to boot sector
102; CF: Cleared if read successful
103; Set if any error
104; Corrupts registers:
105; AL, CX, DH
106;--------------------------------------------------------------------
107.LoadFirstSectorFromDLtoESBX:
108 mov ax, 0201h ; Read 1 sector
109 mov cx, 1 ; Cylinder 0, Sector 1
110 xor dh, dh ; Head 0
111 int BIOS_DISK_INTERRUPT_13h
112.Return:
113 ret
Note: See TracBrowser for help on using the repository browser.