b27ce77bccd0d5bcfc6a87e1b65f6b47e8ce47de
[reactos.git] / drivers / net / ndis / ndis / hardware.c
1 /*
2  * COPYRIGHT:   See COPYING in the top level directory
3  * PROJECT:     ReactOS NDIS library
4  * FILE:        ndis/hardware.c
5  * PURPOSE:     Hardware related routines
6  * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
7  *              Vizzini (vizzini@plasmic.com)
8  * REVISIONS:
9  *   CSH 01/08-2000 Created
10  *   8/25/2003 Vizzini - NDIS4/5 and PnP additions
11  */
12 #include <ndissys.h>
13 #include <miniport.h>
14
15
16 /*
17  * @implemented
18  */
19 ULONG
20 EXPORT
21 NdisImmediateReadPciSlotInformation(
22     IN  NDIS_HANDLE WrapperConfigurationContext,
23     IN  ULONG       SlotNumber,
24     IN  ULONG       Offset,
25     IN  PVOID       Buffer,
26     IN  ULONG       Length)
27 {
28   return HalGetBusDataByOffset (PCIConfiguration,
29                                 0, /* FIXME */
30                                 SlotNumber,
31                                 Buffer,
32                                 Offset,
33                                 Length);
34 }
35
36
37 /*
38  * @implemented
39  */
40 ULONG 
41 EXPORT
42 NdisImmediateWritePciSlotInformation(
43     IN  NDIS_HANDLE WrapperConfigurationContext,
44     IN  ULONG       SlotNumber,
45     IN  ULONG       Offset,
46     IN  PVOID       Buffer,
47     IN  ULONG       Length)
48 {
49   return HalSetBusDataByOffset (PCIConfiguration,
50                                 0, /* FIXME */
51                                 SlotNumber,
52                                 Buffer,
53                                 Offset,
54                                 Length);
55 }
56
57
58 /*
59  * @implemented
60  */
61 NDIS_STATUS
62 EXPORT
63 NdisMPciAssignResources(
64     IN  NDIS_HANDLE             MiniportHandle,
65     IN  ULONG                   SlotNumber,
66     OUT PNDIS_RESOURCE_LIST     *AssignedResources)
67 /*
68  * NOTES:
69  *     - I think this is fundamentally broken
70  */
71 {
72   PCM_RESOURCE_LIST ResourceList;
73   NTSTATUS Status;
74   PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportHandle;
75
76   ResourceList = NULL;
77   Status = HalAssignSlotResources (Adapter->Miniport->RegistryPath,
78                                    0,
79                                    Adapter->Miniport->DriverObject,
80                                    0,
81                                    PCIBus,
82                                    Adapter->BusNumber,
83                                    SlotNumber,
84                                    &ResourceList);
85   if (!NT_SUCCESS (Status))
86     {
87       *AssignedResources = NULL;
88       return NDIS_STATUS_FAILURE;
89     }
90
91   *AssignedResources =
92     (PNDIS_RESOURCE_LIST)&ResourceList->List[0].PartialResourceList;
93
94   return NDIS_STATUS_SUCCESS;
95 }
96
97
98 /*
99  * @unimplemented
100  */
101 VOID
102 EXPORT
103 NdisMQueryAdapterResources(
104     OUT     PNDIS_STATUS        Status,
105     IN      NDIS_HANDLE         WrapperConfigurationContext,
106     OUT     PNDIS_RESOURCE_LIST ResourceList,
107     IN OUT  PUINT               BufferSize)
108 {
109     UNIMPLEMENTED
110 }
111
112
113 /*
114  * @implemented
115  */
116 NDIS_STATUS
117 EXPORT
118 NdisQueryMapRegisterCount(
119     IN  NDIS_INTERFACE_TYPE BusType,
120     OUT PUINT               MapRegisterCount)
121 /*
122  * On X86 (and all other current hardware), map registers aren't real hardware,
123  * and there is no real limit to the number that can be allocated.
124  * As such, we do what microsoft does on the x86 hals and return as follows
125  */
126 {
127         return NDIS_STATUS_NOT_SUPPORTED;
128 }
129
130
131 /*
132  * @unimplemented
133  */
134 VOID
135 EXPORT
136 NdisReadEisaSlotInformation(
137     OUT PNDIS_STATUS                    Status,
138     IN  NDIS_HANDLE                                 WrapperConfigurationContext,
139     OUT PUINT                           SlotNumber,
140     OUT PNDIS_EISA_FUNCTION_INFORMATION EisaData)
141 {
142     UNIMPLEMENTED
143 }
144
145
146 /*
147  * @unimplemented
148  */
149 VOID
150 EXPORT
151 NdisReadEisaSlotInformationEx(
152     OUT PNDIS_STATUS                    Status,
153     IN  NDIS_HANDLE                     WrapperConfigurationContext,
154     OUT PUINT                           SlotNumber,
155     OUT PNDIS_EISA_FUNCTION_INFORMATION *EisaData,
156     OUT PUINT                           NumberOfFunctions)
157 {
158     UNIMPLEMENTED
159 }
160
161
162 /*
163  * @implemented
164  */
165 ULONG
166 EXPORT
167 NdisReadPciSlotInformation(
168     IN  NDIS_HANDLE NdisAdapterHandle,
169     IN  ULONG       SlotNumber,
170     IN  ULONG       Offset,
171     IN  PVOID       Buffer,
172     IN  ULONG       Length)
173 {
174   return HalGetBusDataByOffset (PCIConfiguration,
175                                 0, /* FIXME */
176                                 SlotNumber,
177                                 Buffer,
178                                 Offset,
179                                 Length);
180 }
181
182
183 /*
184  * @implemented
185  */
186 ULONG
187 EXPORT
188 NdisWritePciSlotInformation(
189     IN  NDIS_HANDLE NdisAdapterHandle,
190     IN  ULONG       SlotNumber,
191     IN  ULONG       Offset,
192     IN  PVOID       Buffer,
193     IN  ULONG       Length)
194 {
195   return HalSetBusDataByOffset (PCIConfiguration,
196                                 0, /* FIXME */
197                                 SlotNumber,
198                                 Buffer,
199                                 Offset,
200                                 Length);
201 }
202
203 /* EOF */