ReactOS 0.4.17-dev-1183-g3b30a2a
bus.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _PCIPBUSDATA
 
struct  _PCI_CONFIG_HANDLER
 
struct  _PCI_REGISTRY_INFO_INTERNAL
 
struct  _PCI_TYPE1_CFG_BITS
 
struct  _PCI_TYPE2_CSE_BITS
 
struct  _PCI_TYPE2_ADDRESS_BITS
 
struct  _PCI_TYPE0_CFG_CYCLE_BITS
 
union  _PCI_TYPE1_CFG_CYCLE_BITS
 
struct  _ARRAY
 
struct  _HAL_BUS_HANDLER
 

Macros

#define PCI_ADDRESS_MEMORY_SPACE   0x00000000
 
#define PASTE2(x, y)   x ## y
 
#define POINTER_TO_(x)   PASTE2(P,x)
 
#define READ_FROM(x)   PASTE2(READ_PORT_, x)
 
#define WRITE_TO(x)   PASTE2(WRITE_PORT_, x)
 
#define TYPE_DEFINE(x, y)
 
#define TYPE1_DEFINE(x)   TYPE_DEFINE(x, PPCI_TYPE1_CFG_BITS);
 
#define TYPE2_DEFINE(x)   TYPE_DEFINE(x, PPCI_TYPE2_ADDRESS_BITS);
 
#define TYPE1_START(x, y)
 
#define TYPE1_END(y)    return sizeof(y); }
 
#define TYPE2_END   TYPE1_END
 
#define TYPE1_READ(x, y)
 
#define TYPE1_WRITE(x, y)
 
#define TYPE2_START(x, y)
 
#define TYPE2_READ(x, y)
 
#define TYPE2_WRITE(x, y)
 
#define PCI_TYPE1_ADDRESS_PORT   (PULONG)0xCF8
 
#define PCI_TYPE1_DATA_PORT   0xCFC
 
#define PCI_TYPE2_CSE_PORT   (PUCHAR)0xCF8
 
#define PCI_TYPE2_FORWARD_PORT   (PUCHAR)0xCFA
 
#define PCI_TYPE2_ADDRESS_BASE   0xC
 

Typedefs

typedef NTSTATUS(NTAPI * PciIrqRange) (IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN PCI_SLOT_NUMBER PciSlot, OUT PSUPPORTED_RANGE *Interrupt)
 
typedef struct _PCIPBUSDATA PCIPBUSDATA
 
typedef struct _PCIPBUSDATA * PPCIPBUSDATA
 
typedef ULONG(NTAPI * FncConfigIO) (IN PPCIPBUSDATA BusData, IN PVOID State, IN PUCHAR Buffer, IN ULONG Offset)
 
typedef VOID(NTAPI * FncSync) (IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PKIRQL Irql, IN PVOID State)
 
typedef VOID(NTAPI * FncReleaseSync) (IN PBUS_HANDLER BusHandler, IN KIRQL Irql)
 
typedef struct _PCI_CONFIG_HANDLER PCI_CONFIG_HANDLER
 
typedef struct _PCI_CONFIG_HANDLER * PPCI_CONFIG_HANDLER
 
typedef struct _PCI_REGISTRY_INFO_INTERNAL PCI_REGISTRY_INFO_INTERNAL
 
typedef struct _PCI_REGISTRY_INFO_INTERNAL * PPCI_REGISTRY_INFO_INTERNAL
 
typedef struct _PCI_TYPE1_CFG_BITS PCI_TYPE1_CFG_BITS
 
typedef struct _PCI_TYPE1_CFG_BITS * PPCI_TYPE1_CFG_BITS
 
typedef struct _PCI_TYPE2_CSE_BITS PCI_TYPE2_CSE_BITS
 
typedef struct _PCI_TYPE2_CSE_BITS PPCI_TYPE2_CSE_BITS
 
typedef struct _PCI_TYPE2_ADDRESS_BITS PCI_TYPE2_ADDRESS_BITS
 
typedef struct _PCI_TYPE2_ADDRESS_BITS * PPCI_TYPE2_ADDRESS_BITS
 
typedef struct _PCI_TYPE0_CFG_CYCLE_BITS PCI_TYPE0_CFG_CYCLE_BITS
 
typedef struct _PCI_TYPE0_CFG_CYCLE_BITS * PPCI_TYPE0_CFG_CYCLE_BITS
 
typedef union _PCI_TYPE1_CFG_CYCLE_BITS PCI_TYPE1_CFG_CYCLE_BITS
 
typedef union _PCI_TYPE1_CFG_CYCLE_BITS * PPCI_TYPE1_CFG_CYCLE_BITS
 
typedef struct _ARRAY ARRAY
 
typedef struct _ARRAY * PARRAY
 
typedef struct _HAL_BUS_HANDLER HAL_BUS_HANDLER
 
typedef struct _HAL_BUS_HANDLER * PHAL_BUS_HANDLER
 

Functions

PPCI_REGISTRY_INFO_INTERNAL NTAPI HalpQueryPciRegistryInfo (VOID)
 
VOID NTAPI HalpPCISynchronizeType1 (IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PKIRQL Irql, IN PPCI_TYPE1_CFG_BITS PciCfg)
 
VOID NTAPI HalpPCIReleaseSynchronzationType1 (IN PBUS_HANDLER BusHandler, IN KIRQL Irql)
 
VOID NTAPI HalpPCISynchronizeType2 (IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PKIRQL Irql, IN PPCI_TYPE2_ADDRESS_BITS PciCfg)
 
VOID NTAPI HalpPCIReleaseSynchronizationType2 (IN PBUS_HANDLER BusHandler, IN KIRQL Irql)
 
 TYPE1_DEFINE (HalpPCIReadUcharType1)
 
 TYPE1_DEFINE (HalpPCIReadUshortType1)
 
 TYPE1_DEFINE (HalpPCIReadUlongType1)
 
 TYPE2_DEFINE (HalpPCIReadUcharType2)
 
 TYPE2_DEFINE (HalpPCIReadUshortType2)
 
 TYPE2_DEFINE (HalpPCIReadUlongType2)
 
 TYPE1_DEFINE (HalpPCIWriteUcharType1)
 
 TYPE1_DEFINE (HalpPCIWriteUshortType1)
 
 TYPE1_DEFINE (HalpPCIWriteUlongType1)
 
 TYPE2_DEFINE (HalpPCIWriteUcharType2)
 
 TYPE2_DEFINE (HalpPCIWriteUshortType2)
 
 TYPE2_DEFINE (HalpPCIWriteUlongType2)
 
BOOLEAN NTAPI HalpValidPCISlot (IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot)
 
VOID NTAPI HalpReadPCIConfig (IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
 
VOID NTAPI HalpWritePCIConfig (IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
 
ULONG NTAPI HaliPciInterfaceReadConfig (_In_ PBUS_HANDLER RootBusHandler, _In_ ULONG BusNumber, _In_ PCI_SLOT_NUMBER SlotNumber, _Out_writes_bytes_(Length) PVOID Buffer, _In_ ULONG Offset, _In_ ULONG Length)
 
ULONG NTAPI HaliPciInterfaceWriteConfig (_In_ PBUS_HANDLER RootBusHandler, _In_ ULONG BusNumber, _In_ PCI_SLOT_NUMBER SlotNumber, _In_reads_bytes_(Length) PVOID Buffer, _In_ ULONG Offset, _In_ ULONG Length)
 
ULONG NTAPI HalpGetPCIData (IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootBusHandler, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
 
ULONG NTAPI HalpSetPCIData (IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootBusHandler, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
 
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)
 
ULONG HalpPhase0GetPciDataByOffset (_In_ ULONG Bus, _In_ PCI_SLOT_NUMBER PciSlot, _Out_writes_bytes_all_(Length) PVOID Buffer, _In_ ULONG Offset, _In_ ULONG Length)
 
ULONG HalpPhase0SetPciDataByOffset (_In_ ULONG Bus, _In_ PCI_SLOT_NUMBER PciSlot, _In_reads_bytes_(Length) PVOID Buffer, _In_ ULONG Offset, _In_ ULONG Length)
 
ULONG NTAPI HalpGetRootInterruptVector (_In_ ULONG BusInterruptLevel, _In_ ULONG BusInterruptVector, _Out_ PKIRQL Irql, _Out_ PKAFFINITY Affinity)
 
ULONG NTAPI HalpGetCmosData (_In_ ULONG BusNumber, _In_ ULONG SlotNumber, _Out_writes_bytes_(Length) PVOID Buffer, _In_ ULONG Length)
 
ULONG NTAPI HalpSetCmosData (_In_ ULONG BusNumber, _In_ ULONG SlotNumber, _In_reads_bytes_(Length) PVOID Buffer, _In_ ULONG Length)
 
VOID NTAPI HalpInitializePciBus (VOID)
 
VOID NTAPI HalpInitializePciStubs (VOID)
 
BOOLEAN NTAPI HalpTranslateBusAddress (IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
 
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 HalpFindBusAddressTranslation (IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress, IN OUT PULONG_PTR Context, IN BOOLEAN NextBus)
 
VOID NTAPI HalpRegisterPciDebuggingDeviceInfo (VOID)
 
BOOLEAN NTAPI HaliTranslateBusAddress (IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
 
BOOLEAN NTAPI HaliFindBusAddressTranslation (IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress, IN OUT PULONG_PTR Context, IN BOOLEAN NextBus)
 
NTSTATUS NTAPI HalpAdjustPCIResourceList (IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *pResourceList)
 
ULONG NTAPI HalpGetPCIIntOnISABus (IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN ULONG BusInterruptLevel, IN ULONG BusInterruptVector, OUT PKIRQL Irql, OUT PKAFFINITY Affinity)
 
VOID NTAPI HalpPCIPin2ISALine (IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN PCI_SLOT_NUMBER SlotNumber, IN PPCI_COMMON_CONFIG PciData)
 
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)
 
NTSTATUS NTAPI HalpGetISAFixedPCIIrq (IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN PCI_SLOT_NUMBER PciSlot, OUT PSUPPORTED_RANGE *Range)
 
VOID NTAPI HalpInitBusHandler (VOID)
 
PBUS_HANDLER NTAPI HalpContextToBusHandler (IN ULONG_PTR ContextValue)
 
PBUS_HANDLER FASTCALL HaliReferenceHandlerForConfigSpace (IN BUS_DATA_TYPE ConfigType, IN ULONG BusNumber)
 
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.
 
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)
 
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)
 
BOOLEAN NTAPI HalpTranslateSystemBusAddress (IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
 
BOOLEAN NTAPI HalpTranslateIsaBusAddress (IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
 
ULONG NTAPI HalpGetSystemInterruptVector (IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN ULONG BusInterruptLevel, IN ULONG BusInterruptVector, OUT PKIRQL Irql, OUT PKAFFINITY Affinity)
 

Variables

PCI_CONFIG_HANDLER PCIConfigHandler
 
const PCI_CONFIG_HANDLER PCIConfigHandlerType1
 
const PCI_CONFIG_HANDLER PCIConfigHandlerType2
 
const BUS_HANDLER HalpFakePciBusHandler
 
ULONG HalpBusType
 
BOOLEAN HalpPCIConfigInitialized
 
ULONG HalpMinPciBus
 
ULONG HalpMaxPciBus
 
LIST_ENTRY HalpAllBusHandlers
 

Macro Definition Documentation

◆ PASTE2

#define PASTE2 (   x,
  y 
)    x ## y

Definition at line 8 of file bus.h.

◆ PCI_ADDRESS_MEMORY_SPACE

#define PCI_ADDRESS_MEMORY_SPACE   0x00000000

Definition at line 3 of file bus.h.

◆ PCI_TYPE1_ADDRESS_PORT

#define PCI_TYPE1_ADDRESS_PORT   (PULONG)0xCF8

Definition at line 164 of file bus.h.

◆ PCI_TYPE1_DATA_PORT

#define PCI_TYPE1_DATA_PORT   0xCFC

Definition at line 165 of file bus.h.

◆ PCI_TYPE2_ADDRESS_BASE

#define PCI_TYPE2_ADDRESS_BASE   0xC

Definition at line 172 of file bus.h.

◆ PCI_TYPE2_CSE_PORT

#define PCI_TYPE2_CSE_PORT   (PUCHAR)0xCF8

Definition at line 170 of file bus.h.

◆ PCI_TYPE2_FORWARD_PORT

#define PCI_TYPE2_FORWARD_PORT   (PUCHAR)0xCFA

Definition at line 171 of file bus.h.

◆ POINTER_TO_

#define POINTER_TO_ (   x)    PASTE2(P,x)

Definition at line 9 of file bus.h.

◆ READ_FROM

#define READ_FROM (   x)    PASTE2(READ_PORT_, x)

Definition at line 10 of file bus.h.

◆ TYPE1_DEFINE

#define TYPE1_DEFINE (   x)    TYPE_DEFINE(x, PPCI_TYPE1_CFG_BITS);

Definition at line 25 of file bus.h.

◆ TYPE1_END

#define TYPE1_END (   y)     return sizeof(y); }

Definition at line 37 of file bus.h.

◆ TYPE1_READ

#define TYPE1_READ (   x,
  y 
)
Value:
*((POINTER_TO_(y))Buffer) = \
READ_FROM(y)((POINTER_TO_(y))(ULONG_PTR)(BusData->Config.Type1.Data + i)); \
TYPE1_END(y)
#define TYPE1_START(x, y)
Definition: bus.h:31
#define POINTER_TO_(x)
Definition: bus.h:9
Definition: bufpool.h:45
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
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
uint32_t ULONG_PTR
Definition: typedefs.h:65

Definition at line 44 of file bus.h.

◆ TYPE1_START

#define TYPE1_START (   x,
  y 
)
Value:
{ \
ULONG i = Offset % sizeof(ULONG); \
PciCfg->u.bits.RegisterNumber = Offset / sizeof(ULONG); \
WRITE_PORT_ULONG(BusData->Config.Type1.Address, PciCfg->u.AsULONG);
#define TYPE_DEFINE(x, y)
Definition: bus.h:16
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
uint32_t ULONG
Definition: typedefs.h:59

Definition at line 31 of file bus.h.

◆ TYPE1_WRITE

#define TYPE1_WRITE (   x,
  y 
)
Value:
WRITE_TO(y)((POINTER_TO_(y))(ULONG_PTR)(BusData->Config.Type1.Data + i), \
*((POINTER_TO_(y))Buffer)); \
TYPE1_END(y)

Definition at line 53 of file bus.h.

◆ TYPE2_DEFINE

#define TYPE2_DEFINE (   x)    TYPE_DEFINE(x, PPCI_TYPE2_ADDRESS_BITS);

Definition at line 26 of file bus.h.

◆ TYPE2_END

#define TYPE2_END   TYPE1_END

Definition at line 39 of file bus.h.

◆ TYPE2_READ

#define TYPE2_READ (   x,
  y 
)
Value:
*((POINTER_TO_(y))Buffer) = \
READ_FROM(y)((POINTER_TO_(y))(ULONG_PTR)PciCfg->u.AsUSHORT); \
TYPE2_END(y)
#define TYPE2_START(x, y)
Definition: bus.h:62

Definition at line 70 of file bus.h.

◆ TYPE2_START

#define TYPE2_START (   x,
  y 
)
Value:
{ \
PciCfg->u.bits.RegisterNumber = (USHORT)Offset;
unsigned short USHORT
Definition: pedump.c:61

Definition at line 62 of file bus.h.

◆ TYPE2_WRITE

#define TYPE2_WRITE (   x,
  y 
)
Value:
WRITE_TO(y)((POINTER_TO_(y))(ULONG_PTR)PciCfg->u.AsUSHORT, \
*((POINTER_TO_(y))Buffer)); \
TYPE2_END(y)

Definition at line 79 of file bus.h.

◆ TYPE_DEFINE

#define TYPE_DEFINE (   x,
  y 
)
Value:
ULONG \
NTAPI \
x( \
IN PPCIPBUSDATA BusData, \
IN y PciCfg, \
)
#define IN
Definition: typedefs.h:39
unsigned char * PUCHAR
Definition: typedefs.h:53

Definition at line 16 of file bus.h.

◆ WRITE_TO

#define WRITE_TO (   x)    PASTE2(WRITE_PORT_, x)

Definition at line 11 of file bus.h.

Typedef Documentation

◆ ARRAY

typedef struct _ARRAY ARRAY

◆ FncConfigIO

typedef ULONG(NTAPI * FncConfigIO) (IN PPCIPBUSDATA BusData, IN PVOID State, IN PUCHAR Buffer, IN ULONG Offset)

Definition at line 121 of file bus.h.

◆ FncReleaseSync

typedef VOID(NTAPI * FncReleaseSync) (IN PBUS_HANDLER BusHandler, IN KIRQL Irql)

Definition at line 137 of file bus.h.

◆ FncSync

typedef VOID(NTAPI * FncSync) (IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PKIRQL Irql, IN PVOID State)

Definition at line 129 of file bus.h.

◆ HAL_BUS_HANDLER

◆ PARRAY

typedef struct _ARRAY * PARRAY

◆ PCI_CONFIG_HANDLER

◆ PCI_REGISTRY_INFO_INTERNAL

◆ PCI_TYPE0_CFG_CYCLE_BITS

◆ PCI_TYPE1_CFG_BITS

◆ PCI_TYPE1_CFG_CYCLE_BITS

◆ PCI_TYPE2_ADDRESS_BITS

◆ PCI_TYPE2_CSE_BITS

◆ PciIrqRange

typedef NTSTATUS(NTAPI * PciIrqRange) (IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN PCI_SLOT_NUMBER PciSlot, OUT PSUPPORTED_RANGE *Interrupt)

Definition at line 85 of file bus.h.

◆ PCIPBUSDATA

◆ PHAL_BUS_HANDLER

◆ PPCI_CONFIG_HANDLER

◆ PPCI_REGISTRY_INFO_INTERNAL

◆ PPCI_TYPE0_CFG_CYCLE_BITS

◆ PPCI_TYPE1_CFG_BITS

◆ PPCI_TYPE1_CFG_CYCLE_BITS

◆ PPCI_TYPE2_ADDRESS_BITS

◆ PPCI_TYPE2_CSE_BITS

◆ PPCIPBUSDATA

Function Documentation

◆ 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 1245 of file bussupp.c.

1250{
1251 PHAL_BUS_HANDLER BusHandler;
1253 PLIST_ENTRY NextEntry;
1254
1255 /* Make sure we have a context */
1256 if (!Context)
1257 return FALSE;
1258
1259 /* If we have data in the context, then this shouldn't be a new lookup */
1260 if ((*Context != 0) && (NextBus != FALSE))
1261 return FALSE;
1262
1263 /* Find the bus handler */
1265 if (!Handler)
1266 return FALSE;
1267
1268 /* Check if this is an ongoing lookup */
1269 if (NextBus)
1270 {
1271 /* Get the HAL bus handler */
1273 NextEntry = &BusHandler->AllHandlers;
1274
1275 /* Get the next one if we were already with one */
1276 if (*Context)
1277 NextEntry = NextEntry->Flink;
1278
1279 /* Start scanning */
1280 while (TRUE)
1281 {
1282 /* Check if this is the last one */
1283 if (NextEntry == &HalpAllBusHandlers)
1284 {
1285 /* Quit */
1286 *Context = 1;
1287 return FALSE;
1288 }
1289
1290 /* Call this translator */
1291 BusHandler = CONTAINING_RECORD(NextEntry, HAL_BUS_HANDLER, AllHandlers);
1293 BusHandler->Handler.BusNumber,
1294 BusAddress,
1297 {
1298 break;
1299 }
1300
1301 /* Try the next one */
1302 NextEntry = NextEntry->Flink;
1303 }
1304
1305 /* If we made it, we're done */
1306 *Context = (ULONG_PTR)&BusHandler->Handler;
1307 return TRUE;
1308 }
1309
1310 /* Try the first one through */
1311 if (!HalTranslateBusAddress(Handler->InterfaceType,
1312 Handler->BusNumber,
1313 BusAddress,
1316 {
1317 return FALSE;
1318 }
1319
1320 /* Remember for next time */
1322 return TRUE;
1323}
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
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:1588
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ULONG_PTR
Definition: config.h:101
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
ULONG BusNumber
Definition: haltypes.h:2062
INTERFACE_TYPE InterfaceType
Definition: haltypes.h:2060
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().

◆ HaliPciInterfaceReadConfig()

ULONG NTAPI HaliPciInterfaceReadConfig ( _In_ PBUS_HANDLER  RootBusHandler,
_In_ ULONG  BusNumber,
_In_ PCI_SLOT_NUMBER  SlotNumber,
_Out_writes_bytes_(Length) PVOID  Buffer,
_In_ ULONG  Offset,
_In_ ULONG  Length 
)

Definition at line 934 of file pcibus.c.

941{
942 BUS_HANDLER BusHandler;
943
944 /* Setup fake PCI Bus handler */
945 RtlCopyMemory(&BusHandler, &HalpFakePciBusHandler, sizeof(BUS_HANDLER));
946 BusHandler.BusNumber = BusNumber;
947
948 /* Read configuration data */
950
951 /* Return length */
952 return Length;
953}
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
const BUS_HANDLER HalpFakePciBusHandler
Definition: pcibus.c:94
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
_In_ ULONG BusNumber
Definition: pciidex.h:65
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:68

Referenced by HalpInitializePciStubs(), and HalpQueryInterface().

◆ HaliPciInterfaceWriteConfig()

ULONG NTAPI HaliPciInterfaceWriteConfig ( _In_ PBUS_HANDLER  RootBusHandler,
_In_ ULONG  BusNumber,
_In_ PCI_SLOT_NUMBER  SlotNumber,
_In_reads_bytes_(Length) PVOID  Buffer,
_In_ ULONG  Offset,
_In_ ULONG  Length 
)

Definition at line 957 of file pcibus.c.

964{
965 BUS_HANDLER BusHandler;
966
967 RtlCopyMemory(&BusHandler, &HalpFakePciBusHandler, sizeof(BUS_HANDLER));
968 BusHandler.BusNumber = BusNumber;
969
971
972 return Length;
973}
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

Referenced by HalpQueryInterface().

◆ HaliReferenceHandlerForConfigSpace()

PBUS_HANDLER FASTCALL HaliReferenceHandlerForConfigSpace ( IN BUS_DATA_TYPE  ConfigType,
IN ULONG  BusNumber 
)

Definition at line 221 of file bushndlr.c.

223{
224 /* Lookup the configuration in the configuration table and add a reference */
225 return HalpLookupHandler(HalpConfigTable, ConfigType, BusNumber, TRUE);
226}
PBUS_HANDLER FASTCALL HalpLookupHandler(IN PARRAY Array, IN ULONG Type, IN ULONG Number, IN BOOLEAN AddReference)
Definition: bushndlr.c:76
PARRAY HalpConfigTable
Definition: bushndlr.c:21

Referenced by HalGetBusDataByOffset(), and HalSetBusDataByOffset().

◆ 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 1327 of file bussupp.c.

1332{
1335
1336 /* Find the handler */
1338 if (!(Handler) || !(Handler->TranslateBusAddress))
1339 {
1340 DPRINT1("No translator Interface: %x, Bus: %x, Handler: %p, BusAddress: %x!\n", InterfaceType, BusNumber, Handler, BusAddress);
1341 return FALSE;
1342 }
1343
1344 /* Do the assignment */
1345 Status = Handler->TranslateBusAddress(Handler,
1346 Handler,
1347 BusAddress,
1350
1351 /* Dereference the handler and return */
1353 return Status;
1354}
unsigned char BOOLEAN
Definition: actypes.h:127
#define DPRINT1
Definition: precomp.h:8
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:463
#define HalDereferenceBusHandler
Definition: haltypes.h:309
#define HalReferenceHandlerForBus
Definition: haltypes.h:307

Referenced by HalpInitBusHandler(), and HalTranslateBusAddress().

◆ HalpAdjustPCIResourceList()

NTSTATUS NTAPI HalpAdjustPCIResourceList ( IN PBUS_HANDLER  BusHandler,
IN PBUS_HANDLER  RootHandler,
IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *  pResourceList 
)

Definition at line 757 of file pcibus.c.

760{
761 PPCIPBUSDATA BusData;
765
766 /* Get PCI bus data */
767 BusData = BusHandler->BusData;
768 SlotNumber.u.AsULONG = (*pResourceList)->SlotNumber;
769
770 /* Get the IRQ supported range */
771 Status = BusData->GetIrqRange(BusHandler, RootHandler, SlotNumber, &Interrupt);
772 if (!NT_SUCCESS(Status)) return Status;
773#ifndef _MINIHAL_
774 /* Handle the /PCILOCK feature */
776 {
777 /* /PCILOCK is not yet supported */
778 UNIMPLEMENTED_DBGBREAK("/PCILOCK boot switch is not yet supported.");
779 }
780#endif
781 /* Now create the correct resource list based on the supported bus ranges */
782#if 0
783 Status = HaliAdjustResourceListRange(BusHandler->BusAddresses,
784 Interrupt,
785 pResourceList);
786#else
787 DPRINT1("HAL: No PCI Resource Adjustment done! Hardware may malfunction\n");
789#endif
790
791 /* Return to caller */
793 return Status;
794}
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
BOOLEAN HalpPciLockSettings
Definition: halinit.c:20
#define STATUS_SUCCESS
Definition: shellext.h:65
PciIrqRange GetIrqRange
Definition: bus.h:111
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFINTERRUPT * Interrupt
Definition: wdfinterrupt.h:379

Referenced by HalpAllocateAndInitPciBusHandler().

◆ HalpAssignPCISlotResources()

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 at line 798 of file pcibus.c.

806{
816 DPRINT1("WARNING: PCI Slot Resource Assignment is FOOBAR\n");
817
818 /* FIXME: Should handle 64-bit addresses */
819
820 /* Read configuration data */
821 SlotNumber.u.AsULONG = Slot;
823
824 /* Check if we read it correctly */
825 if (PciConfig.VendorID == PCI_INVALID_VENDORID)
827
828 /* Read the PCI configuration space for the device and store base address and
829 size information in temporary storage. Count the number of valid base addresses */
830 ResourceCount = 0;
832 {
833 if (0xffffffff == PciConfig.u.type0.BaseAddresses[Address])
834 PciConfig.u.type0.BaseAddresses[Address] = 0;
835
836 /* Memory resource */
837 if (0 != PciConfig.u.type0.BaseAddresses[Address])
838 {
840
841 Offset = (UCHAR)FIELD_OFFSET(PCI_COMMON_CONFIG, u.type0.BaseAddresses[Address]);
842
843 /* Write 0xFFFFFFFF there */
844 WriteBuffer = 0xffffffff;
845 HalpWritePCIConfig(BusHandler, SlotNumber, &WriteBuffer, Offset, sizeof(ULONG));
846
847 /* Read that figure back from the config space */
848 HalpReadPCIConfig(BusHandler, SlotNumber, &Size[Address], Offset, sizeof(ULONG));
849
850 /* Write back initial value */
851 HalpWritePCIConfig(BusHandler, SlotNumber, &PciConfig.u.type0.BaseAddresses[Address], Offset, sizeof(ULONG));
852 }
853 }
854
855 /* Interrupt resource */
856 if (0 != PciConfig.u.type0.InterruptPin &&
857 0 != PciConfig.u.type0.InterruptLine &&
858 0xFF != PciConfig.u.type0.InterruptLine)
860
861 /* Allocate output buffer and initialize */
863 PagedPool,
864 sizeof(CM_RESOURCE_LIST) +
866 TAG_HAL);
867
868 if (NULL == *AllocatedResources)
869 return STATUS_NO_MEMORY;
870
871 (*AllocatedResources)->Count = 1;
872 (*AllocatedResources)->List[0].InterfaceType = PCIBus;
873 (*AllocatedResources)->List[0].BusNumber = BusHandler->BusNumber;
874 (*AllocatedResources)->List[0].PartialResourceList.Version = 1;
875 (*AllocatedResources)->List[0].PartialResourceList.Revision = 1;
876 (*AllocatedResources)->List[0].PartialResourceList.Count = ResourceCount;
877 Descriptor = (*AllocatedResources)->List[0].PartialResourceList.PartialDescriptors;
878
879 /* Store configuration information */
881 {
882 if (0 != PciConfig.u.type0.BaseAddresses[Address])
883 {
885 (PciConfig.u.type0.BaseAddresses[Address] & 0x1))
886 {
888 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive; /* FIXME I have no idea... */
889 Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE; /* FIXME Just a guess */
890 Descriptor->u.Memory.Start.QuadPart = (PciConfig.u.type0.BaseAddresses[Address] & PCI_ADDRESS_MEMORY_ADDRESS_MASK);
892 }
893 else if (PCI_ADDRESS_IO_SPACE ==
894 (PciConfig.u.type0.BaseAddresses[Address] & 0x1))
895 {
897 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive; /* FIXME I have no idea... */
898 Descriptor->Flags = CM_RESOURCE_PORT_IO; /* FIXME Just a guess */
899 Descriptor->u.Port.Start.QuadPart = PciConfig.u.type0.BaseAddresses[Address] &= PCI_ADDRESS_IO_ADDRESS_MASK;
900 Descriptor->u.Port.Length = PciSize(Size[Address], PCI_ADDRESS_IO_ADDRESS_MASK & 0xffff);
901 }
902 else
903 {
904 ASSERT(FALSE);
905 return STATUS_UNSUCCESSFUL;
906 }
907 Descriptor++;
908 }
909 }
910
911 if (0 != PciConfig.u.type0.InterruptPin &&
912 0 != PciConfig.u.type0.InterruptLine &&
913 0xFF != PciConfig.u.type0.InterruptLine)
914 {
916 Descriptor->ShareDisposition = CmResourceShareShared; /* FIXME Just a guess */
917 Descriptor->Flags = CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE; /* FIXME Just a guess */
918 Descriptor->u.Interrupt.Level = PciConfig.u.type0.InterruptLine;
919 Descriptor->u.Interrupt.Vector = PciConfig.u.type0.InterruptLine;
920 Descriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
921
922 Descriptor++;
923 }
924
925 ASSERT(Descriptor == (*AllocatedResources)->List[0].PartialResourceList.PartialDescriptors + ResourceCount);
926
927 /* FIXME: Should store the resources in the registry resource map */
928
929 return Status;
930}
#define WriteBuffer(BaseIoAddress, Buffer, Count)
Definition: atapi.h:344
#define PCI_ADDRESS_MEMORY_SPACE
Definition: bus.h:3
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define NULL
Definition: types.h:112
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
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
#define TAG_HAL
Definition: hal.h:61
static ULONG ResourceCount
Definition: inbv.c:50
#define ASSERT(a)
Definition: mode.c:44
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PCM_RESOURCE_LIST * AllocatedResources
Definition: ndis.h:4643
#define CM_RESOURCE_PORT_IO
Definition: cmtypes.h:109
#define CM_RESOURCE_MEMORY_READ_WRITE
Definition: cmtypes.h:121
static ULONG NTAPI PciSize(ULONG Base, ULONG Mask)
Definition: pcibus.c:748
_In_ ULONG _In_ PCI_SLOT_NUMBER _In_ PPCI_COMMON_HEADER PciConfig
Definition: pciidex.h:67
static WCHAR Address[46]
Definition: ping.c:68
#define CmResourceTypeMemory
Definition: restypes.h:106
#define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE
Definition: restypes.h:116
@ PCIBus
Definition: restypes.h:127
#define CmResourceTypePort
Definition: restypes.h:104
#define CmResourceTypeInterrupt
Definition: restypes.h:105
union _PCI_SLOT_NUMBER::@5063 u
unsigned char UCHAR
Definition: typedefs.h:53
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
@ CmResourceShareDeviceExclusive
Definition: cmtypes.h:241
@ CmResourceShareShared
Definition: cmtypes.h:243
#define PCI_INVALID_VENDORID
Definition: iotypes.h:3616
#define PCI_ADDRESS_IO_ADDRESS_MASK
Definition: iotypes.h:4249
#define PCI_TYPE0_ADDRESSES
Definition: iotypes.h:3515
#define PCI_ADDRESS_IO_SPACE
Definition: iotypes.h:4246
#define PCI_ADDRESS_MEMORY_ADDRESS_MASK
Definition: iotypes.h:4250
#define PCI_COMMON_HDR_LENGTH
Definition: iotypes.h:3609

Referenced by HalpAllocateAndInitPciBusHandler(), and HalpAssignSlotResources().

◆ 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 45 of file busemul.c.

53{
54 BUS_HANDLER BusHandler;
55 PAGED_CODE();
56
57 /* Only PCI is supported */
59
60 /* Setup fake PCI Bus handler */
61 RtlCopyMemory(&BusHandler, &HalpFakePciBusHandler, sizeof(BUS_HANDLER));
62 BusHandler.BusNumber = BusNumber;
63
64 /* Call the PCI function */
65 return HalpAssignPCISlotResources(&BusHandler,
66 &BusHandler,
73}
#define PAGED_CODE()
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
const BUS_HANDLER HalpFakePciBusHandler
Definition: pcibus.c:94
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
_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_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

Referenced by HalAssignSlotResources(), HalpInitBusHandler(), and HalpInitNonBusHandler().

◆ HalpcGetCmosData()

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 at line 16 of file cmosbus.c.

23{
24 UNREFERENCED_PARAMETER(RootHandler);
25
26 /* CMOS reads do not support offsets */
27 if (Offset != 0)
28 return 0;
29
30 return HalpGetCmosData(BusHandler->BusNumber,
32 Buffer,
33 Length);
34}
ULONG NTAPI HalpGetCmosData(_In_ ULONG BusNumber, _In_ ULONG SlotNumber, _Out_writes_bytes_(Length) PVOID Buffer, _In_ ULONG Length)
Definition: cmos.c:49
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329

Referenced by HalpRegisterInternalBusHandlers().

◆ HalpContextToBusHandler()

PBUS_HANDLER NTAPI HalpContextToBusHandler ( IN ULONG_PTR  ContextValue)

Definition at line 230 of file bushndlr.c.

231{
232 PLIST_ENTRY NextEntry;
233 PHAL_BUS_HANDLER BusHandler, ThisHandler;
234
235 /* Start lookup */
236 NextEntry = HalpAllBusHandlers.Flink;
237 ThisHandler = CONTAINING_RECORD(NextEntry, HAL_BUS_HANDLER, AllHandlers);
238 if (ContextValue)
239 {
240 /* If the list is empty, quit */
241 if (IsListEmpty(&HalpAllBusHandlers)) return NULL;
242
243 /* Otherwise, scan the list */
244 BusHandler = CONTAINING_RECORD(ContextValue, HAL_BUS_HANDLER, Handler);
245 do
246 {
247 /* Check if we've reached the right one */
248 ThisHandler = CONTAINING_RECORD(NextEntry, HAL_BUS_HANDLER, AllHandlers);
249 if (ThisHandler == BusHandler) break;
250
251 /* Try the next one */
252 NextEntry = NextEntry->Flink;
253 } while (NextEntry != &HalpAllBusHandlers);
254 }
255
256 /* If we looped back to the end, we didn't find anything */
257 if (NextEntry == &HalpAllBusHandlers) return NULL;
258
259 /* Otherwise return the handler */
260 return &ThisHandler->Handler;
261}
LIST_ENTRY HalpAllBusHandlers
Definition: bushndlr.c:19
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954

Referenced by HaliFindBusAddressTranslation().

◆ HalpcSetCmosData()

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 at line 38 of file cmosbus.c.

45{
46 UNREFERENCED_PARAMETER(RootHandler);
47
48 /* CMOS writes do not support offsets */
49 if (Offset != 0)
50 return 0;
51
52 return HalpSetCmosData(BusHandler->BusNumber,
54 Buffer,
55 Length);
56}
ULONG NTAPI HalpSetCmosData(_In_ ULONG BusNumber, _In_ ULONG SlotNumber, _In_reads_bytes_(Length) PVOID Buffer, _In_ ULONG Length)
Definition: cmos.c:104

Referenced by HalpRegisterInternalBusHandlers().

◆ HalpFindBusAddressTranslation()

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

Definition at line 90 of file busemul.c.

95{
96 /* Make sure we have a context */
97 if (!Context) return FALSE;
98
99 /* If we have data in the context, then this shouldn't be a new lookup */
100 if ((*Context != 0) && (NextBus != FALSE)) return FALSE;
101
102 /* Return bus data */
104
105 /* Set context value and return success */
106 *Context = 1;
107 return TRUE;
108}
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by HalpInitNonBusHandler().

◆ HalpGetCmosData()

ULONG NTAPI HalpGetCmosData ( _In_ ULONG  BusNumber,
_In_ ULONG  SlotNumber,
_Out_writes_bytes_(Length) PVOID  Buffer,
_In_ ULONG  Length 
)

Definition at line 49 of file cmos.c.

54{
58
59 /* Do nothing if we don't have a length */
60 if (!Length) return 0;
61
62 /* Acquire CMOS Lock */
64
65 /* Check if this is simple CMOS */
66 if (BusNumber == 0)
67 {
68 /* Loop the buffer up to 0xFF */
69 while ((Len > 0) && (Address < 0x100))
70 {
71 /* Read the data */
73
74 /* Update position and length */
75 Ptr++;
76 Address++;
77 Len--;
78 }
79 }
80 else if (BusNumber == 1)
81 {
82 /* Loop the buffer up to 0xFFFF */
83 while ((Len > 0) && (Address < 0x10000))
84 {
85 /* Write the data */
87
88 /* Update position and length */
89 Ptr++;
90 Address++;
91 Len--;
92 }
93 }
94
95 /* Release CMOS Lock */
97
98 /* Return length read */
99 return Length - Len;
100}
#define Len
Definition: deflate.h:82
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
VOID NTAPI HalpReleaseCmosSpinLock(VOID)
Definition: spinlock.c:243
VOID NTAPI HalpAcquireCmosSpinLock(VOID)
Definition: spinlock.c:226
UCHAR NTAPI HalpReadCmos(_In_ UCHAR Reg)
Definition: cmos.c:114

Referenced by HalGetBusDataByOffset(), and HalpcGetCmosData().

◆ HalpGetISAFixedPCIIrq()

NTSTATUS NTAPI HalpGetISAFixedPCIIrq ( IN PBUS_HANDLER  BusHandler,
IN PBUS_HANDLER  RootHandler,
IN PCI_SLOT_NUMBER  PciSlot,
OUT PSUPPORTED_RANGE *  Range 
)

Definition at line 702 of file pcibus.c.

706{
707 PCI_COMMON_HEADER PciData;
708
709 /* Read PCI configuration data */
711 BusHandler->BusNumber,
713 &PciData,
715
716 /* Make sure it's a real device */
717 if (PciData.VendorID == PCI_INVALID_VENDORID) return STATUS_UNSUCCESSFUL;
718
719 /* Allocate the supported range structure */
721 if (!*Range) return STATUS_INSUFFICIENT_RESOURCES;
722
723 /* Set it up */
724 RtlZeroMemory(*Range, sizeof(SUPPORTED_RANGE));
725 (*Range)->Base = 1;
726
727 /* If the PCI device has no IRQ, nothing to do */
728 if (!PciData.u.type0.InterruptPin) return STATUS_SUCCESS;
729
730 /* FIXME: The PCI IRQ Routing Miniport should be called */
731
732 /* Also if the INT# seems bogus, nothing to do either */
733 if ((PciData.u.type0.InterruptLine == 0) ||
734 (PciData.u.type0.InterruptLine == 255))
735 {
736 /* Fake success */
737 return STATUS_SUCCESS;
738 }
739
740 /* Otherwise, the INT# should be valid, return it to the caller */
741 (*Range)->Base = PciData.u.type0.InterruptLine;
742 (*Range)->Limit = PciData.u.type0.InterruptLine;
743 return STATUS_SUCCESS;
744}
NTHALAPI ULONG NTAPI HalGetBusData(BUS_DATA_TYPE, ULONG, ULONG, PVOID, ULONG)
_In_ ULONG _In_ PCI_SLOT_NUMBER PciSlot
Definition: pciidex.h:66
@ PCIConfiguration
Definition: miniport.h:93
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

Referenced by HalpAllocateAndInitPciBusHandler().

◆ HalpGetPCIData()

ULONG NTAPI HalpGetPCIData ( IN PBUS_HANDLER  BusHandler,
IN PBUS_HANDLER  RootBusHandler,
IN ULONG  SlotNumber,
IN PVOID  Buffer,
IN ULONG  Offset,
IN ULONG  Length 
)

Definition at line 507 of file pcibus.c.

513{
514 PCI_SLOT_NUMBER Slot;
515 UCHAR PciBuffer[PCI_COMMON_HDR_LENGTH];
517 ULONG Len = 0;
518
519 Slot.u.AsULONG = SlotNumber;
520#ifdef SARCH_XBOX
521 if (HalpXboxBlacklistedPCISlot(BusHandler->BusNumber, Slot))
522 {
524 return Length;
525 }
526#endif
527
528 /* Normalize the length */
529 if (Length > sizeof(PCI_COMMON_CONFIG)) Length = sizeof(PCI_COMMON_CONFIG);
530
531 /* Check if this is a vendor-specific read */
533 {
534 /* Read the header */
535 HalpReadPCIConfig(BusHandler, Slot, PciConfig, 0, sizeof(ULONG));
536
537 /* Make sure the vendor is valid */
538 if (PciConfig->VendorID == PCI_INVALID_VENDORID) return 0;
539 }
540 else
541 {
542 /* Read the entire header */
544 HalpReadPCIConfig(BusHandler, Slot, PciConfig, 0, Len);
545
546 /* Validate the vendor ID */
547 if (PciConfig->VendorID == PCI_INVALID_VENDORID)
548 {
549 /* It's invalid, but we want to return this much */
550 Len = sizeof(USHORT);
551 }
552
553 /* Now check if there's space left */
554 if (Len < Offset) return 0;
555
556 /* There is, so return what's after the offset and normalize */
557 Len -= Offset;
558 if (Len > Length) Len = Length;
559
560 /* Copy the data into the caller's buffer */
561 RtlMoveMemory(Buffer, PciBuffer + Offset, Len);
562
563 /* Update buffer and offset, decrement total length */
564 Offset += Len;
566 Length -= Len;
567 }
568
569 /* Now we still have something to copy */
570 if (Length)
571 {
572 /* Check if it's vendor-specific data */
574 {
575 /* Read it now */
576 HalpReadPCIConfig(BusHandler, Slot, Buffer, Offset, Length);
577 Len += Length;
578 }
579 }
580
581 /* Update the total length read */
582 return Len;
583}
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:603
void * PVOID
Definition: typedefs.h:50
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
struct _PCI_COMMON_CONFIG * PPCI_COMMON_CONFIG
struct _PCI_COMMON_CONFIG PCI_COMMON_CONFIG

Referenced by HalGetBusDataByOffset(), and HalpAllocateAndInitPciBusHandler().

◆ HalpGetPCIIntOnISABus()

ULONG NTAPI HalpGetPCIIntOnISABus ( IN PBUS_HANDLER  BusHandler,
IN PBUS_HANDLER  RootHandler,
IN ULONG  BusInterruptLevel,
IN ULONG  BusInterruptVector,
OUT PKIRQL  Irql,
OUT PKAFFINITY  Affinity 
)

Definition at line 658 of file pcibus.c.

664{
665 /* Validate the level first */
666 if (BusInterruptLevel < 1) return 0;
667
668 /* PCI has its IRQs on top of ISA IRQs, so pass it on to the ISA handler */
670 0,
672 0,
673 Irql,
674 Affinity);
675}
_Out_ PKIRQL Irql
Definition: csq.h:179
NTHALAPI ULONG NTAPI HalGetInterruptVector(INTERFACE_TYPE, ULONG, ULONG, ULONG, PKIRQL, PKAFFINITY)
@ Isa
Definition: restypes.h:123
_In_ ULONG _In_ ULONG BusInterruptLevel
Definition: halfuncs.h:171
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:174

Referenced by HalpAllocateAndInitPciBusHandler().

◆ HalpGetRootInterruptVector()

ULONG NTAPI HalpGetRootInterruptVector ( _In_ ULONG  BusInterruptLevel,
_In_ ULONG  BusInterruptVector,
_Out_ PKIRQL  Irql,
_Out_ PKAFFINITY  Affinity 
)

Definition at line 507 of file apic.c.

512{
515 KIRQL Irql;
516
517 /* Resources that already hold a system vector are translated here too, so stay quiet */
519 {
520 DPRINT("No I/O APIC serves input %lu\n", BusInterruptLevel);
521 *OutAffinity = 0;
522 *OutIrql = 0;
523 return 0;
524 }
525
526 /* Get the vector currently registered */
528
529 /* Check if it's used */
531 {
532 /* Calculate IRQL */
534 *OutIrql = HalpVectorToIrql(Vector);
535 }
536 else
537 {
539
540 /* Outer loop to find alternative slots, when all IRQLs are in use */
541 for (Offset = 0; Offset < 15; Offset++)
542 {
543 /* Loop allowed IRQL range */
544 for (Irql = CLOCK_LEVEL - 1; Irql >= CMCI_LEVEL; Irql--)
545 {
546 /* Calculate the vactor */
548
549 /* Check if the vector is free */
551 {
552 /* Found one, allocate the interrupt */
554 *OutIrql = Irql;
555 goto Exit;
556 }
557 }
558 }
559
560 DPRINT1("Failed to get an interrupt vector for IRQ %lu\n", BusInterruptLevel);
561 *OutAffinity = 0;
562 *OutIrql = 0;
563 return 0;
564 }
565
566Exit:
567
568 *OutAffinity = HalpDefaultInterruptAffinity;
570
571 return Vector;
572}
UCHAR HalpVectorToIndex[256]
Definition: apic.c:31
UCHAR FASTCALL HalpIrqToVector(_In_ UCHAR Irq)
Definition: apic.c:344
KIRQL FASTCALL HalpVectorToIrql(UCHAR Vector)
Definition: apic.c:353
UCHAR NTAPI HalpAllocateSystemInterrupt(_In_ UCHAR Irq, _In_ UCHAR Vector)
Definition: apic.c:474
UCHAR FASTCALL HalpVectorToIrq(UCHAR Vector)
Definition: apic.c:360
FORCEINLINE BOOLEAN HalpFindIoApicInput(_In_ ULONG Input, _Out_ PHALP_IOAPIC_UNIT *Unit)
Finds the I/O APIC that serves an input.
Definition: apic.c:158
#define APIC_FREE_VECTOR
Definition: apicp.h:61
#define IrqlToTpr(Irql)
Definition: apicp.h:55
UCHAR KIRQL
Definition: env_spec_w32.h:591
Unit
Definition: gdiplusenums.h:26
KAFFINITY HalpDefaultInterruptAffinity
Definition: processor.c:18
#define CMCI_LEVEL
Definition: ketypes.h:15
#define CLOCK_LEVEL
Definition: ketypes.h:16
#define DPRINT
Definition: sndvol32.h:73
static void Exit(void)
Definition: sock.c:1330
#define NT_ASSERT
Definition: rtlfuncs.h:3334

Referenced by HalGetInterruptVector(), and HalpGetSystemInterruptVector().

◆ HalpGetSystemInterruptVector()

ULONG NTAPI HalpGetSystemInterruptVector ( IN PBUS_HANDLER  BusHandler,
IN PBUS_HANDLER  RootHandler,
IN ULONG  BusInterruptLevel,
IN ULONG  BusInterruptVector,
OUT PKIRQL  Irql,
OUT PKAFFINITY  Affinity 
)

Definition at line 115 of file sysbus.c.

121{
123
124 /* Get the root vector */
127 Irql,
128 Affinity);
129
130 /* Check if the vector is owned by the HAL and fail if it is */
131 if (HalpIDTUsageFlags[Vector].Flags & IDT_REGISTERED) DPRINT1("Vector %lx is ALREADY IN USE!\n", Vector);
133}
ULONG NTAPI HalpGetRootInterruptVector(_In_ ULONG BusInterruptLevel, _In_ ULONG BusInterruptVector, _Out_ PKIRQL OutIrql, _Out_ PKAFFINITY OutAffinity)
Definition: apic.c:507
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ ULONG _In_ ULONG Flags
Definition: dispmprt.h:245
IDTUsageFlags HalpIDTUsageFlags[256]
Definition: usage.c:19
#define IDT_REGISTERED
Definition: halp.h:19
_In_ ULONG _In_ ULONG _In_ ULONG BusInterruptVector
Definition: halfuncs.h:172

Referenced by HalpRegisterInternalBusHandlers().

◆ HalpInitBusHandler()

VOID NTAPI HalpInitBusHandler ( VOID  )

Definition at line 444 of file bushndlr.c.

445{
446 /* Setup the bus lock */
448
449 /* Setup the bus event */
451
452 /* Setup the bus configuration and bus table */
455
456 /* Setup the bus list */
458
459 /* Setup the HAL Dispatch routines */
460#ifndef _MINIHAL_
467#endif
469 HalPciTranslateBusAddress = HaliTranslateBusAddress; /* PCI Driver can override */
471}
BOOLEAN NTAPI HaliFindBusAddressTranslation(IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress, IN OUT PULONG_PTR Context, IN BOOLEAN NextBus)
Definition: bussupp.c:1245
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:1327
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: busemul.c:45
VOID FASTCALL HaliReferenceBusHandler(IN PBUS_HANDLER Handler)
Definition: bushndlr.c:171
PBUS_HANDLER FASTCALL HaliHandlerForConfigSpace(IN BUS_DATA_TYPE ConfigType, IN ULONG BusNumber)
Definition: bushndlr.c:203
VOID FASTCALL HaliDereferenceBusHandler(IN PBUS_HANDLER Handler)
Definition: bushndlr.c:182
PBUS_HANDLER FASTCALL HaliReferenceHandlerForBus(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber)
Definition: bushndlr.c:212
PBUS_HANDLER FASTCALL HaliHandlerForBus(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber)
Definition: bushndlr.c:194
KSPIN_LOCK HalpBusDatabaseSpinLock
Definition: bushndlr.c:17
NTSTATUS NTAPI HaliRegisterBusHandler(IN INTERFACE_TYPE InterfaceType, IN BUS_DATA_TYPE ConfigType, IN ULONG BusNumber, IN INTERFACE_TYPE ParentBusType, IN ULONG ParentBusNumber, IN ULONG ExtraData, IN PINSTALL_BUS_HANDLER InstallCallback, OUT PBUS_HANDLER *ReturnedBusHandler)
Definition: bushndlr.c:266
PARRAY NTAPI HalpAllocateArray(IN ULONG ArraySize)
Definition: bushndlr.c:27
PARRAY HalpBusTable
Definition: bushndlr.c:20
KEVENT HalpBusDatabaseEvent
Definition: bushndlr.c:18
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
#define HalFindBusAddressTranslation
Definition: halfuncs.h:44
#define HalHandlerForBus
Definition: halfuncs.h:35
#define HalRegisterBusHandler
Definition: halfuncs.h:38
#define HalHandlerForConfigSpace
Definition: halfuncs.h:36
#define HalPciTranslateBusAddress
Definition: halfuncs.h:41
#define HalPciAssignSlotResources
Definition: halfuncs.h:42
@ SynchronizationEvent
#define HalReferenceBusHandler
Definition: haltypes.h:308

Referenced by HalpRegisterInternalBusHandlers(), and LoadBootDeviceDriver().

◆ HalpInitializePciBus()

VOID NTAPI HalpInitializePciBus ( VOID  )

Definition at line 964 of file halacpi.c.

965{
966 /* Setup the PCI stub support */
968
969 /* Set the NMI crash flag */
971}
VOID NTAPI HalpInitializePciStubs(VOID)
Definition: pcibus.c:1211
VOID NTAPI HalpGetNMICrashFlag(VOID)
Definition: usage.c:605

Referenced by HalReportResourceUsage().

◆ HalpInitializePciStubs()

VOID NTAPI HalpInitializePciStubs ( VOID  )

Definition at line 1211 of file pcibus.c.

1212{
1213 PPCI_REGISTRY_INFO_INTERNAL PciRegistryInfo;
1215 UCHAR PciType;
1216 ULONG MaxPciBusNumber;
1217
1218 /* Query registry information */
1219 PciRegistryInfo = HalpQueryPciRegistryInfo();
1220 if (!PciRegistryInfo)
1221 {
1222 /* Assume type 1 */
1223 PciType = 1;
1224
1225 /* Force a manual bus scan later */
1226 MaxPciBusNumber = MAXULONG;
1227 }
1228 else
1229 {
1230 /* Get the PCI type */
1231 PciType = PciRegistryInfo->HardwareMechanism & 0xF;
1232
1233 /* Get MaxPciBusNumber and make it 0-based */
1234 MaxPciBusNumber = PciRegistryInfo->NoBuses - 1;
1235
1236 /* Free the info structure */
1237 ExFreePoolWithTag(PciRegistryInfo, TAG_HAL);
1238 }
1239
1240 /* Initialize the PCI lock */
1242
1243 /* Check the type of PCI bus */
1244 switch (PciType)
1245 {
1246 /* Type 1 PCI Bus */
1247 case 1:
1248
1249 /* Copy the Type 1 handler data */
1252 sizeof(PCIConfigHandler));
1253
1254 /* Set correct I/O Ports */
1255 BusData->Config.Type1.Address = PCI_TYPE1_ADDRESS_PORT;
1256 BusData->Config.Type1.Data = PCI_TYPE1_DATA_PORT;
1257 break;
1258
1259 /* Type 2 PCI Bus */
1260 case 2:
1261
1262 /* Copy the Type 2 handler data */
1265 sizeof (PCIConfigHandler));
1266
1267 /* Set correct I/O Ports */
1268 BusData->Config.Type2.CSE = PCI_TYPE2_CSE_PORT;
1269 BusData->Config.Type2.Forward = PCI_TYPE2_FORWARD_PORT;
1270 BusData->Config.Type2.Base = PCI_TYPE2_ADDRESS_BASE;
1271
1272 /* Only 16 devices supported, not 32 */
1273 BusData->MaxDevice = 16;
1274 break;
1275
1276 default:
1277
1278 /* Invalid type */
1279 DbgPrint("HAL: Unknown PCI type\n");
1280 }
1281
1282 /* Run a forced bus scan if needed */
1283 if (MaxPciBusNumber == MAXULONG)
1284 {
1285 ULONG i;
1287
1288 /* Initialize the counter and loop all possible buses */
1289 MaxPciBusNumber = 0;
1290 for (i = 0; i <= PCI_MAX_BRIDGE_NUMBER; i++)
1291 {
1292 /* Loop all devices */
1293 for (j.u.AsULONG = 0; j.u.AsULONG < BusData->MaxDevice; j.u.AsULONG++)
1294 {
1295 /* Query the interface */
1296 ULONG VendorId = 0;
1298 i,
1299 j,
1300 &VendorId,
1301 0,
1302 sizeof(ULONG)))
1303 {
1304 /* Validate the vendor ID */
1305 if ((VendorId & 0xFFFF) != PCI_INVALID_VENDORID)
1306 {
1307 /* Set this as the maximum ID */
1308 MaxPciBusNumber = i;
1309 break;
1310 }
1311 }
1312 }
1313 }
1314 }
1315
1316 /* Set the real max bus number */
1317 HalpMaxPciBus = MaxPciBusNumber;
1318
1319 /* We're done */
1321}
#define PCI_TYPE1_DATA_PORT
Definition: hardware.h:45
#define PCI_TYPE1_ADDRESS_PORT
Definition: hardware.h:44
#define PCI_TYPE2_ADDRESS_BASE
Definition: bus.h:172
#define PCI_TYPE2_CSE_PORT
Definition: bus.h:170
#define PCI_TYPE2_FORWARD_PORT
Definition: bus.h:171
struct _PCIPBUSDATA * PPCIPBUSDATA
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 DbgPrint
Definition: hal.h:12
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
KSPIN_LOCK HalpPCIConfigLock
Definition: pcibus.c:22
ULONG HalpMaxPciBus
Definition: pcibus.c:21
const PCI_CONFIG_HANDLER PCIConfigHandlerType1
Definition: pcibus.c:35
PCI_CONFIG_HANDLER PCIConfigHandler
Definition: pcibus.c:23
const PCI_CONFIG_HANDLER PCIConfigHandlerType2
Definition: pcibus.c:57
ULONG NTAPI HaliPciInterfaceReadConfig(_In_ PBUS_HANDLER RootBusHandler, _In_ ULONG BusNumber, _In_ PCI_SLOT_NUMBER SlotNumber, _Out_writes_bytes_(Length) PVOID Buffer, _In_ ULONG Offset, _In_ ULONG Length)
Definition: pcibus.c:934
BOOLEAN HalpPCIConfigInitialized
Definition: pcibus.c:20
PPCI_REGISTRY_INFO_INTERNAL NTAPI HalpQueryPciRegistryInfo(VOID)
Definition: pcibus.c:978
PVOID BusData
Definition: haltypes.h:2065
ULONG MaxDevice
Definition: bus.h:110
union _PCIPBUSDATA::@1725 Config
struct _PCIPBUSDATA::@1725::@1727 Type2
struct _PCIPBUSDATA::@1725::@1726 Type1
#define MAXULONG
Definition: typedefs.h:251
#define PCI_MAX_BRIDGE_NUMBER
Definition: iotypes.h:3615

Referenced by HalpInitializePciBus(), HalReportResourceUsage(), and LoadBootDeviceDriver().

◆ HalpNoBusData()

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 at line 111 of file bushndlr.c.

118{
119 DPRINT1("STUB GetSetBusData(Bus %x:%x.%x)\n",
120 BusHandler->InterfaceType,
121 BusHandler->ConfigurationType,
122 BusHandler->BusNumber);
123
124 /* Just return a dummy value */
125 return 0;
126}

Referenced by HaliRegisterBusHandler(), and HalpRegisterInternalBusHandlers().

◆ HalpPCIISALine2Pin()

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 at line 690 of file pcibus.c.

695{
697}

Referenced by HalpAllocateAndInitPciBusHandler().

◆ HalpPCIPin2ISALine()

VOID NTAPI HalpPCIPin2ISALine ( IN PBUS_HANDLER  BusHandler,
IN PBUS_HANDLER  RootHandler,
IN PCI_SLOT_NUMBER  SlotNumber,
IN PPCI_COMMON_CONFIG  PciData 
)

Definition at line 680 of file pcibus.c.

684{
686}

Referenced by HalpAllocateAndInitPciBusHandler().

◆ HalpPCIReleaseSynchronizationType2()

VOID NTAPI HalpPCIReleaseSynchronizationType2 ( IN PBUS_HANDLER  BusHandler,
IN KIRQL  Irql 
)

Definition at line 193 of file pcibus.c.

195{
196 PCI_TYPE2_CSE_BITS PciCfg2Cse;
197 PPCIPBUSDATA BusData = (PPCIPBUSDATA)BusHandler->BusData;
198
199 /* Clear CSE and bus number */
200 PciCfg2Cse.u.AsUCHAR = 0;
201 WRITE_PORT_UCHAR(BusData->Config.Type2.CSE, PciCfg2Cse.u.AsUCHAR);
202 WRITE_PORT_UCHAR(BusData->Config.Type2.Forward, 0);
203
204 /* Release the lock */
206}
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
union _PCI_TYPE2_CSE_BITS::@1730 u
UCHAR AsUCHAR
Definition: bus.h:210
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

◆ HalpPCIReleaseSynchronzationType1()

VOID NTAPI HalpPCIReleaseSynchronzationType1 ( IN PBUS_HANDLER  BusHandler,
IN KIRQL  Irql 
)

Definition at line 137 of file pcibus.c.

139{
140 PCI_TYPE1_CFG_BITS PciCfg1;
141
142 /* Clear the PCI Configuration Register */
143 PciCfg1.u.AsULONG = 0;
144 WRITE_PORT_ULONG(((PPCIPBUSDATA)BusHandler->BusData)->Config.Type1.Address,
145 PciCfg1.u.AsULONG);
146
147 /* Release the lock */
149}
VOID NTAPI WRITE_PORT_ULONG(IN PULONG Port, IN ULONG Value)
Definition: portio.c:123
union _PCI_TYPE1_CFG_BITS::@157 u

◆ HalpPCISynchronizeType1()

VOID NTAPI HalpPCISynchronizeType1 ( IN PBUS_HANDLER  BusHandler,
IN PCI_SLOT_NUMBER  Slot,
IN PKIRQL  Irql,
IN PPCI_TYPE1_CFG_BITS  PciCfg 
)

◆ HalpPCISynchronizeType2()

VOID NTAPI HalpPCISynchronizeType2 ( IN PBUS_HANDLER  BusHandler,
IN PCI_SLOT_NUMBER  Slot,
IN PKIRQL  Irql,
IN PPCI_TYPE2_ADDRESS_BITS  PciCfg 
)

◆ HalpPhase0GetPciDataByOffset()

ULONG HalpPhase0GetPciDataByOffset ( _In_ ULONG  Bus,
_In_ PCI_SLOT_NUMBER  PciSlot,
_Out_writes_bytes_all_(Length) PVOID  Buffer,
_In_ ULONG  Offset,
_In_ ULONG  Length 
)

Definition at line 368 of file pcibus.c.

374{
375 ULONG BytesLeft = Length;
376 PUCHAR BufferPtr = Buffer;
377 PCI_TYPE1_CFG_BITS PciCfg;
378
379#ifdef SARCH_XBOX
380 if (HalpXboxBlacklistedPCISlot(Bus, PciSlot))
381 {
383 return Length;
384 }
385#endif
386
387 PciCfg.u.AsULONG = 0;
388 PciCfg.u.bits.BusNumber = Bus;
389 PciCfg.u.bits.DeviceNumber = PciSlot.u.bits.DeviceNumber;
390 PciCfg.u.bits.FunctionNumber = PciSlot.u.bits.FunctionNumber;
391 PciCfg.u.bits.Enable = TRUE;
392
393 while (BytesLeft)
394 {
395 ULONG i;
396
397 PciCfg.u.bits.RegisterNumber = Offset / sizeof(ULONG);
399
400 i = PCIDeref[Offset % sizeof(ULONG)][BytesLeft % sizeof(ULONG)];
401 switch (i)
402 {
403 case 0:
404 {
406
407 /* Number of bytes read */
408 i = sizeof(ULONG);
409 break;
410 }
411 case 1:
412 {
414 Offset % sizeof(ULONG)));
415 break;
416 }
417 case 2:
418 {
420 Offset % sizeof(ULONG)));
421 break;
422 }
423
425 }
426
427 Offset += i;
428 BufferPtr += i;
429 BytesLeft -= i;
430 }
431
432 return Length;
433}
ULONG NTAPI READ_PORT_ULONG(IN PULONG Port)
Definition: portio.c:70
USHORT NTAPI READ_PORT_USHORT(IN PUSHORT Port)
Definition: portio.c:63
#define DEFAULT_UNREACHABLE
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
static const UCHAR PCIDeref[4][4]
Definition: pcibus.c:26
struct _PCI_SLOT_NUMBER::@5063::@5064 bits
struct _PCI_TYPE1_CFG_BITS::@157::@158 bits
uint32_t * PULONG
Definition: typedefs.h:59
uint16_t * PUSHORT
Definition: typedefs.h:56

Referenced by HalpConfigureDebuggingDevice(), and HalpFindMatchingDebuggingDevice().

◆ HalpPhase0SetPciDataByOffset()

ULONG HalpPhase0SetPciDataByOffset ( _In_ ULONG  Bus,
_In_ PCI_SLOT_NUMBER  PciSlot,
_In_reads_bytes_(Length) PVOID  Buffer,
_In_ ULONG  Offset,
_In_ ULONG  Length 
)

Definition at line 437 of file pcibus.c.

443{
444 ULONG BytesLeft = Length;
445 PUCHAR BufferPtr = Buffer;
446 PCI_TYPE1_CFG_BITS PciCfg;
447
448#ifdef SARCH_XBOX
449 if (HalpXboxBlacklistedPCISlot(Bus, PciSlot))
450 {
451 return 0;
452 }
453#endif
454
455 PciCfg.u.AsULONG = 0;
456 PciCfg.u.bits.BusNumber = Bus;
457 PciCfg.u.bits.DeviceNumber = PciSlot.u.bits.DeviceNumber;
458 PciCfg.u.bits.FunctionNumber = PciSlot.u.bits.FunctionNumber;
459 PciCfg.u.bits.Enable = TRUE;
460
461 while (BytesLeft)
462 {
463 ULONG i;
464
465 PciCfg.u.bits.RegisterNumber = Offset / sizeof(ULONG);
467
468 i = PCIDeref[Offset % sizeof(ULONG)][BytesLeft % sizeof(ULONG)];
469 switch (i)
470 {
471 case 0:
472 {
474
475 /* Number of bytes written */
476 i = sizeof(ULONG);
477 break;
478 }
479 case 1:
480 {
482 *BufferPtr);
483 break;
484 }
485 case 2:
486 {
488 *(PUSHORT)BufferPtr);
489 break;
490 }
491
493 }
494
495 Offset += i;
496 BufferPtr += i;
497 BytesLeft -= i;
498 }
499
500 return Length;
501}
VOID NTAPI WRITE_PORT_USHORT(IN PUSHORT Port, IN USHORT Value)
Definition: portio.c:115

Referenced by HalpConfigureDebuggingDevice().

◆ HalpQueryPciRegistryInfo()

PPCI_REGISTRY_INFO_INTERNAL NTAPI HalpQueryPciRegistryInfo ( VOID  )

Definition at line 978 of file pcibus.c.

979{
980#ifndef _MINIHAL_
981 WCHAR NameBuffer[8];
983 UNICODE_STRING KeyName, ConfigName, IdentName;
984 HANDLE KeyHandle, BusKeyHandle, CardListHandle;
986 UCHAR KeyBuffer[sizeof(CM_FULL_RESOURCE_DESCRIPTOR) + 100];
987 PKEY_VALUE_FULL_INFORMATION ValueInfo = (PVOID)KeyBuffer;
988 UCHAR PartialKeyBuffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) +
989 sizeof(PCI_CARD_DESCRIPTOR)];
990 PKEY_VALUE_PARTIAL_INFORMATION PartialValueInfo = (PVOID)PartialKeyBuffer;
991 KEY_FULL_INFORMATION KeyInformation;
993 PWSTR Tag;
994 ULONG i, ElementCount;
995 PCM_FULL_RESOURCE_DESCRIPTOR FullDescriptor;
996 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
997 PPCI_REGISTRY_INFO PciRegInfo;
998 PPCI_REGISTRY_INFO_INTERNAL PciRegistryInfo;
999 PPCI_CARD_DESCRIPTOR CardDescriptor;
1000
1001 /* Setup the object attributes for the key */
1003 L"\\Registry\\Machine\\Hardware\\Description\\"
1004 L"System\\MultiFunctionAdapter");
1006 &KeyName,
1008 NULL,
1009 NULL);
1010
1011 /* Open the key */
1012 Status = ZwOpenKey(&KeyHandle, KEY_READ, &ObjectAttributes);
1013 if (!NT_SUCCESS(Status)) return NULL;
1014
1015 /* Setup the receiving string */
1016 KeyName.Buffer = NameBuffer;
1017 KeyName.MaximumLength = sizeof(NameBuffer);
1018
1019 /* Setup the configuration and identifier key names */
1020 RtlInitUnicodeString(&ConfigName, L"Configuration Data");
1021 RtlInitUnicodeString(&IdentName, L"Identifier");
1022
1023 /* Keep looping for each ID */
1024 for (i = 0; TRUE; i++)
1025 {
1026 /* Setup the key name */
1029 &KeyName,
1031 KeyHandle,
1032 NULL);
1033
1034 /* Open it */
1035 Status = ZwOpenKey(&BusKeyHandle, KEY_READ, &ObjectAttributes);
1036 if (!NT_SUCCESS(Status))
1037 {
1038 /* None left, fail */
1040 return NULL;
1041 }
1042
1043 /* Read the registry data */
1044 Status = ZwQueryValueKey(BusKeyHandle,
1045 &IdentName,
1047 ValueInfo,
1048 sizeof(KeyBuffer),
1049 &ResultLength);
1050 if (!NT_SUCCESS(Status))
1051 {
1052 /* Failed, try the next one */
1053 ZwClose(BusKeyHandle);
1054 continue;
1055 }
1056
1057 /* Get the PCI Tag and validate it */
1058 Tag = (PWSTR)((ULONG_PTR)ValueInfo + ValueInfo->DataOffset);
1059 if ((Tag[0] != L'P') ||
1060 (Tag[1] != L'C') ||
1061 (Tag[2] != L'I') ||
1062 (Tag[3]))
1063 {
1064 /* Not a valid PCI entry, skip it */
1065 ZwClose(BusKeyHandle);
1066 continue;
1067 }
1068
1069 /* Now read our PCI structure */
1070 Status = ZwQueryValueKey(BusKeyHandle,
1071 &ConfigName,
1073 ValueInfo,
1074 sizeof(KeyBuffer),
1075 &ResultLength);
1076 ZwClose(BusKeyHandle);
1077 if (!NT_SUCCESS(Status)) continue;
1078
1079 /* We read it OK! Get the actual resource descriptors */
1080 FullDescriptor = (PCM_FULL_RESOURCE_DESCRIPTOR)
1081 ((ULONG_PTR)ValueInfo + ValueInfo->DataOffset);
1082 PartialDescriptor = (PCM_PARTIAL_RESOURCE_DESCRIPTOR)
1083 ((ULONG_PTR)FullDescriptor->
1084 PartialResourceList.PartialDescriptors);
1085
1086 /* Check if this is our PCI Registry Information */
1087 if (PartialDescriptor->Type == CmResourceTypeDeviceSpecific)
1088 {
1089 /* It is, stop searching */
1090 break;
1091 }
1092 }
1093
1094 /* Close the key */
1096
1097 /* Save the PCI information for later */
1098 PciRegInfo = (PPCI_REGISTRY_INFO)(PartialDescriptor + 1);
1099
1100 /* Assume no Card List entries */
1101 ElementCount = 0;
1102
1103 /* Set up for checking the PCI Card List key */
1105 L"\\Registry\\Machine\\System\\CurrentControlSet\\"
1106 L"Control\\PnP\\PCI\\CardList");
1108 &KeyName,
1110 NULL,
1111 NULL);
1112
1113 /* Attempt to open it */
1114 Status = ZwOpenKey(&CardListHandle, KEY_READ, &ObjectAttributes);
1115 if (NT_SUCCESS(Status))
1116 {
1117 /* It exists, so let's query it */
1118 Status = ZwQueryKey(CardListHandle,
1120 &KeyInformation,
1121 sizeof(KEY_FULL_INFORMATION),
1122 &ResultLength);
1123 if (!NT_SUCCESS(Status))
1124 {
1125 /* Failed to query, so no info */
1126 PciRegistryInfo = NULL;
1127 }
1128 else
1129 {
1130 /* Allocate the full structure */
1131 PciRegistryInfo =
1134 (KeyInformation.Values *
1135 sizeof(PCI_CARD_DESCRIPTOR)),
1136 TAG_HAL);
1137 if (PciRegistryInfo)
1138 {
1139 /* Get the first card descriptor entry */
1140 CardDescriptor = (PPCI_CARD_DESCRIPTOR)(PciRegistryInfo + 1);
1141
1142 /* Loop all the values */
1143 for (i = 0; i < KeyInformation.Values; i++)
1144 {
1145 /* Attempt to get the value */
1146 Status = ZwEnumerateValueKey(CardListHandle,
1147 i,
1149 PartialValueInfo,
1150 sizeof(PartialKeyBuffer),
1151 &ResultLength);
1152 if (!NT_SUCCESS(Status))
1153 {
1154 /* Something went wrong, stop the search */
1155 break;
1156 }
1157
1158 /* Make sure it is correctly sized */
1159 if (PartialValueInfo->DataLength == sizeof(PCI_CARD_DESCRIPTOR))
1160 {
1161 /* Sure is, copy it over */
1162 *CardDescriptor = *(PPCI_CARD_DESCRIPTOR)
1163 PartialValueInfo->Data;
1164
1165 /* One more Card List entry */
1166 ElementCount++;
1167
1168 /* Move to the next descriptor */
1169 CardDescriptor = (CardDescriptor + 1);
1170 }
1171 }
1172 }
1173 }
1174
1175 /* Close the Card List key */
1176 ZwClose(CardListHandle);
1177 }
1178 else
1179 {
1180 /* No key, no Card List */
1181 PciRegistryInfo = NULL;
1182 }
1183
1184 /* Check if we failed to get the full structure */
1185 if (!PciRegistryInfo)
1186 {
1187 /* Just allocate the basic structure then */
1188 PciRegistryInfo = ExAllocatePoolWithTag(NonPagedPool,
1190 TAG_HAL);
1191 if (!PciRegistryInfo) return NULL;
1192 }
1193
1194 /* Save the info we got */
1195 PciRegistryInfo->MajorRevision = PciRegInfo->MajorRevision;
1196 PciRegistryInfo->MinorRevision = PciRegInfo->MinorRevision;
1197 PciRegistryInfo->NoBuses = PCI_GET_NUM_OF_BUSES(PciRegInfo); // Don't use PciRegInfo->NoBuses directly
1198 PciRegistryInfo->HardwareMechanism = PciRegInfo->HardwareMechanism;
1199 PciRegistryInfo->ElementCount = ElementCount;
1200
1201 /* Return it */
1202 return PciRegistryInfo;
1203#else
1204 return NULL;
1205#endif
1206}
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define L(x)
Definition: resources.c:13
#define NonPagedPool
Definition: env_spec_w32.h:307
#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)
@ KeyFullInformation
Definition: nt_native.h:1136
@ KeyValuePartialInformation
Definition: nt_native.h:1185
@ KeyValueFullInformation
Definition: nt_native.h:1184
#define KEY_READ
Definition: nt_native.h:1026
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
NTSYSAPI NTSTATUS NTAPI RtlIntegerToUnicodeString(ULONG Value, ULONG Base, PUNICODE_STRING String)
short WCHAR
Definition: pedump.c:58
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
struct _CM_FULL_RESOURCE_DESCRIPTOR CM_FULL_RESOURCE_DESCRIPTOR
struct _CM_FULL_RESOURCE_DESCRIPTOR * PCM_FULL_RESOURCE_DESCRIPTOR
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR * PCM_PARTIAL_RESOURCE_DESCRIPTOR
#define CmResourceTypeDeviceSpecific
Definition: restypes.h:108
#define PCI_GET_NUM_OF_BUSES(PciRegInfo)
Retrieves the corrected number of buses from the PCI_REGISTRY_INFO structure.
Definition: pci.h:127
struct _PCI_CARD_DESCRIPTOR * PPCI_CARD_DESCRIPTOR
struct _PCI_REGISTRY_INFO * PPCI_REGISTRY_INFO
UCHAR MajorRevision
Definition: pci.h:111
UCHAR HardwareMechanism
Definition: pci.h:114
UCHAR MinorRevision
Definition: pci.h:112
uint16_t * PWSTR
Definition: typedefs.h:56
_In_ PGUID _In_ ULONG _Out_ PULONG ResultLength
Definition: ucxcontroller.h:83
_Must_inspect_result_ _In_ UCXENDPOINT _In_ PVOID Tag
Definition: ucxendpoint.h:325
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2705

Referenced by HalpInitializePciBus(), and HalpInitializePciStubs().

◆ HalpReadPCIConfig()

VOID NTAPI HalpReadPCIConfig ( IN PBUS_HANDLER  BusHandler,
IN PCI_SLOT_NUMBER  Slot,
IN PVOID  Buffer,
IN ULONG  Offset,
IN ULONG  Length 
)

Definition at line 257 of file pcibus.c.

262{
263 /* Validate the PCI Slot */
264 if (!HalpValidPCISlot(BusHandler, Slot))
265 {
266 /* Fill the buffer with invalid data */
268 }
269 else
270 {
271 /* Send the request */
272 HalpPCIConfig(BusHandler,
273 Slot,
274 Buffer,
275 Offset,
276 Length,
278 }
279}
BOOLEAN NTAPI HalpValidPCISlot(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot)
Definition: pcibus.c:329
VOID NTAPI HalpPCIConfig(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PUCHAR Buffer, IN ULONG Offset, IN ULONG Length, IN FncConfigIO *ConfigIO)
Definition: pcibus.c:219
FncConfigIO ConfigRead[3]
Definition: bus.h:147

Referenced by HaliPciInterfaceReadConfig(), HalpAllocateAndInitPciBusHandler(), HalpAssignPCISlotResources(), HalpDebugPciDumpBus(), HalpGetPciBridgeConfig(), HalpGetPCIData(), HalpInitializePciBus(), HalpIsValidPCIDevice(), HalpSetPCIData(), and HalpValidPCISlot().

◆ HalpRegisterPciDebuggingDeviceInfo()

VOID NTAPI HalpRegisterPciDebuggingDeviceInfo ( VOID  )

Definition at line 331 of file kdpci.c.

332{
333 ULONG i;
337 UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\"
338 L"CurrentControlSet\\Services\\PCI\\Debug");
340
341 PAGED_CODE();
342
343 for (i = 0; i < RTL_NUMBER_OF(HalpPciDebuggingDevice); ++i)
344 {
345 if (HalpPciDebuggingDevice[i].InUse)
346 {
348 break;
349 }
350 }
352 {
353 /* Nothing to register */
354 return;
355 }
356
358 if (!NT_SUCCESS(Status))
359 return;
360
361 for (i = 0; i < RTL_NUMBER_OF(HalpPciDebuggingDevice); ++i)
362 {
363 ULONG Value;
365
366 if (!HalpPciDebuggingDevice[i].InUse)
367 continue;
368
369 RtlInitEmptyUnicodeString(&KeyName, StringBuffer, sizeof(StringBuffer));
372 Handle,
373 &KeyName,
375 TRUE);
376 if (!NT_SUCCESS(Status))
377 continue;
378
381 ZwSetValueKey(KeyHandle,
382 &KeyName,
383 0,
384 REG_DWORD,
385 &Value,
386 sizeof(Value));
387
388 PciSlot.u.AsULONG = 0;
393 ZwSetValueKey(KeyHandle,
394 &KeyName,
395 0,
396 REG_DWORD,
397 &Value,
398 sizeof(Value));
399
401 }
402
404}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define RTL_CONSTANT_STRING(s)
Definition: combase.c:35
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:108
PCI_TYPE1_CFG_CYCLE_BITS HalpPciDebuggingDevice[2]
Definition: kdpci.c:31
WCHAR StringBuffer[156]
Definition: ldrinit.c:41
#define KEY_ALL_ACCESS
Definition: nt_native.h:1044
BOOLEAN HasDebuggingDevice
Definition: pci.c:32
#define REG_DWORD
Definition: sdbapi.c:615
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by HalReportResourceUsage().

◆ HalpSetCmosData()

ULONG NTAPI HalpSetCmosData ( _In_ ULONG  BusNumber,
_In_ ULONG  SlotNumber,
_In_reads_bytes_(Length) PVOID  Buffer,
_In_ ULONG  Length 
)

Definition at line 104 of file cmos.c.

109{
112 ULONG Len = Length;
113
114 /* Do nothing if we don't have a length */
115 if (!Length) return 0;
116
117 /* Acquire CMOS Lock */
119
120 /* Check if this is simple CMOS */
121 if (BusNumber == 0)
122 {
123 /* Loop the buffer up to 0xFF */
124 while ((Len > 0) && (Address < 0x100))
125 {
126 /* Write the data */
128
129 /* Update position and length */
130 Ptr++;
131 Address++;
132 Len--;
133 }
134 }
135 else if (BusNumber == 1)
136 {
137 /* Loop the buffer up to 0xFFFF */
138 while ((Len > 0) && (Address < 0x10000))
139 {
140 /* Write the data */
142
143 /* Update position and length */
144 Ptr++;
145 Address++;
146 Len--;
147 }
148 }
149
150 /* Release CMOS Lock */
152
153 /* Return length read */
154 return Length - Len;
155}
VOID NTAPI HalpWriteCmos(_In_ UCHAR Reg, _In_ UCHAR Value)
Definition: cmos.c:123

Referenced by HalpcSetCmosData(), and HalSetBusDataByOffset().

◆ HalpSetPCIData()

ULONG NTAPI HalpSetPCIData ( IN PBUS_HANDLER  BusHandler,
IN PBUS_HANDLER  RootBusHandler,
IN ULONG  SlotNumber,
IN PVOID  Buffer,
IN ULONG  Offset,
IN ULONG  Length 
)

Definition at line 587 of file pcibus.c.

593{
594 PCI_SLOT_NUMBER Slot;
595 UCHAR PciBuffer[PCI_COMMON_HDR_LENGTH];
597 ULONG Len = 0;
598
599 Slot.u.AsULONG = SlotNumber;
600#ifdef SARCH_XBOX
601 if (HalpXboxBlacklistedPCISlot(BusHandler->BusNumber, Slot))
602 return 0;
603#endif
604
605 /* Normalize the length */
606 if (Length > sizeof(PCI_COMMON_CONFIG)) Length = sizeof(PCI_COMMON_CONFIG);
607
608 /* Check if this is a vendor-specific read */
610 {
611 /* Read the header */
612 HalpReadPCIConfig(BusHandler, Slot, PciConfig, 0, sizeof(ULONG));
613
614 /* Make sure the vendor is valid */
615 if (PciConfig->VendorID == PCI_INVALID_VENDORID) return 0;
616 }
617 else
618 {
619 /* Read the entire header and validate the vendor ID */
621 HalpReadPCIConfig(BusHandler, Slot, PciConfig, 0, Len);
622 if (PciConfig->VendorID == PCI_INVALID_VENDORID) return 0;
623
624 /* Return what's after the offset and normalize */
625 Len -= Offset;
626 if (Len > Length) Len = Length;
627
628 /* Copy the specific caller data */
629 RtlMoveMemory(PciBuffer + Offset, Buffer, Len);
630
631 /* Write the actual configuration data */
632 HalpWritePCIConfig(BusHandler, Slot, PciBuffer + Offset, Offset, Len);
633
634 /* Update buffer and offset, decrement total length */
635 Offset += Len;
637 Length -= Len;
638 }
639
640 /* Now we still have something to copy */
641 if (Length)
642 {
643 /* Check if it's vendor-specific data */
645 {
646 /* Read it now */
647 HalpWritePCIConfig(BusHandler, Slot, Buffer, Offset, Length);
648 Len += Length;
649 }
650 }
651
652 /* Update the total length read */
653 return Len;
654}

Referenced by HalpAllocateAndInitPciBusHandler(), and HalSetBusDataByOffset().

◆ HalpTranslateBusAddress()

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

Definition at line 77 of file busemul.c.

82{
83 /* Translation is easy */
85 return TRUE;
86}

Referenced by HalpInitNonBusHandler().

◆ HalpTranslateIsaBusAddress()

BOOLEAN NTAPI HalpTranslateIsaBusAddress ( IN PBUS_HANDLER  BusHandler,
IN PBUS_HANDLER  RootHandler,
IN PHYSICAL_ADDRESS  BusAddress,
IN OUT PULONG  AddressSpace,
OUT PPHYSICAL_ADDRESS  TranslatedAddress 
)

Definition at line 21 of file isabus.c.

26{
28
29 /* Use system translation */
31 RootHandler,
35
36 /* If it didn't work and it was memory address space... */
37 if (!(Status) && (*AddressSpace == 0))
38 {
39 /* Try EISA translation instead */
41 BusHandler->BusNumber,
45 }
46
47 /* Return the result */
48 return Status;
49}
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
BOOLEAN NTAPI HalTranslateBusAddress(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
Definition: bus.c:140
@ Eisa
Definition: restypes.h:124

Referenced by HalpRegisterInternalBusHandlers().

◆ HalpTranslateSystemBusAddress()

BOOLEAN NTAPI HalpTranslateSystemBusAddress ( IN PBUS_HANDLER  BusHandler,
IN PBUS_HANDLER  RootHandler,
IN PHYSICAL_ADDRESS  BusAddress,
IN OUT PULONG  AddressSpace,
OUT PPHYSICAL_ADDRESS  TranslatedAddress 
)

Definition at line 21 of file sysbus.c.

26{
27 PSUPPORTED_RANGE Range = NULL;
28
29 /* Check what kind of address space this is */
30 switch (*AddressSpace)
31 {
32 /* Memory address */
33 case 0:
34
35 /* Loop all prefetch memory */
36 for (Range = &BusHandler->BusAddresses->PrefetchMemory;
37 Range;
38 Range = Range->Next)
39 {
40 /* Check if it's in a valid range */
41 if ((BusAddress.QuadPart >= Range->Base) &&
42 (BusAddress.QuadPart <= Range->Limit))
43 {
44 /* Get out */
45 break;
46 }
47 }
48
49 /* Check if we haven't found anything yet */
50 if (!Range)
51 {
52 /* Loop all bus memory */
53 for (Range = &BusHandler->BusAddresses->Memory;
54 Range;
55 Range = Range->Next)
56 {
57 /* Check if it's in a valid range */
58 if ((BusAddress.QuadPart >= Range->Base) &&
59 (BusAddress.QuadPart <= Range->Limit))
60 {
61 /* Get out */
62 break;
63 }
64 }
65 }
66
67 /* Done */
68 break;
69
70 /* I/O Space */
71 case 1:
72
73 /* Loop all bus I/O memory */
74 for (Range = &BusHandler->BusAddresses->IO;
75 Range;
76 Range = Range->Next)
77 {
78 /* Check if it's in a valid range */
79 if ((BusAddress.QuadPart >= Range->Base) &&
80 (BusAddress.QuadPart <= Range->Limit))
81 {
82 /* Get out */
83 break;
84 }
85 }
86
87 /* Done */
88 break;
89 }
90
91 /* Check if we found a range */
92 if (Range)
93 {
94 /* Do the translation and return the kind of address space this is */
98 {
99 /* Different than what the old HAL would do */
100 DPRINT1("Translation of %I64x is %I64x %s\n",
102 Range->SystemAddressSpace ? "In I/O Space" : "In RAM");
103 }
105 return TRUE;
106 }
107
108 /* Nothing found */
109 DPRINT1("Translation of %I64x failed!\n", BusAddress.QuadPart);
110 return FALSE;
111}
ULONG SystemAddressSpace
Definition: haltypes.h:2032
LONGLONG SystemBase
Definition: haltypes.h:2033
LONGLONG Base
Definition: haltypes.h:2034
LONGLONG Limit
Definition: haltypes.h:2035
struct _SUPPORTED_RANGE * Next
Definition: haltypes.h:2031

Referenced by HalpRegisterInternalBusHandlers(), and HalpTranslateIsaBusAddress().

◆ HalpValidPCISlot()

BOOLEAN NTAPI HalpValidPCISlot ( IN PBUS_HANDLER  BusHandler,
IN PCI_SLOT_NUMBER  Slot 
)

Definition at line 329 of file pcibus.c.

331{
332 PCI_SLOT_NUMBER MultiSlot;
333 PPCIPBUSDATA BusData = (PPCIPBUSDATA)BusHandler->BusData;
334 UCHAR HeaderType;
335 //ULONG Device;
336
337 /* Simple validation */
338 if (Slot.u.bits.Reserved) return FALSE;
339 if (Slot.u.bits.DeviceNumber >= BusData->MaxDevice) return FALSE;
340
341#ifdef SARCH_XBOX
342 if (HalpXboxBlacklistedPCISlot(BusHandler->BusNumber, Slot))
343 return FALSE;
344#endif
345
346 /* Function 0 doesn't need checking */
347 if (!Slot.u.bits.FunctionNumber) return TRUE;
348
349 /* Functions 0+ need Multi-Function support, so check the slot */
350 //Device = Slot.u.bits.DeviceNumber;
351 MultiSlot = Slot;
352 MultiSlot.u.bits.FunctionNumber = 0;
353
354 /* Send function 0 request to get the header back */
355 HalpReadPCIConfig(BusHandler,
356 MultiSlot,
357 &HeaderType,
358 FIELD_OFFSET(PCI_COMMON_CONFIG, HeaderType),
359 sizeof(UCHAR));
360
361 /* Now make sure the header is multi-function */
362 if (!(HeaderType & PCI_MULTIFUNCTION) || (HeaderType == 0xFF)) return FALSE;
363 return TRUE;
364}
if(dx< 0)
Definition: linetemp.h:194
#define PCI_MULTIFUNCTION
Definition: iotypes.h:3619

Referenced by HalpReadPCIConfig(), and HalpWritePCIConfig().

◆ HalpWritePCIConfig()

VOID NTAPI HalpWritePCIConfig ( IN PBUS_HANDLER  BusHandler,
IN PCI_SLOT_NUMBER  Slot,
IN PVOID  Buffer,
IN ULONG  Offset,
IN ULONG  Length 
)

Definition at line 283 of file pcibus.c.

288{
289 /* Validate the PCI Slot */
290 if (HalpValidPCISlot(BusHandler, Slot))
291 {
292 /* Send the request */
293 HalpPCIConfig(BusHandler,
294 Slot,
295 Buffer,
296 Offset,
297 Length,
299 }
300}
FncConfigIO ConfigWrite[3]
Definition: bus.h:148

Referenced by HaliPciInterfaceWriteConfig(), HalpAllocateAndInitPciBusHandler(), HalpAssignPCISlotResources(), HalpDebugPciDumpBus(), and HalpSetPCIData().

◆ TYPE1_DEFINE() [1/6]

TYPE1_DEFINE ( HalpPCIReadUcharType1  )

◆ TYPE1_DEFINE() [2/6]

TYPE1_DEFINE ( HalpPCIReadUlongType1  )

◆ TYPE1_DEFINE() [3/6]

TYPE1_DEFINE ( HalpPCIReadUshortType1  )

◆ TYPE1_DEFINE() [4/6]

TYPE1_DEFINE ( HalpPCIWriteUcharType1  )

◆ TYPE1_DEFINE() [5/6]

TYPE1_DEFINE ( HalpPCIWriteUlongType1  )

◆ TYPE1_DEFINE() [6/6]

TYPE1_DEFINE ( HalpPCIWriteUshortType1  )

◆ TYPE2_DEFINE() [1/6]

TYPE2_DEFINE ( HalpPCIReadUcharType2  )

◆ TYPE2_DEFINE() [2/6]

TYPE2_DEFINE ( HalpPCIReadUlongType2  )

◆ TYPE2_DEFINE() [3/6]

TYPE2_DEFINE ( HalpPCIReadUshortType2  )

◆ TYPE2_DEFINE() [4/6]

TYPE2_DEFINE ( HalpPCIWriteUcharType2  )

◆ TYPE2_DEFINE() [5/6]

TYPE2_DEFINE ( HalpPCIWriteUlongType2  )

◆ TYPE2_DEFINE() [6/6]

TYPE2_DEFINE ( HalpPCIWriteUshortType2  )

Variable Documentation

◆ HalpAllBusHandlers

LIST_ENTRY HalpAllBusHandlers
extern

◆ HalpBusType

◆ HalpFakePciBusHandler

◆ HalpMaxPciBus

ULONG HalpMaxPciBus

Definition at line 655 of file bus.h.

Referenced by HalGetBusDataByOffset().

◆ HalpMinPciBus

ULONG HalpMinPciBus
extern

Definition at line 21 of file pcibus.c.

Referenced by HalGetBusDataByOffset().

◆ HalpPCIConfigInitialized

BOOLEAN HalpPCIConfigInitialized
extern

Definition at line 20 of file pcibus.c.

Referenced by HalGetBusDataByOffset(), HalpInitializePciStubs(), and HalSetBusDataByOffset().

◆ PCIConfigHandler

◆ PCIConfigHandlerType1

const PCI_CONFIG_HANDLER PCIConfigHandlerType1
extern

Definition at line 35 of file pcibus.c.

Referenced by HalpAllocateAndInitPciBusHandler(), and HalpInitializePciStubs().

◆ PCIConfigHandlerType2

const PCI_CONFIG_HANDLER PCIConfigHandlerType2
extern

Definition at line 57 of file pcibus.c.

Referenced by HalpAllocateAndInitPciBusHandler(), and HalpInitializePciStubs().