ReactOS 0.4.16-dev-122-g325d74c
hardware.c
Go to the documentation of this file.
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/*
18 * @implemented
19 */
28{
30 /* Slot number is ignored. */
31 return HalGetBusDataByOffset(PCIConfiguration, WrapperContext->BusNumber,
32 WrapperContext->SlotNumber, Buffer, Offset, Length);
33}
34
35/*
36 * @implemented
37 */
46{
48 /* Slot number is ignored. */
49 return HalSetBusDataByOffset(PCIConfiguration, WrapperContext->BusNumber,
50 WrapperContext->SlotNumber, Buffer, Offset, Length);
51}
52
53/*
54 * @implemented
55 */
61 OUT PNDIS_RESOURCE_LIST *AssignedResources)
62{
64
66 Adapter->NdisMiniportBlock.AllocatedResources == NULL)
67 {
68 NDIS_DbgPrint(MIN_TRACE, ("Bad bus type or no resources\n"));
69 *AssignedResources = NULL;
71 }
72
73 *AssignedResources = &Adapter->NdisMiniportBlock.AllocatedResources->List[0].PartialResourceList;
74
76}
77
78/*
79 * @implemented
80 */
84 IN NDIS_HANDLE NdisMacHandle,
85 IN NDIS_HANDLE NdisWrapperHandle,
88 OUT PNDIS_RESOURCE_LIST *AssignedResources)
89{
91 PLOGICAL_ADAPTER Adapter = WrapperContext->DeviceObject->DeviceExtension;
92
93 return NdisMPciAssignResources(Adapter,
95 AssignedResources);
96}
97
98/*
99 * @implemented
100 */
101VOID
102EXPORT
108/*
109 * FUNCTION: returns a nic's hardware resources
110 * ARGUMENTS:
111 * Status: on return, contains the status of the operation
112 * WrapperConfigurationContext: handle input to MiniportInitialize
113 * ResourceList: on return, contains the list of resources for the nic
114 * BufferSize: size of ResourceList
115 * NOTES:
116 * - Caller must allocate Status and ResourceList
117 * - Must be called at IRQL = PASSIVE_LEVEL;
118 */
119{
121 PLOGICAL_ADAPTER Adapter = WrapperContext->DeviceObject->DeviceExtension;
122 ULONG ResourceListSize;
123
124 PAGED_CODE();
125 ASSERT((Status && ResourceList) || (BufferSize && *BufferSize == 0));
126
127 NDIS_DbgPrint(MAX_TRACE, ("Called\n"));
128
129 if (Adapter->NdisMiniportBlock.AllocatedResources == NULL)
130 {
131 NDIS_DbgPrint(MIN_TRACE, ("No allocated resources!\n"));
133 return;
134 }
135
136 ResourceListSize =
137 FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors) +
138 Adapter->NdisMiniportBlock.AllocatedResources->List[0].PartialResourceList.Count *
140
141 if (*BufferSize >= ResourceListSize)
142 {
144 &Adapter->NdisMiniportBlock.AllocatedResources->List[0].PartialResourceList,
145 ResourceListSize);
146 *BufferSize = ResourceListSize;
148 }
149 else
150 {
151 *BufferSize = ResourceListSize;
153 }
154}
155
156
157/*
158 * @implemented
159 */
161EXPORT
165/*
166 * On X86 (and all other current hardware), map registers aren't real hardware,
167 * and there is no real limit to the number that can be allocated.
168 * As such, we do what microsoft does on the x86 hals and return as follows
169 */
170{
172}
173
174
175/*
176 * @implemented
177 */
178ULONG
179EXPORT
181 IN NDIS_HANDLE NdisAdapterHandle,
186{
187 PLOGICAL_ADAPTER Adapter = NdisAdapterHandle;
188 /* Slot number is ignored since W2K for all NDIS drivers. */
190 Adapter->NdisMiniportBlock.BusNumber, Adapter->NdisMiniportBlock.SlotNumber,
192}
193
194/*
195 * @implemented
196 */
197ULONG
198EXPORT
200 IN NDIS_HANDLE NdisAdapterHandle,
205{
206 PLOGICAL_ADAPTER Adapter = NdisAdapterHandle;
207 /* Slot number is ignored since W2K for all NDIS drivers. */
209 Adapter->NdisMiniportBlock.BusNumber, Adapter->NdisMiniportBlock.SlotNumber,
211}
212
213
214/*
215 * @implemented
216 */
217VOID
218EXPORT
224{
226 ULONG Ret;
228
229 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
230
231 /* We are called only at PASSIVE_LEVEL */
233 if (!Buffer) {
234 NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
236 return;
237 }
238
240 Wrapper->BusNumber,
241 Wrapper->SlotNumber,
242 Buffer,
244
245 if (Ret == 0 || Ret == 2) {
246 NDIS_DbgPrint(MIN_TRACE, ("HalGetBusData failed.\n"));
249 return;
250 }
251
252 *SlotNumber = Wrapper->SlotNumber;
253
255
257
259}
260
261
262/*
263 * @implemented
264 */
265ULONG
266EXPORT
268 IN NDIS_HANDLE NdisAdapterHandle,
272/*
273 * FUNCTION:
274 * ARGUMENTS:
275 * NOTES:
276 * NDIS 5.0
277 */
278{
279 PLOGICAL_ADAPTER Adapter = NdisAdapterHandle;
280
281 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
282
285 Adapter->NdisMiniportBlock.SlotNumber,
286 Buffer,
287 Offset,
288 Length);
289}
290
291
292/*
293 * @implemented
294 */
295ULONG
296EXPORT
298 IN NDIS_HANDLE NdisAdapterHandle,
302/*
303 * FUNCTION:
304 * ARGUMENTS:
305 * NOTES:
306 * NDIS 5.0
307 */
308{
309 PLOGICAL_ADAPTER Adapter = NdisAdapterHandle;
310
311 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
312
315 Adapter->NdisMiniportBlock.SlotNumber,
316 Buffer,
317 Offset,
318 Length);
319}
320
321/*
322 * @implemented
323 */
324VOID
325EXPORT
330/*
331 * FUNCTION:
332 * ARGUMENTS:
333 * NOTES:
334 * NDIS 4.0
335 */
336{
339
340 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
341
342 Wrapper->BusNumber = BusNumber;
343
344 if (Adapter)
346}
347
348/* EOF */
#define PAGED_CODE()
#define MIN_TRACE
Definition: debug.h:14
#define MAX_TRACE
Definition: debug.h:16
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
struct _NDIS_WRAPPER_CONTEXT * PNDIS_WRAPPER_CONTEXT
ULONG EXPORT NdisReadPcmciaAttributeMemory(IN NDIS_HANDLE NdisAdapterHandle, IN ULONG Offset, IN PVOID Buffer, IN ULONG Length)
Definition: hardware.c:267
ULONG EXPORT NdisReadPciSlotInformation(IN NDIS_HANDLE NdisAdapterHandle, IN ULONG SlotNumber, IN ULONG Offset, IN PVOID Buffer, IN ULONG Length)
Definition: hardware.c:180
ULONG EXPORT NdisWritePciSlotInformation(IN NDIS_HANDLE NdisAdapterHandle, IN ULONG SlotNumber, IN ULONG Offset, IN PVOID Buffer, IN ULONG Length)
Definition: hardware.c:199
ULONG EXPORT NdisWritePcmciaAttributeMemory(IN NDIS_HANDLE NdisAdapterHandle, IN ULONG Offset, IN PVOID Buffer, IN ULONG Length)
Definition: hardware.c:297
ULONG EXPORT NdisImmediateReadPciSlotInformation(IN NDIS_HANDLE WrapperConfigurationContext, IN ULONG SlotNumber, IN ULONG Offset, IN PVOID Buffer, IN ULONG Length)
Definition: hardware.c:22
VOID EXPORT NdisMQueryAdapterResources(OUT PNDIS_STATUS Status, IN NDIS_HANDLE WrapperConfigurationContext, OUT PNDIS_RESOURCE_LIST ResourceList, IN OUT PUINT BufferSize)
Definition: hardware.c:103
VOID EXPORT NdisReadEisaSlotInformation(OUT PNDIS_STATUS Status, IN NDIS_HANDLE WrapperConfigurationContext, OUT PUINT SlotNumber, OUT PNDIS_EISA_FUNCTION_INFORMATION EisaData)
Definition: hardware.c:219
NDIS_STATUS EXPORT NdisQueryMapRegisterCount(IN NDIS_INTERFACE_TYPE BusType, OUT PUINT MapRegisterCount)
Definition: hardware.c:162
ULONG EXPORT NdisImmediateWritePciSlotInformation(IN NDIS_HANDLE WrapperConfigurationContext, IN ULONG SlotNumber, IN ULONG Offset, IN PVOID Buffer, IN ULONG Length)
Definition: hardware.c:40
NDIS_STATUS EXPORT NdisMPciAssignResources(IN NDIS_HANDLE MiniportAdapterHandle, IN ULONG SlotNumber, OUT PNDIS_RESOURCE_LIST *AssignedResources)
Definition: hardware.c:58
NDIS_STATUS EXPORT NdisPciAssignResources(IN NDIS_HANDLE NdisMacHandle, IN NDIS_HANDLE NdisWrapperHandle, IN NDIS_HANDLE WrapperConfigurationContext, IN ULONG SlotNumber, OUT PNDIS_RESOURCE_LIST *AssignedResources)
Definition: hardware.c:83
VOID EXPORT NdisOverrideBusNumber(IN NDIS_HANDLE WrapperConfigurationContext, IN NDIS_HANDLE MiniportAdapterHandle OPTIONAL, IN ULONG BusNumber)
Definition: hardware.c:326
NTHALAPI ULONG NTAPI HalGetBusData(BUS_DATA_TYPE, ULONG, ULONG, PVOID, ULONG)
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define PagedPool
Definition: env_spec_w32.h:308
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
Status
Definition: gdiplustypes.h:25
ULONG NTAPI HalSetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: bus.c:123
ULONG NTAPI HalGetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: bus.c:73
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR CM_PARTIAL_RESOURCE_DESCRIPTOR
#define ASSERT(a)
Definition: mode.c:44
unsigned int * PUINT
Definition: ndis.h:50
#define NDIS_STATUS_NOT_SUPPORTED
Definition: ndis.h:479
enum _NDIS_INTERFACE_TYPE NDIS_INTERFACE_TYPE
#define NDIS_STATUS_FAILURE
Definition: ndis.h:465
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
@ NdisInterfacePci
Definition: ndis.h:905
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _In_ NDIS_HANDLE WrapperConfigurationContext
Definition: ndis.h:3946
_In_ NDIS_HANDLE MiniportAdapterHandle
Definition: ndis.h:4668
* PNDIS_STATUS
Definition: ndis.h:45
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
int NDIS_STATUS
Definition: ntddndis.h:475
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
@ EisaConfiguration
Definition: miniport.h:90
@ PCMCIAConfiguration
Definition: miniport.h:96
@ PCIConfiguration
Definition: miniport.h:93
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
PVOID DeviceExtension
Definition: env_spec_w32.h:418
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
NDIS_INTERFACE_TYPE BusType
Definition: ndis.h:2550
PDEVICE_OBJECT DeviceObject
Definition: miniport.h:79
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_In_ WDFDMATRANSACTION _Out_opt_ ULONG * MapRegisterCount
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:68
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:160
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE BusType
Definition: halfuncs.h:159