source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Boot/BootSector.asm@ 375

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

Removed align directives for initalization code and added define for align in boot-time calls to the assembly library (defaulting to 1), resulting in a significant savings for the AT and 386 builds. Fixed a bug with switch command line handling in the serial server. Put in CR characters in licesnse.txt, so that it properly displays on Windows. In the configurator, added default values for user supplied CHS and LBA values, defaulting to values within range when those features are enabled. Updated the copyright message in the configurator as the literal word Copyright is important.

File size: 3.3 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Reading and jumping to boot sector.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; BootSector_TryToLoadFromDriveDL
9; Parameters:
10; DL: Drive to boot from (translated, 00h or 80h)
11; DS: RAMVARS segment
12; Returns:
13; ES:BX: Ptr to boot sector (if successful)
14; CF: Set if boot sector loaded successfully
15; Cleared if failed to load boot sector
16; Corrupts registers:
17; AX, CX, DH, SI, DI, (DL if failed to read boot sector)
18;--------------------------------------------------------------------
19BootSector_TryToLoadFromDriveDL:
20 call BootPrint_TryToBootFromDL
21 call LoadFirstSectorFromDriveDL
22 jc SHORT .FailedToLoadFirstSector
23
24 test dl, dl
25 jns SHORT .AlwaysBootFromFloppyDriveForBooterGames
26 cmp WORD [es:bx+510], 0AA55h ; Valid boot sector?
27 jne SHORT .FirstHardDiskSectorNotBootable
28.AlwaysBootFromFloppyDriveForBooterGames:
29 stc
30 ret
31.FailedToLoadFirstSector:
32 call BootPrint_FailedToLoadFirstSector
33 clc
34 ret
35.FirstHardDiskSectorNotBootable:
36 mov si, g_szBootSectorNotFound
37 call BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
38 clc
39 ret
40
41;--------------------------------------------------------------------
42; LoadFirstSectorFromDriveDL
43; Parameters:
44; DL: Drive to boot from (translated, 00h or 80h)
45; Returns:
46; AH: INT 13h error code
47; ES:BX: Ptr to boot sector (if successful)
48; CF: Cleared if read successful
49; Set if any error
50; Corrupts registers:
51; AL, CX, DH, DI
52;--------------------------------------------------------------------
53LoadFirstSectorFromDriveDL:
54 LOAD_BDA_SEGMENT_TO es, bx ; ES:BX now points to...
55 mov bx, BOOTVARS.rgbBootSect ; ...boot sector location
56 mov di, BOOT_READ_RETRY_TIMES ; Initialize retry counter
57
58.ReadRetryLoop:
59 call .ResetBootDriveFromDL
60 call .LoadFirstSectorFromDLtoESBX
61 jnc SHORT .Return
62 dec di ; Decrement retry counter
63 jnz SHORT .ReadRetryLoop ; Loop while retries left
64.Return:
65 ret
66
67;--------------------------------------------------------------------
68; .ResetBootDriveFromDL
69; Parameters:
70; DL: Drive to boot from (translated, 00h or 80h)
71; Returns:
72; AH: INT 13h error code
73; CF: Cleared if read successful
74; Set if any error
75; Corrupts registers:
76; AL
77;--------------------------------------------------------------------
78.ResetBootDriveFromDL:
79 xor ax, ax ; AH=0h, Disk Controller Reset
80 test dl, dl ; Floppy drive?
81 jns SHORT .SkipAltReset
82 mov ah, 0Dh ; AH=Dh, Reset Hard Disk (Alternate reset)
83.SkipAltReset:
84 int BIOS_DISK_INTERRUPT_13h
85 ret
86
87;--------------------------------------------------------------------
88; .LoadFirstSectorFromDLtoESBX
89; Parameters:
90; DL: Drive to boot from (translated, 00h or 80h)
91; ES:BX: Destination buffer for boot sector
92; Returns:
93; AH: INT 13h error code
94; ES:BX: Ptr to boot sector
95; CF: Cleared if read successful
96; Set if any error
97; Corrupts registers:
98; AL, CX, DH
99;--------------------------------------------------------------------
100.LoadFirstSectorFromDLtoESBX:
101 mov ax, 0201h ; Read 1 sector
102 mov cx, 1 ; Cylinder 0, Sector 1
103 xor dh, dh ; Head 0
104 int BIOS_DISK_INTERRUPT_13h
105 ret
Note: See TracBrowser for help on using the repository browser.