Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

857 lines
22 KiB

  1. /*++
  2. Copyright (c) 2002 Microsoft Corporation
  3. Module Name:
  4. sdbus.h
  5. Abstract:
  6. Author:
  7. Neil Sandlin (neilsa) 1-Jan-2002
  8. Revision History
  9. --*/
  10. #ifndef _SDBUS_H_
  11. #define _SDBUS_H_
  12. typedef enum _DEVICE_OBJECT_TYPE {
  13. FDO = 0,
  14. PDO
  15. } DEVICE_OBJECT_TYPE;
  16. //
  17. // Type of the controller
  18. //
  19. typedef ULONG SDBUS_CONTROLLER_TYPE, *PSDBUS_CONTROLLER_TYPE;
  20. struct _FDO_EXTENSION;
  21. struct _PDO_EXTENSION;
  22. struct _SD_WORK_PACKET;
  23. //
  24. // Io Worker States
  25. //
  26. typedef enum {
  27. WORKER_IDLE = 0,
  28. PACKET_PENDING,
  29. IN_PROCESS,
  30. WAITING_FOR_TIMER
  31. } WORKER_STATE;
  32. //
  33. // socket enumeration states
  34. //
  35. typedef enum {
  36. SOCKET_EMPTY = 0,
  37. CARD_DETECTED,
  38. CARD_NEEDS_ENUMERATION,
  39. CARD_ACTIVE,
  40. CARD_LOGICALLY_REMOVED
  41. } SOCKET_STATE;
  42. //
  43. // Define SynchronizeExecution routine.
  44. //
  45. typedef
  46. BOOLEAN
  47. (*PSYNCHRONIZATION_ROUTINE) (
  48. IN PKINTERRUPT Interrupt,
  49. IN PKSYNCHRONIZE_ROUTINE Routine,
  50. IN PVOID SynchronizeContext
  51. );
  52. //
  53. // Completion routine called by various timed routines
  54. //
  55. typedef
  56. VOID
  57. (*PSDBUS_COMPLETION_ROUTINE) (
  58. IN PDEVICE_OBJECT DeviceObject,
  59. IN PVOID Context
  60. );
  61. typedef
  62. VOID
  63. (*PSDBUS_ACTIVATE_COMPLETION_ROUTINE) (
  64. IN PDEVICE_OBJECT DeviceObject,
  65. IN PVOID Context,
  66. IN NTSTATUS Status
  67. );
  68. //
  69. // SD_FUNCTION_BLOCK allows for a level of indirection, thereby allowing
  70. // the top-level SDBUS code to do it's work without worrying about who's
  71. // particular brand of SD controller it's addressing.
  72. //
  73. typedef struct _SD_FUNCTION_BLOCK {
  74. //
  75. // Function to initialize controller. This is done once after
  76. // the host controller is started, or powered on.
  77. //
  78. VOID
  79. (*InitController)(
  80. IN struct _FDO_EXTENSION *FdoExtension
  81. );
  82. //
  83. // Function to initialize SD function. This is done once after
  84. // the function is started.
  85. //
  86. VOID
  87. (*InitFunction)(
  88. IN struct _FDO_EXTENSION *FdoExtension,
  89. IN struct _PDO_EXTENSION *PdoExtension
  90. );
  91. //
  92. // function to set power for a socket
  93. //
  94. NTSTATUS
  95. (*SetPower)(
  96. IN struct _FDO_EXTENSION *FdoExtension,
  97. IN BOOLEAN Enable,
  98. OUT PULONG pDelayTime
  99. );
  100. //
  101. // function to set reset an SD card
  102. //
  103. NTSTATUS
  104. (*ResetHost)(
  105. IN struct _FDO_EXTENSION *FdoExtension,
  106. IN UCHAR Phase,
  107. OUT PULONG pDelayTime
  108. );
  109. //
  110. // function to control the external LED
  111. //
  112. VOID
  113. (*SetLED)(
  114. IN struct _FDO_EXTENSION *FdoExtension,
  115. IN BOOLEAN Enable
  116. );
  117. //
  118. // Switch focus between IO function or memory function
  119. //
  120. VOID
  121. (*SetFunctionType)(
  122. IN struct _FDO_EXTENSION *FdoExtension,
  123. UCHAR FunctionType
  124. );
  125. //
  126. // Function to determine if a card is in the socket
  127. //
  128. BOOLEAN
  129. (*DetectCardInSocket)(
  130. IN struct _FDO_EXTENSION *FdoExtension
  131. );
  132. BOOLEAN
  133. (*IsWriteProtected)(
  134. IN struct _FDO_EXTENSION *FdoExtension
  135. );
  136. NTSTATUS
  137. (*CheckStatus)(
  138. IN struct _FDO_EXTENSION *FdoExtension
  139. );
  140. NTSTATUS
  141. (*SendSDCommand)(
  142. IN struct _FDO_EXTENSION *FdoExtension,
  143. IN struct _SD_WORK_PACKET *WorkPacket
  144. );
  145. NTSTATUS
  146. (*GetSDResponse)(
  147. IN struct _FDO_EXTENSION *FdoExtension,
  148. IN struct _SD_WORK_PACKET *WorkPacket
  149. );
  150. //
  151. // Interfaces for block memory operations
  152. //
  153. VOID
  154. (*StartBlockOperation)(
  155. IN struct _FDO_EXTENSION *FdoExtension
  156. );
  157. VOID
  158. (*SetBlockParameters)(
  159. IN struct _FDO_EXTENSION *FdoExtension,
  160. IN USHORT SectorCount
  161. );
  162. VOID
  163. (*EndBlockOperation)(
  164. IN struct _FDO_EXTENSION *FdoExtension
  165. );
  166. //
  167. // Copy a sector from the data port to a buffer
  168. //
  169. VOID
  170. (*ReadDataPort)(
  171. IN struct _FDO_EXTENSION *FdoExtension,
  172. IN PUCHAR Buffer,
  173. IN ULONG Length
  174. );
  175. //
  176. // Copy a sector from a buffer to the data port
  177. //
  178. VOID
  179. (*WriteDataPort)(
  180. IN struct _FDO_EXTENSION *FdoExtension,
  181. IN PUCHAR Buffer,
  182. IN ULONG Length
  183. );
  184. //
  185. // Function to enable/disable status change interrupts
  186. //
  187. VOID
  188. (*EnableEvent)(
  189. IN struct _FDO_EXTENSION *FdoExtension,
  190. IN ULONG EventMask
  191. );
  192. VOID
  193. (*DisableEvent)(
  194. IN struct _FDO_EXTENSION *FdoExtension,
  195. IN ULONG EventMask
  196. );
  197. //
  198. // vendor-specific function to handle interrupts
  199. //
  200. ULONG
  201. (*GetPendingEvents)(
  202. IN struct _FDO_EXTENSION *FdoExtension
  203. );
  204. VOID
  205. (*AcknowledgeEvent)(
  206. IN struct _FDO_EXTENSION *FdoExtension,
  207. IN ULONG EventMask
  208. );
  209. } SD_FUNCTION_BLOCK, *PSD_FUNCTION_BLOCK;
  210. //
  211. // Enumeration structures
  212. //
  213. #define MAX_MANFID_LENGTH 64
  214. #define MAX_IDENT_LENGTH 64
  215. typedef struct _SD_FUNCTION_DATA {
  216. struct _SD_FUNCTION_DATA *Next;
  217. //
  218. // Function Number
  219. //
  220. UCHAR Function;
  221. ULONG CardPsn;
  222. ULONG CsaSize;
  223. ULONG Ocr;
  224. UCHAR IoDeviceInterface;
  225. } SD_FUNCTION_DATA, *PSD_FUNCTION_DATA;
  226. typedef struct _SD_CARD_DATA {
  227. UCHAR MfgText[MAX_MANFID_LENGTH];
  228. UCHAR ProductText[MAX_IDENT_LENGTH];
  229. USHORT MfgId;
  230. USHORT MfgInfo;
  231. //
  232. // SD Io card parameters
  233. //
  234. UCHAR CardCapabilities;
  235. //
  236. // SD Memory Card parameters
  237. //
  238. SD_CID SdCid;
  239. SD_CSD SdCsd;
  240. UCHAR ProductName[6];
  241. //
  242. // array of per-function data
  243. //
  244. PSD_FUNCTION_DATA FunctionData;
  245. } SD_CARD_DATA, *PSD_CARD_DATA;
  246. //
  247. // Synchronization primitives
  248. //
  249. #define SDBUS_TEST_AND_SET(X) (InterlockedCompareExchange(X, 1, 0) == 0)
  250. #define SDBUS_TEST_AND_RESET(X) (InterlockedCompareExchange(X, 0, 1) == 1)
  251. //
  252. // Power
  253. //
  254. typedef struct _SD_POWER_CONTEXT {
  255. PSDBUS_COMPLETION_ROUTINE CompletionRoutine;
  256. PVOID Context;
  257. } SD_POWER_CONTEXT, *PSD_POWER_CONTEXT;
  258. typedef struct _SD_ACTIVATE_CONTEXT {
  259. PSDBUS_ACTIVATE_COMPLETION_ROUTINE CompletionRoutine;
  260. PVOID Context;
  261. } SD_ACTIVATE_CONTEXT, *PSD_ACTIVATE_CONTEXT;
  262. //
  263. // Functional Device Object's device extension information
  264. //
  265. // There is one device object for each SDBUS socket controller
  266. // located in the system. This contains the root pointers for
  267. // each of the lists of information on this controller.
  268. //
  269. //
  270. // Flags common to both fdoExtension and pdoExtension
  271. //
  272. #define SDBUS_DEVICE_STARTED 0x00000001
  273. #define SDBUS_DEVICE_LOGICALLY_REMOVED 0x00000002
  274. #define SDBUS_DEVICE_PHYSICALLY_REMOVED 0x00000004
  275. #define SDBUS_DEVICE_WAKE_PENDING 0x00000010
  276. #define SDBUS_DEVICE_DELETED 0x00000040
  277. //
  278. // Flags indicating controller state (fdoExtension)
  279. //
  280. #define SDBUS_HOST_REGISTER_BASE_MAPPED 0x00010000
  281. #define SDBUS_FDO_CONTEXT_SAVED 0x00020000
  282. #define SDBUS_FDO_OFFLINE 0x00040000
  283. #define SDBUS_FDO_WAKE_BY_CD 0x00080000
  284. #define SDBUS_FDO_WORK_ITEM_ACTIVE 0x00100000
  285. //
  286. // Flags indicating interrupt status
  287. //
  288. #define SDBUS_EVENT_INSERTION 0x00000001
  289. #define SDBUS_EVENT_REMOVAL 0x00000002
  290. #define SDBUS_EVENT_CARD_RESPONSE 0x00000004
  291. #define SDBUS_EVENT_CARD_RW_END 0x00000008
  292. #define SDBUS_EVENT_BUFFER_EMPTY 0x00000010
  293. #define SDBUS_EVENT_BUFFER_FULL 0x00000020
  294. #define SDBUS_EVENT_CARD_INTERRUPT 0x00000040
  295. #define SDBUS_EVENT_ALL 0xFFFFFFFF
  296. //
  297. // Flags indicating what type of function is currently being addressed
  298. //
  299. #define SDBUS_FUNCTION_TYPE_MEMORY 1
  300. #define SDBUS_FUNCTION_TYPE_IO 2
  301. //
  302. // FDO Flags
  303. //
  304. #define SDBUS_FDO_EXTENSION_SIGNATURE 'FmcP'
  305. //
  306. // Device extension for the functional device object for sd controllers
  307. //
  308. typedef struct _FDO_EXTENSION {
  309. ULONG Signature;
  310. //
  311. // Pointer to the next sd controller's FDO in the central list
  312. // of all sd controller managed by this driver.
  313. // The head of the list is pointed to by the global variable FdoList
  314. //
  315. PDEVICE_OBJECT NextFdo;
  316. //
  317. // The PDO ejected by the parent bus driver for this sd controller
  318. //
  319. //
  320. PDEVICE_OBJECT Pdo;
  321. //
  322. // The immediately lower device attached beneath the sd controller's FDO.
  323. // This would be the same as the Pdo above, excepting in cases when there are
  324. // lower filter drivers for the sd controller - like the ACPI driver
  325. //
  326. PDEVICE_OBJECT LowerDevice;
  327. //
  328. // Pointer to the miniport-like
  329. //
  330. PSD_FUNCTION_BLOCK FunctionBlock;
  331. //
  332. // Various flags used to track the state of this
  333. // (flags prefixed by SDBUS_ above)
  334. //
  335. ULONG Flags;
  336. //
  337. // Type of the controller. We need to know this since this is
  338. // a monolithic driver. We can do controller specific stuff
  339. // based on the type if needed.
  340. //
  341. SDBUS_CONTROLLER_TYPE ControllerType;
  342. //
  343. // Index into the device dispatch table for vendor-specific
  344. // controller functions
  345. //
  346. ULONG DeviceDispatchIndex;
  347. PDEVICE_OBJECT DeviceObject;
  348. PDRIVER_OBJECT DriverObject;
  349. PUNICODE_STRING RegistryPath;
  350. //
  351. // Kernel objects to handle Io processing
  352. //
  353. KTIMER WorkerTimer;
  354. KDPC WorkerTimeoutDpc;
  355. //
  356. // This field holds the "current work packet" so that the timeout
  357. // dpc can pass it back to the worker routine
  358. //
  359. struct _SD_WORK_PACKET *TimeoutPacket;
  360. KDPC WorkerDpc;
  361. WORKER_STATE WorkerState;
  362. KSPIN_LOCK WorkerSpinLock;
  363. LIST_ENTRY SystemWorkPacketQueue;
  364. LIST_ENTRY IoWorkPacketQueue;
  365. //
  366. // Io workitem to execute card functions at passive level
  367. //
  368. PIO_WORKITEM IoWorkItem;
  369. KEVENT CardInterruptEvent;
  370. KEVENT WorkItemExitEvent;
  371. //
  372. // Sequence number for event logging
  373. //
  374. ULONG SequenceNumber;
  375. //
  376. // Pointer to the interrupt object - if we use interrupt based
  377. // card status change detection
  378. //
  379. PKINTERRUPT SdbusInterruptObject;
  380. //
  381. // IsrEventStatus is the hardware state. It is accessed only at DIRQL
  382. //
  383. ULONG IsrEventStatus;
  384. //
  385. // LatchedIsrEventStatus is pulled from IsrEventStatus synchronously. It is
  386. // used by the ISR's DPC to reflect new hardware events.
  387. //
  388. ULONG LatchedIsrEventStatus;
  389. //
  390. // WorkerEventEventStatus is the set of events pending to be reflected to
  391. // the io worker engine
  392. //
  393. ULONG WorkerEventStatus;
  394. //
  395. // Keeps track of currently enabled events
  396. //
  397. ULONG CurrentlyEnabledEvents;
  398. //
  399. // These are the card events we would like to see
  400. //
  401. ULONG CardEvents;
  402. //
  403. // Power management related stuff.
  404. //
  405. //
  406. // Current power states
  407. //
  408. SYSTEM_POWER_STATE SystemPowerState;
  409. DEVICE_POWER_STATE DevicePowerState;
  410. //
  411. // Indicates device busy
  412. //
  413. ULONG PowerStateInTransition;
  414. //
  415. // Indicates how many children (pc-cards) are pending on an
  416. // IRP_MN_WAIT_WAKE
  417. //
  418. ULONG ChildWaitWakeCount;
  419. //
  420. // Device capabilities as reported by our bus driver
  421. //
  422. DEVICE_CAPABILITIES DeviceCapabilities;
  423. //
  424. // Pending wait wake Irp
  425. //
  426. PIRP WaitWakeIrp;
  427. LONG WaitWakeState;
  428. //
  429. // PCI Bus interface standard
  430. // This contains interfaces to read/write from PCI config space
  431. // of the cardbus controller, among other stuff..
  432. //
  433. BUS_INTERFACE_STANDARD PciBusInterface;
  434. //
  435. // Configuration resources for the sd controller
  436. //
  437. CM_PARTIAL_RESOURCE_DESCRIPTOR Interrupt;
  438. CM_PARTIAL_RESOURCE_DESCRIPTOR TranslatedInterrupt;
  439. //
  440. // Type of bus we are on
  441. //
  442. INTERFACE_TYPE InterfaceType;
  443. //
  444. // SD Host register base
  445. //
  446. PVOID HostRegisterBase;
  447. //
  448. // Size of the register base that has been mapped
  449. //
  450. ULONG HostRegisterSize;
  451. // Memory = 1, IO = 2
  452. UCHAR FunctionType;
  453. USHORT ArgumentReg;
  454. USHORT CmdReg;
  455. USHORT CardStatusReg;
  456. USHORT ResponseReg;
  457. USHORT InterruptMaskReg;
  458. //
  459. // These are used for debugging
  460. //
  461. USHORT cardStatus;
  462. USHORT errorStatus;
  463. //
  464. // card data which describes current card in the socket
  465. //
  466. PSD_CARD_DATA CardData;
  467. //
  468. // State of the current card in the slot
  469. //
  470. UCHAR numFunctions;
  471. BOOLEAN memFunction;
  472. ULONG RelativeAddr;
  473. SD_CID SdCid;
  474. SD_CSD SdCsd;
  475. //
  476. // Status of socket
  477. //
  478. SOCKET_STATE SocketState;
  479. //
  480. // Head of the list of child pc-card PDO's hanging off this controller.
  481. // This is a linked list running through "NextPdoInFdoChain" in the pdo
  482. // extension. This list represents the devices that were enumerated by
  483. // the fdo.
  484. //
  485. PDEVICE_OBJECT PdoList;
  486. //
  487. // Keeps track of the number of PDOs which are actually
  488. // valid (not removed). This is primarily used in
  489. // enumeration of the sd controller upon an IRP_MN_QUERY_DEVICE_RELATIONS
  490. //
  491. ULONG LivePdoCount;
  492. //
  493. // Remove lock for PnP synchronization
  494. //
  495. IO_REMOVE_LOCK RemoveLock;
  496. } FDO_EXTENSION, *PFDO_EXTENSION;
  497. //
  498. // Physical Device Object's device extension information
  499. //
  500. // There is one device object for each function of an SD device
  501. //
  502. //
  503. // Flags indicating card state
  504. //
  505. #define SDBUS_PDO_GENERATES_IRQ 0x00010000
  506. #define SDBUS_PDO_DPC_CALLBACK 0x00020000
  507. #define SDBUS_PDO_CALLBACK_REQUESTED 0x00040000
  508. #define SDBUS_PDO_CALLBACK_IN_SERVICE 0x00080000
  509. #define SDBUS_PDO_EXTENSION_SIGNATURE 'PmcP'
  510. //
  511. // The PDO extension represents an instance of a single SD function on an SD card
  512. //
  513. typedef struct _PDO_EXTENSION {
  514. ULONG Signature;
  515. PDEVICE_OBJECT DeviceObject;
  516. //
  517. // Link to next pdo in the Fdo's pdo chain
  518. //
  519. PDEVICE_OBJECT NextPdoInFdoChain;
  520. //
  521. // Parent extension
  522. //
  523. PFDO_EXTENSION FdoExtension;
  524. //
  525. // Flags
  526. //
  527. ULONG Flags;
  528. //
  529. // Device ISR
  530. //
  531. PSDBUS_CALLBACK_ROUTINE CallbackRoutine;
  532. PVOID CallbackRoutineContext;
  533. //
  534. // Power declarations
  535. //
  536. DEVICE_POWER_STATE DevicePowerState;
  537. SYSTEM_POWER_STATE SystemPowerState;
  538. //
  539. // Device Capabilities
  540. //
  541. DEVICE_CAPABILITIES DeviceCapabilities;
  542. //
  543. // Pending wait wake irp
  544. //
  545. PIRP WaitWakeIrp;
  546. //
  547. // Deletion Mutex
  548. //
  549. ULONG DeletionLock;
  550. //
  551. // SD Function number
  552. //
  553. UCHAR Function;
  554. UCHAR FunctionType;
  555. } PDO_EXTENSION, *PPDO_EXTENSION;
  556. //
  557. // Struct for Database of card bus controller information
  558. // which maps the vendor id/device id to a CONTROLLER_TYPE
  559. //
  560. typedef struct _PCI_CONTROLLER_INFORMATION {
  561. USHORT VendorID;
  562. USHORT DeviceID;
  563. SDBUS_CONTROLLER_TYPE ControllerType;
  564. } PCI_CONTROLLER_INFORMATION, *PPCI_CONTROLLER_INFORMATION;
  565. //
  566. // Struct for database of generic vendor class based on vendor ID
  567. //
  568. typedef struct _PCI_VENDOR_INFORMATION {
  569. USHORT VendorID;
  570. PSD_FUNCTION_BLOCK FunctionBlock;
  571. } PCI_VENDOR_INFORMATION, *PPCI_VENDOR_INFORMATION;
  572. // The pccard device id prefix
  573. #define SDBUS_ID_STRING "SDBUS"
  574. // String to be substituted if manufacturer name is not known
  575. #define SDBUS_UNKNOWN_MANUFACTURER_STRING "UNKNOWN_MANUFACTURER"
  576. // Max length of device id
  577. #define SDBUS_MAXIMUM_DEVICE_ID_LENGTH 128
  578. // Sdbus controller device name
  579. #define SDBUS_DEVICE_NAME "\\Device\\Sdbus"
  580. // Sdbus controller device symbolic link name
  581. #define SDBUS_LINK_NAME "\\DosDevices\\Sdbus"
  582. #define SDBUS_ENABLE_DELAY 10000
  583. //
  584. // problems observed on tecra 750 and satellite 300, with dec-chipset cb nic
  585. //
  586. #define SDBUS_DEFAULT_CONTROLLER_POWERUP_DELAY 250000 // 250 msec
  587. //
  588. // Amount of time to wait after an event interrupt was asserted on the controller
  589. //
  590. #define SDBUS_DEFAULT_EVENT_DPC_DELAY 400000 // 400 msec
  591. //
  592. // Macros for manipulating PDO's flags
  593. //
  594. #define IsDeviceFlagSet(deviceExtension, Flag) (((deviceExtension)->Flags & (Flag))?TRUE:FALSE)
  595. #define SetDeviceFlag(deviceExtension, Flag) ((deviceExtension)->Flags |= (Flag))
  596. #define ResetDeviceFlag(deviceExtension,Flag) ((deviceExtension)->Flags &= ~(Flag))
  597. #define IsFdoExtension(fdoExtension) (fdoExtension->Signature == SDBUS_FDO_EXTENSION_SIGNATURE)
  598. #define IsPdoExtension(pdoExtension) (pdoExtension->Signature == SDBUS_PDO_EXTENSION_SIGNATURE)
  599. #define MarkDeviceStarted(deviceExtension) ((deviceExtension)->Flags |= SDBUS_DEVICE_STARTED)
  600. #define MarkDeviceNotStarted(deviceExtension) ((deviceExtension)->Flags &= ~SDBUS_DEVICE_STARTED)
  601. #define MarkDeviceDeleted(deviceExtension) ((deviceExtension)->Flags |= SDBUS_DEVICE_DELETED);
  602. #define MarkDevicePhysicallyRemoved(deviceExtension) \
  603. ((deviceExtension)->Flags |= SDBUS_DEVICE_PHYSICALLY_REMOVED)
  604. #define MarkDevicePhysicallyInserted(deviceExtension) \
  605. ((deviceExtension)->Flags &= ~SDBUS_DEVICE_PHYSICALLY_REMOVED)
  606. #define MarkDeviceLogicallyRemoved(deviceExtension) \
  607. ((deviceExtension)->Flags |= SDBUS_DEVICE_LOGICALLY_REMOVED)
  608. #define MarkDeviceLogicallyInserted(deviceExtension) \
  609. ((deviceExtension)->Flags &= ~SDBUS_DEVICE_LOGICALLY_REMOVED)
  610. #define MarkDeviceMultifunction(deviceExtension) \
  611. ((deviceExtension)->Flags |= SDBUS_DEVICE_MULTIFUNCTION)
  612. #define IsDeviceStarted(deviceExtension) (((deviceExtension)->Flags & SDBUS_DEVICE_STARTED)?TRUE:FALSE)
  613. #define IsDevicePhysicallyRemoved(deviceExtension) \
  614. (((deviceExtension)->Flags & SDBUS_DEVICE_PHYSICALLY_REMOVED)?TRUE:FALSE)
  615. #define IsDeviceLogicallyRemoved(deviceExtension) \
  616. (((deviceExtension)->Flags & SDBUS_DEVICE_LOGICALLY_REMOVED)?TRUE:FALSE)
  617. #define IsDeviceDeleted(deviceExtension) (((deviceExtension)->Flags & SDBUS_DEVICE_DELETED)?TRUE:FALSE)
  618. #define IsDeviceMultifunction(deviceExtension) (((deviceExtension)->Flags & SDBUS_DEVICE_MULTIFUNCTION)?TRUE:FALSE)
  619. //
  620. // NT definitions
  621. //
  622. #ifdef POOL_TAGGING
  623. #undef ExAllocatePool
  624. #define ExAllocatePool(a,b) ExAllocatePoolWithTag(a,b,'ubdS')
  625. #endif
  626. #define IO_RESOURCE_LIST_VERSION 0x1
  627. #define IO_RESOURCE_LIST_REVISION 0x1
  628. #define IRP_MN_PNP_MAXIMUM_FUNCTION IRP_MN_QUERY_LEGACY_BUS_INFORMATION
  629. //
  630. // Some useful macros
  631. //
  632. #define MIN(x,y) ((x) > (y) ? (y) : (x)) // return minimum among x & y
  633. #define MAX(x,y) ((x) > (y) ? (x) : (y)) // return maximum among x & y
  634. //
  635. // BOOLEAN
  636. // IS_PDO (IN PDEVICE_OBJECT DeviceObject);
  637. //
  638. #define IS_PDO(DeviceObject) (((DeviceObject)->Flags & DO_BUS_ENUMERATED_DEVICE)?TRUE:FALSE)
  639. //
  640. // Io extension macro to just pass on the Irp to a lower driver
  641. //
  642. //
  643. // VOID
  644. // SdbusSkipCallLowerDriver(OUT NTSTATUS Status,
  645. // IN PDEVICE_OBJECT DeviceObject,
  646. // IN PIRP Irp);
  647. //
  648. #define SdbusSkipCallLowerDriver(Status, DeviceObject, Irp) { \
  649. IoSkipCurrentIrpStackLocation(Irp); \
  650. Status = IoCallDriver(DeviceObject,Irp);}
  651. //
  652. // VOID
  653. // SdbusCopyCallLowerDriver(OUT NTSTATUS Status,
  654. // IN PDEVICE_OBJECT DeviceObject,
  655. // IN PIRP Irp);
  656. //
  657. #define SdbusCopyCallLowerDriver(Status, DeviceObject, Irp) { \
  658. IoCopyCurrentIrpStackLocationToNext(Irp); \
  659. Status = IoCallDriver(DeviceObject,Irp); }
  660. // BOOLEAN
  661. // CompareGuid(
  662. // IN LPGUID guid1,
  663. // IN LPGUID guid2
  664. // );
  665. #define CompareGuid(g1, g2) ((g1) == (g2) ?TRUE: \
  666. RtlCompareMemory((g1), \
  667. (g2), \
  668. sizeof(GUID)) \
  669. == sizeof(GUID) \
  670. )
  671. //
  672. // BOOLEAN
  673. // ValidateController(IN FDO_EXTENSION fdoExtension)
  674. //
  675. // Bit of paranoia code. Make sure that the cardbus controller's registers
  676. // are still visible.
  677. //
  678. #define ValidateController(fdoExtension) TRUE
  679. //
  680. // Structure which defines what global parameters are read from the registry
  681. //
  682. typedef struct _GLOBAL_REGISTRY_INFORMATION {
  683. PWSTR Name;
  684. PULONG pValue;
  685. ULONG Default;
  686. } GLOBAL_REGISTRY_INFORMATION, *PGLOBAL_REGISTRY_INFORMATION;
  687. #endif //_SDBUS_H_