4 * Hard coded Linux kernel replacements for x86
6 * (c) 2003 Georg Acher (georg@acher.org)
13 * All structs and prototypes are based on kernel source 2.5.72
15 * Modified by Aleksey Bragin (aleksey@reactos.com) for ReactOS needs
18 * #include <standard-GPL-header.h>
21 /*------------------------------------------------------------------------*/
23 /*------------------------------------------------------------------------*/
24 #include "cromwell_types.h"
26 typedef unsigned int __u32
;
28 typedef unsigned short __u16
;
30 typedef unsigned char __u8
;
35 typedef u32 dma_addr_t
;
59 typedef int irqreturn_t
;
60 typedef unsigned long kernel_ulong_t
;
62 typedef int wait_queue_head_t
;
63 /*------------------------------------------------------------------------*/
64 /* Stuff from xbox/linux environment */
65 /*------------------------------------------------------------------------*/
72 #define NULL ((void*)0)
73 extern void * memset(void *,int,unsigned int);
74 extern void * memcpy(void *,const void *,unsigned int);
76 extern char * strcpy(char *,const char *);
78 static inline char * strcpy(char * dest
,const char *src
)
86 : "=&S" (d0
), "=&D" (d1
), "=&a" (d2
)
87 :"0" (src
),"1" (dest
) : "memory");
91 extern size_t strlen(const char *);
93 extern int memcmp(const void *,const void *,unsigned int);
107 /*------------------------------------------------------------------------*/
108 /* General structs */
109 /*------------------------------------------------------------------------*/
112 void (*function
)(unsigned long);
115 struct list_head timer_list
;
119 void (*func
)(void *);
123 struct bus_type
*bus
;
126 struct device_driver
* driver
;
128 struct device
*parent
;
129 struct list_head driver_list
;
130 void (*release
)(struct device
* dev
);
132 PDEVICE_OBJECT dev_ext
; // ReactOS-specific: pointer to windows device object
134 struct class_device
{int a
;};
135 struct semaphore
{int a
;};
137 struct device_driver
{
139 struct bus_type
*bus
;
140 int (*probe
) (struct device
* dev
);
141 int (*remove
) (struct device
* dev
);
142 struct list_head devices
;
147 int (*match
)(struct device
* dev
, struct device_driver
* drv
);
148 struct device
* (*add
) (struct device
* parent
, char * bus_id
);
149 int (*hotplug
) (struct device
*dev
, char **envp
,
150 int num_envp
, char *buffer
, int buffer_size
);
165 //wait_queue_head_t wait;
168 // windows lookaside list head
169 typedef void* kmem_cache_t
;
176 /* These definitions mirror those in pci.h, so they can be used
177 * interchangeably with their PCI_ counterparts */
178 enum dma_data_direction
{
179 DMA_BIDIRECTIONAL
= 0,
186 #define PCI_DMA_TODEVICE DMA_TO_DEVICE
187 #define PCI_DMA_FROMDEVICE DMA_FROM_DEVICE
189 /* from mod_devicetable.h */
190 struct usb_device_id
{
191 /* which fields to match against? */
194 /* Used for product specific matches; range is inclusive */
200 /* Used for device class matches */
202 __u8 bDeviceSubClass
;
203 __u8 bDeviceProtocol
;
205 /* Used for interface class matches */
206 __u8 bInterfaceClass
;
207 __u8 bInterfaceSubClass
;
208 __u8 bInterfaceProtocol
;
210 /* not matched against */
211 kernel_ulong_t driver_info
;
214 /* Some useful macros to use to create struct usb_device_id */
215 #define USB_DEVICE_ID_MATCH_VENDOR 0x0001
216 #define USB_DEVICE_ID_MATCH_PRODUCT 0x0002
217 #define USB_DEVICE_ID_MATCH_DEV_LO 0x0004
218 #define USB_DEVICE_ID_MATCH_DEV_HI 0x0008
219 #define USB_DEVICE_ID_MATCH_DEV_CLASS 0x0010
220 #define USB_DEVICE_ID_MATCH_DEV_SUBCLASS 0x0020
221 #define USB_DEVICE_ID_MATCH_DEV_PROTOCOL 0x0040
222 #define USB_DEVICE_ID_MATCH_INT_CLASS 0x0080
223 #define USB_DEVICE_ID_MATCH_INT_SUBCLASS 0x0100
224 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
226 /*------------------------------------------------------------------------*/
227 /* imported functions from top-level */
228 /*------------------------------------------------------------------------*/
230 //void zxprintf(char* fmt, ...);
231 //void zxsprintf(char *buffer, char* fmt, ...);
232 //int zxsnprintf(char *buffer, size_t s, char* fmt, ...);
234 /*------------------------------------------------------------------------*/
235 /* PCI structs (taken from linux/pci.h et al., but slightly modified) */
236 /*------------------------------------------------------------------------*/
248 void * dev_ext
; // link to Windows DeviceExtension
252 unsigned char number
;
255 struct pci_device_id
{
256 __u32 vendor
, device
; /* Vendor and device ID or PCI_ANY_ID*/
257 __u32 subvendor
, subdevice
; /* Subsystem ID's or PCI_ANY_ID */
258 __u32
class, class_mask
; /* (class,subclass,prog-if) triplet */
259 kernel_ulong_t driver_data
; /* Data private to the driver */
263 struct list_head node
;
265 const struct pci_device_id
*id_table
; /* must be non-NULL for probe to be called */
266 int STDCALL (*probe
) (struct pci_dev
*dev
, const struct pci_device_id
*id
); /* New device inserted */
267 void STDCALL (*remove
) (struct pci_dev
*dev
); /* Device removed (NULL if not a hot-plug capable driver) */
268 int (*save_state
) (struct pci_dev
*dev
, u32 state
); /* Save Device Context */
269 int (*suspend
) (struct pci_dev
*dev
, u32 state
); /* Device suspended */
270 int (*resume
) (struct pci_dev
*dev
); /* Device woken up */
271 int (*enable_wake
) (struct pci_dev
*dev
, u32 state
, int enable
); /* Enable wake event */
281 struct usbdevfs_hub_portinfo
287 /*------------------------------------------------------------------------*/
288 /* constant defines */
289 /*------------------------------------------------------------------------*/
291 #define TASK_UNINTERRUPTIBLE 0
292 #define HZ 100 /* Don't rely on that... */
293 #define KERN_DEBUG "DBG: "
294 #define KERN_ERR "ERR: "
295 #define KERN_WARNING "WRN: "
296 #define KERN_INFO "INF: "
298 #define GFP_ATOMIC 0x20
300 #define SLAB_ATOMIC 0
301 #define PCI_ANY_ID (~0)
303 #define THIS_MODULE 0
304 //#define PAGE_SIZE 4096
308 #define CLONE_FILES 0
309 #define CLONE_SIGHAND 0
311 #define PF_IOTHREAD 0
314 #define USBDEVFS_HUB_PORTINFO 1234
318 #define PCI_COMMAND 0
319 #undef PCI_COMMAND_MASTER
320 #define PCI_COMMAND_MASTER 0
321 /*------------------------------------------------------------------------*/
322 /* Module/export macros */
323 /*------------------------------------------------------------------------*/
325 #define MODULE_AUTHOR(a)
326 #define MODULE_DESCRIPTION(a)
327 #define MODULE_LICENSE(a)
328 #define MODULE_DEVICE_TABLE(type,name) void* module_table_##name=&name
329 #define MODULE_PARM(a,b)
330 #define MODULE_PARM_DESC(a,b)
335 #define __devinitdata
336 #define module_init(x) static void module_init_##x(void){ x();}
337 #define module_exit(x) void module_exit_##x(void){ x();}
338 #define EXPORT_SYMBOL_GPL(x)
339 #define EXPORT_SYMBOL(x)
341 #define __setup(x,y) int setup_##y=(int)y
342 #define subsys_initcall(x) void subsys_##x(void){x();}
344 /*------------------------------------------------------------------------*/
346 /*------------------------------------------------------------------------*/
348 #define dev_get_drvdata(a) (a)->driver_data
349 #define dev_set_drvdata(a,b) (a)->driver_data=(b)
351 #define __io_virt(x) ((void *)(x))
352 #define readl(addr) (*(volatile unsigned int *) __io_virt(addr))
353 #define writel(b,addr) (*(volatile unsigned int *) __io_virt(addr) = (b))
354 #define likely(x) (x)
355 #define unlikely(x) (x)
356 #define prefetch(x) 1
358 #define inw(x) READ_PORT_USHORT((PUSHORT)(x))
359 #define outw(x,p) WRITE_PORT_USHORT((PUSHORT)(p),(x))
360 #define outl(x,p) WRITE_PORT_ULONG((PULONG)(p),(x))
362 /* The kernel macro for list_for_each_entry makes nonsense (have no clue
363 * why, this is just the same definition...) */
365 #undef list_for_each_entry
366 #define list_for_each_entry(pos, head, member) \
367 for (pos = list_entry((head)->next, typeof(*pos), member), \
368 prefetch(pos->member.next); \
369 &pos->member != (head); \
370 pos = list_entry(pos->member.next, typeof(*pos), member), \
371 prefetch(pos->member.next))
373 /*------------------------------------------------------------------------*/
374 /* function wrapper macros */
375 /*------------------------------------------------------------------------*/
376 #define kmalloc(x,y) ExAllocatePool(PagedPool,x)
377 #define kfree(x) ExFreePool(x)
379 //#define sprintf(a,b,format, arg...) zxsprintf((a),(b),format, ## arg)
380 //#define snprintf(a,b,format, arg...) zxsnprintf((a),(b),format, ##arg)
381 //#define printk(format, arg...) zxprintf(format, ## arg)
382 #define snprintf(a,b,format, arg...) _snprintf((a),(b),format, ##arg)
383 #define printk(format, arg...) DPRINT1(format, ## arg)
384 #define BUG(...) do {} while(0)
386 /* Locks & friends */
388 #define DECLARE_MUTEX(x) struct semaphore x
389 #define init_MUTEX(x)
391 #define SPIN_LOCK_UNLOCKED 0
393 #define spin_lock_init(a) my_spin_lock_init(a)
394 void my_spin_lock_init(spinlock_t
*sl
);
396 #define spin_lock(a) my_spin_lock(a)
397 void my_spin_lock(spinlock_t
*sl
);
399 #define spin_unlock(a) my_spin_unlock(a)
400 void my_spin_unlock(spinlock_t
*sl
);
402 #define spin_lock_irqsave(a,b) b=0, my_spin_lock_irqsave(a,b)
403 void my_spin_lock_irqsave(spinlock_t
*sl
, int flags
);
404 #define spin_unlock_irqrestore(a,b) my_spin_unlock(a)
407 #define local_irq_save(x) __asm__ __volatile__("pushfl ; popl %0 ; cli":"=g" (x): /* no input */ :"memory")
408 #define local_irq_restore(x) __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory", "cc")
410 #define local_irq_save(x) do {} while(0)
411 #define local_irq_restore(x) do {} while(0)
414 #define atomic_inc(x) *(x)+=1
415 #define atomic_dec(x) *(x)-=1
416 #define atomic_dec_and_test(x) (*(x)-=1,(*(x))==0)
417 #define atomic_set(x,a) *(x)=a
418 #define atomic_read(x) *(x)
419 #define ATOMIC_INIT(x) (x)
421 #define down(x) do {} while(0)
422 #define up(x) do {} while(0)
423 #define down_trylock(a) 0
425 #define down_read(a) do {} while(0)
426 #define up_read(a) do {} while(0)
428 #define DECLARE_WAIT_QUEUE_HEAD(x) KEVENT x
430 #define DECLARE_COMPLETION(x) struct completion x
434 #define driver_unregister(a) do {} while(0)
435 #define put_device(a) do {} while(0)
439 #define MAX_POOL_PAGES 2
440 #define BITS_PER_LONG 32
444 PHYSICAL_ADDRESS dmaAddress
;
445 PVOID virtualAddress
;
447 unsigned long bitmap
[128]; // 128 == 32bits*4096 blocks
455 size_t blocks_per_page
;
456 struct pci_dev
*pdev
;
460 int blocks_allocated
;
462 struct pci_page pages
[MAX_POOL_PAGES
];
465 #define to_pci_dev(n) container_of(n, struct pci_dev, dev)
467 #define pci_pool_create(a,b,c,d,e) my_pci_pool_create(a,b,c,d,e)
468 struct pci_pool
*my_pci_pool_create(const char * name
, struct pci_dev
* pdev
, size_t size
, size_t align
, size_t allocation
);
470 #define pci_pool_alloc(a,b,c) my_pci_pool_alloc(a,b,c)
471 void *my_pci_pool_alloc(struct pci_pool
* pool
, int mem_flags
, dma_addr_t
*dma_handle
);
473 #define pci_pool_free(a,b,c) my_pci_pool_free(a,b,c)
474 void my_pci_pool_free(struct pci_pool
* pool
, void * vaddr
, dma_addr_t dma
);
476 #define pci_alloc_consistent(a,b,c) my_pci_alloc_consistent(a,b,c)
477 void *my_pci_alloc_consistent(struct pci_dev
*hwdev
, size_t size
, dma_addr_t
*dma_handle
);
479 #define pci_free_consistent(a,b,c,d) kfree(c)
480 #define pci_pool_destroy(a) my_pci_pool_destroy(a)
481 void my_pci_pool_destroy (struct pci_pool
* pool
);
483 #define pci_module_init(x) my_pci_module_init(x)
484 int my_pci_module_init(struct pci_driver
*x
);
486 #define pci_unregister_driver(a) do {} while(0)
488 #define pci_write_config_word(a,b,c) my_pci_write_config_word(a,b,c)
490 #define bus_register(a) do {} while(0)
491 #define bus_unregister(a) do {} while(0)
494 //#define dma_pool_alloc(a,b,c) my_dma_pool_alloc((a),(b),(c))
495 #define dma_pool_alloc(a,b,c) pci_pool_alloc(a,b,c)
496 #define dma_pool_create(a,b,c,d,e) pci_pool_create(a,b,c,d,e)
497 #define dma_pool_free(a,b,c) pci_pool_free(a,b,c)
498 #define dma_pool_destroy(a) pci_pool_destroy(a)
500 //#define dma_alloc_coherent(a,b,c,d) NULL
501 //#define dma_free_coherent(a,b,c,d) do {} while(0)
502 #define dma_map_single(a,b,c,d) my_dma_map_single(a,b,c,d)
503 dma_addr_t
my_dma_map_single(struct device
*hwdev
, void *ptr
, size_t size
, enum dma_data_direction direction
);
505 #define dma_unmap_single(a,b,c,d) my_dma_unmap_single(a,b,c,d)
506 void my_dma_unmap_single(struct device
*dev
, dma_addr_t dma_addr
, size_t size
, enum dma_data_direction direction
);
508 #define pci_unmap_single(a,b,c,d) my_pci_unmap_single(a,b,c,d)
509 void my_pci_unmap_single(struct pci_dev
*hwdev
, dma_addr_t dma_addr
, size_t size
, int direction
);
511 #define dma_sync_single(a,b,c,d) my_dma_sync_single(a,b,c,d)
512 void my_dma_sync_single(struct device
*hwdev
, dma_addr_t dma_handle
, size_t size
, int direction
);
514 #define dma_sync_sg(a,b,c,d) my_dma_sync_sg(a,b,c,d)
515 void my_dma_sync_sg(struct device
*hwdev
, struct scatterlist
*sg
, int nelems
, int direction
);
517 #define dma_map_sg(a,b,c,d) my_dma_map_sg(a,b,c,d)
518 int my_dma_map_sg(struct device
*hwdev
, struct scatterlist
*sg
, int nents
, enum dma_data_direction direction
);
520 #define dma_unmap_sg(a,b,c,d) my_dma_unmap_sg(a,b,c,d)
521 void my_dma_unmap_sg(struct device
*hwdev
, struct scatterlist
*sg
, int nents
, enum dma_data_direction direction
);
523 #define usb_create_driverfs_dev_files(a) do {} while(0)
524 #define usb_create_driverfs_intf_files(a) do {} while(0)
525 #define sg_dma_address(x) ((u32)((x)->page*4096 + (x)->offset))
526 #define sg_dma_len(x) ((x)->length)
528 #define page_address(x) ((void*)(x/4096))
530 #define PCI_ROM_RESOURCE 1
531 #define IORESOURCE_IO CM_RESOURCE_PORT_IO
533 #define DECLARE_WAITQUEUE(a,b) KEVENT a=0
534 #define init_waitqueue_head(a) my_init_waitqueue_head(a)
535 #define add_wait_queue(a,b) do {} while(0)
536 #define remove_wait_queue(a,b) do {} while(0)
537 void my_init_waitqueue_head(PKEVENT a
);
539 VOID
KeMemoryBarrier(VOID
);
541 #define mb() KeMemoryBarrier()
542 #define wmb() do {} while (0)
543 #define rmb() do {} while (0)
544 /*#define wmb() __asm__ __volatile__ ("": : :"memory")
545 #define rmb() __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")*/
547 #define in_interrupt() 0
549 #define init_completion(x) my_init_completion(x)
550 void my_init_completion(struct completion
*);
551 #define wait_for_completion(x) my_wait_for_completion(x)
552 void my_wait_for_completion(struct completion
*);
555 #define IRQ_HANDLED 1
557 #define INIT_WORK(a,b,c) (a)->func=b
559 #define set_current_state(a) do {} while(0)
561 #define might_sleep() do {} while(0)
562 #define daemonize(a) do {} while(0)
563 #define allow_signal(a) do {} while(0)
564 #define wait_event_interruptible(x,y) do {} while(0)
566 #define interruptible_sleep_on(a) my_interruptible_sleep_on(a)
567 void my_interruptible_sleep_on(PKEVENT evnt
);
569 #define flush_scheduled_work() do {} while(0)
570 #define refrigerator(x) do {} while(0)
571 #define signal_pending(x) 0 // Don't fall through threads! ReactOS implements this correctly
572 #define complete_and_exit(a,b) return 0
574 //#define kill_proc(a,b,c) 0
575 #define kill_proc(a,b,c) my_kill_proc(a, b, c);
576 int my_kill_proc(int pid
, int signal
, int unk
);
578 #define yield() do {} while(0)
579 #define cpu_relax() do {} while(0)
581 #define WARN_ON(a) do {} while(0)
583 /*------------------------------------------------------------------------*/
584 /* Lookaside lists funcs */
585 /*------------------------------------------------------------------------*/
586 #define kmem_cache_create(a,b,c,d,e,f) my_kmem_cache_create((a),(b),(c),(d),(e),(f))
587 #define kmem_cache_destroy(a) my_kmem_cache_destroy((a))
588 #define kmem_cache_alloc(co, flags) my_kmem_cache_alloc((co), (flags))
589 #define kmem_cache_free(co, ptr) my_kmem_cache_free((co), (ptr))
591 kmem_cache_t
*my_kmem_cache_create(const char *tag
, size_t alloc_size
,
592 size_t offset
, unsigned long flags
,
596 BOOLEAN
my_kmem_cache_destroy(kmem_cache_t
*co
);
597 void *my_kmem_cache_alloc(kmem_cache_t
*co
, int flags
);
598 void my_kmem_cache_free(kmem_cache_t
*co
, void *ptr
);
600 /*------------------------------------------------------------------------*/
602 /*------------------------------------------------------------------------*/
604 #define LINUX_VERSION_CODE 0x020572
605 #define UTS_SYSNAME "XBOX"
606 #define UTS_RELEASE "----"
608 /* from linux/kernel.h */
609 #define max_t(type,x,y) \
610 ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
612 #define min_t(type,x,y) \
613 ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
615 #define container_of(ptr, type, member) ({ \
616 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
617 (type *)( (char *)__mptr - offsetof(type,member) );})
619 /* from linux/stddef.h */
622 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
624 /*------------------------------------------------------------------------*/
625 /* Conversion macros */
626 /*------------------------------------------------------------------------*/
628 #define __constant_cpu_to_le32(x) (x)
629 #define cpu_to_le16(x) (x)
630 #define le16_to_cpu(x) (x)
631 #define cpu_to_le32(x) (x)
632 #define cpu_to_le32p(x) (*(__u32*)(x))
633 #define le32_to_cpup(x) (*(__u32*)(x))
634 #define le32_to_cpu(x) ((u32)x)
635 #define le16_to_cpus(x) do {} while (0)
636 #define le16_to_cpup(x) (*(__u16*)(x))
637 #define cpu_to_le16p(x) (*(__u16*)(x))
639 /*------------------------------------------------------------------------*/
641 /*------------------------------------------------------------------------*/
643 #define dev_printk(lvl,x,f,arg...) printk(f, ## arg)
644 #define dev_dbg(x,f,arg...) printk(f, ## arg)
645 #define dev_info(x,f,arg...) printk(f,## arg)
646 #define dev_warn(x,f,arg...) printk(f,## arg)
647 #define dev_err(x,f,arg...) printk(f,## arg)
648 #define pr_debug(x,f,arg...) printk(f,## arg)
649 #define usbprintk printk
653 #define dev_printk(lvl,x,f,arg...) do {} while (0)
654 #define dev_dbg(x,f,arg...) do {} while (0) //printk(f, ## arg)
655 #define dev_info(x,f,arg...) do {} while (0)
656 #define dev_warn(x,f,arg...) do {} while (0)
657 #define dev_err(x,f,arg...) do {} while (0)
658 #define pr_debug(x,f,arg...) do {} while (0)
664 #define PCI_DEVFN(a,b) 0
665 #define PCI_SLOT(a) 0
668 * PCI_DEVICE_CLASS - macro used to describe a specific pci device class
669 * @dev_class: the class, subclass, prog-if triple for this device
670 * @dev_class_mask: the class mask for this device
672 * This macro is used to create a struct pci_device_id that matches a
673 * specific PCI class. The vendor, device, subvendor, and subdevice
674 * fields will be set to PCI_ANY_ID.
676 #define PCI_DEVICE_CLASS(dev_class,dev_class_mask) \
677 .class = (dev_class), .class_mask = (dev_class_mask), \
678 .vendor = PCI_ANY_ID, .device = PCI_ANY_ID, \
679 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
682 /*------------------------------------------------------------------------*/
683 /* Stuff from kernel */
684 /*------------------------------------------------------------------------*/
688 //#include "linux/pci_ids.h"
690 /*------------------------------------------------------------------------*/
691 /* global variables */
692 /*------------------------------------------------------------------------*/
694 #define jiffies my_jiffies
695 extern int my_jiffies
;
696 #define current my_current
697 extern struct dummy_process
*my_current
;
699 extern struct list_head interrupt_list
;
701 /*------------------------------------------------------------------------*/
702 /* Function prototypes */
703 /*------------------------------------------------------------------------*/
704 void STDCALL
usb_hcd_pci_remove (struct pci_dev
*dev
);
706 #define my_wait_ms(x) wait_ms(x) // milliseconds
708 #define udelay(x) my_udelay(x) // microseconds
710 #define my_mdelay(x) wait_ms(1+x/1000);
711 #define mdelay(x) my_mdelay(x); // milliseconds = udelay(1000*x)
713 #define pci_find_slot(a,b) my_pci_find_slot(a,b)
714 struct pci_dev
*my_pci_find_slot(int a
,int b
);
716 /*------------------------------------------------------------------------*/
717 /* Timer management */
718 /*------------------------------------------------------------------------*/
720 #define MAX_TIMERS 20
721 extern struct timer_list
*main_timer_list
[MAX_TIMERS
];
723 static void __inline__
init_timer(struct timer_list
* t
)
725 INIT_LIST_HEAD(&t
->timer_list
);
730 static void __inline__
add_timer(struct timer_list
* t
)
733 for(n
=0;n
<MAX_TIMERS
;n
++)
734 if (main_timer_list
[n
]==0)
736 main_timer_list
[n
]=t
;
741 static void __inline__
del_timer(struct timer_list
* t
)
744 for(n
=0;n
<MAX_TIMERS
;n
++)
745 if (main_timer_list
[n
]==t
)
747 main_timer_list
[n
]=0;
751 static void __inline__
del_timer_sync(struct timer_list
* t
)
754 for(n
=0;n
<MAX_TIMERS
;n
++)
755 if (main_timer_list
[n
]==t
)
757 main_timer_list
[n
]=0;
762 static void __inline__
mod_timer(struct timer_list
* t
, int ex
)
769 #define time_after_eq(a,b) \
770 (((long)(a) - (long)(b) >= 0))
772 /*------------------------------------------------------------------------*/
773 /* Device driver and process related stuff */
774 /*------------------------------------------------------------------------*/
776 static int __inline__
usb_major_init(void){return 0;}
777 static void __inline__
usb_major_cleanup(void){}
778 static void __inline__
schedule_work(void* p
){}
780 #define device_initialize(x) my_device_initialize(x)
781 void my_device_initialize(struct device
*dev
);
783 #define get_device(x) my_get_device(x)
784 struct device
*my_get_device(struct device
*dev
);
786 #define device_add(x) my_device_add(x)
787 int my_device_add(struct device
*dev
);
789 #define driver_register(x) my_driver_register(x)
790 int my_driver_register(struct device_driver
*driver
);
792 #define device_unregister(a) my_device_unregister(a)
793 int my_device_unregister(struct device
*dev
);
795 #define DEVICE_ATTR(a,b,c,d) int xxx_##a
796 #define device_create_file(a,b) do {} while(0)
797 #define device_remove_file(a,b) do {} while(0)
799 #define schedule_timeout(x) my_schedule_timeout(x)
800 int my_schedule_timeout(int x
);
802 #define wake_up(x) my_wake_up(x)
803 void my_wake_up(PKEVENT
);
805 // cannot be mapped via macro due to collision with urb->complete
806 static void __inline__
complete(struct completion
*p
)
808 printk("completing event 0x%08x\n", (ULONG
)p
);
809 /* Wake up x->wait */
811 wake_up((PKEVENT
)&p
->wait
);
814 #define kernel_thread(a,b,c) my_kernel_thread(a,b,c)
815 int my_kernel_thread(int STDCALL (*handler
)(void*), void* parm
, int flags
);
817 /*------------------------------------------------------------------------*/
818 /* PCI, simple and inlined... */
819 /*------------------------------------------------------------------------*/
822 /*------------------------------------------------------------------------*/
824 /*------------------------------------------------------------------------*/
826 #define request_irq(a,b,c,d,e) my_request_irq(a,b,c,d,e)
827 int my_request_irq(unsigned int irq
,
828 int (*handler
)(int, void *, struct pt_regs
*),
829 unsigned long mode
, const char *desc
, void *data
);
831 #define free_irq(a,b) my_free_irq(a,b)
832 int free_irq(int irq
, void* p
);
837 int (*handler
)(int, void *, struct pt_regs
*);
844 // Exported to top level
846 void handle_irqs(int irq
);
847 void inc_jiffies(int);
848 void init_wrapper(struct pci_dev
*pci_dev
);
849 void do_all_timers(void);
851 int my_pci_write_config_word(struct pci_dev
*, int, u16
);
853 void UsbKeyBoardInit(void);
854 void UsbKeyBoardRemove(void);
855 void UsbMouseInit(void);
856 void UsbMouseRemove(void);