VirtualBox

source: vbox/trunk/src/VBox/Devices/PC/BIOS/ata.c@ 71423

Last change on this file since 71423 was 71423, checked in by vboxsync, 7 years ago

BIOS: Reduce harmless warnings for unsupported INT 15h functions.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 39.9 KB
Line 
1/* $Id: ata.c 71423 2018-03-21 11:24:32Z vboxsync $ */
2/** @file
3 * PC BIOS - ???
4 */
5
6/*
7 * Copyright (C) 2006-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 * --------------------------------------------------------------------
17 *
18 * This code is based on:
19 *
20 * ROM BIOS for use with Bochs/Plex86/QEMU emulation environment
21 *
22 * Copyright (C) 2002 MandrakeSoft S.A.
23 *
24 * MandrakeSoft S.A.
25 * 43, rue d'Aboukir
26 * 75002 Paris - France
27 * http://www.linux-mandrake.com/
28 * http://www.mandrakesoft.com/
29 *
30 * This library is free software; you can redistribute it and/or
31 * modify it under the terms of the GNU Lesser General Public
32 * License as published by the Free Software Foundation; either
33 * version 2 of the License, or (at your option) any later version.
34 *
35 * This library is distributed in the hope that it will be useful,
36 * but WITHOUT ANY WARRANTY; without even the implied warranty of
37 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
38 * Lesser General Public License for more details.
39 *
40 * You should have received a copy of the GNU Lesser General Public
41 * License along with this library; if not, write to the Free Software
42 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
43 *
44 */
45
46/*
47 * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
48 * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
49 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
50 * a choice of LGPL license versions is made available with the language indicating
51 * that LGPLv2 or any later version may be used, or where a choice of which version
52 * of the LGPL is applied is otherwise unspecified.
53 */
54
55
56#include <stdint.h>
57#include <stdarg.h>
58#include "inlines.h"
59#include "biosint.h"
60#include "ebda.h"
61#include "ata.h"
62
63#if DEBUG_ATA
64# define BX_DEBUG_ATA(...) BX_DEBUG(__VA_ARGS__)
65#else
66# define BX_DEBUG_ATA(...)
67#endif
68
69
70// ---------------------------------------------------------------------------
71// Start of ATA/ATAPI Driver
72// ---------------------------------------------------------------------------
73
74void insw_discard(unsigned nwords, unsigned port);
75#pragma aux insw_discard = \
76 ".286" \
77 "again:" \
78 "in ax,dx" \
79 "loop again" \
80 parm [cx] [dx] modify exact [cx ax] nomemory;
81
82void insd_discard(unsigned ndwords, unsigned port);
83#if VBOX_BIOS_CPU >= 80386
84# pragma aux insd_discard = \
85 ".386" \
86 "push eax" \
87 "again:" \
88 "in eax,dx" \
89 "loop again" \
90 "pop eax" \
91 parm [cx] [dx] modify exact [cx] nomemory;
92#endif
93
94// ---------------------------------------------------------------------------
95// ATA/ATAPI driver : initialization
96// ---------------------------------------------------------------------------
97void BIOSCALL ata_init(void)
98{
99 uint8_t channel, device;
100 bio_dsk_t __far *bios_dsk;
101
102 bios_dsk = read_word(0x0040, 0x000E) :> &EbdaData->bdisk;
103
104 // Channels info init.
105 for (channel=0; channel<BX_MAX_ATA_INTERFACES; channel++) {
106 bios_dsk->channels[channel].iface = ATA_IFACE_NONE;
107 bios_dsk->channels[channel].iobase1 = 0x0;
108 bios_dsk->channels[channel].iobase2 = 0x0;
109 bios_dsk->channels[channel].irq = 0;
110 }
111
112 // Devices info init.
113 for (device=0; device<BX_MAX_ATA_DEVICES; device++) {
114 bios_dsk->devices[device].type = DSK_TYPE_NONE;
115 bios_dsk->devices[device].device = DSK_DEVICE_NONE;
116 bios_dsk->devices[device].removable = 0;
117 bios_dsk->devices[device].lock = 0;
118 bios_dsk->devices[device].mode = ATA_MODE_NONE;
119 bios_dsk->devices[device].blksize = 0x200;
120 bios_dsk->devices[device].translation = GEO_TRANSLATION_NONE;
121 bios_dsk->devices[device].lchs.heads = 0;
122 bios_dsk->devices[device].lchs.cylinders = 0;
123 bios_dsk->devices[device].lchs.spt = 0;
124 bios_dsk->devices[device].pchs.heads = 0;
125 bios_dsk->devices[device].pchs.cylinders = 0;
126 bios_dsk->devices[device].pchs.spt = 0;
127 bios_dsk->devices[device].sectors = 0;
128 }
129
130 // hdidmap and cdidmap init.
131 for (device=0; device<BX_MAX_STORAGE_DEVICES; device++) {
132 bios_dsk->hdidmap[device] = BX_MAX_STORAGE_DEVICES;
133 bios_dsk->cdidmap[device] = BX_MAX_STORAGE_DEVICES;
134 }
135
136 bios_dsk->hdcount = 0;
137 bios_dsk->cdcount = 0;
138}
139
140// ---------------------------------------------------------------------------
141// ATA/ATAPI driver : software reset
142// ---------------------------------------------------------------------------
143// ATA-3
144// 8.2.1 Software reset - Device 0
145
146void ata_reset(uint16_t device)
147{
148 uint16_t iobase1, iobase2;
149 uint8_t channel, slave, sn, sc;
150 uint16_t max;
151 uint16_t pdelay;
152 bio_dsk_t __far *bios_dsk;
153
154 bios_dsk = read_word(0x0040, 0x000E) :> &EbdaData->bdisk;
155 channel = device / 2;
156 slave = device % 2;
157
158 iobase1 = bios_dsk->channels[channel].iobase1;
159 iobase2 = bios_dsk->channels[channel].iobase2;
160
161 // Reset
162
163 // 8.2.1 (a) -- set SRST in DC
164 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15 | ATA_CB_DC_NIEN | ATA_CB_DC_SRST);
165
166 // 8.2.1 (b) -- wait for BSY
167 max=0xff;
168 while(--max>0) {
169 uint8_t status = inb(iobase1+ATA_CB_STAT);
170 if ((status & ATA_CB_STAT_BSY) != 0)
171 break;
172 }
173
174 // 8.2.1 (f) -- clear SRST
175 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15 | ATA_CB_DC_NIEN);
176
177 if (bios_dsk->devices[device].type != DSK_TYPE_NONE) {
178 // 8.2.1 (g) -- check for sc==sn==0x01
179 // select device
180 outb(iobase1+ATA_CB_DH, slave?ATA_CB_DH_DEV1:ATA_CB_DH_DEV0);
181 sc = inb(iobase1+ATA_CB_SC);
182 sn = inb(iobase1+ATA_CB_SN);
183
184 if ( (sc==0x01) && (sn==0x01) ) {
185 // 8.2.1 (h) -- wait for not BSY
186 max=0xffff; /* The ATA specification says that the drive may be busy for up to 30 seconds. */
187 while(--max>0) {
188 uint8_t status = inb(iobase1+ATA_CB_STAT);
189 if ((status & ATA_CB_STAT_BSY) == 0)
190 break;
191 pdelay=0xffff;
192 while (--pdelay>0) {
193 /* nothing */
194 }
195 }
196 }
197 }
198
199 // 8.2.1 (i) -- wait for DRDY
200 max = 0x10; /* Speed up for virtual drives. Disks are immediately ready, CDs never */
201 while(--max>0) {
202 uint8_t status = inb(iobase1+ATA_CB_STAT);
203 if ((status & ATA_CB_STAT_RDY) != 0)
204 break;
205 }
206
207 // Enable interrupts
208 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
209}
210
211// ---------------------------------------------------------------------------
212// ATA/ATAPI driver : execute a data-in command
213// ---------------------------------------------------------------------------
214 // returns
215 // 0 : no error
216 // 1 : BUSY bit set
217 // 2 : read error
218 // 3 : expected DRQ=1
219 // 4 : no sectors left to read/verify
220 // 5 : more sectors to read/verify
221 // 6 : no sectors left to write
222 // 7 : more sectors to write
223uint16_t ata_cmd_data_in(bio_dsk_t __far *bios_dsk, uint16_t command, uint16_t count)
224{
225 uint16_t iobase1, iobase2, blksize, mult_blk_cnt;
226 uint16_t cylinder;
227 uint8_t head;
228 uint8_t sector;
229 uint8_t device;
230 uint8_t status, mode;
231 char __far *buffer;
232
233 device = bios_dsk->drqp.dev_id;
234
235 iobase1 = bios_dsk->channels[device / 2].iobase1;
236 iobase2 = bios_dsk->channels[device / 2].iobase2;
237 mode = bios_dsk->devices[device].mode;
238 blksize = bios_dsk->devices[device].blksize;
239 if (blksize == 0) { /* If transfer size is exactly 64K */
240#if VBOX_BIOS_CPU >= 80386
241 if (mode == ATA_MODE_PIO32)
242 blksize = 0x4000;
243 else
244#endif
245 blksize = 0x8000;
246 } else {
247#if VBOX_BIOS_CPU >= 80386
248 if (mode == ATA_MODE_PIO32)
249 blksize >>= 2;
250 else
251#endif
252 blksize >>= 1;
253 }
254
255 status = inb(iobase1 + ATA_CB_STAT);
256 if (status & ATA_CB_STAT_BSY)
257 {
258 BX_DEBUG_ATA("%s: disk busy\n", __func__);
259 // Enable interrupts
260 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
261 return 1;
262 }
263
264 buffer = bios_dsk->drqp.buffer;
265 sector = bios_dsk->drqp.sector;
266 cylinder = bios_dsk->drqp.cylinder;
267 head = bios_dsk->drqp.head;
268
269 // sector will be 0 only on lba access. Convert to lba-chs
270 if (sector == 0) {
271 if (bios_dsk->drqp.lba + count >= 268435456)
272 {
273 sector = (bios_dsk->drqp.lba >> 24) & 0x00ff;
274 cylinder = (bios_dsk->drqp.lba >> 32) & 0xffff;
275 outb(iobase1 + ATA_CB_SC, (count & 0xff00) >> 8);
276 outb(iobase1 + ATA_CB_SN, sector);
277 outb(iobase1 + ATA_CB_CL, cylinder & 0x00ff);
278 outb(iobase1 + ATA_CB_CH, cylinder >> 8);
279 /* Leave the bottom 24 bits as is, they are treated correctly by the
280 * LBA28 code path. */
281 }
282 sector = bios_dsk->drqp.lba & 0x000000ffL;
283 cylinder = (bios_dsk->drqp.lba >> 8) & 0x0000ffffL;
284 head = ((bios_dsk->drqp.lba >> 24) & 0x0000000fL) | 0x40;
285 }
286
287 outb(iobase2 + ATA_CB_DC, ATA_CB_DC_HD15 | ATA_CB_DC_NIEN);
288 outb(iobase1 + ATA_CB_FR, 0x00);
289 outb(iobase1 + ATA_CB_SC, count);
290 outb(iobase1 + ATA_CB_SN, sector);
291 outb(iobase1 + ATA_CB_CL, cylinder & 0x00ff);
292 outb(iobase1 + ATA_CB_CH, cylinder >> 8);
293 outb(iobase1 + ATA_CB_DH, ((device & 1) ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0) | head );
294 outb(iobase1 + ATA_CB_CMD, command);
295
296 if (command == ATA_CMD_READ_MULTIPLE || command == ATA_CMD_READ_MULTIPLE_EXT) {
297 mult_blk_cnt = count;
298 count = 1;
299 } else {
300 mult_blk_cnt = 1;
301 }
302
303 while (1) {
304 status = inb(iobase1 + ATA_CB_STAT);
305 if ( !(status & ATA_CB_STAT_BSY) )
306 break;
307 }
308
309 if (status & ATA_CB_STAT_ERR) {
310 BX_DEBUG_ATA("%s: read error\n", __func__);
311 // Enable interrupts
312 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
313 return 2;
314 } else if ( !(status & ATA_CB_STAT_DRQ) ) {
315 BX_DEBUG_ATA("%s: DRQ not set (status %02x)\n", __func__, (unsigned) status);
316 // Enable interrupts
317 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
318 return 3;
319 }
320
321 // FIXME : move seg/off translation here
322
323 int_enable(); // enable higher priority interrupts
324
325 while (1) {
326
327 // adjust if there will be an overrun. 2K max sector size
328 if (FP_OFF(buffer) >= 0xF800)
329 buffer = MK_FP(FP_SEG(buffer) + 0x80, FP_OFF(buffer) - 0x800);
330
331#if VBOX_BIOS_CPU >= 80386
332 if (mode == ATA_MODE_PIO32)
333 buffer = rep_insd(buffer, blksize, iobase1);
334 else
335#endif
336 buffer = rep_insw(buffer, blksize, iobase1);
337 bios_dsk->drqp.trsfsectors += mult_blk_cnt;
338 count--;
339 while (1) {
340 status = inb(iobase1 + ATA_CB_STAT);
341 if ( !(status & ATA_CB_STAT_BSY) )
342 break;
343 }
344 if (count == 0) {
345 if ( (status & (ATA_CB_STAT_BSY | ATA_CB_STAT_RDY | ATA_CB_STAT_DRQ | ATA_CB_STAT_ERR) )
346 != ATA_CB_STAT_RDY ) {
347 BX_DEBUG_ATA("%s: no sectors left (status %02x)\n", __func__, (unsigned) status);
348 // Enable interrupts
349 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
350 return 4;
351 }
352 break;
353 }
354 else {
355 if ( (status & (ATA_CB_STAT_BSY | ATA_CB_STAT_RDY | ATA_CB_STAT_DRQ | ATA_CB_STAT_ERR) )
356 != (ATA_CB_STAT_RDY | ATA_CB_STAT_DRQ) ) {
357 BX_DEBUG_ATA("%s: more sectors left (status %02x)\n", __func__, (unsigned) status);
358 // Enable interrupts
359 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
360 return 5;
361 }
362 continue;
363 }
364 }
365 // Enable interrupts
366 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
367 return 0;
368}
369
370// ---------------------------------------------------------------------------
371// ATA/ATAPI driver : device detection
372// ---------------------------------------------------------------------------
373
374void BIOSCALL ata_detect(void)
375{
376 uint16_t ebda_seg = read_word(0x0040,0x000E);
377 uint8_t hdcount, cdcount, device, type;
378 uint8_t buffer[0x0200];
379 bio_dsk_t __far *bios_dsk;
380
381 bios_dsk = ebda_seg :> &EbdaData->bdisk;
382
383#if BX_MAX_ATA_INTERFACES > 0
384 bios_dsk->channels[0].iface = ATA_IFACE_ISA;
385 bios_dsk->channels[0].iobase1 = 0x1f0;
386 bios_dsk->channels[0].iobase2 = 0x3f0;
387 bios_dsk->channels[0].irq = 14;
388#endif
389#if BX_MAX_ATA_INTERFACES > 1
390 bios_dsk->channels[1].iface = ATA_IFACE_ISA;
391 bios_dsk->channels[1].iobase1 = 0x170;
392 bios_dsk->channels[1].iobase2 = 0x370;
393 bios_dsk->channels[1].irq = 15;
394#endif
395#if 0 /// @todo - temporarily removed to avoid conflict with AHCI
396#if BX_MAX_ATA_INTERFACES > 2
397 bios_dsk->channels[2].iface = ATA_IFACE_ISA;
398 bios_dsk->channels[2].iobase1 = 0x1e8;
399 bios_dsk->channels[2].iobase2 = 0x3e0;
400 bios_dsk->channels[2].irq = 12;
401#endif
402#if BX_MAX_ATA_INTERFACES > 3
403 bios_dsk->channels[3].iface = ATA_IFACE_ISA;
404 bios_dsk->channels[3].iobase1 = 0x168;
405 bios_dsk->channels[3].iobase2 = 0x360;
406 bios_dsk->channels[3].irq = 11;
407#endif
408#endif
409#if BX_MAX_ATA_INTERFACES > 4
410#error Please fill the ATA interface informations
411#endif
412
413 // Device detection
414 hdcount = cdcount = 0;
415
416 for (device = 0; device < BX_MAX_ATA_DEVICES; device++) {
417 uint16_t iobase1, iobase2;
418 uint8_t channel, slave;
419 uint8_t sc, sn, cl, ch, st;
420
421 channel = device / 2;
422 slave = device % 2;
423
424 iobase1 = bios_dsk->channels[channel].iobase1;
425 iobase2 = bios_dsk->channels[channel].iobase2;
426
427 // Disable interrupts
428 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15 | ATA_CB_DC_NIEN);
429
430 // Look for device
431 outb(iobase1+ATA_CB_DH, slave ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0);
432 outb(iobase1+ATA_CB_SC, 0x55);
433 outb(iobase1+ATA_CB_SN, 0xaa);
434 outb(iobase1+ATA_CB_SC, 0xaa);
435 outb(iobase1+ATA_CB_SN, 0x55);
436 outb(iobase1+ATA_CB_SC, 0x55);
437 outb(iobase1+ATA_CB_SN, 0xaa);
438
439 // If we found something
440 sc = inb(iobase1+ATA_CB_SC);
441 sn = inb(iobase1+ATA_CB_SN);
442
443 if ( (sc == 0x55) && (sn == 0xaa) ) {
444 bios_dsk->devices[device].type = DSK_TYPE_UNKNOWN;
445
446 // reset the channel
447 ata_reset(device);
448
449 // check for ATA or ATAPI
450 outb(iobase1+ATA_CB_DH, slave ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0);
451 sc = inb(iobase1+ATA_CB_SC);
452 sn = inb(iobase1+ATA_CB_SN);
453 if ((sc==0x01) && (sn==0x01)) {
454 cl = inb(iobase1+ATA_CB_CL);
455 ch = inb(iobase1+ATA_CB_CH);
456 st = inb(iobase1+ATA_CB_STAT);
457
458 if ((cl==0x14) && (ch==0xeb)) {
459 bios_dsk->devices[device].type = DSK_TYPE_ATAPI;
460 } else if ((cl==0x00) && (ch==0x00) && (st!=0x00)) {
461 bios_dsk->devices[device].type = DSK_TYPE_ATA;
462 } else if ((cl==0xff) && (ch==0xff)) {
463 bios_dsk->devices[device].type = DSK_TYPE_NONE;
464 }
465 }
466 }
467
468 // Enable interrupts
469 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
470
471 type = bios_dsk->devices[device].type;
472
473 // Now we send a IDENTIFY command to ATA device
474 if (type == DSK_TYPE_ATA) {
475 uint64_t sectors;
476 uint16_t cylinders, heads, spt, blksize;
477 chs_t lgeo;
478 uint8_t chsgeo_base;
479 uint8_t removable, mode;
480
481 //Temporary values to do the transfer
482 bios_dsk->devices[device].device = DSK_DEVICE_HD;
483 bios_dsk->devices[device].mode = ATA_MODE_PIO16;
484 bios_dsk->drqp.buffer = buffer;
485 bios_dsk->drqp.dev_id = device;
486
487 if (ata_cmd_data_in(bios_dsk, ATA_CMD_IDENTIFY_DEVICE, 1) !=0 )
488 BX_PANIC("ata-detect: Failed to detect ATA device\n");
489
490 removable = (*(buffer+0) & 0x80) ? 1 : 0;
491#if VBOX_BIOS_CPU >= 80386
492 mode = *(buffer+96) ? ATA_MODE_PIO32 : ATA_MODE_PIO16;
493#else
494 mode = ATA_MODE_PIO16;
495#endif
496 blksize = 512; /* There is no sector size field any more. */
497
498 cylinders = *(uint16_t *)(buffer+(1*2)); // word 1
499 heads = *(uint16_t *)(buffer+(3*2)); // word 3
500 spt = *(uint16_t *)(buffer+(6*2)); // word 6
501
502 sectors = *(uint32_t *)(buffer+(60*2)); // word 60 and word 61
503 if (sectors == 0x0FFFFFFF) /* For disks bigger than ~128GB */
504 sectors = *(uint64_t *)(buffer+(100*2)); // words 100 to 103
505 switch (device)
506 {
507 case 0:
508 chsgeo_base = 0x1e;
509 break;
510 case 1:
511 chsgeo_base = 0x26;
512 break;
513 case 2:
514 chsgeo_base = 0x67;
515 break;
516 case 3:
517 chsgeo_base = 0x70;
518 break;
519 default:
520 chsgeo_base = 0;
521 }
522 if (chsgeo_base)
523 {
524 lgeo.cylinders = inb_cmos(chsgeo_base) + (inb_cmos(chsgeo_base + 1) << 8);
525 lgeo.heads = inb_cmos(chsgeo_base + 2);
526 lgeo.spt = inb_cmos(chsgeo_base + 7);
527 }
528 else
529 set_geom_lba(&lgeo, sectors); /* Default EDD-style translated LBA geometry. */
530
531 BX_INFO("ata%d-%d: PCHS=%u/%u/%u LCHS=%u/%u/%u\n", channel, slave,
532 cylinders, heads, spt, lgeo.cylinders, lgeo.heads, lgeo.spt);
533
534 bios_dsk->devices[device].device = DSK_DEVICE_HD;
535 bios_dsk->devices[device].removable = removable;
536 bios_dsk->devices[device].mode = mode;
537 bios_dsk->devices[device].blksize = blksize;
538 bios_dsk->devices[device].pchs.heads = heads;
539 bios_dsk->devices[device].pchs.cylinders = cylinders;
540 bios_dsk->devices[device].pchs.spt = spt;
541 bios_dsk->devices[device].sectors = sectors;
542 bios_dsk->devices[device].lchs = lgeo;
543 if (device < 2)
544 {
545 uint8_t sum, i;
546 fdpt_t __far *fdpt;
547 void __far * __far *int_vec;
548
549 if (device == 0)
550 fdpt = ebda_seg :> &EbdaData->fdpt0;
551 else
552 fdpt = ebda_seg :> &EbdaData->fdpt1;
553
554 fdpt = MK_FP(0xE200, 0xf00);
555 fdpt += device;
556
557 /* Set the INT 41h or 46h pointer. */
558 int_vec = MK_FP(0, (0x41 + device * 5) * sizeof(void __far *));
559 *int_vec = fdpt;
560
561 /* Update the DPT for drive 0/1 pointed to by Int41/46. This used
562 * to be done at POST time with lots of ugly assembler code, which
563 * isn't worth the effort of converting from AMI to Award CMOS
564 * format. Just do it here. */
565 _fmemset(fdpt, 0, sizeof(*fdpt));
566 fdpt->lcyl = lgeo.cylinders;
567 fdpt->lhead = lgeo.heads;
568 fdpt->sig = 0xa0;
569 fdpt->spt = spt;
570 fdpt->cyl = cylinders;
571 fdpt->head = heads;
572 fdpt->lspt = lgeo.spt;
573 sum = 0;
574 for (i = 0; i < 0xf; i++)
575 sum += *((uint8_t __far *)fdpt + i);
576 sum = -sum;
577 fdpt->csum = sum;
578 }
579
580 // fill hdidmap
581 bios_dsk->hdidmap[hdcount] = device;
582 hdcount++;
583 }
584
585 // Now we send an IDENTIFY command to ATAPI device
586 if (type == DSK_TYPE_ATAPI) {
587 uint8_t type, removable, mode;
588 uint16_t blksize;
589
590 // Temporary values to do the transfer
591 bios_dsk->devices[device].device = DSK_DEVICE_CDROM;
592 bios_dsk->devices[device].mode = ATA_MODE_PIO16;
593 bios_dsk->drqp.buffer = buffer;
594 bios_dsk->drqp.dev_id = device;
595
596 if (ata_cmd_data_in(bios_dsk, ATA_CMD_IDENTIFY_PACKET, 1) != 0)
597 BX_PANIC("ata-detect: Failed to detect ATAPI device\n");
598
599 type = *(buffer+1) & 0x1f;
600 removable = (*(buffer+0) & 0x80) ? 1 : 0;
601#if VBOX_BIOS_CPU >= 80386
602 mode = *(buffer+96) ? ATA_MODE_PIO32 : ATA_MODE_PIO16;
603#else
604 mode = ATA_MODE_PIO16;
605#endif
606 blksize = 2048;
607
608 bios_dsk->devices[device].device = type;
609 bios_dsk->devices[device].removable = removable;
610 bios_dsk->devices[device].mode = mode;
611 bios_dsk->devices[device].blksize = blksize;
612
613 // fill cdidmap
614 bios_dsk->cdidmap[cdcount] = device;
615 cdcount++;
616 }
617
618 {
619 uint32_t sizeinmb;
620 uint16_t ataversion;
621 uint8_t version, model[41];
622 int i;
623
624 switch (type) {
625 case DSK_TYPE_ATA:
626 sizeinmb = (bios_dsk->devices[device].sectors >> 11);
627 case DSK_TYPE_ATAPI:
628 // Read ATA/ATAPI version
629 ataversion = ((uint16_t)(*(buffer+161))<<8) | *(buffer+160);
630 for (version = 15; version > 0; version--) {
631 if ((ataversion & (1 << version)) !=0 )
632 break;
633 }
634
635 // Read model name
636 for (i = 0; i < 20; i++ ) {
637 *(model+(i*2)) = *(buffer+(i*2)+54+1);
638 *(model+(i*2)+1) = *(buffer+(i*2)+54);
639 }
640
641 // Reformat
642 *(model+40) = 0x00;
643 for ( i = 39; i > 0; i-- ){
644 if (*(model+i) == 0x20)
645 *(model+i) = 0x00;
646 else
647 break;
648 }
649 break;
650 }
651
652#ifdef VBOXz
653 // we don't want any noisy output for now
654#else /* !VBOX */
655 switch (type) {
656 int c;
657 case DSK_TYPE_ATA:
658 printf("ata%d %s: ", channel, slave ? " slave" : "master");
659 i=0;
660 while(c=*(model+i++))
661 printf("%c", c);
662 printf(" ATA-%d Hard-Disk (%lu MBytes)\n", version, sizeinmb);
663 break;
664 case DSK_TYPE_ATAPI:
665 printf("ata%d %s: ", channel, slave ? " slave" : "master");
666 i=0;
667 while(c=*(model+i++))
668 printf("%c", c);
669 if (bios_dsk->devices[device].device == DSK_DEVICE_CDROM)
670 printf(" ATAPI-%d CD-ROM/DVD-ROM\n", version);
671 else
672 printf(" ATAPI-%d Device\n", version);
673 break;
674 case DSK_TYPE_UNKNOWN:
675 printf("ata%d %s: Unknown device\n", channel , slave ? " slave" : "master");
676 break;
677 }
678#endif /* !VBOX */
679 }
680 }
681
682 // Store the devices counts
683 bios_dsk->hdcount = hdcount;
684 bios_dsk->cdcount = cdcount;
685 write_byte(0x40,0x75, hdcount);
686
687#ifdef VBOX
688 // we don't want any noisy output for now
689#else /* !VBOX */
690 printf("\n");
691#endif /* !VBOX */
692
693 // FIXME : should use bios=cmos|auto|disable bits
694 // FIXME : should know about translation bits
695 // FIXME : move hard_drive_post here
696
697}
698
699// ---------------------------------------------------------------------------
700// ATA/ATAPI driver : execute a data-out command
701// ---------------------------------------------------------------------------
702 // returns
703 // 0 : no error
704 // 1 : BUSY bit set
705 // 2 : read error
706 // 3 : expected DRQ=1
707 // 4 : no sectors left to read/verify
708 // 5 : more sectors to read/verify
709 // 6 : no sectors left to write
710 // 7 : more sectors to write
711uint16_t ata_cmd_data_out(bio_dsk_t __far *bios_dsk, uint16_t command, uint16_t count)
712{
713 uint64_t lba;
714 char __far *buffer;
715 uint16_t iobase1, iobase2, blksize;
716 uint16_t cylinder;
717 uint16_t head;
718 uint16_t sector;
719 uint16_t device;
720 uint8_t channel, slave;
721 uint8_t status, mode;
722
723 device = bios_dsk->drqp.dev_id;
724 channel = device / 2;
725 slave = device % 2;
726
727 iobase1 = bios_dsk->channels[channel].iobase1;
728 iobase2 = bios_dsk->channels[channel].iobase2;
729 mode = bios_dsk->devices[device].mode;
730 blksize = 0x200; // was = bios_dsk->devices[device].blksize;
731#if VBOX_BIOS_CPU >= 80386
732 if (mode == ATA_MODE_PIO32)
733 blksize >>= 2;
734 else
735#endif
736 blksize >>= 1;
737
738 status = inb(iobase1 + ATA_CB_STAT);
739 if (status & ATA_CB_STAT_BSY)
740 {
741 // Enable interrupts
742 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
743 return 1;
744 }
745
746 lba = bios_dsk->drqp.lba;
747 buffer = bios_dsk->drqp.buffer;
748 sector = bios_dsk->drqp.sector;
749 cylinder = bios_dsk->drqp.cylinder;
750 head = bios_dsk->drqp.head;
751
752 // sector will be 0 only on lba access. Convert to lba-chs
753 if (sector == 0) {
754 if (lba + count >= 268435456)
755 {
756 sector = (lba >> 24) & 0x00ff;
757 cylinder = (lba >> 32) & 0xffff;
758 outb(iobase1 + ATA_CB_SC, (count & 0xff00) >> 8);
759 outb(iobase1 + ATA_CB_SN, sector);
760 outb(iobase1 + ATA_CB_CL, cylinder & 0x00ff);
761 outb(iobase1 + ATA_CB_CH, cylinder >> 8);
762 /* Leave the bottom 24 bits as is, they are treated correctly by the
763 * LBA28 code path. */
764 lba &= 0xffffff;
765 }
766 sector = (uint16_t) (lba & 0x000000ffL);
767 lba >>= 8;
768 cylinder = (uint16_t) (lba & 0x0000ffffL);
769 lba >>= 16;
770 head = ((uint16_t) (lba & 0x0000000fL)) | 0x40;
771 }
772
773 outb(iobase2 + ATA_CB_DC, ATA_CB_DC_HD15 | ATA_CB_DC_NIEN);
774 outb(iobase1 + ATA_CB_FR, 0x00);
775 outb(iobase1 + ATA_CB_SC, count);
776 outb(iobase1 + ATA_CB_SN, sector);
777 outb(iobase1 + ATA_CB_CL, cylinder & 0x00ff);
778 outb(iobase1 + ATA_CB_CH, cylinder >> 8);
779 outb(iobase1 + ATA_CB_DH, (slave ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0) | (uint8_t) head );
780 outb(iobase1 + ATA_CB_CMD, command);
781
782 while (1) {
783 status = inb(iobase1 + ATA_CB_STAT);
784 if ( !(status & ATA_CB_STAT_BSY) )
785 break;
786 }
787
788 if (status & ATA_CB_STAT_ERR) {
789 BX_DEBUG_ATA("%s: write error\n", __func__);
790 // Enable interrupts
791 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
792 return 2;
793 } else if ( !(status & ATA_CB_STAT_DRQ) ) {
794 BX_DEBUG_ATA("%s: DRQ not set (status %02x)\n", __func__, (unsigned) status);
795 // Enable interrupts
796 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
797 return 3;
798 }
799
800 // FIXME : move seg/off translation here
801
802 int_enable(); // enable higher priority interrupts
803
804 while (1) {
805
806 // adjust if there will be an overrun. 2K max sector size
807 if (FP_OFF(buffer) >= 0xF800)
808 buffer = MK_FP(FP_SEG(buffer) + 0x80, FP_OFF(buffer) - 0x800);
809
810#if VBOX_BIOS_CPU >= 80386
811 if (mode == ATA_MODE_PIO32)
812 buffer = rep_outsd(buffer, blksize, iobase1);
813 else
814#endif
815 buffer = rep_outsw(buffer, blksize, iobase1);
816
817 bios_dsk->drqp.trsfsectors++;
818 count--;
819 while (1) {
820 status = inb(iobase1 + ATA_CB_STAT);
821 if ( !(status & ATA_CB_STAT_BSY) )
822 break;
823 }
824 if (count == 0) {
825 if ( (status & (ATA_CB_STAT_BSY | ATA_CB_STAT_RDY | ATA_CB_STAT_DF | ATA_CB_STAT_DRQ | ATA_CB_STAT_ERR) )
826 != ATA_CB_STAT_RDY ) {
827 BX_DEBUG_ATA("%s: no sectors left (status %02x)\n", __func__, (unsigned) status);
828 // Enable interrupts
829 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
830 return 6;
831 }
832 break;
833 }
834 else {
835 if ( (status & (ATA_CB_STAT_BSY | ATA_CB_STAT_RDY | ATA_CB_STAT_DRQ | ATA_CB_STAT_ERR) )
836 != (ATA_CB_STAT_RDY | ATA_CB_STAT_DRQ) ) {
837 BX_DEBUG_ATA("%s: more sectors left (status %02x)\n", __func__, (unsigned) status);
838 // Enable interrupts
839 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
840 return 7;
841 }
842 continue;
843 }
844 }
845 // Enable interrupts
846 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
847 return 0;
848}
849
850
851/**
852 * Read sectors from an attached ATA device.
853 *
854 * @returns status code.
855 * @param bios_dsk Pointer to disk request packet (in the
856 * EBDA).
857 */
858int ata_read_sectors(bio_dsk_t __far *bios_dsk)
859{
860 uint16_t n_sect;
861 int status;
862 uint8_t device_id;
863
864 device_id = bios_dsk->drqp.dev_id;
865 n_sect = bios_dsk->drqp.nsect;
866
867 if (bios_dsk->drqp.sector) {
868 /* CHS addressing. */
869 bios_dsk->devices[device_id].blksize = n_sect * 0x200;
870 BX_DEBUG_ATA("%s: reading %u sectors (CHS)\n", __func__, n_sect);
871 status = ata_cmd_data_in(bios_dsk, ATA_CMD_READ_MULTIPLE, n_sect);
872 bios_dsk->devices[device_id].blksize = 0x200;
873 } else {
874 /* LBA addressing. */
875 if (bios_dsk->drqp.lba + n_sect >= 268435456) {
876 BX_DEBUG_ATA("%s: reading %u sector (LBA,EXT)\n", __func__, n_sect);
877 status = ata_cmd_data_in(bios_dsk, ATA_CMD_READ_SECTORS_EXT, n_sect);
878 } else {
879 bios_dsk->devices[device_id].blksize = n_sect * 0x200;
880 BX_DEBUG_ATA("%s: reading %u sector (LBA,MULT)\n", __func__, n_sect);
881 status = ata_cmd_data_in(bios_dsk, ATA_CMD_READ_MULTIPLE, n_sect);
882 bios_dsk->devices[device_id].blksize = 0x200;
883 }
884 }
885 return status;
886}
887
888/**
889 * Write sectors to an attached ATA device.
890 *
891 * @returns status code.
892 * @param bios_dsk Pointer to disk request packet (in the
893 * EBDA).
894 */
895int ata_write_sectors(bio_dsk_t __far *bios_dsk)
896{
897 uint16_t n_sect;
898
899 n_sect = bios_dsk->drqp.nsect;
900
901 if (bios_dsk->drqp.sector) {
902 /* CHS addressing. */
903 return ata_cmd_data_out(bios_dsk, ATA_CMD_WRITE_SECTORS, n_sect);
904 } else {
905 /* LBA addressing. */
906 if (bios_dsk->drqp.lba + n_sect >= 268435456)
907 return ata_cmd_data_out(bios_dsk, ATA_CMD_WRITE_SECTORS_EXT, n_sect);
908 else
909 return ata_cmd_data_out(bios_dsk, ATA_CMD_WRITE_SECTORS, n_sect);
910 }
911}
912
913
914// ---------------------------------------------------------------------------
915// ATA/ATAPI driver : execute a packet command
916// ---------------------------------------------------------------------------
917 // returns
918 // 0 : no error
919 // 1 : error in parameters
920 // 2 : BUSY bit set
921 // 3 : error
922 // 4 : not ready
923uint16_t ata_cmd_packet(uint16_t device, uint8_t cmdlen, char __far *cmdbuf,
924 uint16_t header, uint32_t length, uint8_t inout, char __far *buffer)
925{
926 uint16_t iobase1, iobase2;
927 uint16_t lcount, lbefore, lafter, count;
928 uint8_t channel, slave;
929 uint8_t status, mode, lmode;
930 uint32_t transfer;
931 bio_dsk_t __far *bios_dsk;
932
933 bios_dsk = read_word(0x0040, 0x000E) :> &EbdaData->bdisk;
934
935 channel = device / 2;
936 slave = device % 2;
937
938 // Data out is not supported yet
939 if (inout == ATA_DATA_OUT) {
940 BX_INFO("%s: DATA_OUT not supported yet\n", __func__);
941 return 1;
942 }
943
944 // The header length must be even
945 if (header & 1) {
946 BX_DEBUG_ATA("%s: header must be even (%04x)\n", __func__, header);
947 return 1;
948 }
949
950 iobase1 = bios_dsk->channels[channel].iobase1;
951 iobase2 = bios_dsk->channels[channel].iobase2;
952 mode = bios_dsk->devices[device].mode;
953 transfer = 0L;
954
955 if (cmdlen < 12)
956 cmdlen = 12;
957 if (cmdlen > 12)
958 cmdlen = 16;
959 cmdlen >>= 1;
960
961 // Reset count of transferred data
962 /// @todo clear in calling code?
963 bios_dsk->drqp.trsfsectors = 0;
964 bios_dsk->drqp.trsfbytes = 0;
965
966 status = inb(iobase1 + ATA_CB_STAT);
967 if (status & ATA_CB_STAT_BSY)
968 return 2;
969
970 outb(iobase2 + ATA_CB_DC, ATA_CB_DC_HD15 | ATA_CB_DC_NIEN);
971 // outb(iobase1 + ATA_CB_FR, 0x00);
972 // outb(iobase1 + ATA_CB_SC, 0x00);
973 // outb(iobase1 + ATA_CB_SN, 0x00);
974 outb(iobase1 + ATA_CB_CL, 0xfff0 & 0x00ff);
975 outb(iobase1 + ATA_CB_CH, 0xfff0 >> 8);
976 outb(iobase1 + ATA_CB_DH, slave ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0);
977 outb(iobase1 + ATA_CB_CMD, ATA_CMD_PACKET);
978
979 // Device should ok to receive command
980 while (1) {
981 status = inb(iobase1 + ATA_CB_STAT);
982 if ( !(status & ATA_CB_STAT_BSY) ) break;
983 }
984
985 if (status & ATA_CB_STAT_CHK) {
986 BX_DEBUG_ATA("%s: error, status is %02x\n", __func__, status);
987 // Enable interrupts
988 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
989 return 3;
990 } else if ( !(status & ATA_CB_STAT_DRQ) ) {
991 BX_DEBUG_ATA("%s: DRQ not set (status %02x)\n", __func__, (unsigned) status);
992 // Enable interrupts
993 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
994 return 4;
995 }
996
997 int_enable(); // enable higher priority interrupts
998
999 // Normalize address
1000 BX_DEBUG_ATA("acp1 buffer ptr: %04x:%04x wlen %04x\n", FP_SEG(cmdbuf), FP_OFF(cmdbuf), cmdlen);
1001 cmdbuf = MK_FP(FP_SEG(cmdbuf) + FP_OFF(cmdbuf) / 16 , FP_OFF(cmdbuf) % 16);
1002 // cmdseg += (cmdoff / 16);
1003 // cmdoff %= 16;
1004
1005 // Send command to device
1006 rep_outsw(cmdbuf, cmdlen, iobase1);
1007
1008 if (inout == ATA_DATA_NO) {
1009 status = inb(iobase1 + ATA_CB_STAT);
1010 }
1011 else {
1012 while (1) {
1013
1014 while (1) {
1015 status = inb(iobase1 + ATA_CB_STAT);
1016 if ( !(status & ATA_CB_STAT_BSY) )
1017 break;
1018 }
1019
1020 // Check if command completed
1021 if ( (status & (ATA_CB_STAT_BSY | ATA_CB_STAT_DRQ) ) ==0 )
1022 break;
1023
1024 if (status & ATA_CB_STAT_CHK) {
1025 BX_DEBUG_ATA("%s: error (status %02x)\n", __func__, status);
1026 // Enable interrupts
1027 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
1028 return 3;
1029 }
1030
1031 // Device must be ready to send data
1032 if ( (status & (ATA_CB_STAT_BSY | ATA_CB_STAT_RDY | ATA_CB_STAT_DRQ | ATA_CB_STAT_CHK) )
1033 != (ATA_CB_STAT_RDY | ATA_CB_STAT_DRQ) ) {
1034 BX_DEBUG_ATA("%s: not ready (status %02x)\n", __func__, status);
1035 // Enable interrupts
1036 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
1037 return 4;
1038 }
1039
1040 // Normalize address
1041 BX_DEBUG_ATA("acp2 buffer ptr: %04x:%04x\n", FP_SEG(buffer), FP_OFF(buffer));
1042 buffer = MK_FP(FP_SEG(buffer) + FP_OFF(buffer) / 16 , FP_OFF(buffer) % 16);
1043 // bufseg += (bufoff / 16);
1044 // bufoff %= 16;
1045
1046 // Get the byte count
1047 lcount = ((uint16_t)(inb(iobase1 + ATA_CB_CH))<<8)+inb(iobase1 + ATA_CB_CL);
1048
1049 // adjust to read what we want
1050 if (header>lcount) {
1051 lbefore = lcount;
1052 header -= lcount;
1053 lcount = 0;
1054 }
1055 else {
1056 lbefore = header;
1057 header = 0;
1058 lcount -= lbefore;
1059 }
1060
1061 if (lcount>length) {
1062 lafter = lcount - length;
1063 lcount = length;
1064 length = 0;
1065 }
1066 else {
1067 lafter = 0;
1068 length -= lcount;
1069 }
1070
1071 // Save byte count
1072 count = lcount;
1073
1074 BX_DEBUG_ATA("Trying to read %04x bytes (%04x %04x %04x) ",lbefore+lcount+lafter,lbefore,lcount,lafter);
1075 BX_DEBUG_ATA("to 0x%04x:0x%04x\n",FP_SEG(buffer),FP_OFF(buffer));
1076
1077 // If counts not dividable by 4, use 16bits mode
1078 lmode = mode;
1079 if (lbefore & 0x03)
1080 lmode = ATA_MODE_PIO16;
1081 if (lcount & 0x03)
1082 lmode = ATA_MODE_PIO16;
1083 if (lafter & 0x03)
1084 lmode = ATA_MODE_PIO16;
1085
1086 // adds an extra byte if count are odd. before is always even
1087 if (lcount & 0x01) {
1088 lcount += 1;
1089 if ((lafter > 0) && (lafter & 0x01)) {
1090 lafter -= 1;
1091 }
1092 }
1093
1094#if VBOX_BIOS_CPU >= 80386
1095 if (lmode == ATA_MODE_PIO32) {
1096 lcount >>= 2;
1097 lbefore >>= 2;
1098 lafter >>= 2;
1099 } else
1100#endif
1101 {
1102 lcount >>= 1;
1103 lbefore >>= 1;
1104 lafter >>= 1;
1105 }
1106
1107#if VBOX_BIOS_CPU >= 80386
1108 if (lmode == ATA_MODE_PIO32) {
1109 if (lbefore)
1110 insd_discard(lbefore, iobase1);
1111 rep_insd(buffer, lcount, iobase1);
1112 if (lafter)
1113 insd_discard(lafter, iobase1);
1114 } else
1115#endif
1116 {
1117 if (lbefore)
1118 insw_discard(lbefore, iobase1);
1119 rep_insw(buffer, lcount, iobase1);
1120 if (lafter)
1121 insw_discard(lafter, iobase1);
1122 }
1123
1124
1125 // Compute new buffer address
1126 buffer += count;
1127
1128 // Save transferred bytes count
1129 transfer += count;
1130 bios_dsk->drqp.trsfbytes = transfer;
1131 }
1132 }
1133
1134 // Final check, device must be ready
1135 if ( (status & (ATA_CB_STAT_BSY | ATA_CB_STAT_RDY | ATA_CB_STAT_DF | ATA_CB_STAT_DRQ | ATA_CB_STAT_CHK) )
1136 != ATA_CB_STAT_RDY ) {
1137 BX_DEBUG_ATA("%s: not ready (status %02x)\n", __func__, (unsigned) status);
1138 // Enable interrupts
1139 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
1140 return 4;
1141 }
1142
1143 // Enable interrupts
1144 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
1145 return 0;
1146}
1147
1148// ---------------------------------------------------------------------------
1149// ATA/ATAPI driver : reset device; intended for ATAPI devices
1150// ---------------------------------------------------------------------------
1151 // returns
1152 // 0 : no error
1153 // 1 : error
1154uint16_t ata_soft_reset(uint16_t device)
1155{
1156 uint16_t iobase1, iobase2;
1157 uint8_t channel, slave;
1158 uint8_t status;
1159 bio_dsk_t __far *bios_dsk;
1160
1161 bios_dsk = read_word(0x0040, 0x000E) :> &EbdaData->bdisk;
1162
1163 channel = device / 2;
1164 slave = device % 2;
1165
1166 iobase1 = bios_dsk->channels[channel].iobase1;
1167 iobase2 = bios_dsk->channels[channel].iobase2;
1168
1169 /* Send a reset command to the device. */
1170 outb(iobase2 + ATA_CB_DC, ATA_CB_DC_HD15 | ATA_CB_DC_NIEN);
1171 outb(iobase1 + ATA_CB_DH, slave ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0);
1172 outb(iobase1 + ATA_CB_CMD, ATA_CMD_DEVICE_RESET);
1173
1174 /* Wait for the device to clear BSY. */
1175 while (1) {
1176 status = inb(iobase1 + ATA_CB_STAT);
1177 if ( !(status & ATA_CB_STAT_BSY) ) break;
1178 }
1179
1180 /* Final check, device must be ready */
1181 if ( (status & (ATA_CB_STAT_BSY | ATA_CB_STAT_RDY | ATA_CB_STAT_DF | ATA_CB_STAT_DRQ | ATA_CB_STAT_CHK) )
1182 != ATA_CB_STAT_RDY ) {
1183 BX_DEBUG_ATA("%s: not ready (status %02x)\n", __func__, (unsigned) status);
1184 /* Enable interrupts */
1185 outb(iobase2 + ATA_CB_DC, ATA_CB_DC_HD15);
1186 return 1;
1187 }
1188
1189 /* Enable interrupts */
1190 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
1191 return 0;
1192}
1193
1194
1195// ---------------------------------------------------------------------------
1196// End of ATA/ATAPI Driver
1197// ---------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette