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

Last change on this file since 415 was 376, checked in by gregli@…, 13 years ago

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

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