Chameleon

Chameleon Commit Details

Date:2011-08-06 01:41:11 (12 years 8 months ago)
Author:Evan Lojewski
Commit:1288
Parents: 1287
Message:Add BiosDisk.cpp to i386 builds
Changes:
R/branches/xZenu/src/modules/Disk/BiosDisk.cpp → /branches/xZenu/src/modules/Disk/i386/BiosDisk.cpp
A/branches/xZenu/src/modules/Disk/i386
M/branches/xZenu/src/modules/Disk/Makefile

File differences

branches/xZenu/src/modules/Disk/BiosDisk.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
/*
* Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
* Reserved. This file contains Original Code and/or Modifications of
* Original Code as defined in and that are subject to the Apple Public
* Source License Version 2.0 (the "License"). You may not use this file
* except in compliance with the License. Please obtain a copy of the
* License at http://www.apple.com/publicsource and read it before using
* this file.
*
* The Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* Copyright 1993 NeXT Computer, Inc.
* All rights reserved.
*/
/* Copyright 2007 David Elliott
2007-12-30 dfe
- Enhanced code to normalize segment/offset to huge pointers so that any
linear address within the first MB of memory can be passed to BIOS
functions. This allows some of the __DATA sections to span into the
next segment and also allows stack variables to be used whereas the
old code could only operate on static data in the first 64k.
NOTE: Requires bios.s change to respect DS.
*/
/* Copyright 2007 VMware Inc.
2007-12-29 dfe
- Added ebiosEjectMedia
*/
/*
* Copyright (c) 2011 Evan Lojewski.
* - Converted to c++
* - Converted to UInt* style variable types
*/
#include <BiosDisk.hpp>
extern "C"
{
#include "libsaio.h"
#include "stdio.h"
}
BiosDisk::BiosDisk(const char* name)
{
// Initialize
mValid = false;
mDiskID = 0;
mUsesEBIOS = 0;
mNoEmulation = false;
mBytesPerSector = 0;
// The correct format should be:
// bios:/hdX/
mBusType = "bios";
if(strncmp(mBusType, name, 4) != 0) name = NULL;
mName = name;
sscanf(name, "bios:/hd%d/", &mDiskID);
mDiskID += 0x80; // 0x80 = fixed disk
mDriveInfo = (boot_drive_info_t*)malloc(sizeof(boot_drive_info_t));
if(BIOSRead(0, 0, 1, 1) == 0 && GetDriveInfo() == 0)
{
mBytesPerSector = mDriveInfo->params.phys_nbps;
printf("Disk: 0x%X (%d sectors)\n", mDiskID, mBytesPerSector);
}
else
{
mValid = 0; // force invalid.
}
}
BiosDisk::~BiosDisk()
{
if(mDriveInfo) free(mDriveInfo);
}
IOReturn BiosDisk::Read(UInt64 sector, UInt64 size, UInt8* buffer)
{
if(!isValid()) return kIOReturnNoDevice;
// Assume EBIOS capable for now...
if(EBIOSRead(sector, size) == kIOReturnSuccess)
{
bcopy((void*)BIOS_ADDR, buffer, size * mBytesPerSector);
return kIOReturnSuccess;
}
else return kIOReturnIOError;
}
IOReturn BiosDisk::Write(UInt64 sector, UInt64 size, UInt8* buffer)
{
if(!isValid()) return kIOReturnNoDevice;
bcopy(buffer, (void*)BIOS_ADDR, size * mBytesPerSector);
if(EBIOSWrite(sector, size) == 0)
{
return kIOReturnSuccess;
}
else return kIOReturnIOError;
}
UInt8 BiosDisk::BIOSRead(UInt16 cylinder, UInt8 head, UInt8 sector, UInt8 count)
{
sector++; // starts at 1
biosBuf_t bb;
int i;
bb.intno = 0x13;
bb.eax.r.h = 0x02;
for (i=0;;)
{
bb.ecx.r.h = cylinder;
bb.ecx.r.l = ((cylinder & 0x300) >> 2) | (sector & 0x3F);
bb.edx.r.h = head;
bb.edx.r.l = mDiskID;
bb.eax.r.l = count;
bb.ebx.rr = OFFSET(ptov(BIOS_ADDR));
bb.es = SEGMENT(ptov(BIOS_ADDR));
bios(&bb);
/* In case of a successful call, make sure we set AH (return code) to zero. */
if (bb.flags.cf == 0) bb.eax.r.h = 0;
/* Now we can really check for the return code (AH) value. */
if ((bb.eax.r.h == 0x00) || (i++ >= 5)) break;
/* reset disk subsystem and try again */
bb.eax.r.h = 0x00;
bios(&bb);
}
return bb.eax.r.h;
}
UInt8 BiosDisk::EBIOSRead(UInt64 sector, UInt8 count)
{
biosBuf_t bb;
UInt8 i;
struct {
UInt8 size;
UInt8 reserved;
UInt8 numblocks;
UInt8 reserved2;
UInt16 bufferOffset;
UInt16 bufferSegment;
UInt64 startblock;
} addrpacket __attribute__((aligned(16))) = {0};
addrpacket.size = sizeof(addrpacket);
for (i=0;;) {
bb.intno = 0x13;
bb.eax.r.h = 0x42;
bb.edx.r.l = mDiskID;
bb.esi.rr = NORMALIZED_OFFSET((unsigned)&addrpacket);
bb.ds = NORMALIZED_SEGMENT((unsigned)&addrpacket);
addrpacket.reserved = addrpacket.reserved2 = 0;
addrpacket.numblocks = count;
addrpacket.bufferOffset = OFFSET(ptov(BIOS_ADDR));
addrpacket.bufferSegment = SEGMENT(ptov(BIOS_ADDR));
addrpacket.startblock = sector;
bios(&bb);
/* In case of a successful call, make sure we set AH (return code) to zero. */
if (bb.flags.cf == 0)
bb.eax.r.h = 0;
/* Now we can really check for the return code (AH) value. */
if ((bb.eax.r.h == 0x00) || (i++ >= 5))
break;
/* reset disk subsystem and try again */
bb.eax.r.h = 0x00;
bios(&bb);
}
return bb.eax.r.h;
}
UInt8 BiosDisk::EBIOSWrite(UInt64 sector, UInt8 count)
{
biosBuf_t bb;
UInt8 i;
static struct {
UInt8 size;
UInt8 reserved;
UInt8 numblocks;
UInt8 reserved2;
UInt16 bufferOffset;
UInt16 bufferSegment;
UInt64 startblock;
} addrpacket __attribute__((aligned(16))) = {0};
addrpacket.size = sizeof(addrpacket);
for (i=0;;) {
bb.intno = 0x13;
bb.eax.r.l = 0; /* Don't verify */
bb.eax.r.h = 0x43;
bb.edx.r.l = mDiskID;
bb.esi.rr = NORMALIZED_OFFSET((unsigned)&addrpacket);
bb.ds = NORMALIZED_SEGMENT((unsigned)&addrpacket);
addrpacket.reserved = addrpacket.reserved2 = 0;
addrpacket.numblocks = count;
addrpacket.bufferOffset = OFFSET(ptov(BIOS_ADDR));
addrpacket.bufferSegment = SEGMENT(ptov(BIOS_ADDR));
addrpacket.startblock = sector;
bios(&bb);
/* In case of a successful call, make sure we set AH (return code) to zero. */
if (bb.flags.cf == 0)
bb.eax.r.h = 0;
/* Now we can really check for the return code (AH) value. */
if ((bb.eax.r.h == 0x00) || (i++ >= 5))
break;
/* reset disk subsystem and try again */
bb.eax.r.h = 0x00;
bios(&bb);
}
return bb.eax.r.h;
}
UInt8 BiosDisk::GetDriveInfo()
{
// we use the BIOS_ADDR (disk buffer) to ensure that the buffer
// is in low mem
boot_drive_info_t* actualInfo = mDriveInfo;
mDriveInfo = (boot_drive_info_t*)BIOS_ADDR;
biosBuf_t bb;
int ret = 0;
#if UNUSED
if (maxhd == 0) {
bb.intno = 0x13;
bb.eax.r.h = 0x08;
bb.edx.r.l = 0x80;
bios(&bb);
if (bb.flags.cf == 0)
maxhd = 0x7f + bb.edx.r.l;
};
#endif
/* Check for El Torito no-emulation mode. */
//dp->no_emulation = is_no_emulation(drive);
/* Check drive for EBIOS support. */
bb.intno = 0x13;
bb.eax.r.h = 0x41;
bb.edx.r.l = mDiskID;
bb.ebx.rr = 0x55aa;
bios(&bb);
if ((bb.ebx.rr == 0xaa55) && (bb.flags.cf == 0)) {
/* Get flags for supported operations. */
mUsesEBIOS = bb.ecx.r.l;
}
if (mUsesEBIOS & (EBIOS_ENHANCED_DRIVE_INFO | EBIOS_LOCKING_ACCESS | EBIOS_FIXED_DISK_ACCESS)) {
/* Get EBIOS drive info. */
mDriveInfo->params.buf_size = sizeof(mDriveInfo->params);
bb.intno = 0x13;
bb.eax.r.h = 0x48;
bb.edx.r.l = mDiskID;
bb.esi.rr = NORMALIZED_OFFSET((unsigned)&mDriveInfo->params);
bb.ds = NORMALIZED_SEGMENT((unsigned)&mDriveInfo->params);
bios(&bb);
if (bb.flags.cf != 0 /* || params.phys_sectors < 2097152 */) {
mUsesEBIOS = 0;
mDriveInfo->params.buf_size = 1;
}
else
{
if (mDiskID >= BASE_HD_DRIVE &&
(mUsesEBIOS & EBIOS_ENHANCED_DRIVE_INFO) &&
mDriveInfo->params.buf_size >= 30 &&
!(mDriveInfo->params.dpte_offset == 0xFFFF && mDriveInfo->params.dpte_segment == 0xFFFF)) {
void *ptr = (void *)(mDriveInfo->params.dpte_offset + ((unsigned int)mDriveInfo->params.dpte_segment << 4));
bcopy(ptr, &mDriveInfo->dpte, sizeof(mDriveInfo->dpte));
}
}
}
/*
* zef: This code will fail on recent JMicron and Intel option ROMs
*/
//if (mDriveInfo->params.phys_heads == 0 || mDriveInfo->params.phys_spt == 0) {
///* Either it's not EBIOS, or EBIOS didn't tell us. */
//bb.intno = 0x13;
//bb.eax.r.h = 0x08;
//bb.edx.r.l = drive;
//bios(&bb);
//if (bb.flags.cf == 0 && bb.eax.r.h == 0) {
//unsigned long cyl;
//unsigned long sec;
//unsigned long hds;
//
//hds = bb.edx.r.h;
//sec = bb.ecx.r.l & 0x3F;
//if ((dp->uses_ebios & EBIOS_ENHANCED_DRIVE_INFO) && (sec != 0)) {
//cyl = (mDriveInfo->params.phys_sectors / ((hds + 1) * sec)) - 1;
//} else {
//cyl = bb.ecx.r.h | ((bb.ecx.r.l & 0xC0) << 2);
//}
//mDriveInfo->params.phys_heads = hds;
//mDriveInfo->params.phys_spt = sec;
//mDriveInfo->params.phys_cyls = cyl;
//} else {
//ret = -1;
//}
//}
/*
if (dp->no_emulation) {
// Some BIOSes give us erroneous EBIOS support information.
// Assume that if you're on a CD, then you can use
// EBIOS disk calls.
//
dp->uses_ebios |= EBIOS_FIXED_DISK_ACCESS;
}*/
if (ret == 0) {
mValid = 1;
}
bcopy(mDriveInfo, actualInfo, sizeof(boot_drive_info_t));
mDriveInfo = actualInfo;
return ret;
}
branches/xZenu/src/modules/Disk/i386/BiosDisk.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
/*
* Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
* Reserved. This file contains Original Code and/or Modifications of
* Original Code as defined in and that are subject to the Apple Public
* Source License Version 2.0 (the "License"). You may not use this file
* except in compliance with the License. Please obtain a copy of the
* License at http://www.apple.com/publicsource and read it before using
* this file.
*
* The Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* Copyright 1993 NeXT Computer, Inc.
* All rights reserved.
*/
/* Copyright 2007 David Elliott
2007-12-30 dfe
- Enhanced code to normalize segment/offset to huge pointers so that any
linear address within the first MB of memory can be passed to BIOS
functions. This allows some of the __DATA sections to span into the
next segment and also allows stack variables to be used whereas the
old code could only operate on static data in the first 64k.
NOTE: Requires bios.s change to respect DS.
*/
/* Copyright 2007 VMware Inc.
2007-12-29 dfe
- Added ebiosEjectMedia
*/
/*
* Copyright (c) 2011 Evan Lojewski.
* - Converted to c++
* - Converted to UInt* style variable types
*/
#include <BiosDisk.hpp>
extern "C"
{
#include "libsaio.h"
#include "stdio.h"
}
BiosDisk::BiosDisk(const char* name)
{
// Initialize
mValid = false;
mDiskID = 0;
mUsesEBIOS = 0;
mNoEmulation = false;
mBytesPerSector = 0;
// The correct format should be:
// bios:/hdX/
mBusType = "bios";
if(strncmp(mBusType, name, 4) != 0) name = NULL;
mName = name;
sscanf(name, "bios:/hd%d/", &mDiskID);
mDiskID += 0x80; // 0x80 = fixed disk
mDriveInfo = (boot_drive_info_t*)malloc(sizeof(boot_drive_info_t));
if(BIOSRead(0, 0, 1, 1) == 0 && GetDriveInfo() == 0)
{
mBytesPerSector = mDriveInfo->params.phys_nbps;
printf("Disk: 0x%X (%d sectors)\n", mDiskID, mBytesPerSector);
}
else
{
mValid = 0; // force invalid.
}
}
BiosDisk::~BiosDisk()
{
if(mDriveInfo) free(mDriveInfo);
}
IOReturn BiosDisk::Read(UInt64 sector, UInt64 size, UInt8* buffer)
{
if(!isValid()) return kIOReturnNoDevice;
// Assume EBIOS capable for now...
if(EBIOSRead(sector, size) == kIOReturnSuccess)
{
bcopy((void*)BIOS_ADDR, buffer, size * mBytesPerSector);
return kIOReturnSuccess;
}
else return kIOReturnIOError;
}
IOReturn BiosDisk::Write(UInt64 sector, UInt64 size, UInt8* buffer)
{
if(!isValid()) return kIOReturnNoDevice;
bcopy(buffer, (void*)BIOS_ADDR, size * mBytesPerSector);
if(EBIOSWrite(sector, size) == 0)
{
return kIOReturnSuccess;
}
else return kIOReturnIOError;
}
UInt8 BiosDisk::BIOSRead(UInt16 cylinder, UInt8 head, UInt8 sector, UInt8 count)
{
sector++; // starts at 1
biosBuf_t bb;
int i;
bb.intno = 0x13;
bb.eax.r.h = 0x02;
for (i=0;;)
{
bb.ecx.r.h = cylinder;
bb.ecx.r.l = ((cylinder & 0x300) >> 2) | (sector & 0x3F);
bb.edx.r.h = head;
bb.edx.r.l = mDiskID;
bb.eax.r.l = count;
bb.ebx.rr = OFFSET(ptov(BIOS_ADDR));
bb.es = SEGMENT(ptov(BIOS_ADDR));
bios(&bb);
/* In case of a successful call, make sure we set AH (return code) to zero. */
if (bb.flags.cf == 0) bb.eax.r.h = 0;
/* Now we can really check for the return code (AH) value. */
if ((bb.eax.r.h == 0x00) || (i++ >= 5)) break;
/* reset disk subsystem and try again */
bb.eax.r.h = 0x00;
bios(&bb);
}
return bb.eax.r.h;
}
UInt8 BiosDisk::EBIOSRead(UInt64 sector, UInt8 count)
{
biosBuf_t bb;
UInt8 i;
struct {
UInt8 size;
UInt8 reserved;
UInt8 numblocks;
UInt8 reserved2;
UInt16 bufferOffset;
UInt16 bufferSegment;
UInt64 startblock;
} addrpacket __attribute__((aligned(16))) = {0};
addrpacket.size = sizeof(addrpacket);
for (i=0;;) {
bb.intno = 0x13;
bb.eax.r.h = 0x42;
bb.edx.r.l = mDiskID;
bb.esi.rr = NORMALIZED_OFFSET((unsigned)&addrpacket);
bb.ds = NORMALIZED_SEGMENT((unsigned)&addrpacket);
addrpacket.reserved = addrpacket.reserved2 = 0;
addrpacket.numblocks = count;
addrpacket.bufferOffset = OFFSET(ptov(BIOS_ADDR));
addrpacket.bufferSegment = SEGMENT(ptov(BIOS_ADDR));
addrpacket.startblock = sector;
bios(&bb);
/* In case of a successful call, make sure we set AH (return code) to zero. */
if (bb.flags.cf == 0)
bb.eax.r.h = 0;
/* Now we can really check for the return code (AH) value. */
if ((bb.eax.r.h == 0x00) || (i++ >= 5))
break;
/* reset disk subsystem and try again */
bb.eax.r.h = 0x00;
bios(&bb);
}
return bb.eax.r.h;
}
UInt8 BiosDisk::EBIOSWrite(UInt64 sector, UInt8 count)
{
biosBuf_t bb;
UInt8 i;
static struct {
UInt8 size;
UInt8 reserved;
UInt8 numblocks;
UInt8 reserved2;
UInt16 bufferOffset;
UInt16 bufferSegment;
UInt64 startblock;
} addrpacket __attribute__((aligned(16))) = {0};
addrpacket.size = sizeof(addrpacket);
for (i=0;;) {
bb.intno = 0x13;
bb.eax.r.l = 0; /* Don't verify */
bb.eax.r.h = 0x43;
bb.edx.r.l = mDiskID;
bb.esi.rr = NORMALIZED_OFFSET((unsigned)&addrpacket);
bb.ds = NORMALIZED_SEGMENT((unsigned)&addrpacket);
addrpacket.reserved = addrpacket.reserved2 = 0;
addrpacket.numblocks = count;
addrpacket.bufferOffset = OFFSET(ptov(BIOS_ADDR));
addrpacket.bufferSegment = SEGMENT(ptov(BIOS_ADDR));
addrpacket.startblock = sector;
bios(&bb);
/* In case of a successful call, make sure we set AH (return code) to zero. */
if (bb.flags.cf == 0)
bb.eax.r.h = 0;
/* Now we can really check for the return code (AH) value. */
if ((bb.eax.r.h == 0x00) || (i++ >= 5))
break;
/* reset disk subsystem and try again */
bb.eax.r.h = 0x00;
bios(&bb);
}
return bb.eax.r.h;
}
UInt8 BiosDisk::GetDriveInfo()
{
// we use the BIOS_ADDR (disk buffer) to ensure that the buffer
// is in low mem
boot_drive_info_t* actualInfo = mDriveInfo;
mDriveInfo = (boot_drive_info_t*)BIOS_ADDR;
biosBuf_t bb;
int ret = 0;
#if UNUSED
if (maxhd == 0) {
bb.intno = 0x13;
bb.eax.r.h = 0x08;
bb.edx.r.l = 0x80;
bios(&bb);
if (bb.flags.cf == 0)
maxhd = 0x7f + bb.edx.r.l;
};
#endif
/* Check for El Torito no-emulation mode. */
//dp->no_emulation = is_no_emulation(drive);
/* Check drive for EBIOS support. */
bb.intno = 0x13;
bb.eax.r.h = 0x41;
bb.edx.r.l = mDiskID;
bb.ebx.rr = 0x55aa;
bios(&bb);
if ((bb.ebx.rr == 0xaa55) && (bb.flags.cf == 0)) {
/* Get flags for supported operations. */
mUsesEBIOS = bb.ecx.r.l;
}
if (mUsesEBIOS & (EBIOS_ENHANCED_DRIVE_INFO | EBIOS_LOCKING_ACCESS | EBIOS_FIXED_DISK_ACCESS)) {
/* Get EBIOS drive info. */
mDriveInfo->params.buf_size = sizeof(mDriveInfo->params);
bb.intno = 0x13;
bb.eax.r.h = 0x48;
bb.edx.r.l = mDiskID;
bb.esi.rr = NORMALIZED_OFFSET((unsigned)&mDriveInfo->params);
bb.ds = NORMALIZED_SEGMENT((unsigned)&mDriveInfo->params);
bios(&bb);
if (bb.flags.cf != 0 /* || params.phys_sectors < 2097152 */) {
mUsesEBIOS = 0;
mDriveInfo->params.buf_size = 1;
}
else
{
if (mDiskID >= BASE_HD_DRIVE &&
(mUsesEBIOS & EBIOS_ENHANCED_DRIVE_INFO) &&
mDriveInfo->params.buf_size >= 30 &&
!(mDriveInfo->params.dpte_offset == 0xFFFF && mDriveInfo->params.dpte_segment == 0xFFFF)) {
void *ptr = (void *)(mDriveInfo->params.dpte_offset + ((unsigned int)mDriveInfo->params.dpte_segment << 4));
bcopy(ptr, &mDriveInfo->dpte, sizeof(mDriveInfo->dpte));
}
}
}
/*
* zef: This code will fail on recent JMicron and Intel option ROMs
*/
//if (mDriveInfo->params.phys_heads == 0 || mDriveInfo->params.phys_spt == 0) {
///* Either it's not EBIOS, or EBIOS didn't tell us. */
//bb.intno = 0x13;
//bb.eax.r.h = 0x08;
//bb.edx.r.l = drive;
//bios(&bb);
//if (bb.flags.cf == 0 && bb.eax.r.h == 0) {
//unsigned long cyl;
//unsigned long sec;
//unsigned long hds;
//
//hds = bb.edx.r.h;
//sec = bb.ecx.r.l & 0x3F;
//if ((dp->uses_ebios & EBIOS_ENHANCED_DRIVE_INFO) && (sec != 0)) {
//cyl = (mDriveInfo->params.phys_sectors / ((hds + 1) * sec)) - 1;
//} else {
//cyl = bb.ecx.r.h | ((bb.ecx.r.l & 0xC0) << 2);
//}
//mDriveInfo->params.phys_heads = hds;
//mDriveInfo->params.phys_spt = sec;
//mDriveInfo->params.phys_cyls = cyl;
//} else {
//ret = -1;
//}
//}
/*
if (dp->no_emulation) {
// Some BIOSes give us erroneous EBIOS support information.
// Assume that if you're on a CD, then you can use
// EBIOS disk calls.
//
dp->uses_ebios |= EBIOS_FIXED_DISK_ACCESS;
}*/
if (ret == 0) {
mValid = 1;
}
bcopy(mDriveInfo, actualInfo, sizeof(boot_drive_info_t));
mDriveInfo = actualInfo;
return ret;
}
branches/xZenu/src/modules/Disk/Makefile
88
99
1010
11
1211
12
1313
1414
DIR = Disk
#i386 only -> BiosDisk
MODULE_OBJS = Disk Partition FDiskPartition GUIDPartition Main
I386_OBJS = BiosDisk
include ../MakeInc.dir

Archive Download the corresponding diff file

Revision: 1288