Thomas,
Attached are patches for atapicam for ATA-MKIII. I've only done light
testing, but they seem to work as expected. They work both as a module
and compiled into the kernel.
Scott
Index: ata-all.c
===
RCS file: /usr/ncvs/src/sys/dev/ata/ata-all.c,v
retrieving revision 1.236
diff -u -r1.236 ata-all.c
--- ata-all.c 30 Mar 2005 12:03:37 - 1.236
+++ ata-all.c 31 Mar 2005 10:08:47 -
@@ -142,6 +142,8 @@
return error;
}
+device_add_child(dev, "atapicam", -1);
+
/* do not attach devices if we are in early boot */
if (ata_delayed_attach)
return 0;
Index: ata-all.h
===
RCS file: /usr/ncvs/src/sys/dev/ata/ata-all.h,v
retrieving revision 1.88
diff -u -r1.88 ata-all.h
--- ata-all.h 30 Mar 2005 12:03:37 - 1.88
+++ ata-all.h 31 Mar 2005 08:05:36 -
@@ -270,6 +270,7 @@
int unit; /* physical unit */
#define ATA_MASTER 0x00
#define ATA_SLAVE 0x10
+#defineATA_ATAPI_CAM 0x100
struct ata_params param; /* ata param structure */
int mode; /* current transfermode */
Index: atapi-cam.c
===
RCS file: /usr/ncvs/src/sys/dev/ata/atapi-cam.c,v
retrieving revision 1.35
diff -u -r1.35 atapi-cam.c
--- atapi-cam.c 17 Jun 2004 07:29:56 - 1.35
+++ atapi-cam.c 31 Mar 2005 10:08:36 -
@@ -40,6 +40,7 @@
#include
#include
#include
+#include
#include
#include
@@ -51,6 +52,23 @@
#include
#include
+#include
+
+/* private data associated with an ATA bus */
+struct atapi_xpt_softc {
+struct ata_device atapi_cam_dev; /* must be first */
+device_t dev;
+device_t parent;
+struct ata_channel *ata_ch;
+struct cam_path*path;
+struct cam_sim *sim;
+intflags;
+#define BUS_REGISTERED 0x01
+#define RESOURCE_SHORTAGE 0x02
+
+TAILQ_HEAD(,atapi_hcb) pending_hcbs;
+struct ata_device *atadev[2];
+};
/* hardware command descriptor block */
struct atapi_hcb {
@@ -67,23 +85,13 @@
TAILQ_ENTRY(atapi_hcb) chain;
};
-/* private data associated with an ATA bus */
-struct atapi_xpt_softc {
-struct ata_channel *ata_ch;
-struct cam_path*path;
-struct cam_sim *sim;
-intflags;
-#define BUS_REGISTERED 0x01
-#define RESOURCE_SHORTAGE 0x02
-
-TAILQ_HEAD(,atapi_hcb) pending_hcbs;
-LIST_ENTRY(atapi_xpt_softc) chain;
-};
-
enum reinit_reason { BOOT_ATTACH, ATTACH, RESET };
-static struct mtx atapicam_softc_mtx;
-static LIST_HEAD(,atapi_xpt_softc) all_buses =
LIST_HEAD_INITIALIZER(all_buses);
+/* Device methods */
+static int atapi_cam_probe(device_t dev);
+static int atapi_cam_attach(device_t dev);
+static int atapi_cam_detach(device_t dev);
+static int atapi_cam_reinit(device_t dev);
/* CAM XPT methods */
static void atapi_action(struct cam_sim *, union ccb *);
@@ -94,7 +102,6 @@
/* internal functions */
static void reinit_bus(struct atapi_xpt_softc *scp, enum reinit_reason reason);
-static void setup_dev(struct atapi_xpt_softc *, struct ata_device *);
static void setup_async_cb(struct atapi_xpt_softc *, uint32_t);
static void cam_rescan_callback(struct cam_periph *, union ccb *);
static void cam_rescan(struct cam_sim *);
@@ -102,64 +109,85 @@
static struct atapi_hcb *allocate_hcb(struct atapi_xpt_softc *, int, int,
union ccb *);
static void free_hcb(struct atapi_hcb *hcb);
static void free_softc(struct atapi_xpt_softc *scp);
-static struct atapi_xpt_softc *get_softc(struct ata_channel *ata_ch);
-static struct ata_device *get_ata_device(struct atapi_xpt_softc *scp, int id);
static MALLOC_DEFINE(M_ATACAM, "ATA CAM transport", "ATA driver CAM-XPT
layer");
-void
-atapi_cam_attach_bus(struct ata_channel *ata_ch)
+static device_method_t atapi_cam_methods[] = {
+ DEVMETHOD(device_probe, atapi_cam_probe),
+ DEVMETHOD(device_attach,atapi_cam_attach),
+ DEVMETHOD(device_detach,atapi_cam_detach),
+ DEVMETHOD(ata_reinit, atapi_cam_reinit),
+ {0, 0}
+};
+
+static driver_t atapi_cam_driver = {
+ "atapicam",
+ atapi_cam_methods,
+ sizeof(struct atapi_xpt_softc)
+};
+
+static devclass_t atapi_cam_devclass;
+DRIVER_MODULE(atapicam, ata, atapi_cam_driver, atapi_cam_devclass, 0, 0);
+DRIVER_MODULE(atapicam, atapci, atapi_cam_driver, atapi_cam_devclass, 0, 0);
+DRIVER_MODULE(atapicam, atacbus, atapi_cam_driver, atapi_cam_devclass, 0, 0);
+MODULE_VERSION(atapicam, 1);
+MODULE_DEPEND(atapicam, ata, 1, 1, 1);
+
+static int
+atapi_cam_probe(device_t dev)
+{
+ device_set_desc(dev, "ATAPI