ReactOS 0.4.17-dev-966-gf06eace
bussupp.c File Reference
#include <hal.h>
#include <debug.h>
#include "pci_classes.h"
#include "pci_vendors.h"
Include dependency graph for bussupp.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define NEWLINE   "\n"
 

Functions

PBUS_HANDLER NTAPI HalpAllocateBusHandler (IN INTERFACE_TYPE InterfaceType, IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN INTERFACE_TYPE ParentBusInterfaceType, IN ULONG ParentBusNumber, IN ULONG BusSpecificData)
 
static VOID NTAPI HalpRegisterInternalBusHandlers (VOID)
 
static NTSTATUS NTAPI HalpMarkChipsetDecode (IN BOOLEAN OverrideEnable)
 
static PBUS_HANDLER NTAPI HalpAllocateAndInitPciBusHandler (IN ULONG PciType, IN ULONG BusNo, IN BOOLEAN TestAllocation)
 
static BOOLEAN NTAPI HalpIsValidPCIDevice (IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot)
 
static NTSTATUS NTAPI HalpGetChipHacks (IN USHORT VendorId, IN USHORT DeviceId, IN UCHAR RevisionId, IN PULONG HackFlags)
 
static BOOLEAN NTAPI HalpIsRecognizedCard (IN PPCI_REGISTRY_INFO_INTERNAL PciRegistryInfo, IN PPCI_COMMON_CONFIG PciData, IN ULONG Flags)
 
static BOOLEAN NTAPI HalpIsIdeDevice (IN PPCI_COMMON_CONFIG PciData)
 
static BOOLEAN NTAPI HalpIsBridgeDevice (IN PPCI_COMMON_CONFIG PciData)
 
static BOOLEAN NTAPI HalpGetPciBridgeConfig (IN ULONG PciType, IN PUCHAR BusCount)
 
static VOID NTAPI HalpFixupPciSupportedRanges (IN ULONG BusCount)
 
static VOID ShowSize (IN ULONG x)
 
VOID NTAPI HalpDebugPciDumpBus (IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER PciSlot, IN ULONG i, IN ULONG j, IN ULONG k, IN PPCI_COMMON_CONFIG PciData)
 
VOID NTAPI HalpInitializePciBus (VOID)
 
VOID NTAPI HalpInitBusHandlers (VOID)
 
VOID NTAPI HalpRegisterKdSupportFunctions (VOID)
 
NTSTATUS NTAPI HalpAssignSlotResources (IN PUNICODE_STRING RegistryPath, IN PUNICODE_STRING DriverClassName, IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT DeviceObject, IN INTERFACE_TYPE BusType, IN ULONG BusNumber, IN ULONG SlotNumber, IN OUT PCM_RESOURCE_LIST *AllocatedResources)
 
BOOLEAN NTAPI HaliFindBusAddressTranslation (IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress, IN OUT PULONG_PTR Context, IN BOOLEAN NextBus)
 
BOOLEAN NTAPI HaliTranslateBusAddress (IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
 
NTSTATUS NTAPI HalAdjustResourceList (IN PIO_RESOURCE_REQUIREMENTS_LIST *ResourceList)
 
NTSTATUS NTAPI HalAssignSlotResources (IN PUNICODE_STRING RegistryPath, IN PUNICODE_STRING DriverClassName, IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT DeviceObject, IN INTERFACE_TYPE BusType, IN ULONG BusNumber, IN ULONG SlotNumber, IN OUT PCM_RESOURCE_LIST *AllocatedResources)
 
ULONG NTAPI HalGetBusData (IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Length)
 
ULONG NTAPI HalGetBusDataByOffset (IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
 
ULONG NTAPI HalGetInterruptVector (IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN ULONG BusInterruptLevel, IN ULONG BusInterruptVector, OUT PKIRQL Irql, OUT PKAFFINITY Affinity)
 
ULONG NTAPI HalSetBusData (IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Length)
 
ULONG NTAPI HalSetBusDataByOffset (IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
 
BOOLEAN NTAPI HalTranslateBusAddress (IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
 

Variables

KSPIN_LOCK HalpPCIConfigLock
 
ULONG HalpPciIrqMask
 
static BOOLEAN WarningsGiven [5]
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file bussupp.c.

◆ NEWLINE

#define NEWLINE   "\n"

Definition at line 701 of file bussupp.c.

Function Documentation

◆ HalAdjustResourceList()

NTSTATUS NTAPI HalAdjustResourceList ( IN PIO_RESOURCE_REQUIREMENTS_LIST *  ResourceList)

Definition at line 1361 of file bussupp.c.

1362{
1364 ULONG Status;
1365 PAGED_CODE();
1366
1367 /* Find the handler */
1368 Handler = HalReferenceHandlerForBus((*ResourceList)->InterfaceType,
1369 (*ResourceList)->BusNumber);
1370 if (!Handler) return STATUS_SUCCESS;
1371
1372 /* Do the assignment */
1373 Status = Handler->AdjustResourceList(Handler,
1374 Handler,
1375 ResourceList);
1376
1377 /* Dereference the handler and return */
1379 return Status;
1380}
#define PAGED_CODE()
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER Handler
Definition: acpixf.h:672
Status
Definition: gdiplustypes.h:24
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309
#define HalDereferenceBusHandler
Definition: haltypes.h:309
#define HalReferenceHandlerForBus
Definition: haltypes.h:307

◆ HalAssignSlotResources()

NTSTATUS NTAPI HalAssignSlotResources ( IN PUNICODE_STRING  RegistryPath,
IN PUNICODE_STRING  DriverClassName,
IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  DeviceObject,
IN INTERFACE_TYPE  BusType,
IN ULONG  BusNumber,
IN ULONG  SlotNumber,
IN OUT PCM_RESOURCE_LIST *  AllocatedResources 
)

Definition at line 1388 of file bussupp.c.

1396{
1397 PAGED_CODE();
1398
1399 /* Check the bus type */
1400 if (BusType != PCIBus)
1401 {
1402 /* Call our internal handler */
1407 BusType,
1408 BusNumber,
1409 SlotNumber,
1411 }
1412 else
1413 {
1414 /* Call the PCI registered function */
1419 PCIBus,
1420 BusNumber,
1421 SlotNumber,
1423 }
1424}
NTSTATUS NTAPI HalpAssignSlotResources(IN PUNICODE_STRING RegistryPath, IN PUNICODE_STRING DriverClassName, IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT DeviceObject, IN INTERFACE_TYPE BusType, IN ULONG BusNumber, IN ULONG SlotNumber, IN OUT PCM_RESOURCE_LIST *AllocatedResources)
Definition: bussupp.c:1207
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PCM_RESOURCE_LIST * AllocatedResources
Definition: ndis.h:4643
#define HalPciAssignSlotResources
Definition: halfuncs.h:42
_In_ ULONG BusNumber
Definition: pciidex.h:65
@ PCIBus
Definition: restypes.h:127
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:68
_In_opt_ PUNICODE_STRING DriverClassName
Definition: halfuncs.h:156
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE BusType
Definition: halfuncs.h:159

◆ HalGetBusData()

ULONG NTAPI HalGetBusData ( IN BUS_DATA_TYPE  BusDataType,
IN ULONG  BusNumber,
IN ULONG  SlotNumber,
IN PVOID  Buffer,
IN ULONG  Length 
)

Definition at line 1432 of file bussupp.c.

1437{
1438 /* Call the extended function */
1439 return HalGetBusDataByOffset(BusDataType,
1440 BusNumber,
1441 SlotNumber,
1442 Buffer,
1443 0,
1444 Length);
1445}
ULONG NTAPI HalGetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: bussupp.c:1453
Definition: bufpool.h:45
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102

◆ HalGetBusDataByOffset()

ULONG NTAPI HalGetBusDataByOffset ( IN BUS_DATA_TYPE  BusDataType,
IN ULONG  BusNumber,
IN ULONG  SlotNumber,
IN PVOID  Buffer,
IN ULONG  Offset,
IN ULONG  Length 
)

Definition at line 1453 of file bussupp.c.

1459{
1461 ULONG Status;
1462
1463 /* Find the handler */
1465 if (!Handler) return 0;
1466
1467 /* Do the assignment */
1468 Status = Handler->GetBusData(Handler,
1469 Handler,
1470 SlotNumber,
1471 Buffer,
1472 Offset,
1473 Length);
1474
1475 /* Dereference the handler and return */
1477 return Status;
1478}
PBUS_HANDLER FASTCALL HaliReferenceHandlerForConfigSpace(IN BUS_DATA_TYPE ConfigType, IN ULONG BusNumber)
Definition: bushndlr.c:221
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101

Referenced by HalGetBusData().

◆ HalGetInterruptVector()

ULONG NTAPI HalGetInterruptVector ( IN INTERFACE_TYPE  InterfaceType,
IN ULONG  BusNumber,
IN ULONG  BusInterruptLevel,
IN ULONG  BusInterruptVector,
OUT PKIRQL  Irql,
OUT PKAFFINITY  Affinity 
)

Definition at line 1486 of file bussupp.c.

1492{
1494 ULONG Vector;
1495 PAGED_CODE();
1496
1497 /* Defaults */
1498 *Irql = 0;
1499 *Affinity = 0;
1500
1501 /* Find the handler */
1503 if (!Handler) return 0;
1504
1505 /* Do the assignment */
1506 Vector = Handler->GetInterruptVector(Handler,
1507 Handler,
1510 Irql,
1511 Affinity);
1514 {
1515 DPRINT1("Returning IRQL %lx, Vector %lx for Level/Vector: %lx/%lx\n",
1517 DPRINT1("Old HAL would've returned IRQL %lx and Vector %lx\n",
1520 }
1521
1522 /* Dereference the handler and return */
1524 return Vector;
1525}
#define DPRINT1
Definition: precomp.h:8
_Out_ PKIRQL Irql
Definition: csq.h:179
#define VECTOR2IRQL(vector)
Definition: halirq.h:26
#define IRQ2VECTOR(irq)
Definition: halirq.h:27
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:463
_In_ ULONG _In_ ULONG BusInterruptLevel
Definition: halfuncs.h:171
_In_ ULONG _In_ ULONG _In_ ULONG BusInterruptVector
Definition: halfuncs.h:172
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:174

◆ HaliFindBusAddressTranslation()

BOOLEAN NTAPI HaliFindBusAddressTranslation ( IN PHYSICAL_ADDRESS  BusAddress,
IN OUT PULONG  AddressSpace,
OUT PPHYSICAL_ADDRESS  TranslatedAddress,
IN OUT PULONG_PTR  Context,
IN BOOLEAN  NextBus 
)

Definition at line 1242 of file bussupp.c.

1247{
1248 PHAL_BUS_HANDLER BusHandler;
1250 PLIST_ENTRY NextEntry;
1251
1252 /* Make sure we have a context */
1253 if (!Context)
1254 return FALSE;
1255
1256 /* If we have data in the context, then this shouldn't be a new lookup */
1257 if ((*Context != 0) && (NextBus != FALSE))
1258 return FALSE;
1259
1260 /* Find the bus handler */
1262 if (!Handler)
1263 return FALSE;
1264
1265 /* Check if this is an ongoing lookup */
1266 if (NextBus)
1267 {
1268 /* Get the HAL bus handler */
1270 NextEntry = &BusHandler->AllHandlers;
1271
1272 /* Get the next one if we were already with one */
1273 if (*Context)
1274 NextEntry = NextEntry->Flink;
1275
1276 /* Start scanning */
1277 while (TRUE)
1278 {
1279 /* Check if this is the last one */
1280 if (NextEntry == &HalpAllBusHandlers)
1281 {
1282 /* Quit */
1283 *Context = 1;
1284 return FALSE;
1285 }
1286
1287 /* Call this translator */
1288 BusHandler = CONTAINING_RECORD(NextEntry, HAL_BUS_HANDLER, AllHandlers);
1290 BusHandler->Handler.BusNumber,
1291 BusAddress,
1294 {
1295 break;
1296 }
1297
1298 /* Try the next one */
1299 NextEntry = NextEntry->Flink;
1300 }
1301
1302 /* If we made it, we're done */
1303 *Context = (ULONG_PTR)&BusHandler->Handler;
1304 return TRUE;
1305 }
1306
1307 /* Try the first one through */
1308 if (!HalTranslateBusAddress(Handler->InterfaceType,
1309 Handler->BusNumber,
1310 BusAddress,
1313 {
1314 return FALSE;
1315 }
1316
1317 /* Remember for next time */
1319 return TRUE;
1320}
PBUS_HANDLER NTAPI HalpContextToBusHandler(IN ULONG_PTR ContextValue)
Definition: bushndlr.c:230
LIST_ENTRY HalpAllBusHandlers
Definition: bushndlr.c:19
BOOLEAN NTAPI HalTranslateBusAddress(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
Definition: bussupp.c:1585
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ULONG_PTR
Definition: config.h:101
_In_ PVOID Context
Definition: storport.h:2269
ULONG BusNumber
Definition: haltypes.h:1994
INTERFACE_TYPE InterfaceType
Definition: haltypes.h:1992
BUS_HANDLER Handler
Definition: bus.h:271
LIST_ENTRY AllHandlers
Definition: bus.h:269
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_In_ ULONG _In_ PHYSICAL_ADDRESS BusAddress
Definition: iofuncs.h:2273
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG _Out_ PPHYSICAL_ADDRESS TranslatedAddress
Definition: iofuncs.h:2275
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2274

Referenced by HalpInitBusHandler().

◆ HaliTranslateBusAddress()

BOOLEAN NTAPI HaliTranslateBusAddress ( IN INTERFACE_TYPE  InterfaceType,
IN ULONG  BusNumber,
IN PHYSICAL_ADDRESS  BusAddress,
IN OUT PULONG  AddressSpace,
OUT PPHYSICAL_ADDRESS  TranslatedAddress 
)

Definition at line 1324 of file bussupp.c.

1329{
1332
1333 /* Find the handler */
1335 if (!(Handler) || !(Handler->TranslateBusAddress))
1336 {
1337 DPRINT1("No translator Interface: %x, Bus: %x, Handler: %p, BusAddress: %x!\n", InterfaceType, BusNumber, Handler, BusAddress);
1338 return FALSE;
1339 }
1340
1341 /* Do the assignment */
1342 Status = Handler->TranslateBusAddress(Handler,
1343 Handler,
1344 BusAddress,
1347
1348 /* Dereference the handler and return */
1350 return Status;
1351}
unsigned char BOOLEAN
Definition: actypes.h:127

Referenced by HalpInitBusHandler(), and HalTranslateBusAddress().

◆ HalpAllocateAndInitPciBusHandler()

static PBUS_HANDLER NTAPI HalpAllocateAndInitPciBusHandler ( IN ULONG  PciType,
IN ULONG  BusNo,
IN BOOLEAN  TestAllocation 
)
static

Definition at line 197 of file bussupp.c.

200{
201 PBUS_HANDLER Bus;
202 PPCIPBUSDATA BusData;
203
204 /* Allocate the bus handler */
207 BusNo,
208 Internal,
209 0,
210 sizeof(PCIPBUSDATA));
211
212 /* Set it up */
218 Bus->BusAddresses->Dma.Limit = 0;
219
220 /* Get our custom bus data */
221 BusData = (PPCIPBUSDATA)Bus->BusData;
222
223 /* Setup custom bus data */
224 BusData->CommonData.Tag = PCI_DATA_TAG;
230 BusData->MaxDevice = PCI_MAX_DEVICES;
232
233 /* Initialize the bitmap */
234 RtlInitializeBitMap(&BusData->DeviceConfigured, BusData->ConfiguredBits, 256);
235
236 /* Check the type of PCI bus */
237 switch (PciType)
238 {
239 /* Type 1 PCI Bus */
240 case 1:
241
242 /* Copy the Type 1 handler data */
245 sizeof(PCIConfigHandler));
246
247 /* Set correct I/O Ports */
248 BusData->Config.Type1.Address = PCI_TYPE1_ADDRESS_PORT;
249 BusData->Config.Type1.Data = PCI_TYPE1_DATA_PORT;
250 break;
251
252 /* Type 2 PCI Bus */
253 case 2:
254
255 /* Copy the Type 1 handler data */
258 sizeof (PCIConfigHandler));
259
260 /* Set correct I/O Ports */
261 BusData->Config.Type2.CSE = PCI_TYPE2_CSE_PORT;
262 BusData->Config.Type2.Forward = PCI_TYPE2_FORWARD_PORT;
263 BusData->Config.Type2.Base = PCI_TYPE2_ADDRESS_BASE;
264
265 /* Only 16 devices supported, not 32 */
266 BusData->MaxDevice = 16;
267 break;
268
269 default:
270
271 /* Invalid type */
272 DbgPrint("HAL: Unknown PCI type\n");
273 }
274
275 /* Return the bus handler */
276 return Bus;
277}
#define PCI_TYPE1_DATA_PORT
Definition: hardware.h:45
#define PCI_TYPE1_ADDRESS_PORT
Definition: hardware.h:44
ULONG NTAPI HalpGetPCIIntOnISABus(IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN ULONG BusInterruptLevel, IN ULONG BusInterruptVector, OUT PKIRQL Irql, OUT PKAFFINITY Affinity)
Definition: pcibus.c:658
NTSTATUS NTAPI HalpAssignPCISlotResources(IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN PUNICODE_STRING RegistryPath, IN PUNICODE_STRING DriverClassName OPTIONAL, IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN ULONG Slot, IN OUT PCM_RESOURCE_LIST *pAllocatedResources)
Definition: pcibus.c:798
VOID NTAPI HalpPCIPin2ISALine(IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN PCI_SLOT_NUMBER SlotNumber, IN PPCI_COMMON_CONFIG PciData)
Definition: pcibus.c:680
#define PCI_TYPE2_ADDRESS_BASE
Definition: bus.h:172
#define PCI_TYPE2_CSE_PORT
Definition: bus.h:170
const PCI_CONFIG_HANDLER PCIConfigHandlerType1
Definition: pcibus.c:35
VOID NTAPI HalpPCIISALine2Pin(IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN PCI_SLOT_NUMBER SlotNumber, IN PPCI_COMMON_CONFIG PciNewData, IN PPCI_COMMON_CONFIG PciOldData)
Definition: pcibus.c:690
NTSTATUS NTAPI HalpAdjustPCIResourceList(IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *pResourceList)
Definition: pcibus.c:757
NTSTATUS NTAPI HalpGetISAFixedPCIIrq(IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN PCI_SLOT_NUMBER PciSlot, OUT PSUPPORTED_RANGE *Range)
Definition: pcibus.c:702
PCI_CONFIG_HANDLER PCIConfigHandler
Definition: pcibus.c:23
VOID NTAPI HalpWritePCIConfig(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pcibus.c:283
const PCI_CONFIG_HANDLER PCIConfigHandlerType2
Definition: pcibus.c:57
VOID NTAPI HalpReadPCIConfig(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pcibus.c:257
ULONG NTAPI HalpGetPCIData(IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootBusHandler, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pcibus.c:507
#define PCI_TYPE2_FORWARD_PORT
Definition: bus.h:171
ULONG NTAPI HalpSetPCIData(IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootBusHandler, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pcibus.c:587
struct _PCIPBUSDATA * PPCIPBUSDATA
PBUS_HANDLER NTAPI HalpAllocateBusHandler(IN INTERFACE_TYPE InterfaceType, IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN INTERFACE_TYPE ParentBusInterfaceType, IN ULONG ParentBusNumber, IN ULONG BusSpecificData)
Definition: bussupp.c:27
#define RtlInitializeBitMap
Definition: dbgbitmap.h:326
#define DbgPrint
Definition: hal.h:12
@ Internal
Definition: restypes.h:122
@ PCIConfiguration
Definition: miniport.h:93
PGETINTERRUPTVECTOR GetInterruptVector
Definition: haltypes.h:2005
PGETSETBUSDATA GetBusData
Definition: haltypes.h:2001
PSUPPORTED_RANGES BusAddresses
Definition: haltypes.h:1999
PASSIGNSLOTRESOURCES AssignSlotResources
Definition: haltypes.h:2004
PGETSETBUSDATA SetBusData
Definition: haltypes.h:2002
PADJUSTRESOURCELIST AdjustResourceList
Definition: haltypes.h:2003
PVOID BusData
Definition: haltypes.h:1997
PciReadWriteConfig WriteConfig
Definition: iotypes.h:5285
PciLine2Pin Line2Pin
Definition: iotypes.h:5287
ULONG Tag
Definition: iotypes.h:5282
PciReadWriteConfig ReadConfig
Definition: iotypes.h:5284
ULONG Version
Definition: iotypes.h:5283
PciPin2Line Pin2Line
Definition: iotypes.h:5286
ULONG ConfiguredBits[PCI_MAX_DEVICES *PCI_MAX_FUNCTION/32]
Definition: bus.h:118
struct _PCIPBUSDATA::@1714::@1715 Type1
union _PCIPBUSDATA::@1714 Config
PciIrqRange GetIrqRange
Definition: bus.h:111
struct _PCIPBUSDATA::@1714::@1716 Type2
PCIBUSDATA CommonData
Definition: bus.h:95
ULONG MaxDevice
Definition: bus.h:110
RTL_BITMAP DeviceConfigured
Definition: bus.h:117
SUPPORTED_RANGE Dma
Definition: haltypes.h:1982
LONGLONG Limit
Definition: haltypes.h:1967
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define PCI_DATA_TAG
Definition: iotypes.h:5278
#define PCI_MAX_DEVICES
Definition: iotypes.h:3600
#define PCI_DATA_VERSION
Definition: iotypes.h:5279

Referenced by HalpInitializePciBus().

◆ HalpAllocateBusHandler()

PBUS_HANDLER NTAPI HalpAllocateBusHandler ( IN INTERFACE_TYPE  InterfaceType,
IN BUS_DATA_TYPE  BusDataType,
IN ULONG  BusNumber,
IN INTERFACE_TYPE  ParentBusInterfaceType,
IN ULONG  ParentBusNumber,
IN ULONG  BusSpecificData 
)

Definition at line 27 of file bussupp.c.

33{
34 PBUS_HANDLER Bus;
35
36 /* Register the bus handler */
38 BusDataType,
40 ParentBusInterfaceType,
41 ParentBusNumber,
42 BusSpecificData,
43 NULL,
44 &Bus);
45 if (!Bus)
46 {
47 return NULL;
48 }
49
50 /* Check for a valid interface */
52 {
53 /* Allocate address ranges and zero them out */
55 sizeof(SUPPORTED_RANGES),
56 TAG_HAL);
58
59 /* Build the data structure */
61 Bus->BusAddresses->Dma.Limit = 7;
62 Bus->BusAddresses->Memory.Limit = 0xFFFFFFFF;
63 Bus->BusAddresses->IO.Limit = 0xFFFF;
66 }
67
68 /* Return the bus address */
69 return Bus;
70}
#define NULL
Definition: types.h:112
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define TAG_HAL
Definition: hal.h:61
#define HalRegisterBusHandler
Definition: halfuncs.h:38
#define HAL_SUPPORTED_RANGE_VERSION
Definition: haltypes.h:1960
@ InterfaceTypeUndefined
Definition: restypes.h:121
SUPPORTED_RANGE PrefetchMemory
Definition: haltypes.h:1980
SUPPORTED_RANGE Memory
Definition: haltypes.h:1978
SUPPORTED_RANGE IO
Definition: haltypes.h:1976
ULONG SystemAddressSpace
Definition: haltypes.h:1964
LONGLONG Base
Definition: haltypes.h:1966
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
@ NonPagedPoolMustSucceed
Definition: ketypes.h:948

Referenced by HalpAllocateAndInitPciBusHandler(), and HalpRegisterInternalBusHandlers().

◆ HalpAssignSlotResources()

NTSTATUS NTAPI HalpAssignSlotResources ( IN PUNICODE_STRING  RegistryPath,
IN PUNICODE_STRING  DriverClassName,
IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  DeviceObject,
IN INTERFACE_TYPE  BusType,
IN ULONG  BusNumber,
IN ULONG  SlotNumber,
IN OUT PCM_RESOURCE_LIST *  AllocatedResources 
)

Definition at line 1207 of file bussupp.c.

1215{
1218 PAGED_CODE();
1219 DPRINT1("Slot assignment for %d on bus %u\n", BusType, BusNumber);
1220
1221 /* Find the handler */
1223 if (!Handler) return STATUS_NOT_FOUND;
1224
1225 /* Do the assignment */
1226 Status = Handler->AssignSlotResources(Handler,
1227 Handler,
1232 SlotNumber,
1234
1235 /* Dereference the handler and return */
1237 return Status;
1238}
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_NOT_FOUND
Definition: shellext.h:72

Referenced by HalAssignSlotResources().

◆ HalpDebugPciDumpBus()

VOID NTAPI HalpDebugPciDumpBus ( IN PBUS_HANDLER  BusHandler,
IN PCI_SLOT_NUMBER  PciSlot,
IN ULONG  i,
IN ULONG  j,
IN ULONG  k,
IN PPCI_COMMON_CONFIG  PciData 
)

Definition at line 707 of file bussupp.c.

713{
714 PCHAR p, ClassName, Boundary, SubClassName, VendorName, ProductName, SubVendorName;
715 UCHAR HeaderType;
717 CHAR LookupString[16] = "";
718 CHAR bSubClassName[64] = "Unknown";
719 CHAR bVendorName[64] = "";
720 CHAR bProductName[128] = "Unknown device";
721 CHAR bSubVendorName[128] = "Unknown";
722 ULONG Size, Mem, b;
723
724 HeaderType = PCI_CONFIGURATION_TYPE(PciData);
725
726 /* Isolate the class name */
727 sprintf(LookupString, "C %02x ", PciData->BaseClass);
728 ClassName = strstr((PCHAR)ClassTable, LookupString);
729 if (ClassName)
730 {
731 /* Isolate the subclass name */
732 ClassName += strlen("C 00 ");
733 Boundary = strstr(ClassName, NEWLINE "C ");
734 sprintf(LookupString, NEWLINE "\t%02x ", PciData->SubClass);
735 SubClassName = strstr(ClassName, LookupString);
736 if (Boundary && SubClassName > Boundary)
737 {
738 SubClassName = NULL;
739 }
740 if (!SubClassName)
741 {
742 SubClassName = ClassName;
743 }
744 else
745 {
746 SubClassName += strlen(NEWLINE "\t00 ");
747 }
748 /* Copy the subclass into our buffer */
749 p = strpbrk(SubClassName, NEWLINE);
750 Length = p - SubClassName;
751 Length = min(Length, sizeof(bSubClassName) - 1);
752 strncpy(bSubClassName, SubClassName, Length);
753 bSubClassName[Length] = '\0';
754 }
755
756 /* Isolate the vendor name */
757 sprintf(LookupString, NEWLINE "%04x ", PciData->VendorID);
758 VendorName = strstr((PCHAR)VendorTable, LookupString);
759 if (VendorName)
760 {
761 /* Copy the vendor name into our buffer */
762 VendorName += strlen(NEWLINE "0000 ");
764 Length = p - VendorName;
765 Length = min(Length, sizeof(bVendorName) - 1);
766 strncpy(bVendorName, VendorName, Length);
767 bVendorName[Length] = '\0';
768 p += strlen(NEWLINE);
769 while (*p == '\t' || *p == '#')
770 {
771 p = strpbrk(p, NEWLINE);
772 p += strlen(NEWLINE);
773 }
774 Boundary = p;
775
776 /* Isolate the product name */
777 sprintf(LookupString, "\t%04x ", PciData->DeviceID);
778 ProductName = strstr(VendorName, LookupString);
779 if (Boundary && ProductName >= Boundary)
780 {
781 ProductName = NULL;
782 }
783 if (ProductName)
784 {
785 /* Copy the product name into our buffer */
786 ProductName += strlen("\t0000 ");
787 p = strpbrk(ProductName, NEWLINE);
788 Length = p - ProductName;
789 Length = min(Length, sizeof(bProductName) - 1);
790 strncpy(bProductName, ProductName, Length);
791 bProductName[Length] = '\0';
792 p += strlen(NEWLINE);
793 while ((*p == '\t' && *(p + 1) == '\t') || *p == '#')
794 {
795 p = strpbrk(p, NEWLINE);
796 p += strlen(NEWLINE);
797 }
798 Boundary = p;
799 SubVendorName = NULL;
800
801 if (HeaderType == PCI_DEVICE_TYPE)
802 {
803 /* Isolate the subvendor and subsystem name */
804 sprintf(LookupString,
805 "\t\t%04x %04x ",
806 PciData->u.type0.SubVendorID,
807 PciData->u.type0.SubSystemID);
808 SubVendorName = strstr(ProductName, LookupString);
809 if (Boundary && SubVendorName >= Boundary)
810 {
811 SubVendorName = NULL;
812 }
813 }
814 if (SubVendorName)
815 {
816 /* Copy the subvendor name into our buffer */
817 SubVendorName += strlen("\t\t0000 0000 ");
818 p = strpbrk(SubVendorName, NEWLINE);
819 Length = p - SubVendorName;
820 Length = min(Length, sizeof(bSubVendorName) - 1);
821 strncpy(bSubVendorName, SubVendorName, Length);
822 bSubVendorName[Length] = '\0';
823 }
824 }
825 }
826
827 /* Print out the data */
828 DbgPrint("%02x:%02x.%x %s [%02x%02x]: %s %s [%04x:%04x] (rev %02x)\n",
829 i,
830 j,
831 k,
832 bSubClassName,
833 PciData->BaseClass,
834 PciData->SubClass,
835 bVendorName,
836 bProductName,
837 PciData->VendorID,
838 PciData->DeviceID,
839 PciData->RevisionID);
840
841 if (HeaderType == PCI_DEVICE_TYPE)
842 {
843 DbgPrint("\tSubsystem: %s [%04x:%04x]\n",
844 bSubVendorName,
845 PciData->u.type0.SubVendorID,
846 PciData->u.type0.SubSystemID);
847 }
848
849 /* Print out and decode flags */
850 DbgPrint("\tFlags:");
851 if (PciData->Command & PCI_ENABLE_BUS_MASTER) DbgPrint(" bus master,");
852 if (PciData->Status & PCI_STATUS_66MHZ_CAPABLE) DbgPrint(" 66MHz,");
853 if ((PciData->Status & PCI_STATUS_DEVSEL) == 0x000) DbgPrint(" fast devsel,");
854 if ((PciData->Status & PCI_STATUS_DEVSEL) == 0x200) DbgPrint(" medium devsel,");
855 if ((PciData->Status & PCI_STATUS_DEVSEL) == 0x400) DbgPrint(" slow devsel,");
856 if ((PciData->Status & PCI_STATUS_DEVSEL) == 0x600) DbgPrint(" unknown devsel,");
857 DbgPrint(" latency %d", PciData->LatencyTimer);
858 if (PciData->u.type0.InterruptPin != 0 &&
859 PciData->u.type0.InterruptLine != 0 &&
860 PciData->u.type0.InterruptLine != 0xFF) DbgPrint(", IRQ %02d", PciData->u.type0.InterruptLine);
861 else if (PciData->u.type0.InterruptPin != 0) DbgPrint(", IRQ assignment required");
862 DbgPrint("\n");
863
864 if (HeaderType == PCI_BRIDGE_TYPE)
865 {
866 DbgPrint("\tBridge:");
867 DbgPrint(" primary bus %d,", PciData->u.type1.PrimaryBus);
868 DbgPrint(" secondary bus %d,", PciData->u.type1.SecondaryBus);
869 DbgPrint(" subordinate bus %d,", PciData->u.type1.SubordinateBus);
870 DbgPrint(" secondary latency %d", PciData->u.type1.SecondaryLatency);
871 DbgPrint("\n");
872 }
873
874 /* Scan addresses */
875 Size = 0;
876 for (b = 0; b < (HeaderType == PCI_DEVICE_TYPE ? PCI_TYPE0_ADDRESSES : PCI_TYPE1_ADDRESSES); b++)
877 {
878 /* Check for a BAR */
879 if (HeaderType != PCI_CARDBUS_BRIDGE_TYPE)
880 Mem = PciData->u.type0.BaseAddresses[b];
881 else
882 Mem = 0;
883 if (Mem)
884 {
885 ULONG PciBar = 0xFFFFFFFF;
886
887 HalpWritePCIConfig(BusHandler,
888 PciSlot,
889 &PciBar,
890 FIELD_OFFSET(PCI_COMMON_HEADER, u.type0.BaseAddresses[b]),
891 sizeof(ULONG));
892 HalpReadPCIConfig(BusHandler,
893 PciSlot,
894 &PciBar,
895 FIELD_OFFSET(PCI_COMMON_HEADER, u.type0.BaseAddresses[b]),
896 sizeof(ULONG));
897 HalpWritePCIConfig(BusHandler,
898 PciSlot,
899 &Mem,
900 FIELD_OFFSET(PCI_COMMON_HEADER, u.type0.BaseAddresses[b]),
901 sizeof(ULONG));
902
903 /* Decode the address type */
904 if (PciBar & PCI_ADDRESS_IO_SPACE)
905 {
906 /* Guess the size */
907 Size = 1 << 2;
908 while (!(PciBar & Size) && (Size)) Size <<= 1;
909
910 /* Print it out */
911 DbgPrint("\tI/O ports at %04lx", Mem & PCI_ADDRESS_IO_ADDRESS_MASK);
912 ShowSize(Size);
913 }
914 else
915 {
916 /* Guess the size */
917 Size = 1 << 4;
918 while (!(PciBar & Size) && (Size)) Size <<= 1;
919
920 /* Print it out */
921 DbgPrint("\tMemory at %08lx (%d-bit, %sprefetchable)",
923 (Mem & PCI_ADDRESS_MEMORY_TYPE_MASK) == PCI_TYPE_32BIT ? 32 : 64,
924 (Mem & PCI_ADDRESS_MEMORY_PREFETCHABLE) ? "" : "non-");
925 ShowSize(Size);
926 }
927 DbgPrint("\n");
928 }
929 }
930}
static const char VendorName[]
Definition: ParaNdis-Oid.c:36
#define NEWLINE
Definition: bussupp.c:701
static VOID ShowSize(IN ULONG x)
Definition: bussupp.c:674
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
_ACRTIMP char *__cdecl strstr(const char *, const char *)
Definition: string.c:3420
_ACRTIMP char *__cdecl strpbrk(const char *, const char *)
Definition: string.c:3530
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLfloat GLfloat p
Definition: glext.h:8902
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define b
Definition: ke_i.h:79
#define sprintf
Definition: sprintf.c:45
#define min(a, b)
Definition: monoChain.cc:55
int k
Definition: mpi.c:3369
_In_ ULONG _In_ PCI_SLOT_NUMBER PciSlot
Definition: pciidex.h:66
char CHAR
Definition: pedump.c:57
strncpy
Definition: string.h:335
unsigned char UCHAR
Definition: typedefs.h:53
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
#define PCI_TYPE_32BIT
Definition: iotypes.h:4240
#define PCI_ADDRESS_IO_ADDRESS_MASK
Definition: iotypes.h:4236
#define PCI_ENABLE_BUS_MASTER
Definition: iotypes.h:3620
#define PCI_TYPE0_ADDRESSES
Definition: iotypes.h:3502
#define PCI_ADDRESS_IO_SPACE
Definition: iotypes.h:4233
#define PCI_CONFIGURATION_TYPE(PciData)
Definition: iotypes.h:3611
#define PCI_TYPE1_ADDRESSES
Definition: iotypes.h:3503
#define PCI_STATUS_66MHZ_CAPABLE
Definition: iotypes.h:3633
#define PCI_BRIDGE_TYPE
Definition: iotypes.h:3608
#define PCI_STATUS_DEVSEL
Definition: iotypes.h:3637
#define PCI_ADDRESS_MEMORY_ADDRESS_MASK
Definition: iotypes.h:4237
#define PCI_ADDRESS_MEMORY_PREFETCHABLE
Definition: iotypes.h:4235
#define PCI_ADDRESS_MEMORY_TYPE_MASK
Definition: iotypes.h:4234
#define PCI_DEVICE_TYPE
Definition: iotypes.h:3607
#define PCI_CARDBUS_BRIDGE_TYPE
Definition: iotypes.h:3609

Referenced by HalpInitializePciBus().

◆ HalpFixupPciSupportedRanges()

static VOID NTAPI HalpFixupPciSupportedRanges ( IN ULONG  BusCount)
static

Definition at line 610 of file bussupp.c.

611{
612 ULONG i;
613 PBUS_HANDLER Bus, ParentBus;
614
615 /* Loop all buses */
616 for (i = 0; i < BusCount; i++)
617 {
618 /* Get PCI bus handler */
619 Bus = HalHandlerForBus(PCIBus, i);
620
621 /* Loop all parent buses */
622 ParentBus = Bus->ParentHandler;
623 while (ParentBus)
624 {
625 /* Should merge addresses */
626 if (!WarningsGiven[0]++)
627 DPRINT1("Found parent bus (indicating PCI Bridge). PCI devices may fail!\n");
628
629 /* Check the next parent */
630 ParentBus = ParentBus->ParentHandler;
631 }
632 }
633
634 /* Loop all buses again */
635 for (i = 0; i < BusCount; i++)
636 {
637 /* Get PCI bus handler */
638 Bus = HalHandlerForBus(PCIBus, i);
639
640 /* Check if this is a PCI 2.2 Bus with Subtractive Decode */
641 if (!((PPCIPBUSDATA)Bus->BusData)->Subtractive)
642 {
643 /* Loop all parent buses */
644 ParentBus = Bus->ParentHandler;
645 while (ParentBus)
646 {
647 /* But check only PCI parent buses specifically */
648 if (ParentBus->InterfaceType == PCIBus)
649 {
650 /* Should trim addresses */
651 if (!WarningsGiven[1]++)
652 DPRINT1("Found parent PCI Bus (indicating PCI-to-PCI Bridge). PCI devices may fail!\n");
653 }
654
655 /* Check the next parent */
656 ParentBus = ParentBus->ParentHandler;
657 }
658 }
659 }
660
661 /* Loop buses one last time */
662 for (i = 0; i < BusCount; i++)
663 {
664 /* Get the PCI bus handler */
665 Bus = HalHandlerForBus(PCIBus, i);
666
667 /* Sort and combine (trim) bus address range information */
668 DPRINT("Warning: Bus addresses not being optimized!\n");
669 }
670}
static BOOLEAN WarningsGiven[5]
Definition: bussupp.c:551
#define HalHandlerForBus
Definition: halfuncs.h:35
#define DPRINT
Definition: sndvol32.h:73
struct _BUS_HANDLER * ParentHandler
Definition: haltypes.h:1996

Referenced by HalpInitializePciBus().

◆ HalpGetChipHacks()

static NTSTATUS NTAPI HalpGetChipHacks ( IN USHORT  VendorId,
IN USHORT  DeviceId,
IN UCHAR  RevisionId,
IN PULONG  HackFlags 
)
static

Definition at line 342 of file bussupp.c.

346{
351 WCHAR Buffer[32];
354
355 /* Setup the object attributes for the key */
357 L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET\\"
358 L"Control\\HAL");
360 &KeyName,
362 NULL,
363 NULL);
364
365 /* Open the key */
366 Status = ZwOpenKey(&KeyHandle, KEY_READ, &ObjectAttributes);
367 if (!NT_SUCCESS(Status)) return Status;
368
369 /* Query value */
370 _swprintf(Buffer, L"%04X%04X", VendorId, DeviceId);
372 Status = ZwQueryValueKey(KeyHandle,
373 &ValueName,
375 &PartialInfo,
376 sizeof(PartialInfo),
377 &ResultLength);
378 if (NT_SUCCESS(Status))
379 {
380 /* Return the flags */
381 DbgPrint("\tFound HackFlags for your chipset\n");
382 *HackFlags = *(PULONG)PartialInfo.Data;
383 DbgPrint("\t\tHack Flags: %lx (Hack Revision: %lx-Your Revision: %lx)\n",
385
386 /* Does it apply to this revision? */
387 if ((RevisionId) && (RevisionId >= (HALP_REVISION_FROM_HACK_FLAGS(*HackFlags))))
388 {
389 /* Read the revision flags */
391 }
392
393 /* Throw out revision data */
395 if (!*HackFlags) DbgPrint("\tNo HackFlags for your chipset's revision!\n");
396 }
397
398 /* Close the handle and return */
400 return Status;
401}
_In_ ULONG_PTR HackFlags
Definition: cdrom.h:983
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define L(x)
Definition: resources.c:13
#define HALP_HACK_FLAGS(x)
Definition: halp.h:169
#define HALP_REVISION_FROM_HACK_FLAGS(x)
Definition: halp.h:167
#define HALP_REVISION_HACK_FLAGS(x)
Definition: halp.h:168
#define _swprintf(buf, format,...)
Definition: sprintf.c:56
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:115
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
@ KeyValuePartialInformation
Definition: nt_native.h:1185
#define KEY_READ
Definition: nt_native.h:1026
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
short WCHAR
Definition: pedump.c:58
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
uint32_t * PULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3782
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2705
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243

Referenced by HalpInitializePciBus().

◆ HalpGetPciBridgeConfig()

static BOOLEAN NTAPI HalpGetPciBridgeConfig ( IN ULONG  PciType,
IN PUCHAR  BusCount 
)
static

Definition at line 556 of file bussupp.c.

558{
560 ULONG i, j, k;
561 UCHAR DataBuffer[PCI_COMMON_HDR_LENGTH];
562 PPCI_COMMON_CONFIG PciData = (PPCI_COMMON_CONFIG)DataBuffer;
563 PBUS_HANDLER BusHandler;
564
565 /* Loop PCI buses */
566 PciSlot.u.bits.Reserved = 0;
567 for (i = 0; i < *BusCount; i++)
568 {
569 /* Get the bus handler */
570 BusHandler = HalHandlerForBus(PCIBus, i);
571
572 /* Loop every device */
573 for (j = 0; j < PCI_MAX_DEVICES; j++)
574 {
575 /* Loop every function */
576 PciSlot.u.bits.DeviceNumber = j;
577 for (k = 0; k < PCI_MAX_FUNCTION; k++)
578 {
579 /* Build the final slot structure */
580 PciSlot.u.bits.FunctionNumber = k;
581
582 /* Read the configuration information */
583 HalpReadPCIConfig(BusHandler,
584 PciSlot,
585 PciData,
586 0,
588
589 /* Skip if this is an invalid function */
590 if (PciData->VendorID == PCI_INVALID_VENDORID) continue;
591
592 /* Make sure that this is a PCI bridge or a cardbus bridge */
593 if (!HalpIsBridgeDevice(PciData)) continue;
594
595 /* Not supported */
596 if (!WarningsGiven[2]++)
597 DPRINT1("Your machine has a PCI-to-PCI or CardBUS Bridge. PCI devices may fail!\n");
598 continue;
599 }
600 }
601 }
602
603 /* If we exited the loop, then there's no bridge to worry about */
604 return FALSE;
605}
static BOOLEAN NTAPI HalpIsBridgeDevice(IN PPCI_COMMON_CONFIG PciData)
Definition: bussupp.c:540
union _PCI_SLOT_NUMBER::@4969 u
struct _PCI_SLOT_NUMBER::@4969::@4970 bits
#define PCI_INVALID_VENDORID
Definition: iotypes.h:3603
struct _PCI_COMMON_CONFIG * PPCI_COMMON_CONFIG
#define PCI_MAX_FUNCTION
Definition: iotypes.h:3601
#define PCI_COMMON_HDR_LENGTH
Definition: iotypes.h:3596

Referenced by HalpInitializePciBus().

◆ HalpInitBusHandlers()

VOID NTAPI HalpInitBusHandlers ( VOID  )

Definition at line 1176 of file bussupp.c.

1177{
1178 /* Register the HAL Bus Handler support */
1180}
static VOID NTAPI HalpRegisterInternalBusHandlers(VOID)
Definition: bussupp.c:75

◆ HalpInitializePciBus()

VOID NTAPI HalpInitializePciBus ( VOID  )

Definition at line 936 of file bussupp.c.

937{
938#ifndef _MINIHAL_
939 PPCI_REGISTRY_INFO_INTERNAL PciRegistryInfo;
940 UCHAR PciType;
942 ULONG i, j, k;
943 UCHAR DataBuffer[PCI_COMMON_HDR_LENGTH];
944 PPCI_COMMON_CONFIG PciData = (PPCI_COMMON_CONFIG)DataBuffer;
945 PBUS_HANDLER BusHandler;
947 BOOLEAN ExtendedAddressDecoding = FALSE;
949
950 /* Query registry information */
951 PciRegistryInfo = HalpQueryPciRegistryInfo();
952 if (!PciRegistryInfo) return;
953
954 /* Initialize the PCI configuration lock */
956
957 /* Get the type and free the info structure */
958 PciType = PciRegistryInfo->HardwareMechanism & 0xF;
959
960 /* Check if this is a type 2 PCI bus with at least one bus */
961 if ((PciRegistryInfo->NoBuses) && (PciType == 2))
962 {
963 /* Setup the PCI slot */
964 PciSlot.u.bits.Reserved = 0;
965 PciSlot.u.bits.FunctionNumber = 0;
966
967 /* Loop all slots */
968 for (i = 0; i < PCI_MAX_DEVICES; i++)
969 {
970 /* Try to setup a Type 2 PCI slot */
971 PciType = 2;
972 BusHandler = HalpAllocateAndInitPciBusHandler(2, 0, TRUE);
973 if (!BusHandler) break;
974
975 /* Now check if it's valid */
976 if (HalpIsValidPCIDevice(BusHandler, PciSlot)) break;
977
978 /* Heh, the BIOS lied... try Type 1 */
979 PciType = 1;
980 BusHandler = HalpAllocateAndInitPciBusHandler(1, 0, TRUE);
981 if (!BusHandler) break;
982
983 /* Now check if it's valid */
984 if (HalpIsValidPCIDevice(BusHandler, PciSlot)) break;
985
986 /* Keep trying */
987 PciType = 2;
988 }
989
990 /* Now allocate the correct kind of handler */
992 }
993
994 /* Okay, now loop all PCI bridges */
995 do
996 {
997 /* Loop all PCI buses */
998 for (i = 0; i < PciRegistryInfo->NoBuses; i++)
999 {
1000 /* Check if we have a handler for it */
1001 if (!HalHandlerForBus(PCIBus, i))
1002 {
1003 /* Allocate it */
1005 }
1006 }
1007 /* Go to the next bridge */
1008 } while (HalpGetPciBridgeConfig(PciType, &PciRegistryInfo->NoBuses));
1009
1010 /* Now build correct address range informaiton */
1011 HalpFixupPciSupportedRanges(PciRegistryInfo->NoBuses);
1012
1013 /* Loop every bus */
1014 DbgPrint("\n====== PCI BUS HARDWARE DETECTION =======\n\n");
1015 PciSlot.u.bits.Reserved = 0;
1016 for (i = 0; i < PciRegistryInfo->NoBuses; i++)
1017 {
1018 /* Get the bus handler */
1019 BusHandler = HalHandlerForBus(PCIBus, i);
1020
1021 /* Loop every device */
1022 for (j = 0; j < PCI_MAX_DEVICES; j++)
1023 {
1024 /* Loop every function */
1025 PciSlot.u.bits.DeviceNumber = j;
1026 for (k = 0; k < PCI_MAX_FUNCTION; k++)
1027 {
1028 /* Build the final slot structure */
1029 PciSlot.u.bits.FunctionNumber = k;
1030
1031 /* Read the configuration information */
1032 HalpReadPCIConfig(BusHandler,
1033 PciSlot,
1034 PciData,
1035 0,
1037
1038 /* Skip if this is an invalid function */
1039 if (PciData->VendorID == PCI_INVALID_VENDORID) continue;
1040
1041 /* Print out the entry */
1042 HalpDebugPciDumpBus(BusHandler, PciSlot, i, j, k, PciData);
1043
1044 /* Check if this is a Cardbus bridge */
1046 {
1047 /* Not supported */
1048 DbgPrint("\tDevice is a PCI Cardbus Bridge. It will not work!\n");
1049 continue;
1050 }
1051
1052 /* Check if this is a PCI device */
1054 {
1055 /* Check if it has an interrupt pin and line registered */
1056 if ((PciData->u.type1.InterruptPin) &&
1057 (PciData->u.type1.InterruptLine))
1058 {
1059 /* Check if this interrupt line is connected to the bus */
1060 if (PciData->u.type1.InterruptLine < 16)
1061 {
1062 /* Is this an IDE device? */
1063 if (!HalpIsIdeDevice(PciData))
1064 {
1065 /* We'll mask out this interrupt then */
1066 DbgPrint("\tDevice is using IRQ %d! ISA Cards using that IRQ may fail!\n",
1067 PciData->u.type1.InterruptLine);
1068 HalpPciIrqMask |= (1 << PciData->u.type1.InterruptLine);
1069 }
1070 }
1071 }
1072 }
1073
1074 /* Check for broken Intel chips */
1075 if (PciData->VendorID == 0x8086)
1076 {
1077 /* Check for broken 82830 PCI controller */
1078 if ((PciData->DeviceID == 0x04A3) &&
1079 (PciData->RevisionID < 0x11))
1080 {
1081 /* Skip */
1082 DbgPrint("\tDevice is a broken Intel 82430 PCI Controller. It will not work!\n\n");
1083 continue;
1084 }
1085
1086 /* Check for broken 82378 PCI-to-ISA Bridge */
1087 if ((PciData->DeviceID == 0x0484) &&
1088 (PciData->RevisionID <= 3))
1089 {
1090 /* Skip */
1091 DbgPrint("\tDevice is a broken Intel 82378 PCI-to-ISA Bridge. It will not work!\n\n");
1092 continue;
1093 }
1094
1095 /* Check for broken 82450 PCI Bridge */
1096 if ((PciData->DeviceID == 0x84C4) &&
1097 (PciData->RevisionID <= 4))
1098 {
1099 DbgPrint("\tDevice is a Intel Orion 82450 PCI Bridge. It will not work!\n\n");
1100 continue;
1101 }
1102 }
1103
1104 /* Do we know this card? */
1105 if (!ExtendedAddressDecoding)
1106 {
1107 /* Check for it */
1108 if (HalpIsRecognizedCard(PciRegistryInfo,
1109 PciData,
1111 {
1112 /* We'll do chipset checks later */
1113 DbgPrint("\tDevice has Extended Address Decoding. It may fail to work on older BIOSes!\n");
1114 ExtendedAddressDecoding = TRUE;
1115 }
1116 }
1117
1118 /* Now check the registry for chipset hacks */
1119 Status = HalpGetChipHacks(PciData->VendorID,
1120 PciData->DeviceID,
1121 PciData->RevisionID,
1122 &HackFlags);
1123 if (NT_SUCCESS(Status))
1124 {
1125 /* Check for broken ACPI routing */
1127 {
1128 DbgPrint("This chipset has broken ACPI IRQ Routing! Be aware!\n\n");
1129 continue;
1130 }
1131
1132 /* Check for broken ACPI timer */
1134 {
1135 DbgPrint("This chipset has a broken ACPI timer! Be aware!\n\n");
1136 continue;
1137 }
1138
1139 /* Check for hibernate-disable */
1141 {
1142 DbgPrint("This chipset has a broken PCI device which is incompatible with hibernation. Be aware!\n\n");
1143 continue;
1144 }
1145
1146 /* Check for USB controllers that generate SMIs */
1148 {
1149 DbgPrint("This chipset has a USB controller which generates SMIs. ReactOS will likely fail to boot!\n\n");
1150 continue;
1151 }
1152 }
1153
1154 /* Terminate the entry */
1155 DbgPrint("\n");
1156 }
1157 }
1158 }
1159
1160 /* Initialize NMI Crash Flag */
1162
1163 /* Free the registry data */
1164 ExFreePoolWithTag(PciRegistryInfo, TAG_HAL);
1165
1166 /* Tell PnP if this hard supports correct decoding */
1167 HalpMarkChipsetDecode(ExtendedAddressDecoding);
1168 DbgPrint("====== PCI BUS DETECTION COMPLETE =======\n\n");
1169#endif // !_MINIHAL_
1170}
PPCI_REGISTRY_INFO_INTERNAL NTAPI HalpQueryPciRegistryInfo(VOID)
Definition: pcibus.c:978
static BOOLEAN NTAPI HalpIsValidPCIDevice(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot)
Definition: bussupp.c:282
static PBUS_HANDLER NTAPI HalpAllocateAndInitPciBusHandler(IN ULONG PciType, IN ULONG BusNo, IN BOOLEAN TestAllocation)
Definition: bussupp.c:197
static VOID NTAPI HalpFixupPciSupportedRanges(IN ULONG BusCount)
Definition: bussupp.c:610
static NTSTATUS NTAPI HalpGetChipHacks(IN USHORT VendorId, IN USHORT DeviceId, IN UCHAR RevisionId, IN PULONG HackFlags)
Definition: bussupp.c:342
KSPIN_LOCK HalpPCIConfigLock
Definition: pcibus.c:22
ULONG HalpPciIrqMask
Definition: bussupp.c:19
static BOOLEAN NTAPI HalpIsRecognizedCard(IN PPCI_REGISTRY_INFO_INTERNAL PciRegistryInfo, IN PPCI_COMMON_CONFIG PciData, IN ULONG Flags)
Definition: bussupp.c:406
VOID NTAPI HalpDebugPciDumpBus(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER PciSlot, IN ULONG i, IN ULONG j, IN ULONG k, IN PPCI_COMMON_CONFIG PciData)
Definition: bussupp.c:707
static NTSTATUS NTAPI HalpMarkChipsetDecode(IN BOOLEAN OverrideEnable)
Definition: bussupp.c:149
static BOOLEAN NTAPI HalpGetPciBridgeConfig(IN ULONG PciType, IN PUCHAR BusCount)
Definition: bussupp.c:556
static BOOLEAN NTAPI HalpIsIdeDevice(IN PPCI_COMMON_CONFIG PciData)
Definition: bussupp.c:487
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
VOID NTAPI HalpGetNMICrashFlag(VOID)
Definition: usage.c:605
#define HALP_CARD_FEATURE_FULL_DECODE
Definition: halp.h:174
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define HAL_PCI_CHIP_HACK_BROKEN_ACPI_TIMER
Definition: haltypes.h:2020
#define HAL_PCI_CHIP_HACK_DISABLE_ACPI_IRQ_ROUTING
Definition: haltypes.h:2022
#define HAL_PCI_CHIP_HACK_USB_SMI_DISABLE
Definition: haltypes.h:2023
#define HAL_PCI_CHIP_HACK_DISABLE_HIBERNATE
Definition: haltypes.h:2021

◆ HalpIsBridgeDevice()

static BOOLEAN NTAPI HalpIsBridgeDevice ( IN PPCI_COMMON_CONFIG  PciData)
static

Definition at line 540 of file bussupp.c.

541{
542 /* Either this is a PCI-to-PCI Bridge, or a CardBUS Bridge */
543 return (((PCI_CONFIGURATION_TYPE(PciData) == PCI_BRIDGE_TYPE) &&
544 (PciData->BaseClass == PCI_CLASS_BRIDGE_DEV) &&
545 (PciData->SubClass == PCI_SUBCLASS_BR_PCI_TO_PCI)) ||
547 (PciData->BaseClass == PCI_CLASS_BRIDGE_DEV) &&
548 (PciData->SubClass == PCI_SUBCLASS_BR_CARDBUS)));
549}
#define PCI_SUBCLASS_BR_PCI_TO_PCI
Definition: iotypes.h:4168
#define PCI_CLASS_BRIDGE_DEV
Definition: iotypes.h:4111
#define PCI_SUBCLASS_BR_CARDBUS
Definition: iotypes.h:4171

Referenced by HalpGetPciBridgeConfig().

◆ HalpIsIdeDevice()

static BOOLEAN NTAPI HalpIsIdeDevice ( IN PPCI_COMMON_CONFIG  PciData)
static

Definition at line 487 of file bussupp.c.

488{
489 /* Simple test first */
490 if ((PciData->BaseClass == PCI_CLASS_MASS_STORAGE_CTLR) &&
491 (PciData->SubClass == PCI_SUBCLASS_MSC_IDE_CTLR))
492 {
493 /* The device is nice enough to admit it */
494 return TRUE;
495 }
496
497 /* Symphony 82C101 */
498 if (PciData->VendorID == 0x1C1C) return TRUE;
499
500 /* ALi MS4803 or M5219 */
501 if ((PciData->VendorID == 0x10B9) &&
502 ((PciData->DeviceID == 0x5215) || (PciData->DeviceID == 0x5219)))
503 {
504 return TRUE;
505 }
506
507 /* Appian Technology */
508 if ((PciData->VendorID == 0x1097) && (PciData->DeviceID == 0x38)) return TRUE;
509
510 /* Compaq Triflex Dual EIDE Controller */
511 if ((PciData->VendorID == 0xE11) && (PciData->DeviceID == 0xAE33)) return TRUE;
512
513 /* Micron PC Tech RZ1000 */
514 if ((PciData->VendorID == 0x1042) && (PciData->DeviceID == 0x1000)) return TRUE;
515
516 /* SiS 85C601 or 5513 [IDE] */
517 if ((PciData->VendorID == 0x1039) &&
518 ((PciData->DeviceID == 0x601) || (PciData->DeviceID == 0x5513)))
519 {
520 return TRUE;
521 }
522
523 /* Symphony Labs W83769F */
524 if ((PciData->VendorID == 0x10AD) &&
525 ((PciData->DeviceID == 0x1) || (PciData->DeviceID == 0x150)))
526 {
527 return TRUE;
528 }
529
530 /* UMC UM8673F */
531 if ((PciData->VendorID == 0x1060) && (PciData->DeviceID == 0x101)) return TRUE;
532
533 /* You've survived */
534 return FALSE;
535}
#define PCI_CLASS_MASS_STORAGE_CTLR
Definition: iotypes.h:4106
#define PCI_SUBCLASS_MSC_IDE_CTLR
Definition: iotypes.h:4131

Referenced by HalpInitializePciBus().

◆ HalpIsRecognizedCard()

static BOOLEAN NTAPI HalpIsRecognizedCard ( IN PPCI_REGISTRY_INFO_INTERNAL  PciRegistryInfo,
IN PPCI_COMMON_CONFIG  PciData,
IN ULONG  Flags 
)
static

Definition at line 406 of file bussupp.c.

409{
410 ULONG ElementCount, i;
411 PPCI_CARD_DESCRIPTOR CardDescriptor;
412
413 /* How many PCI Cards that we know about? */
414 ElementCount = PciRegistryInfo->ElementCount;
415 if (!ElementCount) return FALSE;
416
417 /* Loop all descriptors */
418 CardDescriptor = &PciRegistryInfo->CardList[0];
419 for (i = 0; i < ElementCount; i++, CardDescriptor++)
420 {
421 /* Check for flag match */
422 if (CardDescriptor->Flags != Flags) continue;
423
424 /* Check for VID-PID match */
425 if ((CardDescriptor->VendorID != PciData->VendorID) ||
426 (CardDescriptor->DeviceID != PciData->DeviceID))
427 {
428 /* Skip */
429 continue;
430 }
431
432 /* Check for revision match, if requested */
433 if ((CardDescriptor->Flags & HALP_CHECK_CARD_REVISION_ID) &&
434 (CardDescriptor->RevisionID != PciData->RevisionID))
435 {
436 /* Skip */
437 continue;
438 }
439
440 /* Check what kind of device this is */
441 switch (PCI_CONFIGURATION_TYPE(PciData))
442 {
443 /* CardBUS Bridge */
445
446 /* This means the real device header is in the device-specific data */
447 PciData = (PPCI_COMMON_CONFIG)PciData->DeviceSpecific;
448
449 /* Normal PCI device */
450 case PCI_DEVICE_TYPE:
451
452 /* Check for subvendor match, if requested */
453 if ((CardDescriptor->Flags & HALP_CHECK_CARD_SUBVENDOR_ID) &&
454 (CardDescriptor->SubsystemVendorID != PciData->u.type0.SubVendorID))
455 {
456 /* Skip */
457 continue;
458 }
459
460 /* Check for subsystem match, if requested */
461 if ((CardDescriptor->Flags & HALP_CHECK_CARD_SUBSYSTEM_ID) &&
462 (CardDescriptor->SubsystemID != PciData->u.type0.SubSystemID))
463 {
464 /* Skip */
465 continue;
466 }
467
468 /* You made it! */
469 return TRUE;
470
471 /* PCI Bridge -- don't bother */
472 case PCI_BRIDGE_TYPE:
473 default:
474
475 /* Recognize it */
476 return TRUE;
477 }
478 }
479
480 /* This means the card isn't recognized */
481 return FALSE;
482}
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ ULONG _In_ ULONG Flags
Definition: dispmprt.h:245
#define HALP_CHECK_CARD_REVISION_ID
Definition: halp.h:179
#define HALP_CHECK_CARD_SUBVENDOR_ID
Definition: halp.h:180
#define HALP_CHECK_CARD_SUBSYSTEM_ID
Definition: halp.h:181
if(dx< 0)
Definition: linetemp.h:194
USHORT VendorID
Definition: pci.h:120
USHORT SubsystemID
Definition: pci.h:124
USHORT DeviceID
Definition: pci.h:121
USHORT SubsystemVendorID
Definition: pci.h:123
USHORT RevisionID
Definition: pci.h:122

Referenced by HalpInitializePciBus().

◆ HalpIsValidPCIDevice()

static BOOLEAN NTAPI HalpIsValidPCIDevice ( IN PBUS_HANDLER  BusHandler,
IN PCI_SLOT_NUMBER  Slot 
)
static

Definition at line 282 of file bussupp.c.

284{
285 UCHAR DataBuffer[PCI_COMMON_HDR_LENGTH];
286 PPCI_COMMON_CONFIG PciHeader = (PVOID)DataBuffer;
287 ULONG i;
289
290 /* Read the PCI header */
291 HalpReadPCIConfig(BusHandler, Slot, PciHeader, 0, PCI_COMMON_HDR_LENGTH);
292
293 /* Make sure it's a valid device */
294 if ((PciHeader->VendorID == PCI_INVALID_VENDORID) ||
296 {
297 /* Bail out */
298 return FALSE;
299 }
300
301 /* Make sure interrupt numbers make sense */
302 if (((PciHeader->u.type0.InterruptPin) &&
303 (PciHeader->u.type0.InterruptPin > 4)) ||
304 (PciHeader->u.type0.InterruptLine & 0x70))
305 {
306 /* Bail out */
307 return FALSE;
308 }
309
310 /* Now scan PCI BARs */
311 for (i = 0; i < PCI_TYPE0_ADDRESSES; i++)
312 {
313 /* Check what kind of address it is */
314 Address = PciHeader->u.type0.BaseAddresses[i];
316 {
317 /* Highest I/O port is 65535 */
318 if (Address > 0xFFFF) return FALSE;
319 }
320 else
321 {
322 /* MMIO should be higher than 0x80000 */
323 if ((Address > 0xF) && (Address < 0x80000)) return FALSE;
324 }
325
326 /* Is this a 64-bit address? */
327 if (!(Address & PCI_ADDRESS_IO_SPACE) &&
329 {
330 /* Check the next-next entry, since this one 64-bits wide */
331 i++;
332 }
333 }
334
335 /* Header, interrupt and address data all make sense */
336 return TRUE;
337}
static WCHAR Address[46]
Definition: ping.c:68
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define PCI_TYPE_64BIT
Definition: iotypes.h:4242

Referenced by HalpInitializePciBus().

◆ HalpMarkChipsetDecode()

static NTSTATUS NTAPI HalpMarkChipsetDecode ( IN BOOLEAN  OverrideEnable)
static

Definition at line 149 of file bussupp.c.

150{
152 UNICODE_STRING KeyString;
153 ULONG Data = OverrideEnable;
155
156 /* Open CCS key */
157 RtlInitUnicodeString(&KeyString,
158 L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET");
160 if (NT_SUCCESS(Status))
161 {
162 /* Open PNP Bios key */
163 RtlInitUnicodeString(&KeyString, L"Control\\Biosinfo\\PNPBios");
165 Handle,
166 &KeyString,
168 TRUE);
169
170 /* Close root key */
172
173 /* Check if PNP BIOS key exists */
174 if (NT_SUCCESS(Status))
175 {
176 /* Set the override value */
177 RtlInitUnicodeString(&KeyString, L"FullDecodeChipsetOverride");
178 Status = ZwSetValueKey(KeyHandle,
179 &KeyString,
180 0,
181 REG_DWORD,
182 &Data,
183 sizeof(Data));
184
185 /* Close subkey */
187 }
188 }
189
190 /* Return status */
191 return Status;
192}
ULONG Handle
Definition: gdb_input.c:15
NTSTATUS NTAPI HalpOpenRegistryKey(IN PHANDLE KeyHandle, IN HANDLE RootKey, IN PUNICODE_STRING KeyName, IN ACCESS_MASK DesiredAccess, IN BOOLEAN Create)
Definition: misc.c:104
#define KEY_ALL_ACCESS
Definition: nt_native.h:1044
#define REG_DWORD
Definition: sdbapi.c:615

Referenced by HalpInitializePciBus().

◆ HalpRegisterInternalBusHandlers()

static VOID NTAPI HalpRegisterInternalBusHandlers ( VOID  )
static

Definition at line 75 of file bussupp.c.

76{
77 PBUS_HANDLER Bus;
78
79 /* Only do processor 1 */
80 if (KeGetCurrentPrcb()->Number) return;
81
82 /* Register root support */
84
85 /* Allocate the system bus */
88 0,
90 0,
91 0);
92 if (Bus)
93 {
94 /* Set it up */
97 }
98
99 /* Allocate the CMOS bus */
101 Cmos,
102 0,
104 0,
105 0);
106 if (Bus)
107 {
108 /* Set it up */
111 }
112
113 /* Allocate the CMOS bus */
115 Cmos,
116 1,
118 0,
119 0);
120 if (Bus)
121 {
122 /* Set it up */
125 }
126
127 /* Allocate ISA bus */
130 0,
131 Internal,
132 0,
133 0);
134 if (Bus)
135 {
136 /* Set it up */
138 Bus->BusAddresses->Memory.Limit = 0xFFFFFF;
140 }
141
142 /* No support for EISA or MCA */
144}
ULONG NTAPI HalpcGetCmosData(_In_ PBUS_HANDLER BusHandler, _In_ PBUS_HANDLER RootHandler, _In_ ULONG SlotNumber, _Out_writes_bytes_(Length) PVOID Buffer, _In_ ULONG Offset, _In_ ULONG Length)
Definition: cmosbus.c:16
BOOLEAN NTAPI HalpTranslateIsaBusAddress(IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
Definition: isabus.c:21
ULONG NTAPI HalpcSetCmosData(_In_ PBUS_HANDLER BusHandler, _In_ PBUS_HANDLER RootHandler, _In_ ULONG SlotNumber, _In_reads_bytes_(Length) PVOID Buffer, _In_ ULONG Offset, _In_ ULONG Length)
Definition: cmosbus.c:38
VOID NTAPI HalpInitBusHandler(VOID)
Definition: bushndlr.c:444
ULONG NTAPI HalpNoBusData(_In_ PBUS_HANDLER BusHandler, _In_ PBUS_HANDLER RootHandler, _In_ ULONG SlotNumber, _In_ PVOID Buffer, _In_ ULONG Offset, _In_ ULONG Length)
Handler for buses without configuration space.
Definition: bushndlr.c:111
BOOLEAN NTAPI HalpTranslateSystemBusAddress(IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
Definition: sysbus.c:21
ULONG NTAPI HalpGetSystemInterruptVector(IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN ULONG BusInterruptLevel, IN ULONG BusInterruptVector, OUT PKIRQL Irql, OUT PKAFFINITY Affinity)
Definition: sysbus.c:115
ULONG HalpBusType
Definition: pcibus.c:18
#define ASSERT(a)
Definition: mode.c:44
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1197
#define MACHINE_TYPE_ISA
Definition: ketypes.h:107
_In_ ULONG Number
Definition: haltypes.h:1872
@ Isa
Definition: restypes.h:123
@ Cmos
Definition: miniport.h:89
@ ConfigurationSpaceUndefined
Definition: miniport.h:88
PTRANSLATEBUSADDRESS TranslateBusAddress
Definition: haltypes.h:2006

Referenced by HalpInitBusHandlers().

◆ HalpRegisterKdSupportFunctions()

VOID NTAPI HalpRegisterKdSupportFunctions ( VOID  )

Definition at line 1185 of file bussupp.c.

1186{
1187 /* Register PCI Device Functions */
1190
1191 /* Register memory functions */
1192#if (NTDDI_VERSION >= NTDDI_VISTA)
1195#else
1198#endif
1199
1200 /* Register ACPI stub */
1202}
PVOID NTAPI HalpMapPhysicalMemory64Vista(IN PHYSICAL_ADDRESS PhysicalAddress, IN PFN_COUNT PageCount, IN BOOLEAN FlushCurrentTLB)
Definition: memory.c:156
VOID NTAPI HalpUnmapVirtualAddress(IN PVOID VirtualAddress, IN PFN_COUNT PageCount)
Definition: memory.c:148
VOID NTAPI HalpUnmapVirtualAddressVista(IN PVOID VirtualAddress, IN PFN_COUNT PageCount, IN BOOLEAN FlushCurrentTLB)
Definition: memory.c:227
PVOID NTAPI HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress, IN PFN_COUNT PageCount)
Definition: memory.c:140
VOID NTAPI HalpCheckPowerButton(VOID)
Definition: misc.c:146
NTSTATUS NTAPI HalpReleasePciDeviceForDebugging(_Inout_ PDEBUG_DEVICE_DESCRIPTOR PciDevice)
Releases the PCI device MMIO mappings previously allocated with HalpSetupPciDeviceForDebugging().
Definition: kdpci.c:421
NTSTATUS NTAPI HalpSetupPciDeviceForDebugging(_In_opt_ PVOID LoaderBlock, _Inout_ PDEBUG_DEVICE_DESCRIPTOR PciDevice)
Finds and fully initializes the PCI device associated with the supplied debug device descriptor.
Definition: kdpci.c:483
#define KdUnmapVirtualAddress
Definition: halfuncs.h:56
#define KdMapPhysicalMemory64
Definition: halfuncs.h:55
#define KdSetupPciDeviceForDebugging
Definition: halfuncs.h:50
#define KdReleasePciDeviceforDebugging
Definition: halfuncs.h:51
#define KdCheckPowerButton
Definition: halfuncs.h:53

◆ HalSetBusData()

ULONG NTAPI HalSetBusData ( IN BUS_DATA_TYPE  BusDataType,
IN ULONG  BusNumber,
IN ULONG  SlotNumber,
IN PVOID  Buffer,
IN ULONG  Length 
)

Definition at line 1532 of file bussupp.c.

1537{
1538 /* Call the extended function */
1539 return HalSetBusDataByOffset(BusDataType,
1540 BusNumber,
1541 SlotNumber,
1542 Buffer,
1543 0,
1544 Length);
1545}
ULONG NTAPI HalSetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: bussupp.c:1552

◆ HalSetBusDataByOffset()

ULONG NTAPI HalSetBusDataByOffset ( IN BUS_DATA_TYPE  BusDataType,
IN ULONG  BusNumber,
IN ULONG  SlotNumber,
IN PVOID  Buffer,
IN ULONG  Offset,
IN ULONG  Length 
)

Definition at line 1552 of file bussupp.c.

1558{
1560 ULONG Status;
1561
1562 /* Find the handler */
1564 if (!Handler) return 0;
1565
1566 /* Do the assignment */
1567 Status = Handler->SetBusData(Handler,
1568 Handler,
1569 SlotNumber,
1570 Buffer,
1571 Offset,
1572 Length);
1573
1574 /* Dereference the handler and return */
1576 return Status;
1577}

Referenced by HalSetBusData().

◆ HalTranslateBusAddress()

BOOLEAN NTAPI HalTranslateBusAddress ( IN INTERFACE_TYPE  InterfaceType,
IN ULONG  BusNumber,
IN PHYSICAL_ADDRESS  BusAddress,
IN OUT PULONG  AddressSpace,
OUT PPHYSICAL_ADDRESS  TranslatedAddress 
)

Definition at line 1585 of file bussupp.c.

1590{
1591 /* Look as the bus type */
1592 if (InterfaceType == PCIBus)
1593 {
1594 /* Call the PCI registered function */
1596 BusNumber,
1597 BusAddress,
1600 }
1601 else
1602 {
1603 /* Call the bus handler */
1605 BusNumber,
1606 BusAddress,
1609 }
1610}
BOOLEAN NTAPI HaliTranslateBusAddress(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
Definition: bussupp.c:1324
#define HalPciTranslateBusAddress
Definition: halfuncs.h:41

Referenced by HaliFindBusAddressTranslation().

◆ ShowSize()

static VOID ShowSize ( IN ULONG  x)
static

Definition at line 674 of file bussupp.c.

675{
676 if (!x) return;
677 DbgPrint(" [size=");
678 if (x < 1024)
679 {
680 DbgPrint("%d", (int) x);
681 }
682 else if (x < 1048576)
683 {
684 DbgPrint("%dK", (int)(x / 1024));
685 }
686 else if (x < 0x80000000)
687 {
688 DbgPrint("%dM", (int)(x / 1048576));
689 }
690 else
691 {
692 DbgPrint("%d", x);
693 }
694 DbgPrint("]");
695}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548

Referenced by HalpDebugPciDumpBus().

Variable Documentation

◆ HalpPCIConfigLock

◆ HalpPciIrqMask

ULONG HalpPciIrqMask

Definition at line 19 of file bussupp.c.

Referenced by HalpInitializePciBus().

◆ WarningsGiven

BOOLEAN WarningsGiven[5]
static