openharmony 鸿蒙 capi-scsi-peripheral-api-h

2026-08-25 浏览 (1)

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

NameDescription
int32_t OH_ScsiPeripheral_Init(void)Initializes the SCSI Peripheral DDK.
int32_t OH_ScsiPeripheral_Release(void)Releases the SCSI Peripheral DDK.
int32_t OH_ScsiPeripheral_Open(uint64_t deviceId, uint8_t interfaceIndex, ScsiPeripheral_Device **dev)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.
int32_t OH_ScsiPeripheral_Close(ScsiPeripheral_Device **dev)Closes the SCSI device.
int32_t OH_ScsiPeripheral_TestUnitReady(ScsiPeripheral_Device *dev, ScsiPeripheral_TestUnitReadyRequest *request,ScsiPeripheral_Response *response)Checks whether the logical unit is ready.
int32_t OH_ScsiPeripheral_Inquiry(ScsiPeripheral_Device *dev, ScsiPeripheral_InquiryRequest *request,ScsiPeripheral_InquiryInfo *inquiryInfo, ScsiPeripheral_Response *response)Queries basic information about the SCSI device.
int32_t OH_ScsiPeripheral_ReadCapacity10(ScsiPeripheral_Device *dev, ScsiPeripheral_ReadCapacityRequest *request,ScsiPeripheral_CapacityInfo *capacityInfo, ScsiPeripheral_Response *response)Obtains the capacity information about the SCSI device.
int32_t OH_ScsiPeripheral_RequestSense(ScsiPeripheral_Device *dev, ScsiPeripheral_RequestSenseRequest *request,ScsiPeripheral_Response *response)Obtains sense data, that is, information returned by the SCSI device to the host to report the device status, error information, and diagnosis information.
int32_t OH_ScsiPeripheral_Read10(ScsiPeripheral_Device *dev, ScsiPeripheral_IORequest *request,ScsiPeripheral_Response *response)Reads data from the specified logical block(s).
int32_t OH_ScsiPeripheral_Write10(ScsiPeripheral_Device *dev, ScsiPeripheral_IORequest *request,ScsiPeripheral_Response *response)Writes data to the specified logical block(s) of a device.
int32_t OH_ScsiPeripheral_Verify10(ScsiPeripheral_Device *dev, ScsiPeripheral_VerifyRequest *request,ScsiPeripheral_Response *response)Verifies the specified logical block(s).
int32_t OH_ScsiPeripheral_SendRequestByCdb(ScsiPeripheral_Device *dev, ScsiPeripheral_Request *request,ScsiPeripheral_Response *response)Sends SCSI commands in CDB mode.
int32_t OH_ScsiPeripheral_CreateDeviceMemMap(ScsiPeripheral_Device *dev, size_t size,ScsiPeripheral_DeviceMemMap **devMmap)Creates a buffer. To avoid resource leakage, use OH_ScsiPeripheral_DestroyDeviceMemMap to destroy a buffer after use.
int32_t OH_ScsiPeripheral_DestroyDeviceMemMap(ScsiPeripheral_DeviceMemMap *devMmap)Destroys a buffer. To prevent resource leakage, destroy a buffer in time after use.
int32_t OH_ScsiPeripheral_ParseBasicSenseInfo(uint8_t *senseData, uint8_t senseDataLen,ScsiPeripheral_BasicSenseInfo *senseInfo)Parses basic sense data, including the Information, Command specific information, and Sense key specific fields.

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

TypeDescription
int32_tSCSIPERIPHERAL_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

TypeDescription
int32_tSCSIPERIPHERAL_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

NameDescription
uint64_t deviceIdDevice ID.
uint8_t interfaceIndexInterface index for the API of the SCSI device.
ScsiPeripheral_Device **devDevice handle. For details, see ScsiPeripheral_Device.

Returns

TypeDescription
int32_tSCSIPERIPHERAL_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

NameDescription
ScsiPeripheral_Device **devDevice handle. For details, see ScsiPeripheral_Device.

Returns

TypeDescription
int32_tSCSIPERIPHERAL_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

NameDescription
ScsiPeripheral_Device *devDevice handle. For details, see ScsiPeripheral_Device.
ScsiPeripheral_TestUnitReadyRequest *requestRequest of the test unit ready command. For details, see ScsiPeripheral_TestUnitReadyRequest.
ScsiPeripheral_Response *responseResponse returned by the test unit ready command. For details, see ScsiPeripheral_Response.

Returns

TypeDescription
int32_tSCSIPERIPHERAL_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

NameDescription
ScsiPeripheral_Device *devDevice handle. For details, see ScsiPeripheral_Device.
ScsiPeripheral_InquiryRequest *requestRequest of the inquiry command. For details, see ScsiPeripheral_InquiryRequest.
ScsiPeripheral_InquiryInfo *inquiryInfoQuery result returned by the inquiry command. For details, see ScsiPeripheral_InquiryInfo.
ScsiPeripheral_Response *responseRaw response returned by the inquiry command. For details, see ScsiPeripheral_Response.

Returns

TypeDescription
int32_tSCSIPERIPHERAL_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

NameDescription
ScsiPeripheral_Device *devDevice handle. For details, see ScsiPeripheral_Device.
ScsiPeripheral_ReadCapacityRequest *requestRequest of the read capacity command. For details, see ScsiPeripheral_ReadCapacityRequest.
ScsiPeripheral_CapacityInfo *capacityInfoCapacity information returned by the read capacity command. For details, see ScsiPeripheral_CapacityInfo.
ScsiPeripheral_Response *responseOriginal response returned by the read capacity command. For details, see ScsiPeripheral_Response.

Returns

TypeDescription
int32_tSCSIPERIPHERAL_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

NameDescription
ScsiPeripheral_Device *devDevice handle. For details, see ScsiPeripheral_Device.
ScsiPeripheral_RequestSenseRequest *requestRequest of the Request Sense command. For details, see ScsiPeripheral_RequestSenseRequest.
ScsiPeripheral_Response *responseResponse returned by the Request Sense command. For details, see ScsiPeripheral_Response.

Returns

TypeDescription
int32_tSCSIPERIPHERAL_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

NameDescription
ScsiPeripheral_Device *devDevice handle. For details, see ScsiPeripheral_Device.
ScsiPeripheral_IORequest *requestRequest of the read command. For details, see ScsiPeripheral_IORequest.
ScsiPeripheral_Response *responseResponse returned by the read command. For details, see ScsiPeripheral_Response.

Returns

TypeDescription
int32_tSCSIPERIPHERAL_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

NameDescription
ScsiPeripheral_Device *devDevice handle. For details, see ScsiPeripheral_Device.
ScsiPeripheral_IORequest *requestRequest of the write command. For details, see ScsiPeripheral_IORequest.
ScsiPeripheral_Response *responseResponse returned by the write command. For details, see ScsiPeripheral_Response.

Returns

TypeDescription
int32_tSCSIPERIPHERAL_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

NameDescription
ScsiPeripheral_Device *devDevice handle. For details, see ScsiPeripheral_Device.
ScsiPeripheral_VerifyRequest *requestRequest of the verify command. For details, see ScsiPeripheral_VerifyRequest.
ScsiPeripheral_Response *responseResponse returned by the verify command. For details, see ScsiPeripheral_Response.

Returns

TypeDescription
int32_tSCSIPERIPHERAL_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

NameDescription
ScsiPeripheral_Device *devDevice handle. For details, see ScsiPeripheral_Device.
ScsiPeripheral_Request *requestRequest. For details, see ScsiPeripheral_Request.
ScsiPeripheral_Response *responseResponse. For details, see ScsiPeripheral_Response.

Returns

TypeDescription
int32_tSCSIPERIPHERAL_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

NameDescription
ScsiPeripheral_Device *devDevice handle. For details, see ScsiPeripheral_Device.
size_t sizeBuffer size.
ScsiPeripheral_DeviceMemMap **devMmapDevice memory mapping used to return the created buffer to the caller. For details, see ScsiPeripheral_DeviceMemMap.

Returns

TypeDescription
int32_tSCSIPERIPHERAL_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

NameDescription
ScsiPeripheral_DeviceMemMap *devMmapBuffer to be destroyed, which is created by calling OH_ScsiPeripheral_CreateDeviceMemMap. For details, see ScsiPeripheral_DeviceMemMap.

Returns

TypeDescription
int32_tSCSIPERIPHERAL_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

NameDescription
uint8_t *senseDataSense data to be parsed.
uint8_t senseDataLenLength of sense data.
ScsiPeripheral_BasicSenseInfo *senseInfoBasic sense data after parsing. For details, see ScsiPeripheral_BasicSenseInfo.

Returns

TypeDescription
int32_tSCSIPERIPHERAL_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

openharmony 鸿蒙 capi-usbddk

openharmony 鸿蒙 capi-hidddk-hid-absaxesarray

openharmony 鸿蒙 capi-scsiperipheralddk-scsiperipheral-response

openharmony 鸿蒙 capi-hidddk-hid-relaxesarray

openharmony 鸿蒙 js-apis-driver-deviceManager

openharmony 鸿蒙 capi-hidddk-hid-eventtypearray

openharmony 鸿蒙 capi-baseddk

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/TD0aESdI