--- trunk/reactos/drivers/usb/cromwell/core/hcd.h 2005-02-25 12:20:36 UTC (rev 13740)
+++ trunk/reactos/drivers/usb/cromwell/core/hcd.h 2005-02-25 15:05:51 UTC (rev 13741)
@@ -161,10 +161,60 @@
struct pt_regs;
+// new struct from 2.6
struct hc_driver {
const char *description; /* "ehci-hcd" etc */
/* irq handler */
+ irqreturn_t (*irq) (struct usb_hcd *hcd, struct pt_regs *regs);
+
+ int flags;
+#define HCD_MEMORY 0x0001 /* HC regs use memory (else I/O) */
+#define HCD_USB11 0x0010 /* USB 1.1 */
+#define HCD_USB2 0x0020 /* USB 2.0 */
+
+ /* called to init HCD and root hub */
+ int (*reset) (struct usb_hcd *hcd);
+ int (*start) (struct usb_hcd *hcd);
+
+ /* called after all devices were suspended */
+ int (*suspend) (struct usb_hcd *hcd, u32 state);
+
+ /* called before any devices get resumed */
+ int (*resume) (struct usb_hcd *hcd);
+
+ /* cleanly make HCD stop writing memory and doing I/O */
+ void (*stop) (struct usb_hcd *hcd);
+
+ /* return current frame number */
+ int (*get_frame_number) (struct usb_hcd *hcd);
+
+ /* memory lifecycle */
+ struct usb_hcd *(*hcd_alloc) (void);
+ void (*hcd_free) (struct usb_hcd *hcd);
+
+ /* manage i/o requests, device state */
+ int (*urb_enqueue) (struct usb_hcd *hcd, struct urb *urb,
+ int mem_flags);
+ int (*urb_dequeue) (struct usb_hcd *hcd, struct urb *urb);
+
+ /* hw synch, freeing endpoint resources that urb_dequeue can't */
+ void (*endpoint_disable)(struct usb_hcd *hcd,
+ struct hcd_dev *dev, int bEndpointAddress);
+
+ /* root hub support */
+ int (*hub_status_data) (struct usb_hcd *hcd, char *buf);
+ int (*hub_control) (struct usb_hcd *hcd,
+ u16 typeReq, u16 wValue, u16 wIndex,
+ char *buf, u16 wLength);
+};
+
+// old version, "just in case"
+#if 0
+struct hc_driver {
+ const char *description; /* "ehci-hcd" etc */
+
+ /* irq handler */
void (*irq) (struct usb_hcd *hcd, struct pt_regs *regs);
int flags;
@@ -206,6 +256,7 @@
u16 typeReq, u16 wValue, u16 wIndex,
char *buf, u16 wLength);
};
+#endif
extern void STDCALL usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb, struct pt_regs *regs);
extern void STDCALL usb_bus_init (struct usb_bus *bus);
--- trunk/reactos/drivers/usb/cromwell/linux/linux_wrapper.h 2005-02-25 12:20:36 UTC (rev 13740)
+++ trunk/reactos/drivers/usb/cromwell/linux/linux_wrapper.h 2005-02-25 15:05:51 UTC (rev 13741)
@@ -12,6 +12,9 @@
*
* All structs and prototypes are based on kernel source 2.5.72
*
+ * Modified by Aleksey Bragin (aleksey@reactos.com) for ReactOS needs
+ *
+ *
* #include <standard-GPL-header.h>
*/
@@ -145,6 +148,14 @@
wait_queue_head_t wait;
};
+// windows lookaside list head
+typedef void* kmem_cache_t;
+
+struct dma_pool
+{
+ int dummy;
+};
+
/* from mod_devicetable.h */
struct usb_device_id {
@@ -286,6 +297,8 @@
#define MODULE_DESCRIPTION(a)
#define MODULE_LICENSE(a)
#define MODULE_DEVICE_TABLE(type,name) void* module_table_##name=&name
+#define MODULE_PARM(a,b)
+#define MODULE_PARM_DESC(a,b)
#define __devinit
#define __exit
@@ -313,6 +326,10 @@
#define unlikely(x) (x)
#define prefetch(x) 1
+#define inw(x) READ_PORT_USHORT((PUSHORT)(x))
+#define outw(x,p) WRITE_PORT_USHORT((PUSHORT)(p),(x))
+#define outl(x,p) WRITE_PORT_ULONG((PUSHORT)(p),(x))
+
/* The kernel macro for list_for_each_entry makes nonsense (have no clue
* why, this is just the same definition...) */
@@ -372,7 +389,7 @@
#define down_read(a) do {} while(0)
#define up_read(a) do {} while(0)
-#define DECLARE_WAIT_QUEUE_HEAD(x) int x
+#define DECLARE_WAIT_QUEUE_HEAD(x) KEVENT x
#define DECLARE_COMPLETION(x) struct completion x
@@ -383,6 +400,8 @@
/* PCI */
+#define to_pci_dev(n) container_of(n, struct pci_dev, dev)
+
#define pci_pool_create(a,b,c,d,e) (void*)1
#define pci_pool_alloc(a,b,c) my_pci_pool_alloc(a,b,c)
@@ -427,6 +446,16 @@
#define bus_register(a) do {} while(0)
#define bus_unregister(a) do {} while(0)
+/* DMA */
+//#define dma_pool_alloc(a,b,c) my_dma_pool_alloc((a),(b),(c))
+#define dma_pool_alloc(a,b,c) pci_pool_alloc(a,b,c)
+#define dma_pool_create(a,b,c,d,e) pci_pool_create(a,b,c,d,e)
+#define dma_pool_free(a,b,c) pci_pool_free(a,b,c)
+#define dma_pool_destroy(a) pci_pool_destroy(a)
+
+#define dma_alloc_coherent(a,b,c,d) NULL
+#define dma_free_coherent(a,b,c,d) do {} while(0)
+
#define dma_map_single(a,b,c,d) ((u32)(b)&0xfffffff)
#define dma_unmap_single(a,b,c,d) do {} while(0)
#define pci_unmap_single(a,b,c,d) do {} while(0)
@@ -451,11 +480,15 @@
#define PCI_ROM_RESOURCE 0
#define IORESOURCE_IO 1
-#define DECLARE_WAITQUEUE(a,b) wait_queue_head_t a=0
-#define init_waitqueue_head(a) do {} while(0)
+#define DECLARE_WAITQUEUE(a,b) KEVENT a=0
+#define init_waitqueue_head(a) my_init_waitqueue_head(a)
#define add_wait_queue(a,b) do {} while(0)
#define remove_wait_queue(a,b) do {} while(0)
+void my_init_waitqueue_head(PKEVENT a);
+VOID KeMemoryBarrier(VOID);
+
+#define mb() KeMemoryBarrier()
#define wmb() __asm__ __volatile__ ("": : :"memory")
#define rmb() __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")
@@ -478,7 +511,7 @@
#define wait_event_interruptible(x,y) do {} while(0)
#define interruptible_sleep_on(a) my_interruptible_sleep_on(a)
-void my_interruptible_sleep_on(int a);
+void my_interruptible_sleep_on(PKEVENT evnt);
#define flush_scheduled_work() do {} while(0)
#define refrigerator(x) do {} while(0)
@@ -492,7 +525,26 @@
#define yield() do {} while(0)
#define cpu_relax() do {} while(0)
+#define WARN_ON(a) do {} while(0)
+
/*------------------------------------------------------------------------*/
+/* Lookaside lists funcs */
+/*------------------------------------------------------------------------*/
+#define kmem_cache_create(a,b,c,d,e,f) my_kmem_cache_create((a),(b),(c),(d),(e),(f))
+#define kmem_cache_destroy(a) my_kmem_cache_destroy((a))
+#define kmem_cache_alloc(co, flags) my_kmem_cache_alloc((co), (flags))
+#define kmem_cache_free(co, ptr) my_kmem_cache_free((co), (ptr))
+
+kmem_cache_t *my_kmem_cache_create(const char *tag, size_t alloc_size,
+ size_t offset, unsigned long flags,
+ void *ctor,
+ void *dtor);
+
+void my_kmem_cache_destroy(kmem_cache_t *co);
+void *my_kmem_cache_alloc(kmem_cache_t *co, int flags);
+void my_kmem_cache_free(kmem_cache_t *co, void *ptr);
+
+/*------------------------------------------------------------------------*/
/* Kernel macros */
/*------------------------------------------------------------------------*/
@@ -559,6 +611,21 @@
#define PCI_DEVFN(a,b) 0
#define PCI_SLOT(a) 0
+/**
+ * PCI_DEVICE_CLASS - macro used to describe a specific pci device class
+ * @dev_class: the class, subclass, prog-if triple for this device
+ * @dev_class_mask: the class mask for this device
+ *
+ * This macro is used to create a struct pci_device_id that matches a
+ * specific PCI class. The vendor, device, subvendor, and subdevice
+ * fields will be set to PCI_ANY_ID.
+ */
+#define PCI_DEVICE_CLASS(dev_class,dev_class_mask) \
+ .class = (dev_class), .class_mask = (dev_class_mask), \
+ .vendor = PCI_ANY_ID, .device = PCI_ANY_ID, \
+ .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
+
+
/*------------------------------------------------------------------------*/
/* Stuff from kernel */
/*------------------------------------------------------------------------*/
@@ -647,6 +714,9 @@
add_timer(t);
}
+#define time_after_eq(a,b) \
+ (((long)(a) - (long)(b) >= 0))
+
/*------------------------------------------------------------------------*/
/* Device driver and process related stuff */
/*------------------------------------------------------------------------*/
@@ -678,7 +748,7 @@
int my_schedule_timeout(int x);
#define wake_up(x) my_wake_up(x)
-void my_wake_up(void*);
+void my_wake_up(PKEVENT);
// cannot be mapped via macro due to collision with urb->complete
static void __inline__ complete(struct completion *p)
--- trunk/reactos/drivers/usb/cromwell/sys/linuxwrapper.c 2005-02-25 12:20:36 UTC (rev 13740)
+++ trunk/reactos/drivers/usb/cromwell/sys/linuxwrapper.c 2005-02-25 15:05:51 UTC (rev 13741)
@@ -134,6 +134,8 @@
{
HANDLE hThread;
+ // TODO: Implement actual process killing
+
hThread = (HANDLE)pid;
ZwClose(hThread);
@@ -208,11 +210,19 @@
{
}
/*------------------------------------------------------------------------*/
-void my_wake_up(void* p)
+void my_wake_up(PKEVENT evnt)
{
need_wakeup=1;
+
+ KeSetEvent(evnt, 0, FALSE); // Signal event
}
/*------------------------------------------------------------------------*/
+void my_init_waitqueue_head(PKEVENT evnt)
+{
+ // this is used only in core/message.c, and it isn't needed there
+ //KeInitializeEvent(evnt, NotificationEvent, TRUE); // signalled state
+}
+/*------------------------------------------------------------------------*/
/* wait until woken up (only one wait allowed!) */
int my_schedule_timeout(int x)
{
@@ -254,6 +264,12 @@
// printk("wait for completion done %i\n",x->done);
}
/*------------------------------------------------------------------------*/
+void my_interruptible_sleep_on(PKEVENT evnt)
+{
+ KeWaitForSingleObject(evnt, Executive, KernelMode, FALSE, NULL);
+ KeClearEvent(evnt); // reset to not-signalled
+}
+/*------------------------------------------------------------------------*/
// Helper for pci_module_init
/*------------------------------------------------------------------------*/
int my_pci_module_init(struct pci_driver *x)
@@ -294,4 +310,55 @@
/* No free... */
return 0;
}
-/*------------------------------------------------------------------------*/
\ No newline at end of file
+/*------------------------------------------------------------------------*/
+// Lookaside funcs
+/*------------------------------------------------------------------------*/
+kmem_cache_t *my_kmem_cache_create(const char *tag, size_t alloc_size,
+ size_t offset, unsigned long flags,
+ void *ctor,
+ void *dtor)
+{
+ //TODO: Take in account ctor and dtor - callbacks for alloc/free, flags and offset
+ //FIXME: We assume this cache is always NPaged
+ PNPAGED_LOOKASIDE_LIST Lookaside;
+ ULONG Tag=0x11223344; //FIXME: Make this from tag
+
+ Lookaside = ExAllocatePool(NonPagedPool, sizeof(NPAGED_LOOKASIDE_LIST));
+
+ ExInitializeNPagedLookasideList(
+ Lookaside,
+ NULL,
+ NULL,
+ 0,
+ alloc_size,
+ Tag,
+ 0);
+
+ return (kmem_cache_t *)Lookaside;
+}
+/*------------------------------------------------------------------------*/
+void my_kmem_cache_destroy(kmem_cache_t *co)
+{
+ ExDeleteNPagedLookasideList((PNPAGED_LOOKASIDE_LIST)co);
+
+ ExFreePool(co);
+}
+/*------------------------------------------------------------------------*/
+void *my_kmem_cache_alloc(kmem_cache_t *co, int flags)
+{
+ return ExAllocateFromNPagedLookasideList((PNPAGED_LOOKASIDE_LIST)co);
+}
+/*------------------------------------------------------------------------*/
+void my_kmem_cache_free(kmem_cache_t *co, void *ptr)
+{
+ ExFreeToNPagedLookasideList((PNPAGED_LOOKASIDE_LIST)co, ptr);
+}
+/*------------------------------------------------------------------------*/
+// DMA, not used now
+/*------------------------------------------------------------------------*/
+void *my_dma_pool_alloc(struct dma_pool *pool, int gfp_flags, dma_addr_t *dma_handle)
+{
+ // HalAllocCommonBuffer
+ // But ideally IoGetDmaAdapter
+ return NULL;
+}