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)
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
23 NdisImmediateReadPciSlotInformation(
24 IN NDIS_HANDLE WrapperConfigurationContext
,
30 PNDIS_WRAPPER_CONTEXT WrapperContext
= (PNDIS_WRAPPER_CONTEXT
)WrapperConfigurationContext
;
31 return HalGetBusDataByOffset(PCIConfiguration
, WrapperContext
->BusNumber
,
32 SlotNumber
, Buffer
, Offset
, Length
);
41 NdisImmediateWritePciSlotInformation(
42 IN NDIS_HANDLE WrapperConfigurationContext
,
48 PNDIS_WRAPPER_CONTEXT WrapperContext
= (PNDIS_WRAPPER_CONTEXT
)WrapperConfigurationContext
;
49 return HalSetBusDataByOffset(PCIConfiguration
, WrapperContext
->BusNumber
,
50 SlotNumber
, Buffer
, Offset
, Length
);
59 NdisMPciAssignResources(
60 IN NDIS_HANDLE MiniportHandle
,
62 OUT PNDIS_RESOURCE_LIST
*AssignedResources
)
64 PNDIS_MINIPORT_BLOCK MiniportBlock
= (PNDIS_MINIPORT_BLOCK
)MiniportHandle
;
66 if (MiniportBlock
->BusType
!= PCIBus
||
67 MiniportBlock
->AllocatedResources
== NULL
)
69 *AssignedResources
= NULL
;
70 return NDIS_STATUS_FAILURE
;
73 *AssignedResources
= &MiniportBlock
->AllocatedResources
->List
[0].PartialResourceList
;
75 return NDIS_STATUS_SUCCESS
;
84 NdisMQueryAdapterResources(
85 OUT PNDIS_STATUS Status
,
86 IN NDIS_HANDLE WrapperConfigurationContext
,
87 OUT PNDIS_RESOURCE_LIST ResourceList
,
88 IN OUT PUINT BufferSize
)
90 * FUNCTION: returns a nic's hardware resources
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
97 * - Caller must allocate Status and ResourceList
98 * - Must be called at IRQL = PASSIVE_LEVEL;
101 PNDIS_WRAPPER_CONTEXT WrapperContext
= (PNDIS_WRAPPER_CONTEXT
)WrapperConfigurationContext
;
102 PNDIS_MINIPORT_BLOCK MiniportBlock
= WrapperContext
->DeviceObject
->DeviceExtension
;
103 ULONG ResourceListSize
;
106 ASSERT(Status
&& ResourceList
);
108 NDIS_DbgPrint(MAX_TRACE
, ("Called\n"));
110 if (MiniportBlock
->AllocatedResources
== NULL
)
112 NDIS_DbgPrint(MIN_TRACE
, ("No allocated resources!\n"));
113 *Status
= NDIS_STATUS_FAILURE
;
118 FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST
, PartialDescriptors
) +
119 MiniportBlock
->AllocatedResources
->List
[0].PartialResourceList
.Count
*
120 sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
);
122 if (*BufferSize
>= ResourceListSize
)
124 RtlCopyMemory(ResourceList
,
125 &MiniportBlock
->AllocatedResources
->List
[0].PartialResourceList
,
127 *BufferSize
= ResourceListSize
;
128 *Status
= STATUS_SUCCESS
;
132 *BufferSize
= ResourceListSize
;
133 *Status
= NDIS_STATUS_RESOURCES
;
143 NdisQueryMapRegisterCount(
144 IN NDIS_INTERFACE_TYPE BusType
,
145 OUT PUINT MapRegisterCount
)
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
152 return NDIS_STATUS_NOT_SUPPORTED
;
161 NdisReadEisaSlotInformation(
162 OUT PNDIS_STATUS Status
,
163 IN NDIS_HANDLE WrapperConfigurationContext
,
164 OUT PUINT SlotNumber
,
165 OUT PNDIS_EISA_FUNCTION_INFORMATION EisaData
)
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
)
192 NdisReadPciSlotInformation(
193 IN NDIS_HANDLE NdisAdapterHandle
,
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
);
212 NdisWritePciSlotInformation(
213 IN NDIS_HANDLE NdisAdapterHandle
,
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
);