ReactOS  0.4.15-dev-2720-g5ee0925
pcibus.c File Reference
#include <hal.h>
#include <debug.h>
Include dependency graph for pcibus.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID NTAPI HalpPCISynchronizeType1 (IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PKIRQL Irql, IN PPCI_TYPE1_CFG_BITS PciCfg1)
 
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)
 
VOID NTAPI HalpPCIConfig (IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PUCHAR Buffer, IN ULONG Offset, IN ULONG Length, IN FncConfigIO *ConfigIO)
 
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)
 
BOOLEAN NTAPI HalpValidPCISlot (IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot)
 
ULONG NTAPI HalpGetPCIData (IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
 
ULONG NTAPI HalpSetPCIData (IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
 
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)
 
NTSTATUS NTAPI HalpSetupPciDeviceForDebugging (IN PVOID LoaderBlock, IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice)
 
NTSTATUS NTAPI HalpReleasePciDeviceForDebugging (IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice)
 
VOID NTAPI HalpRegisterPciDebuggingDeviceInfo (VOID)
 
static ULONG NTAPI PciSize (ULONG Base, ULONG Mask)
 
NTSTATUS NTAPI HalpAdjustPCIResourceList (IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *pResourceList)
 
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 *AllocatedResources)
 
ULONG NTAPI HaliPciInterfaceReadConfig (IN PBUS_HANDLER RootBusHandler, IN ULONG BusNumber, IN PCI_SLOT_NUMBER SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
 
PPCI_REGISTRY_INFO_INTERNAL NTAPI HalpQueryPciRegistryInfo (VOID)
 
VOID NTAPI HalpInitializePciStubs (VOID)
 

Variables

BOOLEAN HalpPciLockSettings
 
ULONG HalpBusType
 
PCI_TYPE1_CFG_CYCLE_BITS HalpPciDebuggingDevice [2] = {{{{0}}}}
 
BOOLEAN HalpPCIConfigInitialized
 
ULONG HalpMinPciBus
 
ULONG HalpMaxPciBus
 
KSPIN_LOCK HalpPCIConfigLock
 
PCI_CONFIG_HANDLER PCIConfigHandler
 
UCHAR PCIDeref [4][4]
 
PCI_CONFIG_HANDLER PCIConfigHandlerType1
 
PCI_CONFIG_HANDLER PCIConfigHandlerType2
 
PCIPBUSDATA HalpFakePciBusData
 
BUS_HANDLER HalpFakePciBusHandler
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file pcibus.c.

Function Documentation

◆ HaliPciInterfaceReadConfig()

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

Definition at line 848 of file pcibus.c.

854 {
855  BUS_HANDLER BusHandler;
856 
857  /* Setup fake PCI Bus handler */
858  RtlCopyMemory(&BusHandler, &HalpFakePciBusHandler, sizeof(BUS_HANDLER));
859  BusHandler.BusNumber = BusNumber;
860 
861  /* Read configuration data */
863 
864  /* Return length */
865  return Length;
866 }
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:65
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
Definition: bufpool.h:45
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:156
ULONG BusNumber
Definition: haltypes.h:226
BUS_HANDLER HalpFakePciBusHandler
Definition: pcibus.c:96
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
VOID NTAPI HalpReadPCIConfig(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pcibus.c:261

Referenced by HalpInitializePciStubs().

◆ HalpAdjustPCIResourceList()

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

Definition at line 671 of file pcibus.c.

674 {
675  PPCIPBUSDATA BusData;
679 
680  /* Get PCI bus data */
681  BusData = BusHandler->BusData;
682  SlotNumber.u.AsULONG = (*pResourceList)->SlotNumber;
683 
684  /* Get the IRQ supported range */
685  Status = BusData->GetIrqRange(BusHandler, RootHandler, SlotNumber, &Interrupt);
686  if (!NT_SUCCESS(Status)) return Status;
687 #ifndef _MINIHAL_
688  /* Handle the /PCILOCK feature */
690  {
691  /* /PCILOCK is not yet supported */
692  UNIMPLEMENTED_DBGBREAK("/PCILOCK boot switch is not yet supported.");
693  }
694 #endif
695  /* Now create the correct resource list based on the supported bus ranges */
696 #if 0
697  Status = HaliAdjustResourceListRange(BusHandler->BusAddresses,
698  Interrupt,
699  pResourceList);
700 #else
701  DPRINT1("HAL: No PCI Resource Adjustment done! Hardware may malfunction\n");
703 #endif
704 
705  /* Return to caller */
707  return Status;
708 }
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:65
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFINTERRUPT * Interrupt
Definition: wdfinterrupt.h:372
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN HalpPciLockSettings
Definition: halinit.c:18
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define DPRINT1
Definition: precomp.h:8
#define STATUS_SUCCESS
Definition: shellext.h:65
PciIrqRange GetIrqRange
Definition: bus.h:111
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

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

Definition at line 712 of file pcibus.c.

720 {
721  PCI_COMMON_CONFIG PciConfig;
722  SIZE_T Address;
726  UCHAR Offset;
730  DPRINT1("WARNING: PCI Slot Resource Assignment is FOOBAR\n");
731 
732  /* FIXME: Should handle 64-bit addresses */
733 
734  /* Read configuration data */
735  SlotNumber.u.AsULONG = Slot;
736  HalpReadPCIConfig(BusHandler, SlotNumber, &PciConfig, 0, PCI_COMMON_HDR_LENGTH);
737 
738  /* Check if we read it correctly */
739  if (PciConfig.VendorID == PCI_INVALID_VENDORID)
740  return STATUS_NO_SUCH_DEVICE;
741 
742  /* Read the PCI configuration space for the device and store base address and
743  size information in temporary storage. Count the number of valid base addresses */
744  ResourceCount = 0;
746  {
747  if (0xffffffff == PciConfig.u.type0.BaseAddresses[Address])
748  PciConfig.u.type0.BaseAddresses[Address] = 0;
749 
750  /* Memory resource */
751  if (0 != PciConfig.u.type0.BaseAddresses[Address])
752  {
753  ResourceCount++;
754 
755  Offset = (UCHAR)FIELD_OFFSET(PCI_COMMON_CONFIG, u.type0.BaseAddresses[Address]);
756 
757  /* Write 0xFFFFFFFF there */
758  WriteBuffer = 0xffffffff;
759  HalpWritePCIConfig(BusHandler, SlotNumber, &WriteBuffer, Offset, sizeof(ULONG));
760 
761  /* Read that figure back from the config space */
762  HalpReadPCIConfig(BusHandler, SlotNumber, &Size[Address], Offset, sizeof(ULONG));
763 
764  /* Write back initial value */
765  HalpWritePCIConfig(BusHandler, SlotNumber, &PciConfig.u.type0.BaseAddresses[Address], Offset, sizeof(ULONG));
766  }
767  }
768 
769  /* Interrupt resource */
770  if (0 != PciConfig.u.type0.InterruptPin &&
771  0 != PciConfig.u.type0.InterruptLine &&
772  0xFF != PciConfig.u.type0.InterruptLine)
773  ResourceCount++;
774 
775  /* Allocate output buffer and initialize */
777  PagedPool,
778  sizeof(CM_RESOURCE_LIST) +
780  TAG_HAL);
781 
782  if (NULL == *AllocatedResources)
783  return STATUS_NO_MEMORY;
784 
785  (*AllocatedResources)->Count = 1;
786  (*AllocatedResources)->List[0].InterfaceType = PCIBus;
787  (*AllocatedResources)->List[0].BusNumber = BusHandler->BusNumber;
788  (*AllocatedResources)->List[0].PartialResourceList.Version = 1;
789  (*AllocatedResources)->List[0].PartialResourceList.Revision = 1;
790  (*AllocatedResources)->List[0].PartialResourceList.Count = ResourceCount;
791  Descriptor = (*AllocatedResources)->List[0].PartialResourceList.PartialDescriptors;
792 
793  /* Store configuration information */
795  {
796  if (0 != PciConfig.u.type0.BaseAddresses[Address])
797  {
799  (PciConfig.u.type0.BaseAddresses[Address] & 0x1))
800  {
802  Descriptor->ShareDisposition = CmResourceShareDeviceExclusive; /* FIXME I have no idea... */
803  Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE; /* FIXME Just a guess */
804  Descriptor->u.Memory.Start.QuadPart = (PciConfig.u.type0.BaseAddresses[Address] & PCI_ADDRESS_MEMORY_ADDRESS_MASK);
806  }
807  else if (PCI_ADDRESS_IO_SPACE ==
808  (PciConfig.u.type0.BaseAddresses[Address] & 0x1))
809  {
811  Descriptor->ShareDisposition = CmResourceShareDeviceExclusive; /* FIXME I have no idea... */
812  Descriptor->Flags = CM_RESOURCE_PORT_IO; /* FIXME Just a guess */
813  Descriptor->u.Port.Start.QuadPart = PciConfig.u.type0.BaseAddresses[Address] &= PCI_ADDRESS_IO_ADDRESS_MASK;
814  Descriptor->u.Port.Length = PciSize(Size[Address], PCI_ADDRESS_IO_ADDRESS_MASK & 0xffff);
815  }
816  else
817  {
818  ASSERT(FALSE);
819  return STATUS_UNSUCCESSFUL;
820  }
821  Descriptor++;
822  }
823  }
824 
825  if (0 != PciConfig.u.type0.InterruptPin &&
826  0 != PciConfig.u.type0.InterruptLine &&
827  0xFF != PciConfig.u.type0.InterruptLine)
828  {
830  Descriptor->ShareDisposition = CmResourceShareShared; /* FIXME Just a guess */
831  Descriptor->Flags = CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE; /* FIXME Just a guess */
832  Descriptor->u.Interrupt.Level = PciConfig.u.type0.InterruptLine;
833  Descriptor->u.Interrupt.Vector = PciConfig.u.type0.InterruptLine;
834  Descriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
835 
836  Descriptor++;
837  }
838 
839  ASSERT(Descriptor == (*AllocatedResources)->List[0].PartialResourceList.PartialDescriptors + ResourceCount);
840 
841  /* FIXME: Should store the resources in the registry resource map */
842 
843  return Status;
844 }
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
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:65
#define PCI_TYPE0_ADDRESSES
Definition: iotypes.h:3500
#define PCI_ADDRESS_IO_ADDRESS_MASK
Definition: iotypes.h:4233
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:339
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PCM_RESOURCE_LIST * AllocatedResources
Definition: ndis.h:4640
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
#define PCI_ADDRESS_MEMORY_SPACE
Definition: bus.h:3
LONG NTSTATUS
Definition: precomp.h:26
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define CM_RESOURCE_MEMORY_READ_WRITE
Definition: cmtypes.h:120
#define CmResourceTypePort
Definition: hwresource.cpp:123
#define FALSE
Definition: types.h:117
#define PCI_ADDRESS_MEMORY_ADDRESS_MASK
Definition: iotypes.h:4234
static WCHAR Address[46]
Definition: ping.c:68
Status
Definition: gdiplustypes.h:24
#define PCI_INVALID_VENDORID
Definition: iotypes.h:3601
#define ASSERT(a)
Definition: mode.c:44
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
static ULONG ResourceCount
Definition: inbv.c:92
unsigned char UCHAR
Definition: xmlstorage.h:181
#define TAG_HAL
Definition: hal.h:61
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define CM_RESOURCE_PORT_IO
Definition: cmtypes.h:109
VOID NTAPI HalpWritePCIConfig(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pcibus.c:287
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NULL
Definition: types.h:112
#define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE
Definition: cmtypes.h:143
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI HalpReadPCIConfig(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pcibus.c:261
#define STATUS_SUCCESS
Definition: shellext.h:65
static ULONG NTAPI PciSize(ULONG Base, ULONG Mask)
Definition: pcibus.c:662
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
#define PCI_ADDRESS_IO_SPACE
Definition: iotypes.h:4230
#define WriteBuffer(BaseIoAddress, Buffer, Count)
Definition: atapi.h:344
#define PCI_COMMON_HDR_LENGTH
Definition: iotypes.h:3594

◆ HalpGetISAFixedPCIIrq()

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

Definition at line 569 of file pcibus.c.

573 {
574  PCI_COMMON_HEADER PciData;
575 
576  /* Read PCI configuration data */
578  BusHandler->BusNumber,
579  PciSlot.u.AsULONG,
580  &PciData,
582 
583  /* Make sure it's a real device */
584  if (PciData.VendorID == PCI_INVALID_VENDORID) return STATUS_UNSUCCESSFUL;
585 
586  /* Allocate the supported range structure */
588  if (!*Range) return STATUS_INSUFFICIENT_RESOURCES;
589 
590  /* Set it up */
592  (*Range)->Base = 1;
593 
594  /* If the PCI device has no IRQ, nothing to do */
595  if (!PciData.u.type0.InterruptPin) return STATUS_SUCCESS;
596 
597  /* FIXME: The PCI IRQ Routing Miniport should be called */
598 
599  /* Also if the INT# seems bogus, nothing to do either */
600  if ((PciData.u.type0.InterruptLine == 0) ||
601  (PciData.u.type0.InterruptLine == 255))
602  {
603  /* Fake success */
604  return STATUS_SUCCESS;
605  }
606 
607  /* Otherwise, the INT# should be valid, return it to the caller */
608  (*Range)->Base = PciData.u.type0.InterruptLine;
609  (*Range)->Limit = PciData.u.type0.InterruptLine;
610  return STATUS_SUCCESS;
611 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define PCI_INVALID_VENDORID
Definition: iotypes.h:3601
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define TAG_HAL
Definition: hal.h:61
Definition: range.c:39
NTHALAPI ULONG NTAPI HalGetBusData(BUS_DATA_TYPE, ULONG, ULONG, PVOID, ULONG)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
#define PCI_COMMON_HDR_LENGTH
Definition: iotypes.h:3594

Referenced by HalpAllocateAndInitPciBusHandler().

◆ HalpGetPCIData()

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

Definition at line 371 of file pcibus.c.

377 {
378  PCI_SLOT_NUMBER Slot;
379  UCHAR PciBuffer[PCI_COMMON_HDR_LENGTH];
380  PPCI_COMMON_CONFIG PciConfig = (PPCI_COMMON_CONFIG)PciBuffer;
381  ULONG Len = 0;
382 
383  Slot.u.AsULONG = SlotNumber;
384 #ifdef SARCH_XBOX
385  if (HalpXboxBlacklistedPCISlot(BusHandler, Slot))
386  {
387  if (Offset == 0 && Length >= sizeof(USHORT))
388  {
390  return sizeof(USHORT);
391  }
392  return 0;
393  }
394 #endif
395 
396  /* Normalize the length */
397  if (Length > sizeof(PCI_COMMON_CONFIG)) Length = sizeof(PCI_COMMON_CONFIG);
398 
399  /* Check if this is a vendor-specific read */
401  {
402  /* Read the header */
403  HalpReadPCIConfig(BusHandler, Slot, PciConfig, 0, sizeof(ULONG));
404 
405  /* Make sure the vendor is valid */
406  if (PciConfig->VendorID == PCI_INVALID_VENDORID) return 0;
407  }
408  else
409  {
410  /* Read the entire header */
412  HalpReadPCIConfig(BusHandler, Slot, PciConfig, 0, Len);
413 
414  /* Validate the vendor ID */
415  if (PciConfig->VendorID == PCI_INVALID_VENDORID)
416  {
417  /* It's invalid, but we want to return this much */
418  Len = sizeof(USHORT);
419  }
420 
421  /* Now check if there's space left */
422  if (Len < Offset) return 0;
423 
424  /* There is, so return what's after the offset and normalize */
425  Len -= Offset;
426  if (Len > Length) Len = Length;
427 
428  /* Copy the data into the caller's buffer */
429  RtlMoveMemory(Buffer, PciBuffer + Offset, Len);
430 
431  /* Update buffer and offset, decrement total length */
432  Offset += Len;
433  Buffer = (PVOID)((ULONG_PTR)Buffer + Len);
434  Length -= Len;
435  }
436 
437  /* Now we still have something to copy */
438  if (Length)
439  {
440  /* Check if it's vendor-specific data */
442  {
443  /* Read it now */
444  HalpReadPCIConfig(BusHandler, Slot, Buffer, Offset, Length);
445  Len += Length;
446  }
447  }
448 
449  /* Update the total length read */
450  return Len;
451 }
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:65
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
struct _PCI_COMMON_CONFIG * PPCI_COMMON_CONFIG
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
uint32_t ULONG_PTR
Definition: typedefs.h:65
union _PCI_SLOT_NUMBER::@3809 u
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
#define PCI_INVALID_VENDORID
Definition: iotypes.h:3601
#define Len
Definition: deflate.h:82
unsigned char UCHAR
Definition: xmlstorage.h:181
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI HalpReadPCIConfig(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pcibus.c:261
unsigned short * PUSHORT
Definition: retypes.h:2
#define PCI_COMMON_HDR_LENGTH
Definition: iotypes.h:3594

◆ 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 525 of file pcibus.c.

531 {
532  /* Validate the level first */
533  if (BusInterruptLevel < 1) return 0;
534 
535  /* PCI has its IRQs on top of ISA IRQs, so pass it on to the ISA handler */
536  return HalGetInterruptVector(Isa,
537  0,
539  0,
540  Irql,
541  Affinity);
542 }
_In_ ULONG _In_ ULONG BusInterruptLevel
Definition: halfuncs.h:170
_Out_ PKIRQL Irql
Definition: csq.h:179
NTHALAPI ULONG NTAPI HalGetInterruptVector(INTERFACE_TYPE, ULONG, ULONG, ULONG, PKIRQL, PKAFFINITY)
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:170

Referenced by HalpAllocateAndInitPciBusHandler().

◆ HalpInitializePciStubs()

VOID NTAPI HalpInitializePciStubs ( VOID  )

Definition at line 1104 of file pcibus.c.

1105 {
1106  PPCI_REGISTRY_INFO_INTERNAL PciRegistryInfo;
1107  UCHAR PciType;
1109  ULONG i;
1111  ULONG VendorId = 0;
1112  ULONG MaxPciBusNumber;
1113 
1114  /* Query registry information */
1115  PciRegistryInfo = HalpQueryPciRegistryInfo();
1116  if (!PciRegistryInfo)
1117  {
1118  /* Assume type 1 */
1119  PciType = 1;
1120 
1121  /* Force a manual bus scan later */
1122  MaxPciBusNumber = MAXULONG;
1123  }
1124  else
1125  {
1126  /* Get the PCI type */
1127  PciType = PciRegistryInfo->HardwareMechanism & 0xF;
1128 
1129  /* Get MaxPciBusNumber and make it 0-based */
1130  MaxPciBusNumber = PciRegistryInfo->NoBuses - 1;
1131 
1132  /* Free the info structure */
1133  ExFreePoolWithTag(PciRegistryInfo, TAG_HAL);
1134  }
1135 
1136  /* Initialize the PCI lock */
1138 
1139  /* Check the type of PCI bus */
1140  switch (PciType)
1141  {
1142  /* Type 1 PCI Bus */
1143  case 1:
1144 
1145  /* Copy the Type 1 handler data */
1148  sizeof(PCIConfigHandler));
1149 
1150  /* Set correct I/O Ports */
1151  BusData->Config.Type1.Address = PCI_TYPE1_ADDRESS_PORT;
1152  BusData->Config.Type1.Data = PCI_TYPE1_DATA_PORT;
1153  break;
1154 
1155  /* Type 2 PCI Bus */
1156  case 2:
1157 
1158  /* Copy the Type 2 handler data */
1161  sizeof (PCIConfigHandler));
1162 
1163  /* Set correct I/O Ports */
1164  BusData->Config.Type2.CSE = PCI_TYPE2_CSE_PORT;
1165  BusData->Config.Type2.Forward = PCI_TYPE2_FORWARD_PORT;
1166  BusData->Config.Type2.Base = PCI_TYPE2_ADDRESS_BASE;
1167 
1168  /* Only 16 devices supported, not 32 */
1169  BusData->MaxDevice = 16;
1170  break;
1171 
1172  default:
1173 
1174  /* Invalid type */
1175  DbgPrint("HAL: Unknown PCI type\n");
1176  }
1177 
1178  /* Run a forced bus scan if needed */
1179  if (MaxPciBusNumber == MAXULONG)
1180  {
1181  /* Initialize the max bus number to 0xFF */
1182  HalpMaxPciBus = 0xFF;
1183 
1184  /* Initialize the counter */
1185  MaxPciBusNumber = 0;
1186 
1187  /* Loop all possible buses */
1188  for (i = 0; i < HalpMaxPciBus; i++)
1189  {
1190  /* Loop all devices */
1191  for (j.u.AsULONG = 0; j.u.AsULONG < BusData->MaxDevice; j.u.AsULONG++)
1192  {
1193  /* Query the interface */
1195  i,
1196  j,
1197  &VendorId,
1198  0,
1199  sizeof(ULONG)))
1200  {
1201  /* Validate the vendor ID */
1202  if ((VendorId & 0xFFFF) != PCI_INVALID_VENDORID)
1203  {
1204  /* Set this as the maximum ID */
1205  MaxPciBusNumber = i;
1206  break;
1207  }
1208  }
1209  }
1210  }
1211  }
1212 
1213  /* Set the real max bus number */
1214  HalpMaxPciBus = MaxPciBusNumber;
1215 
1216  /* We're done */
1218 }
#define PCI_TYPE2_FORWARD_PORT
Definition: bus.h:171
ULONG MaxDevice
Definition: bus.h:100
#define DbgPrint
Definition: loader.c:25
#define TRUE
Definition: types.h:120
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
struct _PCIPBUSDATA::@1435::@1437 Type2
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 PCI_TYPE1_ADDRESS_PORT
Definition: hardware.h:33
PCI_CONFIG_HANDLER PCIConfigHandler
Definition: pcibus.c:25
#define PCI_INVALID_VENDORID
Definition: iotypes.h:3601
KSPIN_LOCK HalpPCIConfigLock
Definition: pcibus.c:24
struct _PCIPBUSDATA::@1435::@1436 Type1
unsigned char UCHAR
Definition: xmlstorage.h:181
#define TAG_HAL
Definition: hal.h:61
PCI_CONFIG_HANDLER PCIConfigHandlerType2
Definition: pcibus.c:59
#define PCI_TYPE2_CSE_PORT
Definition: bus.h:170
BUS_HANDLER HalpFakePciBusHandler
Definition: pcibus.c:96
#define MAXULONG
Definition: typedefs.h:251
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
PCI_CONFIG_HANDLER PCIConfigHandlerType1
Definition: pcibus.c:37
#define NULL
Definition: types.h:112
union _PCIPBUSDATA::@1435 Config
BOOLEAN HalpPCIConfigInitialized
Definition: pcibus.c:22
struct _PCIPBUSDATA * PPCIPBUSDATA
#define PCI_TYPE1_DATA_PORT
Definition: hardware.h:34
unsigned int ULONG
Definition: retypes.h:1
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
ULONG NTAPI HaliPciInterfaceReadConfig(IN PBUS_HANDLER RootBusHandler, IN ULONG BusNumber, IN PCI_SLOT_NUMBER SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pcibus.c:848
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
PPCI_REGISTRY_INFO_INTERNAL NTAPI HalpQueryPciRegistryInfo(VOID)
Definition: pcibus.c:871
#define PCI_TYPE2_ADDRESS_BASE
Definition: bus.h:172
PVOID BusData
Definition: haltypes.h:229
ULONG HalpMaxPciBus
Definition: pcibus.c:23

◆ HalpPCIConfig()

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

229 {
230  KIRQL OldIrql;
231  ULONG i;
232  UCHAR State[20];
233 
234  /* Synchronize the operation */
235  PCIConfigHandler.Synchronize(BusHandler, Slot, &OldIrql, State);
236 
237  /* Loop every increment */
238  while (Length)
239  {
240  /* Find out the type of read/write we need to do */
241  i = PCIDeref[Offset % sizeof(ULONG)][Length % sizeof(ULONG)];
242 
243  /* Do the read/write and return the number of bytes */
244  i = ConfigIO[i]((PPCIPBUSDATA)BusHandler->BusData,
245  State,
246  Buffer,
247  Offset);
248 
249  /* Increment the buffer position and offset, and decrease the length */
250  Offset += i;
251  Buffer += i;
252  Length -= i;
253  }
254 
255  /* Release the lock and PCI bus */
257 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
FncReleaseSync ReleaseSynchronzation
Definition: bus.h:128
UCHAR KIRQL
Definition: env_spec_w32.h:591
UCHAR PCIDeref[4][4]
Definition: pcibus.c:28
Definition: bufpool.h:45
PCI_CONFIG_HANDLER PCIConfigHandler
Definition: pcibus.c:25
unsigned char UCHAR
Definition: xmlstorage.h:181
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
FncSync Synchronize
Definition: bus.h:127
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
struct _PCIPBUSDATA * PPCIPBUSDATA
unsigned int ULONG
Definition: retypes.h:1

Referenced by HalpReadPCIConfig(), and HalpWritePCIConfig().

◆ 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 557 of file pcibus.c.

562 {
564 }
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57

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 547 of file pcibus.c.

551 {
553 }
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57

Referenced by HalpAllocateAndInitPciBusHandler().

◆ HalpPCIReleaseSynchronizationType2()

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

Definition at line 196 of file pcibus.c.

198 {
199  PCI_TYPE2_CSE_BITS PciCfg2Cse;
200  PPCIPBUSDATA BusData = (PPCIPBUSDATA)BusHandler->BusData;
201 
202  /* Clear CSE and bus number */
203  PciCfg2Cse.u.AsUCHAR = 0;
204  WRITE_PORT_UCHAR(BusData->Config.Type2.CSE, PciCfg2Cse.u.AsUCHAR);
205  WRITE_PORT_UCHAR(BusData->Config.Type2.Forward, 0);
206 
207  /* Release the lock */
209  KeLowerIrql(Irql);
210 }
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
union _PCI_TYPE2_CSE_BITS::@1476 u
_Out_ PKIRQL Irql
Definition: csq.h:179
VOID FASTCALL KiReleaseSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: ntoskrnl.c:35
struct _PCIPBUSDATA::@1435::@1437 Type2
KSPIN_LOCK HalpPCIConfigLock
Definition: pcibus.c:24
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
union _PCIPBUSDATA::@1435 Config
struct _PCIPBUSDATA * PPCIPBUSDATA
UCHAR AsUCHAR
Definition: bus.h:210

◆ HalpPCIReleaseSynchronzationType1()

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

Definition at line 139 of file pcibus.c.

141 {
142  PCI_TYPE1_CFG_BITS PciCfg1;
143 
144  /* Clear the PCI Configuration Register */
145  PciCfg1.u.AsULONG = 0;
146  WRITE_PORT_ULONG(((PPCIPBUSDATA)BusHandler->BusData)->Config.Type1.Address,
147  PciCfg1.u.AsULONG);
148 
149  /* Release the lock */
151  KeLowerIrql(Irql);
152 }
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
_Out_ PKIRQL Irql
Definition: csq.h:179
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:35
KSPIN_LOCK HalpPCIConfigLock
Definition: pcibus.c:24
union _PCI_TYPE1_CFG_BITS::@153 u

◆ HalpPCISynchronizeType1()

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

Definition at line 120 of file pcibus.c.

124 {
125  /* Setup the PCI Configuration Register */
126  PciCfg1->u.AsULONG = 0;
127  PciCfg1->u.bits.BusNumber = BusHandler->BusNumber;
128  PciCfg1->u.bits.DeviceNumber = Slot.u.bits.DeviceNumber;
129  PciCfg1->u.bits.FunctionNumber = Slot.u.bits.FunctionNumber;
130  PciCfg1->u.bits.Enable = TRUE;
131 
132  /* Acquire the lock */
135 }
#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: pcibus.c:24
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
VOID FASTCALL KiAcquireSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: ntoskrnl.c:28

◆ 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 165 of file pcibus.c.

169 {
170  PCI_TYPE2_CSE_BITS PciCfg2Cse;
171  PPCIPBUSDATA BusData = (PPCIPBUSDATA)BusHandler->BusData;
172 
173  /* Setup the configuration register */
174  PciCfg->u.AsUSHORT = 0;
175  PciCfg->u.bits.Agent = (USHORT)Slot.u.bits.DeviceNumber;
176  PciCfg->u.bits.AddressBase = (USHORT)BusData->Config.Type2.Base;
177 
178  /* Acquire the lock */
181 
182  /* Setup the CSE Register */
183  PciCfg2Cse.u.AsUCHAR = 0;
184  PciCfg2Cse.u.bits.Enable = TRUE;
185  PciCfg2Cse.u.bits.FunctionNumber = (UCHAR)Slot.u.bits.FunctionNumber;
186  PciCfg2Cse.u.bits.Key = -1;
187 
188  /* Write the bus number and CSE */
189  WRITE_PORT_UCHAR(BusData->Config.Type2.Forward,
190  (UCHAR)BusHandler->BusNumber);
191  WRITE_PORT_UCHAR(BusData->Config.Type2.CSE, PciCfg2Cse.u.AsUCHAR);
192 }
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define TRUE
Definition: types.h:120
union _PCI_TYPE2_CSE_BITS::@1476 u
_Out_ PKIRQL Irql
Definition: csq.h:179
struct _PCI_TYPE2_CSE_BITS::@1476::@1477 bits
struct _PCIPBUSDATA::@1435::@1437 Type2
KSPIN_LOCK HalpPCIConfigLock
Definition: pcibus.c:24
unsigned char UCHAR
Definition: xmlstorage.h:181
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
#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:28
union _PCIPBUSDATA::@1435 Config
struct _PCIPBUSDATA * PPCIPBUSDATA
UCHAR AsUCHAR
Definition: bus.h:210

◆ HalpQueryPciRegistryInfo()

PPCI_REGISTRY_INFO_INTERNAL NTAPI HalpQueryPciRegistryInfo ( VOID  )

Definition at line 871 of file pcibus.c.

872 {
873 #ifndef _MINIHAL_
874  WCHAR NameBuffer[8];
876  UNICODE_STRING KeyName, ConfigName, IdentName;
877  HANDLE KeyHandle, BusKeyHandle, CardListHandle;
879  UCHAR KeyBuffer[sizeof(CM_FULL_RESOURCE_DESCRIPTOR) + 100];
880  PKEY_VALUE_FULL_INFORMATION ValueInfo = (PVOID)KeyBuffer;
881  UCHAR PartialKeyBuffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) +
882  sizeof(PCI_CARD_DESCRIPTOR)];
883  PKEY_VALUE_PARTIAL_INFORMATION PartialValueInfo = (PVOID)PartialKeyBuffer;
884  KEY_FULL_INFORMATION KeyInformation;
886  PWSTR Tag;
887  ULONG i, ElementCount;
888  PCM_FULL_RESOURCE_DESCRIPTOR FullDescriptor;
889  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
890  PPCI_REGISTRY_INFO PciRegInfo;
891  PPCI_REGISTRY_INFO_INTERNAL PciRegistryInfo;
892  PPCI_CARD_DESCRIPTOR CardDescriptor;
893 
894  /* Setup the object attributes for the key */
896  L"\\Registry\\Machine\\Hardware\\Description\\"
897  L"System\\MultiFunctionAdapter");
899  &KeyName,
901  NULL,
902  NULL);
903 
904  /* Open the key */
905  Status = ZwOpenKey(&KeyHandle, KEY_READ, &ObjectAttributes);
906  if (!NT_SUCCESS(Status)) return NULL;
907 
908  /* Setup the receiving string */
909  KeyName.Buffer = NameBuffer;
910  KeyName.MaximumLength = sizeof(NameBuffer);
911 
912  /* Setup the configuration and identifier key names */
913  RtlInitUnicodeString(&ConfigName, L"Configuration Data");
914  RtlInitUnicodeString(&IdentName, L"Identifier");
915 
916  /* Keep looping for each ID */
917  for (i = 0; TRUE; i++)
918  {
919  /* Setup the key name */
922  &KeyName,
924  KeyHandle,
925  NULL);
926 
927  /* Open it */
928  Status = ZwOpenKey(&BusKeyHandle, KEY_READ, &ObjectAttributes);
929  if (!NT_SUCCESS(Status))
930  {
931  /* None left, fail */
933  return NULL;
934  }
935 
936  /* Read the registry data */
937  Status = ZwQueryValueKey(BusKeyHandle,
938  &IdentName,
940  ValueInfo,
941  sizeof(KeyBuffer),
942  &ResultLength);
943  if (!NT_SUCCESS(Status))
944  {
945  /* Failed, try the next one */
946  ZwClose(BusKeyHandle);
947  continue;
948  }
949 
950  /* Get the PCI Tag and validate it */
951  Tag = (PWSTR)((ULONG_PTR)ValueInfo + ValueInfo->DataOffset);
952  if ((Tag[0] != L'P') ||
953  (Tag[1] != L'C') ||
954  (Tag[2] != L'I') ||
955  (Tag[3]))
956  {
957  /* Not a valid PCI entry, skip it */
958  ZwClose(BusKeyHandle);
959  continue;
960  }
961 
962  /* Now read our PCI structure */
963  Status = ZwQueryValueKey(BusKeyHandle,
964  &ConfigName,
966  ValueInfo,
967  sizeof(KeyBuffer),
968  &ResultLength);
969  ZwClose(BusKeyHandle);
970  if (!NT_SUCCESS(Status)) continue;
971 
972  /* We read it OK! Get the actual resource descriptors */
973  FullDescriptor = (PCM_FULL_RESOURCE_DESCRIPTOR)
974  ((ULONG_PTR)ValueInfo + ValueInfo->DataOffset);
975  PartialDescriptor = (PCM_PARTIAL_RESOURCE_DESCRIPTOR)
976  ((ULONG_PTR)FullDescriptor->
977  PartialResourceList.PartialDescriptors);
978 
979  /* Check if this is our PCI Registry Information */
980  if (PartialDescriptor->Type == CmResourceTypeDeviceSpecific)
981  {
982  /* It is, stop searching */
983  break;
984  }
985  }
986 
987  /* Close the key */
989 
990  /* Save the PCI information for later */
991  PciRegInfo = (PPCI_REGISTRY_INFO)(PartialDescriptor + 1);
992 
993  /* Assume no Card List entries */
994  ElementCount = 0;
995 
996  /* Set up for checking the PCI Card List key */
998  L"\\Registry\\Machine\\System\\CurrentControlSet\\"
999  L"Control\\PnP\\PCI\\CardList");
1001  &KeyName,
1003  NULL,
1004  NULL);
1005 
1006  /* Attempt to open it */
1007  Status = ZwOpenKey(&CardListHandle, KEY_READ, &ObjectAttributes);
1008  if (NT_SUCCESS(Status))
1009  {
1010  /* It exists, so let's query it */
1011  Status = ZwQueryKey(CardListHandle,
1013  &KeyInformation,
1014  sizeof(KEY_FULL_INFORMATION),
1015  &ResultLength);
1016  if (!NT_SUCCESS(Status))
1017  {
1018  /* Failed to query, so no info */
1019  PciRegistryInfo = NULL;
1020  }
1021  else
1022  {
1023  /* Allocate the full structure */
1024  PciRegistryInfo =
1026  sizeof(PCI_REGISTRY_INFO_INTERNAL) +
1027  (KeyInformation.Values *
1028  sizeof(PCI_CARD_DESCRIPTOR)),
1029  TAG_HAL);
1030  if (PciRegistryInfo)
1031  {
1032  /* Get the first card descriptor entry */
1033  CardDescriptor = (PPCI_CARD_DESCRIPTOR)(PciRegistryInfo + 1);
1034 
1035  /* Loop all the values */
1036  for (i = 0; i < KeyInformation.Values; i++)
1037  {
1038  /* Attempt to get the value */
1039  Status = ZwEnumerateValueKey(CardListHandle,
1040  i,
1042  PartialValueInfo,
1043  sizeof(PartialKeyBuffer),
1044  &ResultLength);
1045  if (!NT_SUCCESS(Status))
1046  {
1047  /* Something went wrong, stop the search */
1048  break;
1049  }
1050 
1051  /* Make sure it is correctly sized */
1052  if (PartialValueInfo->DataLength == sizeof(PCI_CARD_DESCRIPTOR))
1053  {
1054  /* Sure is, copy it over */
1055  *CardDescriptor = *(PPCI_CARD_DESCRIPTOR)
1056  PartialValueInfo->Data;
1057 
1058  /* One more Card List entry */
1059  ElementCount++;
1060 
1061  /* Move to the next descriptor */
1062  CardDescriptor = (CardDescriptor + 1);
1063  }
1064  }
1065  }
1066  }
1067 
1068  /* Close the Card List key */
1069  ZwClose(CardListHandle);
1070  }
1071  else
1072  {
1073  /* No key, no Card List */
1074  PciRegistryInfo = NULL;
1075  }
1076 
1077  /* Check if we failed to get the full structure */
1078  if (!PciRegistryInfo)
1079  {
1080  /* Just allocate the basic structure then */
1081  PciRegistryInfo = ExAllocatePoolWithTag(NonPagedPool,
1083  TAG_HAL);
1084  if (!PciRegistryInfo) return NULL;
1085  }
1086 
1087  /* Save the info we got */
1088  PciRegistryInfo->MajorRevision = PciRegInfo->MajorRevision;
1089  PciRegistryInfo->MinorRevision = PciRegInfo->MinorRevision;
1090  PciRegistryInfo->NoBuses = PciRegInfo->NoBuses;
1091  PciRegistryInfo->HardwareMechanism = PciRegInfo->HardwareMechanism;
1092  PciRegistryInfo->ElementCount = ElementCount;
1093 
1094  /* Return it */
1095  return PciRegistryInfo;
1096 #else
1097  return NULL;
1098 #endif
1099 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define CmResourceTypeDeviceSpecific
Definition: hwresource.cpp:127
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR * PCM_PARTIAL_RESOURCE_DESCRIPTOR
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
uint16_t * PWSTR
Definition: typedefs.h:56
LONG NTSTATUS
Definition: precomp.h:26
UCHAR HardwareMechanism
Definition: pci.h:110
struct _CM_FULL_RESOURCE_DESCRIPTOR CM_FULL_RESOURCE_DESCRIPTOR
UCHAR MinorRevision
Definition: pci.h:108
uint32_t ULONG_PTR
Definition: typedefs.h:65
UCHAR MajorRevision
Definition: pci.h:107
struct _PCI_CARD_DESCRIPTOR * PPCI_CARD_DESCRIPTOR
struct _CM_FULL_RESOURCE_DESCRIPTOR * PCM_FULL_RESOURCE_DESCRIPTOR
void * PVOID
Definition: retypes.h:9
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
Status
Definition: gdiplustypes.h:24
NTSYSAPI NTSTATUS NTAPI RtlIntegerToUnicodeString(ULONG Value, ULONG Base, PUNICODE_STRING String)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
unsigned char UCHAR
Definition: xmlstorage.h:181
static const WCHAR L[]
Definition: oid.c:1250
#define TAG_HAL
Definition: hal.h:61
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
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
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
#define NULL
Definition: types.h:112
UCHAR NoBuses
Definition: pci.h:109
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
struct _PCI_REGISTRY_INFO * PPCI_REGISTRY_INFO

Referenced by 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 261 of file pcibus.c.

266 {
267  /* Validate the PCI Slot */
268  if (!HalpValidPCISlot(BusHandler, Slot))
269  {
270  /* Fill the buffer with invalid data */
272  }
273  else
274  {
275  /* Send the request */
276  HalpPCIConfig(BusHandler,
277  Slot,
278  Buffer,
279  Offset,
280  Length,
282  }
283 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
FncConfigIO ConfigRead[3]
Definition: bus.h:129
BOOLEAN NTAPI HalpValidPCISlot(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot)
Definition: pcibus.c:331
Definition: bufpool.h:45
PCI_CONFIG_HANDLER PCIConfigHandler
Definition: pcibus.c:25
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:593
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:223
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101

Referenced by HaliPciInterfaceReadConfig(), HalpAssignPCISlotResources(), HalpGetPCIData(), HalpSetPCIData(), and HalpValidPCISlot().

◆ HalpRegisterPciDebuggingDeviceInfo()

VOID NTAPI HalpRegisterPciDebuggingDeviceInfo ( VOID  )

Definition at line 635 of file pcibus.c.

636 {
637  BOOLEAN Found = FALSE;
638  ULONG i;
639  PAGED_CODE();
640 
641  /* Loop PCI debugging devices */
642  for (i = 0; i < 2; i++)
643  {
644  /* Reserved bit is set if we found one */
645  if (HalpPciDebuggingDevice[i].u.bits.Reserved1)
646  {
647  Found = TRUE;
648  break;
649  }
650  }
651 
652  /* Bail out if there aren't any */
653  if (!Found) return;
654 
655  /* FIXME: TODO */
656  UNIMPLEMENTED_DBGBREAK("You have implemented the KD routines for searching PCI debugger"
657  "devices, but you have forgotten to implement this routine\n");
658 }
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
PCI_TYPE1_CFG_CYCLE_BITS HalpPciDebuggingDevice[2]
Definition: pcibus.c:20
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
return Found
Definition: dirsup.c:1270
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
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
unsigned int ULONG
Definition: retypes.h:1
#define PAGED_CODE()

Referenced by HalReportResourceUsage().

◆ HalpReleasePciDeviceForDebugging()

NTSTATUS NTAPI HalpReleasePciDeviceForDebugging ( IN OUT PDEBUG_DEVICE_DESCRIPTOR  PciDevice)

Definition at line 626 of file pcibus.c.

627 {
628  DPRINT1("Unimplemented!\n");
629  return STATUS_NOT_IMPLEMENTED;
630 }
return STATUS_NOT_IMPLEMENTED
#define DPRINT1
Definition: precomp.h:8

◆ HalpSetPCIData()

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

Definition at line 455 of file pcibus.c.

461 {
462  PCI_SLOT_NUMBER Slot;
463  UCHAR PciBuffer[PCI_COMMON_HDR_LENGTH];
464  PPCI_COMMON_CONFIG PciConfig = (PPCI_COMMON_CONFIG)PciBuffer;
465  ULONG Len = 0;
466 
467  Slot.u.AsULONG = SlotNumber;
468 #ifdef SARCH_XBOX
469  if (HalpXboxBlacklistedPCISlot(BusHandler, Slot)) return 0;
470 #endif
471 
472  /* Normalize the length */
473  if (Length > sizeof(PCI_COMMON_CONFIG)) Length = sizeof(PCI_COMMON_CONFIG);
474 
475  /* Check if this is a vendor-specific read */
477  {
478  /* Read the header */
479  HalpReadPCIConfig(BusHandler, Slot, PciConfig, 0, sizeof(ULONG));
480 
481  /* Make sure the vendor is valid */
482  if (PciConfig->VendorID == PCI_INVALID_VENDORID) return 0;
483  }
484  else
485  {
486  /* Read the entire header and validate the vendor ID */
488  HalpReadPCIConfig(BusHandler, Slot, PciConfig, 0, Len);
489  if (PciConfig->VendorID == PCI_INVALID_VENDORID) return 0;
490 
491  /* Return what's after the offset and normalize */
492  Len -= Offset;
493  if (Len > Length) Len = Length;
494 
495  /* Copy the specific caller data */
496  RtlMoveMemory(PciBuffer + Offset, Buffer, Len);
497 
498  /* Write the actual configuration data */
499  HalpWritePCIConfig(BusHandler, Slot, PciBuffer + Offset, Offset, Len);
500 
501  /* Update buffer and offset, decrement total length */
502  Offset += Len;
503  Buffer = (PVOID)((ULONG_PTR)Buffer + Len);
504  Length -= Len;
505  }
506 
507  /* Now we still have something to copy */
508  if (Length)
509  {
510  /* Check if it's vendor-specific data */
512  {
513  /* Read it now */
514  HalpWritePCIConfig(BusHandler, Slot, Buffer, Offset, Length);
515  Len += Length;
516  }
517  }
518 
519  /* Update the total length read */
520  return Len;
521 }
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:65
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
struct _PCI_COMMON_CONFIG * PPCI_COMMON_CONFIG
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
uint32_t ULONG_PTR
Definition: typedefs.h:65
union _PCI_SLOT_NUMBER::@3809 u
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
#define PCI_INVALID_VENDORID
Definition: iotypes.h:3601
#define Len
Definition: deflate.h:82
unsigned char UCHAR
Definition: xmlstorage.h:181
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
VOID NTAPI HalpWritePCIConfig(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pcibus.c:287
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI HalpReadPCIConfig(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pcibus.c:261
#define PCI_COMMON_HDR_LENGTH
Definition: iotypes.h:3594

◆ HalpSetupPciDeviceForDebugging()

NTSTATUS NTAPI HalpSetupPciDeviceForDebugging ( IN PVOID  LoaderBlock,
IN OUT PDEBUG_DEVICE_DESCRIPTOR  PciDevice 
)

Definition at line 616 of file pcibus.c.

618 {
619  DPRINT1("Unimplemented!\n");
620  return STATUS_NOT_IMPLEMENTED;
621 }
return STATUS_NOT_IMPLEMENTED
#define DPRINT1
Definition: precomp.h:8

◆ HalpValidPCISlot()

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

Definition at line 331 of file pcibus.c.

333 {
334  PCI_SLOT_NUMBER MultiSlot;
335  PPCIPBUSDATA BusData = (PPCIPBUSDATA)BusHandler->BusData;
336  UCHAR HeaderType;
337  //ULONG Device;
338 
339  /* Simple validation */
340  if (Slot.u.bits.Reserved) return FALSE;
341  if (Slot.u.bits.DeviceNumber >= BusData->MaxDevice) return FALSE;
342 
343 #ifdef SARCH_XBOX
344  if (HalpXboxBlacklistedPCISlot(BusHandler, Slot)) return FALSE;
345 #endif
346 
347  /* Function 0 doesn't need checking */
348  if (!Slot.u.bits.FunctionNumber) return TRUE;
349 
350  /* Functions 0+ need Multi-Function support, so check the slot */
351  //Device = Slot.u.bits.DeviceNumber;
352  MultiSlot = Slot;
353  MultiSlot.u.bits.FunctionNumber = 0;
354 
355  /* Send function 0 request to get the header back */
356  HalpReadPCIConfig(BusHandler,
357  MultiSlot,
358  &HeaderType,
359  FIELD_OFFSET(PCI_COMMON_CONFIG, HeaderType),
360  sizeof(UCHAR));
361 
362  /* Now make sure the header is multi-function */
363  if (!(HeaderType & PCI_MULTIFUNCTION) || (HeaderType == 0xFF)) return FALSE;
364  return TRUE;
365 }
ULONG MaxDevice
Definition: bus.h:100
#define TRUE
Definition: types.h:120
struct _PCI_SLOT_NUMBER::@3809::@3810 bits
#define PCI_MULTIFUNCTION
Definition: iotypes.h:3604
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define FALSE
Definition: types.h:117
union _PCI_SLOT_NUMBER::@3809 u
unsigned char UCHAR
Definition: xmlstorage.h:181
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
struct _PCIPBUSDATA * PPCIPBUSDATA
VOID NTAPI HalpReadPCIConfig(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pcibus.c:261

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 287 of file pcibus.c.

292 {
293  /* Validate the PCI Slot */
294  if (HalpValidPCISlot(BusHandler, Slot))
295  {
296  /* Send the request */
297  HalpPCIConfig(BusHandler,
298  Slot,
299  Buffer,
300  Offset,
301  Length,
303  }
304 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
BOOLEAN NTAPI HalpValidPCISlot(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot)
Definition: pcibus.c:331
Definition: bufpool.h:45
PCI_CONFIG_HANDLER PCIConfigHandler
Definition: pcibus.c:25
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:223
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
FncConfigIO ConfigWrite[3]
Definition: bus.h:130

Referenced by HalpAssignPCISlotResources(), and HalpSetPCIData().

◆ PciSize()

static ULONG NTAPI PciSize ( ULONG  Base,
ULONG  Mask 
)
static

Definition at line 662 of file pcibus.c.

663 {
664  ULONG Size = Mask & Base; /* Find the significant bits */
665  Size = Size & ~(Size - 1); /* Get the lowest of them to find the decode size */
666  return Size;
667 }
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2386
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
processorSet Mask
unsigned int ULONG
Definition: retypes.h:1

Referenced by HalpAssignPCISlotResources().

Variable Documentation

◆ HalpBusType

ULONG HalpBusType

Definition at line 18 of file pcibus.c.

◆ HalpFakePciBusData

PCIPBUSDATA HalpFakePciBusData
Initial value:
=
{
{
{{{0, 0, 0}}},
{0, 0, 0, 0}
},
{{0, 0}},
32,
}
#define PCI_DATA_TAG
Definition: iotypes.h:5275
#define PCI_DATA_VERSION
Definition: iotypes.h:5276
VOID NTAPI HalpWritePCIConfig(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pcibus.c:287
#define NULL
Definition: types.h:112
VOID NTAPI HalpReadPCIConfig(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pcibus.c:261

Definition at line 80 of file pcibus.c.

◆ HalpFakePciBusHandler

BUS_HANDLER HalpFakePciBusHandler
Initial value:
=
{
1,
0,
0,
{0, 0, 0, 0},
}
ULONG NTAPI HalpGetPCIData(IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pcibus.c:371
ULONG(NTAPI * PGETSETBUSDATA)(_In_ PBUS_HANDLER BusHandler, _In_ PBUS_HANDLER RootHandler, _In_ ULONG SlotNumber, _Out_ PVOID Buffer, _In_ ULONG Offset, _In_ ULONG Length)
Definition: haltypes.h:125
PCIPBUSDATA HalpFakePciBusData
Definition: pcibus.c:80
#define NULL
Definition: types.h:112
ULONG NTAPI HalpSetPCIData(IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pcibus.c:455
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 *AllocatedResources)
Definition: pcibus.c:712

Definition at line 96 of file pcibus.c.

Referenced by HaliPciInterfaceReadConfig(), and HalpInitializePciStubs().

◆ HalpMaxPciBus

ULONG HalpMaxPciBus

Definition at line 23 of file pcibus.c.

Referenced by HalpInitializePciStubs().

◆ HalpMinPciBus

ULONG HalpMinPciBus

Definition at line 23 of file pcibus.c.

◆ HalpPCIConfigInitialized

BOOLEAN HalpPCIConfigInitialized

Definition at line 22 of file pcibus.c.

Referenced by HalpInitializePciStubs().

◆ HalpPCIConfigLock

◆ HalpPciDebuggingDevice

PCI_TYPE1_CFG_CYCLE_BITS HalpPciDebuggingDevice[2] = {{{{0}}}}

Definition at line 20 of file pcibus.c.

Referenced by HalpRegisterPciDebuggingDeviceInfo().

◆ HalpPciLockSettings

BOOLEAN HalpPciLockSettings

Definition at line 18 of file halinit.c.

Referenced by HalpAdjustPCIResourceList(), and HalpGetParameters().

◆ PCIConfigHandler

PCI_CONFIG_HANDLER PCIConfigHandler

◆ PCIConfigHandlerType1

PCI_CONFIG_HANDLER PCIConfigHandlerType1
Initial value:
=
{
{
(FncConfigIO)HalpPCIReadUlongType1,
(FncConfigIO)HalpPCIReadUcharType1,
(FncConfigIO)HalpPCIReadUshortType1
},
{
(FncConfigIO)HalpPCIWriteUlongType1,
(FncConfigIO)HalpPCIWriteUcharType1,
(FncConfigIO)HalpPCIWriteUshortType1
}
}
VOID NTAPI HalpPCIReleaseSynchronzationType1(IN PBUS_HANDLER BusHandler, IN KIRQL Irql)
Definition: pcibus.c:139
VOID(NTAPI * FncReleaseSync)(IN PBUS_HANDLER BusHandler, IN KIRQL Irql)
Definition: bus.h:120
VOID(NTAPI * FncSync)(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PKIRQL Irql, IN PVOID State)
Definition: bus.h:112
VOID NTAPI HalpPCISynchronizeType1(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PKIRQL Irql, IN PPCI_TYPE1_CFG_BITS PciCfg1)
Definition: pcibus.c:120
ULONG(NTAPI * FncConfigIO)(IN PPCIPBUSDATA BusData, IN PVOID State, IN PUCHAR Buffer, IN ULONG Offset)
Definition: bus.h:104

Definition at line 37 of file pcibus.c.

Referenced by HalpInitializePciStubs().

◆ PCIConfigHandlerType2

PCI_CONFIG_HANDLER PCIConfigHandlerType2
Initial value:
=
{
{
(FncConfigIO)HalpPCIReadUlongType2,
(FncConfigIO)HalpPCIReadUcharType2,
(FncConfigIO)HalpPCIReadUshortType2
},
{
(FncConfigIO)HalpPCIWriteUlongType2,
(FncConfigIO)HalpPCIWriteUcharType2,
(FncConfigIO)HalpPCIWriteUshortType2
}
}
VOID(NTAPI * FncReleaseSync)(IN PBUS_HANDLER BusHandler, IN KIRQL Irql)
Definition: bus.h:120
VOID(NTAPI * FncSync)(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PKIRQL Irql, IN PVOID State)
Definition: bus.h:112
VOID NTAPI HalpPCIReleaseSynchronizationType2(IN PBUS_HANDLER BusHandler, IN KIRQL Irql)
Definition: pcibus.c:196
ULONG(NTAPI * FncConfigIO)(IN PPCIPBUSDATA BusData, IN PVOID State, IN PUCHAR Buffer, IN ULONG Offset)
Definition: bus.h:104
VOID NTAPI HalpPCISynchronizeType2(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER Slot, IN PKIRQL Irql, IN PPCI_TYPE2_ADDRESS_BITS PciCfg)
Definition: pcibus.c:165

Definition at line 59 of file pcibus.c.

Referenced by HalpInitializePciStubs().

◆ PCIDeref

UCHAR PCIDeref[4][4]
Initial value:
=
{
{0, 1, 2, 2},
{1, 1, 1, 1},
{2, 1, 2, 2},
{1, 1, 1, 1}
}

Definition at line 28 of file pcibus.c.

Referenced by HalpPCIConfig().