Adding Cromwell to usb.

svn path=/trunk/; revision=15720
This commit is contained in:
James Tabor 2005-06-01 21:55:36 +00:00
parent e8d9ee409c
commit 372172fd93
16 changed files with 195 additions and 109 deletions

View file

@ -101,56 +101,56 @@ static int usb_parse_endpoint(struct usb_host_endpoint *endpoint, unsigned char
return parsed; 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; int i, len, numskipped, retval, parsed = 0;
struct usb_descriptor_header *header; struct usb_descriptor_header *header;
struct usb_host_interface *ifp; struct usb_host_interface *ifp;
unsigned char *begin; unsigned char *begin;
interface->act_altsetting = 0; pinterface->act_altsetting = 0;
interface->num_altsetting = 0; pinterface->num_altsetting = 0;
interface->max_altsetting = USB_ALTSETTINGALLOC; pinterface->max_altsetting = USB_ALTSETTINGALLOC;
device_initialize(&interface->dev); device_initialize(&pinterface->dev);
interface->altsetting = kmalloc(sizeof(*interface->altsetting) * interface->max_altsetting, pinterface->altsetting = kmalloc(sizeof(*pinterface->altsetting) * pinterface->max_altsetting,
GFP_KERNEL); GFP_KERNEL);
if (!interface->altsetting) { if (!pinterface->altsetting) {
err("couldn't kmalloc interface->altsetting"); err("couldn't kmalloc pinterface->altsetting");
return -1; return -1;
} }
while (size > 0) { while (size > 0) {
struct usb_interface_descriptor *d; struct usb_interface_descriptor *d;
if (interface->num_altsetting >= interface->max_altsetting) { if (pinterface->num_altsetting >= pinterface->max_altsetting) {
struct usb_host_interface *ptr; struct usb_host_interface *ptr;
int oldmas; int oldmas;
oldmas = interface->max_altsetting; oldmas = pinterface->max_altsetting;
interface->max_altsetting += USB_ALTSETTINGALLOC; pinterface->max_altsetting += USB_ALTSETTINGALLOC;
if (interface->max_altsetting > USB_MAXALTSETTING) { if (pinterface->max_altsetting > USB_MAXALTSETTING) {
warn("too many alternate settings (incr %d max %d)\n", warn("too many alternate settings (incr %d max %d)\n",
USB_ALTSETTINGALLOC, USB_MAXALTSETTING); USB_ALTSETTINGALLOC, USB_MAXALTSETTING);
return -1; return -1;
} }
ptr = kmalloc(sizeof(*ptr) * interface->max_altsetting, GFP_KERNEL); ptr = kmalloc(sizeof(*ptr) * pinterface->max_altsetting, GFP_KERNEL);
if (ptr == NULL) { if (ptr == NULL) {
err("couldn't kmalloc interface->altsetting"); err("couldn't kmalloc pinterface->altsetting");
return -1; return -1;
} }
memcpy(ptr, interface->altsetting, sizeof(*interface->altsetting) * oldmas); memcpy(ptr, pinterface->altsetting, sizeof(*pinterface->altsetting) * oldmas);
kfree(interface->altsetting); kfree(pinterface->altsetting);
interface->altsetting = ptr; pinterface->altsetting = ptr;
} }
ifp = interface->altsetting + interface->num_altsetting; ifp = pinterface->altsetting + pinterface->num_altsetting;
ifp->endpoint = NULL; ifp->endpoint = NULL;
ifp->extra = NULL; ifp->extra = NULL;
ifp->extralen = 0; ifp->extralen = 0;
interface->num_altsetting++; pinterface->num_altsetting++;
memcpy(ifp, buffer, USB_DT_INTERFACE_SIZE); memcpy(ifp, buffer, USB_DT_INTERFACE_SIZE);
@ -268,16 +268,16 @@ int usb_parse_configuration(struct usb_host_config *config, char *buffer)
return -1; return -1;
} }
config->interface = (struct usb_interface *) config->pinterface = (struct usb_interface *)
kmalloc(config->desc.bNumInterfaces * kmalloc(config->desc.bNumInterfaces *
sizeof(struct usb_interface), GFP_KERNEL); sizeof(struct usb_interface), GFP_KERNEL);
dbg("kmalloc IF %p, numif %i", config->interface, config->desc.bNumInterfaces); dbg("kmalloc IF %p, numif %i", config->pinterface, config->desc.bNumInterfaces);
if (!config->interface) { if (!config->pinterface) {
err("out of memory"); err("out of memory");
return -1; return -1;
} }
memset(config->interface, 0, memset(config->pinterface, 0,
config->desc.bNumInterfaces * sizeof(struct usb_interface)); config->desc.bNumInterfaces * sizeof(struct usb_interface));
buffer += config->desc.bLength; 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) if (retval < 0)
return retval; return retval;
@ -367,12 +367,12 @@ void usb_destroy_configuration(struct usb_device *dev)
for (c = 0; c < dev->descriptor.bNumConfigurations; c++) { for (c = 0; c < dev->descriptor.bNumConfigurations; c++) {
struct usb_host_config *cf = &dev->config[c]; struct usb_host_config *cf = &dev->config[c];
if (!cf->interface) if (!cf->pinterface)
break; break;
for (i = 0; i < cf->desc.bNumInterfaces; i++) { for (i = 0; i < cf->desc.bNumInterfaces; i++) {
struct usb_interface *ifp = struct usb_interface *ifp =
&cf->interface[i]; &cf->pinterface[i];
if (!ifp->altsetting) if (!ifp->altsetting)
break; break;
@ -398,7 +398,7 @@ void usb_destroy_configuration(struct usb_device *dev)
kfree(ifp->altsetting); kfree(ifp->altsetting);
} }
kfree(cf->interface); kfree(cf->pinterface);
} }
kfree(dev->config); kfree(dev->config);
} }

View file

@ -424,7 +424,7 @@ extern void usb_bus_get (struct usb_bus *bus);
extern void usb_bus_put (struct usb_bus *bus); extern void usb_bus_put (struct usb_bus *bus);
extern int usb_find_interface_driver (struct usb_device *dev, 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))) #define usb_endpoint_halt(dev, ep, out) ((dev)->halted[out] |= (1 << (ep)))

View file

@ -42,8 +42,8 @@
#endif #endif
/* Wakes up khubd */ /* Wakes up khubd */
static spinlock_t hub_event_lock = SPIN_LOCK_UNLOCKED; //static spinlock_t hub_event_lock = SPIN_LOCK_UNLOCKED;
static DECLARE_MUTEX(usb_address0_sem); //static DECLARE_MUTEX(usb_address0_sem);
static LIST_HEAD(hub_event_list); /* List of hubs needing servicing */ static LIST_HEAD(hub_event_list); /* List of hubs needing servicing */
static LIST_HEAD(hub_list); /* List of all hubs (for cleanup) */ 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 */ /* for dev_info, dev_dbg, etc */
static inline struct device *hubdev (struct usb_device *dev) 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 */ /* 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, static int hub_port_status(struct usb_device *dev, int port,
u16 *status, u16 *change) 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; int ret;
ret = get_port_status(dev, port + 1, &hub->status->port); 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++) { 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; struct usb_interface_descriptor *as;
as = &intf->altsetting[intf->act_altsetting].desc; as = &intf->altsetting[intf->act_altsetting].desc;

View file

@ -683,7 +683,7 @@ void usb_set_maxpacket(struct usb_device *dev)
/* NOTE: affects all endpoints _except_ ep0 */ /* NOTE: affects all endpoints _except_ ep0 */
for (i=0; i<dev->actconfig->desc.bNumInterfaces; i++) { 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_interface *as = ifp->altsetting + ifp->act_altsetting;
struct usb_host_endpoint *ep = as->endpoint; struct usb_host_endpoint *ep = as->endpoint;
int e; 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 * Returns zero on success, or else the status code returned by the
* underlying usb_control_msg() call. * 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_interface *iface;
struct usb_host_interface *iface_as; struct usb_host_interface *iface_as;
int i, ret; int i, ret;
void (*disable)(struct usb_device *, int) = dev->bus->op->disable; 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) { if (!iface) {
warn("selecting invalid interface %d", interface); warn("selecting invalid interface %d", pinterface);
return -EINVAL; return -EINVAL;
} }
@ -817,7 +817,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
only has one alternate setting */ only has one alternate setting */
if (iface->num_altsetting == 1) { if (iface->num_altsetting == 1) {
dbg("ignoring set_interface for dev %d, iface %d, alt %d", dbg("ignoring set_interface for dev %d, iface %d, alt %d",
dev->devnum, interface, alternate); dev->devnum, pinterface, alternate);
return 0; 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, USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE,
iface->altsetting[alternate] iface->altsetting[alternate]
.desc.bAlternateSetting, .desc.bAlternateSetting,
interface, NULL, 0, HZ * 5)) < 0) pinterface, NULL, 0, HZ * 5)) < 0)
return ret; return ret;
/* FIXME drivers shouldn't need to replicate/bugfix the logic here /* FIXME drivers shouldn't need to replicate/bugfix the logic here

View file

@ -42,7 +42,7 @@ static void usb_show_config(struct usb_host_config *config)
usb_show_config_descriptor(&config->desc); usb_show_config_descriptor(&config->desc);
for (i = 0; i < config->desc.bNumInterfaces; i++) { for (i = 0; i < config->desc.bNumInterfaces; i++) {
ifp = config->interface + i; ifp = config->pinterface + i;
if (!ifp) if (!ifp)
break; break;

View file

@ -212,9 +212,9 @@ struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, unsigned ifnum)
int i; int i;
for (i = 0; i < dev->actconfig->desc.bNumInterfaces; 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) .desc.bInterfaceNumber == ifnum)
return &dev->actconfig->interface[i]; return &dev->actconfig->pinterface[i];
return NULL; return NULL;
} }
@ -239,13 +239,13 @@ usb_epnum_to_ep_desc(struct usb_device *dev, unsigned epnum)
int i, j, k; int i, j, k;
for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++)
for (j = 0; j < dev->actconfig->interface[i].num_altsetting; j++) for (j = 0; j < dev->actconfig->pinterface[i].num_altsetting; j++)
for (k = 0; k < dev->actconfig->interface[i] for (k = 0; k < dev->actconfig->pinterface[i]
.altsetting[j].desc.bNumEndpoints; k++) .altsetting[j].desc.bNumEndpoints; k++)
if (epnum == dev->actconfig->interface[i] if (epnum == dev->actconfig->pinterface[i]
.altsetting[j].endpoint[k] .altsetting[j].endpoint[k]
.desc.bEndpointAddress) .desc.bEndpointAddress)
return &dev->actconfig->interface[i] return &dev->actconfig->pinterface[i]
.altsetting[j].endpoint[k] .altsetting[j].endpoint[k]
.desc; .desc;
@ -391,7 +391,7 @@ void usb_driver_release_interface(struct usb_driver *driver, struct usb_interfac
* its associated class and subclass. * its associated class and subclass.
*/ */
const struct usb_device_id * 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_host_interface *intf;
struct usb_device *dev; struct usb_device *dev;
@ -400,8 +400,8 @@ usb_match_id(struct usb_interface *interface, const struct usb_device_id *id)
if (id == NULL) if (id == NULL)
return NULL; return NULL;
intf = &interface->altsetting [interface->act_altsetting]; intf = &pinterface->altsetting [pinterface->act_altsetting];
dev = interface_to_usbdev(interface); dev = interface_to_usbdev(pinterface);
/* It is important to check that id->driver_info is nonzero, /* It is important to check that id->driver_info is nonzero,
since an entry that is all zeroes except for a 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"); dev_dbg (&dev->dev, "unregistering interfaces\n");
if (dev->actconfig) { if (dev->actconfig) {
for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) {
struct usb_interface *interface; struct usb_interface *pinterface;
/* remove this interface */ /* remove this interface */
interface = &dev->actconfig->interface[i]; pinterface = &dev->actconfig->pinterface[i];
device_unregister(&interface->dev); 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. /* Register all of the interfaces for this device with the driver core.
* Remember, interfaces get bound to drivers, not devices. */ * Remember, interfaces get bound to drivers, not devices. */
for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { 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; struct usb_interface_descriptor *desc;
desc = &interface->altsetting [interface->act_altsetting].desc; desc = &pinterface->altsetting [pinterface->act_altsetting].desc;
interface->dev.parent = &dev->dev; pinterface->dev.parent = &dev->dev;
interface->dev.driver = NULL; pinterface->dev.driver = NULL;
interface->dev.bus = &usb_bus_type; pinterface->dev.bus = &usb_bus_type;
interface->dev.dma_mask = parent->dma_mask; pinterface->dev.dma_mask = parent->dma_mask;
sprintf (&interface->dev.bus_id[0], "%d-%s:%d", sprintf (&pinterface->dev.bus_id[0], "%d-%s:%d",
dev->bus->busnum, dev->devpath, dev->bus->busnum, dev->devpath,
desc->bInterfaceNumber); desc->bInterfaceNumber);
if (!desc->iInterface if (!desc->iInterface
|| usb_string (dev, desc->iInterface, || usb_string (dev, desc->iInterface,
interface->dev.name, pinterface->dev.name,
sizeof interface->dev.name) <= 0) { sizeof pinterface->dev.name) <= 0) {
/* typically devices won't bother with interface /* typically devices won't bother with interface
* descriptions; this is the normal case. an * descriptions; this is the normal case. an
* interface's driver might describe it better. * interface's driver might describe it better.
* (also: iInterface is per-altsetting ...) * (also: iInterface is per-altsetting ...)
*/ */
sprintf (&interface->dev.name[0], sprintf (&pinterface->dev.name[0],
"usb-%s-%s interface %d", "usb-%s-%s interface %d",
dev->bus->bus_name, dev->devpath, dev->bus->bus_name, dev->devpath,
desc->bInterfaceNumber); 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); dev_dbg (&dev->dev, "%s - registering interface %s\n", __FUNCTION__, pinterface->dev.bus_id);
device_add (&interface->dev); device_add (&pinterface->dev);
usb_create_driverfs_intf_files (interface); usb_create_driverfs_intf_files (pinterface);
} }
/* add a /proc/bus/usb entry */ /* add a /proc/bus/usb entry */
usbfs_add_device(dev); usbfs_add_device(dev);

View file

@ -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>

View file

@ -0,0 +1,9 @@
<directory name="core">
<xi:include href="core/usbcore.xml" />
</directory>
<directory name="host">
<xi:include href="host/host.xml" />
</directory>
<directory name="uhci">
<xi:include href="uhci/uhci.xml" />
</directory>

View file

@ -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>

View file

@ -6,7 +6,8 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <debug.h> #include <debug.h>
#include "../linux/linux_wrapper.h" #include "../usb_wrapper.h"
#include "../core/hcd.h"
#include "ohci_main.h" #include "ohci_main.h"
// declare basic init funcs // declare basic init funcs

View file

@ -15,6 +15,7 @@ typedef struct _OHCI_DRIVER_EXTENSION
//OHCI_HW_INITIALIZATION_DATA InitializationData; //OHCI_HW_INITIALIZATION_DATA InitializationData;
PVOID HwContext; PVOID HwContext;
//UNICODE_STRING RegistryPath; //UNICODE_STRING RegistryPath;
} OHCI_DRIVER_EXTENSION, *POHCI_DRIVER_EXTENSION; } OHCI_DRIVER_EXTENSION, *POHCI_DRIVER_EXTENSION;
typedef struct _OHCI_DEVICE_EXTENSTION typedef struct _OHCI_DEVICE_EXTENSTION

View file

@ -109,10 +109,12 @@ struct usb_host_interface {
* All standards-conformant USB devices that use isochronous endpoints * All standards-conformant USB devices that use isochronous endpoints
* will use them in non-default settings. * will use them in non-default settings.
*/ */
struct usb_interface { struct usb_interface {
/* array of alternate settings for this interface. /* array of alternate settings for this interface.
* these will be in numeric order, 0..num_altsettting * these will be in numeric order, 0..num_altsettting
*/ */
struct usb_host_interface *altsetting; struct usb_host_interface *altsetting;
unsigned act_altsetting; /* active alternate setting */ unsigned act_altsetting; /* active alternate setting */
@ -123,7 +125,7 @@ struct usb_interface {
int minor; /* minor number this interface is bound to */ int minor; /* minor number this interface is bound to */
struct device dev; /* interface specific device info */ struct device dev; /* interface specific device info */
struct class_device class_dev; struct class_device class_dev;
}; }USB_INTERFACE, *PUSB_INTERFACE;
#define to_usb_interface(d) container_of(d, struct usb_interface, dev) #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 class_dev_to_usb_interface(d) container_of(d, struct usb_interface, class_dev)
#define interface_to_usbdev(intf) \ #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_host_config {
struct usb_config_descriptor desc; struct usb_config_descriptor desc;
//
/* the interfaces associated with this configuration // /* the interfaces associated with this configuration
* these will be in numeric order, 0..desc.bNumInterfaces // * these will be in numeric order, 0..desc.bNumInterfaces
*/ // */
struct usb_interface *interface; //
struct usb_interface *pinterface;
unsigned char *extra; /* Extra descriptors */ unsigned char *extra; /* Extra descriptors */
int extralen; 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 int usb_interface_claimed(struct usb_interface *iface);
extern void usb_driver_release_interface(struct usb_driver *driver, extern void usb_driver_release_interface(struct usb_driver *driver,
struct usb_interface *iface); 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); const struct usb_device_id *id);
extern struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor); extern struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor);

View file

@ -44,11 +44,11 @@
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#endif #endif
#ifdef CONFIG_USB_DEBUG //#ifdef CONFIG_USB_DEBUG
#define DEBUG #define DEBUG
#else //#else
#undef DEBUG //#undef DEBUG
#endif //#endif
#if 0 #if 0
#include <linux/usb.h> #include <linux/usb.h>
@ -2615,7 +2615,7 @@ void __exit uhci_hcd_cleanup(void)
kfree(errbuf); kfree(errbuf);
} }
module_init(uhci_hcd_init); /*module_init(uhci_hcd_init);*/
module_exit(uhci_hcd_cleanup); module_exit(uhci_hcd_cleanup);
MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_AUTHOR(DRIVER_AUTHOR);

View file

@ -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>

View file

@ -5,6 +5,7 @@
*/ */
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#define DEBUG
#include <debug.h> #include <debug.h>
// config and include core/hcd.h, for hc_device struct // config and include core/hcd.h, for hc_device struct
@ -13,7 +14,6 @@
#include "../host/ohci_main.h" #include "../host/ohci_main.h"
// declare basic init funcs // declare basic init funcs
void init_wrapper(struct pci_dev *probe_dev); void init_wrapper(struct pci_dev *probe_dev);
int uhci_hcd_init(void); int uhci_hcd_init(void);
@ -30,7 +30,8 @@ struct pci_dev *dev;
#define USB_UHCI_TAG TAG('u','s','b','u') #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; PDEVICE_OBJECT fdo;
NTSTATUS Status; NTSTATUS Status;
@ -61,20 +62,21 @@ NTSTATUS STDCALL AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT pdo)
// Create a unicode device name // Create a unicode device name
DeviceNumber = 0; //TODO: Allocate new device number every time 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); RtlInitUnicodeString(&DeviceName, DeviceBuffer);
Status = IoCreateDevice(DriverObject, Status = IoCreateDevice(DriverObject,
sizeof(OHCI_DEVICE_EXTENSION)/* + DriverExtension->InitializationData.HwDeviceExtensionSize*/, sizeof(OHCI_DEVICE_EXTENSION),
&DeviceName, /* + DriverExtension->InitializationData.HwDeviceExtensionSize*/
FILE_DEVICE_CONTROLLER, &DeviceName,
0, FILE_DEVICE_CONTROLLER,
FALSE, 0,
&fdo); FALSE,
&fdo);
if (!NT_SUCCESS(Status)) 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; return Status;
} }
@ -93,7 +95,7 @@ NTSTATUS STDCALL AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT pdo)
/* Get bus number from the upper level bus driver. */ /* Get bus number from the upper level bus driver. */
Size = sizeof(ULONG); Size = sizeof(ULONG);
Status = IoGetDeviceProperty( /* Status = IoGetDeviceProperty(
pdo, pdo,
DevicePropertyBusNumber, DevicePropertyBusNumber,
Size, Size,
@ -102,15 +104,16 @@ NTSTATUS STDCALL AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT pdo)
if (!NT_SUCCESS(Status)) 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; return Status;
} }
*/
DPRINT("Done AddDevice\n"); DPRINT1("Done AddDevice\n");
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
VOID STDCALL DriverUnload(PDRIVER_OBJECT DriverObject) VOID STDCALL
DriverUnload(PDRIVER_OBJECT DriverObject)
{ {
DPRINT1("DriverUnload()\n"); DPRINT1("DriverUnload()\n");
@ -127,7 +130,8 @@ VOID STDCALL DriverUnload(PDRIVER_OBJECT DriverObject)
uhci_hcd_cleanup(); uhci_hcd_cleanup();
} }
NTSTATUS InitLinuxWrapper(PDEVICE_OBJECT DeviceObject) NTSTATUS
InitLinuxWrapper(PDEVICE_OBJECT DeviceObject)
{ {
NTSTATUS Status; NTSTATUS Status;
POHCI_DEVICE_EXTENSION DeviceExtension = (POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension; POHCI_DEVICE_EXTENSION DeviceExtension = (POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
@ -153,7 +157,7 @@ NTSTATUS InitLinuxWrapper(PDEVICE_OBJECT DeviceObject)
// Probe device with real id now // Probe device with real id now
uhci_pci_driver.probe(dev, uhci_pci_ids); uhci_pci_driver.probe(dev, uhci_pci_ids);
DPRINT("InitLinuxWrapper() done\n"); DPRINT1("InitLinuxWrapper() done\n");
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -264,7 +268,8 @@ OHCD_PnPStartDevice(IN PDEVICE_OBJECT DeviceObject,
} }
// Dispatch PNP // Dispatch PNP
NTSTATUS STDCALL DispatchPnp(PDEVICE_OBJECT DeviceObject, PIRP Irp) NTSTATUS STDCALL
DispatchPnp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
{ {
PIO_STACK_LOCATION IrpSp; PIO_STACK_LOCATION IrpSp;
NTSTATUS Status; NTSTATUS Status;
@ -274,10 +279,9 @@ NTSTATUS STDCALL DispatchPnp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
switch (IrpSp->MinorFunction) switch (IrpSp->MinorFunction)
{ {
case IRP_MN_START_DEVICE: case IRP_MN_START_DEVICE:
//Status = IntVideoPortForwardIrpAndWait(DeviceObject, Irp); // Status = ForwardIrpAndWait(DeviceObject, Irp);
//if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status)) // if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
Status = OHCD_PnPStartDevice(DeviceObject, Irp);
Status = OHCD_PnPStartDevice(DeviceObject, Irp);
Irp->IoStatus.Status = Status; Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT); 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_SURPRISE_REMOVAL:
case IRP_MN_STOP_DEVICE: case IRP_MN_STOP_DEVICE:
//Status = IntVideoPortForwardIrpAndWait(DeviceObject, Irp); // Status = ForwardIrpAndWait(DeviceObject, Irp);
//if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status)) // if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
Irp->IoStatus.Status = Status; Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
@ -316,22 +320,28 @@ NTSTATUS STDCALL DispatchPnp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
return Status; return Status;
} }
NTSTATUS STDCALL DispatchPower(PDEVICE_OBJECT fido, PIRP Irp) NTSTATUS STDCALL
DispatchPower(PDEVICE_OBJECT fido, PIRP Irp)
{ {
DbgPrint("IRP_MJ_POWER dispatch\n"); DbgPrint("IRP_MJ_POWER dispatch\n");
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
/* /*
* Standard DriverEntry method. * Standard DriverEntry method.
*/ */
NTSTATUS STDCALL NTSTATUS STDCALL
DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegPath) 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;
} }

View file

@ -2,10 +2,21 @@
//#include <ntos/types.h> //#include <ntos/types.h>
//#include <ddk/extypes.h> //#include <ddk/extypes.h>
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#define NDEBUG
#include <debug.h> #include <debug.h>
void wait_ms(int mils); 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" #include "linux/linux_wrapper.h"
#define __KERNEL__ #define __KERNEL__
#undef CONFIG_PCI #undef CONFIG_PCI