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

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

_Must_inspect_result_ NTSTATUS NTAPI UcxCreateObjectWithTwoContexts (_In_ PWDF_OBJECT_ATTRIBUTES Primary, _In_opt_ PWDF_OBJECT_ATTRIBUTES Secondary, _Out_ WDFOBJECT *Object)
 
ULONG NTAPI UcxRandom (VOID)
 
BOOLEAN NTAPI UcxVerifierWantsFailure (_In_ ULONG Setting)
 
ULONG NTAPI UcxRandomInRange (_In_ ULONG Max)
 
NTSTATUS NTAPI UcxRandomErrorStatus (VOID)
 

Variables

UcxDriverState UcxDriver
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file ucxutil.cpp.

Function Documentation

◆ UcxCreateObjectWithTwoContexts()

_Must_inspect_result_ NTSTATUS NTAPI UcxCreateObjectWithTwoContexts ( _In_ PWDF_OBJECT_ATTRIBUTES  Primary,
_In_opt_ PWDF_OBJECT_ATTRIBUTES  Secondary,
_Out_ WDFOBJECT *  Object 
)

Creates a WDF object with a primary set of attributes and an optional second context.

Definition at line 19 of file ucxutil.cpp.

23{
25 WDFOBJECT Created;
27
28 *Object = NULL;
29
30 Status = WdfObjectCreate(Primary, &Created);
31 if (!NT_SUCCESS(Status))
32 {
33 DPRINT1("Object create failed 0x%lx\n", Status);
34 return Status;
35 }
36
37 if (Secondary != NULL && Secondary->ContextTypeInfo != NULL)
38 {
39 Extra = *Secondary;
40 Extra.ParentObject = NULL;
43
44 Status = WdfObjectAllocateContext(Created, &Extra, NULL);
45 if (!NT_SUCCESS(Status))
46 {
47 DPRINT1("Client context on object %p failed 0x%lx\n", Created, Status);
48 WdfObjectDelete(Created);
49 return Status;
50 }
51 }
52
53 *Object = Created;
54 return STATUS_SUCCESS;
55}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:24
#define STATUS_SUCCESS
Definition: shellext.h:65
WDFOBJECT ParentObject
Definition: wdfobject.h:130
WDF_EXECUTION_LEVEL ExecutionLevel
Definition: wdfobject.h:120
WDF_SYNCHRONIZATION_SCOPE SynchronizationScope
Definition: wdfobject.h:125
WdfObjectDelete(String)
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
@ WdfSynchronizationScopeInheritFromParent
Definition: wdfobject.h:63
@ WdfExecutionLevelInheritFromParent
Definition: wdfobject.h:53
FORCEINLINE NTSTATUS WdfObjectAllocateContext(_In_ WDFOBJECT Handle, _In_ PWDF_OBJECT_ATTRIBUTES ContextAttributes, _Outptr_opt_ PVOID *Context)
Definition: wdfobject.h:587

Referenced by UcxController::Create(), UcxRootHub::Create(), UcxUsbDevice::Create(), UcxStaticStreams::Create(), and UcxEndpoint::Create().

◆ UcxRandom()

ULONG NTAPI UcxRandom ( VOID  )

Definition at line 61 of file ucxutil.cpp.

62{
63 UcxDriver.RandomSeed = UcxDriver.RandomSeed * 1103515245 + 12345;
64
65 return (UcxDriver.RandomSeed / 65536) % 32768;
66}
ULONG RandomSeed
Definition: ucxutil.h:159
UcxDriverState UcxDriver
Definition: ucxutil.cpp:13

Referenced by UcxRandomErrorStatus(), UcxRandomInRange(), and UcxVerifierWantsFailure().

◆ UcxRandomErrorStatus()

NTSTATUS NTAPI UcxRandomErrorStatus ( VOID  )

Definition at line 93 of file ucxutil.cpp.

94{
95 return (NTSTATUS)(0xC0000000 | UcxRandom());
96}
ULONG NTAPI UcxRandom(VOID)
Definition: ucxutil.cpp:61

Referenced by _IRQL_requires_(), UcxEndpoint::OpenStaticStreams(), and UcxQueryUsbCapability().

◆ UcxRandomInRange()

ULONG NTAPI UcxRandomInRange ( _In_ ULONG  Max)

Definition at line 85 of file ucxutil.cpp.

87{
88 return (UcxRandom() % Max) + 1;
89}
#define Max(a, b)
Definition: cdprocs.h:78

Referenced by UcxApplyStreamCountOverride().

◆ UcxVerifierWantsFailure()

BOOLEAN NTAPI UcxVerifierWantsFailure ( _In_ ULONG  Setting)

0 never fails, 1 always fails, N fails about once in N calls.

Definition at line 71 of file ucxutil.cpp.

73{
74 if (Setting == 0)
75 return FALSE;
76
77 if (Setting == 1)
78 return TRUE;
79
80 return (32768 / Setting) > UcxRandom();
81}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117

Referenced by _IRQL_requires_(), UcxEndpoint::OpenStaticStreams(), and UcxQueryUsbCapability().

Variable Documentation

◆ UcxDriver

UcxDriverState UcxDriver

Definition at line 13 of file ucxutil.cpp.

Referenced by UcxRandom().