Revert 18883 and 18912, as they break named pipes
[reactos.git] / reactos / drivers / usb / miniport / usbuhci / uhci.c
1 /*
2 ReactOS specific functions for UHCI module
3 by Aleksey Bragin (aleksey@reactos.com)
4 and Hervé Poussineau (hpoussin@reactos.org)
5 Some parts of code are inspired (or even just copied) from ReactOS Videoport driver
6 */
7 #define NDEBUG
8 #include "uhci.h"
9
10 extern struct pci_driver uhci_pci_driver;
11 extern struct pci_device_id uhci_pci_ids[];
12 struct pci_device_id* pci_ids = &uhci_pci_ids[0];
13
14 NTSTATUS
15 InitLinuxWrapper(PDEVICE_OBJECT DeviceObject)
16 {
17 NTSTATUS Status = STATUS_SUCCESS;
18
19 PUSBMP_DEVICE_EXTENSION DeviceExtension = (PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
20
21 /* Create generic linux structure */
22 struct pci_dev *dev;
23 dev = ExAllocatePoolWithTag(PagedPool, sizeof(struct pci_dev), USB_UHCI_TAG);
24 DeviceExtension->pdev = dev;
25
26 /* Initialize generic linux structure */
27 dev->irq = DeviceExtension->InterruptVector;
28 dev->dev_ext = (PVOID)DeviceExtension;
29 dev->slot_name = ExAllocatePoolWithTag(NonPagedPool, 128, USB_UHCI_TAG); // 128 max len for slot name
30 init_wrapper(dev);
31
32 strcpy(dev->dev.name, "UnivHCI PCI-USB Controller");
33 strcpy(dev->slot_name, "UHCD PCI Slot");
34
35 /* Init the HCD. Probe will be called automatically, but will fail because id=NULL */
36 Status = uhci_hcd_init();
37 if (!NT_SUCCESS(Status))
38 {
39 DPRINT("UHCI: uhci_hcd_init() failed with status 0x%08lx\n", Status);
40 /* FIXME: deinitialize linux wrapper */
41 ExFreePoolWithTag(dev, USB_UHCI_TAG);
42 return Status;
43 }
44
45 /* Init core usb */
46 usb_init();
47
48 /* Probe device with real id now */
49 uhci_pci_driver.probe(dev, uhci_pci_ids);
50
51 // DPRINT1("UHCI :SysIoBusNumA %d\n",DeviceExtension->SystemIoBusNumber);
52 // DeviceExtension->SystemIoBusNumber = dev->bus->number;
53 // DPRINT1("UHCI: SysIoBusNumB %d\n",DeviceExtension->SystemIoBusNumber);
54
55 return Status;
56 }
57
58 VOID STDCALL
59 DriverUnload(PDRIVER_OBJECT DriverObject)
60 {
61 PUSBMP_DEVICE_EXTENSION DeviceExtension;
62 PDEVICE_OBJECT DeviceObject;
63 struct pci_dev *dev;
64
65 DeviceObject = DriverObject->DeviceObject;
66 DeviceExtension = (PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
67
68 dev = DeviceExtension->pdev;
69
70 DPRINT1("UHCI: DriverUnload()\n");
71
72 // Exit usb device
73 usb_exit();
74
75 // Remove device (uhci_pci_driver.remove)
76 uhci_pci_driver.remove(dev);
77
78 ExFreePool(dev->slot_name);
79 ExFreePool(dev);
80
81 // Perform some cleanup
82 uhci_hcd_cleanup();
83 }