ata_all.c (199178) | ata_all.c (199747) |
---|---|
1/*- 2 * Copyright (c) 2009 Alexander Motin <mav@FreeBSD.org> 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 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2009 Alexander Motin <mav@FreeBSD.org> 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 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/cam/ata/ata_all.c 199178 2009-11-11 11:10:36Z mav $"); | 28__FBSDID("$FreeBSD: head/sys/cam/ata/ata_all.c 199747 2009-11-24 12:47:58Z mav $"); |
29 30#include <sys/param.h> 31 32#ifdef _KERNEL 33#include <opt_scsi.h> 34 35#include <sys/systm.h> 36#include <sys/libkern.h> --- 449 unchanged lines hidden (view full) --- 486 return ATA_UDMA1; 487 if (ap->udmamodes & 0x01) 488 return ATA_UDMA0; 489 } 490 return -1; 491} 492 493int | 29 30#include <sys/param.h> 31 32#ifdef _KERNEL 33#include <opt_scsi.h> 34 35#include <sys/systm.h> 36#include <sys/libkern.h> --- 449 unchanged lines hidden (view full) --- 486 return ATA_UDMA1; 487 if (ap->udmamodes & 0x01) 488 return ATA_UDMA0; 489 } 490 return -1; 491} 492 493int |
494ata_max_mode(struct ata_params *ap, int mode, int maxmode) | 494ata_max_mode(struct ata_params *ap, int maxmode) |
495{ 496 | 495{ 496 |
497 if (maxmode && mode > maxmode) 498 mode = maxmode; | 497 if (maxmode == 0) 498 maxmode = ATA_DMA_MAX; 499 if (maxmode >= ATA_UDMA0 && ata_max_umode(ap) > 0) 500 return (min(maxmode, ata_max_umode(ap))); 501 if (maxmode >= ATA_WDMA0 && ata_max_wmode(ap) > 0) 502 return (min(maxmode, ata_max_wmode(ap))); 503 return (min(maxmode, ata_max_pmode(ap))); 504} |
499 | 505 |
500 if (mode >= ATA_UDMA0 && ata_max_umode(ap) > 0) 501 return (min(mode, ata_max_umode(ap))); | 506char * 507ata_mode2string(int mode) 508{ 509 switch (mode) { 510 case -1: return "UNSUPPORTED"; 511 case 0: return "NONE"; 512 case ATA_PIO0: return "PIO0"; 513 case ATA_PIO1: return "PIO1"; 514 case ATA_PIO2: return "PIO2"; 515 case ATA_PIO3: return "PIO3"; 516 case ATA_PIO4: return "PIO4"; 517 case ATA_WDMA0: return "WDMA0"; 518 case ATA_WDMA1: return "WDMA1"; 519 case ATA_WDMA2: return "WDMA2"; 520 case ATA_UDMA0: return "UDMA0"; 521 case ATA_UDMA1: return "UDMA1"; 522 case ATA_UDMA2: return "UDMA2"; 523 case ATA_UDMA3: return "UDMA3"; 524 case ATA_UDMA4: return "UDMA4"; 525 case ATA_UDMA5: return "UDMA5"; 526 case ATA_UDMA6: return "UDMA6"; 527 default: 528 if (mode & ATA_DMA_MASK) 529 return "BIOSDMA"; 530 else 531 return "BIOSPIO"; 532 } 533} |
502 | 534 |
503 if (mode >= ATA_WDMA0 && ata_max_wmode(ap) > 0) 504 return (min(mode, ata_max_wmode(ap))); | 535u_int 536ata_mode2speed(int mode) 537{ 538 switch (mode) { 539 case ATA_PIO0: 540 default: 541 return (3300); 542 case ATA_PIO1: 543 return (5200); 544 case ATA_PIO2: 545 return (8300); 546 case ATA_PIO3: 547 return (11100); 548 case ATA_PIO4: 549 return (16700); 550 case ATA_WDMA0: 551 return (4200); 552 case ATA_WDMA1: 553 return (13300); 554 case ATA_WDMA2: 555 return (16700); 556 case ATA_UDMA0: 557 return (16700); 558 case ATA_UDMA1: 559 return (25000); 560 case ATA_UDMA2: 561 return (33300); 562 case ATA_UDMA3: 563 return (44400); 564 case ATA_UDMA4: 565 return (66700); 566 case ATA_UDMA5: 567 return (100000); 568 case ATA_UDMA6: 569 return (133000); 570 } 571} |
505 | 572 |
506 if (mode > ata_max_pmode(ap)) 507 return (min(mode, ata_max_pmode(ap))); | 573u_int 574ata_revision2speed(int revision) 575{ 576 switch (revision) { 577 case 1: 578 default: 579 return (150000); 580 case 2: 581 return (300000); 582 case 3: 583 return (600000); 584 } 585} |
508 | 586 |
509 return (mode); | 587int 588ata_speed2revision(u_int speed) 589{ 590 switch (speed) { 591 case 150000: 592 default: 593 return (1); 594 case 300000: 595 return (2); 596 case 600000: 597 return (3); 598 } |
510} 511 512int 513ata_identify_match(caddr_t identbuffer, caddr_t table_entry) 514{ 515 struct scsi_inquiry_pattern *entry; 516 struct ata_params *ident; 517 --- 29 unchanged lines hidden --- | 599} 600 601int 602ata_identify_match(caddr_t identbuffer, caddr_t table_entry) 603{ 604 struct scsi_inquiry_pattern *entry; 605 struct ata_params *ident; 606 --- 29 unchanged lines hidden --- |