source: xtideuniversalbios/trunk/BIOS_Drive_Information_Tool/Src/Bios.asm@ 346

Last change on this file since 346 was 327, checked in by aitotat@…, 13 years ago

BIOS Drive Information Tool v1.0.0

File size: 5.5 KB
Line 
1; Project name : BIOS Drive Information Tool
2; Description : Functions to read information from BIOS.
3
4
5; Section containing code
6SECTION .text
7
8;---------------------------------------------------------------------
9; Bios_GetNumberOfHardDrivesToDX
10; Parameters:
11; Nothing
12; Returns: (if no errors)
13; DX: Number of hard drives in system
14; CF: Set if no hard drives found
15; Corrupts registers:
16; AX, BX, CX
17;--------------------------------------------------------------------
18ALIGN JUMP_ALIGN
19Bios_GetNumberOfHardDrivesToDX:
20 mov dl, 80h ; First hard drive
21 mov ah, GET_DRIVE_PARAMETERS
22 int BIOS_DISK_INTERRUPT_13h
23 mov dh, 0 ; Preserve CF
24 ret
25
26
27;---------------------------------------------------------------------
28; Bios_ReadOldInt13hParametersFromDriveDL
29; Parameters:
30; DL: BIOS drive number
31; Returns: (if no errors)
32; BL: Drive Type (for floppies only)
33; AX: Sectors per track (1...63)
34; DX: Number of heads (1...255)
35; CX: Number of cylinders (1...1024)
36; CF: Cleared = no errors
37; Set = BIOS error code stored in AH
38; Corrupts registers:
39; Nothing
40;--------------------------------------------------------------------
41ALIGN JUMP_ALIGN
42Bios_ReadOldInt13hParametersFromDriveDL:
43 mov ah, GET_DRIVE_PARAMETERS
44 int BIOS_DISK_INTERRUPT_13h
45 jc SHORT ReturnWithBiosErrorCodeInAH
46 ; Fall to ExtractCHSfromOldInt13hDriveParameters
47
48;---------------------------------------------------------------------
49; ExtractCHSfromOldInt13hDriveParameters
50; Parameters:
51; CH: Maximum cylinder number, bits 7...0
52; CL: Bits 7...6: Maximum cylinder number, bits 9 and 8
53; Bits 5...0: Maximum sector number (1...63)
54; DH: Maximum head number (0...254)
55; Returns:
56; BL: Drive Type (for floppies only)
57; AX: Sectors per track (1...63)
58; DX: Number of heads (1...255)
59; CX: Number of cylinders (1...1024)
60; CF: Cleared
61; Corrupts registers:
62; Nothing
63;--------------------------------------------------------------------
64ExtractCHSfromOldInt13hDriveParameters:
65 mov al, cl ; Copy sector number...
66 and ax, BYTE 3Fh ; ...and limit to 1...63
67 sub cl, al ; Remove from max cylinder high
68 eROL_IM cl, 2 ; High bits to beginning
69 eMOVZX dx, dh ; Copy Max head to DX
70 xchg cl, ch ; Max cylinder now in CX
71 inc cx ; Max cylinder to number of cylinders
72 inc dx ; Max head to number of heads
73 clc ; No errors
74 ret
75
76
77;---------------------------------------------------------------------
78; Bios_ReadOldInt13hCapacityFromDriveDL
79; Parameters:
80; DL: BIOS drive number
81; Returns: (if no errors)
82; CX:DX: Total number of sectors
83; AH: BIOS Error code
84; CF: Cleared = no errors
85; Set = BIOS error code stored in AH
86; Corrupts registers:
87; Nothing
88;--------------------------------------------------------------------
89ALIGN JUMP_ALIGN
90Bios_ReadOldInt13hCapacityFromDriveDL:
91 mov ah, GET_DISK_TYPE
92 int BIOS_DISK_INTERRUPT_13h
93 jc SHORT ReturnInvalidErrorCodeInAH
94 xor ah, ah
95 ret
96
97
98;---------------------------------------------------------------------
99; Bios_ReadAtaInfoFromDriveDLtoBX
100; Parameters:
101; DL: BIOS drive number
102; Returns: (if no errors)
103; DS:BX: Ptr to ATA information
104; AH: BIOS Error code
105; CF: Cleared = no errors
106; Set = BIOS error code stored in AH
107; Corrupts registers:
108; ES
109;--------------------------------------------------------------------
110ALIGN JUMP_ALIGN
111Bios_ReadAtaInfoFromDriveDLtoBX:
112 mov bx, g_rgbAtaInfo
113 push ds
114 pop es
115 mov ah, GET_DRIVE_INFORMATION
116 int BIOS_DISK_INTERRUPT_13h
117 ret
118
119
120;---------------------------------------------------------------------
121; Bios_ReadEbiosVersionFromDriveDL
122; Parameters:
123; DL: BIOS drive number
124; Returns:
125; AH: BIOS error code
126; BX: Version of extensions
127; CX: Interface support bit map
128; CF: Cleared = no errors
129; Set = BIOS error code stored in AH
130; Corrupts registers:
131; Nothing
132;--------------------------------------------------------------------
133ALIGN JUMP_ALIGN
134Bios_ReadEbiosVersionFromDriveDL:
135 mov ah, CHECK_EXTENSIONS_PRESENT
136 mov bx, 55AAh
137 int BIOS_DISK_INTERRUPT_13h
138 jc SHORT .NoEbiosPresent
139 cmp bx, 0AA55h
140 jne SHORT .NoEbiosPresent
141 eMOVZX bx, ah ; Copy version to BX
142 xor ah, ah
143 ret
144.NoEbiosPresent:
145 mov ah, RET_HD_INVALID
146 stc
147 ret
148
149
150;---------------------------------------------------------------------
151; Bios_ReadEbiosInfoFromDriveDLtoDSSI
152; Parameters:
153; DL: BIOS drive number
154; Returns: (if no errors)
155; DS:SI: Ptr to EDRIVE_INFO
156; AH: BIOS Error code
157; CF: Cleared = no errors
158; Set = BIOS error code stored in AH
159; Corrupts registers:
160; Nothing
161;--------------------------------------------------------------------
162ALIGN JUMP_ALIGN
163Bios_ReadEbiosInfoFromDriveDLtoDSSI:
164 mov si, g_edriveInfo
165 mov WORD [si+EDRIVE_INFO.wSize], MINIMUM_EDRIVEINFO_SIZE
166 mov ah, GET_EXTENDED_DRIVE_INFORMATION
167 int BIOS_DISK_INTERRUPT_13h
168 ret
169
170
171;---------------------------------------------------------------------
172; ReturnInvalidErrorCodeInAH
173; ReturnWithBiosErrorCodeInAH
174; Parameters:
175; Nothing
176; Returns: (if no errors)
177; AH: BIOS Error code
178; CF: Set
179; Corrupts registers:
180; Nothing
181;--------------------------------------------------------------------
182ReturnInvalidErrorCodeInAH:
183 stc
184 mov ah, RET_HD_INVALID
185ReturnWithBiosErrorCodeInAH:
186 ret
187
188
189; Section containing uninitialized data
190SECTION .bss
191
192g_edriveInfo:
193g_rgbAtaInfo: resb 512
Note: See TracBrowser for help on using the repository browser.