다음을 통해 공유


SpbCx 개체 핸들

이 항목에서는 SPB 프레임워크 확장(SpbCx) 라이브러리에 대해 정의된 개체 핸들에 대해 설명합니다.

또한 SerCx2 DDI는 KMDF(Kernel-Mode Driver Framework)에서 정의한 두 가지 제네릭 개체 핸들 형식인 WDFDEVICE 및 WDFREQUEST를 사용합니다. 프레임워크 핸들 형식에 대한 자세한 내용은 프레임워크 개체 요약을 참조하세요.

이 항목에서는 다음 개체 핸들에 대해 설명합니다.

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와의 상호 운용성

SerCx2 드라이버 지원 메서드SpbCx에서 정의한 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.