ReactOS 0.4.17-dev-1196-gb6224c3
cardbus.c File Reference
#include <pci.h>
#include <debug.h>
Include dependency graph for cardbus.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

 C_ASSERT (FIELD_OFFSET(PCI_COMMON_HEADER, u.type1.BridgeControl)==FIELD_OFFSET(PCI_COMMON_HEADER, u.type2.BridgeControl))
 
VOID NTAPI Cardbus_SaveCurrentSettings (IN PPCI_CONFIGURATOR_CONTEXT Context)
 
VOID NTAPI Cardbus_SaveLimits (IN PPCI_CONFIGURATOR_CONTEXT Context)
 
VOID NTAPI Cardbus_MassageHeaderForLimitsDetermination (IN PPCI_CONFIGURATOR_CONTEXT Context)
 
VOID NTAPI Cardbus_RestoreCurrent (IN PPCI_CONFIGURATOR_CONTEXT Context)
 
VOID NTAPI Cardbus_GetAdditionalResourceDescriptors (IN PPCI_CONFIGURATOR_CONTEXT Context, IN PPCI_COMMON_HEADER PciData, IN PIO_RESOURCE_DESCRIPTOR IoDescriptor)
 
VOID NTAPI Cardbus_ResetDevice (IN PPCI_PDO_EXTENSION PdoExtension, IN PPCI_COMMON_HEADER PciData)
 
NTSTATUS NTAPI Cardbus_ChangeResourceSettings (_In_ PPCI_PDO_EXTENSION PdoExtension, _Inout_ PPCI_COMMON_HEADER PciData)
 
NTSTATUS NTAPI pcicbintrf_Initializer (IN PVOID Instance)
 
NTSTATUS NTAPI pcicbintrf_Constructor (IN PVOID DeviceExtension, IN PVOID Instance, IN PVOID InterfaceData, IN USHORT Version, IN USHORT Size, IN PINTERFACE Interface)
 

Variables

PCI_INTERFACE PciCardbusPrivateInterface
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file cardbus.c.

Function Documentation

◆ C_ASSERT()

C_ASSERT ( FIELD_OFFSET(PCI_COMMON_HEADER, u.type1.BridgeControl)  = =FIELD_OFFSET(PCI_COMMON_HEADER, u.type2.BridgeControl))

◆ Cardbus_ChangeResourceSettings()

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

Definition at line 149 of file cardbus.c.

152{
154 ULONG Bar, BarMask;
155
156 /* The socket register BAR gets its assigned address, or zero when it was given none */
157 Resources = PdoExtension->Resources;
158 if ((Resources) && (Resources->Limit[0].Type != CmResourceTypeNull))
159 {
160 Bar = PciData->u.type2.SocketRegistersBaseAddress;
162 {
164 }
165 else
166 {
168 }
169
170 Bar &= ~BarMask;
171 if (Resources->Current[0].Type != CmResourceTypeNull)
172 Bar |= Resources->Current[0].u.Generic.Start.LowPart & BarMask;
173
174 PciData->u.type2.SocketRegistersBaseAddress = Bar;
175 }
176
177 /* The windows stay as read, only what a power loss would wipe is written again */
178 PciData->u.type2.PrimaryBus = PdoExtension->Dependent.type1.PrimaryBus;
179 PciData->u.type2.SecondaryBus = PdoExtension->Dependent.type1.SecondaryBus;
180 PciData->u.type2.SubordinateBus = PdoExtension->Dependent.type1.SubordinateBus;
181
182 if (PdoExtension->Dependent.type1.VgaBitSet)
183 PciData->u.type2.BridgeControl |= PCI_ENABLE_BRIDGE_VGA;
184
185 return STATUS_SUCCESS;
186}
@ PdoExtension
Definition: precomp.h:61
void Bar(void)
Definition: terminate.cpp:70
#define CmResourceTypeNull
Definition: restypes.h:103
#define PCI_ENABLE_BRIDGE_VGA
Definition: pci.h:63
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t ULONG
Definition: typedefs.h:59
#define PCI_ADDRESS_IO_ADDRESS_MASK
Definition: iotypes.h:4249
#define PCI_ADDRESS_IO_SPACE
Definition: iotypes.h:4246
#define PCI_ADDRESS_MEMORY_ADDRESS_MASK
Definition: iotypes.h:4250

◆ Cardbus_GetAdditionalResourceDescriptors()

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

Definition at line 128 of file cardbus.c.

131{
132 /* The VGA enable is the same bit as on a PCI-to-PCI bridge */
134}
VOID NTAPI PPBridge_GetAdditionalResourceDescriptors(IN PPCI_CONFIGURATOR_CONTEXT Context, IN PPCI_COMMON_HEADER PciData, IN PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: ppbridge.c:657
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81

◆ Cardbus_MassageHeaderForLimitsDetermination()

VOID NTAPI Cardbus_MassageHeaderForLimitsDetermination ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 102 of file cardbus.c.

103{
104 PPCI_COMMON_HEADER Current, PciData;
105
106 Current = Context->Current;
107 PciData = Context->PciData;
108
109 /* Only the socket register BAR is sized, the windows keep what the firmware wrote */
110 PciData->u.type2.SocketRegistersBaseAddress = 0xFFFFFFFF;
111
112 /* Writing the error bits back would clear them, so keep them out of the probe */
113 Context->SecondaryStatus = Current->u.type2.SecondaryStatus;
114 Current->u.type2.SecondaryStatus = 0;
115 PciData->u.type2.SecondaryStatus = 0;
116}

◆ Cardbus_ResetDevice()

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

Definition at line 138 of file cardbus.c.

140{
142 UNREFERENCED_PARAMETER(PciData);
143
144 /* The socket reset bit belongs to the socket driver, so it goes back as it was read */
145}
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329

◆ Cardbus_RestoreCurrent()

VOID NTAPI Cardbus_RestoreCurrent ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 120 of file cardbus.c.

121{
122 /* Put back the secondary status that was held out of the probe */
123 Context->Current->u.type2.SecondaryStatus = Context->SecondaryStatus;
124}

◆ Cardbus_SaveCurrentSettings()

VOID NTAPI Cardbus_SaveCurrentSettings ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 39 of file cardbus.c.

40{
42 PPCI_COMMON_HEADER Current;
46
47 PdoExtension = Context->PdoExtension;
48 Current = Context->Current;
49 Limit = &PdoExtension->Resources->Limit[0];
50 Partial = &PdoExtension->Resources->Current[0];
51
52 /* Only the socket register BAR is tracked, the four windows are left to the socket driver */
53 Partial->Type = Limit->Type;
54 if (Limit->Type != CmResourceTypeNull)
55 {
56 Address = Current->u.type2.SocketRegistersBaseAddress;
57 if (Limit->Type == CmResourceTypePort)
58 {
60 }
61 else
62 {
64 }
65
66 Partial->Flags = Limit->Flags;
67 Partial->ShareDisposition = Limit->ShareDisposition;
68 Partial->u.Generic.Start.QuadPart = Address;
69 Partial->u.Generic.Length = Limit->u.Generic.Length;
70
71 /* A BAR the firmware never placed decodes nothing yet */
72 if (!Address)
73 Partial->Type = CmResourceTypeNull;
74 }
75
76 /* Remember the bus numbers so they survive the function losing power */
77 PdoExtension->Dependent.type1.PrimaryBus = Current->u.type2.PrimaryBus;
78 PdoExtension->Dependent.type1.SecondaryBus = Current->u.type2.SecondaryBus;
79 PdoExtension->Dependent.type1.SubordinateBus = Current->u.type2.SubordinateBus;
80
81 /* A bridge that forwards VGA also claims the legacy video ranges */
82 if (Current->u.type2.BridgeControl & PCI_ENABLE_BRIDGE_VGA)
83 {
84 PdoExtension->Dependent.type1.VgaBitSet = TRUE;
85 PdoExtension->AdditionalResourceCount = 4;
86 }
87}
#define TRUE
Definition: types.h:120
static WCHAR Address[46]
Definition: ping.c:68
#define CmResourceTypePort
Definition: restypes.h:104
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@494 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@494::@495 Generic
_In_ LONG _In_ LONG Limit
Definition: kefuncs.h:304

◆ Cardbus_SaveLimits()

VOID NTAPI Cardbus_SaveLimits ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 91 of file cardbus.c.

92{
93 /* The socket register BAR is 32-bit only, so it never takes a high half from the next field */
94 PciCreateIoDescriptorFromBarLimit(&Context->PdoExtension->Resources->Limit[0],
95 Context->PciData->u.type2.SocketRegistersBaseAddress,
96 0,
97 FALSE);
98}
#define FALSE
Definition: types.h:117
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

◆ pcicbintrf_Constructor()

NTSTATUS NTAPI pcicbintrf_Constructor ( IN PVOID  DeviceExtension,
IN PVOID  Instance,
IN PVOID  InterfaceData,
IN USHORT  Version,
IN USHORT  Size,
IN PINTERFACE  Interface 
)

Definition at line 200 of file cardbus.c.

206{
207 UNREFERENCED_PARAMETER(DeviceExtension);
209 UNREFERENCED_PARAMETER(InterfaceData);
213
214 /* Not provided, so the query fails and the socket driver goes without it */
216}
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
_In_ UCXUSBDEVICE _In_ ULONG Interface
Definition: ucxusbdevice.h:428
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_WMI_INSTANCE_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_opt_ WDFWMIINSTANCE * Instance
Definition: wdfwmi.h:481

◆ pcicbintrf_Initializer()

NTSTATUS NTAPI pcicbintrf_Initializer ( IN PVOID  Instance)

Definition at line 190 of file cardbus.c.

191{
193 /* PnP Interfaces don't get Initialized */
194 ASSERTMSG("PCI pcicbintrf_Initializer, unexpected call.\n", FALSE);
195 return STATUS_UNSUCCESSFUL;
196}
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Variable Documentation

◆ PciCardbusPrivateInterface

PCI_INTERFACE PciCardbusPrivateInterface
Initial value:
=
{
&GUID_PCI_CARDBUS_INTERFACE_PRIVATE,
0,
}
NTSTATUS NTAPI pcicbintrf_Constructor(IN PVOID DeviceExtension, IN PVOID Instance, IN PVOID InterfaceData, IN USHORT Version, IN USHORT Size, IN PINTERFACE Interface)
Definition: cardbus.c:200
NTSTATUS NTAPI pcicbintrf_Initializer(IN PVOID Instance)
Definition: cardbus.c:190
#define PCI_INTERFACE_PDO
Definition: pci.h:67
@ PciInterface_PciCb
Definition: pci.h:142
struct _PCI_CARDBUS_INTERFACE_PRIVATE PCI_CARDBUS_INTERFACE_PRIVATE
#define PCI_CB_INTRF_VERSION
Definition: iotypes.h:5534

Definition at line 18 of file cardbus.c.