Deleted Added
full compact
ata-all.c (181753) ata-all.c (183724)
1/*-
2 * Copyright (c) 1998 - 2008 S�ren Schmidt <sos@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) 1998 - 2008 S�ren Schmidt <sos@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/dev/ata/ata-all.c 181753 2008-08-15 10:55:11Z philip $");
28__FBSDID("$FreeBSD: head/sys/dev/ata/ata-all.c 183724 2008-10-09 12:56:57Z sos $");
29
30#include "opt_ata.h"
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/ata.h>
34#include <sys/kernel.h>
35#include <sys/module.h>
36#include <sys/endian.h>

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

611 ata_queue_request(request);
612 error = request->result;
613 ata_free_request(request);
614 }
615
616 if (!error && (isprint(atadev->param.model[0]) ||
617 isprint(atadev->param.model[1]))) {
618 struct ata_params *atacap = &atadev->param;
29
30#include "opt_ata.h"
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/ata.h>
34#include <sys/kernel.h>
35#include <sys/module.h>
36#include <sys/endian.h>

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

611 ata_queue_request(request);
612 error = request->result;
613 ata_free_request(request);
614 }
615
616 if (!error && (isprint(atadev->param.model[0]) ||
617 isprint(atadev->param.model[1]))) {
618 struct ata_params *atacap = &atadev->param;
619 char buffer[64];
620 int16_t *ptr;
621
622 for (ptr = (int16_t *)atacap;
623 ptr < (int16_t *)atacap + sizeof(struct ata_params)/2; ptr++) {
624 *ptr = le16toh(*ptr);
625 }
626 if (!(!strncmp(atacap->model, "FX", 2) ||
627 !strncmp(atacap->model, "NEC", 3) ||

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

643 device_get_unit(ch->dev),
644 ata_unit2str(atadev),
645 ata_mode2str(ata_pmode(atacap)),
646 ata_mode2str(ata_wmode(atacap)),
647 ata_mode2str(ata_umode(atacap)),
648 (atacap->hwres & ATA_CABLE_ID) ? "80":"40");
649
650 if (init) {
619 int16_t *ptr;
620
621 for (ptr = (int16_t *)atacap;
622 ptr < (int16_t *)atacap + sizeof(struct ata_params)/2; ptr++) {
623 *ptr = le16toh(*ptr);
624 }
625 if (!(!strncmp(atacap->model, "FX", 2) ||
626 !strncmp(atacap->model, "NEC", 3) ||

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

642 device_get_unit(ch->dev),
643 ata_unit2str(atadev),
644 ata_mode2str(ata_pmode(atacap)),
645 ata_mode2str(ata_wmode(atacap)),
646 ata_mode2str(ata_umode(atacap)),
647 (atacap->hwres & ATA_CABLE_ID) ? "80":"40");
648
649 if (init) {
650 char buffer[64];
651
651 sprintf(buffer, "%.40s/%.8s", atacap->model, atacap->revision);
652 device_set_desc_copy(atadev->dev, buffer);
653 if ((atadev->param.config & ATA_PROTO_ATAPI) &&
654 (atadev->param.config != ATA_CFA_MAGIC1) &&
655 (atadev->param.config != ATA_CFA_MAGIC2)) {
656 if (atapi_dma &&
657 (atadev->param.config & ATA_DRQ_MASK) != ATA_DRQ_INTR &&
658 ata_umode(&atadev->param) >= ATA_UDMA2)

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

672 }
673 return error;
674}
675
676int
677ata_identify(device_t dev)
678{
679 struct ata_channel *ch = device_get_softc(dev);
652 sprintf(buffer, "%.40s/%.8s", atacap->model, atacap->revision);
653 device_set_desc_copy(atadev->dev, buffer);
654 if ((atadev->param.config & ATA_PROTO_ATAPI) &&
655 (atadev->param.config != ATA_CFA_MAGIC1) &&
656 (atadev->param.config != ATA_CFA_MAGIC2)) {
657 if (atapi_dma &&
658 (atadev->param.config & ATA_DRQ_MASK) != ATA_DRQ_INTR &&
659 ata_umode(&atadev->param) >= ATA_UDMA2)

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

673 }
674 return error;
675}
676
677int
678ata_identify(device_t dev)
679{
680 struct ata_channel *ch = device_get_softc(dev);
680 struct ata_device *devices[ATA_PM];
681 device_t childdevs[ATA_PM];
681 struct ata_device *atadev;
682 device_t child;
682 int i;
683
684 if (bootverbose)
685 device_printf(dev, "identify ch->devices=%08x\n", ch->devices);
686
687 for (i = 0; i < ATA_PM; ++i) {
688 if (ch->devices & (((ATA_ATA_MASTER | ATA_ATAPI_MASTER) << i))) {
689 int unit = -1;
690
683 int i;
684
685 if (bootverbose)
686 device_printf(dev, "identify ch->devices=%08x\n", ch->devices);
687
688 for (i = 0; i < ATA_PM; ++i) {
689 if (ch->devices & (((ATA_ATA_MASTER | ATA_ATAPI_MASTER) << i))) {
690 int unit = -1;
691
691 if (!(devices[i] = malloc(sizeof(struct ata_device),
692 M_ATA, M_NOWAIT | M_ZERO))) {
692 if (!(atadev = malloc(sizeof(struct ata_device),
693 M_ATA, M_NOWAIT | M_ZERO))) {
693 device_printf(dev, "out of memory\n");
694 return ENOMEM;
695 }
694 device_printf(dev, "out of memory\n");
695 return ENOMEM;
696 }
696 devices[i]->unit = i;
697 atadev->unit = i;
697#ifdef ATA_STATIC_ID
698 if (ch->devices & ((ATA_ATA_MASTER << i)))
699 unit = (device_get_unit(dev) << 1) + i;
700#endif
698#ifdef ATA_STATIC_ID
699 if (ch->devices & ((ATA_ATA_MASTER << i)))
700 unit = (device_get_unit(dev) << 1) + i;
701#endif
701 if (!(childdevs[i] = ata_add_child(dev, devices[i], unit))) {
702 free(devices[i], M_ATA);
703 devices[i]=NULL;
704 }
705 else {
706 if (ata_getparam(devices[i], 1)) {
707 device_delete_child(dev, childdevs[i]);
708 free(devices[i], M_ATA);
709 childdevs[i] = NULL;
710 devices[i] = NULL;
702 if ((child = ata_add_child(dev, atadev, unit))) {
703 if (ata_getparam(atadev, 1)) {
704 device_delete_child(dev, child);
705 free(atadev, M_ATA);
711 }
712 }
706 }
707 }
708 else
709 free(atadev, M_ATA);
713 }
710 }
714 devices[i] = NULL;
715 childdevs[i] = NULL;
716 }
711 }
717
718 bus_generic_probe(dev);
719 bus_generic_attach(dev);
720 return 0;
721}
722
723void
724ata_default_registers(device_t dev)
725{

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

890 if (mode & ATA_DMA_MASK)
891 return "BIOSDMA";
892 else
893 return "BIOSPIO";
894 }
895}
896
897int
712 bus_generic_probe(dev);
713 bus_generic_attach(dev);
714 return 0;
715}
716
717void
718ata_default_registers(device_t dev)
719{

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

884 if (mode & ATA_DMA_MASK)
885 return "BIOSDMA";
886 else
887 return "BIOSPIO";
888 }
889}
890
891int
892ata_atapi(device_t dev)
893{
894 struct ata_channel *ch = device_get_softc(device_get_parent(dev));
895 struct ata_device *atadev = device_get_softc(dev);
896
897 return ((atadev->unit == ATA_MASTER && ch->devices & ATA_ATAPI_MASTER) ||
898 (atadev->unit == ATA_SLAVE && ch->devices & ATA_ATAPI_SLAVE));
899}
900
901int
898ata_pmode(struct ata_params *ap)
899{
900 if (ap->atavalid & ATA_FLAG_64_70) {
901 if (ap->apiomodes & 0x02)
902 return ATA_PIO4;
903 if (ap->apiomodes & 0x01)
904 return ATA_PIO3;
905 }

--- 175 unchanged lines hidden ---
902ata_pmode(struct ata_params *ap)
903{
904 if (ap->atavalid & ATA_FLAG_64_70) {
905 if (ap->apiomodes & 0x02)
906 return ATA_PIO4;
907 if (ap->apiomodes & 0x01)
908 return ATA_PIO3;
909 }

--- 175 unchanged lines hidden ---