本主題說明針對 SPB 架構延伸模組 (SpbCx) 程式庫定義的物件控制碼。
此外,SerCx2 DDI 會使用兩種泛型物件句柄類型 WDFDEVICE 和 WDFREQUEST,這些類型是由 Kernel-Mode 驅動程式架構 (KMDF) 所定義。 如需架構控制碼類型的詳細資訊,請參閱 架構物件摘要。
本主題說明下列物件控點:
Header: Spbcx.h
SPBREQUEST 物件控制碼
An SPBREQUEST object handle represents an I/O request that is issued to a target device on the bus.
DECLARE_HANDLE(SPBREQUEST)
The SPBREQUEST object class is derived from the WDFREQUEST object class, which represents an I/O request that is dispatched by the I/O manager. Thus, WdfRequestXxx methods that take WDFREQUEST handle values as parameters accept SPBREQUEST handle values as valid parameter values. 如需這些方法的詳細資訊,請參閱 架構要求物件。
However, some SpbCx methods and callback functions specifically require SPBREQUEST handles as parameters. For such a parameter, substituting a WDFREQUEST handle that is not also an SPBREQUEST handle is an error.
For example, the SpbRequestGetTransferParameters method takes an SPBREQUEST handle as a parameter. To supply, for this parameter, a WDFREQUEST handle that is not also an SPBREQUEST handle is an error. The reason for this requirement is that an SPBREQUEST object must store additional, SPB-specific state information to support I/O transfer sequences. The WDFREQUEST base object class does not provide this support.
During device initialization, your SPB controller driver can assign a per-request context to an SPBREQUEST handle by calling the SpbControllerSetRequestAttributes method.
SPBTARGET 物件句柄
An SPBTARGET object handle identifies a logical connection from a client (peripheral driver) to an addressable port or peripheral device on the bus.
DECLARE_HANDLE(SPBTARGET)
For an I2C bus, an SPBTARGET handle corresponds to a specific device address.
For an SPI bus, an SPBTARGET handle corresponds to a device-select line.
Typically, an SPBTARGET object exists from the start of the EvtSpbTargetConnect event callback through the end of the corresponding EvtSpbTargetDisconnect event callback. However, the lifetime of the SPBTARGET object might extend beyond the second callback if the SPB controller driver takes an additional reference on the SPBTARGET object to prevent the object from unexpectedly disappearing during the processing of an I/O request for the target.
SPB 控制器驅動程式會針對 SPB 控制器裝置執行所有硬體特定的作業。 When a client sends an IRP_MJ_CREATE request to open a connection to a target on the bus, the SPB framework extension (SpbCx), which manages the I/O queue for the controller driver, passes this request to the SPB controller driver by calling this driver's EvtSpbTargetConnect callback function. This Target parameter of this function is an SPBTARGET handle. 函式可以使用此控制碼,從 PnP 管理員擷取連線特定的資源資訊 (例如,裝置位址) 。 When the client sends an IRP_MJ_CLOSE request to close the connection, SpbCx passes this request to the SPB controller driver's EvtSpbTargetDisconnect callback function, which releases these resources.
Exclusive-Mode Access
用戶端具有存取目標裝置的獨佔模式。 一次只能有一個用戶端連線到特定目標裝置。 SpbCx ensures that only one SPBTARGET handle exists for a target device address on the bus. 這是必要的限制,因為SpbCx不支援由兩個或多個客戶端傳送至目標裝置的 I/O 要求交錯。 如果目標裝置必須能夠接收來自數個用戶端的要求,則此裝置需要與控制器驅動程式分開的 MUX 驅動程式,才能正確交錯要求的作業。
與 KMDF 的互通性
SpbCx 所定義的 SerCx2 驅動程式支援方法 和 SpbCx 事件回呼函式 會使用 SPBTARGET 控制碼來代表匯流排上目標裝置的開啟連線。 However, a controller driver must typically call KMDF methods that require WDFFILEOBJECT handles, instead of SPBTARGET handles, to designate target devices.
An SPBTARGET object is similar to a WDFFILEOBJECT object. However, an SPBTARGET object contains additional, SPB-specific information. For example, during the processing of an IOCTL_SPB_EXECUTE_SEQUENCE I/O control request, the SPBTARGET object for the target device tracks the state of the transfers in the I/O transfer sequence.
To obtain the WDFFILEOBJECT handle to a target, the SPB controller driver calls the SpbTargetGetFileObject method. This method accepts, as an input parameter, an SPBTARGET handle to an open target device, and returns the corresponding WDFFILEOBJECT handle to this target.
In accordance with KMDF conventions, the SPB controller driver can attach its own context to the SPBTARGET object for a target device, and this context can include associated EvtCleanupCallback and EvtDestroyCallback callback functions. SPB 控制器驅動程式會使用此內容來追蹤控制器驅動程式和目標裝置特有的資訊。 In addition, this driver can create child objects of the SPBTARGET object, such as timers, DPCs, or, if needed, I/O requests and I/O queues.