1/*- 2 * Copyright (c) 1998,1999 S�ren Schmidt 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * |
28 * $FreeBSD: head/sys/dev/ata/ata-all.c 52067 1999-10-09 19:57:13Z sos $ |
29 */ 30 31#include "ata.h" 32#include "apm.h" 33#include "isa.h" 34#include "pci.h" 35#include "atadisk.h" 36#include "atapicd.h" 37#include "atapifd.h" 38#include "atapist.h" 39#include "opt_global.h" |
40#include "opt_ata.h" |
41#include <sys/param.h> 42#include <sys/systm.h> 43#include <sys/kernel.h> 44#include <sys/interrupt.h> 45#include <sys/conf.h> 46#include <sys/disk.h> 47#include <sys/module.h> 48#include <sys/bus.h> --- 24 unchanged lines hidden (view full) --- 73#include <dev/ata/atapi-all.h> 74 75/* misc defines */ 76#if SMP == 0 77#define isa_apic_irq(x) x 78#endif 79 80/* prototypes */ |
81static int32_t ata_probe(int32_t, int32_t, int32_t, device_t, int32_t *); 82static void ataintr(void *); |
83static int8_t *active2str(int32_t); |
84 |
85/* local vars */ 86static int32_t atanlun = 2; |
87struct ata_softc *atadevices[MAXATA]; 88static devclass_t ata_devclass; |
89MALLOC_DEFINE(M_ATA, "ATA generic", "ATA driver generic layer"); |
90 91#if NISA > 0 92static struct isa_pnp_id ata_ids[] = { |
93 {0x0006d041, "Generic ESDI/IDE/ATA controller"}, /* PNP0600 */ 94 {0x0106d041, "Plus Hardcard II"}, /* PNP0601 */ 95 {0x0206d041, "Plus Hardcard IIXL/EZ"}, /* PNP0602 */ 96 {0x0306d041, "Generic ATA"}, /* PNP0603 */ |
97 {0} 98}; 99 100static int 101ata_isaprobe(device_t dev) 102{ 103 struct resource *port; 104 int rid; --- 74 unchanged lines hidden (view full) --- 179DRIVER_MODULE(ata, isa, ata_isa_driver, ata_devclass, 0, 0); 180#endif 181 182#if NPCI > 0 183static const char * 184ata_pcimatch(device_t dev) 185{ 186 switch (pci_get_devid(dev)) { |
187 /* supported chipsets */ |
188 case 0x12308086: 189 return "Intel PIIX IDE controller"; 190 case 0x70108086: 191 return "Intel PIIX3 IDE controller"; 192 case 0x71118086: 193 return "Intel PIIX4 IDE controller"; |
194 case 0x522910b9: 195 return "AcerLabs Aladdin IDE controller"; |
196 case 0x4d33105a: 197 return "Promise Ultra/33 IDE controller"; 198 case 0x4d38105a: 199 return "Promise Ultra/66 IDE controller"; |
200 case 0x00041103: 201 return "HighPoint HPT366 IDE controller"; |
202 203 /* unsupported but known chipsets, generic DMA only */ |
204 case 0x05711106: /* 82c586 */ 205 case 0x05961106: /* 82c596 */ |
206 return "VIA Apollo IDE controller (generic mode)"; |
207 case 0x06401095: |
208 return "CMD 640 IDE controller (generic mode)"; |
209 case 0x06461095: |
210 return "CMD 646 IDE controller (generic mode)"; |
211 case 0xc6931080: |
212 return "Cypress 82C693 IDE controller (generic mode)"; |
213 case 0x01021078: |
214 return "Cyrix 5530 IDE controller (generic mode)"; |
215 default: 216 if (pci_get_class(dev) == PCIC_STORAGE && |
217 (pci_get_subclass(dev) == PCIS_STORAGE_IDE)) 218 return "Unknown PCI IDE controller (generic mode)"; |
219 } 220 return NULL; 221} 222 223static int 224ata_pciprobe(device_t dev) 225{ 226 const char *desc = ata_pcimatch(dev); --- 19 unchanged lines hidden (view full) --- 246 247 /* set up vendor-specific stuff */ 248 type = pci_get_devid(dev); 249 class = pci_get_class(dev); 250 subclass = pci_get_subclass(dev); 251 cmd = pci_read_config(dev, PCIR_COMMAND, 4); 252 253#ifdef ATA_DEBUG |
254 printf("ata-pci%d: type=%08x class=%02x subclass=%02x cmd=%08x if=%02x\n", 255 unit, type, class, subclass, cmd, pci_get_progif(dev)); |
256#endif 257 |
258 if (pci_get_progif(dev) & PCIP_STORAGE_IDE_MASTERDEV) { 259 iobase_1 = IO_WD1; 260 altiobase_1 = iobase_1 + ATA_ALTPORT; 261 irq1 = 14; 262 } 263 else { |
264 iobase_1 = pci_read_config(dev, 0x10, 4) & 0xfffc; 265 altiobase_1 = pci_read_config(dev, 0x14, 4) & 0xfffc; |
266 bmaddr_1 = pci_read_config(dev, 0x20, 4) & 0xfffc; |
267 irq1 = pci_read_config(dev, PCI_INTERRUPT_REG, 4) & 0xff; |
268 } |
269 270 if (pci_get_progif(dev) & PCIP_STORAGE_IDE_MASTERDEV) { 271 iobase_2 = IO_WD2; 272 altiobase_2 = iobase_2 + ATA_ALTPORT; 273 irq2 = 15; 274 } |
275 else { |
276 iobase_2 = pci_read_config(dev, 0x18, 4) & 0xfffc; 277 altiobase_2 = pci_read_config(dev, 0x1c, 4) & 0xfffc; 278 bmaddr_2 = (pci_read_config(dev, 0x20, 4) & 0xfffc) + ATA_BM_OFFSET1; 279 irq2 = pci_read_config(dev, PCI_INTERRUPT_REG, 4) & 0xff; 280 } |
281 |
282 /* is this controller busmaster DMA capable ? */ 283 if (pci_get_progif(dev) & PCIP_STORAGE_IDE_MASTERDEV) { 284 /* is busmastering support turned on ? */ 285 if ((pci_read_config(dev, PCI_COMMAND_STATUS_REG, 4) & 5) == 5) { 286 /* is there a valid port range to connect to ? */ 287 if ((bmaddr_1 = pci_read_config(dev, 0x20, 4) & 0xfffc)) { 288 bmaddr_2 = bmaddr_1 + ATA_BM_OFFSET1; 289 printf("ata-pci%d: Busmastering DMA supported\n", unit); |
290 } 291 else |
292 printf("ata-pci%d: Busmastering DMA not configured\n", unit); |
293 } 294 else |
295 printf("ata-pci%d: Busmastering DMA not enabled\n", unit); 296 } 297 else { 298 /* the Promise controllers need this to support burst mode */ 299 if (type == 0x4d33105a || type == 0x4d38105a) 300 outb(bmaddr_1 + 0x1f, inb(bmaddr_1 + 0x1f) | 0x01); 301 302 /* Promise and HPT366 controllers support busmastering DMA */ 303 if (type == 0x4d33105a || type == 0x4d38105a || type == 0x00041103) 304 printf("ata-pci%d: Busmastering DMA supported\n", unit); 305 306 /* we dont know this controller, disable busmastering DMA */ 307 else { 308 bmaddr_1 = bmaddr_2 = 0; |
309 printf("ata-pci%d: Busmastering DMA not supported\n", unit); |
310 } |
311 } 312 313 /* now probe the addresse found for "real" ATA/ATAPI hardware */ 314 lun = 0; |
315 if (iobase_1 && ata_probe(iobase_1, altiobase_1, bmaddr_1, dev, &lun)) { |
316 scp = atadevices[lun]; 317 if (iobase_1 == IO_WD1) 318#ifdef __i386__ 319 inthand_add(device_get_nameunit(dev), irq1, ataintr, scp, 320 &bio_imask, INTR_EXCL); 321#endif 322#ifdef __alpha__ 323 alpha_platform_setup_ide_intr(0, ataintr, scp); 324#endif 325 else { 326 struct resource *irq; 327 int rid = 0; 328 void *ih; 329 |
330 if (!(irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, 331 RF_SHAREABLE | RF_ACTIVE))) |
332 printf("ata_pciattach: Unable to alloc interrupt\n"); |
333 bus_setup_intr(dev, irq, INTR_TYPE_BIO, ataintr, scp, &ih); |
334 } 335 printf("ata%d at 0x%04x irq %d on ata-pci%d\n", 336 lun, iobase_1, isa_apic_irq(irq1), unit); 337 } 338 lun = 1; |
339 if (iobase_2 && ata_probe(iobase_2, altiobase_2, bmaddr_2, dev, &lun)) { |
340 scp = atadevices[lun]; 341 if (iobase_2 == IO_WD2) 342#ifdef __i386__ 343 inthand_add(device_get_nameunit(dev), irq2, ataintr, scp, 344 &bio_imask, INTR_EXCL); 345#endif 346#ifdef __alpha__ 347 alpha_platform_setup_ide_intr(1, ataintr, scp); 348#endif 349 else { 350 struct resource *irq; 351 int rid = 0; 352 void *ih; 353 |
354 if (!(irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, 355 RF_SHAREABLE | RF_ACTIVE))) 356 printf("ata_pciattach: Unable to alloc interrupt\n"); 357 bus_setup_intr(dev, irq, INTR_TYPE_BIO, ataintr, scp, &ih); |
358 } 359 printf("ata%d at 0x%04x irq %d on ata-pci%d\n", 360 lun, iobase_2, isa_apic_irq(irq2), unit); 361 } 362 return 0; 363} 364 365static device_method_t ata_pci_methods[] = { --- 5 unchanged lines hidden (view full) --- 371 372static driver_t ata_pci_driver = { 373 "ata-pci", 374 ata_pci_methods, 375 sizeof(int), 376}; 377 378DRIVER_MODULE(ata, pci, ata_pci_driver, ata_devclass, 0, 0); |
379#endif 380 381static int32_t 382ata_probe(int32_t ioaddr, int32_t altioaddr, int32_t bmaddr, 383 device_t dev, int32_t *unit) 384{ |
385 struct ata_softc *scp; 386 int32_t lun, mask = 0; |
387 u_int8_t status0, status1; 388 |
389 if (atanlun > MAXATA) { 390 printf("ata: unit out of range(%d)\n", atanlun); |
391 return 0; 392 } |
393 394 /* check if this is located at one of the std addresses */ 395 if (ioaddr == IO_WD1) 396 lun = 0; 397 else if (ioaddr == IO_WD2) 398 lun = 1; 399 else 400 lun = atanlun++; 401 402 if ((scp = atadevices[lun])) { |
403 printf("ata%d: unit already attached\n", lun); 404 return 0; 405 } |
406 scp = malloc(sizeof(struct ata_softc), M_ATA, M_NOWAIT); |
407 if (scp == NULL) { 408 printf("ata%d: failed to allocate driver storage\n", lun); 409 return 0; 410 } 411 bzero(scp, sizeof(struct ata_softc)); 412 |
413 scp->ioaddr = ioaddr; 414 scp->altioaddr = altioaddr; |
415 scp->lun = lun; 416 scp->unit = *unit; |
417 scp->active = ATA_IDLE; 418 419 if (bootverbose) 420 printf("ata%d: iobase=0x%04x altiobase=0x%04x\n", 421 scp->lun, scp->ioaddr, scp->altioaddr); 422 423 424 /* do we have any signs of ATA/ATAPI HW being present ? */ --- 64 unchanged lines hidden (view full) --- 489 } 490 TAILQ_INIT(&scp->ata_queue); 491 TAILQ_INIT(&scp->atapi_queue); 492 *unit = scp->lun; 493 scp->dev = dev; 494 if (bmaddr) 495 scp->bmaddr = bmaddr; 496 atadevices[scp->lun] = scp; |
497#if NAPM > 0 498 scp->resume_hook.ah_fun = (void *)ata_reinit; 499 scp->resume_hook.ah_arg = scp; 500 scp->resume_hook.ah_name = "ATA driver"; 501 scp->resume_hook.ah_order = APM_MID_ORDER; 502 apm_hook_establish(APM_HOOK_RESUME, &scp->resume_hook); 503#endif 504 return ATA_IOSIZE; 505} 506 507static void 508ataintr(void *data) 509{ 510 struct ata_softc *scp =(struct ata_softc *)data; 511 |
512 /* is this interrupt really for this channel */ 513 if (scp->flags & ATA_DMA_ACTIVE) 514 if (!(ata_dmastatus(scp) & ATA_BMSTAT_INTERRUPT)) 515 return; 516 if ((scp->status = inb(scp->ioaddr + ATA_STATUS)) == ATA_S_BUSY) /*XXX SOS*/ 517 return; |
518 519 /* find & call the responsible driver to process this interrupt */ 520 switch (scp->active) { 521#if NATADISK > 0 522 case ATA_ACTIVE_ATA: |
523 if (scp->running && (ad_interrupt(scp->running) == ATA_OP_CONTINUES)) |
524 return; 525 break; 526#endif 527#if NATAPICD > 0 || NATAPIFD > 0 || NATAPIST > 0 528 case ATA_ACTIVE_ATAPI: |
529 if (scp->running && (atapi_interrupt(scp->running) == ATA_OP_CONTINUES)) |
530 return; 531 break; 532#endif 533 case ATA_WAIT_INTR: 534 wakeup((caddr_t)scp); 535 break; 536 |
537 case ATA_REINITING: 538 return; 539 |
540 case ATA_IGNORE_INTR: 541 break; 542 543 default: 544 case ATA_IDLE: 545#ifdef ATA_DEBUG 546 { 547 static int32_t intr_count = 0; --- 17 unchanged lines hidden (view full) --- 565 566#ifdef ATA_DEBUG 567 printf("ata_start: entered\n"); 568#endif 569 if (scp->active != ATA_IDLE) 570 return; 571 572#if NATADISK > 0 |
573 /* find & call the responsible driver if anything on the ATA queue */ |
574 if ((ad_request = TAILQ_FIRST(&scp->ata_queue))) { 575 TAILQ_REMOVE(&scp->ata_queue, ad_request, chain); 576 scp->active = ATA_ACTIVE_ATA; 577 scp->running = ad_request; 578 ad_transfer(ad_request); 579#ifdef ATA_DEBUG 580 printf("ata_start: started ata, leaving\n"); 581#endif 582 return; 583 } 584#endif 585#if NATAPICD > 0 || NATAPIFD > 0 || NATAPIST > 0 586 /* |
587 * find & call the responsible driver if anything on the ATAPI queue. |
588 * check for device busy by polling the DSC bit, if busy, check 589 * for requests to the other device on the channel (if any). |
590 * if the other device is an ATA disk it already had its chance above. 591 * if no request can be served, timeout a call to ata_start. |
592 */ 593 if ((atapi_request = TAILQ_FIRST(&scp->atapi_queue))) { 594 struct atapi_softc *atp = atapi_request->device; |
595 static int32_t interval = 1; |
596 |
597 if (atp->flags & ATAPI_F_DSC_USED) { 598 outb(atp->controller->ioaddr + ATA_DRIVE, ATA_D_IBM | atp->unit); 599 DELAY(1); 600 if (!(inb(atp->controller->ioaddr + ATA_STATUS) & ATA_S_DSC)) { 601 while ((atapi_request = TAILQ_NEXT(atapi_request, chain))) { 602 if (atapi_request->device->unit != atp->unit) { 603 struct atapi_softc *tmp = atapi_request->device; |
604 |
605 outb(tmp->controller->ioaddr + ATA_DRIVE, 606 ATA_D_IBM | tmp->unit); 607 DELAY(1); 608 if (!inb(tmp->controller->ioaddr+ATA_STATUS)&ATA_S_DSC) 609 atapi_request = NULL; 610 break; 611 } 612 } |
613 } |
614 if (!atapi_request) { 615 timeout((timeout_t *)ata_start, atp->controller, interval++); 616 return; 617 } 618 else 619 interval = 1; |
620 } |
621 TAILQ_REMOVE(&scp->atapi_queue, atapi_request, chain); 622 scp->active = ATA_ACTIVE_ATAPI; 623 scp->running = atapi_request; 624 atapi_transfer(atapi_request); 625#ifdef ATA_DEBUG 626 printf("ata_start: started atapi, leaving\n"); 627#endif 628 return; --- 11 unchanged lines hidden (view full) --- 640 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | ATA_MASTER); 641 DELAY(1); 642 inb(scp->ioaddr + ATA_STATUS); 643 outb(scp->altioaddr, ATA_A_IDS | ATA_A_RESET); 644 DELAY(10000); 645 outb(scp->altioaddr, ATA_A_IDS); 646 DELAY(10000); 647 inb(scp->ioaddr + ATA_ERROR); |
648 DELAY(3000); |
649 650 /* wait for BUSY to go inactive */ |
651 for (timeout = 0; timeout < 310000; timeout++) { |
652 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | ATA_MASTER); 653 DELAY(1); 654 status0 = inb(scp->ioaddr + ATA_STATUS); 655 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | ATA_SLAVE); 656 DELAY(1); 657 status1 = inb(scp->ioaddr + ATA_STATUS); 658 if (*mask == 0x01) /* wait for master only */ |
659 if (!(status0 & ATA_S_BUSY)) |
660 break; 661 if (*mask == 0x02) /* wait for slave only */ |
662 if (!(status1 & ATA_S_BUSY)) |
663 break; 664 if (*mask == 0x03) /* wait for both master & slave */ |
665 if (!(status0 & ATA_S_BUSY) && !(status1 & ATA_S_BUSY)) |
666 break; 667 DELAY(100); 668 } |
669 DELAY(1); 670 outb(scp->altioaddr, ATA_A_4BIT); 671 if (status0 & ATA_S_BUSY) |
672 *mask &= ~0x01; |
673 if (status1 & ATA_S_BUSY) |
674 *mask &= ~0x02; 675 if (bootverbose) 676 printf("ata%d: mask=%02x status0=%02x status1=%02x\n", 677 scp->lun, *mask, status0, status1); 678} 679 680int32_t 681ata_reinit(struct ata_softc *scp) 682{ |
683 int32_t mask = 0, omask; |
684 |
685 scp->active = ATA_REINITING; 686 scp->running = NULL; |
687 printf("ata%d: resetting devices .. ", scp->lun); |
688 if (scp->devices & (ATA_ATA_MASTER | ATA_ATAPI_MASTER)) 689 mask |= 0x01; 690 if (scp->devices & (ATA_ATA_SLAVE | ATA_ATAPI_SLAVE)) 691 mask |= 0x02; |
692 omask = mask; |
693 ata_reset(scp, &mask); |
694 if (omask != mask) 695 printf(" device dissapeared! %d ", omask & ~mask); |
696 697#if NATADISK > 0 |
698 if (scp->devices & (ATA_ATA_MASTER) && scp->dev_softc[0]) |
699 ad_reinit((struct ad_softc *)scp->dev_softc[0]); |
700 if (scp->devices & (ATA_ATA_SLAVE) && scp->dev_softc[1]) |
701 ad_reinit((struct ad_softc *)scp->dev_softc[1]); 702#endif 703#if NATAPICD > 0 || NATAPIFD > 0 || NATAPIST > 0 |
704 if (scp->devices & (ATA_ATAPI_MASTER) && scp->dev_softc[0]) |
705 atapi_reinit((struct atapi_softc *)scp->dev_softc[0]); |
706 if (scp->devices & (ATA_ATAPI_SLAVE) && scp->dev_softc[1]) |
707 atapi_reinit((struct atapi_softc *)scp->dev_softc[1]); 708#endif 709 printf("done\n"); |
710 scp->active = ATA_IDLE; |
711 ata_start(scp); 712 return 0; 713} 714 715int32_t 716ata_wait(struct ata_softc *scp, int32_t device, u_int8_t mask) 717{ 718 u_int8_t status; --- 8 unchanged lines hidden (view full) --- 727 scp->lun, device?"slave":"master"); 728 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | device); 729 DELAY(1); 730 status = inb(scp->ioaddr + ATA_STATUS); 731 } 732 if (status == 0xff) 733 return -1; 734 scp->status = status; |
735 if (!(status & ATA_S_BUSY)) { |
736 if (status & ATA_S_ERROR) 737 scp->error = inb(scp->ioaddr + ATA_ERROR); 738 if ((status & mask) == mask) 739 return (status & ATA_S_ERROR); 740 } 741 if (timeout > 1000) { 742 timeout += 1000; 743 DELAY(1000); --- 15 unchanged lines hidden (view full) --- 759 printf("ata%d: ata_command: addr=%04x, device=%02x, cmd=%02x, " 760 "c=%d, h=%d, s=%d, count=%d, flags=%02x\n", 761 scp->lun, scp->ioaddr, device, command, 762 cylinder, head, sector, count, flags); 763#endif 764 765 /* ready to issue command ? */ 766 if (ata_wait(scp, device, 0) < 0) { |
767 printf("ata%d-%s: timeout waiting to give command=%02x s=%02x e=%02x\n", 768 scp->lun, device ? "slave" : "master", command, 769 scp->status, scp->error); 770 return -1; |
771 } 772 outb(scp->ioaddr + ATA_FEATURE, feature); 773 outb(scp->ioaddr + ATA_CYL_LSB, cylinder); 774 outb(scp->ioaddr + ATA_CYL_MSB, cylinder >> 8); 775 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | device | head); 776 outb(scp->ioaddr + ATA_SECTOR, sector); 777 outb(scp->ioaddr + ATA_COUNT, count); 778 |
779 switch (flags) { 780 case ATA_WAIT_INTR: |
781 if (scp->active != ATA_IDLE) 782 printf("DANGER wait_intr active=%s\n", active2str(scp->active)); |
783 scp->active = ATA_WAIT_INTR; 784 outb(scp->ioaddr + ATA_CMD, command); 785 if (tsleep((caddr_t)scp, PRIBIO, "atacmd", 500)) { 786 printf("ata_command: timeout waiting for interrupt\n"); 787 scp->active = ATA_IDLE; 788 return -1; 789 } 790 break; 791 792 case ATA_IGNORE_INTR: |
793 if (scp->active != ATA_IDLE && scp->active != ATA_REINITING) 794 printf("DANGER ignore_intr active=%s\n", active2str(scp->active)); 795 if (scp->active != ATA_REINITING) 796 scp->active = ATA_IGNORE_INTR; |
797 outb(scp->ioaddr + ATA_CMD, command); 798 break; 799 800 case ATA_IMMEDIATE: |
801 outb(scp->ioaddr + ATA_CMD, command); 802 break; |
803 804 default: 805 printf("DANGER illegal interrupt flag=%s\n", active2str(flags)); |
806 } 807#ifdef ATA_DEBUG 808 printf("ata_command: leaving\n"); 809#endif 810 return 0; 811} 812 813int8_t * 814ata_mode2str(int32_t mode) 815{ 816 switch (mode) { 817 case ATA_MODE_PIO: 818 return "PIO"; |
819 case ATA_MODE_WDMA2: |
820 return "DMA"; |
821 case ATA_MODE_UDMA2: |
822 return "UDMA33"; |
823 case ATA_MODE_UDMA3: 824 return "UDMA3"; 825 case ATA_MODE_UDMA4: |
826 return "UDMA66"; 827 default: 828 return "???"; 829 } 830} 831 |
832static int8_t * 833active2str(int32_t active) 834{ 835 switch (active) { 836 case ATA_IDLE: 837 return("ATA_IDLE"); 838 case ATA_WAIT_INTR: 839 return("ATA_WAIT_INTR"); 840 case ATA_IGNORE_INTR: 841 return("ATA_IGNORE_INTR"); 842 case ATA_ACTIVE_ATA: 843 return("ATA_ACTIVE_ATA"); 844 case ATA_ACTIVE_ATAPI: 845 return("ATA_ACTIVE_ATAPI"); 846 case ATA_REINITING: 847 return("ATA_REINITING"); 848 default: 849 return("UNKNOWN"); 850 } 851} 852 |
853void 854bswap(int8_t *buf, int32_t len) 855{ 856 u_int16_t *p = (u_int16_t*)(buf + len); 857 858 while (--p >= (u_int16_t*)buf) 859 *p = ntohs(*p); 860} --- 34 unchanged lines hidden --- |