Start removing dead code and ReactOS specific structure fields (the NDIS structures...
[reactos.git] / reactos / 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 * 25 Aug 2003 Vizzini - NDIS4/5 and PnP additions
11 * 3 Oct 2003 Vizzini - formatting and minor bugfixes
12 *
13 */
14
15 #include "ndissys.h"
16
17 \f
18 /*
19 * @implemented
20 */
21 ULONG
22 EXPORT
23 NdisImmediateReadPciSlotInformation(
24 IN NDIS_HANDLE WrapperConfigurationContext,
25 IN ULONG SlotNumber,
26 IN ULONG Offset,
27 IN PVOID Buffer,
28 IN ULONG Length)
29 {
30 PNDIS_WRAPPER_CONTEXT WrapperContext = (PNDIS_WRAPPER_CONTEXT)WrapperConfigurationContext;
31 return HalGetBusDataByOffset(PCIConfiguration, WrapperContext->BusNumber,
32 SlotNumber, Buffer, Offset, Length);
33 }
34
35 \f
36 /*
37 * @implemented
38 */
39 ULONG
40 EXPORT
41 NdisImmediateWritePciSlotInformation(
42 IN NDIS_HANDLE WrapperConfigurationContext,
43 IN ULONG SlotNumber,
44 IN ULONG Offset,
45 IN PVOID Buffer,
46 IN ULONG Length)
47 {
48 PNDIS_WRAPPER_CONTEXT WrapperContext = (PNDIS_WRAPPER_CONTEXT)WrapperConfigurationContext;
49 return HalSetBusDataByOffset(PCIConfiguration, WrapperContext->BusNumber,
50 SlotNumber, Buffer, Offset, Length);
51 }
52
53 \f
54 /*
55 * @implemented
56 */
57 NDIS_STATUS
58 EXPORT
59 NdisMPciAssignResources(
60 IN NDIS_HANDLE MiniportHandle,
61 IN ULONG SlotNumber,
62 OUT PNDIS_RESOURCE_LIST *AssignedResources)
63 {
64 PNDIS_MINIPORT_BLOCK MiniportBlock = (PNDIS_MINIPORT_BLOCK)MiniportHandle;
65
66 if (MiniportBlock->BusType != PCIBus ||
67 MiniportBlock->AllocatedResources == NULL)
68 {
69 *AssignedResources = NULL;
70 return NDIS_STATUS_FAILURE;
71 }
72
73 *AssignedResources = &MiniportBlock->AllocatedResources->List[0].PartialResourceList;
74
75 return NDIS_STATUS_SUCCESS;
76 }
77
78 \f
79 /*
80 * @implemented
81 */
82 VOID
83 EXPORT
84 NdisMQueryAdapterResources(
85 OUT PNDIS_STATUS Status,
86 IN NDIS_HANDLE WrapperConfigurationContext,
87 OUT PNDIS_RESOURCE_LIST ResourceList,
88 IN OUT PUINT BufferSize)
89 /*
90 * FUNCTION: returns a nic's hardware resources
91 * ARGUMENTS:
92 * Status: on return, contains the status of the operation
93 * WrapperConfigurationContext: handle input to MiniportInitialize
94 * ResourceList: on return, contains the list of resources for the nic
95 * BufferSize: size of ResourceList
96 * NOTES:
97 * - Caller must allocate Status and ResourceList
98 * - Must be called at IRQL = PASSIVE_LEVEL;
99 */
100 {
101 PNDIS_WRAPPER_CONTEXT WrapperContext = (PNDIS_WRAPPER_CONTEXT)WrapperConfigurationContext;
102 PNDIS_MINIPORT_BLOCK MiniportBlock = WrapperContext->DeviceObject->DeviceExtension;
103 ULONG ResourceListSize;
104
105 PAGED_CODE();
106 ASSERT(Status && ResourceList);
107
108 NDIS_DbgPrint(MAX_TRACE, ("Called\n"));
109
110 if (MiniportBlock->AllocatedResources == NULL)
111 {
112 NDIS_DbgPrint(MIN_TRACE, ("No allocated resources!\n"));
113 *Status = NDIS_STATUS_FAILURE;
114 return;
115 }
116
117 ResourceListSize =
118 FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors) +
119 MiniportBlock->AllocatedResources->List[0].PartialResourceList.Count *
120 sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
121
122 if (*BufferSize >= ResourceListSize)
123 {
124 RtlCopyMemory(ResourceList,
125 &MiniportBlock->AllocatedResources->List[0].PartialResourceList,
126 ResourceListSize);
127 *BufferSize = ResourceListSize;
128 *Status = STATUS_SUCCESS;
129 }
130 else
131 {
132 *BufferSize = ResourceListSize;
133 *Status = NDIS_STATUS_RESOURCES;
134 }
135 }
136
137
138 /*
139 * @implemented
140 */
141 NDIS_STATUS
142 EXPORT
143 NdisQueryMapRegisterCount(
144 IN NDIS_INTERFACE_TYPE BusType,
145 OUT PUINT MapRegisterCount)
146 /*
147 * On X86 (and all other current hardware), map registers aren't real hardware,
148 * and there is no real limit to the number that can be allocated.
149 * As such, we do what microsoft does on the x86 hals and return as follows
150 */
151 {
152 return NDIS_STATUS_NOT_SUPPORTED;
153 }
154
155 \f
156 /*
157 * @unimplemented
158 */
159 VOID
160 EXPORT
161 NdisReadEisaSlotInformation(
162 OUT PNDIS_STATUS Status,
163 IN NDIS_HANDLE WrapperConfigurationContext,
164 OUT PUINT SlotNumber,
165 OUT PNDIS_EISA_FUNCTION_INFORMATION EisaData)
166 {
167 UNIMPLEMENTED
168 }
169
170
171 /*
172 * @unimplemented
173 */
174 VOID
175 EXPORT
176 NdisReadEisaSlotInformationEx(
177 OUT PNDIS_STATUS Status,
178 IN NDIS_HANDLE WrapperConfigurationContext,
179 OUT PUINT SlotNumber,
180 OUT PNDIS_EISA_FUNCTION_INFORMATION *EisaData,
181 OUT PUINT NumberOfFunctions)
182 {
183 UNIMPLEMENTED
184 }
185
186
187 /*
188 * @implemented
189 */
190 ULONG
191 EXPORT
192 NdisReadPciSlotInformation(
193 IN NDIS_HANDLE NdisAdapterHandle,
194 IN ULONG SlotNumber,
195 IN ULONG Offset,
196 IN PVOID Buffer,
197 IN ULONG Length)
198 {
199 PNDIS_MINIPORT_BLOCK Adapter = (PNDIS_MINIPORT_BLOCK)NdisAdapterHandle;
200 /* Slot number is ignored since W2K for all NDIS drivers. */
201 return HalGetBusDataByOffset(PCIConfiguration,
202 Adapter->BusNumber, Adapter->SlotNumber,
203 Buffer, Offset, Length);
204 }
205
206 \f
207 /*
208 * @implemented
209 */
210 ULONG
211 EXPORT
212 NdisWritePciSlotInformation(
213 IN NDIS_HANDLE NdisAdapterHandle,
214 IN ULONG SlotNumber,
215 IN ULONG Offset,
216 IN PVOID Buffer,
217 IN ULONG Length)
218 {
219 PNDIS_MINIPORT_BLOCK Adapter = (PNDIS_MINIPORT_BLOCK)NdisAdapterHandle;
220 /* Slot number is ignored since W2K for all NDIS drivers. */
221 return HalSetBusDataByOffset(PCIConfiguration,
222 Adapter->BusNumber, Adapter->SlotNumber,
223 Buffer, Offset, Length);
224 }
225
226 /* EOF */