ReactOS  0.4.13-dev-922-g2fbff73
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
 

Macros

#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)
 

Typedefs

typedef struct _PCIPBUSDATA PCIPBUSDATA
 
typedef struct _PCIPBUSDATAPPCIPBUSDATA
 
typedef ULONG(NTAPIFncConfigIO) (IN PPCIPBUSDATA BusData, IN PVOID State, IN PUCHAR Buffer, IN ULONG Offset)
 
typedef VOID(NTAPIFncSync) (IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PKIRQL Irql, IN PVOID State)
 
typedef VOID(NTAPIFncReleaseSync) (IN PBUS_HANDLER BusHandler, IN KIRQL Irql)
 
typedef struct _PCI_CONFIG_HANDLER PCI_CONFIG_HANDLER
 
typedef struct _PCI_CONFIG_HANDLERPPCI_CONFIG_HANDLER
 
typedef struct _PCI_REGISTRY_INFO_INTERNAL PCI_REGISTRY_INFO_INTERNAL
 
typedef struct _PCI_REGISTRY_INFO_INTERNALPPCI_REGISTRY_INFO_INTERNAL
 

Functions

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 HalpPCIReleaseSynchronzationType2 (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 HalpGetSystemInterruptVector (ULONG BusNumber, ULONG BusInterruptLevel, ULONG BusInterruptVector, PKIRQL Irql, PKAFFINITY Affinity)
 
ULONG NTAPI HalpGetCmosData (IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Length)
 
ULONG NTAPI HalpSetCmosData (IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Length)
 
ULONG NTAPI HalpGetPCIData (IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootBusHandler, IN PCI_SLOT_NUMBER SlotNumber, IN PUCHAR Buffer, IN ULONG Offset, IN ULONG Length)
 
ULONG NTAPI HalpSetPCIData (IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootBusHandler, IN PCI_SLOT_NUMBER SlotNumber, IN PUCHAR 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)
 
VOID NTAPI HalpInitializePciBus (VOID)
 

Variables

ULONG HalpBusType
 
BOOLEAN HalpPCIConfigInitialized
 
BUS_HANDLER HalpFakePciBusHandler
 
ULONG HalpMinPciBus
 
ULONG HalpMaxPciBus
 

Macro Definition Documentation

◆ PASTE2

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

Definition at line 6 of file bus.h.

◆ POINTER_TO_

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

Definition at line 7 of file bus.h.

◆ READ_FROM

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

Definition at line 8 of file bus.h.

◆ TYPE1_DEFINE

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

Definition at line 23 of file bus.h.

◆ TYPE1_END

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

Definition at line 35 of file bus.h.

◆ TYPE1_READ

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

Definition at line 42 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);
GLint GLint GLint GLint GLint x
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
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define TYPE_DEFINE(x, y)
Definition: bus.h:14
unsigned int ULONG
Definition: retypes.h:1

Definition at line 29 of file bus.h.

◆ TYPE1_WRITE

#define TYPE1_WRITE (   x,
  y 
)
Value:
WRITE_TO(y)((POINTER_TO_(y))(BusData->Config.Type1.Data + i), \
*((POINTER_TO_(y))Buffer)); \
TYPE1_END(y)
#define POINTER_TO_(x)
Definition: bus.h:7
#define TYPE1_START(x, y)
Definition: bus.h:29
GLint GLint GLint GLint GLint x
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
Definition: bufpool.h:45
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Definition at line 51 of file bus.h.

◆ TYPE2_DEFINE

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

Definition at line 24 of file bus.h.

◆ TYPE2_END

#define TYPE2_END   TYPE1_END

Definition at line 37 of file bus.h.

◆ TYPE2_READ

#define TYPE2_READ (   x,
  y 
)
Value:
*((POINTER_TO_(y))Buffer) = \
READ_FROM(y)((POINTER_TO_(y))(ULONG)PciCfg->u.AsUSHORT); \
TYPE2_END(y)
#define POINTER_TO_(x)
Definition: bus.h:7
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define TYPE2_START(x, y)
Definition: bus.h:60
Definition: bufpool.h:45
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
unsigned int ULONG
Definition: retypes.h:1

Definition at line 68 of file bus.h.

◆ TYPE2_START

#define TYPE2_START (   x,
  y 
)
Value:
{ \
PciCfg->u.bits.RegisterNumber = (USHORT)Offset;
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define TYPE_DEFINE(x, y)
Definition: bus.h:14
unsigned short USHORT
Definition: pedump.c:61

Definition at line 60 of file bus.h.

◆ TYPE2_WRITE

#define TYPE2_WRITE (   x,
  y 
)
Value:
WRITE_TO(y)((POINTER_TO_(y))(ULONG)PciCfg->u.AsUSHORT, \
*((POINTER_TO_(y))Buffer)); \
TYPE2_END(y)
#define POINTER_TO_(x)
Definition: bus.h:7
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define TYPE2_START(x, y)
Definition: bus.h:60
Definition: bufpool.h:45
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
unsigned int ULONG
Definition: retypes.h:1

Definition at line 77 of file bus.h.

◆ TYPE_DEFINE

#define TYPE_DEFINE (   x,
  y 
)
Value:
x( \
IN PPCIPBUSDATA BusData, \
IN y PciCfg, \
)
#define IN
Definition: typedefs.h:38
unsigned char * PUCHAR
Definition: retypes.h:3
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
Definition: bufpool.h:45
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
unsigned int ULONG
Definition: retypes.h:1

Definition at line 14 of file bus.h.

◆ WRITE_TO

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

Definition at line 9 of file bus.h.

Typedef Documentation

◆ FncConfigIO

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

Definition at line 104 of file bus.h.

◆ FncReleaseSync

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

Definition at line 120 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 112 of file bus.h.

◆ PCI_CONFIG_HANDLER

◆ PCI_REGISTRY_INFO_INTERNAL

◆ PCIPBUSDATA

◆ PPCI_CONFIG_HANDLER

◆ PPCI_REGISTRY_INFO_INTERNAL

◆ PPCIPBUSDATA

Function Documentation

◆ 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 490 of file pci.c.

498 {
499  KeBugCheck(0);
500  return STATUS_SUCCESS;
501 }
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1507
return STATUS_SUCCESS
Definition: btrfs.c:2777

◆ HalpGetCmosData()

ULONG NTAPI HalpGetCmosData ( IN ULONG  BusNumber,
IN ULONG  SlotNumber,
IN PVOID  Buffer,
IN ULONG  Length 
)

Definition at line 47 of file cmos.c.

51 {
54  ULONG Len = Length;
55 
56  /* FIXME: Acquire CMOS Lock */
57 
58  /* Do nothing if we don't have a length */
59  if (!Length) return 0;
60 
61  /* Check if this is simple CMOS */
62  if (!BusNumber)
63  {
64  /* Loop the buffer up to 0xFF */
65  while ((Len > 0) && (Address < 0x100))
66  {
67  /* Read the data */
69 
70  /* Update position and length */
71  Ptr++;
72  Address++;
73  Len--;
74  }
75  }
76  else if (BusNumber == 1)
77  {
78  /* Loop the buffer up to 0xFFFF */
79  while ((Len > 0) && (Address < 0x10000))
80  {
81  /* Write the data */
83 
84  /* Update position and length */
85  Ptr++;
86  Address++;
87  Len--;
88  }
89  }
90 
91  /* FIXME: Release the CMOS Lock */
92 
93  /* Return length read */
94  return Length - Len;
95 }
unsigned char * PUCHAR
Definition: retypes.h:3
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
static WCHAR Address[46]
Definition: ping.c:68
UCHAR FORCEINLINE HalpReadCmos(IN UCHAR Reg)
Definition: cmos.c:24
Definition: bufpool.h:45
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:156
#define Len
Definition: deflate.h:82
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG _In_ ULONG SlotNumber
Definition: halfuncs.h:156
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned int ULONG
Definition: retypes.h:1

◆ HalpGetPCIData()

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

Definition at line 338 of file pci.c.

344 {
345  UCHAR PciBuffer[PCI_COMMON_HDR_LENGTH];
346  PPCI_COMMON_CONFIG PciConfig = (PPCI_COMMON_CONFIG)PciBuffer;
347  ULONG Len = 0;
348 
349  /* Normalize the length */
350  if (Length > sizeof(PCI_COMMON_CONFIG)) Length = sizeof(PCI_COMMON_CONFIG);
351 
352  /* Check if this is a vendor-specific read */
354  {
355  /* Read the header */
356  HalpReadPCIConfig(BusHandler, Slot, PciConfig, 0, sizeof(ULONG));
357 
358  /* Make sure the vendor is valid */
359  if (PciConfig->VendorID == PCI_INVALID_VENDORID) return 0;
360  }
361  else
362  {
363  /* Read the entire header */
365  HalpReadPCIConfig(BusHandler, Slot, PciConfig, 0, Len);
366 
367  /* Validate the vendor ID */
368  if (PciConfig->VendorID == PCI_INVALID_VENDORID)
369  {
370  /* It's invalid, but we want to return this much */
371  PciConfig->VendorID = PCI_INVALID_VENDORID;
372  Len = sizeof(USHORT);
373  }
374 
375  /* Now check if there's space left */
376  if (Len < Offset) return 0;
377 
378  /* There is, so return what's after the offset and normalize */
379  Len -= Offset;
380  if (Len > Length) Len = Length;
381 
382  /* Copy the data into the caller's buffer */
383  RtlMoveMemory(Buffer, PciBuffer + Offset, Len);
384 
385  /* Update buffer and offset, decrement total length */
386  Offset += Len;
387  Buffer += Len;
388  Length -= Len;
389  }
390 
391  /* Now we still have something to copy */
392  if (Length)
393  {
394  /* Check if it's vendor-specific data */
396  {
397  /* Read it now */
398  HalpReadPCIConfig(BusHandler, Slot, Buffer, Offset, Length);
399  Len += Length;
400  }
401  }
402 
403  /* Update the total length read */
404  return Len;
405 }
struct _PCI_COMMON_CONFIG * PPCI_COMMON_CONFIG
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
Definition: bufpool.h:45
VOID NTAPI HalpReadPCIConfig(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pci.c:255
#define PCI_INVALID_VENDORID
Definition: iotypes.h:3244
#define Len
Definition: deflate.h:82
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1
#define PCI_COMMON_HDR_LENGTH
Definition: iotypes.h:3237

Referenced by HalGetBusDataByOffset(), and HalpAllocateAndInitPciBusHandler().

◆ HalpGetSystemInterruptVector()

ULONG NTAPI HalpGetSystemInterruptVector ( ULONG  BusNumber,
ULONG  BusInterruptLevel,
ULONG  BusInterruptVector,
PKIRQL  Irql,
PKAFFINITY  Affinity 
)

◆ HalpInitializePciBus()

VOID NTAPI HalpInitializePciBus ( VOID  )

Definition at line 770 of file pci.c.

771 {
772  /* Initialize the stubs */
774 
775  /* FIXME: Initialize NMI Crash Flag */
776 }
VOID NTAPI HalpInitializePciStubs(VOID)
Definition: pci.c:674

◆ HalpPCIReleaseSynchronzationType1()

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

Definition at line 133 of file pci.c.

135 {
136  PCI_TYPE1_CFG_BITS PciCfg1;
137 
138  /* Clear the PCI Configuration Register */
139  PciCfg1.u.AsULONG = 0;
140  WRITE_PORT_ULONG(((PPCIPBUSDATA)BusHandler->BusData)->Config.Type1.Address,
141  PciCfg1.u.AsULONG);
142 
143  /* Release the lock */
145  KeLowerIrql(Irql);
146 }
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
_Out_ PKIRQL Irql
Definition: csq.h:179
KSPIN_LOCK HalpPCIConfigLock
Definition: pci.c:19
VOID NTAPI WRITE_PORT_ULONG(IN PULONG Port, IN ULONG Value)
Definition: portio.c:123
VOID FASTCALL KiReleaseSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: ntoskrnl.c:39
union _PCI_TYPE1_CFG_BITS::@1442 u
ULONG AsULONG
Definition: bus.h:192

◆ HalpPCIReleaseSynchronzationType2()

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

Definition at line 190 of file pci.c.

192 {
193  PCI_TYPE2_CSE_BITS PciCfg2Cse;
194  PPCIPBUSDATA BusData = (PPCIPBUSDATA)BusHandler->BusData;
195 
196  /* Clear CSE and bus number */
197  PciCfg2Cse.u.AsUCHAR = 0;
198  WRITE_PORT_UCHAR(BusData->Config.Type2.CSE, PciCfg2Cse.u.AsUCHAR);
199  WRITE_PORT_UCHAR(BusData->Config.Type2.Forward, 0);
200 
201  /* Release the lock */
203  KeLowerIrql(Irql);
204 }
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
struct _PCIPBUSDATA::@1403::@1405 Type2
_Out_ PKIRQL Irql
Definition: csq.h:179
KSPIN_LOCK HalpPCIConfigLock
Definition: pci.c:19
VOID FASTCALL KiReleaseSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: ntoskrnl.c:39
union _PCIPBUSDATA::@1403 Config
union _PCI_TYPE2_CSE_BITS::@1444 u
struct _PCIPBUSDATA * PPCIPBUSDATA
UCHAR AsUCHAR
Definition: bus.h:210
void WRITE_PORT_UCHAR(PUCHAR Address, UCHAR Value)
Definition: mach.c:539

◆ HalpPCISynchronizeType1()

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

Definition at line 114 of file pci.c.

118 {
119  /* Setup the PCI Configuration Register */
120  PciCfg1->u.AsULONG = 0;
121  PciCfg1->u.bits.BusNumber = BusHandler->BusNumber;
122  PciCfg1->u.bits.DeviceNumber = Slot.u.bits.DeviceNumber;
123  PciCfg1->u.bits.FunctionNumber = Slot.u.bits.FunctionNumber;
124  PciCfg1->u.bits.Enable = TRUE;
125 
126  /* Acquire the lock */
129 }
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define TRUE
Definition: types.h:120
_Out_ PKIRQL Irql
Definition: csq.h:179
KSPIN_LOCK HalpPCIConfigLock
Definition: pci.c:19
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
VOID FASTCALL KiAcquireSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: ntoskrnl.c:32

◆ HalpPCISynchronizeType2()

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

Definition at line 159 of file pci.c.

163 {
164  PCI_TYPE2_CSE_BITS PciCfg2Cse;
165  PPCIPBUSDATA BusData = (PPCIPBUSDATA)BusHandler->BusData;
166 
167  /* Setup the configuration register */
168  PciCfg->u.AsUSHORT = 0;
169  PciCfg->u.bits.Agent = (USHORT)Slot.u.bits.DeviceNumber;
170  PciCfg->u.bits.AddressBase = (USHORT)BusData->Config.Type2.Base;
171 
172  /* Acquire the lock */
175 
176  /* Setup the CSE Register */
177  PciCfg2Cse.u.AsUCHAR = 0;
178  PciCfg2Cse.u.bits.Enable = TRUE;
179  PciCfg2Cse.u.bits.FunctionNumber = (UCHAR)Slot.u.bits.FunctionNumber;
180  PciCfg2Cse.u.bits.Key = -1;
181 
182  /* Write the bus number and CSE */
183  WRITE_PORT_UCHAR(BusData->Config.Type2.Forward,
184  (UCHAR)BusHandler->BusNumber);
185  WRITE_PORT_UCHAR(BusData->Config.Type2.CSE, PciCfg2Cse.u.AsUCHAR);
186 }
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define TRUE
Definition: types.h:120
struct _PCIPBUSDATA::@1403::@1405 Type2
_Out_ PKIRQL Irql
Definition: csq.h:179
KSPIN_LOCK HalpPCIConfigLock
Definition: pci.c:19
union _PCIPBUSDATA::@1403 Config
union _PCI_TYPE2_CSE_BITS::@1444 u
unsigned char UCHAR
Definition: xmlstorage.h:181
struct _PCI_TYPE2_CSE_BITS::@1444::@1445 bits
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
unsigned short USHORT
Definition: pedump.c:61
VOID FASTCALL KiAcquireSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: ntoskrnl.c:32
struct _PCIPBUSDATA * PPCIPBUSDATA
UCHAR AsUCHAR
Definition: bus.h:210
void WRITE_PORT_UCHAR(PUCHAR Address, UCHAR Value)
Definition: mach.c:539

◆ 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 255 of file pci.c.

260 {
261  /* Validate the PCI Slot */
262  if (!HalpValidPCISlot(BusHandler, Slot))
263  {
264  /* Fill the buffer with invalid data */
266  }
267  else
268  {
269  /* Send the request */
270  HalpPCIConfig(BusHandler,
271  Slot,
272  Buffer,
273  Offset,
274  Length,
276  }
277 }
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: pci.c:217
FncConfigIO ConfigRead[3]
Definition: bus.h:129
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
Definition: bufpool.h:45
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
BOOLEAN NTAPI HalpValidPCISlot(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot)
Definition: pci.c:302
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:593
PCI_CONFIG_HANDLER PCIConfigHandler
Definition: pci.c:20

◆ HalpSetCmosData()

ULONG NTAPI HalpSetCmosData ( IN ULONG  BusNumber,
IN ULONG  SlotNumber,
IN PVOID  Buffer,
IN ULONG  Length 
)

Definition at line 99 of file cmos.c.

103 {
104  PUCHAR Ptr = (PUCHAR)Buffer;
106  ULONG Len = Length;
107 
108  /* FIXME: Acquire CMOS Lock */
109 
110  /* Do nothing if we don't have a length */
111  if (!Length) return 0;
112 
113  /* Check if this is simple CMOS */
114  if (!BusNumber)
115  {
116  /* Loop the buffer up to 0xFF */
117  while ((Len > 0) && (Address < 0x100))
118  {
119  /* Write the data */
121 
122  /* Update position and length */
123  Ptr++;
124  Address++;
125  Len--;
126  }
127  }
128  else if (BusNumber == 1)
129  {
130  /* Loop the buffer up to 0xFFFF */
131  while ((Len > 0) && (Address < 0x10000))
132  {
133  /* Write the data */
135 
136  /* Update position and length */
137  Ptr++;
138  Address++;
139  Len--;
140  }
141  }
142 
143  /* FIXME: Release the CMOS Lock */
144 
145  /* Return length read */
146  return Length - Len;
147 }
VOID FORCEINLINE HalpWriteCmos(IN UCHAR Reg, IN UCHAR Value)
Definition: cmos.c:35
unsigned char * PUCHAR
Definition: retypes.h:3
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
static WCHAR Address[46]
Definition: ping.c:68
Definition: bufpool.h:45
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:156
#define Len
Definition: deflate.h:82
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG _In_ ULONG SlotNumber
Definition: halfuncs.h:156
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned int ULONG
Definition: retypes.h:1

◆ HalpSetPCIData()

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

Definition at line 409 of file pci.c.

415 {
416  UCHAR PciBuffer[PCI_COMMON_HDR_LENGTH];
417  PPCI_COMMON_CONFIG PciConfig = (PPCI_COMMON_CONFIG)PciBuffer;
418  ULONG Len = 0;
419 
420  /* Normalize the length */
421  if (Length > sizeof(PCI_COMMON_CONFIG)) Length = sizeof(PCI_COMMON_CONFIG);
422 
423  /* Check if this is a vendor-specific read */
425  {
426  /* Read the header */
427  HalpReadPCIConfig(BusHandler, Slot, PciConfig, 0, sizeof(ULONG));
428 
429  /* Make sure the vendor is valid */
430  if (PciConfig->VendorID == PCI_INVALID_VENDORID) return 0;
431  }
432  else
433  {
434  /* Read the entire header and validate the vendor ID */
436  HalpReadPCIConfig(BusHandler, Slot, PciConfig, 0, Len);
437  if (PciConfig->VendorID == PCI_INVALID_VENDORID) return 0;
438 
439  /* Return what's after the offset and normalize */
440  Len -= Offset;
441  if (Len > Length) Len = Length;
442 
443  /* Copy the specific caller data */
444  RtlMoveMemory(PciBuffer + Offset, Buffer, Len);
445 
446  /* Write the actual configuration data */
447  HalpWritePCIConfig(BusHandler, Slot, PciBuffer + Offset, Offset, Len);
448 
449  /* Update buffer and offset, decrement total length */
450  Offset += Len;
451  Buffer += Len;
452  Length -= Len;
453  }
454 
455  /* Now we still have something to copy */
456  if (Length)
457  {
458  /* Check if it's vendor-specific data */
460  {
461  /* Read it now */
462  HalpWritePCIConfig(BusHandler, Slot, Buffer, Offset, Length);
463  Len += Length;
464  }
465  }
466 
467  /* Update the total length read */
468  return Len;
469 }
struct _PCI_COMMON_CONFIG * PPCI_COMMON_CONFIG
VOID NTAPI HalpWritePCIConfig(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pci.c:281
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
Definition: bufpool.h:45
VOID NTAPI HalpReadPCIConfig(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pci.c:255
#define PCI_INVALID_VENDORID
Definition: iotypes.h:3244
#define Len
Definition: deflate.h:82
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned int ULONG
Definition: retypes.h:1
#define PCI_COMMON_HDR_LENGTH
Definition: iotypes.h:3237

Referenced by HalpAllocateAndInitPciBusHandler(), and HalSetBusDataByOffset().

◆ HalpValidPCISlot()

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

Definition at line 302 of file pci.c.

304 {
305  PCI_SLOT_NUMBER MultiSlot;
306  PPCIPBUSDATA BusData = (PPCIPBUSDATA)BusHandler->BusData;
307  UCHAR HeaderType;
308  ULONG Device;
309 
310  /* Simple validation */
311  if (Slot.u.bits.Reserved) return FALSE;
312  if (Slot.u.bits.DeviceNumber >= BusData->MaxDevice) return FALSE;
313 
314  /* Function 0 doesn't need checking */
315  if (!Slot.u.bits.FunctionNumber) return TRUE;
316 
317  /* Functions 0+ need Multi-Function support, so check the slot */
318  Device = Slot.u.bits.DeviceNumber;
319  MultiSlot = Slot;
320  MultiSlot.u.bits.FunctionNumber = 0;
321 
322  /* Send function 0 request to get the header back */
323  HalpReadPCIConfig(BusHandler,
324  MultiSlot,
325  &HeaderType,
326  FIELD_OFFSET(PCI_COMMON_CONFIG, HeaderType),
327  sizeof(UCHAR));
328 
329  /* Now make sure the header is multi-function */
330  if (!(HeaderType & PCI_MULTIFUNCTION) || (HeaderType == 0xFF)) return FALSE;
331  return TRUE;
332 }
#define TRUE
Definition: types.h:120
ULONG MaxDevice
Definition: bus.h:100
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
#define PCI_MULTIFUNCTION
Definition: iotypes.h:3247
struct _PCI_SLOT_NUMBER::@3634::@3635 bits
union _PCI_SLOT_NUMBER::@3634 u
VOID NTAPI HalpReadPCIConfig(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pci.c:255
if(!(yy_init))
Definition: macro.lex.yy.c:714
unsigned char UCHAR
Definition: xmlstorage.h:181
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
struct _PCIPBUSDATA * PPCIPBUSDATA
unsigned int ULONG
Definition: retypes.h:1

◆ 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 281 of file pci.c.

286 {
287  /* Validate the PCI Slot */
288  if (HalpValidPCISlot(BusHandler, Slot))
289  {
290  /* Send the request */
291  HalpPCIConfig(BusHandler,
292  Slot,
293  Buffer,
294  Offset,
295  Length,
297  }
298 }
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: pci.c:217
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
Definition: bufpool.h:45
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
BOOLEAN NTAPI HalpValidPCISlot(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot)
Definition: pci.c:302
FncConfigIO ConfigWrite[3]
Definition: bus.h:130
PCI_CONFIG_HANDLER PCIConfigHandler
Definition: pci.c:20

◆ TYPE1_DEFINE() [1/6]

TYPE1_DEFINE ( HalpPCIReadUcharType1  )

◆ TYPE1_DEFINE() [2/6]

TYPE1_DEFINE ( HalpPCIReadUshortType1  )

◆ TYPE1_DEFINE() [3/6]

TYPE1_DEFINE ( HalpPCIReadUlongType1  )

◆ TYPE1_DEFINE() [4/6]

TYPE1_DEFINE ( HalpPCIWriteUcharType1  )

◆ TYPE1_DEFINE() [5/6]

TYPE1_DEFINE ( HalpPCIWriteUshortType1  )

◆ TYPE1_DEFINE() [6/6]

TYPE1_DEFINE ( HalpPCIWriteUlongType1  )

◆ TYPE2_DEFINE() [1/6]

TYPE2_DEFINE ( HalpPCIReadUcharType2  )

◆ TYPE2_DEFINE() [2/6]

TYPE2_DEFINE ( HalpPCIReadUshortType2  )

◆ TYPE2_DEFINE() [3/6]

TYPE2_DEFINE ( HalpPCIReadUlongType2  )

◆ TYPE2_DEFINE() [4/6]

TYPE2_DEFINE ( HalpPCIWriteUcharType2  )

◆ TYPE2_DEFINE() [5/6]

TYPE2_DEFINE ( HalpPCIWriteUshortType2  )

◆ TYPE2_DEFINE() [6/6]

TYPE2_DEFINE ( HalpPCIWriteUlongType2  )

Variable Documentation

◆ HalpBusType

ULONG HalpBusType

Definition at line 17 of file bus.c.

◆ HalpFakePciBusHandler

BUS_HANDLER HalpFakePciBusHandler

Definition at line 91 of file pci.c.

◆ HalpMaxPciBus

ULONG HalpMaxPciBus

Definition at line 18 of file pci.c.

◆ HalpMinPciBus

ULONG HalpMinPciBus

Definition at line 18 of file pci.c.

◆ HalpPCIConfigInitialized

BOOLEAN HalpPCIConfigInitialized

Definition at line 17 of file pci.c.