diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2007-02-19 11:53:35 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2007-02-19 11:53:35 +0000 |
commit | d0788a6541abc4f2326c60e9a61b56ce013bf0c0 (patch) | |
tree | d904f3b7bb33fb1b27e9264877ce6173431d8f06 /sys | |
parent | ba9fe1788e998566b683be13eaf4a19db27b32e6 (diff) |
implement the start of the framework for scsi emulation of ata disks
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ata/atascsi.c | 107 | ||||
-rw-r--r-- | sys/dev/ata/atascsi.h | 10 |
2 files changed, 109 insertions, 8 deletions
diff --git a/sys/dev/ata/atascsi.c b/sys/dev/ata/atascsi.c index 670dce2ac54..e38f54a7d54 100644 --- a/sys/dev/ata/atascsi.c +++ b/sys/dev/ata/atascsi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atascsi.c,v 1.2 2007/02/19 11:48:34 dlg Exp $ */ +/* $OpenBSD: atascsi.c,v 1.3 2007/02/19 11:53:34 dlg Exp $ */ /* * Copyright (c) 2007 David Gwynne <dlg@openbsd.org> @@ -26,6 +26,7 @@ #include <sys/queue.h> #include <scsi/scsi_all.h> +#include <scsi/scsi_disk.h> #include <scsi/scsiconf.h> #include <dev/ata/atascsi.h> @@ -34,7 +35,7 @@ struct atascsi { struct device *as_dev; void *as_cookie; - int *as_ports; + struct ata_port **as_ports; struct atascsi_methods *as_methods; struct scsi_adapter as_switch; @@ -59,6 +60,16 @@ struct scsi_device atascsi_device = { NULL, NULL, NULL, NULL }; +int atascsi_disk_cmd(struct scsi_xfer *); +int atascsi_disk_inq(struct scsi_xfer *); +int atascsi_disk_capacity(struct scsi_xfer *); +int atascsi_disk_sync(struct scsi_xfer *); +int atascsi_disk_sense(struct scsi_xfer *); + +int atascsi_atapi_cmd(struct scsi_xfer *); + +int atascsi_stuffup(struct scsi_xfer *); + struct atascsi * atascsi_attach(struct device *self, struct atascsi_attach_args *aaa) { @@ -86,7 +97,7 @@ atascsi_attach(struct device *self, struct atascsi_attach_args *aaa) as->as_link.adapter_target = aaa->aaa_nports; as->as_link.openings = aaa->aaa_ncmds; - as->as_ports = malloc(sizeof(int) * aaa->aaa_nports, + as->as_ports = malloc(sizeof(struct ata_port *) * aaa->aaa_nports, M_DEVBUF, M_WAITOK); bzero(as->as_ports, sizeof(int) * aaa->aaa_nports); @@ -116,7 +127,9 @@ atascsi_probe(struct atascsi *as, int port) if (port > as->as_link.adapter_buswidth) return (ENXIO); +#if 0 as->as_ports[port] = as->as_methods->probe(as->as_cookie, port); +#endif return (0); } @@ -124,6 +137,94 @@ atascsi_probe(struct atascsi *as, int port) int atascsi_cmd(struct scsi_xfer *xs) { + struct scsi_link *link = xs->sc_link; + struct atascsi *as = link->adapter_softc; + struct ata_port *ap = as->as_ports[link->target]; + + if (ap == NULL) + return (atascsi_stuffup(xs)); + + switch (ap->ap_type) { + case ATA_PORT_T_DISK: + return (atascsi_disk_cmd(xs)); + case ATA_PORT_T_ATAPI: + return (atascsi_atapi_cmd(xs)); + + case ATA_PORT_T_NONE: + default: + return (atascsi_stuffup(xs)); + } +} + +int +atascsi_disk_cmd(struct scsi_xfer *xs) +{ +#if 0 + struct scsi_link *link = xs->sc_link; + struct atascsi *as = link->adapter_softc; + struct ata_port *ap = as->as_ports[link->target]; + int s; +#endif + + switch (xs->cmd->opcode) { + case READ_BIG: + case WRITE_BIG: + case READ_COMMAND: + case WRITE_COMMAND: + /* deal with io outside the switch */ + break; + + case SYNCHRONIZE_CACHE: + return (atascsi_disk_sync(xs)); + case REQUEST_SENSE: + return (atascsi_disk_sense(xs)); + case INQUIRY: + return (atascsi_disk_inq(xs)); + case READ_CAPACITY: + return (atascsi_disk_capacity(xs)); + + case TEST_UNIT_READY: + case START_STOP: + case PREVENT_ALLOW: + return (COMPLETE); + + default: + return (atascsi_stuffup(xs)); + } + + return (atascsi_stuffup(xs)); +} + +int +atascsi_disk_inq(struct scsi_xfer *xs) +{ + return (atascsi_stuffup(xs)); +} +int +atascsi_disk_sync(struct scsi_xfer *xs) +{ + return (atascsi_stuffup(xs)); +} +int +atascsi_disk_sense(struct scsi_xfer *xs) +{ + return (atascsi_stuffup(xs)); +} +int +atascsi_disk_capacity(struct scsi_xfer *xs) +{ + return (atascsi_stuffup(xs)); +} + +int +atascsi_atapi_cmd(struct scsi_xfer *xs) +{ + return (atascsi_stuffup(xs)); +} + +int +atascsi_stuffup(struct scsi_xfer *xs) +{ int s; xs->error = XS_DRIVER_STUFFUP; diff --git a/sys/dev/ata/atascsi.h b/sys/dev/ata/atascsi.h index 04d8d0baa3b..70b72ffc4a5 100644 --- a/sys/dev/ata/atascsi.h +++ b/sys/dev/ata/atascsi.h @@ -1,4 +1,4 @@ -/* $OpenBSD: atascsi.h,v 1.2 2007/02/19 11:48:34 dlg Exp $ */ +/* $OpenBSD: atascsi.h,v 1.3 2007/02/19 11:53:34 dlg Exp $ */ /* * Copyright (c) 2007 David Gwynne <dlg@openbsd.org> @@ -33,11 +33,11 @@ struct atascsi_attach_args { int aaa_ncmds; }; -struct atascsi_port { +struct ata_port { int ap_type; -#define ATABUS_PORT_T_NONE 0 -#define ATABUS_PORT_T_DISK 1 -#define ATABUS_PORT_T_ATAPI 2 +#define ATA_PORT_T_NONE 0 +#define ATA_PORT_T_DISK 1 +#define ATA_PORT_T_ATAPI 2 }; struct ata_xfer { |