#include <pci.h>
#include <debug.h>
Go to the source code of this file.
|
| VOID NTAPI | PciGetResizableBarCapability (_Inout_ PPCI_PDO_EXTENSION PdoExtension) |
| | Records which BARs of a new function can be resized and the sizes each of them supports.
|
| |
| static BOOLEAN NTAPI | PciFillResizedBarRequirement (_Out_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ PIO_RESOURCE_DESCRIPTOR Limit, _In_ ULONGLONG Length, _In_ UCHAR Option) |
| |
| ULONG NTAPI | PciAddResizableBarRequirements (_In_ PPCI_PDO_EXTENSION PdoExtension, _In_ ULONG BarIndex, _In_ PIO_RESOURCE_DESCRIPTOR Limit, _Out_writes_opt_(2) PIO_RESOURCE_DESCRIPTOR Descriptors) |
| | Writes the requirements for the sizes a resizable BAR can grow to. They go ahead of the default requirement, which the caller then lists as the alternative. The largest size is preferred, and the smallest supported size follows it when that is also bigger than the default.
|
| |
| static VOID NTAPI | PciSelectResizableBarSize (_In_ PPCI_PDO_EXTENSION PdoExtension, _In_ ULONG BarIndex, _In_ ULONGLONG Length) |
| |
| VOID NTAPI | PciApplyResizableBarSizes (_In_ PPCI_PDO_EXTENSION PdoExtension) |
| | Sets every resizable BAR to the length it was assigned. The memory decode has to be off, since the size field changes what the BAR decodes. Critical devices call this from the IPI that updates their hardware.
|
| |
◆ NDEBUG
◆ PCI_RBAR_SIZE_TO_LENGTH
| #define PCI_RBAR_SIZE_TO_LENGTH |
( |
|
Bit | ) |
(1ULL << ((Bit) + 20)) |
◆ PciAddResizableBarRequirements()
Writes the requirements for the sizes a resizable BAR can grow to. They go ahead of the default requirement, which the caller then lists as the alternative. The largest size is preferred, and the smallest supported size follows it when that is also bigger than the default.
- Parameters
-
| [in] | PdoExtension | The PDO extension of the function. |
| [in] | BarIndex | The BAR the default requirement describes. |
| [in] | Limit | The default requirement of the BAR. |
| [out] | Descriptors | Receives up to two descriptors, or NULL to only count them. |
- Returns
- The number of descriptors written, which is 0 when the BAR cannot grow.
Definition at line 142 of file rbar.c.
147{
152
153
155 return 0;
156
157 SizeMask =
PdoExtension->ResizableBarState.SizeMask[BarIndex];
158 if (!SizeMask)
159 return 0;
160
161
163 if ((Largest <= Limit->
u.Memory.Length) ||
165 {
166 return 0;
167 }
169
171 if ((Smallest >
Limit->u.Memory.Length) &&
172 (Smallest < Largest) &&
174 {
176 }
177
178 if (Descriptors)
180
182}
#define PCI_RBAR_MAX_ENTRIES
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
static BOOLEAN NTAPI PciFillResizedBarRequirement(_Out_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ PIO_RESOURCE_DESCRIPTOR Limit, _In_ ULONGLONG Length, _In_ UCHAR Option)
#define PCI_RBAR_SIZE_TO_LENGTH(Bit)
#define CmResourceTypeMemory
#define RtlCopyMemory(Destination, Source, Length)
NTSYSAPI CCHAR WINAPI RtlFindMostSignificantBit(ULONGLONG)
NTSYSAPI CCHAR WINAPI RtlFindLeastSignificantBit(ULONGLONG)
#define IO_RESOURCE_ALTERNATIVE
#define IO_RESOURCE_PREFERRED
_In_ LONG _In_ LONG Limit
Referenced by PciBuildRequirementsList().
◆ PciApplyResizableBarSizes()
Sets every resizable BAR to the length it was assigned. The memory decode has to be off, since the size field changes what the BAR decodes. Critical devices call this from the IPI that updates their hardware.
- Parameters
-
| [in] | PdoExtension | The PDO extension of the function whose resources are being set. |
Definition at line 229 of file rbar.c.
231{
235
237 return;
238
239
245 {
247 return;
248 }
249
251 {
252 if (!
PdoExtension->ResizableBarState.SizeMask[BarIndex])
253 continue;
254
258 {
259 continue;
260 }
261
263 BarIndex,
265 }
266}
ULONGLONG NTAPI RtlCmDecodeMemIoResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _Out_opt_ PULONGLONG Start)
VOID NTAPI PciReadDeviceConfig(IN PPCI_PDO_EXTENSION DeviceExtension, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
static VOID NTAPI PciSelectResizableBarSize(_In_ PPCI_PDO_EXTENSION PdoExtension, _In_ ULONG BarIndex, _In_ ULONGLONG Length)
#define FIELD_OFFSET(t, f)
#define CmResourceTypeMemoryLarge
#define PCI_ENABLE_MEMORY_SPACE
Referenced by PcipUpdateHardware().
◆ PciFillResizedBarRequirement()
Definition at line 97 of file rbar.c.
102{
104
108
113 Limit->u.Memory.MinimumAddress.QuadPart,
114 Limit->u.Memory.MaximumAddress.QuadPart);
116}
#define NT_SUCCESS(StatCode)
_In_ ULONG _In_ ULONG _In_ ULONG Length
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
@ CmResourceShareDeviceExclusive
NTSYSAPI NTSTATUS NTAPI RtlIoEncodeMemIoResource(_In_ struct _IO_RESOURCE_DESCRIPTOR *Descriptor, _In_ UCHAR Type, _In_ ULONGLONG Length, _In_ ULONGLONG Alignment, _In_ ULONGLONG MinimumAddress, _In_ ULONGLONG MaximumAddress)
Referenced by PciAddResizableBarRequirements().
◆ PciGetResizableBarCapability()
Records which BARs of a new function can be resized and the sizes each of them supports.
- Parameters
-
| [in,out] | PdoExtension | The PDO extension of the function being enumerated. |
Definition at line 31 of file rbar.c.
33{
37
39
41
42
44 return;
45
51 return;
52
53
61
63
65 {
67 &SizeMask,
69 sizeof(SizeMask));
74
77
78
79 if (!SizeMask ||
81 State->SizeMask[BarIndex])
82 {
83 continue;
84 }
85
86 State->SizeMask[BarIndex] = SizeMask;
88
89 DPRINT1(
"PCI: BAR %lu of %p is resizable, sizes 0x%08lx\n",
91 }
92}
#define PCI_RBAR_CONTROL_BAR_INDEX_MASK
#define PCI_RBAR_ENTRY_CONTROL(n)
#define PCI_RBAR_CAPABILITY_SIZES_SHIFT
#define PCI_RBAR_ENTRY_CAPABILITY(n)
#define PCI_RBAR_CONTROL_COUNT_SHIFT
#define PCI_RBAR_CONTROL_COUNT_MASK
#define PCI_RBAR_EXTENDED_CAP_ID
ULONG NTAPI PciReadDeviceExtendedCapability(_In_ PPCI_PDO_EXTENSION DeviceExtension, _In_ ULONG CapabilityId, _Out_writes_bytes_(Length) PPCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Buffer, _In_ ULONG Length)
Finds an extended capability and reads it into the caller's buffer.
_In_ ULONG _In_ ULONG Offset
#define RtlZeroMemory(Destination, Length)
_In_ WDF_WMI_PROVIDER_CONTROL Control
Referenced by PciGetEnhancedCapabilities().
◆ PciSelectResizableBarSize()
Definition at line 187 of file rbar.c.
191{
195
196
198 if (!Megabytes || (Megabytes & (Megabytes - 1)) || (
Length & 0xFFFFF))
199 return;
200
201 if (!(
State->SizeMask[BarIndex] & Megabytes))
202 return;
203
205
209 return;
210
211 Control &= ~PCI_RBAR_CONTROL_SIZE_MASK;
214
215 DPRINT(
"PCI: BAR %lu of %p resized to %I64u MB\n", BarIndex,
PdoExtension, Megabytes);
216}
VOID NTAPI PciWriteDeviceConfig(IN PPCI_PDO_EXTENSION DeviceExtension, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
#define PCI_RBAR_CONTROL_SIZE_SHIFT
#define PCI_RBAR_CONTROL_SIZE_MASK
Referenced by PciApplyResizableBarSizes().