harmony 鸿蒙SCSI Peripheral DDK

2025-06-12 浏览 (1)

SCSI Peripheral DDK

Overview

The SCSI Peripheral DDK is a suite dedicated to SCSI device driver development at the application layer. It provides APIs for initializing the DDK, releasing the DDK, enabling and disabling devices, and reading data from and writing data to devices. It also declares the macros, enum variables, and data structures required by the SCSI Peripheral DDK APIs.

System capability: SystemCapability.Driver.SCSI.Extension

Since: 18

Summary

File

NameDescription
scsi_peripheral_api.hDeclares the SCSI Peripheral DDK APIs used by the host to access the SCSI device.
scsi_peripheral_types.hProvides the enum variables, structures, and macros used in the SCSI Peripheral DDK APIs.

Structs

NameDescription
struct  ScsiPeripheral_DeviceMemMapDevice memory mapping created by calling OH_ScsiPeripheral_CreateDeviceMemMap. The buffer that uses the device memory mapping can provide better performance.
struct  ScsiPeripheral_IORequestRead/write operation request.
struct  ScsiPeripheral_RequestRequest structure.
struct  ScsiPeripheral_ResponseResponse structure.
struct  ScsiPeripheral_TestUnitReadyRequestRequest structure of the test unit ready command.
struct  ScsiPeripheral_InquiryRequestRequest structure of the inquiry command.
struct  ScsiPeripheral_InquiryInfoSCSI inquiry data.
struct  ScsiPeripheral_ReadCapacityRequestRequest structure of the read capacity command.
struct  ScsiPeripheral_CapacityInfoSCSI read capacity.
struct  ScsiPeripheral_RequestSenseRequestRequest structure of the request sense command.
struct  ScsiPeripheral_BasicSenseInfoBasic information about the sense data.
struct  ScsiPeripheral_VerifyRequestRequest structure of the verify command.

Macros

NameDescription
SCSIPERIPHERAL_MIN_DESCRIPTOR_FORMAT_SENSE   8Minimum length of the sense data descriptor format.
SCSIPERIPHERAL_MIN_FIXED_FORMAT_SENSE   18Minimum length of the fixed format of sense data.
SCSIPERIPHERAL_MAX_CMD_DESC_BLOCK_LEN   16Maximum length of a command descriptor block (CDB).
SCSIPERIPHERAL_MAX_SENSE_DATA_LEN   252Maximum length of sense data. In the SCSI protocol, the maximum length of sense data is usually 252 bytes.
SCSIPERIPHERAL_VENDOR_ID_LEN   8Maximum length of the vendor ID.
SCSIPERIPHERAL_PRODUCT_ID_LEN   18Maximum length of the product ID.
SCSIPERIPHERAL_PRODUCT_REV_LEN   4Maximum length of the product version.

Types

NameDescription
typedef struct ScsiPeripheral_Device ScsiPeripheral_DeviceOpaque SCSI device structure.
typedef struct ScsiPeripheral_DeviceMemMap ScsiPeripheral_DeviceMemMapDevice memory mapping created by calling OH_ScsiPeripheral_CreateDeviceMemMap. The buffer that uses the device memory mapping can provide better performance.
typedef struct ScsiPeripheral_IORequest ScsiPeripheral_IORequestRead/write operation request.
typedef struct ScsiPeripheral_Request ScsiPeripheral_RequestRequest structure.
typedef struct ScsiPeripheral_Response ScsiPeripheral_ResponseResponse structure.
typedef struct ScsiPeripheral_TestUnitReadyRequest ScsiPeripheral_TestUnitReadyRequestRequest structure of the test unit ready command.
typedef struct ScsiPeripheral_InquiryRequest ScsiPeripheral_InquiryRequestRequest structure of the inquiry command.
typedef struct ScsiPeripheral_InquiryInfo ScsiPeripheral_InquiryInfoSCSI inquiry data.
typedef struct ScsiPeripheral_ReadCapacityRequest ScsiPeripheral_ReadCapacityRequestRequest structure of the read capacity command.
typedef struct ScsiPeripheral_CapacityInfo ScsiPeripheral_CapacityInfoSCSI read capacity.
typedef struct ScsiPeripheral_RequestSenseRequest ScsiPeripheral_RequestSenseRequestRequest structure of the request sense command.
typedef struct ScsiPeripheral_BasicSenseInfo ScsiPeripheral_BasicSenseInfoBasic information about the sense data.
typedef struct ScsiPeripheral_VerifyRequest ScsiPeripheral_VerifyRequestRequest structure of the verify command.

Enums

NameDescription
ScsiPeripheral_DdkErrCode {
SCSIPERIPHERAL_DDK_NO_PERM = 201, SCSIPERIPHERAL_DDK_INVALID_PARAMETER = 401, SCSIPERIPHERAL_DDK_SUCCESS = 31700000, SCSIPERIPHERAL_DDK_MEMORY_ERROR = 31700001, SCSIPERIPHERAL_DDK_INVALID_OPERATION = 31700002, SCSIPERIPHERAL_DDK_IO_ERROR = 31700003, SCSIPERIPHERAL_DDK_TIMEOUT = 31700004, SCSIPERIPHERAL_DDK_INIT_ERROR = 31700005, SCSIPERIPHERAL_DDK_SERVICE_ERROR = 31700006, SCSIPERIPHERAL_DDK_DEVICE_NOT_FOUND = 31700007
}
SCSI Peripheral DDK error codes.
ScsiPeripheral_Status {
SCSIPERIPHERAL_STATUS_GOOD = 0x00, SCSIPERIPHERAL_STATUS_CHECK_CONDITION_NEEDED = 0x02, SCSIPERIPHERAL_STATUS_CONDITION_MET = 0x04, SCSIPERIPHERAL_STATUS_BUSY = 0x08, SCSIPERIPHERAL_STATUS_RESERVATION_CONFLICT = 0x18, SCSIPERIPHERAL_STATUS_TASK_SET_FULL = 0x28, SCSIPERIPHERAL_STATUS_ACA_ACTIVE = 0x30, SCSIPERIPHERAL_STATUS_TASK_ABORTED = 0x40
}
SCSI status used for the response.

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.
int32_t OH_ScsiPeripheral_Close (ScsiPeripheral_Device **dev)Disables the SCSI device.
int32_t OH_ScsiPeripheral_TestUnitReady (ScsiPeripheral_Device *dev, ScsiPeripheral_TestUnitReadyRequest *request, ScsiPeripheral_Response *response)Checks whether the logical units are 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 a specified logical block.
int32_t OH_ScsiPeripheral_Write10 (ScsiPeripheral_Device *dev, ScsiPeripheral_IORequest *request, ScsiPeripheral_Response *response)Writes data to a specified logical block of a device.
int32_t OH_ScsiPeripheral_Verify10 (ScsiPeripheral_Device *dev, ScsiPeripheral_VerifyRequest *request, ScsiPeripheral_Response *response)Verifies a specified logical block.
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 memory leakage, use OH_ScsiPeripheral_DestroyDeviceMemMap to destroy a buffer after use.
int32_t OH_ScsiPeripheral_DestroyDeviceMemMap (ScsiPeripheral_DeviceMemMap *devMmap)Destroys a buffer. To avoid 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.

Macro Description

SCSIPERIPHERAL_MAX_CMD_DESC_BLOCK_LEN

#define SCSIPERIPHERAL_MAX_CMD_DESC_BLOCK_LEN   16

Description

Maximum length of a CDB.

Since: 18

SCSIPERIPHERAL_MAX_SENSE_DATA_LEN

#define SCSIPERIPHERAL_MAX_SENSE_DATA_LEN   252

Description

Maximum length of sense data. In the SCSI protocol, the maximum length of sense data is usually 252 bytes.

Since: 18

SCSIPERIPHERAL_MIN_DESCRIPTOR_FORMAT_SENSE

#define SCSIPERIPHERAL_MIN_DESCRIPTOR_FORMAT_SENSE   8

Description

Minimum length of the sense data descriptor format.

Since: 18

SCSIPERIPHERAL_MIN_FIXED_FORMAT_SENSE

#define SCSIPERIPHERAL_MIN_FIXED_FORMAT_SENSE   18

Description

Minimum length of the fixed format of sense data.

Since: 18

SCSIPERIPHERAL_PRODUCT_ID_LEN

#define SCSIPERIPHERAL_PRODUCT_ID_LEN   18

Description

Maximum length of the product ID.

Since: 18

SCSIPERIPHERAL_PRODUCT_REV_LEN

#define SCSIPERIPHERAL_PRODUCT_REV_LEN   4

Description

Maximum length of the product version.

Since: 18

SCSIPERIPHERAL_VENDOR_ID_LEN

#define SCSIPERIPHERAL_VENDOR_ID_LEN   8

Description

Maximum length of the vendor ID.

Since: 18

Type Description

ScsiPeripheral_BasicSenseInfo

typedef struct ScsiPeripheral_BasicSenseInfo ScsiPeripheral_BasicSenseInfo

Description

Basic information about the sense data.

Since: 18

ScsiPeripheral_CapacityInfo

typedef struct ScsiPeripheral_CapacityInfo ScsiPeripheral_CapacityInfo

Description

SCSI read capacity.

Since: 18

ScsiPeripheral_Device

typedef struct ScsiPeripheral_Device ScsiPeripheral_Device

Description

Opaque SCSI device structure.

Since: 18

ScsiPeripheral_DeviceMemMap

typedef struct ScsiPeripheral_DeviceMemMap ScsiPeripheral_DeviceMemMap

Description

Device memory mapping created by calling OH_ScsiPeripheral_CreateDeviceMemMap. The buffer that uses the device memory mapping can provide better performance.

Since: 18

ScsiPeripheral_InquiryInfo

typedef struct ScsiPeripheral_InquiryInfo ScsiPeripheral_InquiryInfo

Description

SCSI inquiry data.

Since: 18

ScsiPeripheral_InquiryRequest

typedef struct ScsiPeripheral_InquiryRequest ScsiPeripheral_InquiryRequest

Description

Request structure of the inquiry command.

Since: 18

ScsiPeripheral_IORequest

typedef struct ScsiPeripheral_IORequest ScsiPeripheral_IORequest

Description

Read/write operation request.

Since: 18

ScsiPeripheral_ReadCapacityRequest

typedef struct ScsiPeripheral_ReadCapacityRequest ScsiPeripheral_ReadCapacityRequest

Description

Request structure of the read capacity command.

Since: 18

ScsiPeripheral_Request

typedef struct ScsiPeripheral_Request ScsiPeripheral_Request

Description

Request structure.

Since: 18

ScsiPeripheral_RequestSenseRequest

typedef struct ScsiPeripheral_RequestSenseRequest ScsiPeripheral_RequestSenseRequest

Description

Request structure of the request sense command.

Since: 18

ScsiPeripheral_Response

typedef struct ScsiPeripheral_Response ScsiPeripheral_Response

Description

Response structure.

Since: 18

ScsiPeripheral_TestUnitReadyRequest

typedef struct ScsiPeripheral_TestUnitReadyRequest ScsiPeripheral_TestUnitReadyRequest

Description

Request structure of the test unit ready command.

Since: 18

ScsiPeripheral_VerifyRequest

typedef struct ScsiPeripheral_VerifyRequest ScsiPeripheral_VerifyRequest

Description

Request structure of the verify command.

Since: 18

Enum Description

ScsiPeripheral_DdkErrCode

enum ScsiPeripheral_DdkErrCode

Description

SCSI Peripheral DDK error codes.

Since: 18

ValueDescription
SCSIPERIPHERAL_DDK_NO_PERMPermission denied.
SCSIPERIPHERAL_DDK_INVALID_PARAMETERInvalid parameter.
SCSIPERIPHERAL_DDK_SUCCESSOperation succeeded.
SCSIPERIPHERAL_DDK_MEMORY_ERRORMemory-related errors, such as insufficient memory, memory data replication failure, or memory request failure.
SCSIPERIPHERAL_DDK_INVALID_OPERATIONInvalid operation.
SCSIPERIPHERAL_DDK_IO_ERRORDevice input/output operation failure.
SCSIPERIPHERAL_DDK_TIMEOUTTransfer timeout.
SCSIPERIPHERAL_DDK_INIT_ERRORDDK initialization error, or DDK uninitialized.
SCSIPERIPHERAL_DDK_SERVICE_ERRORFailed to communicate with the SCSI Peripheral DDK.
SCSIPERIPHERAL_DDK_DEVICE_NOT_FOUNDDevice not found.

ScsiPeripheral_Status

enum ScsiPeripheral_Status

Description

SCSI status used for the response.

Since: 18

ValueDescription
SCSIPERIPHERAL_STATUS_GOODNormal state.
SCSIPERIPHERAL_STATUS_CHECK_CONDITION_NEEDEDStatus check required.
SCSIPERIPHERAL_STATUS_CONDITION_METConditions met.
SCSIPERIPHERAL_STATUS_BUSYOccupying.
SCSIPERIPHERAL_STATUS_RESERVATION_CONFLICTResource reservation conflict.
SCSIPERIPHERAL_STATUS_TASK_SET_FULLTask set already full.
SCSIPERIPHERAL_STATUS_ACA_ACTIVEACA activity status.
SCSIPERIPHERAL_STATUS_TASK_ABORTEDTask aborted.

Function Description

OH_ScsiPeripheral_Close()

int32_t OH_ScsiPeripheral_Close (ScsiPeripheral_Device ** dev)

Description

Disables the SCSI device.

Since: 18

Parameters

NameDescription
devDevice handle. For details, see ScsiPeripheral_Device.

Required Permissions

ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL

Returns

  • SCSIPERIPHERAL_DDK_SUCCESS: Operation succeeded.

  • SCSIPERIPHERAL_DDK_NO_PERM: Permission verification failed.

  • SCSIPERIPHERAL_DDK_INIT_ERROR: DDK not initialized.

  • SCSIPERIPHERAL_DDK_INVALID_PARAMETER: empty dev.

  • SCSIPERIPHERAL_DDK_SERVICE_ERROR: DDK service communication error.

  • SCSIPERIPHERAL_DDK_IO_ERROR: DDK I/O error.

OH_ScsiPeripheral_CreateDeviceMemMap()

int32_t OH_ScsiPeripheral_CreateDeviceMemMap (ScsiPeripheral_Device * dev, size_t size, ScsiPeripheral_DeviceMemMap ** devMmap )

Description

Creates a buffer. To avoid memory leakage, use OH_ScsiPeripheral_DestroyDeviceMemMap to destroy a buffer after use.

Since: 18

Parameters

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

Required Permissions

ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL

Returns

  • SCSIPERIPHERAL_DDK_SUCCESS: Operation succeeded.

  • SCSIPERIPHERAL_DDK_INVALID_PARAMETER: Empty dev or devMmap.

  • SCSIPERIPHERAL_DDK_MEMORY_ERROR: Memory operation error.

OH_ScsiPeripheral_DestroyDeviceMemMap()

int32_t OH_ScsiPeripheral_DestroyDeviceMemMap (ScsiPeripheral_DeviceMemMap * devMmap)

Description

Destroys a buffer. To avoid resource leakage, destroy a buffer in time after use.

Since: 18

Parameters

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

Required Permissions

ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL

Returns

  • SCSIPERIPHERAL_DDK_SUCCESS: Operation succeeded.

  • SCSIPERIPHERAL_DDK_INVALID_PARAMETER: Empty devMmap.

  • SCSIPERIPHERAL_DDK_MEMORY_ERROR: Memory operation error.

OH_ScsiPeripheral_Init()

int32_t OH_ScsiPeripheral_Init (void )

Description

Initializes the SCSI Peripheral DDK.

Since: 18

Required Permissions

ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL

Returns

  • SCSIPERIPHERAL_DDK_SUCCESS: Operation succeeded.

  • SCSIPERIPHERAL_DDK_NO_PERM: Permission verification failed.

  • SCSIPERIPHERAL_DDK_INIT_ERROR: DDK initialization error.

  • SCSIPERIPHERAL_DDK_SERVICE_ERROR: DDK service communication error.

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.

Since: 18

Parameters

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

Required Permissions

ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL

Returns

  • SCSIPERIPHERAL_DDK_SUCCESS: Operation succeeded.

  • SCSIPERIPHERAL_DDK_NO_PERM: Permission verification failed.

  • SCSIPERIPHERAL_DDK_INIT_ERROR: DDK not initialized.

  • SCSIPERIPHERAL_DDK_INVALID_PARAMETER: Empty dev, request, inquiryInfo, inquiryInfo->data, or response.

  • SCSIPERIPHERAL_DDK_SERVICE_ERROR: DDK service communication error.

  • SCSIPERIPHERAL_DDK_MEMORY_ERROR: Memory operation error.

  • SCSIPERIPHERAL_DDK_IO_ERROR: DDK I/O error.

  • SCSIPERIPHERAL_DDK_TIMEOUT: Transfer timeout.

  • SCSIPERIPHERAL_DDK_INVALID_OPERATION: Operation not supported.

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.

Since: 18

Parameters

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

Required Permissions

ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL

Returns

  • SCSIPERIPHERAL_DDK_SUCCESS: Operation succeeded.

  • SCSIPERIPHERAL_DDK_NO_PERM: Permission verification failed.

  • SCSIPERIPHERAL_DDK_INIT_ERROR: DDK not initialized.

  • SCSIPERIPHERAL_DDK_INVALID_PARAMETER: empty dev.

  • SCSIPERIPHERAL_DDK_SERVICE_ERROR: DDK service communication error.

  • SCSIPERIPHERAL_DDK_MEMORY_ERROR: Memory operation error.

  • SCSIPERIPHERAL_DDK_IO_ERROR: DDK I/O operation error.

  • SCSIPERIPHERAL_DDK_DEVICE_NOT_FOUND: Device not found based on deviceId and interfaceIndex.

  • SCSIPERIPHERAL_DDK_INVALID_OPERATION: Operation not supported.

  • SCSIPERIPHERAL_DDK_TIMEOUT: Transfer timeout.

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
senseDataSense data to be parsed.
senseDataLenLength of sense data.
senseInfoStores parsed basic information. For details, see ScsiPeripheral_BasicSenseInfo.

Required Permissions

ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL

Returns

  • SCSIPERIPHERAL_DDK_SUCCESS: Operation succeeded.

  • SCSIPERIPHERAL_DDK_INVALID_PARAMETER: senseData or senseDataLen error. (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.)

OH_ScsiPeripheral_Read10()

int32_t OH_ScsiPeripheral_Read10 (ScsiPeripheral_Device * dev, ScsiPeripheral_IORequest * request, ScsiPeripheral_Response * response )

Description

Reads data from a specified logical block.

Since: 18

Parameters

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

Required Permissions

ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL

Returns

  • SCSIPERIPHERAL_DDK_SUCCESS: Operation succeeded.

  • SCSIPERIPHERAL_DDK_NO_PERM: Permission verification failed.

  • SCSIPERIPHERAL_DDK_INIT_ERROR: DDK not initialized.

  • SCSIPERIPHERAL_DDK_INVALID_PARAMETER: Empty dev, request, request->data, or response.

  • SCSIPERIPHERAL_DDK_SERVICE_ERROR: DDK service communication error.

  • SCSIPERIPHERAL_DDK_MEMORY_ERROR: Memory operation error.

  • SCSIPERIPHERAL_DDK_IO_ERROR: DDK I/O error.

  • SCSIPERIPHERAL_DDK_TIMEOUT: Transfer timeout.

  • SCSIPERIPHERAL_DDK_INVALID_OPERATION: Operation 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.

Since: 18

Parameters

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

Required Permissions

ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL

Returns

  • SCSIPERIPHERAL_DDK_SUCCESS: Operation succeeded.

  • SCSIPERIPHERAL_DDK_NO_PERM: Permission verification failed.

  • SCSIPERIPHERAL_DDK_INIT_ERROR: DDK not initialized.

  • SCSIPERIPHERAL_DDK_INVALID_PARAMETER: Empty dev, request, capacityInfo, or response.

  • SCSIPERIPHERAL_DDK_SERVICE_ERROR: DDK service communication error.

  • SCSIPERIPHERAL_DDK_MEMORY_ERROR: Memory operation error.

  • SCSIPERIPHERAL_DDK_IO_ERROR: DDK I/O error.

  • SCSIPERIPHERAL_DDK_TIMEOUT: Transfer timeout.

  • SCSIPERIPHERAL_DDK_INVALID_OPERATION: Operation not supported.

OH_ScsiPeripheral_Release()

int32_t OH_ScsiPeripheral_Release (void )

Description

Releases the SCSI Peripheral DDK.

Since: 18

Required Permissions

ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL

Returns

  • SCSIPERIPHERAL_DDK_SUCCESS: Operation succeeded.

  • SCSIPERIPHERAL_DDK_NO_PERM: Permission verification failed.

  • SCSIPERIPHERAL_DDK_INIT_ERROR: DDK not initialized.

  • SCSIPERIPHERAL_DDK_SERVICE_ERROR: DDK service communication error.

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.

Since: 18

Parameters

NameDescription
devDevice handle. For details, see ScsiPeripheral_Device.
requestRequest of the request sense command. For details, see ScsiPeripheral_RequestSenseRequest.
responseResponse returned by the request sense command. For details, see ScsiPeripheral_Response.

Required Permissions

ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL

Returns

  • SCSIPERIPHERAL_DDK_SUCCESS: Operation succeeded.

  • SCSIPERIPHERAL_DDK_NO_PERM: Permission verification failed.

  • SCSIPERIPHERAL_DDK_INIT_ERROR: DDK not initialized.

  • SCSIPERIPHERAL_DDK_INVALID_PARAMETER: Empty dev, request, or response.

  • SCSIPERIPHERAL_DDK_SERVICE_ERROR: DDK service communication error.

  • SCSIPERIPHERAL_DDK_MEMORY_ERROR: Memory operation error.

  • SCSIPERIPHERAL_DDK_IO_ERROR: DDK I/O error.

  • SCSIPERIPHERAL_DDK_TIMEOUT: Transfer timeout.

  • SCSIPERIPHERAL_DDK_INVALID_OPERATION: Operation not supported.

OH_ScsiPeripheral_SendRequestByCdb()

int32_t OH_ScsiPeripheral_SendRequestByCdb (ScsiPeripheral_Device * dev, ScsiPeripheral_Request * request, ScsiPeripheral_Response * response )

Description

Sends SCSI commands in command descriptor block (CDB) mode.

Since: 18

Parameters

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

Required Permissions

ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL

Returns

  • SCSIPERIPHERAL_DDK_SUCCESS: Operation succeeded.

  • SCSIPERIPHERAL_DDK_NO_PERM: Permission verification failed.

  • SCSIPERIPHERAL_DDK_INIT_ERROR: DDK not initialized.

  • SCSIPERIPHERAL_DDK_INVALID_PARAMETER: Empty dev, request, request->data, or response, or invalid request->cdbLength value (0).

  • SCSIPERIPHERAL_DDK_SERVICE_ERROR: DDK service communication error.

  • SCSIPERIPHERAL_DDK_MEMORY_ERROR: Memory operation error.

  • SCSIPERIPHERAL_DDK_IO_ERROR: DDK I/O error.

  • SCSIPERIPHERAL_DDK_TIMEOUT: Transfer timeout.

  • SCSIPERIPHERAL_DDK_INVALID_OPERATION: Operation not supported.

OH_ScsiPeripheral_TestUnitReady()

int32_t OH_ScsiPeripheral_TestUnitReady (ScsiPeripheral_Device * dev, ScsiPeripheral_TestUnitReadyRequest * request, ScsiPeripheral_Response * response )

Description

Checks whether the logical units are ready.

Since: 18

Parameters

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

Required Permissions

ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL

Returns

  • SCSIPERIPHERAL_DDK_SUCCESS: Operation succeeded.

  • SCSIPERIPHERAL_DDK_NO_PERM: Permission verification failed.

  • SCSIPERIPHERAL_DDK_INIT_ERROR: DDK not initialized.

  • SCSIPERIPHERAL_DDK_INVALID_PARAMETER: Empty dev, request, or response.

  • SCSIPERIPHERAL_DDK_SERVICE_ERROR: DDK service communication error.

  • SCSIPERIPHERAL_DDK_MEMORY_ERROR: Memory operation error.

  • SCSIPERIPHERAL_DDK_IO_ERROR: DDK I/O error.

  • SCSIPERIPHERAL_DDK_TIMEOUT: Transfer timeout.

  • SCSIPERIPHERAL_DDK_INVALID_OPERATION: Operation not supported.

OH_ScsiPeripheral_Verify10()

int32_t OH_ScsiPeripheral_Verify10 (ScsiPeripheral_Device * dev, ScsiPeripheral_VerifyRequest * request, ScsiPeripheral_Response * response )

Description

Verifies a specified logical block.

Since: 18

Parameters

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

Required Permissions

ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL

Returns

  • SCSIPERIPHERAL_DDK_SUCCESS: Operation succeeded.

  • SCSIPERIPHERAL_DDK_NO_PERM: Permission verification failed.

  • SCSIPERIPHERAL_DDK_INIT_ERROR: DDK not initialized.

  • SCSIPERIPHERAL_DDK_INVALID_PARAMETER: Empty dev, request, or response.

  • SCSIPERIPHERAL_DDK_SERVICE_ERROR: DDK service communication error.

  • SCSIPERIPHERAL_DDK_MEMORY_ERROR: Memory operation error.

  • SCSIPERIPHERAL_DDK_IO_ERROR: DDK I/O error.

  • SCSIPERIPHERAL_DDK_TIMEOUT: Transfer timeout.

  • SCSIPERIPHERAL_DDK_INVALID_OPERATION: Operation not supported.

OH_ScsiPeripheral_Write10()

int32_t OH_ScsiPeripheral_Write10 (ScsiPeripheral_Device * dev, ScsiPeripheral_IORequest * request, ScsiPeripheral_Response * response )

Description

Writes data to a specified logical block of a device.

Since: 18

Parameters

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

Required Permissions

ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL

Returns

  • SCSIPERIPHERAL_DDK_SUCCESS: Operation succeeded.

  • SCSIPERIPHERAL_DDK_NO_PERM: Permission verification failed.

  • SCSIPERIPHERAL_DDK_INIT_ERROR: DDK not initialized.

  • SCSIPERIPHERAL_DDK_INVALID_PARAMETER: Empty dev, request, request->data, or response.

  • SCSIPERIPHERAL_DDK_SERVICE_ERROR: DDK service communication error.

  • SCSIPERIPHERAL_DDK_MEMORY_ERROR: Memory operation error.

  • SCSIPERIPHERAL_DDK_IO_ERROR: DDK I/O error.

  • SCSIPERIPHERAL_DDK_TIMEOUT: Transfer timeout.

  • SCSIPERIPHERAL_DDK_INVALID_OPERATION: Operation not supported.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Driver Development Kit

harmony 鸿蒙Base DDK

harmony 鸿蒙DDK_Ashmem

harmony 鸿蒙Hid_AbsAxesArray

harmony 鸿蒙Hid_Device

harmony 鸿蒙Hid_EmitItem

harmony 鸿蒙Hid_EventProperties

harmony 鸿蒙Hid_EventTypeArray

harmony 鸿蒙Hid_KeyCodeArray

harmony 鸿蒙Hid_MscEventArray

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