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

Last change on this file since 90 was 90, checked in by Tomi Tilli, 14 years ago

Changes to XTIDE Universal BIOS:

  • Removed INT 13h format and diagnostics functions.
  • Removed INT 18h callback handler.
  • Removed configuration for early/late initialization. Now XT builds always use late and AT build early initialization.
  • Reduced number of supported IDE controllers from 5 to 4.
  • Removed reserved configuration bytes.
  • Removed simple and system boot loaders.
File size: 5.0 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Int 19h BIOS functions (Boot Strap Loader).
3
4; Section containing code
5SECTION .text
6
7B_READ_RETRY_TIMES EQU 3 ; Number of times to retry
8
9
10;--------------------------------------------------------------------
11; Boots if boot sector is successfully read from the drive.
12;
13; Int19h_TryToLoadBootSectorFromDL
14; Parameters:
15; DL: Drive to boot from (translated, 00h or 80h)
16; DS: RAMVARS segment
17; Returns:
18; ES:BX: Ptr to boot sector (if successfull)
19; CF: Set if boot sector loaded succesfully
20; Cleared if failed to load boot sector
21; Corrupts registers:
22; AX, CX, DH, DI, (DL if failed to read boot sector)
23;--------------------------------------------------------------------
24ALIGN JUMP_ALIGN
25Int19h_TryToLoadBootSectorFromDL:
26 call BootPrint_TryToBootFromDL
27 call Int19h_LoadFirstSectorFromDL
28 jc SHORT .FailedToLoadFirstSector
29
30 test dl, 80h
31 jz SHORT .AlwaysBootFromFloppyDriveForBooterGames
32 cmp WORD [es:bx+510], 0AA55h ; Valid boot sector?
33 jne SHORT .FirstHardDiskSectorNotBootable
34.AlwaysBootFromFloppyDriveForBooterGames:
35 call BootPrint_BootSectorLoaded
36 stc
37 ret
38.FailedToLoadFirstSector:
39 call BootPrint_FailedToLoadFirstSector
40 clc
41 ret
42.FirstHardDiskSectorNotBootable:
43 call BootPrint_FirstSectorNotBootable
44 clc
45 ret
46
47;--------------------------------------------------------------------
48; Reads first sector (boot sector) from drive DL.
49;
50; Int19h_LoadFirstSectorFromDL
51; Parameters:
52; DL: Drive to boot from (translated, 00h or 80h)
53; Returns:
54; AH: INT 13h error code
55; ES:BX: Ptr to boot sector (if successfull)
56; CF: Cleared if read successfull
57; Set if any error
58; Corrupts registers:
59; AL, CX, DH, DI
60;--------------------------------------------------------------------
61ALIGN JUMP_ALIGN
62Int19h_LoadFirstSectorFromDL:
63 LOAD_BDA_SEGMENT_TO es, bx ; ES:BX now points to...
64 mov bx, BOOTVARS.rgbBootSect ; ...boot sector location
65 mov di, B_READ_RETRY_TIMES ; Retry counter
66ALIGN JUMP_ALIGN
67.ReadRetryLoop:
68 call .ResetBootDriveFromDL
69 call .LoadFirstSectorFromDLtoESBX
70 jnc SHORT .Return
71 dec di ; Decrement retry counter
72 jnz SHORT .ReadRetryLoop ; Loop while retries left
73ALIGN JUMP_ALIGN
74.Return:
75 ret
76
77;--------------------------------------------------------------------
78; .ResetBootDriveFromDL
79; Parameters:
80; DL: Drive to boot from (translated, 00h or 80h)
81; Returns:
82; AH: INT 13h error code
83; CF: Cleared if read successfull
84; Set if any error
85; Corrupts registers:
86; AL
87;--------------------------------------------------------------------
88ALIGN JUMP_ALIGN
89.ResetBootDriveFromDL:
90 xor ax, ax ; AH=0h, Disk Controller Reset
91 test dl, 80h ; Floppy drive?
92 jz SHORT .ResetDriveFromDL ; If so, jump to reset
93 mov ah, 0Dh ; AH=Dh, Reset Hard Disk (Alternate reset)
94.ResetDriveFromDL:
95 int INTV_DISK_FUNC
96 ret
97
98;--------------------------------------------------------------------
99; Reads first sector (boot sector) from drive DL to ES:BX.
100;
101; .LoadFirstSectorFromDLtoESBX
102; Parameters:
103; DL: Drive to boot from (translated, 00h or 80h)
104; ES:BX: Destination buffer for boot sector
105; Returns:
106; AH: INT 13h error code
107; ES:BX: Ptr to boot sector
108; CF: Cleared if read successfull
109; Set if any error
110; Corrupts registers:
111; AL, CX, DH
112;--------------------------------------------------------------------
113ALIGN JUMP_ALIGN
114.LoadFirstSectorFromDLtoESBX:
115 mov ax, 0201h ; Read 1 sector
116 mov cx, 1 ; Cylinder 0, Sector 1
117 xor dh, dh ; Head 0
118 int INTV_DISK_FUNC
119 ret
120
121
122;--------------------------------------------------------------------
123; Jumps to boot sector pointed by ES:BX.
124;
125; Int19h_JumpToBootSector
126; Parameters:
127; DL: Drive to boot from (translated, 00h or 80h)
128; ES:BX: Ptr to boot sector
129; Returns:
130; Never returns
131;--------------------------------------------------------------------
132ALIGN JUMP_ALIGN
133Int19h_JumpToBootSector:
134 push es ; Push boot sector segment
135 push bx ; Push boot sector offset
136 call Int19h_ClearSegmentsForBoot
137 xor dh, dh ; Device supported by INT 13h
138 retf
139
140;--------------------------------------------------------------------
141; Clears DS and ES registers to zero.
142;
143; Int19h_ClearSegmentsForBoot
144; Parameters:
145; Nothing
146; Returns:
147; DS=ES: Zero
148; Corrupts registers:
149; AX
150;--------------------------------------------------------------------
151ALIGN JUMP_ALIGN
152Int19h_ClearSegmentsForBoot:
153 xor ax, ax
154 mov ds, ax
155 mov es, ax
156 ret
157
158
159;--------------------------------------------------------------------
160; Calls INT 18h (ROM Basic or Boot Failure). Called after booting from
161; floppy drive or hard disk fails.
162;
163; Int19h_BootFailure
164; Parameters:
165; Nothing
166; Returns:
167; Should never return (but might)
168;--------------------------------------------------------------------
169ALIGN JUMP_ALIGN
170Int19h_BootFailure:
171 call Int19h_ClearSegmentsForBoot
172 int INTV_BOOT_FAILURE
173 ret
Note: See TracBrowser for help on using the repository browser.