1 | /*␊ |
2 | * Copyright (c) 2009 Evan Lojewski. All rights reserved.␊ |
3 | *␊ |
4 | */␊ |
5 | ␊ |
6 | #include "libsaio.h"␊ |
7 | #include "modules.h"␊ |
8 | #include "pci.h"␊ |
9 | #include "bootstruct.h"␊ |
10 | ␊ |
11 | #define kEnableUSBMod␉␉␉"EnableUSBModule"␊ |
12 | ␊ |
13 | extern int usb_loop(void);␊ |
14 | extern void notify_usb_dev(pci_dt_t *pci_dev);␊ |
15 | ␊ |
16 | void USBFix_pci_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6);␊ |
17 | void USBFix_start_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6);␊ |
18 | ␊ |
19 | ␊ |
20 | void USBFix_pci_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)␊ |
21 | {␊ |
22 | ␉pci_dt_t* current = arg1;␊ |
23 | ␉if(current->class_id == PCI_CLASS_SERIAL_USB)␊ |
24 | ␉{␊ |
25 | ␉␉notify_usb_dev(current);␊ |
26 | ␉}␊ |
27 | }␊ |
28 | ␊ |
29 | void USBFix_start_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)␊ |
30 | {␊ |
31 | ␉usb_loop();␊ |
32 | }␊ |
33 | ␊ |
34 | void USBFix_start(void);␊ |
35 | void USBFix_start(void)␊ |
36 | {␊ |
37 | ␉bool enable = true;␊ |
38 | ␉getBoolForKey(kEnableUSBMod, &enable, DEFAULT_BOOT_CONFIG) ;␊ |
39 | ␉␊ |
40 | ␉if (enable) {␊ |
41 | ␉␉register_hook_callback("PCIDevice", &USBFix_pci_hook);␊ |
42 | ␉␉register_hook_callback("Kernel Start", &USBFix_start_hook);␊ |
43 | ␉}␊ |
44 | ␉␊ |
45 | ␊ |
46 | }␊ |
47 | ␊ |
48 | |