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

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

Changes to XTIDE Universal BIOS:

  • Boot menu finally works but timeout and drive numbers not yet implemented.
File size: 3.4 KB
RevLine 
[96]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 successfull)
14; CF: Set if boot sector loaded succesfully
15; Cleared if failed to load boot sector
16; Corrupts registers:
17; AX, CX, DH, DI, (DL if failed to read boot sector)
18;--------------------------------------------------------------------
19ALIGN JUMP_ALIGN
20BootSector_TryToLoadFromDriveDL:
21 call BootPrint_TryToBootFromDL
22 call LoadFirstSectorFromDriveDL
23 jc SHORT .FailedToLoadFirstSector
24
[128]25 test dl, dl
26 jns SHORT .AlwaysBootFromFloppyDriveForBooterGames
[96]27 cmp WORD [es:bx+510], 0AA55h ; Valid boot sector?
28 jne SHORT .FirstHardDiskSectorNotBootable
29.AlwaysBootFromFloppyDriveForBooterGames:
[130]30 mov ax, g_szFound
31 call BootPrint_BootSectorResultStringFromAX
[96]32 stc
33 ret
34.FailedToLoadFirstSector:
35 call BootPrint_FailedToLoadFirstSector
36 clc
37 ret
38.FirstHardDiskSectorNotBootable:
[130]39 mov ax, g_szNotFound
40 call BootPrint_BootSectorResultStringFromAX
[96]41 clc
42 ret
43
44;--------------------------------------------------------------------
45; LoadFirstSectorFromDriveDL
46; Parameters:
47; DL: Drive to boot from (translated, 00h or 80h)
48; Returns:
49; AH: INT 13h error code
50; ES:BX: Ptr to boot sector (if successfull)
51; CF: Cleared if read successfull
52; Set if any error
53; Corrupts registers:
54; AL, CX, DH, DI
55;--------------------------------------------------------------------
56ALIGN JUMP_ALIGN
57LoadFirstSectorFromDriveDL:
58 LOAD_BDA_SEGMENT_TO es, bx ; ES:BX now points to...
59 mov bx, BOOTVARS.rgbBootSect ; ...boot sector location
60 mov di, BOOT_READ_RETRY_TIMES ; Initialize retry counter
61ALIGN JUMP_ALIGN
62.ReadRetryLoop:
63 call .ResetBootDriveFromDL
64 call .LoadFirstSectorFromDLtoESBX
65 jnc SHORT .Return
66 dec di ; Decrement retry counter
67 jnz SHORT .ReadRetryLoop ; Loop while retries left
68.Return:
69 ret
70
71;--------------------------------------------------------------------
72; .ResetBootDriveFromDL
73; Parameters:
74; DL: Drive to boot from (translated, 00h or 80h)
75; Returns:
76; AH: INT 13h error code
77; CF: Cleared if read successfull
78; Set if any error
79; Corrupts registers:
80; AL
81;--------------------------------------------------------------------
82ALIGN JUMP_ALIGN
83.ResetBootDriveFromDL:
84 xor ax, ax ; AH=0h, Disk Controller Reset
[128]85 test dl, dl ; Floppy drive?
86 jns SHORT .SkipAltReset
87 mov ah, 0Dh ; AH=Dh, Reset Hard Disk (Alternate reset)
88.SkipAltReset:
[96]89 int INTV_DISK_FUNC
90 ret
91
92;--------------------------------------------------------------------
93; .LoadFirstSectorFromDLtoESBX
94; Parameters:
95; DL: Drive to boot from (translated, 00h or 80h)
96; ES:BX: Destination buffer for boot sector
97; Returns:
98; AH: INT 13h error code
99; ES:BX: Ptr to boot sector
100; CF: Cleared if read successfull
101; Set if any error
102; Corrupts registers:
103; AL, CX, DH
104;--------------------------------------------------------------------
105ALIGN JUMP_ALIGN
106.LoadFirstSectorFromDLtoESBX:
107 mov ax, 0201h ; Read 1 sector
108 mov cx, 1 ; Cylinder 0, Sector 1
109 xor dh, dh ; Head 0
110 int INTV_DISK_FUNC
111 ret
Note: See TracBrowser for help on using the repository browser.