Module Name:    src
Committed By:   skrll
Date:           Mon Jan 23 08:02:55 UTC 2017

Modified Files:
        src/sys/arch/amiga/dev [netbsd-7-nhusb]: slhci_zbus.c
        src/sys/arch/mips/adm5120/dev [netbsd-7-nhusb]: ahci.c ahcivar.h
        src/sys/arch/mips/conf [netbsd-7-nhusb]: files.adm5120

Log Message:
Adapt to branch


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.1.20.1 src/sys/arch/amiga/dev/slhci_zbus.c
cvs rdiff -u -r1.12.10.1 -r1.12.10.2 src/sys/arch/mips/adm5120/dev/ahci.c
cvs rdiff -u -r1.5 -r1.5.10.1 src/sys/arch/mips/adm5120/dev/ahcivar.h
cvs rdiff -u -r1.3 -r1.3.36.1 src/sys/arch/mips/conf/files.adm5120

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amiga/dev/slhci_zbus.c
diff -u src/sys/arch/amiga/dev/slhci_zbus.c:1.1 src/sys/arch/amiga/dev/slhci_zbus.c:1.1.20.1
--- src/sys/arch/amiga/dev/slhci_zbus.c:1.1	Sat Apr 27 22:27:33 2013
+++ src/sys/arch/amiga/dev/slhci_zbus.c	Mon Jan 23 08:02:54 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: slhci_zbus.c,v 1.1 2013/04/27 22:27:33 rkujawa Exp $ */
+/*	$NetBSD: slhci_zbus.c,v 1.1.20.1 2017/01/23 08:02:54 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: slhci_zbus.c,v 1.1 2013/04/27 22:27:33 rkujawa Exp $");
+__KERNEL_RCSID(0, "$NetBSD: slhci_zbus.c,v 1.1.20.1 2017/01/23 08:02:54 skrll Exp $");
 
 /*
  * Thylacine driver.
@@ -100,7 +100,7 @@ slhci_zbus_attach(device_t parent, devic
 	zsc = device_private(self);
 	sc = &zsc->sc_sc;
 	sc->sc_dev = self;
-	sc->sc_bus.hci_private = sc;
+	sc->sc_bus.ub_hcpriv = sc;
 
 	zsc->sc_bst.base = (bus_addr_t)zap->va;
 	zsc->sc_bst.absm = &amiga_bus_stride_1;

Index: src/sys/arch/mips/adm5120/dev/ahci.c
diff -u src/sys/arch/mips/adm5120/dev/ahci.c:1.12.10.1 src/sys/arch/mips/adm5120/dev/ahci.c:1.12.10.2
--- src/sys/arch/mips/adm5120/dev/ahci.c:1.12.10.1	Tue Sep  6 20:33:07 2016
+++ src/sys/arch/mips/adm5120/dev/ahci.c	Mon Jan 23 08:02:54 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahci.c,v 1.12.10.1 2016/09/06 20:33:07 skrll Exp $	*/
+/*	$NetBSD: ahci.c,v 1.12.10.2 2017/01/23 08:02:54 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
@@ -64,14 +64,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.12.10.1 2016/09/06 20:33:07 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.12.10.2 2017/01/23 08:02:54 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/proc.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 
 #include <sys/bus.h>
 #include <machine/cpu.h>
@@ -81,6 +81,7 @@ __KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.1
 #include <dev/usb/usbdivar.h>
 #include <dev/usb/usb_mem.h>
 #include <dev/usb/usbdevs.h>
+#include <dev/usb/usbroothub.h>
 
 #include <mips/adm5120/include/adm5120reg.h>
 #include <mips/adm5120/include/adm5120var.h>
@@ -89,61 +90,54 @@ __KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.1
 #include <mips/adm5120/dev/ahcireg.h>
 #include <mips/adm5120/dev/ahcivar.h>
 
-static usbd_status	ahci_open(usbd_pipe_handle);
+static usbd_status	ahci_open(struct usbd_pipe *);
 static void		ahci_softintr(void *);
 static void		ahci_poll(struct usbd_bus *);
 static void		ahci_poll_hub(void *);
 static void		ahci_poll_device(void *arg);
-static usbd_status	ahci_allocm(struct usbd_bus *, usb_dma_t *, u_int32_t);
-static void		ahci_freem(struct usbd_bus *, usb_dma_t *);
-static usbd_xfer_handle ahci_allocx(struct usbd_bus *);
-static void		ahci_freex(struct usbd_bus *, usbd_xfer_handle);
+static struct usbd_xfer *
+			ahci_allocx(struct usbd_bus *, unsigned int);
+static void		ahci_freex(struct usbd_bus *, struct usbd_xfer *);
 
 static void		ahci_get_lock(struct usbd_bus *, kmutex_t **);
+static int		ahci_roothub_ctrl(struct usbd_bus *, usb_device_request_t *,
+    void *, int);
 
-static int		ahci_str(usb_string_descriptor_t *, int, const char *);
-
-static usbd_status	ahci_root_ctrl_transfer(usbd_xfer_handle);
-static usbd_status	ahci_root_ctrl_start(usbd_xfer_handle);
-static void		ahci_root_ctrl_abort(usbd_xfer_handle);
-static void		ahci_root_ctrl_close(usbd_pipe_handle);
-static void		ahci_root_ctrl_done(usbd_xfer_handle);
-
-static usbd_status	ahci_root_intr_transfer(usbd_xfer_handle);
-static usbd_status	ahci_root_intr_start(usbd_xfer_handle);
-static void		ahci_root_intr_abort(usbd_xfer_handle);
-static void		ahci_root_intr_close(usbd_pipe_handle);
-static void		ahci_root_intr_done(usbd_xfer_handle);
-
-static usbd_status	ahci_device_ctrl_transfer(usbd_xfer_handle);
-static usbd_status	ahci_device_ctrl_start(usbd_xfer_handle);
-static void		ahci_device_ctrl_abort(usbd_xfer_handle);
-static void		ahci_device_ctrl_close(usbd_pipe_handle);
-static void		ahci_device_ctrl_done(usbd_xfer_handle);
-
-static usbd_status	ahci_device_intr_transfer(usbd_xfer_handle);
-static usbd_status	ahci_device_intr_start(usbd_xfer_handle);
-static void		ahci_device_intr_abort(usbd_xfer_handle);
-static void		ahci_device_intr_close(usbd_pipe_handle);
-static void		ahci_device_intr_done(usbd_xfer_handle);
-
-static usbd_status	ahci_device_isoc_transfer(usbd_xfer_handle);
-static usbd_status	ahci_device_isoc_start(usbd_xfer_handle);
-static void		ahci_device_isoc_abort(usbd_xfer_handle);
-static void		ahci_device_isoc_close(usbd_pipe_handle);
-static void		ahci_device_isoc_done(usbd_xfer_handle);
-
-static usbd_status	ahci_device_bulk_transfer(usbd_xfer_handle);
-static usbd_status	ahci_device_bulk_start(usbd_xfer_handle);
-static void		ahci_device_bulk_abort(usbd_xfer_handle);
-static void		ahci_device_bulk_close(usbd_pipe_handle);
-static void		ahci_device_bulk_done(usbd_xfer_handle);
+static usbd_status	ahci_root_intr_transfer(struct usbd_xfer *);
+static usbd_status	ahci_root_intr_start(struct usbd_xfer *);
+static void		ahci_root_intr_abort(struct usbd_xfer *);
+static void		ahci_root_intr_close(struct usbd_pipe *);
+static void		ahci_root_intr_done(struct usbd_xfer *);
+
+static usbd_status	ahci_device_ctrl_transfer(struct usbd_xfer *);
+static usbd_status	ahci_device_ctrl_start(struct usbd_xfer *);
+static void		ahci_device_ctrl_abort(struct usbd_xfer *);
+static void		ahci_device_ctrl_close(struct usbd_pipe *);
+static void		ahci_device_ctrl_done(struct usbd_xfer *);
+
+static usbd_status	ahci_device_intr_transfer(struct usbd_xfer *);
+static usbd_status	ahci_device_intr_start(struct usbd_xfer *);
+static void		ahci_device_intr_abort(struct usbd_xfer *);
+static void		ahci_device_intr_close(struct usbd_pipe *);
+static void		ahci_device_intr_done(struct usbd_xfer *);
+
+static usbd_status	ahci_device_isoc_transfer(struct usbd_xfer *);
+static usbd_status	ahci_device_isoc_start(struct usbd_xfer *);
+static void		ahci_device_isoc_abort(struct usbd_xfer *);
+static void		ahci_device_isoc_close(struct usbd_pipe *);
+static void		ahci_device_isoc_done(struct usbd_xfer *);
+
+static usbd_status	ahci_device_bulk_transfer(struct usbd_xfer *);
+static usbd_status	ahci_device_bulk_start(struct usbd_xfer *);
+static void		ahci_device_bulk_abort(struct usbd_xfer *);
+static void		ahci_device_bulk_close(struct usbd_pipe *);
+static void		ahci_device_bulk_done(struct usbd_xfer *);
 
 static int		ahci_transaction(struct ahci_softc *,
-	usbd_pipe_handle, u_int8_t, int, u_char *, u_int8_t);
-static void		ahci_noop(usbd_pipe_handle);
-static void		ahci_abort_xfer(usbd_xfer_handle, usbd_status);
-static void		ahci_device_clear_toggle(usbd_pipe_handle);
+	struct usbd_pipe *, uint8_t, int, u_char *, uint8_t);
+static void		ahci_noop(struct usbd_pipe *);
+static void		ahci_abort_xfer(struct usbd_xfer *, usbd_status);
+static void		ahci_device_clear_toggle(struct usbd_pipe *);
 
 extern int usbdebug;
 extern int uhubdebug;
@@ -152,9 +146,6 @@ int ahci_dummy;
 
 #define AHCI_DEBUG
 
-/* For root hub */
-#define AHCI_INTR_ENDPT	(1)
-
 #ifdef AHCI_DEBUG
 #define D_TRACE	(0x0001)	/* function trace */
 #define D_MSG	(0x0002)	/* debug messages */
@@ -166,80 +157,70 @@ int ahci_debug = 0;
 void		print_req(usb_device_request_t *);
 void		print_req_hub(usb_device_request_t *);
 void		print_dumpreg(struct ahci_softc *);
-void		print_xfer(usbd_xfer_handle);
+void		print_xfer(struct usbd_xfer *);
 #else
 #define DPRINTF(z,x)
 #endif
 
 
 struct usbd_bus_methods ahci_bus_methods = {
-	.open_pipe = ahci_open,
-	.soft_intr = ahci_softintr,
-	.do_poll = ahci_poll,
-	.allocm = ahci_allocm,
-	.freem = ahci_freem,
-	.allocx = ahci_allocx,
-	.freex = ahci_freex,
-	.get_lock = ahci_get_lock,
-};
-
-struct usbd_pipe_methods ahci_root_ctrl_methods = {
-	.transfer = ahci_root_ctrl_transfer,
-	.start = ahci_root_ctrl_start,
-	.abort = ahci_root_ctrl_abort,
-	.close = ahci_root_ctrl_close,
-	.cleartoggle = ahci_noop,
-	.done = ahci_root_ctrl_done,
+	.ubm_open = ahci_open,
+	.ubm_softint = ahci_softintr,
+	.ubm_dopoll = ahci_poll,
+	.ubm_allocx = ahci_allocx,
+	.ubm_freex = ahci_freex,
+	.ubm_getlock = ahci_get_lock,
+	.ubm_rhctrl = ahci_roothub_ctrl,
 };
 
 struct usbd_pipe_methods ahci_root_intr_methods = {
-	.transfer = ahci_root_intr_transfer,
-	.start = ahci_root_intr_start,
-	.abort = ahci_root_intr_abort,
-	.close = ahci_root_intr_close,
-	.cleartoggle = ahci_noop,
-	.done = ahci_root_intr_done,
+	.upm_transfer = ahci_root_intr_transfer,
+	.upm_start = ahci_root_intr_start,
+	.upm_abort = ahci_root_intr_abort,
+	.upm_close = ahci_root_intr_close,
+	.upm_cleartoggle = ahci_noop,
+	.upm_done = ahci_root_intr_done,
 };
 
 struct usbd_pipe_methods ahci_device_ctrl_methods = {
-	.transfer = ahci_device_ctrl_transfer,
-	.start = ahci_device_ctrl_start,
-	.abort = ahci_device_ctrl_abort,
-	.close = ahci_device_ctrl_close,
-	.cleartoggle = ahci_noop,
-	.done = ahci_device_ctrl_done,
+	.upm_transfer = ahci_device_ctrl_transfer,
+	.upm_start = ahci_device_ctrl_start,
+	.upm_abort = ahci_device_ctrl_abort,
+	.upm_close = ahci_device_ctrl_close,
+	.upm_cleartoggle = ahci_noop,
+	.upm_done = ahci_device_ctrl_done,
 };
 
 struct usbd_pipe_methods ahci_device_intr_methods = {
-	.transfer = ahci_device_intr_transfer,
-	.start = ahci_device_intr_start,
-	.abort = ahci_device_intr_abort,
-	.close = ahci_device_intr_close,
-	.cleartoggle = ahci_device_clear_toggle,
-	.done = ahci_device_intr_done,
+	.upm_transfer = ahci_device_intr_transfer,
+	.upm_start = ahci_device_intr_start,
+	.upm_abort = ahci_device_intr_abort,
+	.upm_close = ahci_device_intr_close,
+	.upm_cleartoggle = ahci_device_clear_toggle,
+	.upm_done = ahci_device_intr_done,
 };
 
 struct usbd_pipe_methods ahci_device_isoc_methods = {
-	.transfer = ahci_device_isoc_transfer,
-	.start = ahci_device_isoc_start,
-	.abort = ahci_device_isoc_abort,
-	.close = ahci_device_isoc_close,
-	.cleartoggle = ahci_noop,
-	.done = ahci_device_isoc_done,
+	.upm_transfer = ahci_device_isoc_transfer,
+	.upm_start = ahci_device_isoc_start,
+	.upm_abort = ahci_device_isoc_abort,
+	.upm_close = ahci_device_isoc_close,
+	.upm_cleartoggle = ahci_noop,
+	.upm_done = ahci_device_isoc_done,
 };
 
 struct usbd_pipe_methods ahci_device_bulk_methods = {
-	.transfer = ahci_device_bulk_transfer,
-	.start = ahci_device_bulk_start,
-	.abort = ahci_device_bulk_abort,
-	.close = ahci_device_bulk_close,
-	.cleartoggle = ahci_device_clear_toggle,
-	.done = ahci_device_bulk_done,
+	.upm_transfer = ahci_device_bulk_transfer,
+	.upm_start = ahci_device_bulk_start,
+	.upm_abort = ahci_device_bulk_abort,
+	.upm_close = ahci_device_bulk_close,
+	.upm_cleartoggle = ahci_device_clear_toggle,
+	.upm_done = ahci_device_bulk_done,
 };
 
 struct ahci_pipe {
 	struct usbd_pipe pipe;
-	u_int32_t toggle;
+	uint32_t toggle;
 };
 
 static int	ahci_match(device_t, cfdata_t, void *);
@@ -254,9 +235,9 @@ ahci_match(device_t parent, struct cfdat
 	struct obio_attach_args *aa = aux;
 
 	if (strcmp(aa->oba_name, cf->cf_name) == 0)
-		return (1);
+		return 1;
 
-	return (0);
+	return 0;
 }
 
 #define	REG_READ(o)	bus_space_read_4(sc->sc_st, sc->sc_ioh, (o))
@@ -280,6 +261,7 @@ ahci_attach(device_t parent, device_t se
 	sc->sc_bus.ub_methods = &ahci_bus_methods;
 	sc->sc_bus.ub_pipesize = sizeof(struct ahci_pipe);
 	sc->sc_bus.ub_dmatag = sc->sc_dmat;
+	sc->sc_bus.ub_usedma = true;
 
 	/* Map the device. */
 	if (bus_space_map(sc->sc_st, aa->oba_addr,
@@ -307,15 +289,15 @@ ahci_attach(device_t parent, device_t se
 	REG_WRITE(ADMHCD_REG_INTENABLE, 0); /* disable interrupts */
 	REG_WRITE(ADMHCD_REG_CONTROL, ADMHCD_SW_RESET); /* reset */
 	delay_ms(10);
-        while (REG_READ(ADMHCD_REG_CONTROL) & ADMHCD_SW_RESET)
-                delay_ms(1);
+	while (REG_READ(ADMHCD_REG_CONTROL) & ADMHCD_SW_RESET)
+		delay_ms(1);
 
 	REG_WRITE(ADMHCD_REG_CONTROL, ADMHCD_HOST_EN);
-        REG_WRITE(ADMHCD_REG_HOSTHEAD, 0x00000000);
-        REG_WRITE(ADMHCD_REG_FMINTERVAL, 0x20002edf);
-        REG_WRITE(ADMHCD_REG_LSTHRESH, 0x628);
-        REG_WRITE(ADMHCD_REG_RHDESCR, ADMHCD_NPS | ADMHCD_LPSC);
-        REG_WRITE(ADMHCD_REG_HOSTCONTROL, ADMHCD_STATE_OP);
+	REG_WRITE(ADMHCD_REG_HOSTHEAD, 0x00000000);
+	REG_WRITE(ADMHCD_REG_FMINTERVAL, 0x20002edf);
+	REG_WRITE(ADMHCD_REG_LSTHRESH, 0x628);
+	REG_WRITE(ADMHCD_REG_RHDESCR, ADMHCD_NPS | ADMHCD_LPSC);
+	REG_WRITE(ADMHCD_REG_HOSTCONTROL, ADMHCD_STATE_OP);
 
 	REG_WRITE(ADMHCD_REG_INTENABLE, 0); /* XXX: enable interrupts */
 
@@ -335,7 +317,7 @@ ahci_intr(void *arg)
 {
 #if 0
 	struct ahci_softc *sc = arg;
-	u_int8_t r;
+	uint8_t r;
 #ifdef AHCI_DEBUG
 	char bitbuf[256];
 #endif
@@ -368,25 +350,25 @@ ahci_intr(void *arg)
 }
 
 usbd_status
-ahci_open(usbd_pipe_handle pipe)
+ahci_open(struct usbd_pipe *pipe)
 {
-	usbd_device_handle dev = pipe->device;
-	struct ahci_softc *sc = (struct ahci_softc *)dev->bus;
+	struct usbd_device *dev = pipe->up_dev;
 	struct ahci_pipe *apipe = (struct ahci_pipe *)pipe;
-	usb_endpoint_descriptor_t *ed = pipe->endpoint->edesc;
+	usb_endpoint_descriptor_t *ed = pipe->up_endpoint->ue_edesc;
+	uint8_t rhaddr = dev->ud_bus->ub_rhaddr;
 
 	DPRINTF(D_TRACE, ("ahci_open(addr=%d,ep=%d,scaddr=%d)",
-		dev->address, ed->bEndpointAddress, sc->sc_addr));
+		dev->ud_addr, ed->bEndpointAddress, rhaddr));
 
 	apipe->toggle=0;
 
-	if (dev->address == sc->sc_addr) {
+	if (dev->ud_addr == rhaddr) {
 		switch (ed->bEndpointAddress) {
 		case USB_CONTROL_ENDPOINT:
-			pipe->methods = &ahci_root_ctrl_methods;
+			pipe->up_methods = &roothub_ctrl_methods;
 			break;
-		case UE_DIR_IN | AHCI_INTR_ENDPT:
-			pipe->methods = &ahci_root_intr_methods;
+		case UE_DIR_IN | USBROOTHUB_INTR_ENDPT:
+			pipe->up_methods = &ahci_root_intr_methods;
 			break;
 		default:
 			printf("open:endpointErr!\n");
@@ -396,19 +378,19 @@ ahci_open(usbd_pipe_handle pipe)
 		switch (ed->bmAttributes & UE_XFERTYPE) {
 		case UE_CONTROL:
 			DPRINTF(D_MSG, ("control "));
-			pipe->methods = &ahci_device_ctrl_methods;
+			pipe->up_methods = &ahci_device_ctrl_methods;
 			break;
 		case UE_INTERRUPT:
 			DPRINTF(D_MSG, ("interrupt "));
-			pipe->methods = &ahci_device_intr_methods;
+			pipe->up_methods = &ahci_device_intr_methods;
 			break;
 		case UE_ISOCHRONOUS:
 			DPRINTF(D_MSG, ("isochronous "));
-			pipe->methods = &ahci_device_isoc_methods;
+			pipe->up_methods = &ahci_device_isoc_methods;
 			break;
 		case UE_BULK:
 			DPRINTF(D_MSG, ("bluk "));
-			pipe->methods = &ahci_device_bulk_methods;
+			pipe->up_methods = &ahci_device_bulk_methods;
 			break;
 		}
 	}
@@ -427,6 +409,11 @@ ahci_poll(struct usbd_bus *bus)
 	DPRINTF(D_TRACE, ("%s()", __func__));
 }
 
+#define AHCI_BUS2SC(bus)	((bus)->ub_hcpriv)
+#define AHCI_PIPE2SC(pipe)	AHCI_BUS2SC((pipe)->up_dev->ud_bus)
+#define AHCI_XFER2SC(xfer)	AHCI_BUS2SC((xfer)->ux_bus)
+#define AHCI_APIPE2SC(ap)	AHCI_BUS2SC((d)->pipe.up_dev->ud_bus)
+
 /*
  * Emulation of interrupt transfer for status change endpoint
  * of root hub.
@@ -434,9 +421,8 @@ ahci_poll(struct usbd_bus *bus)
 void
 ahci_poll_hub(void *arg)
 {
-	usbd_xfer_handle xfer = arg;
-	usbd_pipe_handle pipe = xfer->pipe;
-	struct ahci_softc *sc = (struct ahci_softc *)pipe->device->bus;
+	struct usbd_xfer *xfer = arg;
+	struct ahci_softc *sc = AHCI_XFER2SC(xfer);
 	u_char *p;
 	static int p0_state=0;
 	static int p1_state=0;
@@ -444,7 +430,7 @@ ahci_poll_hub(void *arg)
 	callout_reset(&sc->sc_poll_handle, sc->sc_interval, ahci_poll_hub, xfer);
 
 	/* USB spec 11.13.3 (p.260) */
-	p = KERNADDR(&xfer->dmabuf, 0);
+	p = KERNADDR(&xfer->ux_dmabuf, 0);
 	p[0] = 0;
 	if ((REG_READ(ADMHCD_REG_PORTSTATUS0) & ADMHCD_CCS) != p0_state) {
 		p[0] = 2;
@@ -461,56 +447,38 @@ ahci_poll_hub(void *arg)
 	if (p[0] == 0)
 		return;
 
-	xfer->actlen = 1;
-	xfer->status = USBD_NORMAL_COMPLETION;
+	xfer->ux_actlen = 1;
+	xfer->ux_status = USBD_NORMAL_COMPLETION;
 	mutex_enter(&sc->sc_lock);
 	usb_transfer_complete(xfer);
 	mutex_exit(&sc->sc_lock);
 }
 
-usbd_status
-ahci_allocm(struct usbd_bus *bus, usb_dma_t *dma, u_int32_t size)
-{
-	struct ahci_softc *sc = (struct ahci_softc *)bus;
-
-	DPRINTF(D_MEM, ("SLallocm"));
-	return usb_allocmem(&sc->sc_bus, size, 0, dma);
-}
-
-void
-ahci_freem(struct usbd_bus *bus, usb_dma_t *dma)
-{
-	struct ahci_softc *sc = (struct ahci_softc *)bus;
-
-	DPRINTF(D_MEM, ("SLfreem"));
-	usb_freemem(&sc->sc_bus, dma);
-}
-
-usbd_xfer_handle
-ahci_allocx(struct usbd_bus *bus)
+struct usbd_xfer *
+ahci_allocx(struct usbd_bus *bus, unsigned int nframes)
 {
-	struct ahci_softc *sc = (struct ahci_softc *)bus;
-	usbd_xfer_handle xfer;
+	struct ahci_softc *sc = AHCI_BUS2SC(bus);
+	struct usbd_xfer *xfer;
 
 	DPRINTF(D_MEM, ("SLallocx"));
 
 	xfer = SIMPLEQ_FIRST(&sc->sc_free_xfers);
 	if (xfer) {
-		SIMPLEQ_REMOVE_HEAD(&sc->sc_free_xfers, next);
+		SIMPLEQ_REMOVE_HEAD(&sc->sc_free_xfers, ux_next);
 #ifdef DIAGNOSTIC
-		if (xfer->busy_free != XFER_FREE) {
+		if (xfer->ux_state != XFER_FREE) {
 			printf("ahci_allocx: xfer=%p not free, 0x%08x\n",
-				xfer, xfer->busy_free);
+				xfer, xfer->ux_state);
 		}
 #endif
 	} else {
-		xfer = malloc(sizeof(*xfer), M_USB, M_NOWAIT);
+		xfer = kmem_alloc(sizeof(*xfer), KM_SLEEP);
 	}
 
 	if (xfer) {
 		memset(xfer, 0, sizeof(*xfer));
 #ifdef DIAGNOSTIC
-		xfer->busy_free = XFER_BUSY;
+		xfer->ux_state = XFER_BUSY;
 #endif
 	}
 
@@ -518,33 +486,33 @@ ahci_allocx(struct usbd_bus *bus)
 }
 
 void
-ahci_freex(struct usbd_bus *bus, usbd_xfer_handle xfer)
+ahci_freex(struct usbd_bus *bus, struct usbd_xfer *xfer)
 {
-	struct ahci_softc *sc = (struct ahci_softc *)bus;
+	struct ahci_softc *sc = AHCI_BUS2SC(bus);
 
 	DPRINTF(D_MEM, ("SLfreex"));
 
 #ifdef DIAGNOSTIC
-	if (xfer->busy_free != XFER_BUSY) {
+	if (xfer->ux_state != XFER_BUSY) {
 		printf("ahci_freex: xfer=%p not busy, 0x%08x\n",
-			xfer, xfer->busy_free);
+			xfer, xfer->ux_state);
 		return;
 	}
-	xfer->busy_free = XFER_FREE;
+	xfer->ux_state = XFER_FREE;
 #endif
-	SIMPLEQ_INSERT_HEAD(&sc->sc_free_xfers, xfer, next);
+	SIMPLEQ_INSERT_HEAD(&sc->sc_free_xfers, xfer, ux_next);
 }
 
 static void
 ahci_get_lock(struct usbd_bus *bus, kmutex_t **lock)
 {
-	struct ahci_softc *sc = bus->ub_hcpriv;
+	struct ahci_softc *sc = AHCI_BUS2SC(bus);
 
 	*lock = &sc->sc_lock;
 }
 
 void
-ahci_noop(usbd_pipe_handle pipe)
+ahci_noop(struct usbd_pipe *pipe)
 {
 	DPRINTF(D_TRACE, ("%s()", __func__));
 }
@@ -552,272 +520,52 @@ ahci_noop(usbd_pipe_handle pipe)
 /*
  * Data structures and routines to emulate the root hub.
  */
-usb_device_descriptor_t ahci_devd = {
-	USB_DEVICE_DESCRIPTOR_SIZE,
-	UDESC_DEVICE,		/* type */
-	{0x01, 0x01},			/* USB version */
-	UDCLASS_HUB,		/* class */
-	UDSUBCLASS_HUB,		/* subclass */
-	0,			/* protocol */
-	64,			/* max packet */
-	{USB_VENDOR_SCANLOGIC & 0xff,	/* vendor ID (low)  */
-	 USB_VENDOR_SCANLOGIC >> 8  },	/* vendor ID (high) */
-	{0} /* ? */,		/* product ID */
-	{0},			/* device */
-	1,			/* index to manufacturer */
-	2,			/* index to product */
-	0,			/* index to serial number */
-	1			/* number of configurations */
-};
-
-usb_config_descriptor_t ahci_confd = {
-	USB_CONFIG_DESCRIPTOR_SIZE,
-	UDESC_CONFIG,
-	{USB_CONFIG_DESCRIPTOR_SIZE +
-	 USB_INTERFACE_DESCRIPTOR_SIZE +
-	 USB_ENDPOINT_DESCRIPTOR_SIZE},
-	1,			/* number of interfaces */
-	1,			/* configuration value */
-	0,			/* index to configuration */
-	UC_SELF_POWERED,	/* attributes */
-	250			/* max current is 500mA... */
-};
-
-usb_interface_descriptor_t ahci_ifcd = {
-	USB_INTERFACE_DESCRIPTOR_SIZE,
-	UDESC_INTERFACE,
-	0,			/* interface number */
-	0,			/* alternate setting */
-	1,			/* number of endpoint */
-	UICLASS_HUB,		/* class */
-	UISUBCLASS_HUB,		/* subclass */
-	0,			/* protocol */
-	0			/* index to interface */
-};
-
-usb_endpoint_descriptor_t ahci_endpd = {
-	USB_ENDPOINT_DESCRIPTOR_SIZE,
-	UDESC_ENDPOINT,
-	UE_DIR_IN | AHCI_INTR_ENDPT,	/* endpoint address */
-	UE_INTERRUPT,		/* attributes */
-	{8},			/* max packet size */
-	255			/* interval */
-};
-
-usb_hub_descriptor_t ahci_hubd = {
-	USB_HUB_DESCRIPTOR_SIZE,
-	UDESC_HUB,
-	2,			/* number of ports */
-	{ 0, 0},    		/* hub characteristics */
-	0,			/* 5:power on to power good */
-	0,			/* 6:maximum current */
-	{ 0x00 },		/* both ports are removable */
-	{ 0x00 }		/* port power control mask */
-};
 
 static int
-ahci_str(usb_string_descriptor_t *p, int l, const char *s)
+ahci_roothub_ctrl(struct usbd_bus *bus, usb_device_request_t *req,
+    void *buf, int buflen)
 {
-	int i;
-
-	if (l == 0)
-		return 0;
-	p->bLength = 2 * strlen(s) + 2;
-	if (l == 1)
-		return 1;
-	p->bDescriptorType = UDESC_STRING;
-	l -= 2;
-	for (i = 0; s[i] && l > 1; i++, l -= 2)
-		USETW2(p->bString[i], 0, s[i]);
-	return 2 * i + 2;
-}
-
-usbd_status
-ahci_root_ctrl_transfer(usbd_xfer_handle xfer)
-{
-	struct ahci_softc *sc = (struct ahci_softc *)xfer->pipe->device->bus;
-	usbd_status error;
-
-	DPRINTF(D_TRACE, ("SLRCtrans "));
-
-	/* Insert last in queue */
-	mutex_enter(&sc->sc_lock);
-	error = usb_insert_transfer(xfer);
-	mutex_exit(&sc->sc_lock);
-	if (error) {
-		DPRINTF(D_MSG, ("usb_insert_transfer returns err! "));
-		return error;
-	}
-
-	/*
-	 * Pipe isn't running (otherwise error would be USBD_INPROG),
-	 * so start it first.
-	 */
-	return ahci_root_ctrl_start(SIMPLEQ_FIRST(&xfer->pipe->queue));
-}
-
-usbd_status
-ahci_root_ctrl_start(usbd_xfer_handle xfer)
-{
-	struct ahci_softc *sc = (struct ahci_softc *)xfer->pipe->device->bus;
-	usb_device_request_t *req;
-	int len, value, index, l, status;
-	int totlen = 0;
-	void *buf = NULL;
+	struct ahci_softc *sc = AHCI_BUS2SC(bus);
+	uint16_t len, value, index;
 	usb_port_status_t ps;
-	usbd_status error;
-
+	int totlen = 0;
+	int status;
 
 	DPRINTF(D_TRACE, ("SLRCstart "));
 
-	req = &xfer->request;
-
 	len = UGETW(req->wLength);
 	value = UGETW(req->wValue);
 	index = UGETW(req->wIndex);
 
-	if (len)
-		buf = KERNADDR(&xfer->dmabuf, 0);
-
-#ifdef AHCI_DEBUG
-	if ((ahci_debug & D_TRACE))
-		print_req_hub(req);
-#endif
-
 #define C(x,y) ((x) | ((y) << 8))
 	switch (C(req->bRequest, req->bmRequestType)) {
-	case C(UR_CLEAR_FEATURE, UT_WRITE_DEVICE):
-		DPRINTF(D_MSG, ("UR_CLEAR_FEATURE(DEVICE)XXX "));
-		break;
-	case C(UR_CLEAR_FEATURE, UT_WRITE_INTERFACE):
-		DPRINTF(D_MSG, ("UR_CLEAR_FEATURE(INTERFACE)XXX "));
-		break;
-	case C(UR_CLEAR_FEATURE, UT_WRITE_ENDPOINT):
-		DPRINTF(D_MSG, ("UR_CLEAR_FEATURE(ENDPOINT)XXX "));
-		break;
-	case C(UR_GET_CONFIG, UT_READ_DEVICE):
-		DPRINTF(D_MSG, ("UR_GET_CONFIG "));
-		if (len > 0) {
-			*(u_int8_t *)buf = sc->sc_conf;
-			totlen = 1;
-		}
-		break;
 	case C(UR_GET_DESCRIPTOR, UT_READ_DEVICE):
-		switch (value >> 8) {
-		case UDESC_DEVICE:
+		switch (value) {
+		case C(0, UDESC_DEVICE): {
+			usb_device_descriptor_t devd;
+
 			DPRINTF(D_MSG, ("UDESC_DEVICE "));
-			if ((value & 0xff) != 0) {
-				error = USBD_IOERROR;
-				goto ret;
-			}
-			totlen = l = min(len, USB_DEVICE_DESCRIPTOR_SIZE);
-			memcpy(buf, &ahci_devd, l);
-			break;
-		case UDESC_CONFIG:
-			DPRINTF(D_MSG, ("UDESC_CONFIG "));
-			if ((value & 0xff) != 0) {
-				error = USBD_IOERROR;
-				goto ret;
-			}
-			totlen = l = min(len, USB_CONFIG_DESCRIPTOR_SIZE);
-			memcpy(buf, &ahci_confd, l);
-			buf = (char *)buf + l;
-			len -= l;
-
-			l = min(len, USB_INTERFACE_DESCRIPTOR_SIZE);
-			totlen += l;
-			memcpy(buf, &ahci_ifcd, l);
-			buf = (char *)buf + l;
-			len -= l;
-
-			l = min(len, USB_ENDPOINT_DESCRIPTOR_SIZE);
-			totlen += l;
-			memcpy(buf, &ahci_endpd, l);
-			break;
-		case UDESC_STRING:
-			DPRINTF(D_MSG, ("UDESC_STR "));
-			if (len == 0)
-				break;
-			*(u_int8_t *)buf = 0;
-			totlen = 1;
-			switch (value & 0xff) {
-			case 0:
-				break;
-			case 1:	/* Vendor */
-				totlen = ahci_str(buf, len, "ADMTek");
-				break;
-			case 2:	/* Product */
-				totlen = ahci_str(buf, len, "ADM5120 root hub");
-				break;
-			default:
-				printf("strerr%d ", value & 0xff);
-				break;
-			}
+			totlen = min(buflen, sizeof(devd));
+			memcpy(&devd, buf, totlen);
+			USETW(devd.idVendor, USB_VENDOR_SCANLOGIC);
+			memcpy(buf, &devd, totlen);
+			break;
+		}
+#define sd ((usb_string_descriptor_t *)buf)
+		case C(1, UDESC_STRING):
+			/* Vendor */
+			totlen = usb_makestrdesc(sd, len, "ADMTek");
+			break;
+		case C(2, UDESC_STRING):
+			/* Product */
+			totlen = usb_makestrdesc(sd, len, "ADM5120 root hub");
 			break;
 		default:
 			printf("unknownGetDescriptor=%x", value);
-			error = USBD_IOERROR;
-			break;
-		}
-		break;
-	case C(UR_GET_INTERFACE, UT_READ_INTERFACE):
-		/* Get Interface, 9.4.4 */
-		if (len > 0) {
-			*(u_int8_t *)buf = 0;
-			totlen = 1;
-		}
-		break;
-	case C(UR_GET_STATUS, UT_READ_DEVICE):
-		/* Get Status from device, 9.4.5 */
-		if (len > 1) {
-			USETW(((usb_status_t *)buf)->wStatus, UDS_SELF_POWERED);
-			totlen = 2;
+			/* default from usbroothub */
+			return buflen;
 		}
 		break;
-	case C(UR_GET_STATUS, UT_READ_INTERFACE):
-	case C(UR_GET_STATUS, UT_READ_ENDPOINT):
-		/* Get Status from interface, endpoint, 9.4.5 */
-		if (len > 1) {
-			USETW(((usb_status_t *)buf)->wStatus, 0);
-			totlen = 2;
-		}
-		break;
-	case C(UR_SET_ADDRESS, UT_WRITE_DEVICE):
-		/* Set Address, 9.4.6 */
-		DPRINTF(D_MSG, ("UR_SET_ADDRESS "));
-		if (value >= USB_MAX_DEVICES) {
-			error = USBD_IOERROR;
-			goto ret;
-		}
-		sc->sc_addr = value;
-		break;
-	case C(UR_SET_CONFIG, UT_WRITE_DEVICE):
-		/* Set Configuration, 9.4.7 */
-		DPRINTF(D_MSG, ("UR_SET_CONFIG "));
-		if (value != 0 && value != 1) {
-			error = USBD_IOERROR;
-			goto ret;
-		}
-		sc->sc_conf = value;
-		break;
-	case C(UR_SET_DESCRIPTOR, UT_WRITE_DEVICE):
-		/* Set Descriptor, 9.4.8, not supported */
-		DPRINTF(D_MSG, ("UR_SET_DESCRIPTOR,WRITE_DEVICE not supported\n"));
-		break;
-	case C(UR_SET_FEATURE, UT_WRITE_DEVICE):
-	case C(UR_SET_FEATURE, UT_WRITE_INTERFACE):
-	case C(UR_SET_FEATURE, UT_WRITE_ENDPOINT):
-		/* Set Feature, 9.4.9, not supported */
-		DPRINTF(D_MSG, ("UR_SET_FEATURE not supported\n"));
-		error = USBD_IOERROR;
-		break;
-	case C(UR_SET_INTERFACE, UT_WRITE_INTERFACE):
-		/* Set Interface, 9.4.10, not supported */
-		break;
-	case C(UR_SYNCH_FRAME, UT_WRITE_ENDPOINT):
-		/* Synch Frame, 9.4.11, not supported */
-		break;
-
 	/*
 	 * Hub specific requests
 	 */
@@ -830,8 +578,7 @@ ahci_root_ctrl_start(usbd_xfer_handle xf
 #define WPS(x) REG_WRITE(ADMHCD_REG_PORTSTATUS0+(index-1)*4, (x))
 		/* Clear Port Feature, 11.16.2.2 */
 		if (index != 1 && index != 2 ) {
-			error = USBD_IOERROR;
-			goto ret;
+			return -1;
 		}
 		switch (value) {
 		case UHF_PORT_POWER:
@@ -863,8 +610,7 @@ ahci_root_ctrl_start(usbd_xfer_handle xf
 			break;
 		default:
 			printf("ClrPortFeatERR:value=0x%x ", value);
-			error = USBD_IOERROR;
-			break;
+			return -1;
 		}
 		//DPRINTF(D_XFER, ("CH=%04x ", sc->sc_change));
 #undef WPS
@@ -877,19 +623,22 @@ ahci_root_ctrl_start(usbd_xfer_handle xf
 		/* Get Hub Descriptor, 11.16.2.4 */
 		DPRINTF(D_MSG, ("UR_GET_DESCRIPTOR RCD"));
 		if ((value&0xff) != 0) {
-			error = USBD_IOERROR;
-			goto ret;
+			return -1;
 		}
-		l = min(len, USB_HUB_DESCRIPTOR_SIZE);
-		totlen = l;
-		memcpy(buf, &ahci_hubd, l);
+		usb_hub_descriptor_t hubd;
+
+		totlen = min(buflen, sizeof(hubd));
+		memcpy(&hubd, buf, totlen);
+		hubd.bNbrPorts = 2;
+		USETW(hubd.wHubCharacteristics, 0);
+		hubd.bPwrOn2PwrGood = 0;
+		memcpy(buf, &hubd, totlen);
 		break;
 	case C(UR_GET_STATUS, UT_READ_CLASS_DEVICE):
 		/* Get Hub Status, 11.16.2.5 */
 		DPRINTF(D_MSG, ("UR_GET_STATUS RCD"));
 		if (len != 4) {
-			error = USBD_IOERROR;
-			goto ret;
+			return -1;
 		}
 		memset(buf, 0, len);
 		totlen = len;
@@ -898,8 +647,7 @@ ahci_root_ctrl_start(usbd_xfer_handle xf
 		/* Get Port Status, 11.16.2.6 */
 		if ((index != 1 && index != 2)  || len != 4) {
 			printf("index=%d,len=%d ", index, len);
-			error = USBD_IOERROR;
-			goto ret;
+			return -1;
 		}
 		status = REG_READ(ADMHCD_REG_PORTSTATUS0+(index-1)*4);
 		DPRINTF(D_MSG, ("UR_GET_STATUS RCO=%x ", status));
@@ -907,15 +655,13 @@ ahci_root_ctrl_start(usbd_xfer_handle xf
 		//DPRINTF(D_XFER, ("ST=%04x,CH=%04x ", status, sc->sc_change));
 		USETW(ps.wPortStatus, status  & (UPS_CURRENT_CONNECT_STATUS|UPS_PORT_ENABLED|UPS_SUSPEND|UPS_OVERCURRENT_INDICATOR|UPS_RESET|UPS_PORT_POWER|UPS_LOW_SPEED));
 		USETW(ps.wPortChange, (status>>16) & (UPS_C_CONNECT_STATUS|UPS_C_PORT_ENABLED|UPS_C_SUSPEND|UPS_C_OVERCURRENT_INDICATOR|UPS_C_PORT_RESET));
-		l = min(len, sizeof(ps));
-		memcpy(buf, &ps, l);
-		totlen = l;
+		totlen = min(len, sizeof(ps));
+		memcpy(buf, &ps, totlen);
 		break;
 	case C(UR_SET_DESCRIPTOR, UT_WRITE_CLASS_DEVICE):
 		/* Set Hub Descriptor, 11.16.2.7, not supported */
 		/* STALL ? */
-		error = USBD_IOERROR;
-		break;
+		return -1;
 	case C(UR_SET_FEATURE, UT_WRITE_CLASS_DEVICE):
 		/* Set Hub Feature, 11.16.2.8, not supported */
 		break;
@@ -924,8 +670,7 @@ ahci_root_ctrl_start(usbd_xfer_handle xf
 		/* Set Port Feature, 11.16.2.9 */
 		if ((index != 1) && (index !=2)) {
 			printf("index=%d ", index);
-			error = USBD_IOERROR;
-			goto ret;
+			return -1;
 		}
 		switch (value) {
 		case UHF_PORT_RESET:
@@ -942,49 +687,24 @@ ahci_root_ctrl_start(usbd_xfer_handle xf
 			break;
 		default:
 			printf("SetPortFeatERR=0x%x ", value);
-			error = USBD_IOERROR;
-			break;
+			return -1;
 		}
 #undef WPS
 		break;
 	default:
 		DPRINTF(D_MSG, ("ioerr(UR=%02x,UT=%02x) ",
 			req->bRequest, req->bmRequestType));
-		error = USBD_IOERROR;
-		goto ret;
+		/* default from usbroothub */
+		return buflen;
 	}
-	xfer->actlen = totlen;
-	error = USBD_NORMAL_COMPLETION;
- ret:
-	xfer->status = error;
-	mutex_enter(&sc->sc_lock);
-	usb_transfer_complete(xfer);
-	mutex_exit(&sc->sc_lock);
-	return USBD_IN_PROGRESS;
-}
 
-void
-ahci_root_ctrl_abort(usbd_xfer_handle xfer)
-{
-	DPRINTF(D_TRACE, ("SLRCabort "));
-}
-
-void
-ahci_root_ctrl_close(usbd_pipe_handle pipe)
-{
-	DPRINTF(D_TRACE, ("SLRCclose "));
-}
-
-void
-ahci_root_ctrl_done(usbd_xfer_handle xfer)
-{
-	DPRINTF(D_TRACE, ("SLRCdone\n"));
+	return totlen;
 }
 
 static usbd_status
-ahci_root_intr_transfer(usbd_xfer_handle xfer)
+ahci_root_intr_transfer(struct usbd_xfer *xfer)
 {
-	struct ahci_softc *sc = (struct ahci_softc *)xfer->pipe->device->bus;
+	struct ahci_softc *sc = AHCI_XFER2SC(xfer);
 	usbd_status error;
 
 	DPRINTF(D_TRACE, ("SLRItransfer "));
@@ -1000,33 +720,32 @@ ahci_root_intr_transfer(usbd_xfer_handle
 	 * Pipe isn't running (otherwise error would be USBD_INPROG),
 	 * start first.
 	 */
-	return ahci_root_intr_start(SIMPLEQ_FIRST(&xfer->pipe->queue));
+	return ahci_root_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue));
 }
 
 static usbd_status
-ahci_root_intr_start(usbd_xfer_handle xfer)
+ahci_root_intr_start(struct usbd_xfer *xfer)
 {
-	usbd_pipe_handle pipe = xfer->pipe;
-	struct ahci_softc *sc = (struct ahci_softc *)pipe->device->bus;
+	struct ahci_softc *sc = AHCI_XFER2SC(xfer);
 
 	DPRINTF(D_TRACE, ("SLRIstart "));
 
-	sc->sc_interval = MS_TO_TICKS(xfer->pipe->endpoint->edesc->bInterval);
+	sc->sc_interval = MS_TO_TICKS(xfer->ux_pipe->up_endpoint->ue_edesc->bInterval);
 	callout_reset(&sc->sc_poll_handle, sc->sc_interval, ahci_poll_hub, xfer);
 	sc->sc_intr_xfer = xfer;
 	return USBD_IN_PROGRESS;
 }
 
 static void
-ahci_root_intr_abort(usbd_xfer_handle xfer)
+ahci_root_intr_abort(struct usbd_xfer *xfer)
 {
 	DPRINTF(D_TRACE, ("SLRIabort "));
 }
 
 static void
-ahci_root_intr_close(usbd_pipe_handle pipe)
+ahci_root_intr_close(struct usbd_pipe *pipe)
 {
-	struct ahci_softc *sc = (struct ahci_softc *)pipe->device->bus;
+	struct ahci_softc *sc = AHCI_PIPE2SC(pipe);
 
 	DPRINTF(D_TRACE, ("SLRIclose "));
 
@@ -1035,15 +754,15 @@ ahci_root_intr_close(usbd_pipe_handle pi
 }
 
 static void
-ahci_root_intr_done(usbd_xfer_handle xfer)
+ahci_root_intr_done(struct usbd_xfer *xfer)
 {
 	//DPRINTF(D_XFER, ("RIdn "));
 }
 
 static usbd_status
-ahci_device_ctrl_transfer(usbd_xfer_handle xfer)
+ahci_device_ctrl_transfer(struct usbd_xfer *xfer)
 {
-	struct ahci_softc *sc = (struct ahci_softc *)xfer->pipe->device->bus;
+	struct ahci_softc *sc = AHCI_XFER2SC(xfer);
 	usbd_status error;
 
 	DPRINTF(D_TRACE, ("C"));
@@ -1054,41 +773,41 @@ ahci_device_ctrl_transfer(usbd_xfer_hand
 	if (error)
 		return error;
 
-	return ahci_device_ctrl_start(SIMPLEQ_FIRST(&xfer->pipe->queue));
+	return ahci_device_ctrl_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue));
 }
 
 static usbd_status
-ahci_device_ctrl_start(usbd_xfer_handle xfer)
+ahci_device_ctrl_start(struct usbd_xfer *xfer)
 {
 	usbd_status status =  USBD_NORMAL_COMPLETION;
 	int s, err;
 	static struct admhcd_ed ep_v __attribute__((aligned(16))), *ep;
 	static struct admhcd_td td_v[4] __attribute__((aligned(16))), *td, *td1, *td2, *td3;
 	static usb_dma_t reqdma;
-	usbd_pipe_handle pipe = xfer->pipe;
-        usb_device_request_t *req = &xfer->request;
-	struct ahci_softc *sc = (struct ahci_softc *)pipe->device->bus;
+	struct usbd_pipe *pipe = xfer->ux_pipe;
+	usb_device_request_t *req = &xfer->ux_request;
+	struct ahci_softc *sc = AHCI_XFER2SC(xfer);
 	int len, isread;
 
 
 #if 0
-	struct ahci_pipe *apipe = (struct ahci_pipe *)xfer->pipe;
+	struct ahci_pipe *apipe = (struct ahci_pipe *)xfer->ux_pipe;
 #endif
 	mutex_enter(&sc->sc_lock);
 /*	printf("ctrl_start>>>\n"); */
 
 #ifdef DIAGNOSTIC
-        if (!(xfer->rqflags & URQ_REQUEST)) {
-                /* XXX panic */
-                printf("ahci_device_ctrl_transfer: not a request\n");
-                return (USBD_INVAL);
-        }
+	if (!(xfer->ux_rqflags & URQ_REQUEST)) {
+		/* XXX panic */
+		printf("ahci_device_ctrl_transfer: not a request\n");
+		return USBD_INVAL;
+	}
 #endif
 
-#define KSEG1ADDR(x) (0xa0000000 | (((u_int32_t)x) & 0x1fffffff))
+#define KSEG1ADDR(x) (0xa0000000 | (((uint32_t)x) & 0x1fffffff))
 	DPRINTF(D_TRACE, ("st "));
 	if (!ep) {
-	        ep = (struct admhcd_ed *)KSEG1ADDR(&ep_v);
+		ep = (struct admhcd_ed *)KSEG1ADDR(&ep_v);
 		td = (struct admhcd_td *)KSEG1ADDR(&td_v[0]);
 		td1 = (struct admhcd_td *)KSEG1ADDR(&td_v[1]);
 		td2 = (struct admhcd_td *)KSEG1ADDR(&td_v[2]);
@@ -1097,41 +816,41 @@ ahci_device_ctrl_start(usbd_xfer_handle 
 			sizeof(usb_device_request_t),
 			0, &reqdma);
 		if (err)
-			return (USBD_NOMEM);
+			return USBD_NOMEM;
 
 		/* printf("ep: %p\n",ep); */
 	};
 
-	ep->control =  pipe->device->address | \
-		((pipe->device->speed==USB_SPEED_FULL)?ADMHCD_ED_SPEED:0) | \
-		((UGETW(pipe->endpoint->edesc->wMaxPacketSize))<<ADMHCD_ED_MAXSHIFT);
+	ep->control =  pipe->up_dev->ud_addr | \
+		((pipe->up_dev->ud_speed==USB_SPEED_FULL)?ADMHCD_ED_SPEED:0) | \
+		((UGETW(pipe->up_endpoint->ue_edesc->wMaxPacketSize))<<ADMHCD_ED_MAXSHIFT);
 	memcpy(KERNADDR(&reqdma, 0), req, sizeof *req);
 /* 	printf("status: %x\n",REG_READ(ADMHCD_REG_PORTSTATUS0));
 	printf("ep_control: %x\n",ep->control);
-	printf("speed: %x\n",pipe->device->speed);
+	printf("speed: %x\n",pipe->up_dev->ud_speed);
 	printf("req: %p\n",req);
-	printf("dmabuf: %p\n",xfer->dmabuf.block); */
+	printf("dmabuf: %p\n",xfer->ux_dmabuf.block); */
 
 	isread = req->bmRequestType & UT_READ;
 	len = UGETW(req->wLength);
 
-        ep->next = ep;
+	ep->next = ep;
 
-        td->buffer = DMAADDR(&reqdma,0) | 0xa0000000;
-        td->buflen=sizeof(*req);
-        td->control=ADMHCD_TD_SETUP | ADMHCD_TD_DATA0 | ADMHCD_TD_OWN;
+	td->buffer = DMAADDR(&reqdma,0) | 0xa0000000;
+	td->buflen=sizeof(*req);
+	td->control=ADMHCD_TD_SETUP | ADMHCD_TD_DATA0 | ADMHCD_TD_OWN;
 
 	if (len) {
 		td->next = td1;
 
-		td1->buffer = DMAADDR(&xfer->dmabuf,0) | 0xa0000000;
+		td1->buffer = DMAADDR(&xfer->ux_dmabuf,0) | 0xa0000000;
 		td1->buflen = len;
 		td1->next = td2;
 		td1->control= (isread?ADMHCD_TD_IN:ADMHCD_TD_OUT) | ADMHCD_TD_DATA1 | ADMHCD_TD_R | ADMHCD_TD_OWN;
-        } else {
-                td1->control = 0;
-                td->next = td2;
-        };
+	} else {
+		td1->control = 0;
+		td->next = td2;
+	};
 
 	td2->buffer = 0;
 	td2->buflen= 0;
@@ -1162,44 +881,44 @@ ahci_device_ctrl_start(usbd_xfer_handle 
 	printf("td3->next: %p\n",td3->next);
 */
 
-        REG_WRITE(ADMHCD_REG_HOSTHEAD, (u_int32_t)ep);
-        REG_WRITE(ADMHCD_REG_HOSTCONTROL, ADMHCD_STATE_OP | ADMHCD_DMA_EN);
+	REG_WRITE(ADMHCD_REG_HOSTHEAD, (uint32_t)ep);
+	REG_WRITE(ADMHCD_REG_HOSTCONTROL, ADMHCD_STATE_OP | ADMHCD_DMA_EN);
 /*	printf("1: %x %x %x %x\n", ep->control, td->control, td1->control, td2->control); */
-        s=100;
-        while (s--) {
-                delay_ms(10);
+	s=100;
+	while (s--) {
+		delay_ms(10);
 /*                printf("%x %x %x %x\n", ep->control, td->control, td1->control, td2->control);*/
 		status = USBD_TIMEOUT;
-                if (td->control & ADMHCD_TD_OWN) continue;
+		if (td->control & ADMHCD_TD_OWN) continue;
 
-                err = (td->control & ADMHCD_TD_ERRMASK)>>ADMHCD_TD_ERRSHIFT;
-                if (err) {
+		err = (td->control & ADMHCD_TD_ERRMASK)>>ADMHCD_TD_ERRSHIFT;
+		if (err) {
 			status = USBD_IOERROR;
-                        break;
-                };
+			break;
+		};
 
 		status = USBD_TIMEOUT;
-                if (td1->control & ADMHCD_TD_OWN) continue;
-                err = (td1->control & ADMHCD_TD_ERRMASK)>>ADMHCD_TD_ERRSHIFT;
-                if (err) {
+		if (td1->control & ADMHCD_TD_OWN) continue;
+		err = (td1->control & ADMHCD_TD_ERRMASK)>>ADMHCD_TD_ERRSHIFT;
+		if (err) {
 			status = USBD_IOERROR;
-                        break;
-                };
+			break;
+		};
 
 		status = USBD_TIMEOUT;
-                if (td2->control & ADMHCD_TD_OWN) continue;
-                err = (td2->control & ADMHCD_TD_ERRMASK)>>ADMHCD_TD_ERRSHIFT;
-                if (err) {
+		if (td2->control & ADMHCD_TD_OWN) continue;
+		err = (td2->control & ADMHCD_TD_ERRMASK)>>ADMHCD_TD_ERRSHIFT;
+		if (err) {
 			status = USBD_IOERROR;
-                };
+		};
 		status = USBD_NORMAL_COMPLETION;
-                break;
+		break;
 
 	};
-        REG_WRITE(ADMHCD_REG_HOSTCONTROL, ADMHCD_STATE_OP);
+	REG_WRITE(ADMHCD_REG_HOSTCONTROL, ADMHCD_STATE_OP);
 
-	xfer->actlen = len;
-	xfer->status = status;
+	xfer->ux_actlen = len;
+	xfer->ux_status = status;
 
 /* 	printf("ctrl_start<<<\n"); */
 
@@ -1209,28 +928,28 @@ ahci_device_ctrl_start(usbd_xfer_handle 
 }
 
 static void
-ahci_device_ctrl_abort(usbd_xfer_handle xfer)
+ahci_device_ctrl_abort(struct usbd_xfer *xfer)
 {
 	DPRINTF(D_TRACE, ("Cab "));
 	ahci_abort_xfer(xfer, USBD_CANCELLED);
 }
 
 static void
-ahci_device_ctrl_close(usbd_pipe_handle pipe)
+ahci_device_ctrl_close(struct usbd_pipe *pipe)
 {
 	DPRINTF(D_TRACE, ("Ccl "));
 }
 
 static void
-ahci_device_ctrl_done(usbd_xfer_handle xfer)
+ahci_device_ctrl_done(struct usbd_xfer *xfer)
 {
 	DPRINTF(D_TRACE, ("Cdn "));
 }
 
 static usbd_status
-ahci_device_intr_transfer(usbd_xfer_handle xfer)
+ahci_device_intr_transfer(struct usbd_xfer *xfer)
 {
-	struct ahci_softc *sc = (struct ahci_softc *)xfer->pipe->device->bus;
+	struct ahci_softc *sc = AHCI_XFER2SC(xfer);
 	usbd_status error;
 
 	DPRINTF(D_TRACE, ("INTRtrans "));
@@ -1241,28 +960,28 @@ ahci_device_intr_transfer(usbd_xfer_hand
 	if (error)
 		return error;
 
-	return ahci_device_intr_start(SIMPLEQ_FIRST(&xfer->pipe->queue));
+	return ahci_device_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue));
 }
 
 static usbd_status
-ahci_device_intr_start(usbd_xfer_handle xfer)
+ahci_device_intr_start(struct usbd_xfer *xfer)
 {
-	usbd_pipe_handle pipe = xfer->pipe;
+	struct usbd_pipe *pipe = xfer->ux_pipe;
 	struct ahci_xfer *sx;
 
 	DPRINTF(D_TRACE, ("INTRstart "));
 
-	sx = malloc(sizeof(*sx), M_USB, M_NOWAIT);
+	sx = kmem_intr_alloc(sizeof(*sx), KM_NOSLEEP);
 	if (sx == NULL)
 		goto reterr;
 	memset(sx, 0, sizeof(*sx));
-	sx->sx_xfer  = xfer;
-	xfer->hcpriv = sx;
+	sx->sx_xfer = xfer;
+	xfer->ux_hcpriv = sx;
 
 	/* initialize callout */
 	callout_init(&sx->sx_callout_t, 0);
 	callout_reset(&sx->sx_callout_t,
-		MS_TO_TICKS(pipe->endpoint->edesc->bInterval),
+		MS_TO_TICKS(pipe->up_endpoint->ue_edesc->bInterval),
 		ahci_poll_device, sx);
 
 	/* ACK */
@@ -1276,9 +995,9 @@ static void
 ahci_poll_device(void *arg)
 {
 	struct ahci_xfer *sx = (struct ahci_xfer *)arg;
-	usbd_xfer_handle xfer = sx->sx_xfer;
-	usbd_pipe_handle pipe = xfer->pipe;
-	struct ahci_softc *sc = (struct ahci_softc *)pipe->device->bus;
+	struct usbd_xfer *xfer = sx->sx_xfer;
+	struct usbd_pipe *pipe = xfer->ux_pipe;
+	struct ahci_softc *sc = AHCI_XFER2SC(xfer);
 	void *buf;
 	int pid;
 	int r;
@@ -1286,15 +1005,15 @@ ahci_poll_device(void *arg)
 	DPRINTF(D_TRACE, ("pldev"));
 
 	callout_reset(&sx->sx_callout_t,
-		MS_TO_TICKS(pipe->endpoint->edesc->bInterval),
+		MS_TO_TICKS(pipe->up_endpoint->ue_edesc->bInterval),
 		ahci_poll_device, sx);
 
 	/* interrupt transfer */
-	pid = (UE_GET_DIR(pipe->endpoint->edesc->bEndpointAddress) == UE_DIR_IN)
+	pid = (UE_GET_DIR(pipe->up_endpoint->ue_edesc->bEndpointAddress) == UE_DIR_IN)
 	    ? ADMHCD_TD_IN : ADMHCD_TD_OUT;
-	buf = KERNADDR(&xfer->dmabuf, 0);
+	buf = KERNADDR(&xfer->ux_dmabuf, 0);
 
-	r = ahci_transaction(sc, pipe, pid, xfer->length, buf, 0/*toggle*/);
+	r = ahci_transaction(sc, pipe, pid, xfer->ux_length, buf, 0/*toggle*/);
 	if (r < 0) {
 		DPRINTF(D_MSG, ("%s error", __func__));
 		return;
@@ -1303,24 +1022,24 @@ ahci_poll_device(void *arg)
 	if (r == 0)
 		return;
 
-	xfer->status = USBD_NORMAL_COMPLETION;
+	xfer->ux_status = USBD_NORMAL_COMPLETION;
 	mutex_enter(&sc->sc_lock);
 	usb_transfer_complete(xfer);
 	mutex_exit(&sc->sc_lock);
 }
 
 static void
-ahci_device_intr_abort(usbd_xfer_handle xfer)
+ahci_device_intr_abort(struct usbd_xfer *xfer)
 {
 	struct ahci_xfer *sx;
 
 	DPRINTF(D_TRACE, ("INTRabort "));
 
-	sx = xfer->hcpriv;
+	sx = xfer->ux_hcpriv;
 	if (sx) {
 		callout_stop(&sx->sx_callout_t);
-		free(sx, M_USB);
-		xfer->hcpriv = NULL;
+		kmem_intr_free(sx, sizeof(*sx));
+		xfer->ux_hcpriv = NULL;
 	} else {
 		printf("%s: sx == NULL!\n", __func__);
 	}
@@ -1328,53 +1047,53 @@ ahci_device_intr_abort(usbd_xfer_handle 
 }
 
 static void
-ahci_device_intr_close(usbd_pipe_handle pipe)
+ahci_device_intr_close(struct usbd_pipe *pipe)
 {
 	DPRINTF(D_TRACE, ("INTRclose "));
 }
 
 static void
-ahci_device_intr_done(usbd_xfer_handle xfer)
+ahci_device_intr_done(struct usbd_xfer *xfer)
 {
 	DPRINTF(D_TRACE, ("INTRdone "));
 }
 
 static usbd_status
-ahci_device_isoc_transfer(usbd_xfer_handle xfer)
+ahci_device_isoc_transfer(struct usbd_xfer *xfer)
 {
 	DPRINTF(D_TRACE, ("S"));
 	return USBD_NORMAL_COMPLETION;
 }
 
 static usbd_status
-ahci_device_isoc_start(usbd_xfer_handle xfer)
+ahci_device_isoc_start(struct usbd_xfer *xfer)
 {
 	DPRINTF(D_TRACE, ("st "));
 	return USBD_NORMAL_COMPLETION;
 }
 
 static void
-ahci_device_isoc_abort(usbd_xfer_handle xfer)
+ahci_device_isoc_abort(struct usbd_xfer *xfer)
 {
 	DPRINTF(D_TRACE, ("Sab "));
 }
 
 static void
-ahci_device_isoc_close(usbd_pipe_handle pipe)
+ahci_device_isoc_close(struct usbd_pipe *pipe)
 {
 	DPRINTF(D_TRACE, ("Scl "));
 }
 
 static void
-ahci_device_isoc_done(usbd_xfer_handle xfer)
+ahci_device_isoc_done(struct usbd_xfer *xfer)
 {
 	DPRINTF(D_TRACE, ("Sdn "));
 }
 
 static usbd_status
-ahci_device_bulk_transfer(usbd_xfer_handle xfer)
+ahci_device_bulk_transfer(struct usbd_xfer *xfer)
 {
-	struct ahci_softc *sc = (struct ahci_softc *)xfer->pipe->device->bus;
+	struct ahci_softc *sc = AHCI_XFER2SC(xfer);
 	usbd_status error;
 
 	DPRINTF(D_TRACE, ("B"));
@@ -1385,11 +1104,11 @@ ahci_device_bulk_transfer(usbd_xfer_hand
 	if (error)
 		return error;
 
-	return ahci_device_bulk_start(SIMPLEQ_FIRST(&xfer->pipe->queue));
+	return ahci_device_bulk_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue));
 }
 
 static usbd_status
-ahci_device_bulk_start(usbd_xfer_handle xfer)
+ahci_device_bulk_start(struct usbd_xfer *xfer)
 {
 #define NBULK_TDS 32
 	static volatile int level = 0;
@@ -1397,19 +1116,19 @@ ahci_device_bulk_start(usbd_xfer_handle 
 	int s, err;
 	static struct admhcd_ed ep_v __attribute__((aligned(16))), *ep;
 	static struct admhcd_td td_v[NBULK_TDS] __attribute__((aligned(16))), *td[NBULK_TDS];
-	usbd_pipe_handle pipe = xfer->pipe;
-	struct ahci_softc *sc = (struct ahci_softc *)pipe->device->bus;
+	struct usbd_pipe *pipe = xfer->ux_pipe;
+	struct ahci_softc *sc = AHCI_XFER2SC(xfer);
 	int endpt, i, len, tlen, segs, offset, isread, toggle, short_ok;
-	struct ahci_pipe *apipe = (struct ahci_pipe *)xfer->pipe;
+	struct ahci_pipe *apipe = (struct ahci_pipe *)xfer->ux_pipe;
 
-#define KSEG1ADDR(x) (0xa0000000 | (((u_int32_t)x) & 0x1fffffff))
+#define KSEG1ADDR(x) (0xa0000000 | (((uint32_t)x) & 0x1fffffff))
 	DPRINTF(D_TRACE, ("st "));
 
 #ifdef DIAGNOSTIC
-	if (xfer->rqflags & URQ_REQUEST) {
+	if (xfer->ux_rqflags & URQ_REQUEST) {
 		/* XXX panic */
 		printf("ohci_device_bulk_start: a request\n");
-		return (USBD_INVAL);
+		return USBD_INVAL;
 	}
 #endif
 
@@ -1418,7 +1137,7 @@ ahci_device_bulk_start(usbd_xfer_handle 
 /* 	printf("bulk_start>>>\n"); */
 
 	if (!ep) {
-	        ep = (struct admhcd_ed *)KSEG1ADDR(&ep_v);
+		ep = (struct admhcd_ed *)KSEG1ADDR(&ep_v);
 		for (i=0; i<NBULK_TDS; i++) {
 			td[i] = (struct admhcd_td *)KSEG1ADDR(&td_v[i]);
 		};
@@ -1430,28 +1149,28 @@ ahci_device_bulk_start(usbd_xfer_handle 
 		toggle = apipe->toggle;
 	};
 
-	endpt = pipe->endpoint->edesc->bEndpointAddress;
-	ep->control = pipe->device->address | ((endpt & 0xf) << ADMHCD_ED_EPSHIFT)|\
-		((pipe->device->speed==USB_SPEED_FULL)?ADMHCD_ED_SPEED:0) | \
-		((UGETW(pipe->endpoint->edesc->wMaxPacketSize))<<ADMHCD_ED_MAXSHIFT);
+	endpt = pipe->up_endpoint->ue_edesc->bEndpointAddress;
+	ep->control = pipe->up_dev->ud_addr | ((endpt & 0xf) << ADMHCD_ED_EPSHIFT)|\
+		((pipe->up_dev->ud_speed==USB_SPEED_FULL)?ADMHCD_ED_SPEED:0) | \
+		((UGETW(pipe->up_endpoint->ue_edesc->wMaxPacketSize))<<ADMHCD_ED_MAXSHIFT);
 
-	short_ok = xfer->flags & USBD_SHORT_XFER_OK?ADMHCD_TD_R:0;
+	short_ok = xfer->ux_flags & USBD_SHORT_XFER_OK?ADMHCD_TD_R:0;
 /*	printf("level: %d\n",level);
 	printf("short_xfer: %x\n",short_ok);
 	printf("ep_control: %x\n",ep->control);
-	printf("speed: %x\n",pipe->device->speed);
-	printf("dmabuf: %p\n",xfer->dmabuf.block); */
+	printf("speed: %x\n",pipe->up_dev->ud_speed);
+	printf("dmabuf: %p\n",xfer->ux_dmabuf.block); */
 
-        isread = UE_GET_DIR(endpt) == UE_DIR_IN;
-        len = xfer->length;
+	isread = UE_GET_DIR(endpt) == UE_DIR_IN;
+	len = xfer->ux_length;
 
-        ep->next = ep;
+	ep->next = ep;
 
 	i = 0;
 	offset = 0;
 	while ((len>0) || (i==0)) {
 		tlen = min(len,4096);
-		td[i]->buffer = DMAADDR(&xfer->dmabuf,offset) | 0xa0000000;
+		td[i]->buffer = DMAADDR(&xfer->ux_dmabuf,offset) | 0xa0000000;
 		td[i]->buflen=tlen;
 		td[i]->control=(isread?ADMHCD_TD_IN:ADMHCD_TD_OUT) | toggle | ADMHCD_TD_OWN | short_ok;
 		td[i]->len=tlen;
@@ -1486,27 +1205,27 @@ ahci_device_bulk_start(usbd_xfer_handle 
 		printf("td[%d]->buflen: %x\n",i,td[i]->buflen);
 	}; */
 
-        REG_WRITE(ADMHCD_REG_HOSTHEAD, (u_int32_t)ep);
-        REG_WRITE(ADMHCD_REG_HOSTCONTROL, ADMHCD_STATE_OP | ADMHCD_DMA_EN);
+	REG_WRITE(ADMHCD_REG_HOSTHEAD, (uint32_t)ep);
+	REG_WRITE(ADMHCD_REG_HOSTCONTROL, ADMHCD_STATE_OP | ADMHCD_DMA_EN);
 	i = 0;
 /*	printf("1: %x %d %x %x\n", ep->control, i, td[i]->control, td[i]->buflen); */
-        s=100;
+	s=100;
 	err = 0;
-        while (s--) {
+	while (s--) {
 /*                printf("%x %d %x %x\n", ep->control, i, td[i]->control, td[i]->buflen); */
 		status = USBD_TIMEOUT;
-                if (td[i]->control & ADMHCD_TD_OWN) {
+		if (td[i]->control & ADMHCD_TD_OWN) {
 			delay_ms(3);
 			continue;
 		};
 
 		len += td[i]->len - td[i]->buflen;
 
-                err = (td[i]->control & ADMHCD_TD_ERRMASK)>>ADMHCD_TD_ERRSHIFT;
-                if (err) {
+		err = (td[i]->control & ADMHCD_TD_ERRMASK)>>ADMHCD_TD_ERRSHIFT;
+		if (err) {
 			status = USBD_IOERROR;
-                        break;
-                };
+			break;
+		};
 
 		i++;
 		if (i==segs) {
@@ -1515,17 +1234,17 @@ ahci_device_bulk_start(usbd_xfer_handle 
 		};
 
 	};
-        REG_WRITE(ADMHCD_REG_HOSTCONTROL, ADMHCD_STATE_OP);
+	REG_WRITE(ADMHCD_REG_HOSTCONTROL, ADMHCD_STATE_OP);
 
-	apipe->toggle = ((u_int32_t)ep->head & 2)?ADMHCD_TD_DATA1:ADMHCD_TD_DATA0;
+	apipe->toggle = ((uint32_t)ep->head & 2)?ADMHCD_TD_DATA1:ADMHCD_TD_DATA0;
 /*	printf("bulk_transfer_done: status: %x, err: %x, len: %x, toggle: %x\n", status,err,len,apipe->toggle); */
 
 	if (short_ok && (err == 0x9 || err == 0xd)) {
 /*		printf("bulk_transfer_done: short_transfer fix\n"); */
 		status = USBD_NORMAL_COMPLETION;
 	};
-	xfer->actlen = len;
-	xfer->status = status;
+	xfer->ux_actlen = len;
+	xfer->ux_status = status;
 
 	level--;
 /*	printf("bulk_start<<<\n"); */
@@ -1537,20 +1256,20 @@ ahci_device_bulk_start(usbd_xfer_handle 
 }
 
 static void
-ahci_device_bulk_abort(usbd_xfer_handle xfer)
+ahci_device_bulk_abort(struct usbd_xfer *xfer)
 {
 	DPRINTF(D_TRACE, ("Bab "));
 	ahci_abort_xfer(xfer, USBD_CANCELLED);
 }
 
 static void
-ahci_device_bulk_close(usbd_pipe_handle pipe)
+ahci_device_bulk_close(struct usbd_pipe *pipe)
 {
 	DPRINTF(D_TRACE, ("Bcl "));
 }
 
 static void
-ahci_device_bulk_done(usbd_xfer_handle xfer)
+ahci_device_bulk_done(struct usbd_xfer *xfer)
 {
 	DPRINTF(D_TRACE, ("Bdn "));
 }
@@ -1564,8 +1283,8 @@ ahci_device_bulk_done(usbd_xfer_handle x
  * return 1 if ACK, 0 if NAK, -1 if error.
  */
 static int
-ahci_transaction(struct ahci_softc *sc, usbd_pipe_handle pipe,
-	u_int8_t pid, int len, u_char *buf, u_int8_t toggle)
+ahci_transaction(struct ahci_softc *sc, struct usbd_pipe *pipe,
+	uint8_t pid, int len, u_char *buf, uint8_t toggle)
 {
 	return -1;
 #if 0
@@ -1576,12 +1295,12 @@ ahci_transaction(struct ahci_softc *sc, 
 	int timeout;
 	int ls_via_hub = 0;
 	int pl;
-	u_int8_t isr;
-	u_int8_t result = 0;
-	u_int8_t devaddr = pipe->device->address;
-	u_int8_t endpointaddr = pipe->endpoint->edesc->bEndpointAddress;
-	u_int8_t endpoint;
-	u_int8_t cmd = DATA0_RD;
+	uint8_t isr;
+	uint8_t result = 0;
+	uint8_t devaddr = pipe->up_dev->ud_addr;
+	uint8_t endpointaddr = pipe->up_endpoint->ue_edesc->bEndpointAddress;
+	uint8_t endpoint;
+	uint8_t cmd = DATA0_RD;
 
 	endpoint = UE_GET_ADDR(endpointaddr);
 	DPRINTF(D_XFER, ("\n(%x,%d%s%d,%d) ",
@@ -1605,7 +1324,7 @@ ahci_transaction(struct ahci_softc *sc, 
 
 	/* Low speed device via HUB */
 	/* XXX does not work... */
-	if ((sc->sc_fullspeed) && pipe->device->speed == USB_SPEED_LOW) {
+	if ((sc->sc_fullspeed) && pipe->up_dev->ud_speed == USB_SPEED_LOW) {
 		pl = len + 16;
 		cmd |= SL11_EPCTRL_PREAMBLE;
 
@@ -1620,7 +1339,7 @@ ahci_transaction(struct ahci_softc *sc, 
 	}
 
 	/* timing ? */
-	if (sl11read(sc, SL811_CSOF) <= (u_int8_t)pl)
+	if (sl11read(sc, SL811_CSOF) <= (uint8_t)pl)
 		cmd |= SL11_EPCTRL_SOF;
 
 	/* Transfer */
@@ -1671,16 +1390,16 @@ ahci_transaction(struct ahci_softc *sc, 
 }
 
 void
-ahci_abort_xfer(usbd_xfer_handle xfer, usbd_status status)
+ahci_abort_xfer(struct usbd_xfer *xfer, usbd_status status)
 {
-	xfer->status = status;
+	xfer->ux_status = status;
 	usb_transfer_complete(xfer);
 }
 
 void
-ahci_device_clear_toggle(usbd_pipe_handle pipe)
+ahci_device_clear_toggle(struct usbd_pipe *pipe)
 {
-        struct ahci_pipe *apipe = (struct ahci_pipe *)pipe;
+	struct ahci_pipe *apipe = (struct ahci_pipe *)pipe;
 	apipe->toggle = 0;
 }
 
@@ -1771,12 +1490,12 @@ print_dumpreg(struct ahci_softc *sc)
 }
 
 void
-print_xfer(usbd_xfer_handle xfer)
+print_xfer(struct usbd_xfer *xfer)
 {
 	printf("xfer: length=%d, actlen=%d, flags=%x, timeout=%d,",
-		xfer->length, xfer->actlen, xfer->flags, xfer->timeout);
+		xfer->ux_length, xfer->ux_actlen, xfer->ux_flags, xfer->ux_timeout);
 	printf("request{ ");
-	print_req_hub(&xfer->request);
+	print_req_hub(&xfer->ux_request);
 	printf("} ");
 }
 #endif /* AHCI_DEBUG */

Index: src/sys/arch/mips/adm5120/dev/ahcivar.h
diff -u src/sys/arch/mips/adm5120/dev/ahcivar.h:1.5 src/sys/arch/mips/adm5120/dev/ahcivar.h:1.5.10.1
--- src/sys/arch/mips/adm5120/dev/ahcivar.h:1.5	Sun Sep 22 08:30:22 2013
+++ src/sys/arch/mips/adm5120/dev/ahcivar.h	Mon Jan 23 08:02:54 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahcivar.h,v 1.5 2013/09/22 08:30:22 skrll Exp $	*/
+/*	$NetBSD: ahcivar.h,v 1.5.10.1 2017/01/23 08:02:54 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
@@ -70,7 +70,7 @@
 	usb_delay_ms(&sc->sc_bus, (X));
 
 struct ahci_xfer {
-	usbd_xfer_handle sx_xfer;
+	struct usbd_xfer *sx_xfer;
 	callout_t sx_callout_t;
 };
 
@@ -84,10 +84,10 @@ struct ahci_softc {
 	kmutex_t		 sc_lock;
 	kmutex_t		 sc_intr_lock;
 
-	void				(*sc_enable_power)(void *, int);
-	void				(*sc_enable_intr)(void *, int);
-	void				*sc_arg;
-	int				 sc_powerstat;
+	void			(*sc_enable_power)(void *, int);
+	void			(*sc_enable_intr)(void *, int);
+	void			*sc_arg;
+	int			 sc_powerstat;
 #define POWER_ON	(1)
 #define POWER_OFF	(0)
 #define INTR_ON 	(1)
@@ -97,13 +97,13 @@ struct ahci_softc {
 
 	device_t		 sc_parent;	/* parent device */
 
-	u_int8_t		 sc_addr;	/* device address of root hub */
-	u_int8_t		 sc_conf;
+	uint8_t			 sc_addr;	/* device address of root hub */
+	uint8_t			 sc_conf;
 	SIMPLEQ_HEAD(, usbd_xfer) sc_free_xfers;
 
 	/* Information for the root hub interrupt pipe */
 	int			 sc_interval;
-	usbd_xfer_handle	 sc_intr_xfer;
+	struct usbd_xfer	*sc_intr_xfer;
 	callout_t		 sc_poll_handle;
 
 	int				 sc_flags;

Index: src/sys/arch/mips/conf/files.adm5120
diff -u src/sys/arch/mips/conf/files.adm5120:1.3 src/sys/arch/mips/conf/files.adm5120:1.3.36.1
--- src/sys/arch/mips/conf/files.adm5120:1.3	Mon Apr  4 20:01:14 2011
+++ src/sys/arch/mips/conf/files.adm5120	Mon Jan 23 08:02:55 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: files.adm5120,v 1.3 2011/04/04 20:01:14 dyoung Exp $
+#	$NetBSD: files.adm5120,v 1.3.36.1 2017/01/23 08:02:55 skrll Exp $
 
 file	arch/mips/adm5120/adm5120_intr.c
 
@@ -44,6 +44,6 @@ attach	wdc at extio with wdc_extio
 file	arch/mips/adm5120/dev/wdc_extio.c		wdc_extio
 
 # On-chip USB controller
-device	ahci: usbus, usb_dma
+device	ahci: usbus, usbroothub, usb_dma
 attach	ahci at obio
 file	arch/mips/adm5120/dev/ahci.c			ahci

Reply via email to