parisc: USB OHCI endianess fixes
Signed-off-by: Helge Deller <deller@gmx.de>
diff --git a/src/hw/usb-hid.c b/src/hw/usb-hid.c
index 92c6b19..0c84d72 100644
--- a/src/hw/usb-hid.c
+++ b/src/hw/usb-hid.c
@@ -27,7 +27,7 @@
struct usb_ctrlrequest req;
req.bRequestType = USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE;
req.bRequest = HID_REQ_SET_PROTOCOL;
- req.wValue = val;
+ req.wValue = cpu_to_le16(val);
req.wIndex = 0;
req.wLength = 0;
return usb_send_default_control(pipe, &req, NULL);
@@ -40,7 +40,7 @@
struct usb_ctrlrequest req;
req.bRequestType = USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE;
req.bRequest = HID_REQ_SET_IDLE;
- req.wValue = (ms/4)<<8;
+ req.wValue = cpu_to_le16((ms/4)<<8);
req.wIndex = 0;
req.wLength = 0;
return usb_send_default_control(pipe, &req, NULL);
@@ -68,10 +68,10 @@
// XXX - this enables the first found keyboard (could be random)
return -1;
- if (epdesc->wMaxPacketSize < sizeof(struct keyevent)
- || epdesc->wMaxPacketSize > MAX_KBD_EVENT) {
+ if (le16_to_cpu(epdesc->wMaxPacketSize) < sizeof(struct keyevent)
+ || le16_to_cpu(epdesc->wMaxPacketSize) > MAX_KBD_EVENT) {
dprintf(1, "USB keyboard wMaxPacketSize=%d; aborting\n"
- , epdesc->wMaxPacketSize);
+ , le16_to_cpu(epdesc->wMaxPacketSize));
return -1;
}
@@ -110,10 +110,10 @@
// XXX - this enables the first found mouse (could be random)
return -1;
- if (epdesc->wMaxPacketSize < sizeof(struct mouseevent)
- || epdesc->wMaxPacketSize > MAX_MOUSE_EVENT) {
+ if (le16_to_cpu(epdesc->wMaxPacketSize) < sizeof(struct mouseevent)
+ || le16_to_cpu(epdesc->wMaxPacketSize) > MAX_MOUSE_EVENT) {
dprintf(1, "USB mouse wMaxPacketSize=%d; aborting\n"
- , epdesc->wMaxPacketSize);
+ , le16_to_cpu(epdesc->wMaxPacketSize));
return -1;
}
diff --git a/src/hw/usb-ohci.c b/src/hw/usb-ohci.c
index f8a8067..c839d11 100644
--- a/src/hw/usb-ohci.c
+++ b/src/hw/usb-ohci.c
@@ -269,6 +269,7 @@
ohci_controller_setup(struct pci_device *pci)
{
struct ohci_regs *regs = pci_enable_membar(pci, PCI_BASE_ADDRESS_0);
+ dprintf(1, "OHCI controller init on dev %pP \n", pci);
if (!regs)
return;
@@ -320,7 +321,7 @@
usb_desc2pipe(&pipe->pipe, usbdev, epdesc);
pipe->ed.hwINFO = cpu_to_le32(
(ED_SKIP | usbdev->devaddr | (pipe->pipe.ep << 7)
- | (epdesc->wMaxPacketSize << 16)
+ | (le16_to_cpu(epdesc->wMaxPacketSize) << 16)
| (usbdev->speed ? ED_LOWSPEED : 0)));
struct usb_ohci_s *cntl = container_of(
usbdev->hub->cntl, struct usb_ohci_s, usb);
@@ -338,7 +339,7 @@
if (frameexp > 5)
frameexp = 5;
- int maxpacket = epdesc->wMaxPacketSize;
+ int maxpacket = le16_to_cpu(epdesc->wMaxPacketSize);
// Determine number of entries needed for 2 timer ticks.
int ms = 1<<frameexp;
int count = DIV_ROUND_UP(ticks_to_ms(2), ms) + 1;
diff --git a/src/hw/usb.c b/src/hw/usb.c
index 7d3e452..74230f3 100644
--- a/src/hw/usb.c
+++ b/src/hw/usb.c
@@ -174,7 +174,7 @@
pipe->ep = epdesc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
pipe->devaddr = usbdev->devaddr;
pipe->speed = usbdev->speed;
- pipe->maxpacket = epdesc->wMaxPacketSize;
+ pipe->maxpacket = le16_to_cpu(epdesc->wMaxPacketSize);
pipe->eptype = epdesc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
}
@@ -248,18 +248,18 @@
if (ret)
return NULL;
- struct usb_config_descriptor *config = malloc_tmphigh(cfg.wTotalLength);
+ struct usb_config_descriptor *config = malloc_tmphigh(le16_to_cpu(cfg.wTotalLength));
if (!config) {
warn_noalloc();
return NULL;
}
- req.wLength = cpu_to_le16(cfg.wTotalLength);
+ req.wLength = cfg.wTotalLength;
ret = usb_send_default_control(pipe, &req, config);
if (ret || config->wTotalLength != cfg.wTotalLength) {
free(config);
return NULL;
}
- //hexdump(config, cfg.wTotalLength);
+ //hexdump(config, le16_to_cpu(cfg.wTotalLength));
return config;
}
@@ -302,7 +302,7 @@
// Create a pipe for the default address.
struct usb_endpoint_descriptor epdesc = {
- .wMaxPacketSize = speed_to_ctlsize[usbdev->speed],
+ .wMaxPacketSize = cpu_to_le16(speed_to_ctlsize[usbdev->speed]),
.bmAttributes = USB_ENDPOINT_XFER_CONTROL,
};
usbdev->defpipe = usb_alloc_pipe(usbdev, &epdesc);
@@ -346,15 +346,15 @@
if (ret)
return 0;
u16 maxpacket = dinfo.bMaxPacketSize0;
- if (dinfo.bcdUSB >= 0x0300)
+ if (le16_to_cpu(dinfo.bcdUSB) >= 0x0300)
maxpacket = 1 << dinfo.bMaxPacketSize0;
dprintf(3, "device rev=%04x cls=%02x sub=%02x proto=%02x size=%d\n"
- , dinfo.bcdUSB, dinfo.bDeviceClass, dinfo.bDeviceSubClass
+ , le16_to_cpu(dinfo.bcdUSB), dinfo.bDeviceClass, dinfo.bDeviceSubClass
, dinfo.bDeviceProtocol, maxpacket);
if (maxpacket < 8)
return 0;
struct usb_endpoint_descriptor epdesc = {
- .wMaxPacketSize = maxpacket,
+ .wMaxPacketSize = cpu_to_le16(maxpacket),
.bmAttributes = USB_ENDPOINT_XFER_CONTROL,
};
usbdev->defpipe = usb_realloc_pipe(usbdev, usbdev->defpipe, &epdesc);
diff --git a/src/parisc/parisc.c b/src/parisc/parisc.c
index 66aedd7..92d044e 100644
--- a/src/parisc/parisc.c
+++ b/src/parisc/parisc.c
@@ -22,6 +22,7 @@
#include "hw/pci_ids.h" // PCI IDs
#include "hw/pci_regs.h" // PCI_BASE_ADDRESS_0
#include "hw/ata.h"
+#include "hw/usb.h"
#include "hw/usb-ohci.h"
#include "hw/blockcmd.h" // scsi_is_ready()
#include "hw/rtc.h"
@@ -2917,6 +2918,7 @@
serial_setup();
// ohci_setup();
+ usb_setup();
block_setup();
/* find SCSI PCI card when running on Astro or Dino */