usb: Infrastructure changes
Make OHCI OwnershipChange work properly
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include <uchar.h>
|
||||
#define HAVE_STDARG_H
|
||||
#include <86box/86box.h>
|
||||
#include <86box/timer.h>
|
||||
|
@@ -30,7 +30,6 @@
|
||||
#include <86box/pit.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/port_92.h>
|
||||
#include <86box/usb.h>
|
||||
#include <86box/hdc.h>
|
||||
#include <86box/hdc_ide.h>
|
||||
#include <86box/chipset.h>
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include <uchar.h>
|
||||
#define HAVE_STDARG_H
|
||||
#include <86box/86box.h>
|
||||
#include "cpu.h"
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include <uchar.h>
|
||||
#define HAVE_STDARG_H
|
||||
#include <86box/86box.h>
|
||||
#include <86box/device.h>
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include <uchar.h>
|
||||
#define HAVE_STDARG_H
|
||||
#include <86box/86box.h>
|
||||
#include <86box/mem.h>
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include <uchar.h>
|
||||
#define HAVE_STDARG_H
|
||||
#include <86box/86box.h>
|
||||
#include "cpu.h"
|
||||
|
@@ -23,6 +23,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct usb_t usb_t;
|
||||
typedef struct usb_device_t usb_device_t;
|
||||
|
||||
enum usb_pid
|
||||
{
|
||||
@@ -39,22 +40,6 @@ enum usb_errors
|
||||
USB_ERROR_UNDERRUN = 3
|
||||
};
|
||||
|
||||
/* USB endpoint device struct. Incomplete and unused. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t vendor_id;
|
||||
uint16_t device_id;
|
||||
|
||||
/* General-purpose function for I/O. Non-zero value indicates error. */
|
||||
uint8_t (*device_process)(void* priv, uint8_t* data, uint32_t *len, uint8_t pid_token, uint8_t endpoint, uint8_t underrun_not_allowed);
|
||||
/* Device reset. */
|
||||
void (*device_reset)(void* priv);
|
||||
/* Get address. */
|
||||
uint8_t (*device_get_address)(void* priv);
|
||||
|
||||
void* priv;
|
||||
} usb_device_t;
|
||||
|
||||
enum usb_bus_types
|
||||
{
|
||||
USB_BUS_OHCI = 0,
|
||||
@@ -107,6 +92,35 @@ typedef struct
|
||||
uint8_t bDescriptorType;
|
||||
} usb_desc_base_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bmRequestType;
|
||||
uint8_t bRequest;
|
||||
uint16_t wValue;
|
||||
uint16_t wIndex;
|
||||
uint16_t wLength;
|
||||
} usb_desc_setup_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
usb_desc_base_t base;
|
||||
uint8_t bEndpointAddress;
|
||||
uint8_t bmAttributes;
|
||||
uint16_t wMaxPacketSize;
|
||||
uint8_t bInterval;
|
||||
} usb_desc_endpoint_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
usb_desc_base_t base;
|
||||
|
||||
uint16_t bcdHID;
|
||||
uint8_t bCountryCode;
|
||||
uint8_t bNumDescriptors;
|
||||
uint8_t bDescriptorType;
|
||||
uint16_t wDescriptorLength;
|
||||
} usb_desc_hid_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
usb_desc_base_t base;
|
||||
@@ -123,16 +137,7 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
usb_desc_base_t base;
|
||||
uint8_t bEndpointAddress;
|
||||
uint8_t bmAttributes;
|
||||
uint8_t wMaxPacketSize;
|
||||
uint8_t bInterval;
|
||||
} usb_desc_endpoint_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
usb_desc_base_t base;
|
||||
uint16_t bString[];
|
||||
char16_t bString[];
|
||||
} usb_desc_string_t;
|
||||
|
||||
typedef struct
|
||||
@@ -145,12 +150,47 @@ typedef struct
|
||||
uint8_t iConfiguration;
|
||||
uint8_t bmAttributes;
|
||||
uint8_t bMaxPower;
|
||||
|
||||
usb_desc_interface_t interface_descs[];
|
||||
} usb_desc_conf_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
usb_desc_base_t base;
|
||||
|
||||
uint16_t bcdUSB;
|
||||
uint8_t bDeviceClass;
|
||||
uint8_t bDeviceSubClass;
|
||||
uint8_t bDeviceProtocol;
|
||||
uint8_t bMaxPacketSize;
|
||||
uint16_t idVendor;
|
||||
uint16_t idProduct;
|
||||
uint16_t bcdDevice;
|
||||
uint8_t iManufacturer;
|
||||
uint8_t iProduct;
|
||||
uint8_t iSerialNumber;
|
||||
uint8_t bNumConfigurations;
|
||||
} usb_desc_device_t;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
/* USB endpoint device struct. Incomplete and unused. */
|
||||
typedef struct usb_device_t
|
||||
{
|
||||
usb_desc_device_t device_desc;
|
||||
struct {
|
||||
usb_desc_conf_t conf_desc;
|
||||
usb_desc_base_t* other_descs[16];
|
||||
} conf_desc_items;
|
||||
|
||||
/* General-purpose function for I/O. Non-zero value indicates error. */
|
||||
uint8_t (*device_process)(void* priv, uint8_t* data, uint32_t *len, uint8_t pid_token, uint8_t endpoint, uint8_t underrun_not_allowed);
|
||||
/* Device reset. */
|
||||
void (*device_reset)(void* priv);
|
||||
/* Get address. */
|
||||
uint8_t (*device_get_address)(void* priv);
|
||||
|
||||
void* priv;
|
||||
} usb_device_t;
|
||||
|
||||
/* Global variables. */
|
||||
extern const device_t usb_device;
|
||||
extern usb_t* usb_device_inst;
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <wchar.h>
|
||||
#include <uchar.h>
|
||||
#include <assert.h>
|
||||
#define HAVE_STDARG_H
|
||||
#include <86box/86box.h>
|
||||
@@ -702,8 +703,9 @@ ohci_mmio_write(uint32_t addr, uint8_t val, void *p)
|
||||
/* bit OwnershipChangeRequest triggers an ownership change (SMM <-> OS) */
|
||||
if (val & 0x08) {
|
||||
dev->ohci_mmio[OHCI_HcInterruptStatus].b[3] = 0x40;
|
||||
if ((dev->ohci_mmio[OHCI_HcInterruptEnable].b[3] & 0xc0) == 0xc0)
|
||||
if ((dev->ohci_mmio[OHCI_HcInterruptEnable].b[3] & 0x40) == 0x40) {
|
||||
smi_raise();
|
||||
}
|
||||
}
|
||||
|
||||
/* bit HostControllerReset must be cleared for the controller to be seen as initialized */
|
||||
|
Reference in New Issue
Block a user