Adding Cromwell to usb.
authorJames Tabor <james.tabor@reactos.org>
Wed, 1 Jun 2005 21:55:36 +0000 (21:55 +0000)
committerJames Tabor <james.tabor@reactos.org>
Wed, 1 Jun 2005 21:55:36 +0000 (21:55 +0000)
svn path=/trunk/; revision=15720

16 files changed:
reactos/drivers/usb/cromwell/core/config.c
reactos/drivers/usb/cromwell/core/hcd.h
reactos/drivers/usb/cromwell/core/hub.c
reactos/drivers/usb/cromwell/core/message.c
reactos/drivers/usb/cromwell/core/usb-debug.c
reactos/drivers/usb/cromwell/core/usb.c
reactos/drivers/usb/cromwell/core/usbcore.xml [new file with mode: 0644]
reactos/drivers/usb/cromwell/directory.xml [new file with mode: 0644]
reactos/drivers/usb/cromwell/host/host.xml [new file with mode: 0644]
reactos/drivers/usb/cromwell/host/ohci_main.c
reactos/drivers/usb/cromwell/host/ohci_main.h
reactos/drivers/usb/cromwell/linux/usb.h
reactos/drivers/usb/cromwell/uhci/uhci-hcd.c
reactos/drivers/usb/cromwell/uhci/uhci.xml [new file with mode: 0644]
reactos/drivers/usb/cromwell/uhci/uhci_main.c
reactos/drivers/usb/cromwell/usb_wrapper.h

index 1c40bbd..bc18273 100644 (file)
@@ -101,56 +101,56 @@ static int usb_parse_endpoint(struct usb_host_endpoint *endpoint, unsigned char
        return parsed;
 }
 
-static int usb_parse_interface(struct usb_interface *interface, unsigned char *buffer, int size)
+static int usb_parse_interface(struct usb_interface *pinterface, unsigned char *buffer, int size)
 {
        int i, len, numskipped, retval, parsed = 0;
        struct usb_descriptor_header *header;
        struct usb_host_interface *ifp;
        unsigned char *begin;
 
-       interface->act_altsetting = 0;
-       interface->num_altsetting = 0;
-       interface->max_altsetting = USB_ALTSETTINGALLOC;
-       device_initialize(&interface->dev);
+       pinterface->act_altsetting = 0;
+       pinterface->num_altsetting = 0;
+       pinterface->max_altsetting = USB_ALTSETTINGALLOC;
+       device_initialize(&pinterface->dev);
 
-       interface->altsetting = kmalloc(sizeof(*interface->altsetting) * interface->max_altsetting,
+       pinterface->altsetting = kmalloc(sizeof(*pinterface->altsetting) * pinterface->max_altsetting,
                                        GFP_KERNEL);
        
-       if (!interface->altsetting) {
-               err("couldn't kmalloc interface->altsetting");
+       if (!pinterface->altsetting) {
+               err("couldn't kmalloc pinterface->altsetting");
                return -1;
        }
 
        while (size > 0) {
                struct usb_interface_descriptor *d;
        
-               if (interface->num_altsetting >= interface->max_altsetting) {
+               if (pinterface->num_altsetting >= pinterface->max_altsetting) {
                        struct usb_host_interface *ptr;
                        int oldmas;
 
-                       oldmas = interface->max_altsetting;
-                       interface->max_altsetting += USB_ALTSETTINGALLOC;
-                       if (interface->max_altsetting > USB_MAXALTSETTING) {
+                       oldmas = pinterface->max_altsetting;
+                       pinterface->max_altsetting += USB_ALTSETTINGALLOC;
+                       if (pinterface->max_altsetting > USB_MAXALTSETTING) {
                                warn("too many alternate settings (incr %d max %d)\n",
                                        USB_ALTSETTINGALLOC, USB_MAXALTSETTING);
                                return -1;
                        }
 
-                       ptr = kmalloc(sizeof(*ptr) * interface->max_altsetting, GFP_KERNEL);
+                       ptr = kmalloc(sizeof(*ptr) * pinterface->max_altsetting, GFP_KERNEL);
                        if (ptr == NULL) {
-                               err("couldn't kmalloc interface->altsetting");
+                               err("couldn't kmalloc pinterface->altsetting");
                                return -1;
                        }
-                       memcpy(ptr, interface->altsetting, sizeof(*interface->altsetting) * oldmas);
-                       kfree(interface->altsetting);
-                       interface->altsetting = ptr;
+                       memcpy(ptr, pinterface->altsetting, sizeof(*pinterface->altsetting) * oldmas);
+                       kfree(pinterface->altsetting);
+                       pinterface->altsetting = ptr;
                }
 
-               ifp = interface->altsetting + interface->num_altsetting;
+               ifp = pinterface->altsetting + pinterface->num_altsetting;
                ifp->endpoint = NULL;
                ifp->extra = NULL;
                ifp->extralen = 0;
-               interface->num_altsetting++;
+               pinterface->num_altsetting++;
 
                memcpy(ifp, buffer, USB_DT_INTERFACE_SIZE);
 
@@ -268,16 +268,16 @@ int usb_parse_configuration(struct usb_host_config *config, char *buffer)
                return -1;
        }
 
-       config->interface = (struct usb_interface *)
+       config->pinterface = (struct usb_interface *)
                kmalloc(config->desc.bNumInterfaces *
                sizeof(struct usb_interface), GFP_KERNEL);
-       dbg("kmalloc IF %p, numif %i", config->interface, config->desc.bNumInterfaces);
-       if (!config->interface) {
+       dbg("kmalloc IF %p, numif %i", config->pinterface, config->desc.bNumInterfaces);
+       if (!config->pinterface) {
                err("out of memory");
                return -1;      
        }
 
-       memset(config->interface, 0,
+       memset(config->pinterface, 0,
               config->desc.bNumInterfaces * sizeof(struct usb_interface));
 
        buffer += config->desc.bLength;
@@ -337,7 +337,7 @@ int usb_parse_configuration(struct usb_host_config *config, char *buffer)
                        }
                }
 
-               retval = usb_parse_interface(config->interface + i, buffer, size);
+               retval = usb_parse_interface(config->pinterface + i, buffer, size);
                if (retval < 0)
                        return retval;
 
@@ -367,12 +367,12 @@ void usb_destroy_configuration(struct usb_device *dev)
        for (c = 0; c < dev->descriptor.bNumConfigurations; c++) {
                struct usb_host_config *cf = &dev->config[c];
 
-               if (!cf->interface)
+               if (!cf->pinterface)
                        break;
 
                for (i = 0; i < cf->desc.bNumInterfaces; i++) {
                        struct usb_interface *ifp =
-                               &cf->interface[i];
+                               &cf->pinterface[i];
                                
                        if (!ifp->altsetting)
                                break;
@@ -398,7 +398,7 @@ void usb_destroy_configuration(struct usb_device *dev)
 
                        kfree(ifp->altsetting);
                }
-               kfree(cf->interface);
+               kfree(cf->pinterface);
        }
        kfree(dev->config);
 }
index 5b6a6a0..3a85edf 100644 (file)
@@ -424,7 +424,7 @@ extern void usb_bus_get (struct usb_bus *bus);
 extern void usb_bus_put (struct usb_bus *bus);
 
 extern int usb_find_interface_driver (struct usb_device *dev,
-       struct usb_interface *interface);
+       struct usb_interface *pinterface);
 
 #define usb_endpoint_halt(dev, ep, out) ((dev)->halted[out] |= (1 << (ep)))
 
index ff4809f..dda273f 100644 (file)
@@ -42,8 +42,8 @@
 #endif
 
 /* Wakes up khubd */
-static spinlock_t hub_event_lock = SPIN_LOCK_UNLOCKED;
-static DECLARE_MUTEX(usb_address0_sem);
+//static spinlock_t hub_event_lock = SPIN_LOCK_UNLOCKED;
+//static DECLARE_MUTEX(usb_address0_sem);
 
 static LIST_HEAD(hub_event_list);      /* List of hubs needing servicing */
 static LIST_HEAD(hub_list);            /* List of all hubs (for cleanup) */
@@ -67,7 +67,7 @@ static inline char *portspeed (int portstatus)
 /* for dev_info, dev_dbg, etc */
 static inline struct device *hubdev (struct usb_device *dev)
 {
-       return &dev->actconfig->interface [0].dev;
+       return &dev->actconfig->pinterface [0].dev;
 }
 
 /* USB 2.0 spec Section 11.24.4.5 */
@@ -699,7 +699,7 @@ static void hub_start_disconnect(struct usb_device *dev)
 static int hub_port_status(struct usb_device *dev, int port,
                               u16 *status, u16 *change)
 {
-       struct usb_hub *hub = usb_get_intfdata (dev->actconfig->interface);
+       struct usb_hub *hub = usb_get_intfdata (dev->actconfig->pinterface);
        int ret;
 
        ret = get_port_status(dev, port + 1, &hub->status->port);
@@ -1360,7 +1360,7 @@ int usb_physical_reset_device(struct usb_device *dev)
        }
 
        for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) {
-               struct usb_interface *intf = &dev->actconfig->interface[i];
+               struct usb_interface *intf = &dev->actconfig->pinterface[i];
                struct usb_interface_descriptor *as;
 
                as = &intf->altsetting[intf->act_altsetting].desc;
index 79d1065..f3ed78b 100644 (file)
@@ -683,7 +683,7 @@ void usb_set_maxpacket(struct usb_device *dev)
 
        /* NOTE:  affects all endpoints _except_ ep0 */
        for (i=0; i<dev->actconfig->desc.bNumInterfaces; i++) {
-               struct usb_interface *ifp = dev->actconfig->interface + i;
+               struct usb_interface *ifp = dev->actconfig->pinterface + i;
                struct usb_host_interface *as = ifp->altsetting + ifp->act_altsetting;
                struct usb_host_endpoint *ep = as->endpoint;
                int e;
@@ -800,16 +800,16 @@ int usb_clear_halt(struct usb_device *dev, int pipe)
  * Returns zero on success, or else the status code returned by the
  * underlying usb_control_msg() call.
  */
-int usb_set_interface(struct usb_device *dev, int interface, int alternate)
+int usb_set_interface(struct usb_device *dev, int pinterface, int alternate)
 {
        struct usb_interface *iface;
        struct usb_host_interface *iface_as;
        int i, ret;
        void (*disable)(struct usb_device *, int) = dev->bus->op->disable;
 
-       iface = usb_ifnum_to_if(dev, interface);
+       iface = usb_ifnum_to_if(dev, pinterface);
        if (!iface) {
-               warn("selecting invalid interface %d", interface);
+               warn("selecting invalid interface %d", pinterface);
                return -EINVAL;
        }
 
@@ -817,7 +817,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
           only has one alternate setting */
        if (iface->num_altsetting == 1) {
                dbg("ignoring set_interface for dev %d, iface %d, alt %d",
-                       dev->devnum, interface, alternate);
+                       dev->devnum, pinterface, alternate);
                return 0;
        }
 
@@ -828,7 +828,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
                                   USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE,
                                   iface->altsetting[alternate]
                                        .desc.bAlternateSetting,
-                                  interface, NULL, 0, HZ * 5)) < 0)
+                                  pinterface, NULL, 0, HZ * 5)) < 0)
                return ret;
 
        /* FIXME drivers shouldn't need to replicate/bugfix the logic here
index a6a6160..bb77936 100644 (file)
@@ -42,7 +42,7 @@ static void usb_show_config(struct usb_host_config *config)
 
        usb_show_config_descriptor(&config->desc);
        for (i = 0; i < config->desc.bNumInterfaces; i++) {
-               ifp = config->interface + i;
+               ifp = config->pinterface + i;
 
                if (!ifp)
                        break;
index de3740e..443b709 100644 (file)
@@ -212,9 +212,9 @@ struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, unsigned ifnum)
        int i;
 
        for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++)
-               if (dev->actconfig->interface[i].altsetting[0]
+               if (dev->actconfig->pinterface[i].altsetting[0]
                                .desc.bInterfaceNumber == ifnum)
-                       return &dev->actconfig->interface[i];
+                       return &dev->actconfig->pinterface[i];
 
        return NULL;
 }
@@ -239,13 +239,13 @@ usb_epnum_to_ep_desc(struct usb_device *dev, unsigned epnum)
        int i, j, k;
 
        for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++)
-               for (j = 0; j < dev->actconfig->interface[i].num_altsetting; j++)
-                       for (k = 0; k < dev->actconfig->interface[i]
+               for (j = 0; j < dev->actconfig->pinterface[i].num_altsetting; j++)
+                       for (k = 0; k < dev->actconfig->pinterface[i]
                                .altsetting[j].desc.bNumEndpoints; k++)
-                               if (epnum == dev->actconfig->interface[i]
+                               if (epnum == dev->actconfig->pinterface[i]
                                                .altsetting[j].endpoint[k]
                                                .desc.bEndpointAddress)
-                                       return &dev->actconfig->interface[i]
+                                       return &dev->actconfig->pinterface[i]
                                                .altsetting[j].endpoint[k]
                                                .desc;
 
@@ -391,7 +391,7 @@ void usb_driver_release_interface(struct usb_driver *driver, struct usb_interfac
  * its associated class and subclass.
  */   
 const struct usb_device_id *
-usb_match_id(struct usb_interface *interface, const struct usb_device_id *id)
+usb_match_id(struct usb_interface *pinterface, const struct usb_device_id *id)
 {
        struct usb_host_interface *intf;
        struct usb_device *dev;
@@ -400,8 +400,8 @@ usb_match_id(struct usb_interface *interface, const struct usb_device_id *id)
        if (id == NULL)
                return NULL;
 
-       intf = &interface->altsetting [interface->act_altsetting];
-       dev = interface_to_usbdev(interface);
+       intf = &pinterface->altsetting [pinterface->act_altsetting];
+       dev = interface_to_usbdev(pinterface);
 
        /* It is important to check that id->driver_info is nonzero,
           since an entry that is all zeroes except for a nonzero
@@ -901,11 +901,11 @@ void usb_disconnect(struct usb_device **pdev)
        dev_dbg (&dev->dev, "unregistering interfaces\n");
        if (dev->actconfig) {
                for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) {
-                       struct usb_interface    *interface;
+                       struct usb_interface    *pinterface;
 
                        /* remove this interface */
-                       interface = &dev->actconfig->interface[i];
-                       device_unregister(&interface->dev);
+                       pinterface = &dev->actconfig->pinterface[i];
+                       device_unregister(&pinterface->dev);
                }
        }
 
@@ -1205,35 +1205,35 @@ int usb_new_device(struct usb_device *dev, struct device *parent)
        /* Register all of the interfaces for this device with the driver core.
         * Remember, interfaces get bound to drivers, not devices. */
        for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) {
-               struct usb_interface *interface = &dev->actconfig->interface[i];
+               struct usb_interface *pinterface = &dev->actconfig->pinterface[i];
                struct usb_interface_descriptor *desc;
 
-               desc = &interface->altsetting [interface->act_altsetting].desc;
-               interface->dev.parent = &dev->dev;
-               interface->dev.driver = NULL;
-               interface->dev.bus = &usb_bus_type;
-               interface->dev.dma_mask = parent->dma_mask;
-               sprintf (&interface->dev.bus_id[0], "%d-%s:%d",
+               desc = &pinterface->altsetting [pinterface->act_altsetting].desc;
+               pinterface->dev.parent = &dev->dev;
+               pinterface->dev.driver = NULL;
+               pinterface->dev.bus = &usb_bus_type;
+               pinterface->dev.dma_mask = parent->dma_mask;
+               sprintf (&pinterface->dev.bus_id[0], "%d-%s:%d",
                         dev->bus->busnum, dev->devpath,
                         desc->bInterfaceNumber);
                if (!desc->iInterface
                                || usb_string (dev, desc->iInterface,
-                                       interface->dev.name,
-                                       sizeof interface->dev.name) <= 0) {
+                                       pinterface->dev.name,
+                                       sizeof pinterface->dev.name) <= 0) {
                        /* typically devices won't bother with interface
                         * descriptions; this is the normal case.  an
                         * interface's driver might describe it better.
                         * (also: iInterface is per-altsetting ...)
                         */
-                       sprintf (&interface->dev.name[0],
+                       sprintf (&pinterface->dev.name[0],
                                "usb-%s-%s interface %d",
                                dev->bus->bus_name, dev->devpath,
                                desc->bInterfaceNumber);
-                       DPRINT1("usb_new_device: %s\n", interface->dev.name);
+                       DPRINT1("usb_new_device: %s\n", pinterface->dev.name);
                }
-               dev_dbg (&dev->dev, "%s - registering interface %s\n", __FUNCTION__, interface->dev.bus_id);
-               device_add (&interface->dev);
-               usb_create_driverfs_intf_files (interface);
+               dev_dbg (&dev->dev, "%s - registering interface %s\n", __FUNCTION__, pinterface->dev.bus_id);
+               device_add (&pinterface->dev);
+               usb_create_driverfs_intf_files (pinterface);
        }
        /* add a /proc/bus/usb entry */
        usbfs_add_device(dev);
diff --git a/reactos/drivers/usb/cromwell/core/usbcore.xml b/reactos/drivers/usb/cromwell/core/usbcore.xml
new file mode 100644 (file)
index 0000000..2d8aef6
--- /dev/null
@@ -0,0 +1,21 @@
+<module name="usbcore" type="kernelmodedriver" installbase="system32/drivers" installname="usbcore.sys" warnings="true">
+        <importlibrary definition="usbcore.def" />
+       <define name="__USE_W32API" />
+       <define name="DEBUG_MODE" />
+       <include base="ntoskrnl">include</include>
+       <library>ntoskrnl</library>
+       <library>hal</library> 
+       <file>message.c</file>
+       <file>hcd.c</file>
+       <file>hcd-pci.c</file>
+       <file>hub.c</file>
+       <file>usb.c</file>
+       <file>config.c</file>
+       <file>urb.c</file>
+       <file>buffer_simple.c</file>
+       <file>usb-debug.c</file>
+       <file>../sys/ros_wrapper.c</file>
+       <file>../sys/linuxwrapper.c</file>
+       <file>usbcore.c</file>
+       <file>usbcore.rc</file>
+</module>
diff --git a/reactos/drivers/usb/cromwell/directory.xml b/reactos/drivers/usb/cromwell/directory.xml
new file mode 100644 (file)
index 0000000..d002f1a
--- /dev/null
@@ -0,0 +1,9 @@
+<directory name="core">\r
+       <xi:include href="core/usbcore.xml" />\r
+</directory>\r
+<directory name="host">\r
+       <xi:include href="host/host.xml" />\r
+</directory>\r
+<directory name="uhci">\r
+       <xi:include href="uhci/uhci.xml" />\r
+</directory>\r
diff --git a/reactos/drivers/usb/cromwell/host/host.xml b/reactos/drivers/usb/cromwell/host/host.xml
new file mode 100644 (file)
index 0000000..c8b4605
--- /dev/null
@@ -0,0 +1,15 @@
+<module name="ohci" type="kernelmodedriver" installbase="system32/drivers" installname="ohci.sys" warnings="true">
+        <importlibrary definition="ohci.def" />
+       <define name="__USE_W32API" />
+       <define name="DEBUG_MODE" />
+       <include base="ntoskrnl">include</include>
+       <include>../linux</include>
+       <library>ntoskrnl</library>
+       <library>hal</library>
+       <library>usbcore</library>
+       <file>ohci-hcd.c</file>
+       <file>../sys/ros_wrapper.c</file>
+       <file>../sys/linuxwrapper.c</file>
+       <file>ohci_main.c</file>
+       <file>ohci.rc</file>
+</module>
index 57c6182..66f8632 100644 (file)
@@ -6,7 +6,8 @@
 
 #include <ddk/ntddk.h>
 #include <debug.h>
-#include "../linux/linux_wrapper.h"
+#include "../usb_wrapper.h"
+#include "../core/hcd.h"
 #include "ohci_main.h"
 
 // declare basic init funcs
index 06e3b4e..f7258cf 100644 (file)
@@ -15,6 +15,7 @@ typedef struct _OHCI_DRIVER_EXTENSION
    //OHCI_HW_INITIALIZATION_DATA InitializationData;
    PVOID HwContext;
    //UNICODE_STRING RegistryPath;
+
 } OHCI_DRIVER_EXTENSION, *POHCI_DRIVER_EXTENSION;
 
 typedef struct _OHCI_DEVICE_EXTENSTION
index ef1c1f7..2f31091 100644 (file)
@@ -109,10 +109,12 @@ struct usb_host_interface {
  * All standards-conformant USB devices that use isochronous endpoints
  * will use them in non-default settings.
  */
+
 struct usb_interface {
        /* array of alternate settings for this interface.
         * these will be in numeric order, 0..num_altsettting
         */
+
        struct usb_host_interface *altsetting;
 
        unsigned act_altsetting;        /* active alternate setting */
@@ -123,7 +125,7 @@ struct usb_interface {
        int minor;                      /* minor number this interface is bound to */
        struct device dev;              /* interface specific device info */
        struct class_device class_dev;
-};
+}USB_INTERFACE, *PUSB_INTERFACE;
 #define        to_usb_interface(d) container_of(d, struct usb_interface, dev)
 #define class_dev_to_usb_interface(d) container_of(d, struct usb_interface, class_dev)
 #define        interface_to_usbdev(intf) \
@@ -148,11 +150,12 @@ static inline void usb_set_intfdata (struct usb_interface *intf, void *data)
  */
 struct usb_host_config {
        struct usb_config_descriptor    desc;
-
-       /* the interfaces associated with this configuration
-        * these will be in numeric order, 0..desc.bNumInterfaces
-        */
-       struct usb_interface *interface;
+//     
+//     /* the interfaces associated with this configuration
+//      * these will be in numeric order, 0..desc.bNumInterfaces
+//      */
+//
+       struct usb_interface *pinterface;
 
        unsigned char *extra;   /* Extra descriptors */
        int extralen;
@@ -289,7 +292,7 @@ extern void usb_driver_claim_interface(struct usb_driver *driver,
 extern int usb_interface_claimed(struct usb_interface *iface);
 extern void usb_driver_release_interface(struct usb_driver *driver,
                        struct usb_interface *iface);
-const struct usb_device_id *usb_match_id(struct usb_interface *interface,
+const struct usb_device_id *usb_match_id(struct usb_interface *pinterface,
                                         const struct usb_device_id *id);
 
 extern struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor);
index 99674c4..c5f010a 100644 (file)
 #include <linux/proc_fs.h>
 #endif
 
-#ifdef CONFIG_USB_DEBUG
+//#ifdef CONFIG_USB_DEBUG
 #define DEBUG
-#else
-#undef DEBUG
-#endif
+//#else
+//#undef DEBUG
+//#endif
 
 #if 0
 #include <linux/usb.h>
@@ -2615,7 +2615,7 @@ void __exit uhci_hcd_cleanup(void)
                kfree(errbuf);
 }
 
-module_init(uhci_hcd_init);
+/*module_init(uhci_hcd_init);*/
 module_exit(uhci_hcd_cleanup);
 
 MODULE_AUTHOR(DRIVER_AUTHOR);
diff --git a/reactos/drivers/usb/cromwell/uhci/uhci.xml b/reactos/drivers/usb/cromwell/uhci/uhci.xml
new file mode 100644 (file)
index 0000000..c9878e4
--- /dev/null
@@ -0,0 +1,15 @@
+<module name="uhci" type="kernelmodedriver" installbase="system32/drivers" installname="uhci.sys" warnings="true">
+        <importlibrary definition="uhci.def" />
+       <define name="__USE_W32API" />
+       <define name="DEBUG_MODE" />
+       <include base="ntoskrnl">include</include>
+       <include>../linux</include>
+       <library>ntoskrnl</library>
+       <library>hal</library>
+       <library>usbcore</library>
+       <file>uhci-hcd.c</file>
+       <file>../sys/ros_wrapper.c</file>
+       <file>../sys/linuxwrapper.c</file>
+       <file>uhci_main.c</file>
+       <file>uhci.rc</file>
+</module>
index b19cb49..f917425 100644 (file)
@@ -5,6 +5,7 @@
 */
 
 #include <ddk/ntddk.h>
+#define DEBUG
 #include <debug.h>
 
 // config and include core/hcd.h, for hc_device struct
@@ -13,7 +14,6 @@
 
 #include "../host/ohci_main.h"
 
-
 // declare basic init funcs
 void init_wrapper(struct pci_dev *probe_dev);
 int uhci_hcd_init(void);
@@ -30,7 +30,8 @@ struct pci_dev *dev;
 
 #define USB_UHCI_TAG TAG('u','s','b','u')
 
-NTSTATUS STDCALL AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT pdo)
+NTSTATUS STDCALL 
+AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT pdo)
 {
        PDEVICE_OBJECT fdo;
        NTSTATUS Status;
@@ -61,20 +62,21 @@ NTSTATUS STDCALL AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT pdo)
    
        // Create a unicode device name
        DeviceNumber = 0; //TODO: Allocate new device number every time
-       swprintf(DeviceBuffer, L"\\Device\\USBFDO-%lu", DeviceNumber);
+       swprintf(DeviceBuffer, L"\\Device\\USBPDO-%lu", DeviceNumber);
        RtlInitUnicodeString(&DeviceName, DeviceBuffer);
 
        Status = IoCreateDevice(DriverObject,
-                                   sizeof(OHCI_DEVICE_EXTENSION)/* + DriverExtension->InitializationData.HwDeviceExtensionSize*/,
-                                                       &DeviceName,
-                                                       FILE_DEVICE_CONTROLLER,
-                                                       0,
-                                                       FALSE,
-                                                       &fdo);
+                sizeof(OHCI_DEVICE_EXTENSION),
+            /* + DriverExtension->InitializationData.HwDeviceExtensionSize*/
+               &DeviceName,
+               FILE_DEVICE_CONTROLLER,
+               0,
+               FALSE,
+               &fdo);
 
        if (!NT_SUCCESS(Status))
        {
-               DPRINT("IoCreateDevice call failed with status 0x%08x\n", Status);
+               DPRINT1("IoCreateDevice call failed with status 0x%08x\n", Status);
                return Status;
        }
 
@@ -93,7 +95,7 @@ NTSTATUS STDCALL AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT pdo)
 
        /* Get bus number from the upper level bus driver. */
        Size = sizeof(ULONG);
-       Status = IoGetDeviceProperty(
+/*     Status = IoGetDeviceProperty(
                                pdo,
                                DevicePropertyBusNumber,
                                Size,
@@ -102,15 +104,16 @@ NTSTATUS STDCALL AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT pdo)
        
        if (!NT_SUCCESS(Status))
        {
-               DPRINT("Couldn't get an information from bus driver. Panic!!!\n");
+               DPRINT1("Couldn't get an information from bus driver. Panic!!!\n");
                return Status;
        }
-
-       DPRINT("Done AddDevice\n");
+*/
+       DPRINT1("Done AddDevice\n");
        return STATUS_SUCCESS;
 }
 
-VOID STDCALL DriverUnload(PDRIVER_OBJECT DriverObject)
+VOID STDCALL 
+DriverUnload(PDRIVER_OBJECT DriverObject)
 {
        DPRINT1("DriverUnload()\n");
 
@@ -127,7 +130,8 @@ VOID STDCALL DriverUnload(PDRIVER_OBJECT DriverObject)
        uhci_hcd_cleanup();
 }
 
-NTSTATUS InitLinuxWrapper(PDEVICE_OBJECT DeviceObject)
+NTSTATUS
+InitLinuxWrapper(PDEVICE_OBJECT DeviceObject)
 {
        NTSTATUS Status;
        POHCI_DEVICE_EXTENSION DeviceExtension = (POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
@@ -153,7 +157,7 @@ NTSTATUS InitLinuxWrapper(PDEVICE_OBJECT DeviceObject)
        // Probe device with real id now
        uhci_pci_driver.probe(dev, uhci_pci_ids);
 
-       DPRINT("InitLinuxWrapper() done\n");
+       DPRINT1("InitLinuxWrapper() done\n");
 
        return STATUS_SUCCESS;
 }
@@ -264,7 +268,8 @@ OHCD_PnPStartDevice(IN PDEVICE_OBJECT DeviceObject,
 }
 
 // Dispatch PNP
-NTSTATUS STDCALL DispatchPnp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+NTSTATUS STDCALL
+DispatchPnp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
 {
    PIO_STACK_LOCATION IrpSp;
    NTSTATUS Status;
@@ -274,10 +279,9 @@ NTSTATUS STDCALL DispatchPnp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
    switch (IrpSp->MinorFunction)
    {
       case IRP_MN_START_DEVICE:
-         //Status = IntVideoPortForwardIrpAndWait(DeviceObject, Irp);
-         //if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
-         
-                Status = OHCD_PnPStartDevice(DeviceObject, Irp);
+//         Status = ForwardIrpAndWait(DeviceObject, Irp);
+//         if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
+                Status = OHCD_PnPStartDevice(DeviceObject, Irp);
          Irp->IoStatus.Status = Status;
          Irp->IoStatus.Information = 0;
          IoCompleteRequest(Irp, IO_NO_INCREMENT);
@@ -290,8 +294,8 @@ NTSTATUS STDCALL DispatchPnp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
       case IRP_MN_SURPRISE_REMOVAL:
 
       case IRP_MN_STOP_DEVICE:
-         //Status = IntVideoPortForwardIrpAndWait(DeviceObject, Irp);
-         //if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
+//         Status = ForwardIrpAndWait(DeviceObject, Irp);
+//         if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
             Status = STATUS_SUCCESS;
          Irp->IoStatus.Status = Status;
          Irp->IoStatus.Information = 0;
@@ -316,22 +320,28 @@ NTSTATUS STDCALL DispatchPnp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
    return Status;
 }
 
-NTSTATUS STDCALL DispatchPower(PDEVICE_OBJECT fido, PIRP Irp)
+NTSTATUS STDCALL 
+DispatchPower(PDEVICE_OBJECT fido, PIRP Irp)
 {
        DbgPrint("IRP_MJ_POWER dispatch\n");
        return STATUS_SUCCESS;
 }
 
+
 /*
  * Standard DriverEntry method.
  */
 NTSTATUS STDCALL
 DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegPath)
 {
-       DriverObject->DriverUnload = DriverUnload;
-       DriverObject->DriverExtension->AddDevice = AddDevice;
-       DriverObject->MajorFunction[IRP_MJ_PNP] = DispatchPnp;
-       DriverObject->MajorFunction[IRP_MJ_POWER] = DispatchPower;
 
-       return STATUS_SUCCESS;
+   DPRINT1("******************** Cromwell UHCI ********************\n");
+
+   DriverObject->DriverUnload = DriverUnload;
+   DriverObject->DriverExtension->AddDevice = AddDevice;
+
+   DriverObject->MajorFunction[IRP_MJ_PNP] = DispatchPnp;
+   DriverObject->MajorFunction[IRP_MJ_POWER] = DispatchPower;
+
+   return STATUS_SUCCESS;
 }
index f454f2f..0d9ab29 100644 (file)
@@ -2,10 +2,21 @@
 //#include <ntos/types.h>
 //#include <ddk/extypes.h>
 #include <ddk/ntddk.h>
+#define NDEBUG
 #include <debug.h>
 
 void wait_ms(int mils);
 
+#ifndef _snprintf
+int _snprintf(char * buf, size_t cnt, const char *fmt, ...);
+#endif
+#ifndef sprintf
+int sprintf(char * buf, const char *fmt, ...);
+#endif
+#ifndef swprintf
+int swprintf(wchar_t *buf, const wchar_t *fmt, ...);
+#endif
+
 #include "linux/linux_wrapper.h"
 #define __KERNEL__
 #undef CONFIG_PCI