ReactOS 0.4.17-dev-1190-g4c812f4
ppbridge.c File Reference
#include <pci.h>
#include <debug.h>
Include dependency graph for ppbridge.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

ULONG NTAPI PciBridgeIoBase (IN PPCI_COMMON_HEADER PciData)
 
ULONG NTAPI PciBridgeIoLimit (IN PPCI_COMMON_HEADER PciData)
 
ULONG NTAPI PciBridgeMemoryBase (IN PPCI_COMMON_HEADER PciData)
 
ULONG NTAPI PciBridgeMemoryLimit (IN PPCI_COMMON_HEADER PciData)
 
PHYSICAL_ADDRESS NTAPI PciBridgePrefetchMemoryBase (IN PPCI_COMMON_HEADER PciData)
 
PHYSICAL_ADDRESS NTAPI PciBridgePrefetchMemoryLimit (IN PPCI_COMMON_HEADER PciData)
 
ULONG NTAPI PciBridgeMemoryWorstCaseAlignment (IN ULONG Length)
 
BOOLEAN NTAPI PciBridgeIsPositiveDecode (IN PPCI_PDO_EXTENSION PdoExtension)
 
BOOLEAN NTAPI PciBridgeIsSubtractiveDecode (IN PPCI_CONFIGURATOR_CONTEXT Context)
 
VOID NTAPI PPBridge_SaveCurrentSettings (IN PPCI_CONFIGURATOR_CONTEXT Context)
 
VOID NTAPI PPBridge_SaveLimits (IN PPCI_CONFIGURATOR_CONTEXT Context)
 
VOID NTAPI PPBridge_MassageHeaderForLimitsDetermination (IN PPCI_CONFIGURATOR_CONTEXT Context)
 
VOID NTAPI PPBridge_RestoreCurrent (IN PPCI_CONFIGURATOR_CONTEXT Context)
 
VOID NTAPI PPBridge_GetAdditionalResourceDescriptors (IN PPCI_CONFIGURATOR_CONTEXT Context, IN PPCI_COMMON_HEADER PciData, IN PIO_RESOURCE_DESCRIPTOR IoDescriptor)
 
VOID NTAPI PPBridge_ResetDevice (IN PPCI_PDO_EXTENSION PdoExtension, IN PPCI_COMMON_HEADER PciData)
 
static VOID NTAPI PciBridgeOpenWindow (_Inout_ PPCI_COMMON_HEADER PciData, _In_ ULONG Index, _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Window)
 Opens one forwarding window of a bridge over the range assigned to it.
 
static VOID NTAPI PciBridgeRestoreOpenWindows (_Inout_ PPCI_COMMON_HEADER PciData, _In_ PPCI_COMMON_HEADER SavedHeader)
 Copies back the windows that were open in a bridge header saved before enumeration.
 
NTSTATUS NTAPI PPBridge_ChangeResourceSettings (_In_ PPCI_PDO_EXTENSION PdoExtension, _Inout_ PPCI_COMMON_HEADER PciData)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file ppbridge.c.

Function Documentation

◆ PciBridgeIoBase()

ULONG NTAPI PciBridgeIoBase ( IN PPCI_COMMON_HEADER  PciData)

Definition at line 20 of file ppbridge.c.

21{
22 BOOLEAN Is32Bit;
23 ULONG Base, IoBase;
25
26 /* Get the base */
27 Base = PciData->u.type1.IOBase;
28
29 /* Low bit specifies 32-bit address, top bits specify the base */
30 Is32Bit = (Base & 0xF) == 1;
31 IoBase = (Base & 0xF0) << 8;
32
33 /* Is it 32-bit? */
34 if (Is32Bit)
35 {
36 /* Read the upper 16-bits from the other register */
37 IoBase |= PciData->u.type1.IOBaseUpper16 << 16;
38 ASSERT(PciData->u.type1.IOLimit & 0x1);
39 }
40
41 /* Return the base address */
42 return IoBase;
43}
unsigned char BOOLEAN
Definition: actypes.h:127
#define ASSERT(a)
Definition: mode.c:44
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2486
uint32_t ULONG
Definition: typedefs.h:59
#define PCI_CONFIGURATION_TYPE(PciData)
Definition: iotypes.h:3624
#define PCI_BRIDGE_TYPE
Definition: iotypes.h:3621

Referenced by PciBridgeRestoreOpenWindows(), and PPBridge_SaveCurrentSettings().

◆ PciBridgeIoLimit()

ULONG NTAPI PciBridgeIoLimit ( IN PPCI_COMMON_HEADER  PciData)

Definition at line 47 of file ppbridge.c.

48{
49 BOOLEAN Is32Bit;
50 ULONG Limit, IoLimit;
52
53 /* Get the limit */
54 Limit = PciData->u.type1.IOLimit;
55
56 /* Low bit specifies 32-bit address, top bits specify the limit */
57 Is32Bit = (Limit & 0xF) == 1;
58 IoLimit = (Limit & 0xF0) << 8;
59
60 /* Is it 32-bit? */
61 if (Is32Bit)
62 {
63 /* Read the upper 16-bits from the other register */
64 IoLimit |= PciData->u.type1.IOLimitUpper16 << 16;
65 ASSERT(PciData->u.type1.IOBase & 0x1);
66 }
67
68 /* Return the I/O limit */
69 return IoLimit | 0xFFF;
70}
_In_ LONG _In_ LONG Limit
Definition: kefuncs.h:304

Referenced by PciBridgeRestoreOpenWindows(), PPBridge_SaveCurrentSettings(), and PPBridge_SaveLimits().

◆ PciBridgeIsPositiveDecode()

BOOLEAN NTAPI PciBridgeIsPositiveDecode ( IN PPCI_PDO_EXTENSION  PdoExtension)

Definition at line 167 of file ppbridge.c.

168{
169 /* Undocumented ACPI Method PDEC to get positive decode settings */
171}
BOOLEAN NTAPI PciIsSlotPresentInParentMethod(IN PPCI_PDO_EXTENSION PdoExtension, IN ULONG Method)
Definition: utils.c:1169
@ PdoExtension
Definition: precomp.h:61

Referenced by PciBridgeIsSubtractiveDecode().

◆ PciBridgeIsSubtractiveDecode()

BOOLEAN NTAPI PciBridgeIsSubtractiveDecode ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 175 of file ppbridge.c.

176{
177 PPCI_COMMON_HEADER Current, PciData;
179
180 /* Get pointers from context */
181 Current = Context->Current;
182 PciData = Context->PciData;
183 PdoExtension = Context->PdoExtension;
184
185 /* Only valid for PCI-to-PCI bridges */
186 ASSERT((Current->BaseClass == PCI_CLASS_BRIDGE_DEV) &&
187 (Current->SubClass == PCI_SUBCLASS_BR_PCI_TO_PCI));
188
189 /* Check for hacks first, then check the ProgIf of the bridge */
190 if (!(PdoExtension->HackFlags & PCI_HACK_SUBTRACTIVE_DECODE) &&
191 (Current->ProgIf != 1) &&
192 ((PciData->u.type1.IOLimit & 0xF0) == 0xF0))
193 {
194 /* A subtractive decode bridge would have a ProgIf 1, and no I/O limit */
195 DPRINT("PCIX - Subtractive decode does not seem to be enabled\n");
196 return FALSE;
197 }
198
199 /*
200 * Check for Intel ICH PCI-to-PCI (i82801) bridges (used on the i810,
201 * i820, i840, i845 Chipsets) that have subtractive decode broken.
202 */
203 if (((PdoExtension->VendorId == 0x8086) &&
204 ((PdoExtension->DeviceId == 0x2418) ||
205 (PdoExtension->DeviceId == 0x2428) ||
206 (PdoExtension->DeviceId == 0x244E) ||
207 (PdoExtension->DeviceId == 0x2448))) ||
209 {
210 /* Check if the ACPI BIOS says positive decode should be enabled */
212 {
213 /* Obey ACPI */
214 DPRINT1("PCIX - Putting bridge in positive decode because of PDEC\n");
215 return FALSE;
216 }
217 }
218
219 /* If we found subtractive decode, we'll need a resource update later */
220 DPRINT1("PCIX - Subtractive decode on 0x%x\n", Current->u.type1.SecondaryBus);
221 PdoExtension->UpdateHardware = TRUE;
222 return TRUE;
223}
#define DPRINT1
Definition: precomp.h:8
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
BOOLEAN NTAPI PciBridgeIsPositiveDecode(IN PPCI_PDO_EXTENSION PdoExtension)
Definition: ppbridge.c:167
#define PCI_HACK_SUBTRACTIVE_DECODE
Definition: pci.h:29
#define PCI_HACK_BROKEN_SUBTRACTIVE_DECODE
Definition: pci.h:50
#define DPRINT
Definition: sndvol32.h:73
#define PCI_SUBCLASS_BR_PCI_TO_PCI
Definition: iotypes.h:4181
#define PCI_CLASS_BRIDGE_DEV
Definition: iotypes.h:4124

Referenced by PPBridge_SaveLimits().

◆ PciBridgeMemoryBase()

ULONG NTAPI PciBridgeMemoryBase ( IN PPCI_COMMON_HEADER  PciData)

Definition at line 74 of file ppbridge.c.

75{
77
78 /* Return the memory base */
79 return (PciData->u.type1.MemoryBase << 16);
80}

Referenced by PciBridgeRestoreOpenWindows(), and PPBridge_SaveCurrentSettings().

◆ PciBridgeMemoryLimit()

ULONG NTAPI PciBridgeMemoryLimit ( IN PPCI_COMMON_HEADER  PciData)

Definition at line 84 of file ppbridge.c.

85{
87
88 /* Return the memory limit */
89 return (PciData->u.type1.MemoryLimit << 16) | 0xFFFFF;
90}

Referenced by PciBridgeRestoreOpenWindows(), PPBridge_SaveCurrentSettings(), and PPBridge_SaveLimits().

◆ PciBridgeMemoryWorstCaseAlignment()

ULONG NTAPI PciBridgeMemoryWorstCaseAlignment ( IN ULONG  Length)

Definition at line 150 of file ppbridge.c.

151{
153 ASSERT(Length != 0);
154
155 /* Start with highest alignment (2^31) */
156 Alignment = 0x80000000;
157
158 /* Keep dividing until we reach the correct power of two */
159 while (!(Length & Alignment)) Alignment >>= 1;
160
161 /* Return the alignment */
162 return Alignment;
163}
union Alignment_ Alignment
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102

Referenced by PPBridge_SaveCurrentSettings().

◆ PciBridgeOpenWindow()

static VOID NTAPI PciBridgeOpenWindow ( _Inout_ PPCI_COMMON_HEADER  PciData,
_In_ ULONG  Index,
_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR  Window 
)
static

Opens one forwarding window of a bridge over the range assigned to it.

Parameters
[in,out]PciDataThe bridge header, with all of its windows closed.
[in]IndexThe resource index of the window, 2 for I/O, 3 for memory and 4 for prefetchable memory.
[in]WindowThe range the window is to forward.

Definition at line 727 of file ppbridge.c.

731{
732 ULONGLONG First, Last, Length;
733 BOOLEAN TypeMatches;
734
735 /* A window with no range stays closed, a large prefetchable window is still memory */
736 if (Index == 2)
737 {
738 TypeMatches = (Window->Type == CmResourceTypePort);
739 }
740 else
741 {
742 TypeMatches = (Window->Type == CmResourceTypeMemory) ||
744 }
745
746 if (!TypeMatches)
747 return;
748
750 if (!Length)
751 return;
752
753 Last = First + Length - 1;
754
755 /* Low nibbles and unimplemented upper registers are read-only, so writing them is harmless */
756 if (Index == 2)
757 {
758 /* I/O is forwarded in 4KB steps */
759 PciData->u.type1.IOBase = (UCHAR)((First >> 8) & 0xF0);
760 PciData->u.type1.IOLimit = (UCHAR)((Last >> 8) & 0xF0);
761 PciData->u.type1.IOBaseUpper16 = (USHORT)(First >> 16);
762 PciData->u.type1.IOLimitUpper16 = (USHORT)(Last >> 16);
763 }
764 else if (Index == 3)
765 {
766 /* Memory is forwarded in 1MB steps and only below 4GB */
767 PciData->u.type1.MemoryBase = (USHORT)((First >> 16) & 0xFFF0);
768 PciData->u.type1.MemoryLimit = (USHORT)((Last >> 16) & 0xFFF0);
769 }
770 else
771 {
772 /* Prefetchable memory also moves in 1MB steps, with the high halves above 4GB */
773 PciData->u.type1.PrefetchBase = (USHORT)((First >> 16) & 0xFFF0);
774 PciData->u.type1.PrefetchLimit = (USHORT)((Last >> 16) & 0xFFF0);
775 PciData->u.type1.PrefetchBaseUpper32 = (ULONG)(First >> 32);
776 PciData->u.type1.PrefetchLimitUpper32 = (ULONG)(Last >> 32);
777 }
778}
WCHAR First[]
Definition: FormatMessage.c:11
ULONGLONG NTAPI RtlCmDecodeMemIoResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _Out_opt_ PULONGLONG Start)
Definition: memres.c:58
unsigned short USHORT
Definition: pedump.c:61
#define CmResourceTypeMemory
Definition: restypes.h:106
#define CmResourceTypePort
Definition: restypes.h:104
Definition: window.c:29
unsigned char UCHAR
Definition: typedefs.h:53
uint64_t ULONGLONG
Definition: typedefs.h:67
_In_ WDFCOLLECTION _In_ ULONG Index
#define CmResourceTypeMemoryLarge
Definition: cmtypes.h:231

Referenced by PPBridge_ChangeResourceSettings().

◆ PciBridgePrefetchMemoryBase()

PHYSICAL_ADDRESS NTAPI PciBridgePrefetchMemoryBase ( IN PPCI_COMMON_HEADER  PciData)

Definition at line 94 of file ppbridge.c.

95{
96 BOOLEAN Is64Bit;
98 USHORT PrefetchBase;
100
101 /* Get the base */
102 PrefetchBase = PciData->u.type1.PrefetchBase;
103
104 /* Low bit specifies 64-bit address, top bits specify the base */
105 Is64Bit = (PrefetchBase & 0xF) == 1;
106 Base.QuadPart = 0;
107 Base.LowPart = ((PrefetchBase & 0xFFF0) << 16);
108
109 /* Is it 64-bit? */
110 if (Is64Bit)
111 {
112 /* Read the upper 32-bits from the other register */
113 Base.HighPart = PciData->u.type1.PrefetchBaseUpper32;
114 }
115
116 /* Return the base */
117 return Base;
118}

Referenced by PciBridgeRestoreOpenWindows(), and PPBridge_SaveCurrentSettings().

◆ PciBridgePrefetchMemoryLimit()

PHYSICAL_ADDRESS NTAPI PciBridgePrefetchMemoryLimit ( IN PPCI_COMMON_HEADER  PciData)

Definition at line 122 of file ppbridge.c.

123{
124 BOOLEAN Is64Bit;
126 USHORT PrefetchLimit;
128
129 /* Get the base */
130 PrefetchLimit = PciData->u.type1.PrefetchLimit;
131
132 /* Low bit specifies 64-bit address, top bits specify the limit */
133 Is64Bit = (PrefetchLimit & 0xF) == 1;
134 Limit.QuadPart = 0;
135 Limit.LowPart = (PrefetchLimit << 16) | 0xFFFFF;
136
137 /* Is it 64-bit? */
138 if (Is64Bit)
139 {
140 /* Read the upper 32-bits from the other register */
141 Limit.HighPart = PciData->u.type1.PrefetchLimitUpper32;
142 }
143
144 /* Return the limit */
145 return Limit;
146}

Referenced by PciBridgeRestoreOpenWindows(), PPBridge_SaveCurrentSettings(), and PPBridge_SaveLimits().

◆ PciBridgeRestoreOpenWindows()

static VOID NTAPI PciBridgeRestoreOpenWindows ( _Inout_ PPCI_COMMON_HEADER  PciData,
_In_ PPCI_COMMON_HEADER  SavedHeader 
)
static

Copies back the windows that were open in a bridge header saved before enumeration.

Parameters
[in,out]PciDataThe bridge header, with all of its windows closed.
[in]SavedHeaderThe header PPBridge_SaveCurrentSettings kept for the bridge.

Definition at line 793 of file ppbridge.c.

796{
797 ULONGLONG First, Last;
798
799 /* A window based at zero or ending below its base was left closed */
800 First = PciBridgeIoBase(SavedHeader);
801 Last = PciBridgeIoLimit(SavedHeader);
802 if (First && (First < Last))
803 {
804 PciData->u.type1.IOBase = SavedHeader->u.type1.IOBase;
805 PciData->u.type1.IOLimit = SavedHeader->u.type1.IOLimit;
806 PciData->u.type1.IOBaseUpper16 = SavedHeader->u.type1.IOBaseUpper16;
807 PciData->u.type1.IOLimitUpper16 = SavedHeader->u.type1.IOLimitUpper16;
808 }
809
810 First = PciBridgeMemoryBase(SavedHeader);
811 Last = PciBridgeMemoryLimit(SavedHeader);
812 if (First && (First < Last))
813 {
814 PciData->u.type1.MemoryBase = SavedHeader->u.type1.MemoryBase;
815 PciData->u.type1.MemoryLimit = SavedHeader->u.type1.MemoryLimit;
816 }
817
820 if (First && (First < Last))
821 {
822 PciData->u.type1.PrefetchBase = SavedHeader->u.type1.PrefetchBase;
823 PciData->u.type1.PrefetchLimit = SavedHeader->u.type1.PrefetchLimit;
824 PciData->u.type1.PrefetchBaseUpper32 = SavedHeader->u.type1.PrefetchBaseUpper32;
825 PciData->u.type1.PrefetchLimitUpper32 = SavedHeader->u.type1.PrefetchLimitUpper32;
826 }
827}
PHYSICAL_ADDRESS NTAPI PciBridgePrefetchMemoryBase(IN PPCI_COMMON_HEADER PciData)
Definition: ppbridge.c:94
PHYSICAL_ADDRESS NTAPI PciBridgePrefetchMemoryLimit(IN PPCI_COMMON_HEADER PciData)
Definition: ppbridge.c:122
ULONG NTAPI PciBridgeIoBase(IN PPCI_COMMON_HEADER PciData)
Definition: ppbridge.c:20
ULONG NTAPI PciBridgeMemoryLimit(IN PPCI_COMMON_HEADER PciData)
Definition: ppbridge.c:84
ULONG NTAPI PciBridgeIoLimit(IN PPCI_COMMON_HEADER PciData)
Definition: ppbridge.c:47
ULONG NTAPI PciBridgeMemoryBase(IN PPCI_COMMON_HEADER PciData)
Definition: ppbridge.c:74
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by PPBridge_ChangeResourceSettings().

◆ PPBridge_ChangeResourceSettings()

NTSTATUS NTAPI PPBridge_ChangeResourceSettings ( _In_ PPCI_PDO_EXTENSION  PdoExtension,
_Inout_ PPCI_COMMON_HEADER  PciData 
)

Definition at line 831 of file ppbridge.c.

834{
835 //BOOLEAN IoActive;
836 PPCI_COMMON_CONFIG SavedConfig;
837 PPCI_FUNCTION_RESOURCES PciResources;
840 PULONG BarArray;
841 ULONG Bar, BarMask, i;
842
843 /* Check if I/O Decodes are enabled */
844 //IoActive = (PciData->u.type1.IOBase & 0xF) == 1;
845
846 /* Close every window, only the ones with a range to forward get opened again */
847 PciData->u.type1.MemoryBase = 0xFFFF;
848 PciData->u.type1.PrefetchBase = 0xFFFF;
849 PciData->u.type1.IOBase = 0xFF;
850 PciData->u.type1.IOLimit = 0;
851 PciData->u.type1.MemoryLimit = 0;
852 PciData->u.type1.PrefetchLimit = 0;
853 PciData->u.type1.PrefetchBaseUpper32 = 0;
854 PciData->u.type1.PrefetchLimitUpper32 = 0;
855 PciData->u.type1.IOBaseUpper16 = 0;
856 PciData->u.type1.IOLimitUpper16 = 0;
857
858 /* Only the bridges PPBridge_SaveCurrentSettings kept a header for have windows to restore */
859 SavedConfig = NULL;
860 if ((PdoExtension->Dependent.type1.SubtractiveDecode) &&
861 (((PdoExtension->VendorId == 0x8086) &&
862 ((PdoExtension->DeviceId == 0x2418) ||
863 (PdoExtension->DeviceId == 0x2428) ||
864 (PdoExtension->DeviceId == 0x244E) ||
865 (PdoExtension->DeviceId == 0x2448))) ||
867 {
868 SavedConfig = PdoExtension->ParentFdoExtension->PreservedConfig;
869 }
870
871 /* A subtractive bridge has no window limits, so the loop below leaves these alone */
872 if (SavedConfig)
873 PciBridgeRestoreOpenWindows(PciData, (PPCI_COMMON_HEADER)SavedConfig);
874
875 /* Write back the BARs, windows and ROM with the ranges assigned to them */
876 PciResources = PdoExtension->Resources;
877 if (PciResources)
878 {
879 BarArray = PciData->u.type1.BaseAddresses;
880 for (i = 0; i < 6; i++)
881 {
882 /* Nothing to write for what the bridge does not implement */
883 if (PciResources->Limit[i].Type == CmResourceTypeNull)
884 continue;
885
886 CmDescriptor = &PciResources->Current[i];
887 Address.QuadPart = 0;
888 if (CmDescriptor->Type != CmResourceTypeNull)
889 Address = CmDescriptor->u.Generic.Start;
890
892 {
893 /* Keep the type bits the BAR reports */
894 Bar = BarArray[i];
897 else
899
900 BarArray[i] = (Bar & ~BarMask) | (Address.LowPart & BarMask);
901
902 /* A 64-bit BAR takes the high half of the address in the next BAR */
903 if (!(Bar & PCI_ADDRESS_IO_SPACE) &&
905 ((i + 1) < PCI_TYPE1_ADDRESSES))
906 {
907 i++;
908 BarArray[i] = Address.HighPart;
909 }
910 }
911 else if (i < 5)
912 {
913 PciBridgeOpenWindow(PciData, i, CmDescriptor);
914 }
915 else
916 {
917 /* The ROM decodes only while its enable bit is set */
918 Bar = PciData->u.type1.ROMBaseAddress &
920 if (CmDescriptor->Type != CmResourceTypeNull)
921 {
924 }
925
926 PciData->u.type1.ROMBaseAddress = Bar;
927 }
928 }
929 }
930
931 /* Copy the bus number data */
932 PciData->u.type1.PrimaryBus = PdoExtension->Dependent.type1.PrimaryBus;
933 PciData->u.type1.SecondaryBus = PdoExtension->Dependent.type1.SecondaryBus;
934 PciData->u.type1.SubordinateBus = PdoExtension->Dependent.type1.SubordinateBus;
935
936 /* Copy the decode flags */
937 if (PdoExtension->Dependent.type1.IsaBitSet)
938 {
939 PciData->u.type1.BridgeControl |= PCI_ENABLE_BRIDGE_ISA;
940 }
941
942 if (PdoExtension->Dependent.type1.VgaBitSet)
943 {
944 PciData->u.type1.BridgeControl |= PCI_ENABLE_BRIDGE_VGA;
945 }
946
947 return STATUS_SUCCESS;
948}
#define NULL
Definition: types.h:112
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
void Bar(void)
Definition: terminate.cpp:70
static WCHAR Address[46]
Definition: ping.c:68
static VOID NTAPI PciBridgeRestoreOpenWindows(_Inout_ PPCI_COMMON_HEADER PciData, _In_ PPCI_COMMON_HEADER SavedHeader)
Copies back the windows that were open in a bridge header saved before enumeration.
Definition: ppbridge.c:793
static VOID NTAPI PciBridgeOpenWindow(_Inout_ PPCI_COMMON_HEADER PciData, _In_ ULONG Index, _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Window)
Opens one forwarding window of a bridge over the range assigned to it.
Definition: ppbridge.c:727
#define CmResourceTypeNull
Definition: restypes.h:103
#define PCI_ENABLE_BRIDGE_VGA
Definition: pci.h:63
#define PCI_ENABLE_BRIDGE_ISA
Definition: pci.h:62
#define STATUS_SUCCESS
Definition: shellext.h:65
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@494 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@494::@495 Generic
IO_RESOURCE_DESCRIPTOR Limit[7]
Definition: pci.h:287
CM_PARTIAL_RESOURCE_DESCRIPTOR Current[7]
Definition: pci.h:288
uint32_t * PULONG
Definition: typedefs.h:59
#define PCI_TYPE_64BIT
Definition: iotypes.h:4255
#define PCI_ADDRESS_IO_ADDRESS_MASK
Definition: iotypes.h:4249
#define PCI_ADDRESS_IO_SPACE
Definition: iotypes.h:4246
#define PCI_TYPE1_ADDRESSES
Definition: iotypes.h:3516
#define PCI_ADDRESS_ROM_ADDRESS_MASK
Definition: iotypes.h:4251
#define PCI_ADDRESS_MEMORY_ADDRESS_MASK
Definition: iotypes.h:4250
#define PCI_ROMADDRESS_ENABLED
Definition: iotypes.h:4257
#define PCI_ADDRESS_MEMORY_TYPE_MASK
Definition: iotypes.h:4247

◆ PPBridge_GetAdditionalResourceDescriptors()

VOID NTAPI PPBridge_GetAdditionalResourceDescriptors ( IN PPCI_CONFIGURATOR_CONTEXT  Context,
IN PPCI_COMMON_HEADER  PciData,
IN PIO_RESOURCE_DESCRIPTOR  IoDescriptor 
)

Definition at line 657 of file ppbridge.c.

660{
661
663
664 /* Does this bridge have VGA decodes on it? */
665 if (PciData->u.type1.BridgeControl & PCI_ENABLE_BRIDGE_VGA)
666 {
667 /* Build a private descriptor with 3 entries */
668 IoDescriptor->Type = CmResourceTypeDevicePrivate;
669 IoDescriptor->u.DevicePrivate.Data[0] = 3;
670 IoDescriptor->u.DevicePrivate.Data[1] = 3;
671
672 /* First, the VGA range at 0xA0000 */
673 IoDescriptor[1].Type = CmResourceTypeMemory;
674 IoDescriptor[1].Flags = CM_RESOURCE_MEMORY_READ_WRITE;
675 IoDescriptor[1].u.Port.Length = 0x20000;
676 IoDescriptor[1].u.Port.Alignment = 1;
677 IoDescriptor[1].u.Port.MinimumAddress.QuadPart = 0xA0000;
678 IoDescriptor[1].u.Port.MaximumAddress.QuadPart = 0xBFFFF;
679
680 /* Then, the VGA registers at 0x3B0 */
681 IoDescriptor[2].Type = CmResourceTypePort;
682 IoDescriptor[2].Flags = CM_RESOURCE_PORT_POSITIVE_DECODE |
684 IoDescriptor[2].u.Port.Length = 12;
685 IoDescriptor[2].u.Port.Alignment = 1;
686 IoDescriptor[2].u.Port.MinimumAddress.QuadPart = 0x3B0;
687 IoDescriptor[2].u.Port.MaximumAddress.QuadPart = 0x3BB;
688
689 /* And finally the VGA registers at 0x3C0 */
690 IoDescriptor[3].Type = CmResourceTypePort;
691 IoDescriptor[3].Flags = CM_RESOURCE_PORT_POSITIVE_DECODE |
693 IoDescriptor[3].u.Port.Length = 32;
694 IoDescriptor[3].u.Port.Alignment = 1;
695 IoDescriptor[3].u.Port.MinimumAddress.QuadPart = 0x3C0;
696 IoDescriptor[3].u.Port.MaximumAddress.QuadPart = 0x3DF;
697 }
698}
#define CM_RESOURCE_PORT_POSITIVE_DECODE
Definition: cmtypes.h:113
#define CM_RESOURCE_MEMORY_READ_WRITE
Definition: cmtypes.h:121
#define CM_RESOURCE_PORT_10_BIT_DECODE
Definition: cmtypes.h:110
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
#define CmResourceTypeDevicePrivate
Definition: restypes.h:112

Referenced by Cardbus_GetAdditionalResourceDescriptors().

◆ PPBridge_MassageHeaderForLimitsDetermination()

VOID NTAPI PPBridge_MassageHeaderForLimitsDetermination ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 611 of file ppbridge.c.

612{
613 PPCI_COMMON_HEADER PciData, Current;
614
615 /* Get pointers from context */
616 PciData = Context->PciData;
617 Current = Context->Current;
618
619 /*
620 * Write FFh everywhere so that the PCI bridge ignores what it can't handle.
621 * Based on the bits that were ignored (still 0), this is how we can tell
622 * what the limit is.
623 */
624 RtlFillMemory(PciData->u.type1.BaseAddresses,
625 FIELD_OFFSET(PCI_COMMON_HEADER, u.type1.CapabilitiesPtr) -
626 FIELD_OFFSET(PCI_COMMON_HEADER, u.type1.BaseAddresses),
627 0xFF);
628
629 /* Copy the saved settings from the current context into the PCI header */
630 PciData->u.type1.PrimaryBus = Current->u.type1.PrimaryBus;
631 PciData->u.type1.SecondaryBus = Current->u.type1.SecondaryBus;
632 PciData->u.type1.SubordinateBus = Current->u.type1.SubordinateBus;
633 PciData->u.type1.SecondaryLatency = Current->u.type1.SecondaryLatency;
634
635 /* No I/O limit or base. The bottom base bit specifies that FIXME */
636 PciData->u.type1.IOBaseUpper16 = 0xFFFE;
637 PciData->u.type1.IOLimitUpper16 = 0xFFFF;
638
639 /* Save secondary status before it gets cleared */
640 Context->SecondaryStatus = Current->u.type1.SecondaryStatus;
641
642 /* Clear secondary status */
643 Current->u.type1.SecondaryStatus = 0;
644 PciData->u.type1.SecondaryStatus = 0;
645}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:603
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

◆ PPBridge_ResetDevice()

VOID NTAPI PPBridge_ResetDevice ( IN PPCI_PDO_EXTENSION  PdoExtension,
IN PPCI_COMMON_HEADER  PciData 
)

Definition at line 702 of file ppbridge.c.

704{
706
707 /* Never write the header back with the secondary bus held in reset */
708 PciData->u.type1.BridgeControl &= ~PCI_ASSERT_BRIDGE_RESET;
709}

◆ PPBridge_RestoreCurrent()

VOID NTAPI PPBridge_RestoreCurrent ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 649 of file ppbridge.c.

650{
651 /* Copy back the secondary status register */
652 Context->Current->u.type1.SecondaryStatus = Context->SecondaryStatus;
653}

◆ PPBridge_SaveCurrentSettings()

VOID NTAPI PPBridge_SaveCurrentSettings ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 227 of file ppbridge.c.

228{
231 PIO_RESOURCE_DESCRIPTOR IoDescriptor;
234 PPCI_COMMON_HEADER Current;
235 PPCI_COMMON_CONFIG SavedConfig;
236 ULONG i, Bar, BarMask;
237 PULONG BarArray;
239 BOOLEAN HaveIoLimit, CheckAlignment;
241
242 /* Get the pointers from the extension */
243 PdoExtension = Context->PdoExtension;
244 Resources = PdoExtension->Resources;
245 Current = Context->Current;
246
247 /* Check if decodes are disabled */
249 {
250 /* Well, we're going to need them from somewhere, use the registry data */
252 if (NT_SUCCESS(Status)) Current = &BiosData;
253 }
254
255 /* Scan all current and limit descriptors for each BAR needed */
256 BarArray = Current->u.type1.BaseAddresses;
257 for (i = 0; i < 6; i++)
258 {
259 /* Get the current resource descriptor, and the limit requirement */
260 CmDescriptor = &Resources->Current[i];
261 IoDescriptor = &Resources->Limit[i];
262
263 /* Copy descriptor data, skipping null descriptors */
264 CmDescriptor->Type = IoDescriptor->Type;
265 if (CmDescriptor->Type == CmResourceTypeNull) continue;
266 CmDescriptor->Flags = IoDescriptor->Flags;
267 CmDescriptor->ShareDisposition = IoDescriptor->ShareDisposition;
268
269 /* Initialize the high-parts to zero, since most stuff is 32-bit only */
270 Base.QuadPart = Limit.QuadPart = Length.QuadPart = 0;
271
272 /* Check if we're handling PCI BARs, or the ROM BAR */
273 if ((i < PCI_TYPE1_ADDRESSES) || (i == 5))
274 {
275 /* Is this the ROM BAR? */
276 if (i == 5)
277 {
278 /* Read the correct bar, with the appropriate mask */
279 Bar = Current->u.type1.ROMBaseAddress;
281
282 /* Decode the base address, and write down the length */
283 Base.LowPart = Bar & BarMask;
284 DPRINT1("PCIX - ROM BAR Base: %lx\n", Base.LowPart);
285 CmDescriptor->u.Memory.Length = IoDescriptor->u.Memory.Length;
286 }
287 else
288 {
289 /* Otherwise, get the BAR from the array */
290 Bar = BarArray[i];
291
292 /* Is this an I/O BAR? */
294 {
295 /* Set the correct mask */
296 ASSERT(CmDescriptor->Type == CmResourceTypePort);
298 }
299 else
300 {
301 /* This is a memory BAR, set the correct base */
302 ASSERT((CmDescriptor->Type == CmResourceTypeMemory) ||
303 (CmDescriptor->Type == CmResourceTypeMemoryLarge));
305
306 /* IS this a 64-bit BAR? */
308 {
309 /* Read the next 32-bits as well, ie, the next BAR */
310 Base.HighPart = BarArray[i + 1];
311 }
312 }
313
314 /* Decode the base address, and write down the length */
315 Base.LowPart = Bar & BarMask;
316 DPRINT1("PCIX - BAR Base: %lx\n", Base.LowPart);
317 CmDescriptor->u.Generic.Length = IoDescriptor->u.Generic.Length;
318 }
319 }
320 else
321 {
322 /* Reset loop conditions */
323 HaveIoLimit = FALSE;
325
326 /* Check which descriptor is being parsed */
327 if (i == 2)
328 {
329 /* I/O Port Requirements */
330 Base.LowPart = PciBridgeIoBase(Current);
331 Limit.LowPart = PciBridgeIoLimit(Current);
332 DPRINT1("PCIX - Bridge I/O Base and Limit: %lx %lx\n",
333 Base.LowPart, Limit.LowPart);
334
335 /* Do we have any I/O Port data? */
336 if (!(Base.LowPart) && (Current->u.type1.IOLimit))
337 {
338 /* There's a limit */
339 HaveIoLimit = TRUE;
340 }
341 }
342 else if (i == 3)
343 {
344 /* Memory requirements */
345 Base.LowPart = PciBridgeMemoryBase(Current);
346 Limit.LowPart = PciBridgeMemoryLimit(Current);
347
348 /* These should always be there, so check their alignment */
349 DPRINT1("PCIX - Bridge MEM Base and Limit: %lx %lx\n",
350 Base.LowPart, Limit.LowPart);
352 }
353 else if (i == 4)
354 {
355 /* This should only be present for prefetch memory */
359
360 /* If it's there, check the alignment */
361 DPRINT1("PCIX - Bridge Prefetch MEM Base and Limit: %I64x %I64x\n", Base, Limit);
363 }
364
365 /* Check for invalid base address */
366 if (Base.QuadPart >= Limit.QuadPart)
367 {
368 /* Assume the descriptor is bogus */
369 CmDescriptor->Type = CmResourceTypeNull;
370 IoDescriptor->Type = CmResourceTypeNull;
371 continue;
372 }
373
374 /* Check if there's no memory, and no I/O port either */
375 if (!(Base.QuadPart) && !(HaveIoLimit))
376 {
377 /* This seems like a bogus requirement, ignore it */
378 CmDescriptor->Type = CmResourceTypeNull;
379 continue;
380 }
381
382 /* The window spans its base through its limit */
383 Length.QuadPart = Limit.QuadPart - Base.QuadPart + 1;
384
385 /* Junk in the upper prefetch limit would give a window no descriptor can hold */
387 (Limit.HighPart > Base.HighPart) &&
388 (Limit.LowPart > Base.LowPart))
389 {
390 DPRINT1("PCIX - Bridge prefetch limit %I64x has junk in its upper half\n",
391 Limit.QuadPart);
392 Limit.HighPart = Base.HighPart;
393 Length.QuadPart = Limit.QuadPart - Base.QuadPart + 1;
394 }
395
396 /* A prefetchable window of 4GB or more takes the large memory form */
397 Status = RtlCmEncodeMemIoResource(CmDescriptor,
398 CmDescriptor->Type,
399 Length.QuadPart,
400 Base.QuadPart);
401 if (!NT_SUCCESS(Status))
402 {
403 CmDescriptor->Type = CmResourceTypeNull;
404 continue;
405 }
406
407 /* Check if alignment should be set */
408 if (CheckAlignment)
409 {
410 /* Compute the required alignment for this length, 2GB at most */
411 if (Length.HighPart)
412 {
413 IoDescriptor->u.Memory.Alignment = 0x80000000;
414 }
415 else
416 {
417 IoDescriptor->u.Memory.Alignment =
419 }
420 }
421 }
422
423 /* Now set the base address */
424 CmDescriptor->u.Generic.Start = Base;
425 }
426
427 /* Save PCI settings into the PDO extension for easy access later */
428 PdoExtension->Dependent.type1.PrimaryBus = Current->u.type1.PrimaryBus;
429 PdoExtension->Dependent.type1.SecondaryBus = Current->u.type1.SecondaryBus;
430 PdoExtension->Dependent.type1.SubordinateBus = Current->u.type1.SubordinateBus;
431
432 /* Check for subtractive decode bridges */
433 if (PdoExtension->Dependent.type1.SubtractiveDecode)
434 {
435 /* Check if legacy VGA decodes are enabled */
436 DPRINT1("PCIX - Subtractive decode bridge\n");
437 if (Current->u.type1.BridgeControl & PCI_ENABLE_BRIDGE_VGA)
438 {
439 /* Save this setting for later */
440 DPRINT1("PCIX - VGA Bridge\n");
441 PdoExtension->Dependent.type1.VgaBitSet = TRUE;
442 }
443
444 /* Legacy ISA decoding is not compatible with subtractive decode */
445 ASSERT(PdoExtension->Dependent.type1.IsaBitSet == FALSE);
446 }
447 else
448 {
449 /* Check if legacy VGA decodes are enabled */
450 if (Current->u.type1.BridgeControl & PCI_ENABLE_BRIDGE_VGA)
451 {
452 /* Save this setting for later */
453 DPRINT1("PCIX - VGA Bridge\n");
454 PdoExtension->Dependent.type1.VgaBitSet = TRUE;
455
456 /* And on positive decode, we'll also need extra resources locked */
457 PdoExtension->AdditionalResourceCount = 4;
458 }
459
460 /* Check if legacy ISA decoding is enabled */
461 if (Current->u.type1.BridgeControl & PCI_ENABLE_BRIDGE_ISA)
462 {
463 /* Save this setting for later */
464 DPRINT1("PCIX - ISA Bridge\n");
465 PdoExtension->Dependent.type1.IsaBitSet = TRUE;
466 }
467 }
468
469 /*
470 * Check for Intel ICH PCI-to-PCI (i82801) bridges (used on the i810,
471 * i820, i840, i845 Chipsets) that have subtractive decode broken.
472 */
473 if (((PdoExtension->VendorId == 0x8086) &&
474 ((PdoExtension->DeviceId == 0x2418) ||
475 (PdoExtension->DeviceId == 0x2428) ||
476 (PdoExtension->DeviceId == 0x244E) ||
477 (PdoExtension->DeviceId == 0x2448))) ||
479 {
480 /* Check if subtractive decode is actually enabled */
481 if (PdoExtension->Dependent.type1.SubtractiveDecode)
482 {
483 /* We're going to need a copy of the configuration for later use */
484 DPRINT1("PCIX - apply config save hack to ICH subtractive decode\n");
486 PdoExtension->ParentFdoExtension->PreservedConfig = SavedConfig;
487 if (SavedConfig) RtlCopyMemory(SavedConfig, Current, PCI_COMMON_HDR_LENGTH);
488 }
489 }
490}
VOID CheckAlignment()
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
NTSTATUS NTAPI PciGetBiosConfig(IN PPCI_PDO_EXTENSION DeviceExtension, OUT PPCI_COMMON_HEADER PciData)
Definition: utils.c:840
#define TAG_PCI_PRESERVED
Definition: pci.h:37
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Status
Definition: gdiplustypes.h:24
#define CM_RESOURCE_MEMORY_PREFETCHABLE
Definition: cmtypes.h:125
#define CM_RESOURCE_MEMORY_LARGE_48_MAXLEN
Definition: cmtypes.h:139
ULONG NTAPI PciBridgeMemoryWorstCaseAlignment(IN ULONG Length)
Definition: ppbridge.c:150
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@494::@499 Memory
struct _IO_RESOURCE_DESCRIPTOR::@2498::@2503 Generic
union _IO_RESOURCE_DESCRIPTOR::@2498 u
struct _IO_RESOURCE_DESCRIPTOR::@2498::@2500 Memory
PBIOS_DATA BiosData
Definition: bios.c:42
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define PCI_ENABLE_IO_SPACE
Definition: iotypes.h:3631
#define PCI_ENABLE_MEMORY_SPACE
Definition: iotypes.h:3632
#define PCI_COMMON_HDR_LENGTH
Definition: iotypes.h:3609
NTSYSAPI NTSTATUS NTAPI RtlCmEncodeMemIoResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _In_ UCHAR Type, _In_ ULONGLONG Length, _In_ ULONGLONG Start)
Definition: memres.c:116

◆ PPBridge_SaveLimits()

VOID NTAPI PPBridge_SaveLimits ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 494 of file ppbridge.c.

495{
497 PULONG BarArray;
498 PHYSICAL_ADDRESS MemoryLimit;
499 ULONG i;
502
503 /* Get the pointers from the context */
504 Working = Context->PciData;
505 PdoExtension = Context->PdoExtension;
506
507 /* Scan the BARs into the limit descriptors */
508 BarArray = Working->u.type1.BaseAddresses;
509 Limit = PdoExtension->Resources->Limit;
510
511 /* First of all, loop all the BARs */
512 for (i = 0; i < PCI_TYPE1_ADDRESSES; i++)
513 {
514 /* Create a descriptor for their limits, the second BAR has no BAR after it */
515 ULONG NextBar = ((i + 1) < PCI_TYPE1_ADDRESSES) ? BarArray[i + 1] : 0;
516
517 if (PciCreateIoDescriptorFromBarLimit(&Limit[i], BarArray[i], NextBar, FALSE))
518 {
519 /* This was a 64-bit descriptor, make sure there's space */
521
522 /* Skip the next descriptor since this one is double sized */
523 i++;
524 Limit[i].Type = CmResourceTypeNull;
525 }
526 }
527
528 /* Check if this is a subtractive decode bridge */
530 {
531 /* This bridge is subtractive */
532 PdoExtension->Dependent.type1.SubtractiveDecode = TRUE;
533
534 /* Subtractive bridges cannot use legacy ISA or VGA functionality */
535 PdoExtension->Dependent.type1.IsaBitSet = FALSE;
536 PdoExtension->Dependent.type1.VgaBitSet = FALSE;
537 }
538
539 /* For normal decode bridges, we'll need to find the bridge limits too */
540 if (!PdoExtension->Dependent.type1.SubtractiveDecode)
541 {
542 /* Loop the descriptors that are left, to store the bridge limits */
543 for (i = PCI_TYPE1_ADDRESSES; i < 5; i++)
544 {
545 /* No 64-bit memory addresses, and set the address to 0 to begin */
546 MemoryLimit.HighPart = 0;
547 (&Limit[i])->u.Port.MinimumAddress.QuadPart = 0;
548
549 /* Are we getting the I/O limit? */
550 if (i == 2)
551 {
552 /* There should be one, get it */
553 ASSERT(Working->u.type1.IOLimit != 0);
554 ASSERT((Working->u.type1.IOLimit & 0x0E) == 0);
555 MemoryLimit.LowPart = PciBridgeIoLimit(Working);
556
557 /* Build a descriptor for this limit */
561 (&Limit[i])->u.Port.Alignment = 0x1000;
562 (&Limit[i])->u.Port.MinimumAddress.QuadPart = 0;
563 (&Limit[i])->u.Port.MaximumAddress = MemoryLimit;
564 (&Limit[i])->u.Port.Length = 0;
565 }
566 else if (i == 3)
567 {
568 /* There should be a valid memory limit, get it */
569 ASSERT((Working->u.type1.MemoryLimit & 0xF) == 0);
570 MemoryLimit.LowPart = PciBridgeMemoryLimit(Working);
571
572 /* Build the descriptor for it */
575 (&Limit[i])->u.Memory.Alignment = 0x100000;
576 (&Limit[i])->u.Memory.MinimumAddress.QuadPart = 0;
577 (&Limit[i])->u.Memory.MaximumAddress = MemoryLimit;
578 (&Limit[i])->u.Memory.Length = 0;
579 }
580 else if (Working->u.type1.PrefetchLimit)
581 {
582 /* Get the prefetch memory limit, if there is one */
584
585 /* Write out the descriptor for it */
588 (&Limit[i])->u.Memory.Alignment = 0x100000;
589 (&Limit[i])->u.Memory.MinimumAddress.QuadPart = 0;
590 (&Limit[i])->u.Memory.MaximumAddress = MemoryLimit;
591 (&Limit[i])->u.Memory.Length = 0;
592 }
593 else
594 {
595 /* Blank descriptor */
597 }
598 }
599 }
600
601 /* Does the ROM have its own BAR? */
602 if (Working->u.type1.ROMBaseAddress & PCI_ROMADDRESS_ENABLED)
603 {
604 /* Build a limit for it as well */
605 PciCreateIoDescriptorFromBarLimit(&Limit[i], Working->u.type1.ROMBaseAddress, 0, TRUE);
606 }
607}
Type
Definition: Type.h:7
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ ULONG _In_ ULONG Flags
Definition: dispmprt.h:245
BOOLEAN NTAPI PciCreateIoDescriptorFromBarLimit(_Out_ PIO_RESOURCE_DESCRIPTOR ResourceDescriptor, _In_ ULONG Bar, _In_ ULONG NextBar, _In_ BOOLEAN Rom)
Builds the requirement of a BAR from the value it reads back after all ones were written to it.
Definition: utils.c:1252
@ Working
Definition: fbtusb.h:82
if(dx< 0)
Definition: linetemp.h:194
#define CM_RESOURCE_PORT_WINDOW_DECODE
Definition: cmtypes.h:115
BOOLEAN NTAPI PciBridgeIsSubtractiveDecode(IN PPCI_CONFIGURATOR_CONTEXT Context)
Definition: ppbridge.c:175
ULONG LowPart
Definition: typedefs.h:106