📄 cam.h
字号:
/* ** Copyright 2002, Thomas Kurschel. All rights reserved.** Distributed under the terms of the NewOS License.*/// This interface isn't fully compliant to the official // CAM specification; especially many options like // passing virtual/physical address or pointers/array// are fixed. I added a comment to all changes.// There is no target mode support, let's hope noone// ever needs it.#ifndef __CAM_H__#define __CAM_H__#include <newos/types.h>#include <kernel/sem.h>/* Defines for the XPT function codes, according to CAM spec. *//* Common function commands, 0x00 - 0x0F */#define XPT_NOOP 0x00 /* Execute Nothing */#define XPT_SCSI_IO 0x01 /* Execute the requested SCSI IO */#define XPT_GDEV_TYPE 0x02 /* Get the device type information */#define XPT_PATH_INQ 0x03 /* Path Inquiry */#define XPT_REL_SIMQ 0x04 /* Release the SIM queue that is frozen */#define XPT_SASYNC_CB 0x05 /* Set Async callback parameters */#define XPT_SDEV_TYPE 0x06 /* Set the device type information */#define XPT_SCAN_BUS 0x07 /* Scan the Scsi Bus *//* XPT SCSI control functions, 0x10 - 0x1F */#define XPT_ABORT 0x10 /* Abort the selected CCB */#define XPT_RESET_BUS 0x11 /* Reset the SCSI bus */#define XPT_RESET_DEV 0x12 /* Reset the SCSI device, BDR */#define XPT_TERM_IO 0x13 /* Terminate the I/O process */#define XPT_SCAN_LUN 0x14 /* Scan Logical Unit *//* HBA engine commands, 0x20 - 0x2F */#define XPT_ENG_INQ 0x20 /* HBA engine inquiry */#define XPT_ENG_EXEC 0x21 /* HBA execute engine request *//* Target mode commands, 0x30 - 0x3F */#define XPT_EN_LUN 0x30 /* Enable LUN, Target mode support */#define XPT_TARGET_IO 0x31 /* Execute the target IO request */#define XPT_ACCEPT_TARG 0x32 /* Accept Host Target Mode CDB */#define XPT_CONT_TARG 0x33 /* Cont. Host Target I/O Connection */#define XPT_IMMED_NOTIFY 0x34 /* Notify Host Target driver of event*/#define XPT_NOTIFY_ACK 0x35 /* Acknowledgement of event */#define XPT_FUNC 0x7F /* TEMPLATE */#define XPT_VUNIQUE 0x80 /* All the rest are vendor unique commands *//* ---------------------------------------------------------------------- *//* General allocation length defines for the CCB structures. */// TK: changed name and size#define SCSI_MAX_CDB_SIZE 16 /* Space for the CDB bytes/pointer */// TK: max size of sense data#define SCSI_MAX_SENSE_SIZE 64#define VUHBA 14 /* Vendor Unique HBA length */#define SIM_ID 16 /* ASCII string len for SIM ID */#define HBA_ID 16 /* ASCII string len for HBA ID */#define SIM_PRIV 50 /* Length of SIM private data area *//* Structure definitions for the CAM control blocks, CCB's for the subsystem. *//* Common CCB header definition. */// TK: all other, action specific structures can be modified by XPT/SIM,// thus you can only reuse this header between two requests;// don't change cam_path_id, cam_target_id or cam_target_len as // CCBs are allocated device-specificallytypedef struct ccb_header{ uint32 phys_addr; /* physical address of this CCB */ uint16 cam_ccb_len; /* Length of the entire CCB */ uchar cam_func_code; /* XPT function code */ uchar cam_status; /* Returned CAM subsystem status */ uchar cam_hrsvd0; /* Reserved field, for alignment */ uchar cam_path_id; /* Path ID for the request */ uchar cam_target_id; /* Target device ID */ uchar cam_target_lun; /* Target LUN number */ uint32 cam_flags; /* Flags for operation of the subsystem */ // TK: released once after execution of queued CCB // initialised by alloc_ccb, can be replaced for xpt_action but // must be restored before returning to free_ccb sem_id completion_sem; struct xpt_bus_info *xpt_bus; //struct xpt_target_info *xpt_target; struct xpt_device_info *xpt_device; uchar xpt_state;} CCB_HEADER;/* Common SCSI functions. *//* Union definition for the CDB space in the SCSI I/O request CCB */// TK: unused typedef union cdb_un{ uchar *cam_cdb_ptr; /* Pointer to the CDB bytes to send */ uchar cam_cdb_bytes[ SCSI_MAX_CDB_SIZE ]; /* Area for the CDB to send */} CDB_UN;/* Get device type CCB */typedef struct ccb_getdev{ CCB_HEADER cam_ch; /* Header information fields */ char *cam_inq_data; /* Ptr to the inquiry data space */ uchar cam_pd_type; /* Periph device type from the TLUN */} CCB_GETDEV;/* Path inquiry CCB */typedef struct ccb_pathinq{ CCB_HEADER cam_ch; /* Header information fields */ uchar cam_version_num; /* Version number for the SIM/HBA */ uchar cam_hba_inquiry; /* Mimic of INQ byte 7 for the HBA */ uchar cam_target_sprt; /* Flags for target mode support */ uchar cam_hba_misc; /* Misc HBA feature flags */ uint16 cam_hba_eng_cnt; /* HBA engine count */ uchar cam_vuhba_flags[ VUHBA ]; /* Vendor unique capabilities */ uint32 cam_sim_priv; /* Size of SIM private data area */ uint32 cam_async_flags; /* Event cap. for Async Callback */ uchar cam_hpath_id; /* Highest path ID in the subsystem */ uchar cam_initiator_id; /* ID of the HBA on the SCSI bus */ uchar cam_prsvd0; /* Reserved field, for alignment */ uchar cam_prsvd1; /* Reserved field, for alignment */ char cam_sim_vid[ SIM_ID ]; /* Vendor ID of the SIM */ char cam_hba_vid[ HBA_ID ]; /* Vendor ID of the HBA */ uchar *cam_osd_usage; /* Ptr for the OSD specific area */} CCB_PATHINQ;/* Release SIM Queue CCB */typedef struct ccb_relsim{ CCB_HEADER cam_ch; /* Header information fields */ uint32 cam_frzn_count; /* Frozen count of the queue */} CCB_RELSIM;/* SCSI I/O Request CCB */typedef struct ccb_scsiio{ CCB_HEADER cam_ch; /* Header information fields */ // TK: not used //uchar *cam_pdrv_ptr; /* Ptr used by the Peripheral driver */ //CCB_HEADER *cam_next_ccb; /* Ptr to the next CCB for action */ //uchar *cam_req_map; /* Ptr for mapping info on the Req. */ //void (*cam_cbfcnp)(struct ccb_scsiio *); // /* Callback on completion function */ // TK: new entries struct ccb_scsiio *xpt_next, *xpt_prev; // TK: replaced //uchar *cam_data_ptr; /* Pointer to the data buf/SG list */ // TK: sg_list contains physical addresses if != NULL; // cam_data should contain virtual address if data is virtually continuous; // if there is no sg_list but cam_data, XPT automatically creates sg_list; // only a few (emulated) commands depend on cam_data; // thus you should always provide sg_list uchar *cam_data; struct sg_elem *cam_sg_list; // SG list uint32 cam_dxfer_len; /* Data xfer length */ // TK: fixed sized array instead of pointer uchar cam_sense_ptr[SCSI_MAX_SENSE_SIZE]; /* Pointer to the sense data buffer */ // TK: unused uchar cam_sense_len; /* Num of bytes in the Autosense buf */ uchar cam_cdb_len; /* Number of bytes for the CDB */ uint16 cam_sglist_cnt; /* Num of scatter gather list entries */ // TK: enlarged for huge mediums; -1 means n/a int64 cam_sort; /* Value used by SIM to sort on */ uchar cam_scsi_status; /* Returned scsi device status */ uchar cam_sense_resid; /* Autosense resid length: 2's comp */ uchar cam_osd_rsvd1[2]; /* OSD Reserved field, for alignment */ int32 cam_resid; /* Transfer residual length: 2's comp */ // TK: must use command array uint8 cam_cdb[SCSI_MAX_CDB_SIZE]; /* Union for CDB bytes/pointer */ uint32 cam_timeout; /* Timeout value */ // TK: unused (required for target mode only) //uchar *cam_msg_ptr; /* Pointer to the message buffer */ //uint16 cam_msgb_len; /* Num of bytes in the message buf */ uint16 cam_vu_flags; /* Vendor unique flags */ uchar cam_tag_action; /* What to do for tag queuing */ uchar cam_iorsvd0[3]; /* Reserved field, for alignment */ // TK: private XPT data bool xpt_tmp_sg : 1; // XPT created SG table for this request bool xpt_ordered : 1; // XPT blocks other requests uchar cam_sim_priv[ SIM_PRIV ]; /* SIM private data area */} CCB_SCSIIO;/* Set Async Callback CCB */typedef struct ccb_setasync{ CCB_HEADER cam_ch; /* Header information fields */ uint32 cam_async_flags; /* Event enables for Callback resp */ void (*cam_async_func)(); /* Async Callback function address */ uchar *pdrv_buf; /* Buffer set aside by the Per. drv */ uchar pdrv_buf_len; /* The size of the buffer */} CCB_SETASYNC;/* Set device type CCB */typedef struct ccb_setdev{ CCB_HEADER cam_ch; /* Header information fields */ uchar cam_dev_type; /* Val for the dev type field in EDT */} CCB_SETDEV;/* SCSI Control Functions. *//* Abort XPT Request CCB */typedef struct ccb_abort{ CCB_HEADER cam_ch; /* Header information fields */ CCB_HEADER *cam_abort_ch; /* Pointer to the CCB to abort */} CCB_ABORT;/* Reset SCSI Bus CCB */typedef struct ccb_resetbus{ CCB_HEADER cam_ch; /* Header information fields */} CCB_RESETBUS;/* Reset SCSI Device CCB */typedef struct ccb_resetdev{ CCB_HEADER cam_ch; /* Header information fields */} CCB_RESETDEV;/* Terminate I/O Process Request CCB */typedef struct ccb_termio{ CCB_HEADER cam_ch; /* Header information fields */ CCB_HEADER *cam_termio_ch; /* Pointer to the CCB to terminate */} CCB_TERMIO;/* Target mode structures. *//* Host Target Mode Version 1 Enable LUN CCB */typedef struct ccb_en_lun{ CCB_HEADER cam_ch; /* Header information fields */ uint16 cam_grp6_len; /* Group 6 VU CDB length */ uint16 cam_grp7_len; /* Group 7 VU CDB length */ uchar *cam_ccb_listptr; /* Pointer to the target CCB list */ uint16 cam_ccb_listcnt; /* Count of Target CCBs in the list */} CCB_EN_LUN;/* Enable LUN CCB (HTM V2) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -