ReactOS 0.4.17-dev-1281-g065abb3
bootdev.cpp File Reference
#include "usbhub3.h"
#include <debug.h>
Include dependency graph for bootdev.cpp:

Go to the source code of this file.

Classes

struct  HubBootRegistration
 

Macros

#define NDEBUG
 
#define HUB_BOOT_REGISTRATION_VERSION   1
 

Typedefs

typedef BOOLEAN(NTAPI * PFN_HUB_BOOT_DEVICE_READY) (_In_ PDEVICE_OBJECT Pdo, _In_ PVOID Context)
 

Functions

 C_ASSERT (sizeof(HubBootRegistration)==0x18)
 
 _IRQL_requires_ (PASSIVE_LEVEL) static BOOLEAN NTAPI HubBootIsExternal(_In_ WDFDEVICE Device)
 Sends a synchronous IOCTL to the specified device object.
 
static VOID NTAPI HubBootRecoveryWorkItem (_In_ WDFWORKITEM WorkItem)
 
 _IRQL_requires_max_ (DISPATCH_LEVEL) static VOID NTAPI HubBootAfterRecovery(_In_ HubChild *Child)
 
 UNREFERENCED_PARAMETER (Pdo)
 
 PAGED_CODE ()
 
 if (Child->m_Hub->IsHubResetInProgress())
 
 if (!NT_SUCCESS(ReadStatus))
 
 if (Child->HasState(ChildState::DifferentDeviceOnBootPort) &&!(Change &PC_CONNECT))
 
 if (Port->m_ConnectionStatus==DeviceFailedEnumeration)
 
 if (Status &PS_CONNECTED)
 
 if ((Child->m_Kind &DSM_KIND_SUPER_SPEED) &&HubLinkState(Status)==LINK_SS_INACTIVE)
 
Port ClearFlag (PortFlag::SsInactiveSeenForBoot)
 
 DPRINT ("Boot device on port %u still missing, status 0x%lx\n", Port->Number(), PortStatus)
 
 if (Pdo->HasFlag(PdoFlag::InBootPath)) return STATUS_SUCCESS
 
 if (Child->m_BootControl.Request==NULL)
 
 if (!Child->m_Port->HasFlag(PortFlag::DeviceConnected))
 
 if (!WinPe)
 
 DPRINT ("Port %u device is now in the boot path\n", Pdo->m_PortNumber)
 
 DPRINT ("Port %u usage notice %d, in path %u\n", Pdo->m_PortNumber,(int) NotificationType, IsInNotificationPath)
 
 if (!(Child->m_SqmFlags &(LONG) ChildSqm::HoldsPagingFiles))
 
 switch (NotificationType)
 

Variables

_In_ PVOID Context
 
HubPort * Port = Child->m_Port
 
ULONG PortStatus = 0
 
USHORT Status = (USHORT)(PortStatus & 0xFFFF)
 
USHORT Change = (USHORT)(PortStatus >> 16)
 
NTSTATUS ReadStatus = HubReadPortStatusForBootDevice(Child, &PortStatus)
 
BOOLEAN Ready = FALSE
 
InterlockedExchange & Child = Pdo->m_Child
 
Done __pad0__
 
_In_ BOOLEAN WinPe = HubIsWinPe()
 
_In_ BOOLEAN _In_ BOOLEAN External
 
HubFdo * Hub = Pdo->m_Hub
 
Child m_NeedsForwardProgress = TRUE
 
return STATUS_SUCCESS
 
_In_ WDF_SPECIAL_FILE_TYPE NotificationType
 
_In_ WDF_SPECIAL_FILE_TYPE _In_ BOOLEAN IsInNotificationPath
 

Macro Definition Documentation

◆ HUB_BOOT_REGISTRATION_VERSION

#define HUB_BOOT_REGISTRATION_VERSION   1

Definition at line 38 of file bootdev.cpp.

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file bootdev.cpp.

Typedef Documentation

◆ PFN_HUB_BOOT_DEVICE_READY

typedef BOOLEAN(NTAPI * PFN_HUB_BOOT_DEVICE_READY) (_In_ PDEVICE_OBJECT Pdo, _In_ PVOID Context)

Definition at line 16 of file bootdev.cpp.

Function Documentation

◆ _IRQL_requires_()

_IRQL_requires_ ( PASSIVE_LEVEL  )

Sends a synchronous IOCTL to the specified device object.

Parameters
[in]IoControlCodeThe IOCTL to send to the device.
[in]DeviceObjectPointer to the device object that will handle the IOCTL.
[in]InputBufferOptional pointer to a buffer containing input data for the IOCTL. When specified, the buffer should be at least of InputBufferLength size.
[in]InputBufferLengthSize in bytes, of the buffer pointed by InputBuffer.
[out]OutputBufferOptional pointer to a buffer that will receive output data from the IOCTL. When specified, the buffer should be at least of OutputBufferLength size.
[in]OutputBufferLengthSize in bytes, of the buffer pointed by OutputBuffer.
[in]FileObjectOptional pointer to a file object that may be necessary for the IOCTL.
Returns
An NTSTATUS code indicating success or failure of this function.
Note
Must be called at PASSIVE_LEVEL with all APCs enabled.

Nothing is found unless the PCI bus driver publishes the properties.

The root hub name without its prefix; NULL when the PDO has no name.

Grows a private buffer to what the helper asks for.

Definition at line 43 of file bootdev.cpp.

49{
50 BOOLEAN InMachine = FALSE;
52 ULONG Size;
54
55 PAGED_CODE();
56
57 Status = IoGetDevicePropertyData(WdfDeviceWdmGetDeviceObject(Device),
58 &DEVPKEY_Device_InLocalMachineContainer,
60 0,
61 sizeof(InMachine),
62 &InMachine,
63 &Size,
64 &Type);
65 if (!NT_SUCCESS(Status))
66 {
67 DPRINT("No container answer for %p (0x%lx), treated as external\n", Device, Status);
68 return TRUE;
69 }
70
71 return InMachine == DEVPROP_FALSE;
72}
Type
Definition: Type.h:7
unsigned char BOOLEAN
Definition: actypes.h:127
LONG NTSTATUS
Definition: precomp.h:26
USHORT Status
Definition: bootdev.cpp:132
PAGED_CODE()
#define DEVPROP_FALSE
Definition: devpropdef.h:67
ULONG DEVPROPTYPE
Definition: devpropdef.h:24
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PUCXHUB_DEVICE_CREATE_INFO _Out_ UCXUSBDEVICE * Device
Definition: hubucx.h:258
#define LOCALE_NEUTRAL
#define DPRINT
Definition: sndvol32.h:73
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539

◆ _IRQL_requires_max_()

_IRQL_requires_max_ ( DISPATCH_LEVEL  )

Definition at line 89 of file bootdev.cpp.

95{
98 WDFWORKITEM WorkItem;
100
101 if (!Child->m_Port->HasFlag(PortFlag::PendingRecoveryUpdate))
102 return;
103
104 Child->m_Port->ClearFlag(PortFlag::PendingRecoveryUpdate);
105
108 Attributes.ParentObject = Child->m_Pdo->m_Device;
109
110 Status = WdfWorkItemCreate(&Config, &Attributes, &WorkItem);
111 if (!NT_SUCCESS(Status))
112 {
113 DPRINT1("Boot recovery work item failed 0x%lx\n", Status);
114 return;
115 }
116
118}
#define DPRINT1
Definition: precomp.h:8
static VOID NTAPI HubBootRecoveryWorkItem(_In_ WDFWORKITEM WorkItem)
Definition: bootdev.cpp:78
_In_ ULONG Attributes
Definition: dispmprt.h:1077
@ PendingRecoveryUpdate
WdfWorkItemEnqueue(WorkItem)
_In_opt_ PVOID _In_ PUCXHUB_WORKITEM WorkItem
Definition: hubucx.h:227
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG Config
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:536
FORCEINLINE VOID WDF_OBJECT_ATTRIBUTES_INIT(_Out_ PWDF_OBJECT_ATTRIBUTES Attributes)
Definition: wdfobject.h:147
FORCEINLINE VOID WDF_WORKITEM_CONFIG_INIT(_Out_ PWDF_WORKITEM_CONFIG Config, _In_ PFN_WDF_WORKITEM EvtWorkItemFunc)
Definition: wdfworkitem.h:85

◆ C_ASSERT()

C_ASSERT ( sizeof(HubBootRegistration)  = =0x18)

◆ ClearFlag()

◆ DPRINT() [1/3]

DPRINT ( "Boot device on port %u still  missing,
status 0x%lx\n"  ,
Port->  Number(),
PortStatus   
)

◆ DPRINT() [2/3]

DPRINT ( "Port %u device is now in the boot path\n"  ,
Pdo->  m_PortNumber 
)

◆ DPRINT() [3/3]

DPRINT ( "Port %u usage notice %  d,
in path %u\n"  ,
Pdo->  m_PortNumber,
(int)  NotificationType,
IsInNotificationPath   
)

◆ HubBootRecoveryWorkItem()

static VOID NTAPI HubBootRecoveryWorkItem ( _In_ WDFWORKITEM  WorkItem)
static

Definition at line 78 of file bootdev.cpp.

80{
82
83 DPRINT("Boot device recovered after a surprise removal\n");
84 HubWmiNotifyBootSurpriseRemoval();
85 HubBumpBootSurpriseRemovalCount();
86}
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329

Referenced by _IRQL_requires_max_().

◆ if() [1/11]

if ( !  Child->m_SqmFlags &(LONG) ChildSqm::HoldsPagingFiles)

Definition at line 331 of file bootdev.cpp.

332 {
335 }
HubFlushSqmFlags(Child)
@ HoldsPagingFiles
#define InterlockedOr
Definition: interlocked.h:239
long LONG
Definition: pedump.c:60

◆ if() [2/11]

if ( !Child->m_Port->  HasFlagPortFlag::DeviceConnected)

Definition at line 279 of file bootdev.cpp.

280 {
281 DPRINT1("Boot device on port %u left before its usage notice\n", Pdo->m_PortNumber);
283 }
_In_ UCXUSBDEVICE _In_ PDEVICE_OBJECT Pdo
Definition: hubucx.h:280
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136

◆ if() [3/11]

if ( !  NT_SUCCESSReadStatus)

Definition at line 153 of file bootdev.cpp.

154 {
155 DPRINT1("Boot device port %u status read failed 0x%lx\n", Port->Number(), ReadStatus);
156 goto Done;
157 }
NTSTATUS ReadStatus
Definition: bootdev.cpp:134
HubPort * Port
Definition: bootdev.cpp:130
USHORT Number() const
Definition: hubport.h:213
KEVENT Done
Definition: devreq.cpp:1162

◆ if() [4/11]

if ( !  WinPe)

Definition at line 285 of file bootdev.cpp.

286 {
287 /* Internal devices are not registered; saves memory where SATA was replaced by USB */
288 if (External)
289 {
290 Status = HubBootRegister(Child);
291 if (!NT_SUCCESS(Status))
292 DPRINT1("Boot device registration failed 0x%lx\n", Status);
293
294 if (!Child->HasProperty(ChildProperty::IsHub))
295 HubWmiRegisterBootSurpriseRemoval(Pdo->m_Device);
296 }
297 else
298 {
299 DPRINT1("Boot device on port %u is internal, not registered\n", Pdo->m_PortNumber);
300 }
301
302 Pdo->SetFlag(PdoFlag::InBootPath);
303 Child->m_Port->SetFlag(PortFlag::SupportsReattach);
304 }
_In_ BOOLEAN _In_ BOOLEAN External
Definition: bootdev.cpp:259
@ SupportsReattach

◆ if() [5/11]

Definition at line 182 of file bootdev.cpp.

183 {
185 {
186 DPRINT("Boot port %u stayed in SS.Inactive, device counted present\n", Port->Number());
187 Ready = TRUE;
188 goto Done;
189 }
190
191 DPRINT("Boot port %u in SS.Inactive for the first time\n", Port->Number());
193 goto Done;
194 }
BOOLEAN Ready
Definition: bootdev.cpp:135
VOID SetFlag(_In_ PortFlag Flag)
Definition: hubport.h:192
BOOLEAN HasFlag(_In_ PortFlag Flag) const
Definition: hubport.h:185
@ SsInactiveSeenForBoot

◆ if() [6/11]

if ( Child->  HasStateChildState::DifferentDeviceOnBootPort) &&!(Change &PC_CONNECT)

Definition at line 162 of file bootdev.cpp.

163 {
164 DPRINT("Boot port %u still holds a different device\n", Port->Number());
165 goto Done;
166 }

◆ if() [7/11]

if ( Child->m_BootControl.  Request = = NULL)

Definition at line 269 of file bootdev.cpp.

270 {
271 Status = Child->m_BootControl.Create(Child->m_Object, WdfDeviceGetIoTarget(Hub->m_Device));
272 if (!NT_SUCCESS(Status))
273 {
274 DPRINT1("Boot request on port %u not created 0x%lx\n", Pdo->m_PortNumber, Status);
275 return Status;
276 }
277 }
HubFdo * Hub
Definition: bootdev.cpp:261
WDFDEVICE m_Device
Definition: fdo.h:349

◆ if() [8/11]

if ( Child->m_Hub->  IsHubResetInProgress())

Definition at line 142 of file bootdev.cpp.

143 {
144 DPRINT("Boot device on port %u counted present during a hub reset\n", Port->Number());
145 Ready = TRUE;
146 goto Done;
147 }

◆ if() [9/11]

if ( Pdo->  HasFlagPdoFlag::InBootPath)

◆ if() [10/11]

if ( Port->  m_ConnectionStatus = = DeviceFailedEnumeration)

Definition at line 168 of file bootdev.cpp.

169 {
170 DPRINT("Boot device on port %u failed its last enumeration\n", Port->Number());
171 goto Done;
172 }

◆ if() [11/11]

if ( Status &  PS_CONNECTED)

Definition at line 174 of file bootdev.cpp.

175 {
176 DPRINT("Boot device on port %u is connected\n", Port->Number());
177 Ready = TRUE;
178 goto Done;
179 }

◆ PAGED_CODE()

PAGED_CODE ( )

Referenced by _IRQL_requires_().

◆ switch()

switch ( NotificationType  )

Definition at line 337 of file bootdev.cpp.

338 {
339 /* Paging on an external disk that is not the boot disk is refused */
341 if (!WinPe)
342 {
343 External = HubBootIsExternal(Device);
344 if (External)
345 {
346 if (Pdo->HasFlag(PdoFlag::InBootPath))
347 return STATUS_SUCCESS;
348
349 DPRINT1("Paging refused on external port %u device\n", Pdo->m_PortNumber);
351 }
352 }
353 return HubBootAddToPath(Pdo, WinPe, External);
354
356 if (!WinPe && !Pdo->HasFlag(PdoFlag::InBootPath))
357 External = HubBootIsExternal(Device);
358 return HubBootAddToPath(Pdo, WinPe, External);
359
362 Child->m_NeedsForwardProgress = TRUE;
363 return STATUS_SUCCESS;
364
365 default:
366 return STATUS_SUCCESS;
367 }
_In_ BOOLEAN WinPe
Definition: bootdev.cpp:257
return STATUS_SUCCESS
Definition: bootdev.cpp:309
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
_In_ WDF_SPECIAL_FILE_TYPE _In_ BOOLEAN IsInNotificationPath
Definition: wdfdevice.h:1027
@ WdfSpecialFileBoot
Definition: wdfdevice.h:445
@ WdfSpecialFileHibernation
Definition: wdfdevice.h:443
@ WdfSpecialFilePaging
Definition: wdfdevice.h:442

◆ UNREFERENCED_PARAMETER()

UNREFERENCED_PARAMETER ( Pdo  )

Variable Documentation

◆ __pad0__

Done __pad0__

Definition at line 199 of file bootdev.cpp.

◆ Change

◆ Child

Definition at line 149 of file bootdev.cpp.

◆ Context

Initial value:
{
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81

Definition at line 127 of file bootdev.cpp.

◆ External

BOOLEAN External
Initial value:
{
HubChild* Child = Pdo->m_Child

Definition at line 258 of file bootdev.cpp.

Referenced by CmpInitializeHive(), if(), and switch().

◆ Hub

HubFdo * Hub = Pdo->m_Hub

Definition at line 261 of file bootdev.cpp.

Referenced by _IRQL_requires_(), _IRQL_requires_max_(), UcxController::Address0Release(), XhciUsbDevice::BuildAddressContext(), XhciUsbDevice::BuildSlotContext(), DeviceMachine::ComputeExitLatency(), HubChild::Create(), DeviceMachine::CreateDefaultEndpoint(), DeviceMachine::CreateDeviceInController(), DeviceMachine::CreateEndpoints(), UcxUsbDevice::CreateFromHub(), DeviceMachine::DeleteDefaultEndpoint(), DeviceMachine::DeleteDeviceInController(), PortMachine::DisconnectDevice(), for(), HubAcpiAllocate(), HubAddPort(), HubBuildDescContext(), HubCheckUsb2HubDescriptor(), HubCheckUsb3HubDescriptor(), HubClearTtBuffer(), HubConfigurationComplete(), HubConnectorCopyParentId(), HubConnectorSetRootId(), HubControlComplete(), HubCreateParentRequest(), HubCreateUcxRequest(), HubEvtIoDeviceControl(), HubEvtIoInternalDeviceControl(), HubEvtOverCurrentWorkItem(), HubFindHubInterface(), HubInterruptComplete(), HubIoBuild20Descriptor(), HubIoctlComplete(), HubIoCyclePort(), HubIoForward(), HubIoGetConnectionAttributes(), HubIoGetConnectionInformation(), HubIoGetConnectionInformationV2(), HubIoGetConnectionName(), HubIoGetConnectorProperties(), HubIoGetDescriptor(), HubIoGetDriverKeyName(), HubIoGetHubCapabilities(), HubIoGetHubInformationEx(), HubIoGetNodeInformation(), HubIoGetPortStatus(), HubIoLockChild(), HubIoPrepare(), HubIoResetHub(), HubIoUnlockChildren(), HubIoValidate(), HubLogConfigTotalLengthMismatch(), HubMailboxComplete(), HubMailboxTransfer(), HubMakeUsb2StyleDescriptor(), HubParentInfoComplete(), HubPipeResetComplete(), PortMachine::HubPowerTake(), HubResetComplete(), HubRootHubInfoComplete(), HubSendControl(), HubSendToParent(), HubSendUcxIoctl(), HubTakePortStatusRequest(), HubTtClearComplete(), HubUsb4AddPowerRelation(), HubUsb4FindHost(), HubUsb4HostAt(), HubUsb4InterfaceChange(), HubUsb4InvalidatePowerRelations(), HubUsb4OpenWorkItem(), HubUsb4RemovePowerRelation(), HubUsb4TargetRemoveComplete(), HubValidateHubConfiguration(), HubWmiExecuteMethod(), HubWmiFirePortEvent(), HubWmiHubName(), HubWmiHubNameRequest(), HubWmiNotifyOverCurrent(), HubWmiQueryDeviceNode(), HubWmiQueryHubNode(), HubWmiResetOverCurrent(), if(), PortNextChange30(), PortSendControl(), PortTrackPendingOperation(), DeviceMachine::ReleaseAddressZero(), DeviceMachine::SelectConfigValid(), DeviceMachine::SetIsochDelay(), DeviceMachine::SetSel(), UcxBuildPortPath(), UcxEvtQueryStackInterface(), UcxHubAddress0Release(), UcxHubAllowControllerIdle(), UcxHubBlockControllerIdle(), UcxHubClearTtBufferComplete(), UcxHubCreateControlEndpoint(), UcxHubDeviceCreate(), UcxHubDeviceDelete(), UcxHubDeviceDisconnect(), UcxHubDeviceSetPdo(), UcxHubEndpointCreate(), UcxHubEndpointDelete(), UcxHubEndpointSetPriority(), UcxHubQueryControllerBus(), UcxHubStreamsSupported(), and UcxHubWorkItemAllocate().

◆ IsInNotificationPath

Initial value:
{
HubPdo* Pdo = HubGetPdoContext(Device)

Definition at line 318 of file bootdev.cpp.

◆ m_NeedsForwardProgress

Child m_NeedsForwardProgress = TRUE

Definition at line 307 of file bootdev.cpp.

◆ NotificationType

◆ Port

HubPort* Port = Child->m_Port

Definition at line 130 of file bootdev.cpp.

Referenced by if().

◆ PortStatus

◆ ReadStatus

◆ Ready

BOOLEAN Ready = FALSE

Definition at line 135 of file bootdev.cpp.

Referenced by _Requires_lock_held_(), if(), KiDeferredReadyThread(), and KiSetPriorityThread().

◆ Status

Definition at line 132 of file bootdev.cpp.

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

◆ STATUS_SUCCESS

return STATUS_SUCCESS

Definition at line 309 of file bootdev.cpp.

Referenced by switch().

◆ WinPe

BOOLEAN WinPe = HubIsWinPe()

Definition at line 257 of file bootdev.cpp.

Referenced by switch().