Modify some pci_hal funcs, fix obvious errors in code
[reactos.git] / reactos / drivers / usb / cromwell / linux / pci_hal.c
1 // PCI -> HAL interface
2 // this file is part of linux_wrapper.h
3
4 //FIXME: Move this file, make its definitions more general
5 #include "../host/ohci_main.h"
6
7 /*
8 Initialize device before it's used by a driver. Ask low-level code to enable I/O and memory.
9 Wake up the device if it was suspended. Beware, this function can fail.
10 */
11 static int __inline__ pci_enable_device(struct pci_dev *dev)
12 {
13 DPRINT1("pci_enable_device() called...\n");
14 return 0;
15 }
16
17 // Get physical address where resource x resides
18 static PHYSICAL_ADDRESS __inline__ pci_resource_start (struct pci_dev *dev, int x)
19 {
20 POHCI_DEVICE_EXTENSION dev_ext = (POHCI_DEVICE_EXTENSION)dev->dev_ext;
21 DPRINT1("pci_resource_start() called, x=0x%x\n", x);
22
23 //FIXME: Take x into account
24 return dev_ext->BaseAddress;
25 //return dev->base[x];
26 }
27
28 // ???
29 static unsigned long __inline__ pci_resource_len (struct pci_dev *dev, int x)
30 {
31 POHCI_DEVICE_EXTENSION ext = (POHCI_DEVICE_EXTENSION)dev->dev_ext;
32
33 DPRINT1("pci_resource_len() called, x=0x%x\n", x);
34
35 //FIXME: Take x into account
36 return ext->BaseAddrLength;
37 }
38
39 // ???
40 static int __inline__ pci_resource_flags(struct pci_dev *dev, int x)
41 {
42 POHCI_DEVICE_EXTENSION ext = (POHCI_DEVICE_EXTENSION)dev->dev_ext;
43
44 DPRINT1("pci_resource_flags() called, x=0x%x\n", x);
45
46 //FIXME: Take x into account
47 return ext->Flags;
48 }
49
50 /*
51 Enables bus-mastering for device dev
52 */
53 static int __inline__ pci_set_master(struct pci_dev *dev) {return 0;}
54
55 // Store pointer to data for this device
56 static int __inline__ pci_set_drvdata(struct pci_dev *dev, void* d)
57 {
58 DPRINT1("pci_set_drvdata() called...\n");
59 dev->data=(void*)d;
60 return 0;
61 }
62
63 // Get pointer to previously saved data
64 static void __inline__ *pci_get_drvdata(struct pci_dev *dev)
65 {
66 DPRINT1("pci_get_drvdata() called...\n");
67 return dev->data;
68 }
69
70
71 /*
72 ===========================================================================
73 I/O mem related stuff below
74 */
75
76 /*
77 Allocate I/O memory region.
78
79 Parameters:
80 start begin of region
81 n length of region
82 name name of requester
83 */
84 static int __inline__ request_region(PHYSICAL_ADDRESS addr, unsigned long len, const char * d)
85 {
86 DPRINT1("request_region(): addr=0x%lx, len=0x%lx\n", addr.u.LowPart, len);
87 return ~0;
88 }
89
90 /*
91 Unmap I/O memory from kernel address space.
92
93 Parameters:
94 addr virtual start address
95
96 */
97 static int __inline__ iounmap(void* p)
98 {
99 DPRINT1("iounmap(): p=0x%x. FIXME - how to obtain len of mapped region?\n", p);
100
101 //MmUnnapIoSpace(p);
102
103 return 0;
104 }
105
106 /*
107 Release I/O port region.
108
109 Parameters:
110 start begin of region
111 n length of region
112 */
113 static int __inline__ release_region(PHYSICAL_ADDRESS addr, unsigned long len)
114 {
115 DPRINT1("release_region(): addr=0x%lx, len=0x%lx\n", addr.u.LowPart, len);
116 return 0;
117 }
118
119 /*
120 Allocate I/O memory region.
121
122 Parameters:
123 start begin of region
124 n length of region
125 name name of requester
126 */
127 static int __inline__ request_mem_region(PHYSICAL_ADDRESS addr, unsigned long len, const char * d)
128 {
129 DPRINT1("request_mem_region(): addr=0x%x, len=0x%x\n", addr, len);
130 return 1;
131 }
132
133 /*
134 Remap I/O memory into kernel address space (no cache).
135
136 Parameters:
137 phys_addr begin of physical address range
138 size size of physical address range
139
140 Returns:
141 virtual start address of mapped range
142 */
143 static void __inline__ *ioremap_nocache(PHYSICAL_ADDRESS addr, unsigned long len)
144 {
145 // MmMapIoSpace with NoCache param
146 DPRINT1("ioremap_nocache(): addr=0x%x, len=0x%x\n", addr, len);
147
148 return MmMapIoSpace(addr, len, MmNonCached);
149 }
150
151 /*
152 Release I/O memory region.
153
154 Parameters:
155 start begin of region
156 n length of region
157 */
158 static int __inline__ release_mem_region(PHYSICAL_ADDRESS addr, unsigned long len)
159 {
160 DPRINT1("release_mem_region(): addr=0x%x, len=0x%x\n", addr, len);
161 return 0;
162 }