2 * Copyright (C) 2009-2010, Shao Miller <shao.miller@yrdsb.edu.on.ca>.
3 * Copyright 2006-2008, V.
4 * For WinAoE contact information, see http://winaoe.org/
6 * This file is part of WinVBlock, derived from WinAoE.
8 * WinVBlock is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * WinVBlock is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.
31 * A bus thread routine.
33 * @v bus The bus to be used in the thread routine.
35 * If you implement your own bus thread routine, you should call
36 * WvBusProcessWorkItems() within its loop.
38 typedef void STDCALL WVL_F_BUS_THREAD(IN WV_SP_BUS_T);
39 typedef WVL_F_BUS_THREAD * WVL_FP_BUS_THREAD;
44 * @v bus The bus to receive the PnP IRP.
45 * @v irp The IRP to process.
46 * @ret NTSTATUS The status of the operation.
48 typedef NTSTATUS STDCALL WV_F_BUS_PNP(IN WV_SP_BUS_T, IN PIRP);
49 typedef WV_F_BUS_PNP * WV_FP_BUS_PNP;
52 typedef enum WV_BUS_STATE {
55 WvBusStateStopPending,
57 WvBusStateRemovePending,
58 WvBusStateSurpriseRemovePending,
61 } WV_E_BUS_STATE, * WV_EP_BUS_STATE;
64 typedef struct WV_BUS_T {
65 PDEVICE_OBJECT LowerDeviceObject;
68 winvblock__uint32 Children;
69 WVL_FP_BUS_THREAD Thread;
72 WV_E_BUS_STATE OldState;
74 WV_FP_BUS_PNP QueryDevText;
79 KSPIN_LOCK WorkItemsLock;
81 } WV_S_BUS_T, * WV_SP_BUS_T;
83 /* A child PDO node on a bus. Treat this as an opaque type. */
84 typedef struct WV_BUS_NODE {
89 /* The child's unit number relative to the parent bus. */
90 winvblock__uint32 Num;
92 } WV_S_BUS_NODE, * WV_SP_BUS_NODE;
95 * A custom work-item function.
97 * @v context Function-specific data.
99 * If a driver needs to enqueue a work item which should execute in the
100 * context of the bus' controlling thread (this is the thread which calls
101 * WvBusProcessWorkItems()), then this is the function prototype to be
104 typedef void STDCALL WV_F_BUS_WORK_ITEM(void *);
105 typedef WV_F_BUS_WORK_ITEM * WV_FP_BUS_WORK_ITEM;
106 typedef struct WV_BUS_CUSTOM_WORK_ITEM {
107 WV_FP_BUS_WORK_ITEM Func;
109 } WV_S_BUS_CUSTOM_WORK_ITEM, * WV_SP_BUS_CUSTOM_WORK_ITEM;
112 extern winvblock__lib_func void WvBusInit(WV_SP_BUS_T);
113 extern winvblock__lib_func WV_SP_BUS_T WvBusCreate(void);
114 extern winvblock__lib_func void WvBusProcessWorkItems(WV_SP_BUS_T);
115 extern winvblock__lib_func void WvBusCancelWorkItems(WV_SP_BUS_T);
116 extern winvblock__lib_func NTSTATUS WvBusStartThread(
120 extern winvblock__lib_func winvblock__bool STDCALL WvBusInitNode(
124 extern winvblock__lib_func NTSTATUS STDCALL WvBusAddNode(
128 extern winvblock__lib_func NTSTATUS STDCALL WvBusRemoveNode(WV_SP_BUS_NODE);
129 extern winvblock__lib_func NTSTATUS STDCALL WvBusEnqueueIrp(WV_SP_BUS_T, PIRP);
130 extern winvblock__lib_func NTSTATUS STDCALL WvBusEnqueueCustomWorkItem(
132 WV_SP_BUS_CUSTOM_WORK_ITEM
134 extern winvblock__lib_func NTSTATUS STDCALL WvBusSysCtl(
138 extern winvblock__lib_func NTSTATUS STDCALL WvBusPower(
142 /* IRP_MJ_PNP dispatcher in bus/pnp.c */
143 extern winvblock__lib_func NTSTATUS STDCALL WvBusPnp(
148 extern winvblock__lib_func winvblock__uint32 STDCALL WvBusGetNodeNum(
151 extern winvblock__lib_func WV_SP_BUS_NODE STDCALL WvBusGetNextNode(
155 extern winvblock__lib_func PDEVICE_OBJECT STDCALL WvBusGetNodePdo(
158 extern winvblock__lib_func winvblock__uint32 STDCALL WvBusGetNodeCount(
162 #endif /* WVL_M_BUS_H_ */