46c3116cc585b0baa8d56173bd907df8d3f03d7d
3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 /////////////////////////////////////////////////////////////////////////////////////////////
31 /////////////////////////////////////////////////////////////////////////////////////////////
35 BOOL
DiskResetController(U32 DriveNumber
)
40 DbgPrint((DPRINT_DISK
, "DiskResetController(0x%x) DISK OPERATION FAILED -- RESETTING CONTROLLER\n", DriveNumber
));
42 // BIOS Int 13h, function 0 - Reset disk system
44 // DL = drive (if bit 7 is set both hard disks and floppy disks reset)
47 // CF clear if successful
50 RegsIn
.b
.dl
= DriveNumber
;
52 // Reset the disk controller
53 Int386(0x13, &RegsIn
, &RegsOut
);
55 return INT386_SUCCESS(RegsOut
);
58 BOOL
DiskInt13ExtensionsSupported(U32 DriveNumber
)
63 DbgPrint((DPRINT_DISK
, "DiskInt13ExtensionsSupported()\n"));
65 // IBM/MS INT 13 Extensions - INSTALLATION CHECK
68 // DL = drive (80h-FFh)
70 // CF set on error (extensions not supported)
71 // AH = 01h (invalid function)
72 // CF clear if successful
73 // BX = AA55h if installed
74 // AH = major version of extensions
76 // 20h = 2.0 / EDD-1.0
77 // 21h = 2.1 / EDD-1.1
80 // CX = API subset support bitmap
81 // DH = extension version (v2.0+ ??? -- not present in 1.x)
83 // Bitfields for IBM/MS INT 13 Extensions API support bitmap
84 // Bit 0, extended disk access functions (AH=42h-44h,47h,48h) supported
85 // Bit 1, removable drive controller functions (AH=45h,46h,48h,49h,INT 15/AH=52h) supported
86 // Bit 2, enhanced disk drive (EDD) functions (AH=48h,AH=4Eh) supported
87 // extended drive parameter table is valid
91 RegsIn
.b
.dl
= DriveNumber
;
93 // Reset the disk controller
94 Int386(0x13, &RegsIn
, &RegsOut
);
96 if (!INT386_SUCCESS(RegsOut
))
98 // CF set on error (extensions not supported)
102 if (RegsOut
.w
.bx
!= 0xAA55)
104 // BX = AA55h if installed
109 // The original check is too strict because some BIOSes report that
110 // extended disk access functions are not suported when booting
111 // from a CD (e.g. Phoenix BIOS v6.00PG). Argh!
113 if (!(RegsOut
.w
.cx
& 0x0001))
115 // CX = API subset support bitmap
116 // Bit 0, extended disk access functions (AH=42h-44h,47h,48h) supported
121 // Use this relaxed check instead
122 if (RegsOut
.w
.cx
== 0x0000)
124 // CX = API subset support bitmap
131 VOID
DiskStopFloppyMotor(VOID
)
133 WRITE_PORT_UCHAR((PUCHAR
)0x3F2, 0);
136 BOOL
DiskGetExtendedDriveParameters(U32 DriveNumber
, PVOID Buffer
, U16 BufferSize
)
140 PU16 Ptr
= (PU16
)(BIOSCALLBUFFER
);
142 DbgPrint((DPRINT_DISK
, "DiskGetExtendedDriveParameters()\n"));
144 // Initialize transfer buffer
147 // BIOS Int 13h, function 48h - Get drive parameters
149 // DL = drive (bit 7 set for hard disk)
150 // DS:SI = result buffer
154 // CF clear if successful
156 // DS:SI -> result buffer
158 RegsIn
.b
.dl
= DriveNumber
;
159 RegsIn
.x
.ds
= BIOSCALLBUFSEGMENT
; // DS:SI -> result buffer
160 RegsIn
.w
.si
= BIOSCALLBUFOFFSET
;
162 // Get drive parameters
163 Int386(0x13, &RegsIn
, &RegsOut
);
165 if (!INT386_SUCCESS(RegsOut
))
170 memcpy(Buffer
, Ptr
, BufferSize
);
175 #endif // defined __i386__