ReactOS 0.4.17-dev-1281-g065abb3
XhciCommonBuffer Class Reference

#include <dmapool.h>

Collaboration diagram for XhciCommonBuffer:

Classes

struct  SizeClass
 

Public Member Functions

NTSTATUS Create (_In_ XhciController *Controller)
 
NTSTATUS Prepare ()
 
VOID Release ()
 
VOID D0Exit ()
 
VOID PostResetFlush ()
 
VOID OnHostLost ()
 
VOID Rebalance ()
 
 _IRQL_requires_max_ (DISPATCH_LEVEL) XhciDmaBuffer *Acquire(_In_ ULONG Size)
 
 _IRQL_requires_max_ (DISPATCH_LEVEL) NTSTATUS AcquireList(_In_ ULONG Size
 
 _IRQL_requires_max_ (DISPATCH_LEVEL) VOID Free(_In_ XhciDmaBuffer *Buffer)
 
 _IRQL_requires_max_ (DISPATCH_LEVEL) VOID FreeList(_Inout_ PLIST_ENTRY List)
 
WDFDMAENABLER DmaEnabler () const
 
PDMA_ADAPTER DmaAdapter () const
 
ULONG MaxDmaSize () const
 
ULONG MapRegisterCount () const
 
 _IRQL_requires_ (PASSIVE_LEVEL) VOID GrowthWork()
 
 _IRQL_requires_ (PASSIVE_LEVEL) VOID ReclaimWork()
 
VOID EnablerCleanup ()
 

Public Attributes

_In_ ULONG Count
 
_In_ ULONG _Inout_ PLIST_ENTRY List
 

Private Member Functions

 _IRQL_requires_ (PASSIVE_LEVEL) NTSTATUS CreateEnabler()
 
SizeClass * ClassForSize (_In_ ULONG Size)
 
 _IRQL_requires_ (PASSIVE_LEVEL) VOID AddSegments(_Inout_ SizeClass *Class
 
 _IRQL_requires_max_ (DISPATCH_LEVEL) BOOLEAN Grab(_Inout_ SizeClass *Class
 
 _Requires_lock_held_ (m_Lock) BOOLEAN ReturnFree(_Inout_ XhciDmaBuffer *Buffer)
 
 _Requires_lock_held_ (m_Lock) VOID ShrinkClass(_Inout_ SizeClass *Class)
 
 _IRQL_requires_max_ (DISPATCH_LEVEL) VOID QueueGrowth()
 
 _IRQL_requires_ (PASSIVE_LEVEL) VOID Flush()
 

Private Attributes

_In_ ULONG _Out_ PLIST_ENTRY Taken
 
_In_ ULONG _Out_ PLIST_ENTRY _Out_ PBOOLEAN NeedGrow
 
XhciController * m_Controller
 
WDFDMAENABLER m_Enabler
 
PDMA_ADAPTER m_Adapter
 
ULONG m_MaxDmaSize
 
ULONG m_MapRegisters
 
BOOLEAN m_Initialized
 
BOOLEAN m_HoldsUcxReference
 
KSPIN_LOCK m_Lock
 
SizeClass m_Small
 
SizeClass m_Large
 
ULONG m_PagesTotal
 
ULONG m_PagesInUse
 
LIST_ENTRY m_ReclaimList
 
ULONG m_ReclaimPages
 
WDFWORKITEM m_ReclaimItem
 
WDFWORKITEM m_GrowthItem
 
BOOLEAN m_GrowthQueued
 
ULONG m_GrowthOutstanding
 
KEVENT m_GrowthIdle
 

Detailed Description

DMA enabler and buffer pool.

Definition at line 24 of file dmapool.h.

Member Function Documentation

◆ _IRQL_requires_() [1/5]

XhciCommonBuffer::_IRQL_requires_ ( PASSIVE_LEVEL  )
private

◆ _IRQL_requires_() [2/5]

XhciCommonBuffer::_IRQL_requires_ ( PASSIVE_LEVEL  )
private

◆ _IRQL_requires_() [3/5]

XhciCommonBuffer::_IRQL_requires_ ( PASSIVE_LEVEL  )
private

◆ _IRQL_requires_() [4/5]

XhciCommonBuffer::_IRQL_requires_ ( PASSIVE_LEVEL  )

◆ _IRQL_requires_() [5/5]

XhciCommonBuffer::_IRQL_requires_ ( PASSIVE_LEVEL  )

◆ _IRQL_requires_max_() [1/6]

XhciCommonBuffer::_IRQL_requires_max_ ( DISPATCH_LEVEL  )
private

◆ _IRQL_requires_max_() [2/6]

XhciCommonBuffer::_IRQL_requires_max_ ( DISPATCH_LEVEL  )

Count zeroed buffers onto List (linked through Link); all or nothing.

◆ _IRQL_requires_max_() [3/6]

XhciCommonBuffer::_IRQL_requires_max_ ( DISPATCH_LEVEL  )

◆ _IRQL_requires_max_() [4/6]

XhciCommonBuffer::_IRQL_requires_max_ ( DISPATCH_LEVEL  )

◆ _IRQL_requires_max_() [5/6]

XhciCommonBuffer::_IRQL_requires_max_ ( DISPATCH_LEVEL  )
private

◆ _IRQL_requires_max_() [6/6]

XhciCommonBuffer::_IRQL_requires_max_ ( DISPATCH_LEVEL  )

Zeroed buffer of at least Size bytes, Size <= PAGE_SIZE. NULL when none can be had.

◆ _Requires_lock_held_() [1/2]

XhciCommonBuffer::_Requires_lock_held_ ( m_Lock  )
private

◆ _Requires_lock_held_() [2/2]

XhciCommonBuffer::_Requires_lock_held_ ( m_Lock  )
private

◆ ClassForSize()

XhciCommonBuffer::SizeClass * XhciCommonBuffer::ClassForSize ( _In_ ULONG  Size)
private

Definition at line 273 of file dmapool.cpp.

275{
277 return &m_Small;
279 return &m_Large;
280 return NULL;
281}
SizeClass m_Large
Definition: dmapool.h:140
SizeClass m_Small
Definition: dmapool.h:139
#define NULL
Definition: types.h:112
#define XHCI_POOL_SMALL_BYTES
Definition: dmapool.cpp:15
#define XHCI_POOL_PAGE_BYTES
Definition: dmapool.cpp:14
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539

◆ Create()

NTSTATUS XhciCommonBuffer::Create ( _In_ XhciController *  Controller)

◆ D0Exit()

VOID XhciCommonBuffer::D0Exit ( )

Referenced by XhciController::D0Exit().

◆ DmaAdapter()

PDMA_ADAPTER XhciCommonBuffer::DmaAdapter ( ) const

ReadFromDevice adapter, used for both directions.

Definition at line 738 of file dmapool.cpp.

739{
740 return m_Adapter;
741}
PDMA_ADAPTER m_Adapter
Definition: dmapool.h:132

Referenced by XhciControlRing::BuildControlTd(), and XhciControlRing::ReleaseResources().

◆ DmaEnabler()

WDFDMAENABLER XhciCommonBuffer::DmaEnabler ( ) const

Definition at line 732 of file dmapool.cpp.

733{
734 return m_Enabler;
735}
WDFDMAENABLER m_Enabler
Definition: dmapool.h:131

◆ EnablerCleanup()

VOID XhciCommonBuffer::EnablerCleanup ( )

Definition at line 702 of file dmapool.cpp.

703{
705 {
706 DPRINT1("DMA pool torn down with buffers still owned: small %lu of %lu, large %lu of %lu\n",
709 ASSERT(FALSE);
710 }
711
712 /* KMDF frees the pages and work items as children of the enabler */
713 m_Enabler = NULL;
714 m_Adapter = NULL;
722
723 /* Last touch of this object; the controller context may go away right after */
725 {
728 }
729}
#define DPRINT1
Definition: precomp.h:8
WDFWORKITEM m_GrowthItem
Definition: dmapool.h:148
WDFWORKITEM m_ReclaimItem
Definition: dmapool.h:146
LIST_ENTRY m_ReclaimList
Definition: dmapool.h:144
BOOLEAN m_HoldsUcxReference
Definition: dmapool.h:136
XhciController * m_Controller
Definition: dmapool.h:130
UCXCONTROLLER m_Ucx
Definition: hc.h:87
#define FALSE
Definition: types.h:117
static VOID NTAPI XhciPoolInitClass(_Out_ PLIST_ENTRY FreeList, _Out_ PLIST_ENTRY PageList)
Definition: dmapool.cpp:76
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define ASSERT(a)
Definition: mode.c:44
#define WdfObjectDereference(Handle)
Definition: wdfobject.h:826

◆ MapRegisterCount()

ULONG XhciCommonBuffer::MapRegisterCount ( ) const

Definition at line 750 of file dmapool.cpp.

751{
752 return m_MapRegisters;
753}
ULONG m_MapRegisters
Definition: dmapool.h:134

◆ MaxDmaSize()

ULONG XhciCommonBuffer::MaxDmaSize ( ) const

Definition at line 744 of file dmapool.cpp.

745{
746 return m_MaxDmaSize;
747}
ULONG m_MaxDmaSize
Definition: dmapool.h:133

◆ OnHostLost()

VOID XhciCommonBuffer::OnHostLost ( )

◆ PostResetFlush()

VOID XhciCommonBuffer::PostResetFlush ( )

◆ Prepare()

NTSTATUS XhciCommonBuffer::Prepare ( )

◆ Rebalance()

VOID XhciCommonBuffer::Rebalance ( )

Driven by the controller watchdog.

Definition at line 655 of file dmapool.cpp.

656{
657 BOOLEAN Reclaim;
658
659 if (m_ReclaimItem == NULL)
660 return;
661
662 {
664
665 ShrinkClass(&m_Small);
666 ShrinkClass(&m_Large);
667 Reclaim = !IsListEmpty(&m_ReclaimList);
668 }
669
670 if (Reclaim)
672}
unsigned char BOOLEAN
Definition: actypes.h:127
KSPIN_LOCK m_Lock
Definition: dmapool.h:138
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
WdfWorkItemEnqueue(WorkItem)

Referenced by XhciController::WatchdogTick().

◆ Release()

VOID XhciCommonBuffer::Release ( )

Definition at line 227 of file dmapool.cpp.

228{
229 /* Nothing to do: the pool survives ReleaseHardware and dies with the enabler */
230}

Referenced by XhciController::ReleaseHardware().

Member Data Documentation

◆ Count

_In_ ULONG XhciCommonBuffer::Count

Definition at line 50 of file dmapool.h.

Referenced by _IRQL_requires_max_().

◆ List

_In_ ULONG _Inout_ PLIST_ENTRY XhciCommonBuffer::List

Definition at line 51 of file dmapool.h.

◆ m_Adapter

PDMA_ADAPTER XhciCommonBuffer::m_Adapter
private

Definition at line 132 of file dmapool.h.

Referenced by DmaAdapter(), and EnablerCleanup().

◆ m_Controller

XhciController* XhciCommonBuffer::m_Controller
private

Definition at line 130 of file dmapool.h.

Referenced by _IRQL_requires_(), and EnablerCleanup().

◆ m_Enabler

WDFDMAENABLER XhciCommonBuffer::m_Enabler
private

Definition at line 131 of file dmapool.h.

Referenced by _IRQL_requires_(), DmaEnabler(), and EnablerCleanup().

◆ m_GrowthIdle

KEVENT XhciCommonBuffer::m_GrowthIdle
private

Definition at line 151 of file dmapool.h.

Referenced by _IRQL_requires_().

◆ m_GrowthItem

WDFWORKITEM XhciCommonBuffer::m_GrowthItem
private

Definition at line 148 of file dmapool.h.

Referenced by EnablerCleanup().

◆ m_GrowthOutstanding

ULONG XhciCommonBuffer::m_GrowthOutstanding
private

Definition at line 150 of file dmapool.h.

◆ m_GrowthQueued

BOOLEAN XhciCommonBuffer::m_GrowthQueued
private

Definition at line 149 of file dmapool.h.

◆ m_HoldsUcxReference

BOOLEAN XhciCommonBuffer::m_HoldsUcxReference
private

Definition at line 136 of file dmapool.h.

Referenced by EnablerCleanup().

◆ m_Initialized

BOOLEAN XhciCommonBuffer::m_Initialized
private

Definition at line 135 of file dmapool.h.

Referenced by _IRQL_requires_().

◆ m_Large

SizeClass XhciCommonBuffer::m_Large
private

◆ m_Lock

KSPIN_LOCK XhciCommonBuffer::m_Lock
private

Definition at line 138 of file dmapool.h.

Referenced by _IRQL_requires_(), _IRQL_requires_max_(), and Rebalance().

◆ m_MapRegisters

ULONG XhciCommonBuffer::m_MapRegisters
private

Definition at line 134 of file dmapool.h.

Referenced by MapRegisterCount().

◆ m_MaxDmaSize

ULONG XhciCommonBuffer::m_MaxDmaSize
private

Definition at line 133 of file dmapool.h.

Referenced by MaxDmaSize().

◆ m_PagesInUse

ULONG XhciCommonBuffer::m_PagesInUse
private

Definition at line 142 of file dmapool.h.

Referenced by _IRQL_requires_max_().

◆ m_PagesTotal

ULONG XhciCommonBuffer::m_PagesTotal
private

Definition at line 141 of file dmapool.h.

◆ m_ReclaimItem

WDFWORKITEM XhciCommonBuffer::m_ReclaimItem
private

Definition at line 146 of file dmapool.h.

Referenced by EnablerCleanup(), and Rebalance().

◆ m_ReclaimList

LIST_ENTRY XhciCommonBuffer::m_ReclaimList
private

Definition at line 144 of file dmapool.h.

Referenced by _IRQL_requires_(), EnablerCleanup(), and Rebalance().

◆ m_ReclaimPages

ULONG XhciCommonBuffer::m_ReclaimPages
private

Definition at line 145 of file dmapool.h.

◆ m_Small

SizeClass XhciCommonBuffer::m_Small
private

◆ NeedGrow

_In_ ULONG _Out_ PLIST_ENTRY _Out_ PBOOLEAN XhciCommonBuffer::NeedGrow
private

Definition at line 112 of file dmapool.h.

Referenced by _IRQL_requires_max_().

◆ Taken

_In_ ULONG _Out_ PLIST_ENTRY XhciCommonBuffer::Taken
private

Definition at line 111 of file dmapool.h.

Referenced by _IRQL_requires_max_().


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