Deleted Added
full compact
ata-all.c (54788) ata-all.c (54969)
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 *
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 54788 1999-12-18 20:06:30Z sos $
28 * $FreeBSD: head/sys/dev/ata/ata-all.c 54969 1999-12-21 20:18:56Z 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"

--- 150 unchanged lines hidden (view full) ---

187
188 switch (pci_get_devid(dev)) {
189 /* supported chipsets */
190 case 0x12308086:
191 return "Intel PIIX ATA controller";
192 case 0x70108086:
193 return "Intel PIIX3 ATA controller";
194 case 0x71118086:
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"

--- 150 unchanged lines hidden (view full) ---

187
188 switch (pci_get_devid(dev)) {
189 /* supported chipsets */
190 case 0x12308086:
191 return "Intel PIIX ATA controller";
192 case 0x70108086:
193 return "Intel PIIX3 ATA controller";
194 case 0x71118086:
195 case 0x71998086:
195 return "Intel PIIX4 ATA controller";
196 case 0x522910b9:
197 return "AcerLabs Aladdin ATA controller";
198 case 0x05711106: /* 82c586 & 82c686 */
199 if (ata_find_dev(dev, 0x05861106))
200 return "VIA 82C586 ATA controller";
201 if (ata_find_dev(dev, 0x06861106))
202 return "VIA 82C686 ATA controller";
203 return "VIA Apollo ATA controller";
204 case 0x55131039:
205 return "SiS 5591 ATA controller";
196 return "Intel PIIX4 ATA controller";
197 case 0x522910b9:
198 return "AcerLabs Aladdin ATA controller";
199 case 0x05711106: /* 82c586 & 82c686 */
200 if (ata_find_dev(dev, 0x05861106))
201 return "VIA 82C586 ATA controller";
202 if (ata_find_dev(dev, 0x06861106))
203 return "VIA 82C686 ATA controller";
204 return "VIA Apollo ATA controller";
205 case 0x55131039:
206 return "SiS 5591 ATA controller";
207 case 0x74091022:
208 return "AMD 756 ATA controller";
206 case 0x4d33105a:
207 return "Promise Ultra/33 ATA controller";
208 case 0x4d38105a:
209 return "Promise Ultra/66 ATA controller";
210 case 0x00041103:
211 return "HighPoint HPT366 ATA controller";
212
213 /* unsupported but known chipsets, generic DMA only */

--- 112 unchanged lines hidden (view full) ---

326
327 case 0x4d33105a:
328 case 0x4d38105a:
329 /* the Promise's need burst mode to be turned on explicitly */
330 outb(bmaddr_1 + 0x1f, inb(bmaddr_1 + 0x1f) | 0x01);
331 break;
332
333 case 0x05711106:
209 case 0x4d33105a:
210 return "Promise Ultra/33 ATA controller";
211 case 0x4d38105a:
212 return "Promise Ultra/66 ATA controller";
213 case 0x00041103:
214 return "HighPoint HPT366 ATA controller";
215
216 /* unsupported but known chipsets, generic DMA only */

--- 112 unchanged lines hidden (view full) ---

329
330 case 0x4d33105a:
331 case 0x4d38105a:
332 /* the Promise's need burst mode to be turned on explicitly */
333 outb(bmaddr_1 + 0x1f, inb(bmaddr_1 + 0x1f) | 0x01);
334 break;
335
336 case 0x05711106:
334 /* the VIA Apollo needs some sensible defaults */
337 case 0x74091022:
338 /* the VIA 82C586, VIA 82C686 & AMD 756 needs some sensible defaults */
335 /* set prefetch, postwrite */
336 pci_write_config(dev, 0x41, pci_read_config(dev, 0x41, 1) | 0xf0, 1);
337
338 /* set fifo configuration half'n'half */
339 pci_write_config(dev, 0x43,
340 (pci_read_config(dev, 0x43, 1) & 0x90) | 0x2a, 1);
341
342 /* set status register read retry */

--- 130 unchanged lines hidden (view full) ---

473 if (scp == NULL) {
474 printf("ata%d: failed to allocate driver storage\n", lun);
475 return 0;
476 }
477 bzero(scp, sizeof(struct ata_softc));
478
479 scp->ioaddr = ioaddr;
480 scp->altioaddr = altioaddr;
339 /* set prefetch, postwrite */
340 pci_write_config(dev, 0x41, pci_read_config(dev, 0x41, 1) | 0xf0, 1);
341
342 /* set fifo configuration half'n'half */
343 pci_write_config(dev, 0x43,
344 (pci_read_config(dev, 0x43, 1) & 0x90) | 0x2a, 1);
345
346 /* set status register read retry */

--- 130 unchanged lines hidden (view full) ---

477 if (scp == NULL) {
478 printf("ata%d: failed to allocate driver storage\n", lun);
479 return 0;
480 }
481 bzero(scp, sizeof(struct ata_softc));
482
483 scp->ioaddr = ioaddr;
484 scp->altioaddr = altioaddr;
485 scp->bmaddr = bmaddr;
481 scp->lun = lun;
482 scp->unit = *unit;
483 scp->active = ATA_IDLE;
484
485 if (bootverbose)
486 scp->lun = lun;
487 scp->unit = *unit;
488 scp->active = ATA_IDLE;
489
490 if (bootverbose)
486 printf("ata%d: iobase=0x%04x altiobase=0x%04x\n",
487 scp->lun, scp->ioaddr, scp->altioaddr);
491 printf("ata%d: iobase=0x%04x altiobase=0x%04x bmaddr=0x%04x\n",
492 scp->lun, scp->ioaddr, scp->altioaddr, scp->bmaddr);
488
493
489
490 /* do we have any signs of ATA/ATAPI HW being present ? */
491 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | ATA_MASTER);
492 DELAY(1);
493 status0 = inb(scp->ioaddr + ATA_STATUS);
494 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | ATA_SLAVE);
495 DELAY(1);
496 status1 = inb(scp->ioaddr + ATA_STATUS);
497 if ((status0 & 0xf8) != 0xf8)

--- 54 unchanged lines hidden (view full) ---

552 if (!scp->devices) {
553 free(scp, M_DEVBUF);
554 return 0;
555 }
556 TAILQ_INIT(&scp->ata_queue);
557 TAILQ_INIT(&scp->atapi_queue);
558 *unit = scp->lun;
559 scp->dev = dev;
494 /* do we have any signs of ATA/ATAPI HW being present ? */
495 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | ATA_MASTER);
496 DELAY(1);
497 status0 = inb(scp->ioaddr + ATA_STATUS);
498 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | ATA_SLAVE);
499 DELAY(1);
500 status1 = inb(scp->ioaddr + ATA_STATUS);
501 if ((status0 & 0xf8) != 0xf8)

--- 54 unchanged lines hidden (view full) ---

556 if (!scp->devices) {
557 free(scp, M_DEVBUF);
558 return 0;
559 }
560 TAILQ_INIT(&scp->ata_queue);
561 TAILQ_INIT(&scp->atapi_queue);
562 *unit = scp->lun;
563 scp->dev = dev;
560 if (bmaddr)
561 scp->bmaddr = bmaddr;
562 atadevices[scp->lun] = scp;
563#if NAPM > 0
564 scp->resume_hook.ah_fun = (void *)ata_reinit;
565 scp->resume_hook.ah_arg = scp;
566 scp->resume_hook.ah_name = "ATA driver";
567 scp->resume_hook.ah_order = APM_MID_ORDER;
568 apm_hook_establish(APM_HOOK_RESUME, &scp->resume_hook);
569#endif

--- 59 unchanged lines hidden (view full) ---

629}
630
631void
632ata_start(struct ata_softc *scp)
633{
634 struct ad_request *ad_request;
635 struct atapi_request *atapi_request;
636
564 atadevices[scp->lun] = scp;
565#if NAPM > 0
566 scp->resume_hook.ah_fun = (void *)ata_reinit;
567 scp->resume_hook.ah_arg = scp;
568 scp->resume_hook.ah_name = "ATA driver";
569 scp->resume_hook.ah_order = APM_MID_ORDER;
570 apm_hook_establish(APM_HOOK_RESUME, &scp->resume_hook);
571#endif

--- 59 unchanged lines hidden (view full) ---

631}
632
633void
634ata_start(struct ata_softc *scp)
635{
636 struct ad_request *ad_request;
637 struct atapi_request *atapi_request;
638
637#ifdef ATA_DEBUG
638 printf("ata_start: entered\n");
639#endif
640 if (scp->active != ATA_IDLE)
641 return;
642
643#if NATADISK > 0
644 /* find & call the responsible driver if anything on the ATA queue */
645 if ((ad_request = TAILQ_FIRST(&scp->ata_queue))) {
646 TAILQ_REMOVE(&scp->ata_queue, ad_request, chain);
647 scp->active = ATA_ACTIVE_ATA;
648 scp->running = ad_request;
649 ad_transfer(ad_request);
639 if (scp->active != ATA_IDLE)
640 return;
641
642#if NATADISK > 0
643 /* find & call the responsible driver if anything on the ATA queue */
644 if ((ad_request = TAILQ_FIRST(&scp->ata_queue))) {
645 TAILQ_REMOVE(&scp->ata_queue, ad_request, chain);
646 scp->active = ATA_ACTIVE_ATA;
647 scp->running = ad_request;
648 ad_transfer(ad_request);
650#ifdef ATA_DEBUG
651 printf("ata_start: started ata, leaving\n");
652#endif
653 return;
654 }
655#endif
656#if NATAPICD > 0 || NATAPIFD > 0 || NATAPIST > 0
657 /*
658 * find & call the responsible driver if anything on the ATAPI queue.
659 * check for device busy by polling the DSC bit, if busy, check
660 * for requests to the other device on the channel (if any).

--- 27 unchanged lines hidden (view full) ---

688 }
689 else
690 interval = 1;
691 }
692 TAILQ_REMOVE(&scp->atapi_queue, atapi_request, chain);
693 scp->active = ATA_ACTIVE_ATAPI;
694 scp->running = atapi_request;
695 atapi_transfer(atapi_request);
649 return;
650 }
651#endif
652#if NATAPICD > 0 || NATAPIFD > 0 || NATAPIST > 0
653 /*
654 * find & call the responsible driver if anything on the ATAPI queue.
655 * check for device busy by polling the DSC bit, if busy, check
656 * for requests to the other device on the channel (if any).

--- 27 unchanged lines hidden (view full) ---

684 }
685 else
686 interval = 1;
687 }
688 TAILQ_REMOVE(&scp->atapi_queue, atapi_request, chain);
689 scp->active = ATA_ACTIVE_ATAPI;
690 scp->running = atapi_request;
691 atapi_transfer(atapi_request);
696#ifdef ATA_DEBUG
697 printf("ata_start: started atapi, leaving\n");
698#endif
699 return;
700 }
701#endif
702}
703
704void
705ata_reset(struct ata_softc *scp, int32_t *mask)
706{

--- 171 unchanged lines hidden (view full) ---

878
879 case ATA_IMMEDIATE:
880 outb(scp->ioaddr + ATA_CMD, command);
881 break;
882
883 default:
884 printf("DANGER: illegal interrupt flag=%s\n", active2str(flags));
885 }
692 return;
693 }
694#endif
695}
696
697void
698ata_reset(struct ata_softc *scp, int32_t *mask)
699{

--- 171 unchanged lines hidden (view full) ---

871
872 case ATA_IMMEDIATE:
873 outb(scp->ioaddr + ATA_CMD, command);
874 break;
875
876 default:
877 printf("DANGER: illegal interrupt flag=%s\n", active2str(flags));
878 }
886#ifdef ATA_DEBUG
887 printf("ata_command: leaving\n");
888#endif
889 return 0;
890}
891
892int8_t *
893ata_mode2str(int32_t mode)
894{
895 switch (mode) {
896 case ATA_MODE_PIO:

--- 75 unchanged lines hidden ---
879 return 0;
880}
881
882int8_t *
883ata_mode2str(int32_t mode)
884{
885 switch (mode) {
886 case ATA_MODE_PIO:

--- 75 unchanged lines hidden ---