scsi_peripheral_api.h
Overview
Declares the SCSI Peripheral DDK APIs used by the host to access the SCSI device.
File to include: <scsi_peripheral/scsi_peripheral_api.h>
Library: libscsi.z.so
System capability: SystemCapability.Driver.SCSI.Extension
Since: 18
Related module: ScsiPeripheralDDK
Summary
Function
Function Description
OH_ScsiPeripheral_Init()
int32_t OH_ScsiPeripheral_Init(void)
Description
Initializes the SCSI Peripheral DDK.
Required permissions: ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL
Since: 18
Returns
| Type | Description |
|---|---|
| int32_t | SCSIPERIPHERAL_DDK_SUCCESS: The API call is successful. SCSIPERIPHERAL_DDK_NO_PERM: The permission verification fails. SCSIPERIPHERAL_DDK_INIT_ERROR: The DDK initialization fails. SCSIPERIPHERAL_DDK_SERVICE_ERROR: The communication with the DDK service fails. |
OH_ScsiPeripheral_Release()
int32_t OH_ScsiPeripheral_Release(void)
Description
Releases the SCSI Peripheral DDK.
Required permissions: ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL
Since: 18
Returns
| Type | Description |
|---|---|
| int32_t | SCSIPERIPHERAL_DDK_SUCCESS: The API call is successful. SCSIPERIPHERAL_DDK_NO_PERM: The permission verification fails. SCSIPERIPHERAL_DDK_INIT_ERROR: The DDK is not initialized. SCSIPERIPHERAL_DDK_SERVICE_ERROR: The communication with the DDK service fails. |
OH_ScsiPeripheral_Open()
int32_t OH_ScsiPeripheral_Open(uint64_t deviceId, uint8_t interfaceIndex, ScsiPeripheral_Device **dev)
Description
Opens the SCSI device specified by deviceId and interfaceIndex. The deviceId can be obtained by shifting the bus number of the USB device left by 32 bits and then performing a bitwise OR operation with the device address. interfaceIndex refers to the index of the USB interface to be opened.
Required permissions: ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL
Since: 18
Parameters
| Name | Description |
|---|---|
| uint64_t deviceId | Device ID. |
| uint8_t interfaceIndex | Interface index for the API of the SCSI device. |
| ScsiPeripheral_Device **dev | Device handle. For details, see ScsiPeripheral_Device. |
Returns
| Type | Description |
|---|---|
| int32_t | SCSIPERIPHERAL_DDK_SUCCESS: The API call is successful. SCSIPERIPHERAL_DDK_NO_PERM: The permission verification fails. SCSIPERIPHERAL_DDK_INIT_ERROR: The DDK is not initialized. SCSIPERIPHERAL_DDK_INVALID_PARAMETER: The input dev or *dev is null. SCSIPERIPHERAL_DDK_SERVICE_ERROR: The communication with the DDK service fails. SCSIPERIPHERAL_DDK_MEMORY_ERROR: The memory operation fails. SCSIPERIPHERAL_DDK_IO_ERROR: An I/O error occurs. SCSIPERIPHERAL_DDK_DEVICE_NOT_FOUND: No device is found based on the specified deviceId and interfaceIndex. SCSIPERIPHERAL_DDK_INVALID_OPERATION: The operation is not supported. |
OH_ScsiPeripheral_Close()
int32_t OH_ScsiPeripheral_Close(ScsiPeripheral_Device **dev)
Description
Closes the SCSI device.
Required permissions: ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL
Since: 18
Parameters
| Name | Description |
|---|---|
| ScsiPeripheral_Device **dev | Device handle. For details, see ScsiPeripheral_Device. |
Returns
| Type | Description |
|---|---|
| int32_t | SCSIPERIPHERAL_DDK_SUCCESS: The API call is successful. SCSIPERIPHERAL_DDK_NO_PERM: The permission verification fails. SCSIPERIPHERAL_DDK_INIT_ERROR: The DDK is not initialized. SCSIPERIPHERAL_DDK_INVALID_PARAMETER: The input dev or *dev is null. SCSIPERIPHERAL_DDK_SERVICE_ERROR: The communication with the DDK service fails. SCSIPERIPHERAL_DDK_IO_ERROR: An I/O error occurs. |
OH_ScsiPeripheral_TestUnitReady()
int32_t OH_ScsiPeripheral_TestUnitReady(ScsiPeripheral_Device *dev, ScsiPeripheral_TestUnitReadyRequest *request,ScsiPeripheral_Response *response)
Description
Checks whether the logical unit is ready.
Required permissions: ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL
Since: 18
Parameters
| Name | Description |
|---|---|
| ScsiPeripheral_Device *dev | Device handle. For details, see ScsiPeripheral_Device. |
| ScsiPeripheral_TestUnitReadyRequest *request | Request of the test unit ready command. For details, see ScsiPeripheral_TestUnitReadyRequest. |
| ScsiPeripheral_Response *response | Response returned by the test unit ready command. For details, see ScsiPeripheral_Response. |
Returns
| Type | Description |
|---|---|
| int32_t | SCSIPERIPHERAL_DDK_SUCCESS: The API call is successful. SCSIPERIPHERAL_DDK_NO_PERM: The permission verification fails. SCSIPERIPHERAL_DDK_INIT_ERROR: The DDK is not initialized. SCSIPERIPHERAL_DDK_INVALID_PARAMETER: The input dev, request, or response is null. SCSIPERIPHERAL_DDK_SERVICE_ERROR: The communication with the DDK service fails. SCSIPERIPHERAL_DDK_MEMORY_ERROR: The memory operation fails. SCSIPERIPHERAL_DDK_IO_ERROR: An I/O error occurs. SCSIPERIPHERAL_DDK_TIMEOUT: The transmission times out. SCSIPERIPHERAL_DDK_INVALID_OPERATION: The operation is not supported. |
OH_ScsiPeripheral_Inquiry()
int32_t OH_ScsiPeripheral_Inquiry(ScsiPeripheral_Device *dev, ScsiPeripheral_InquiryRequest *request,ScsiPeripheral_InquiryInfo *inquiryInfo, ScsiPeripheral_Response *response)
Description
Queries basic information about the SCSI device.
Required permissions: ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL
Since: 18
Parameters
| Name | Description |
|---|---|
| ScsiPeripheral_Device *dev | Device handle. For details, see ScsiPeripheral_Device. |
| ScsiPeripheral_InquiryRequest *request | Request of the inquiry command. For details, see ScsiPeripheral_InquiryRequest. |
| ScsiPeripheral_InquiryInfo *inquiryInfo | Query result returned by the inquiry command. For details, see ScsiPeripheral_InquiryInfo. |
| ScsiPeripheral_Response *response | Raw response returned by the inquiry command. For details, see ScsiPeripheral_Response. |
Returns
| Type | Description |
|---|---|
| int32_t | SCSIPERIPHERAL_DDK_SUCCESS: The API call is successful. SCSIPERIPHERAL_DDK_NO_PERM: The permission verification fails. SCSIPERIPHERAL_DDK_INIT_ERROR: The DDK is not initialized. SCSIPERIPHERAL_DDK_INVALID_PARAMETER: The input dev, request, inquiryInfo, inquiryInfo->data, or response is null. SCSIPERIPHERAL_DDK_SERVICE_ERROR: The communication with the DDK service fails. SCSIPERIPHERAL_DDK_MEMORY_ERROR: The memory operation fails. SCSIPERIPHERAL_DDK_IO_ERROR: An I/O error occurs. SCSIPERIPHERAL_DDK_TIMEOUT: The transmission times out. SCSIPERIPHERAL_DDK_INVALID_OPERATION: The operation is not supported. |
OH_ScsiPeripheral_ReadCapacity10()
int32_t OH_ScsiPeripheral_ReadCapacity10(ScsiPeripheral_Device *dev, ScsiPeripheral_ReadCapacityRequest *request,ScsiPeripheral_CapacityInfo *capacityInfo, ScsiPeripheral_Response *response)
Description
Obtains the capacity information about the SCSI device.
Required permissions: ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL
Since: 18
Parameters
| Name | Description |
|---|---|
| ScsiPeripheral_Device *dev | Device handle. For details, see ScsiPeripheral_Device. |
| ScsiPeripheral_ReadCapacityRequest *request | Request of the read capacity command. For details, see ScsiPeripheral_ReadCapacityRequest. |
| ScsiPeripheral_CapacityInfo *capacityInfo | Capacity information returned by the read capacity command. For details, see ScsiPeripheral_CapacityInfo. |
| ScsiPeripheral_Response *response | Original response returned by the read capacity command. For details, see ScsiPeripheral_Response. |
Returns
| Type | Description |
|---|---|
| int32_t | SCSIPERIPHERAL_DDK_SUCCESS: The API call is successful. SCSIPERIPHERAL_DDK_NO_PERM: The permission verification fails. SCSIPERIPHERAL_DDK_INIT_ERROR: The DDK is not initialized. SCSIPERIPHERAL_DDK_INVALID_PARAMETER: The input dev, request, capacityInfo, or response is null. SCSIPERIPHERAL_DDK_SERVICE_ERROR: The communication with the DDK service fails. SCSIPERIPHERAL_DDK_MEMORY_ERROR: The memory operation fails. SCSIPERIPHERAL_DDK_IO_ERROR: An I/O error occurs. SCSIPERIPHERAL_DDK_TIMEOUT: The transmission times out. SCSIPERIPHERAL_DDK_INVALID_OPERATION: The operation is not supported. |
OH_ScsiPeripheral_RequestSense()
int32_t OH_ScsiPeripheral_RequestSense(ScsiPeripheral_Device *dev, ScsiPeripheral_RequestSenseRequest *request,ScsiPeripheral_Response *response)
Description
Obtains sense data, that is, information returned by the SCSI device to the host to report the device status, error information, and diagnosis information.
Required permissions: ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL
Since: 18
Parameters
| Name | Description |
|---|---|
| ScsiPeripheral_Device *dev | Device handle. For details, see ScsiPeripheral_Device. |
| ScsiPeripheral_RequestSenseRequest *request | Request of the Request Sense command. For details, see ScsiPeripheral_RequestSenseRequest. |
| ScsiPeripheral_Response *response | Response returned by the Request Sense command. For details, see ScsiPeripheral_Response. |
Returns
| Type | Description |
|---|---|
| int32_t | SCSIPERIPHERAL_DDK_SUCCESS: The API call is successful. SCSIPERIPHERAL_DDK_NO_PERM: The permission verification fails. SCSIPERIPHERAL_DDK_INIT_ERROR: The DDK is not initialized. SCSIPERIPHERAL_DDK_INVALID_PARAMETER: The input dev, request, or response is null. SCSIPERIPHERAL_DDK_SERVICE_ERROR: The communication with the DDK service fails. SCSIPERIPHERAL_DDK_MEMORY_ERROR: The memory operation fails. SCSIPERIPHERAL_DDK_IO_ERROR: An I/O error occurs. SCSIPERIPHERAL_DDK_TIMEOUT: The transmission times out. SCSIPERIPHERAL_DDK_INVALID_OPERATION: The operation is not supported. |
OH_ScsiPeripheral_Read10()
int32_t OH_ScsiPeripheral_Read10(ScsiPeripheral_Device *dev, ScsiPeripheral_IORequest *request,ScsiPeripheral_Response *response)
Description
Reads data from the specified logical block(s).
Required permissions: ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL
Since: 18
Parameters
| Name | Description |
|---|---|
| ScsiPeripheral_Device *dev | Device handle. For details, see ScsiPeripheral_Device. |
| ScsiPeripheral_IORequest *request | Request of the read command. For details, see ScsiPeripheral_IORequest. |
| ScsiPeripheral_Response *response | Response returned by the read command. For details, see ScsiPeripheral_Response. |
Returns
| Type | Description |
|---|---|
| int32_t | SCSIPERIPHERAL_DDK_SUCCESS: The API call is successful. SCSIPERIPHERAL_DDK_NO_PERM: The permission verification fails. SCSIPERIPHERAL_DDK_INIT_ERROR: The DDK is not initialized. SCSIPERIPHERAL_DDK_INVALID_PARAMETER: The input dev, request, request->data, or response is null. SCSIPERIPHERAL_DDK_SERVICE_ERROR: The communication with the DDK service fails. SCSIPERIPHERAL_DDK_MEMORY_ERROR: The memory operation fails. SCSIPERIPHERAL_DDK_IO_ERROR: An I/O error occurs. SCSIPERIPHERAL_DDK_TIMEOUT: The transmission times out. SCSIPERIPHERAL_DDK_INVALID_OPERATION: The operation is not supported. |
OH_ScsiPeripheral_Write10()
int32_t OH_ScsiPeripheral_Write10(ScsiPeripheral_Device *dev, ScsiPeripheral_IORequest *request,ScsiPeripheral_Response *response)
Description
Writes data to the specified logical block(s) of a device.
Required permissions: ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL
Since: 18
Parameters
| Name | Description |
|---|---|
| ScsiPeripheral_Device *dev | Device handle. For details, see ScsiPeripheral_Device. |
| ScsiPeripheral_IORequest *request | Request of the write command. For details, see ScsiPeripheral_IORequest. |
| ScsiPeripheral_Response *response | Response returned by the write command. For details, see ScsiPeripheral_Response. |
Returns
| Type | Description |
|---|---|
| int32_t | SCSIPERIPHERAL_DDK_SUCCESS: The API call is successful. SCSIPERIPHERAL_DDK_NO_PERM: The permission verification fails. SCSIPERIPHERAL_DDK_INIT_ERROR: The DDK is not initialized. SCSIPERIPHERAL_DDK_INVALID_PARAMETER: The input dev, request, request->data, or response is null. SCSIPERIPHERAL_DDK_SERVICE_ERROR: The communication with the DDK service fails. SCSIPERIPHERAL_DDK_MEMORY_ERROR: The memory operation fails. SCSIPERIPHERAL_DDK_IO_ERROR: An I/O error occurs. SCSIPERIPHERAL_DDK_TIMEOUT: The transmission times out. SCSIPERIPHERAL_DDK_INVALID_OPERATION: The operation is not supported. |
OH_ScsiPeripheral_Verify10()
int32_t OH_ScsiPeripheral_Verify10(ScsiPeripheral_Device *dev, ScsiPeripheral_VerifyRequest *request,ScsiPeripheral_Response *response)
Description
Verifies the specified logical block(s).
Required permissions: ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL
Since: 18
Parameters
| Name | Description |
|---|---|
| ScsiPeripheral_Device *dev | Device handle. For details, see ScsiPeripheral_Device. |
| ScsiPeripheral_VerifyRequest *request | Request of the verify command. For details, see ScsiPeripheral_VerifyRequest. |
| ScsiPeripheral_Response *response | Response returned by the verify command. For details, see ScsiPeripheral_Response. |
Returns
| Type | Description |
|---|---|
| int32_t | SCSIPERIPHERAL_DDK_SUCCESS: The API call is successful. SCSIPERIPHERAL_DDK_NO_PERM: The permission verification fails. SCSIPERIPHERAL_DDK_INIT_ERROR: The DDK is not initialized. SCSIPERIPHERAL_DDK_INVALID_PARAMETER: The input dev, request, or response is null. SCSIPERIPHERAL_DDK_SERVICE_ERROR: The communication with the DDK service fails. SCSIPERIPHERAL_DDK_MEMORY_ERROR: The memory operation fails. SCSIPERIPHERAL_DDK_IO_ERROR: An I/O error occurs. SCSIPERIPHERAL_DDK_TIMEOUT: The transmission times out. SCSIPERIPHERAL_DDK_INVALID_OPERATION: The operation is not supported. |
OH_ScsiPeripheral_SendRequestByCdb()
int32_t OH_ScsiPeripheral_SendRequestByCdb(ScsiPeripheral_Device *dev, ScsiPeripheral_Request *request,ScsiPeripheral_Response *response)
Description
Sends SCSI commands in CDB mode.
Required permissions: ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL
Since: 18
Parameters
| Name | Description |
|---|---|
| ScsiPeripheral_Device *dev | Device handle. For details, see ScsiPeripheral_Device. |
| ScsiPeripheral_Request *request | Request. For details, see ScsiPeripheral_Request. |
| ScsiPeripheral_Response *response | Response. For details, see ScsiPeripheral_Response. |
Returns
| Type | Description |
|---|---|
| int32_t | SCSIPERIPHERAL_DDK_SUCCESS: The API call is successful. SCSIPERIPHERAL_DDK_NO_PERM: The permission verification fails. SCSIPERIPHERAL_DDK_INIT_ERROR: The DDK is not initialized. SCSIPERIPHERAL_DDK_INVALID_PARAMETER: The input dev, request, request->data, or response is null, or request->cdbLength is 0. SCSIPERIPHERAL_DDK_SERVICE_ERROR: The communication with the DDK service fails. SCSIPERIPHERAL_DDK_MEMORY_ERROR: The memory operation fails. SCSIPERIPHERAL_DDK_IO_ERROR: An I/O error occurs. SCSIPERIPHERAL_DDK_TIMEOUT: The transmission times out. SCSIPERIPHERAL_DDK_INVALID_OPERATION: The operation is not supported. |
OH_ScsiPeripheral_CreateDeviceMemMap()
int32_t OH_ScsiPeripheral_CreateDeviceMemMap(ScsiPeripheral_Device *dev, size_t size,ScsiPeripheral_DeviceMemMap **devMmap)
Description
Creates a buffer. To avoid resource leakage, use OH_ScsiPeripheral_DestroyDeviceMemMap to destroy a buffer after use.
Since: 18
Parameters
| Name | Description |
|---|---|
| ScsiPeripheral_Device *dev | Device handle. For details, see ScsiPeripheral_Device. |
| size_t size | Buffer size. |
| ScsiPeripheral_DeviceMemMap **devMmap | Device memory mapping used to return the created buffer to the caller. For details, see ScsiPeripheral_DeviceMemMap. |
Returns
| Type | Description |
|---|---|
| int32_t | SCSIPERIPHERAL_DDK_SUCCESS: The API call is successful. SCSIPERIPHERAL_DDK_INVALID_PARAMETER: The input dev, devMmap, or *devMmap is null. SCSIPERIPHERAL_DDK_MEMORY_ERROR: The memory operation fails. |
OH_ScsiPeripheral_DestroyDeviceMemMap()
int32_t OH_ScsiPeripheral_DestroyDeviceMemMap(ScsiPeripheral_DeviceMemMap *devMmap)
Description
Destroys a buffer. To prevent resource leakage, destroy a buffer in time after use.
Since: 18
Parameters
| Name | Description |
|---|---|
| ScsiPeripheral_DeviceMemMap *devMmap | Buffer to be destroyed, which is created by calling OH_ScsiPeripheral_CreateDeviceMemMap. For details, see ScsiPeripheral_DeviceMemMap. |
Returns
| Type | Description |
|---|---|
| int32_t | SCSIPERIPHERAL_DDK_SUCCESS: The API call is successful. SCSIPERIPHERAL_DDK_INVALID_PARAMETER: The input devMmap is null. SCSIPERIPHERAL_DDK_MEMORY_ERROR: The memory operation fails. |
OH_ScsiPeripheral_ParseBasicSenseInfo()
int32_t OH_ScsiPeripheral_ParseBasicSenseInfo(uint8_t *senseData, uint8_t senseDataLen,ScsiPeripheral_BasicSenseInfo *senseInfo)
Description
Parses basic sense data, including the Information, Command specific information, and Sense key specific fields.
Since: 18
Parameters
| Name | Description |
|---|---|
| uint8_t *senseData | Sense data to be parsed. |
| uint8_t senseDataLen | Length of sense data. |
| ScsiPeripheral_BasicSenseInfo *senseInfo | Basic sense data after parsing. For details, see ScsiPeripheral_BasicSenseInfo. |
Returns
| Type | Description |
|---|---|
| int32_t | SCSIPERIPHERAL_DDK_SUCCESS: The API call is successful. SCSIPERIPHERAL_DDK_INVALID_PARAMETER: The input senseData is not a descriptor or is not of the fixed format, or senseDataLen is smaller than SCSIPERIPHERAL_MIN_DESCRIPTOR_FORMAT_SENSE or SCSIPERIPHERAL_MIN_FIXED_FORMAT_SENSE. |
你可能感兴趣的鸿蒙文章
openharmony 鸿蒙 capi-scsiperipheralddk-scsiperipheral-request
openharmony 鸿蒙 capi-usbddk-usbconfigdescriptor
openharmony 鸿蒙 capi-hidddk-hid-absaxesarray
openharmony 鸿蒙 capi-scsiperipheralddk-scsiperipheral-response
openharmony 鸿蒙 capi-hidddk-hid-relaxesarray
openharmony 鸿蒙 js-apis-driver-deviceManager