advlib.h
来自「基于组件方式开发操作系统的OSKIT源代码」· C头文件 代码 · 共 866 行 · 第 1/2 页
H
866 行
#define ADVV_MC_DATE_W 0x0044#define ADVV_MC_VER_W 0x0046#define ADVV_NEXTRDY_B 0x0048#define ADVV_DONENEXT_B 0x0049#define ADVV_USE_TAGGED_QNG_B 0x004A#define ADVV_SCSIBUSY_B 0x004B#define ADVV_Q_DONE_IN_PROGRESS_B 0x004C#define ADVV_CURCDB_B 0x004D#define ADVV_RCLUN_B 0x004E#define ADVV_BUSY_QHEAD_B 0x004F#define ADVV_DISC1_QHEAD_B 0x0050#define ADVV_DISC_ENABLE_B 0x0052#define ADVV_CAN_TAGGED_QNG_B 0x0053#define ADVV_HOSTSCSI_ID_B 0x0055#define ADVV_MCODE_CNTL_B 0x0056#define ADVV_NULL_TARGET_B 0x0057#define ADVV_FREE_Q_HEAD_W 0x0058#define ADVV_DONE_Q_TAIL_W 0x005A#define ADVV_FREE_Q_HEAD_B (ADVV_FREE_Q_HEAD_W+1)#define ADVV_DONE_Q_TAIL_B (ADVV_DONE_Q_TAIL_W+1)#define ADVV_HOST_FLAG_B 0x005D#define ADV_HOST_FLAG_IN_ISR 0x01#define ADV_HOST_FLAG_ACK_INT 0x02#define ADVV_TOTAL_READY_Q_B 0x0064#define ADVV_VER_SERIAL_B 0x0065#define ADVV_HALTCODE_SAVED_W 0x0066#define ADVV_WTM_FLAG_B 0x0068#define ADVV_RISC_FLAG_B 0x006A#define ADV_RISC_FLAG_GEN_INT 0x01#define ADV_RISC_FLAG_REQ_SG_LIST 0x02#define ADVV_REQ_SG_LIST_QP 0x006B#define ADV_TRANS_CUR 0x01 /* Modify current neogtiation status */#define ADV_TRANS_ACTIVE 0x03 /* Assume this is the active target */#define ADV_TRANS_GOAL 0x04 /* Modify negotiation goal */#define ADV_TRANS_USER 0x08 /* Modify user negotiation settings */struct adv_transinfo { u_int8_t period; u_int8_t offset;};struct adv_target_transinfo { struct adv_transinfo current; struct adv_transinfo goal; struct adv_transinfo user;};struct adv_softc{ bus_space_tag_t tag; bus_space_handle_t bsh; bus_dma_tag_t parent_dmat; bus_dma_tag_t buffer_dmat; bus_dma_tag_t sense_dmat; bus_dmamap_t sense_dmamap; struct scsi_sense_data *sense_buffers; bus_addr_t sense_physbase; bus_addr_t overrun_physbase; adv_btype type; struct adv_target_transinfo tinfo[8]; target_bit_vector fix_asyn_xfer; target_bit_vector fix_asyn_xfer_always; target_bit_vector disc_enable; target_bit_vector user_disc_enable; target_bit_vector cmd_qng_enabled; target_bit_vector user_cmd_qng_enabled; u_int16_t control;#define ADV_CNTL_INITIATOR 0x0001#define ADV_CNTL_BIOS_GT_1GB 0x0002#define ADV_CNTL_BIOS_GT_2_DISK 0x0004#define ADV_CNTL_BIOS_REMOVABLE 0x0008#define ADV_CNTL_NO_SCAM 0x0010#define ADV_CNTL_INT_MULTI_Q 0x0080#define ADV_CNTL_NO_LUN_SUPPORT 0x0040#define ADV_CNTL_NO_VERIFY_COPY 0x0100#define ADV_CNTL_RESET_SCSI 0x0200#define ADV_CNTL_INIT_INQUIRY 0x0400#define ADV_CNTL_INIT_VERBOSE 0x0800#define ADV_CNTL_SCSI_PARITY 0x1000#define ADV_CNTL_BURST_MODE 0x2000#define ADV_CNTL_SDTR_ENABLE_ULTRA 0x4000 u_int16_t bug_fix_control;#define ADV_BUG_FIX_IF_NOT_DWB 0x0001#define ADV_BUG_FIX_ASYN_USE_SYN 0x0002 adv_state state; struct cam_path *path; int unit; int init_level; u_int32_t max_dma_addr; u_int32_t max_dma_count; u_int8_t isa_dma_speed; u_int8_t isa_dma_channel; u_int8_t scsi_id; u_int8_t chip_version; u_int8_t max_tags_per_target; u_int8_t max_openings; u_int8_t cur_active; u_int8_t openings_needed; u_int8_t *sdtr_period_tbl; u_int8_t sdtr_period_tbl_size; struct cam_sim *sim; LIST_HEAD(, ccb_hdr) pending_ccbs; SLIST_HEAD(, adv_ccb_info) free_ccb_infos;};/* * Structures for talking to the RISC engine. */struct adv_scsiq_1 { u_int8_t status;#define QS_FREE 0x00#define QS_READY 0x01#define QS_DISC1 0x02#define QS_DISC2 0x04#define QS_BUSY 0x08#define QS_ABORTED 0x40#define QS_DONE 0x80 u_int8_t q_no; /* * Queue ID of the first queue * used in this transaction. */ u_int8_t cntl;#define QC_NO_CALLBACK 0x01#define QC_SG_SWAP_QUEUE 0x02#define QC_SG_HEAD 0x04#define QC_DATA_IN 0x08#define QC_DATA_OUT 0x10#define QC_URGENT 0x20#define QC_MSG_OUT 0x40#define QC_REQ_SENSE 0x80 u_int8_t sg_queue_cnt; /* Number of SG entries */ u_int8_t target_id; /* target id as a bit vector */ u_int8_t target_lun; /* LUN - taken from our xs */ u_int32_t data_addr; /* * physical addres of first * (possibly only) segment * to transfer. */ u_int32_t data_cnt; /* * byte count of the first * (possibly only) segment * to transfer. */ u_int32_t sense_addr; /* * physical address of the sense * buffer. */ u_int8_t sense_len; /* length of sense buffer */ u_int8_t extra_bytes;};struct adv_scsiq_2 { u_int32_t ccb_ptr; /* Pointer to our CCB */ u_int8_t target_ix; /* Combined TID and LUN */ u_int8_t flag; u_int8_t cdb_len; /* * Number of bytes in the SCSI * command to execute. */ u_int8_t tag_code; /* * Tag type for this transaction * (SIMPLE, ORDERED, HEAD ) */#define ADV_TAG_FLAG_EXTRA_BYTES 0x10#define ADV_TAG_FLAG_DISABLE_DISCONNECT 0x04#define ADV_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX 0x08#define ADV_TAG_FLAG_DISABLE_CHK_COND_INT_HOST 0x40 u_int16_t vm_id;};struct adv_scsiq_3 { u_int8_t done_stat;#define QD_IN_PROGRESS 0x00#define QD_NO_ERROR 0x01#define QD_ABORTED_BY_HOST 0x02#define QD_WITH_ERROR 0x04#define QD_INVALID_REQUEST 0x80#define QD_INVALID_HOST_NUM 0x81#define QD_INVALID_DEVICE 0x82#define QD_ERR_INTERNAL 0xFF u_int8_t host_stat;#define QHSTA_NO_ERROR 0x00#define QHSTA_M_SEL_TIMEOUT 0x11#define QHSTA_M_DATA_OVER_RUN 0x12#define QHSTA_M_DATA_UNDER_RUN 0x12#define QHSTA_M_UNEXPECTED_BUS_FREE 0x13#define QHSTA_M_BAD_BUS_PHASE_SEQ 0x14#define QHSTA_D_QDONE_SG_LIST_CORRUPTED 0x21#define QHSTA_D_ASC_DVC_ERROR_CODE_SET 0x22#define QHSTA_D_HOST_ABORT_FAILED 0x23#define QHSTA_D_EXE_SCSI_Q_FAILED 0x24#define QHSTA_D_EXE_SCSI_Q_BUSY_TIMEOUT 0x25#define QHSTA_D_ASPI_NO_BUF_POOL 0x26#define QHSTA_M_WTM_TIMEOUT 0x41#define QHSTA_M_BAD_CMPL_STATUS_IN 0x42#define QHSTA_M_NO_AUTO_REQ_SENSE 0x43#define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44#define QHSTA_M_TARGET_STATUS_BUSY 0x45#define QHSTA_M_BAD_TAG_CODE 0x46#define QHSTA_M_BAD_QUEUE_FULL_OR_BUSY 0x47#define QHSTA_M_HUNG_REQ_SCSI_BUS_RESET 0x48#define QHSTA_D_LRAM_CMP_ERROR 0x81 #define QHSTA_M_MICRO_CODE_ERROR_HALT 0xA1 u_int8_t scsi_stat; u_int8_t scsi_msg;};struct adv_scsiq_4 { u_int8_t cdb[ADV_MAX_CDB_LEN]; u_int8_t y_first_sg_list_qp; u_int8_t y_working_sg_qp; u_int8_t y_working_sg_ix; u_int8_t y_res; u_int16_t x_req_count; u_int16_t x_reconnect_rtn; u_int32_t x_saved_data_addr; u_int32_t x_saved_data_cnt;};struct adv_q_done_info { struct adv_scsiq_2 d2; struct adv_scsiq_3 d3; u_int8_t q_status; u_int8_t q_no; u_int8_t cntl; u_int8_t sense_len; u_int8_t extra_bytes; u_int8_t res; u_int32_t remain_bytes;};struct adv_sg_entry { u_int32_t addr; u_int32_t bytes;};struct adv_sg_head { u_int16_t entry_cnt; /* * Number of SG entries * in this list */ u_int16_t queue_cnt; /* * Number of queues required * to store entry_cnt * SG entries. */ u_int16_t entry_to_copy; /* * Number of SG entries to * copy to the board. */ u_int16_t res; struct adv_sg_entry *sg_list;};#define QCX_SORT (0x0001)#define QCX_COALEASE (0x0002)struct adv_scsi_q { struct adv_scsiq_1 q1; struct adv_scsiq_2 q2; u_int8_t *cdbptr; /* * Pointer to the SCSI command * to execute. */ struct adv_sg_head *sg_head; /* * Pointer to possible SG list */};struct adv_scsi_req_q { struct adv_scsiq_1 r1; struct adv_scsiq_2 r2; u_int8_t *cdbptr; struct adv_sg_head *sg_head; u_int8_t *sense_ptr; struct adv_scsiq_3 r3; u_int8_t cdb[ADV_MAX_CDB_LEN]; u_int8_t sense[ADV_MIN_SENSE_LEN];};struct adv_risc_q { u_int8_t fwd; u_int8_t bwd; struct adv_scsiq_1 i1; struct adv_scsiq_2 i2; struct adv_scsiq_3 i3; struct adv_scsiq_4 i4;};struct adv_sg_list_q { u_int8_t seq_no; u_int8_t q_no; u_int8_t cntl;#define QCSG_SG_XFER_LIST 0x02#define QCSG_SG_XFER_MORE 0x04#define QCSG_SG_XFER_END 0x08 u_int8_t sg_head_qp; u_int8_t sg_list_cnt; u_int8_t sg_cur_list_cnt;};#define ADV_SGQ_B_SG_CNTL 4#define ADV_SGQ_B_SG_HEAD_QP 5#define ADV_SGQ_B_SG_LIST_CNT 6#define ADV_SGQ_B_SG_CUR_LIST_CNT 7#define ADV_SGQ_LIST_BEG 8struct asc_risc_sg_list_q { u_int8_t fwd; u_int8_t bwd; struct adv_sg_list_q sg; struct adv_sg_entry sg_list[ADV_SG_LIST_PER_Q];};/* Chip Register functions */void adv_set_bank(struct adv_softc *adv, u_int8_t bank);/* LRAM routines */u_int8_t adv_read_lram_8(struct adv_softc *adv, u_int16_t addr);void adv_write_lram_8(struct adv_softc *adv, u_int16_t addr, u_int8_t value);u_int16_t adv_read_lram_16(struct adv_softc *adv, u_int16_t addr);void adv_write_lram_16(struct adv_softc *adv, u_int16_t addr, u_int16_t value);/* Intialization */int adv_find_signature(bus_space_tag_t tag, bus_space_handle_t bsh);void adv_lib_init(struct adv_softc *adv);u_int16_t adv_get_eeprom_config(struct adv_softc *adv, struct adv_eeprom_config *eeprom_config);int adv_set_eeprom_config(struct adv_softc *adv, struct adv_eeprom_config *eeprom_config);int adv_reset_chip_and_scsi_bus(struct adv_softc *adv);int adv_test_external_lram(struct adv_softc* adv);int adv_init_lram_and_mcode(struct adv_softc *adv);u_int8_t adv_get_chip_irq(struct adv_softc *adv);u_int8_t adv_set_chip_irq(struct adv_softc *adv, u_int8_t irq_no);void adv_set_chip_scsiid(struct adv_softc *adv, int new_id);/* Queue handling and execution */int adv_execute_scsi_queue(struct adv_softc *adv, struct adv_scsi_q *scsiq, u_int32_t datalen);u_int8_t adv_copy_lram_doneq(struct adv_softc *adv, u_int16_t q_addr, struct adv_q_done_info *scsiq, u_int32_t max_dma_count);/* Chip Control */int adv_start_chip(struct adv_softc *adv);void adv_start_execution(struct adv_softc *adv);int adv_stop_execution(struct adv_softc *adv);int adv_is_chip_halted(struct adv_softc *adv);/* Interrupt processing */void adv_ack_interrupt(struct adv_softc *adv);void adv_isr_chip_halted(struct adv_softc *adv);/* SDTR Conversion */void adv_set_syncrate(struct adv_softc *adv, struct cam_path *path, u_int target_id, u_int period, u_int offset, u_int type);void adv_sdtr_to_period_offset(struct adv_softc *adv, u_int8_t sync_data, u_int8_t *period, u_int8_t *offset, int tid);u_int8_t adv_period_offset_to_sdtr(struct adv_softc *adv, u_int *period, u_int *offset, int tid);/* Error recovery */int adv_abort_ccb(struct adv_softc *adv, int target, int lun, union ccb *ccb, u_int32_t status, int queued_only);int adv_reset_bus(struct adv_softc *adv);/* Async event callback */void advasync(void *callback_arg, u_int32_t code, struct cam_path *path, void *arg);#define ADV_INB(adv, offset) \ bus_space_read_1((adv)->tag, (adv)->bsh, offset)#define ADV_INW(adv, offset) \ bus_space_read_2((adv)->tag, (adv)->bsh, offset)#define ADV_INSB(adv, offset, valp, count) \ bus_space_read_multi_1((adv)->tag, (adv)->bsh, offset, valp, count)/* These controllers seem to have problems with PIO on some fast processors */static __inline void ADV_INSW(struct adv_softc *, u_int, u_int16_t *, u_int);static __inline voidADV_INSW(struct adv_softc *adv, u_int offset, u_int16_t *valp, u_int count){ while (count--) *valp++ = bus_space_read_2(adv->tag, adv->bsh, offset);}#define ADV_OUTB(adv, offset, val) \ bus_space_write_1((adv)->tag, (adv)->bsh, offset, val)#define ADV_OUTW(adv, offset, val) \ bus_space_write_2((adv)->tag, (adv)->bsh, offset, val)/* These controllers seem to have problems with PIO on some fast processors */static __inline void ADV_OUTSW(struct adv_softc *, u_int, u_int16_t *, u_int);static __inline voidADV_OUTSW(struct adv_softc *adv, u_int offset, u_int16_t *valp, u_int count){ while (count--) bus_space_write_2(adv->tag, adv->bsh, offset, *valp++);}#endif /* _ADVLIB_H_ */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?