ReactOS 0.4.17-dev-966-gf06eace
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)
 
VOID NTAPI PPBridge_ChangeResourceSettings (IN PPCI_PDO_EXTENSION PdoExtension, IN 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.IOLimit;
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:3611
#define PCI_BRIDGE_TYPE
Definition: iotypes.h:3608

Referenced by 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 PPBridge_SaveCurrentSettings(), and PPBridge_SaveLimits().

◆ PciBridgeIsPositiveDecode()

BOOLEAN NTAPI PciBridgeIsPositiveDecode ( IN PPCI_PDO_EXTENSION  PdoExtension)

Definition at line 165 of file ppbridge.c.

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

Referenced by PciBridgeIsSubtractiveDecode().

◆ PciBridgeIsSubtractiveDecode()

BOOLEAN NTAPI PciBridgeIsSubtractiveDecode ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 173 of file ppbridge.c.

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

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 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 PPBridge_SaveCurrentSettings(), and PPBridge_SaveLimits().

◆ PciBridgeMemoryWorstCaseAlignment()

ULONG NTAPI PciBridgeMemoryWorstCaseAlignment ( IN ULONG  Length)

Definition at line 148 of file ppbridge.c.

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

Referenced by PPBridge_SaveCurrentSettings().

◆ 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.LowPart = ((PrefetchBase & 0xFFF0) << 16);
107
108 /* Is it 64-bit? */
109 if (Is64Bit)
110 {
111 /* Read the upper 32-bits from the other register */
112 Base.HighPart = PciData->u.type1.PrefetchBaseUpper32;
113 }
114
115 /* Return the base */
116 return Base;
117}
unsigned short USHORT
Definition: pedump.c:61

Referenced by PPBridge_SaveCurrentSettings().

◆ PciBridgePrefetchMemoryLimit()

PHYSICAL_ADDRESS NTAPI PciBridgePrefetchMemoryLimit ( IN PPCI_COMMON_HEADER  PciData)

Definition at line 121 of file ppbridge.c.

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

Referenced by PPBridge_SaveCurrentSettings(), and PPBridge_SaveLimits().

◆ PPBridge_ChangeResourceSettings()

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

Definition at line 684 of file ppbridge.c.

686{
687 //BOOLEAN IoActive;
689 PPCI_FUNCTION_RESOURCES PciResources;
690 ULONG i;
691
692 /* Check if I/O Decodes are enabled */
693 //IoActive = (PciData->u.type1.IOBase & 0xF) == 1;
694
695 /*
696 * Check for Intel ICH PCI-to-PCI (i82801) bridges (used on the i810,
697 * i820, i840, i845 Chipsets) that don't have subtractive decode broken.
698 * If they do have broken subtractive support, or if they are not ICH bridges,
699 * then check if the bridge supports subtractive decode at all.
700 */
701 if ((((PdoExtension->VendorId == 0x8086) &&
702 ((PdoExtension->DeviceId == 0x2418) ||
703 (PdoExtension->DeviceId == 0x2428) ||
704 (PdoExtension->DeviceId == 0x244E) ||
705 (PdoExtension->DeviceId == 0x2448))) &&
707 (PdoExtension->Dependent.type1.SubtractiveDecode == FALSE))) ||
708 (PdoExtension->Dependent.type1.SubtractiveDecode == FALSE))
709 {
710 /* No resources are needed on a subtractive decode bridge */
711 PciData->u.type1.MemoryBase = 0xFFFF;
712 PciData->u.type1.PrefetchBase = 0xFFFF;
713 PciData->u.type1.IOBase = 0xFF;
714 PciData->u.type1.IOLimit = 0;
715 PciData->u.type1.MemoryLimit = 0;
716 PciData->u.type1.PrefetchLimit = 0;
717 PciData->u.type1.PrefetchBaseUpper32 = 0;
718 PciData->u.type1.PrefetchLimitUpper32 = 0;
719 PciData->u.type1.IOBaseUpper16 = 0;
720 PciData->u.type1.IOLimitUpper16 = 0;
721 }
722 else
723 {
724 /*
725 * Otherwise, get the FDO to read the old PCI configuration header that
726 * had been saved by the hack in PPBridge_SaveCurrentSettings.
727 */
728 FdoExtension = PdoExtension->ParentFdoExtension;
729 ASSERT(PdoExtension->Resources == NULL);
730
731 /* Read the PCI header data and use that here */
732 PciData->u.type1.IOBase = FdoExtension->PreservedConfig->u.type1.IOBase;
733 PciData->u.type1.IOLimit = FdoExtension->PreservedConfig->u.type1.IOLimit;
734 PciData->u.type1.MemoryBase = FdoExtension->PreservedConfig->u.type1.MemoryBase;
735 PciData->u.type1.MemoryLimit = FdoExtension->PreservedConfig->u.type1.MemoryLimit;
736 PciData->u.type1.PrefetchBase = FdoExtension->PreservedConfig->u.type1.PrefetchBase;
737 PciData->u.type1.PrefetchLimit = FdoExtension->PreservedConfig->u.type1.PrefetchLimit;
738 PciData->u.type1.PrefetchBaseUpper32 = FdoExtension->PreservedConfig->u.type1.PrefetchBaseUpper32;
739 PciData->u.type1.PrefetchLimitUpper32 = FdoExtension->PreservedConfig->u.type1.PrefetchLimitUpper32;
740 PciData->u.type1.IOBaseUpper16 = FdoExtension->PreservedConfig->u.type1.IOBaseUpper16;
741 PciData->u.type1.IOLimitUpper16 = FdoExtension->PreservedConfig->u.type1.IOLimitUpper16;
742 }
743
744 /* Loop bus resources */
745 PciResources = PdoExtension->Resources;
746 if (PciResources)
747 {
748 /* Loop each resource type (the BARs, ROM BAR and Prefetch) */
749 for (i = 0; i < 6; i++)
750 {
752 }
753 }
754
755 /* Copy the bus number data */
756 PciData->u.type1.PrimaryBus = PdoExtension->Dependent.type1.PrimaryBus;
757 PciData->u.type1.SecondaryBus = PdoExtension->Dependent.type1.SecondaryBus;
758 PciData->u.type1.SubordinateBus = PdoExtension->Dependent.type1.SubordinateBus;
759
760 /* Copy the decode flags */
761 if (PdoExtension->Dependent.type1.IsaBitSet)
762 {
763 PciData->u.type1.BridgeControl |= PCI_ENABLE_BRIDGE_ISA;
764 }
765
766 if (PdoExtension->Dependent.type1.VgaBitSet)
767 {
768 PciData->u.type1.BridgeControl |= PCI_ENABLE_BRIDGE_VGA;
769 }
770}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
#define NULL
Definition: types.h:112
@ FdoExtension
Definition: precomp.h:48
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 PCI_ENABLE_BRIDGE_VGA
Definition: pci.h:63
#define PCI_ENABLE_BRIDGE_ISA
Definition: pci.h:62

◆ PPBridge_GetAdditionalResourceDescriptors()

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

Definition at line 629 of file ppbridge.c.

632{
633
635
636 /* Does this bridge have VGA decodes on it? */
637 if (PciData->u.type1.BridgeControl & PCI_ENABLE_BRIDGE_VGA)
638 {
639 /* Build a private descriptor with 3 entries */
640 IoDescriptor->Type = CmResourceTypeDevicePrivate;
641 IoDescriptor->u.DevicePrivate.Data[0] = 3;
642 IoDescriptor->u.DevicePrivate.Data[1] = 3;
643
644 /* First, the VGA range at 0xA0000 */
645 IoDescriptor[1].Type = CmResourceTypeMemory;
646 IoDescriptor[1].Flags = CM_RESOURCE_MEMORY_READ_WRITE;
647 IoDescriptor[1].u.Port.Length = 0x20000;
648 IoDescriptor[1].u.Port.Alignment = 1;
649 IoDescriptor[1].u.Port.MinimumAddress.QuadPart = 0xA0000;
650 IoDescriptor[1].u.Port.MaximumAddress.QuadPart = 0xBFFFF;
651
652 /* Then, the VGA registers at 0x3B0 */
653 IoDescriptor[2].Type = CmResourceTypePort;
654 IoDescriptor[2].Flags = CM_RESOURCE_PORT_POSITIVE_DECODE |
656 IoDescriptor[2].u.Port.Length = 12;
657 IoDescriptor[2].u.Port.Alignment = 1;
658 IoDescriptor[2].u.Port.MinimumAddress.QuadPart = 0x3B0;
659 IoDescriptor[2].u.Port.MaximumAddress.QuadPart = 0x3BB;
660
661 /* And finally the VGA registers at 0x3C0 */
662 IoDescriptor[3].Type = CmResourceTypePort;
663 IoDescriptor[3].Flags = CM_RESOURCE_PORT_POSITIVE_DECODE |
665 IoDescriptor[3].u.Port.Length = 32;
666 IoDescriptor[3].u.Port.Alignment = 1;
667 IoDescriptor[3].u.Port.MinimumAddress.QuadPart = 0x3C0;
668 IoDescriptor[3].u.Port.MaximumAddress.QuadPart = 0x3DF;
669 }
670}
#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 CmResourceTypeMemory
Definition: restypes.h:106
#define CmResourceTypeDevicePrivate
Definition: restypes.h:112
#define CmResourceTypePort
Definition: restypes.h:104

◆ PPBridge_MassageHeaderForLimitsDetermination()

VOID NTAPI PPBridge_MassageHeaderForLimitsDetermination ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 583 of file ppbridge.c.

584{
585 PPCI_COMMON_HEADER PciData, Current;
586
587 /* Get pointers from context */
588 PciData = Context->PciData;
589 Current = Context->Current;
590
591 /*
592 * Write FFh everywhere so that the PCI bridge ignores what it can't handle.
593 * Based on the bits that were ignored (still 0), this is how we can tell
594 * what the limit is.
595 */
596 RtlFillMemory(PciData->u.type1.BaseAddresses,
597 FIELD_OFFSET(PCI_COMMON_HEADER, u.type1.CapabilitiesPtr) -
598 FIELD_OFFSET(PCI_COMMON_HEADER, u.type1.BaseAddresses),
599 0xFF);
600
601 /* Copy the saved settings from the current context into the PCI header */
602 PciData->u.type1.PrimaryBus = Current->u.type1.PrimaryBus;
603 PciData->u.type1.SecondaryBus = Current->u.type1.SecondaryBus;
604 PciData->u.type1.SubordinateBus = Current->u.type1.SubordinateBus;
605 PciData->u.type1.SecondaryLatency = Current->u.type1.SecondaryLatency;
606
607 /* No I/O limit or base. The bottom base bit specifies that FIXME */
608 PciData->u.type1.IOBaseUpper16 = 0xFFFE;
609 PciData->u.type1.IOLimitUpper16 = 0xFFFF;
610
611 /* Save secondary status before it gets cleared */
612 Context->SecondaryStatus = Current->u.type1.SecondaryStatus;
613
614 /* Clear secondary status */
615 Current->u.type1.SecondaryStatus = 0;
616 PciData->u.type1.SecondaryStatus = 0;
617}
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 674 of file ppbridge.c.

676{
678 UNREFERENCED_PARAMETER(PciData);
680}
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57

◆ PPBridge_RestoreCurrent()

VOID NTAPI PPBridge_RestoreCurrent ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 621 of file ppbridge.c.

622{
623 /* Copy back the secondary status register */
624 Context->Current->u.type1.SecondaryStatus = Context->SecondaryStatus;
625}

◆ PPBridge_SaveCurrentSettings()

VOID NTAPI PPBridge_SaveCurrentSettings ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 225 of file ppbridge.c.

226{
229 PIO_RESOURCE_DESCRIPTOR IoDescriptor;
232 PPCI_COMMON_HEADER Current;
233 PPCI_COMMON_CONFIG SavedConfig;
234 ULONG i, Bar, BarMask;
235 PULONG BarArray;
237 BOOLEAN HaveIoLimit, CheckAlignment;
239
240 /* Get the pointers from the extension */
241 PdoExtension = Context->PdoExtension;
242 Resources = PdoExtension->Resources;
243 Current = Context->Current;
244
245 /* Check if decodes are disabled */
247 {
248 /* Well, we're going to need them from somewhere, use the registry data */
250 if (NT_SUCCESS(Status)) Current = &BiosData;
251 }
252
253 /* Scan all current and limit descriptors for each BAR needed */
254 BarArray = Current->u.type1.BaseAddresses;
255 for (i = 0; i < 6; i++)
256 {
257 /* Get the current resource descriptor, and the limit requirement */
258 CmDescriptor = &Resources->Current[i];
259 IoDescriptor = &Resources->Limit[i];
260
261 /* Copy descriptor data, skipping null descriptors */
262 CmDescriptor->Type = IoDescriptor->Type;
263 if (CmDescriptor->Type == CmResourceTypeNull) continue;
264 CmDescriptor->Flags = IoDescriptor->Flags;
265 CmDescriptor->ShareDisposition = IoDescriptor->ShareDisposition;
266
267 /* Initialize the high-parts to zero, since most stuff is 32-bit only */
268 Base.QuadPart = Limit.QuadPart = Length.QuadPart = 0;
269
270 /* Check if we're handling PCI BARs, or the ROM BAR */
271 if ((i < PCI_TYPE1_ADDRESSES) || (i == 5))
272 {
273 /* Is this the ROM BAR? */
274 if (i == 5)
275 {
276 /* Read the correct bar, with the appropriate mask */
277 Bar = Current->u.type1.ROMBaseAddress;
279
280 /* Decode the base address, and write down the length */
281 Base.LowPart = Bar & BarMask;
282 DPRINT1("ROM BAR Base: %lx\n", Base.LowPart);
283 CmDescriptor->u.Memory.Length = IoDescriptor->u.Memory.Length;
284 }
285 else
286 {
287 /* Otherwise, get the BAR from the array */
288 Bar = BarArray[i];
289
290 /* Is this an I/O BAR? */
292 {
293 /* Set the correct mask */
294 ASSERT(CmDescriptor->Type == CmResourceTypePort);
296 }
297 else
298 {
299 /* This is a memory BAR, set the correct base */
300 ASSERT((CmDescriptor->Type == CmResourceTypeMemory) ||
301 (CmDescriptor->Type == CmResourceTypeMemoryLarge));
303
304 /* IS this a 64-bit BAR? */
306 {
307 /* Read the next 32-bits as well, ie, the next BAR */
308 Base.HighPart = BarArray[i + 1];
309 }
310 }
311
312 /* Decode the base address, and write down the length */
313 Base.LowPart = Bar & BarMask;
314 DPRINT1("BAR Base: %lx\n", Base.LowPart);
315 CmDescriptor->u.Generic.Length = IoDescriptor->u.Generic.Length;
316 }
317 }
318 else
319 {
320 /* Reset loop conditions */
321 HaveIoLimit = FALSE;
323
324 /* Check which descriptor is being parsed */
325 if (i == 2)
326 {
327 /* I/O Port Requirements */
328 Base.LowPart = PciBridgeIoBase(Current);
329 Limit.LowPart = PciBridgeIoLimit(Current);
330 DPRINT1("Bridge I/O Base and Limit: %lx %lx\n",
331 Base.LowPart, Limit.LowPart);
332
333 /* Do we have any I/O Port data? */
334 if (!(Base.LowPart) && (Current->u.type1.IOLimit))
335 {
336 /* There's a limit */
337 HaveIoLimit = TRUE;
338 }
339 }
340 else if (i == 3)
341 {
342 /* Memory requirements */
343 Base.LowPart = PciBridgeMemoryBase(Current);
344 Limit.LowPart = PciBridgeMemoryLimit(Current);
345
346 /* These should always be there, so check their alignment */
347 DPRINT1("Bridge MEM Base and Limit: %lx %lx\n",
348 Base.LowPart, Limit.LowPart);
350 }
351 else if (i == 4)
352 {
353 /* This should only be present for prefetch memory */
357
358 /* If it's there, check the alignment */
359 DPRINT1("Bridge Prefetch MEM Base and Limit: %I64x %I64x\n", Base, Limit);
361 }
362
363 /* Check for invalid base address */
364 if (Base.QuadPart >= Limit.QuadPart)
365 {
366 /* Assume the descriptor is bogus */
367 CmDescriptor->Type = CmResourceTypeNull;
368 IoDescriptor->Type = CmResourceTypeNull;
369 continue;
370 }
371
372 /* Check if there's no memory, and no I/O port either */
373 if (!(Base.LowPart) && !(HaveIoLimit))
374 {
375 /* This seems like a bogus requirement, ignore it */
376 CmDescriptor->Type = CmResourceTypeNull;
377 continue;
378 }
379
380 /* Set the length to be the limit - the base; should always be 32-bit */
381 Length.QuadPart = Limit.LowPart - Base.LowPart + 1;
382 ASSERT(Length.HighPart == 0);
383 CmDescriptor->u.Generic.Length = Length.LowPart;
384
385 /* Check if alignment should be set */
386 if (CheckAlignment)
387 {
388 /* Compute the required alignment for this length */
389 ASSERT(CmDescriptor->u.Memory.Length > 0);
390 IoDescriptor->u.Memory.Alignment =
391 PciBridgeMemoryWorstCaseAlignment(CmDescriptor->u.Memory.Length);
392 }
393 }
394
395 /* Now set the base address */
396 CmDescriptor->u.Generic.Start.LowPart = Base.LowPart;
397 }
398
399 /* Save PCI settings into the PDO extension for easy access later */
400 PdoExtension->Dependent.type1.PrimaryBus = Current->u.type1.PrimaryBus;
401 PdoExtension->Dependent.type1.SecondaryBus = Current->u.type1.SecondaryBus;
402 PdoExtension->Dependent.type1.SubordinateBus = Current->u.type1.SubordinateBus;
403
404 /* Check for subtractive decode bridges */
405 if (PdoExtension->Dependent.type1.SubtractiveDecode)
406 {
407 /* Check if legacy VGA decodes are enabled */
408 DPRINT1("Subtractive decode bridge\n");
409 if (Current->u.type1.BridgeControl & PCI_ENABLE_BRIDGE_VGA)
410 {
411 /* Save this setting for later */
412 DPRINT1("VGA Bridge\n");
413 PdoExtension->Dependent.type1.VgaBitSet = TRUE;
414 }
415
416 /* Legacy ISA decoding is not compatible with subtractive decode */
417 ASSERT(PdoExtension->Dependent.type1.IsaBitSet == FALSE);
418 }
419 else
420 {
421 /* Check if legacy VGA decodes are enabled */
422 if (Current->u.type1.BridgeControl & PCI_ENABLE_BRIDGE_VGA)
423 {
424 /* Save this setting for later */
425 DPRINT1("VGA Bridge\n");
426 PdoExtension->Dependent.type1.VgaBitSet = TRUE;
427
428 /* And on positive decode, we'll also need extra resources locked */
429 PdoExtension->AdditionalResourceCount = 4;
430 }
431
432 /* Check if legacy ISA decoding is enabled */
433 if (Current->u.type1.BridgeControl & PCI_ENABLE_BRIDGE_ISA)
434 {
435 /* Save this setting for later */
436 DPRINT1("ISA Bridge\n");
437 PdoExtension->Dependent.type1.IsaBitSet = TRUE;
438 }
439 }
440
441 /*
442 * Check for Intel ICH PCI-to-PCI (i82801) bridges (used on the i810,
443 * i820, i840, i845 Chipsets) that have subtractive decode broken.
444 */
445 if (((PdoExtension->VendorId == 0x8086) &&
446 ((PdoExtension->DeviceId == 0x2418) ||
447 (PdoExtension->DeviceId == 0x2428) ||
448 (PdoExtension->DeviceId == 0x244E) ||
449 (PdoExtension->DeviceId == 0x2448))) ||
451 {
452 /* Check if subtractive decode is actually enabled */
453 if (PdoExtension->Dependent.type1.SubtractiveDecode)
454 {
455 /* We're going to need a copy of the configuration for later use */
456 DPRINT1("apply config save hack to ICH subtractive decode\n");
457 SavedConfig = ExAllocatePoolWithTag(0, PCI_COMMON_HDR_LENGTH, 'PciP');
458 PdoExtension->ParentFdoExtension->PreservedConfig = SavedConfig;
459 if (SavedConfig) RtlCopyMemory(SavedConfig, Current, PCI_COMMON_HDR_LENGTH);
460 }
461 }
462}
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:767
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Status
Definition: gdiplustypes.h:24
void Bar(void)
Definition: terminate.cpp:70
#define CM_RESOURCE_MEMORY_PREFETCHABLE
Definition: cmtypes.h:125
PHYSICAL_ADDRESS NTAPI PciBridgePrefetchMemoryBase(IN PPCI_COMMON_HEADER PciData)
Definition: ppbridge.c:94
ULONG NTAPI PciBridgeMemoryWorstCaseAlignment(IN ULONG Length)
Definition: ppbridge.c:148
PHYSICAL_ADDRESS NTAPI PciBridgePrefetchMemoryLimit(IN PPCI_COMMON_HEADER PciData)
Definition: ppbridge.c:121
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
#define CmResourceTypeNull
Definition: restypes.h:103
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@486::@487 Generic
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@486 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@486::@491 Memory
struct _IO_RESOURCE_DESCRIPTOR::@2481::@2486 Generic
struct _IO_RESOURCE_DESCRIPTOR::@2481::@2483 Memory
union _IO_RESOURCE_DESCRIPTOR::@2481 u
PBIOS_DATA BiosData
Definition: bios.c:42
uint32_t * PULONG
Definition: typedefs.h:59
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define CmResourceTypeMemoryLarge
Definition: cmtypes.h:231
#define PCI_TYPE_64BIT
Definition: iotypes.h:4242
#define PCI_ADDRESS_IO_ADDRESS_MASK
Definition: iotypes.h:4236
#define PCI_ENABLE_IO_SPACE
Definition: iotypes.h:3618
#define PCI_ADDRESS_IO_SPACE
Definition: iotypes.h:4233
#define PCI_ENABLE_MEMORY_SPACE
Definition: iotypes.h:3619
#define PCI_TYPE1_ADDRESSES
Definition: iotypes.h:3503
#define PCI_ADDRESS_ROM_ADDRESS_MASK
Definition: iotypes.h:4238
#define PCI_ADDRESS_MEMORY_ADDRESS_MASK
Definition: iotypes.h:4237
#define PCI_COMMON_HDR_LENGTH
Definition: iotypes.h:3596
#define PCI_ADDRESS_MEMORY_TYPE_MASK
Definition: iotypes.h:4234

◆ PPBridge_SaveLimits()

VOID NTAPI PPBridge_SaveLimits ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 466 of file ppbridge.c.

467{
469 PULONG BarArray;
470 PHYSICAL_ADDRESS MemoryLimit;
471 ULONG i;
474
475 /* Get the pointers from the context */
476 Working = Context->PciData;
477 PdoExtension = Context->PdoExtension;
478
479 /* Scan the BARs into the limit descriptors */
480 BarArray = Working->u.type1.BaseAddresses;
481 Limit = PdoExtension->Resources->Limit;
482
483 /* First of all, loop all the BARs */
484 for (i = 0; i < PCI_TYPE1_ADDRESSES; i++)
485 {
486 /* Create a descriptor for their limits, the second BAR has no BAR after it */
487 ULONG NextBar = ((i + 1) < PCI_TYPE1_ADDRESSES) ? BarArray[i + 1] : 0;
488
489 if (PciCreateIoDescriptorFromBarLimit(&Limit[i], BarArray[i], NextBar, FALSE))
490 {
491 /* This was a 64-bit descriptor, make sure there's space */
493
494 /* Skip the next descriptor since this one is double sized */
495 i++;
496 Limit[i].Type = CmResourceTypeNull;
497 }
498 }
499
500 /* Check if this is a subtractive decode bridge */
502 {
503 /* This bridge is subtractive */
504 PdoExtension->Dependent.type1.SubtractiveDecode = TRUE;
505
506 /* Subtractive bridges cannot use legacy ISA or VGA functionality */
507 PdoExtension->Dependent.type1.IsaBitSet = FALSE;
508 PdoExtension->Dependent.type1.VgaBitSet = FALSE;
509 }
510
511 /* For normal decode bridges, we'll need to find the bridge limits too */
512 if (!PdoExtension->Dependent.type1.SubtractiveDecode)
513 {
514 /* Loop the descriptors that are left, to store the bridge limits */
515 for (i = PCI_TYPE1_ADDRESSES; i < 5; i++)
516 {
517 /* No 64-bit memory addresses, and set the address to 0 to begin */
518 MemoryLimit.HighPart = 0;
519 (&Limit[i])->u.Port.MinimumAddress.QuadPart = 0;
520
521 /* Are we getting the I/O limit? */
522 if (i == 2)
523 {
524 /* There should be one, get it */
525 ASSERT(Working->u.type1.IOLimit != 0);
526 ASSERT((Working->u.type1.IOLimit & 0x0E) == 0);
527 MemoryLimit.LowPart = PciBridgeIoLimit(Working);
528
529 /* Build a descriptor for this limit */
533 (&Limit[i])->u.Port.Alignment = 0x1000;
534 (&Limit[i])->u.Port.MinimumAddress.QuadPart = 0;
535 (&Limit[i])->u.Port.MaximumAddress = MemoryLimit;
536 (&Limit[i])->u.Port.Length = 0;
537 }
538 else if (i == 3)
539 {
540 /* There should be a valid memory limit, get it */
541 ASSERT((Working->u.type1.MemoryLimit & 0xF) == 0);
542 MemoryLimit.LowPart = PciBridgeMemoryLimit(Working);
543
544 /* Build the descriptor for it */
547 (&Limit[i])->u.Memory.Alignment = 0x100000;
548 (&Limit[i])->u.Memory.MinimumAddress.QuadPart = 0;
549 (&Limit[i])->u.Memory.MaximumAddress = MemoryLimit;
550 (&Limit[i])->u.Memory.Length = 0;
551 }
552 else if (Working->u.type1.PrefetchLimit)
553 {
554 /* Get the prefetch memory limit, if there is one */
556
557 /* Write out the descriptor for it */
560 (&Limit[i])->u.Memory.Alignment = 0x100000;
561 (&Limit[i])->u.Memory.MinimumAddress.QuadPart = 0;
562 (&Limit[i])->u.Memory.MaximumAddress = MemoryLimit;
563 (&Limit[i])->u.Memory.Length = 0;
564 }
565 else
566 {
567 /* Blank descriptor */
569 }
570 }
571 }
572
573 /* Does the ROM have its own BAR? */
574 if (Working->u.type1.ROMBaseAddress & PCI_ROMADDRESS_ENABLED)
575 {
576 /* Build a limit for it as well */
577 PciCreateIoDescriptorFromBarLimit(&Limit[i], Working->u.type1.ROMBaseAddress, 0, TRUE);
578 }
579}
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:1179
@ 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:173
ULONG LowPart
Definition: typedefs.h:106
#define PCI_ROMADDRESS_ENABLED
Definition: iotypes.h:4244