mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 18:23:57 -06:00
hw/ufs: Modify lu.c to share codes with SCSI subsystem
This patch removes the code that ufs-lu was duplicating from scsi-hd and allows them to share code. It makes ufs-lu have a virtual scsi-bus and scsi-hd internally. This allows scsi related commands to be passed thorugh to the scsi-hd. The query request and nop command work the same as the existing logic. Well-known lus do not have a virtual scsi-bus and scsi-hd, and handle the necessary scsi commands by emulating them directly. Signed-off-by: Jeuk Kim <jeuk20.kim@samsung.com>
This commit is contained in:
parent
c60be6e3e3
commit
096434fea1
6 changed files with 334 additions and 1479 deletions
36
hw/ufs/ufs.h
36
hw/ufs/ufs.h
|
@ -16,7 +16,8 @@
|
|||
#include "block/ufs.h"
|
||||
|
||||
#define UFS_MAX_LUS 32
|
||||
#define UFS_BLOCK_SIZE 4096
|
||||
#define UFS_BLOCK_SIZE_SHIFT 12
|
||||
#define UFS_BLOCK_SIZE (1 << UFS_BLOCK_SIZE_SHIFT)
|
||||
|
||||
typedef struct UfsBusClass {
|
||||
BusClass parent_class;
|
||||
|
@ -24,7 +25,7 @@ typedef struct UfsBusClass {
|
|||
} UfsBusClass;
|
||||
|
||||
typedef struct UfsBus {
|
||||
SCSIBus parent_bus;
|
||||
BusState parent_bus;
|
||||
} UfsBus;
|
||||
|
||||
#define TYPE_UFS_BUS "ufs-bus"
|
||||
|
@ -55,19 +56,22 @@ typedef struct UfsRequest {
|
|||
|
||||
/* for scsi command */
|
||||
QEMUSGList *sg;
|
||||
uint32_t data_len;
|
||||
} UfsRequest;
|
||||
|
||||
struct UfsLu;
|
||||
typedef UfsReqResult (*UfsScsiOp)(struct UfsLu *, UfsRequest *);
|
||||
|
||||
typedef struct UfsLu {
|
||||
SCSIDevice qdev;
|
||||
DeviceState qdev;
|
||||
uint8_t lun;
|
||||
UnitDescriptor unit_desc;
|
||||
SCSIBus bus;
|
||||
SCSIDevice *scsi_dev;
|
||||
BlockConf conf;
|
||||
UfsScsiOp scsi_op;
|
||||
} UfsLu;
|
||||
|
||||
typedef struct UfsWLu {
|
||||
SCSIDevice qdev;
|
||||
uint8_t lun;
|
||||
} UfsWLu;
|
||||
|
||||
typedef struct UfsParams {
|
||||
char *serial;
|
||||
uint8_t nutrs; /* Number of UTP Transfer Request Slots */
|
||||
|
@ -84,10 +88,10 @@ typedef struct UfsHc {
|
|||
UfsRequest *req_list;
|
||||
|
||||
UfsLu *lus[UFS_MAX_LUS];
|
||||
UfsWLu *report_wlu;
|
||||
UfsWLu *dev_wlu;
|
||||
UfsWLu *boot_wlu;
|
||||
UfsWLu *rpmb_wlu;
|
||||
UfsLu report_wlu;
|
||||
UfsLu dev_wlu;
|
||||
UfsLu boot_wlu;
|
||||
UfsLu rpmb_wlu;
|
||||
DeviceDescriptor device_desc;
|
||||
GeometryDescriptor geometry_desc;
|
||||
Attributes attributes;
|
||||
|
@ -104,9 +108,6 @@ typedef struct UfsHc {
|
|||
#define TYPE_UFS_LU "ufs-lu"
|
||||
#define UFSLU(obj) OBJECT_CHECK(UfsLu, (obj), TYPE_UFS_LU)
|
||||
|
||||
#define TYPE_UFS_WLU "ufs-wlu"
|
||||
#define UFSWLU(obj) OBJECT_CHECK(UfsWLu, (obj), TYPE_UFS_WLU)
|
||||
|
||||
typedef enum UfsQueryFlagPerm {
|
||||
UFS_QUERY_FLAG_NONE = 0x0,
|
||||
UFS_QUERY_FLAG_READ = 0x1,
|
||||
|
@ -128,4 +129,9 @@ static inline bool is_wlun(uint8_t lun)
|
|||
lun == UFS_UPIU_RPMB_WLUN);
|
||||
}
|
||||
|
||||
void ufs_build_upiu_header(UfsRequest *req, uint8_t trans_type, uint8_t flags,
|
||||
uint8_t response, uint8_t scsi_status,
|
||||
uint16_t data_segment_length);
|
||||
void ufs_complete_req(UfsRequest *req, UfsReqResult req_result);
|
||||
void ufs_init_wlu(UfsLu *wlu, uint8_t wlun);
|
||||
#endif /* HW_UFS_UFS_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue