ReactOS 0.4.17-dev-1196-gb6224c3
cardbus.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS PCI Bus Driver
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: drivers/bus/pci/intrface/cardbus.c
5 * PURPOSE: CardBus Interface
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include <pci.h>
12
13#define NDEBUG
14#include <debug.h>
15
16/* GLOBALS ********************************************************************/
17
19{
20 &GUID_PCI_CARDBUS_INTERFACE_PRIVATE,
25 0,
29};
30
31/* The VGA descriptors of a PCI-to-PCI bridge are reused, both headers keep this register here */
32C_ASSERT(FIELD_OFFSET(PCI_COMMON_HEADER, u.type1.BridgeControl) ==
33 FIELD_OFFSET(PCI_COMMON_HEADER, u.type2.BridgeControl));
34
35/* FUNCTIONS ******************************************************************/
36
37VOID
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}
88
89VOID
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}
99
100VOID
101NTAPI
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}
117
118VOID
119NTAPI
121{
122 /* Put back the secondary status that was held out of the probe */
123 Context->Current->u.type2.SecondaryStatus = Context->SecondaryStatus;
124}
125
126VOID
127NTAPI
129 IN PPCI_COMMON_HEADER PciData,
130 IN PIO_RESOURCE_DESCRIPTOR IoDescriptor)
131{
132 /* The VGA enable is the same bit as on a PCI-to-PCI bridge */
134}
135
136VOID
137NTAPI
139 IN PPCI_COMMON_HEADER PciData)
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}
146
148NTAPI
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}
187
189NTAPI
191{
193 /* PnP Interfaces don't get Initialized */
194 ASSERTMSG("PCI pcicbintrf_Initializer, unexpected call.\n", FALSE);
195 return STATUS_UNSUCCESSFUL;
196}
197
199NTAPI
202 IN PVOID InterfaceData,
204 IN USHORT Size,
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}
217
218/* EOF */
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI Cardbus_ChangeResourceSettings(_In_ PPCI_PDO_EXTENSION PdoExtension, _Inout_ PPCI_COMMON_HEADER PciData)
Definition: cardbus.c:149
VOID NTAPI Cardbus_SaveCurrentSettings(IN PPCI_CONFIGURATOR_CONTEXT Context)
Definition: cardbus.c:39
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
PCI_INTERFACE PciCardbusPrivateInterface
Definition: cardbus.c:18
VOID NTAPI Cardbus_MassageHeaderForLimitsDetermination(IN PPCI_CONFIGURATOR_CONTEXT Context)
Definition: cardbus.c:102
VOID NTAPI Cardbus_RestoreCurrent(IN PPCI_CONFIGURATOR_CONTEXT Context)
Definition: cardbus.c:120
VOID NTAPI Cardbus_SaveLimits(IN PPCI_CONFIGURATOR_CONTEXT Context)
Definition: cardbus.c:91
VOID NTAPI Cardbus_ResetDevice(IN PPCI_PDO_EXTENSION PdoExtension, IN PPCI_COMMON_HEADER PciData)
Definition: cardbus.c:138
NTSTATUS NTAPI pcicbintrf_Initializer(IN PVOID Instance)
Definition: cardbus.c:190
VOID NTAPI Cardbus_GetAdditionalResourceDescriptors(IN PPCI_CONFIGURATOR_CONTEXT Context, IN PPCI_COMMON_HEADER PciData, IN PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: cardbus.c:128
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
VOID NTAPI PPBridge_GetAdditionalResourceDescriptors(IN PPCI_CONFIGURATOR_CONTEXT Context, IN PPCI_COMMON_HEADER PciData, IN PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: ppbridge.c:657
#define PCI_INTERFACE_PDO
Definition: pci.h:67
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
@ PciInterface_PciCb
Definition: pci.h:142
@ PdoExtension
Definition: precomp.h:61
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 C_ASSERT(e)
Definition: intsafe.h:73
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
void Bar(void)
Definition: terminate.cpp:70
#define _Inout_
Definition: no_sal2.h:162
#define _In_
Definition: no_sal2.h:158
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
unsigned short USHORT
Definition: pedump.c:61
static WCHAR Address[46]
Definition: ping.c:68
#define CmResourceTypeNull
Definition: restypes.h:103
#define CmResourceTypePort
Definition: restypes.h:104
#define PCI_ENABLE_BRIDGE_VGA
Definition: pci.h:63
#define STATUS_SUCCESS
Definition: shellext.h:65
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@494 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@494::@495 Generic
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
_In_ UCXUSBDEVICE _In_ ULONG Interface
Definition: ucxusbdevice.h:428
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_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
#define PCI_ADDRESS_IO_ADDRESS_MASK
Definition: iotypes.h:4249
struct _PCI_CARDBUS_INTERFACE_PRIVATE PCI_CARDBUS_INTERFACE_PRIVATE
#define PCI_ADDRESS_IO_SPACE
Definition: iotypes.h:4246
#define PCI_ADDRESS_MEMORY_ADDRESS_MASK
Definition: iotypes.h:4250
#define PCI_CB_INTRF_VERSION
Definition: iotypes.h:5534
_In_ LONG _In_ LONG Limit
Definition: kefuncs.h:304