ReactOS 0.4.17-dev-1281-g065abb3
XhciSlotTable Class Reference

#include <slots.h>

Collaboration diagram for XhciSlotTable:

Public Member Functions

NTSTATUS Create (_In_ XhciController *Controller)
 
NTSTATUS Prepare ()
 
VOID Release ()
 
VOID Program ()
 
VOID D0Entry ()
 
VOID DisableAll ()
 
 _IRQL_requires_ (PASSIVE_LEVEL) VOID PreReset()
 
 _IRQL_requires_ (PASSIVE_LEVEL) VOID PostReset()
 
VOID OnHostLost ()
 
 _IRQL_requires_max_ (DISPATCH_LEVEL) NTSTATUS SetSlot(_In_ ULONG SlotId
 
 _IRQL_requires_max_ (DISPATCH_LEVEL) PVOID LookupSlot(_In_ ULONG SlotId) const
 
VOID OnTransferEvent (_In_ const XHCI_TRB *Event)
 
VOID OnDeviceNotificationEvent (_In_ const XHCI_TRB *Event)
 
VOID DiscardState ()
 

Public Attributes

_In_ PVOID Device
 
_In_ PVOID _In_ ULONG64 OutputContextAddress
 

Private Member Functions

VOID ZeroScratchpads ()
 
VOID FreeTables ()
 
BOOLEAN IsValidSlot (_In_ ULONG SlotId) const
 

Private Attributes

XhciController * m_Controller
 
ULONG m_SlotCount
 
ULONG m_ScratchpadCount
 
XhciDmaBuffer * m_Dcbaa
 
XhciDmaBuffer * m_ScratchpadArray
 
LIST_ENTRY m_ScratchpadPages
 
PVOID * m_SlotMap
 

Detailed Description

DCBAA, scratchpad buffers and slot id lookup.

Definition at line 13 of file slots.h.

Member Function Documentation

◆ _IRQL_requires_() [1/2]

XhciSlotTable::_IRQL_requires_ ( PASSIVE_LEVEL  )

◆ _IRQL_requires_() [2/2]

XhciSlotTable::_IRQL_requires_ ( PASSIVE_LEVEL  )

◆ _IRQL_requires_max_() [1/2]

XhciSlotTable::_IRQL_requires_max_ ( DISPATCH_LEVEL  )

Sets the DCBAA entry of a slot, or clears it for LogicalAddress 0; STATUS_ACCESS_DENIED if in use.

◆ _IRQL_requires_max_() [2/2]

XhciSlotTable::_IRQL_requires_max_ ( DISPATCH_LEVEL  ) const

◆ Create()

NTSTATUS XhciSlotTable::Create ( _In_ XhciController *  Controller)

Definition at line 17 of file slots.cpp.

19{
21
22 /* Release walks this list even when Prepare never ran */
24 return STATUS_SUCCESS;
25}
XhciController * m_Controller
Definition: slots.h:69
LIST_ENTRY m_ScratchpadPages
Definition: slots.h:74
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define STATUS_SUCCESS
Definition: shellext.h:65
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ UCXCONTROLLER * Controller

Referenced by XhciController::Initialize().

◆ D0Entry()

VOID XhciSlotTable::D0Entry ( )

Definition at line 161 of file slots.cpp.

162{
163 Program();
164}
VOID Program()
Definition: slots.cpp:148

Referenced by XhciController::RunD0Pass().

◆ DisableAll()

VOID XhciSlotTable::DisableAll ( )

Definition at line 199 of file slots.cpp.

200{
201 ULONG SlotId;
202
203 for (SlotId = 1; IsValidSlot(SlotId); SlotId++)
204 {
205 if (m_SlotMap[SlotId] == NULL)
206 continue;
207
208 DPRINT("Slot %lu lost its device %p\n", SlotId, m_SlotMap[SlotId]);
209
210 /* This clears the map entry */
211 XhciSlotDevice(m_SlotMap[SlotId])->SetDisabled();
212 }
213}
BOOLEAN IsValidSlot(_In_ ULONG SlotId) const
Definition: slots.h:63
PVOID * m_SlotMap
Definition: slots.h:75
#define NULL
Definition: types.h:112
static XhciUsbDevice *NTAPI XhciSlotDevice(_In_ PVOID Entry)
Definition: slots.cpp:192
#define DPRINT
Definition: sndvol32.h:73
uint32_t ULONG
Definition: typedefs.h:59

Referenced by XhciController::D0Entry(), and DiscardState().

◆ DiscardState()

VOID XhciSlotTable::DiscardState ( )

State was lost: zero the scratchpad pages, then disable every slot (D0 entry cleanup).

Definition at line 183 of file slots.cpp.

184{
186 DisableAll();
187}
VOID ZeroScratchpads()
Definition: slots.cpp:167
VOID DisableAll()
Definition: slots.cpp:199

Referenced by XhciController::D0Entry().

◆ FreeTables()

VOID XhciSlotTable::FreeTables ( )
private

Definition at line 104 of file slots.cpp.

105{
107
109 Pool->FreeList(&m_ScratchpadPages);
110
111 if (m_ScratchpadArray != NULL)
112 {
113 Pool->Free(m_ScratchpadArray);
115 }
116
117 if (m_Dcbaa != NULL)
118 {
119 Pool->Free(m_Dcbaa);
120 m_Dcbaa = NULL;
121 }
122
123 if (m_SlotMap != NULL)
124 {
126 m_SlotMap = NULL;
127 }
128
129 m_SlotCount = 0;
131}
Definition: bufpool.h:50
XhciCommonBuffer m_Buffers
Definition: hc.h:92
XhciDmaBuffer * m_Dcbaa
Definition: slots.h:72
ULONG m_SlotCount
Definition: slots.h:70
XhciDmaBuffer * m_ScratchpadArray
Definition: slots.h:73
ULONG m_ScratchpadCount
Definition: slots.h:71
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define XHCI_TAG_SLOT
Definition: xhciutil.h:17

Referenced by _IRQL_requires_().

◆ IsValidSlot()

BOOLEAN XhciSlotTable::IsValidSlot ( _In_ ULONG  SlotId) const
inlineprivate

Definition at line 63 of file slots.h.

65 {
66 return m_SlotMap != NULL && SlotId != 0 && SlotId <= m_SlotCount;
67 }

Referenced by _IRQL_requires_max_(), DisableAll(), and OnHostLost().

◆ OnDeviceNotificationEvent()

VOID XhciSlotTable::OnDeviceNotificationEvent ( _In_ const XHCI_TRB *  Event)

Definition at line 334 of file slots.cpp.

336{
337 PVOID Device = LookupSlot(XhciTrbSlotId(Event));
338
339 if (Device == NULL)
340 {
341 DPRINT("Device notification for empty slot %lu dropped\n", XhciTrbSlotId(Event));
342 return;
343 }
344
346}
VOID OnDeviceNotificationEvent(_In_ const XHCI_TRB *Event)
Definition: slotdev.cpp:1728
_Check_return_ _In_ DXGK_EVENT_TYPE _In_ ULONG Event
Definition: dispmprt.h:1287
_Must_inspect_result_ _In_ PUCXHUB_DEVICE_CREATE_INFO _Out_ UCXUSBDEVICE * Device
Definition: hubucx.h:258
FORCEINLINE ULONG NTAPI XhciTrbSlotId(_In_ const XHCI_TRB *Trb)
Definition: xhcihw.h:51

◆ OnHostLost()

VOID XhciSlotTable::OnHostLost ( )

Definition at line 247 of file slots.cpp.

248{
249 ULONG SlotId;
250
251 DPRINT("Controller gone, %lu slots\n", m_SlotCount);
252
253 for (SlotId = 1; IsValidSlot(SlotId); SlotId++)
254 {
255 if (m_SlotMap[SlotId] != NULL)
257 }
258}
VOID OnHostLost()
Definition: slotdev.cpp:1773

Referenced by XhciController::RunRecovery().

◆ OnTransferEvent()

VOID XhciSlotTable::OnTransferEvent ( _In_ const XHCI_TRB *  Event)

◆ Prepare()

NTSTATUS XhciSlotTable::Prepare ( )

◆ Program()

VOID XhciSlotTable::Program ( )

Writes DCBAAP and CONFIG.MaxSlotsEn; the controller calls it before Run.

Definition at line 148 of file slots.cpp.

149{
151 return;
152
153 /* CIE stays 0: configuration information is not used */
158}
BOOLEAN IsAccessible() const
Definition: hc.cpp:193
XhciRegisters m_Registers
Definition: hc.h:91
VOID WriteOperational64(_In_ ULONG Offset, _In_ ULONG64 Value)
Definition: mmio.cpp:460
VOID WriteOperational32(_In_ ULONG Offset, _In_ ULONG Value)
Definition: mmio.cpp:441
PHYSICAL_ADDRESS LogicalAddress
Definition: dmapool.h:17
LONGLONG QuadPart
Definition: typedefs.h:114
#define XHCI_OP_CONFIG
Definition: xhcihw.h:190
#define XHCI_OP_DCBAAP
Definition: xhcihw.h:189
#define XHCI_CONFIG_MAX_SLOTS_MASK
Definition: xhcihw.h:191

Referenced by D0Entry().

◆ Release()

VOID XhciSlotTable::Release ( )

◆ ZeroScratchpads()

VOID XhciSlotTable::ZeroScratchpads ( )
private

Definition at line 167 of file slots.cpp.

168{
170
172 return;
173
175 {
177
178 RtlZeroMemory(Page->VirtualAddress, Page->Size);
179 }
180}
PLIST_ENTRY Entry
Definition: devhcd.cpp:1262
_In_ PVOID _Out_opt_ BOOLEAN _Out_opt_ PPFN_NUMBER Page
Definition: mm.h:1287
Definition: typedefs.h:120
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by DiscardState().

Member Data Documentation

◆ Device

_In_ PVOID XhciSlotTable::Device

Definition at line 38 of file slots.h.

Referenced by _IRQL_requires_max_().

◆ m_Controller

XhciController* XhciSlotTable::m_Controller
private

Definition at line 69 of file slots.h.

Referenced by _IRQL_requires_(), _IRQL_requires_max_(), Create(), FreeTables(), and Program().

◆ m_Dcbaa

XhciDmaBuffer* XhciSlotTable::m_Dcbaa
private

Definition at line 72 of file slots.h.

Referenced by _IRQL_requires_(), _IRQL_requires_max_(), FreeTables(), and Program().

◆ m_ScratchpadArray

XhciDmaBuffer* XhciSlotTable::m_ScratchpadArray
private

Definition at line 73 of file slots.h.

Referenced by _IRQL_requires_(), and FreeTables().

◆ m_ScratchpadCount

ULONG XhciSlotTable::m_ScratchpadCount
private

Definition at line 71 of file slots.h.

Referenced by _IRQL_requires_(), and FreeTables().

◆ m_ScratchpadPages

LIST_ENTRY XhciSlotTable::m_ScratchpadPages
private

Definition at line 74 of file slots.h.

Referenced by _IRQL_requires_(), Create(), FreeTables(), and ZeroScratchpads().

◆ m_SlotCount

ULONG XhciSlotTable::m_SlotCount
private

Definition at line 70 of file slots.h.

Referenced by _IRQL_requires_(), FreeTables(), IsValidSlot(), OnHostLost(), and Program().

◆ m_SlotMap

PVOID* XhciSlotTable::m_SlotMap
private

◆ OutputContextAddress

_In_ PVOID _In_ ULONG64 XhciSlotTable::OutputContextAddress

Definition at line 39 of file slots.h.

Referenced by _IRQL_requires_max_().


The documentation for this class was generated from the following files: