ReactOS 0.4.15-dev-7942-gd23573b
state.c File Reference
#include <pci.h>
#include <debug.h>
Include dependency graph for state.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID NTAPI PciInitializeState (IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciBeginStateTransition (IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE NewState)
 
NTSTATUS NTAPI PciCancelStateTransition (IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE StateNotEntered)
 
VOID NTAPI PciCommitStateTransition (IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE NewState)
 

Variables

PCHAR PciTransitionText [PciMaxObjectState+1]
 
NTSTATUS PnpStateCancelArray [PciMaxObjectState]
 
NTSTATUS PnpStateTransitionArray [PciMaxObjectState *PciMaxObjectState]
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file state.c.

Function Documentation

◆ PciBeginStateTransition()

NTSTATUS NTAPI PciBeginStateTransition ( IN PPCI_FDO_EXTENSION  DeviceExtension,
IN PCI_STATE  NewState 
)

Definition at line 97 of file state.c.

99{
102 DPRINT1("PCI Request to begin transition of Extension %p to %s ->",
103 DeviceExtension,
104 PciTransitionText[NewState]);
105
106 /* Assert the device isn't already in a pending transition */
107 ASSERT(DeviceExtension->TentativeNextState == DeviceExtension->DeviceState);
108
109 /* Assert this is a valid state */
110 CurrentState = DeviceExtension->DeviceState;
112 ASSERT(NewState < PciMaxObjectState);
113
114 /* Lookup if this state transition is valid */
117 {
118 /* Invalid transition (logical fault) */
119 DPRINT1("ERROR\nPCI: Error trying to enter state \"%s\" "
120 "from state \"%s\"\n",
121 PciTransitionText[NewState],
124 }
126 {
127 /* Invalid transition (illegal request) */
128 DPRINT1("ERROR\nPCI: Illegal request to try to enter state \"%s\" "
129 "from state \"%s\", rejecting",
130 PciTransitionText[NewState],
132 }
133
134 /* New state must be different from current, unless request is at fault */
135 ASSERT((NewState != DeviceExtension->DeviceState) || (!NT_SUCCESS(Status)));
136
137 /* Enter the new state if successful, and return state status */
138 if (NT_SUCCESS(Status)) DeviceExtension->TentativeNextState = NewState;
139 DbgPrint("%x\n", Status);
140 return Status;
141}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PCHAR PciTransitionText[PciMaxObjectState+1]
Definition: state.c:18
NTSTATUS PnpStateTransitionArray[PciMaxObjectState *PciMaxObjectState]
Definition: state.c:39
enum _PCI_STATE PCI_STATE
@ PciMaxObjectState
Definition: pci.h:135
Status
Definition: gdiplustypes.h:25
#define DbgPrint
Definition: hal.h:12
NTSYSAPI void WINAPI DbgBreakPoint(void)
#define ASSERT(a)
Definition: mode.c:44
#define STATUS_FAIL_CHECK
Definition: ntstatus.h:685
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
_Out_opt_ PBOOLEAN CurrentState
Definition: zwfuncs.h:393

Referenced by PciFdoIrpStartDevice(), PciPdoIrpStartDevice(), and PciQueryDeviceRelations().

◆ PciCancelStateTransition()

NTSTATUS NTAPI PciCancelStateTransition ( IN PPCI_FDO_EXTENSION  DeviceExtension,
IN PCI_STATE  StateNotEntered 
)

Definition at line 145 of file state.c.

147{
149 DPRINT1("PCI Request to cancel transition of Extension %p to %s ->",
150 DeviceExtension,
151 PciTransitionText[StateNotEntered]);
152
153 /* The next state can't be the state the device is already in */
154 if (DeviceExtension->TentativeNextState == DeviceExtension->DeviceState)
155 {
156 /* It's too late since the state was already committed */
157 ASSERT(StateNotEntered < PciMaxObjectState);
158 ASSERT(PnpStateCancelArray[StateNotEntered] != STATUS_FAIL_CHECK);
159
160 /* Return failure */
162 DbgPrint("%x\n", Status);
163 }
164 else
165 {
166 /* The device hasn't yet entered the state, so it's still possible to cancel */
167 ASSERT(DeviceExtension->TentativeNextState == StateNotEntered);
168 DeviceExtension->TentativeNextState = DeviceExtension->DeviceState;
169
170 /* Return success */
172 DbgPrint("%x\n", Status);
173 }
174
175 /* Return the cancel state */
176 return Status;
177}
NTSTATUS PnpStateCancelArray[PciMaxObjectState]
Definition: state.c:29
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178

Referenced by PciFdoIrpStartDevice(), PciPdoIrpStartDevice(), and PciQueryDeviceRelations().

◆ PciCommitStateTransition()

VOID NTAPI PciCommitStateTransition ( IN PPCI_FDO_EXTENSION  DeviceExtension,
IN PCI_STATE  NewState 
)

Definition at line 181 of file state.c.

183{
184 DPRINT1("PCI Commit transition of Extension %p to %s\n",
185 DeviceExtension, PciTransitionText[NewState]);
186
187 /* Make sure this is a valid commit */
188 ASSERT(NewState != PciSynchronizedOperation);
189 ASSERT(DeviceExtension->TentativeNextState == NewState);
190
191 /* Enter the new state */
192 DeviceExtension->DeviceState = NewState;
193}
@ PciSynchronizedOperation
Definition: pci.h:134

Referenced by PciFdoIrpStartDevice(), and PciPdoIrpStartDevice().

◆ PciInitializeState()

VOID NTAPI PciInitializeState ( IN PPCI_FDO_EXTENSION  DeviceExtension)

Definition at line 88 of file state.c.

89{
90 /* Set the initial state */
91 DeviceExtension->DeviceState = PciNotStarted;
92 DeviceExtension->TentativeNextState = PciNotStarted;
93}
@ PciNotStarted
Definition: pci.h:129

Referenced by PciInitializeFdoExtensionCommonFields(), and PciPdoCreate().

Variable Documentation

◆ PciTransitionText

PCHAR PciTransitionText[PciMaxObjectState+1]
Initial value:
=
{
"PciNotStarted",
"PciStarted",
"PciDeleted",
"PciStopped",
"PciSurpriseRemoved",
"PciSynchronizedOperation",
"PciMaxObjectState"
}

Definition at line 18 of file state.c.

Referenced by PciBeginStateTransition(), PciCancelStateTransition(), and PciCommitStateTransition().

◆ PnpStateCancelArray

◆ PnpStateTransitionArray

NTSTATUS PnpStateTransitionArray[PciMaxObjectState *PciMaxObjectState]

Definition at line 39 of file state.c.

Referenced by PciBeginStateTransition().