vgabios: Unify code to generate the vbe mode list.
[seabios.git] / src / usb.h
index 6bc0cfda411cbf3842bc9c16949396a48fc32b1a..8b2af405d917916319eaee35bf5c066d1ce50cbb 100644 (file)
--- a/src/usb.h
+++ b/src/usb.h
@@ -4,39 +4,56 @@
 
 #include "util.h" // struct mutex_s
 
+// Information on a USB end point.
 struct usb_pipe {
     struct usb_s *cntl;
+    u64 path;
     u8 type;
     u8 ep;
     u8 devaddr;
-    u8 lowspeed;
+    u8 speed;
     u16 maxpacket;
-    u8 toggle;
+    u8 tt_devaddr;
+    u8 tt_port;
 };
 
-// Local information for a usb controller.
+// Common information for usb controllers.
 struct usb_s {
-    u8 type;
-    u8 maxaddr;
-    u16 bdf;
     struct usb_pipe *defaultpipe;
     struct mutex_s resetlock;
+    struct pci_device *pci;
+    int busid;
+    u8 type;
+    u8 maxaddr;
+};
+
+// Information for enumerating USB hubs
+struct usbhub_s {
+    struct usbhub_op_s *op;
+    struct usb_pipe *pipe;
+    struct usb_s *cntl;
+    struct mutex_s lock;
+    u32 powerwait;
+    u32 port;
+    u32 threads;
+    u32 portcount;
+    u32 devcount;
+};
 
-    union {
-        struct {
-            u16 iobase;
-            void *control_qh, *bulk_qh, *framelist;
-        } uhci;
-        struct {
-            struct ohci_regs *regs;
-        } ohci;
-    };
+// Hub callback (32bit) info
+struct usbhub_op_s {
+    int (*detect)(struct usbhub_s *hub, u32 port);
+    int (*reset)(struct usbhub_s *hub, u32 port);
+    void (*disconnect)(struct usbhub_s *hub, u32 port);
 };
 
 #define USB_TYPE_UHCI 1
 #define USB_TYPE_OHCI 2
+#define USB_TYPE_EHCI 3
 
-extern struct usb_s USBControllers[];
+#define USB_FULLSPEED 0
+#define USB_LOWSPEED  1
+#define USB_HIGHSPEED 2
 
 #define USB_MAXADDR 127
 
@@ -181,8 +198,7 @@ struct usb_endpoint_descriptor {
 
 // usb.c
 void usb_setup(void);
-struct usb_pipe *usb_set_address(struct usb_s *cntl, int lowspeed);
-int configure_usb_device(struct usb_pipe *pipe);
+void usb_enumerate(struct usbhub_s *hub);
 int send_default_control(struct usb_pipe *pipe, const struct usb_ctrlrequest *req
                          , void *data);
 int usb_send_bulk(struct usb_pipe *pipe, int dir, void *data, int datasize);