#ifndef _AHCIREG_H
#define _AHCIREG_H
#ifdef __cplusplus
extern "C" {
#endif
#define AHCI_MAX_PORTS 32
#define AHCI_PORT_MAX_CMD_SLOTS 32
#define VIA_VENID 0x1106
#define AHCI_MAX_PRDT_NUMBER 65535
#define AHCI_MIN_PRDT_NUMBER 1
#define AHCI_PRDT_NUMBER 257
#define AHCI_PCI_RNUM 0x24
#define AHCI_HBA_CAP_NP (0x1f << 0)
#define AHCI_HBA_CAP_SXS (0x1 << 5)
#define AHCI_HBA_CAP_EMS (0x1 << 6)
#define AHCI_HBA_CAP_CCCS (0x1 << 7)
#define AHCI_HBA_CAP_NCS (0x1f << 8)
#define AHCI_HBA_CAP_PSC (0x1 << 13)
#define AHCI_HBA_CAP_SSC (0x1 << 14)
#define AHCI_HBA_CAP_PMD (0x1 << 15)
#define AHCI_HBA_CAP_FBSS (0x1 << 16)
#define AHCI_HBA_CAP_SPM (0x1 << 17)
#define AHCI_HBA_CAP_SAM (0x1 << 18)
#define AHCI_HBA_CAP_ISS (0xf << 20)
#define AHCI_HBA_CAP_SCLO (0x1 << 24)
#define AHCI_HBA_CAP_SAL (0x1 << 25)
#define AHCI_HBA_CAP_SALP (0x1 << 26)
#define AHCI_HBA_CAP_SSS (0x1 << 27)
#define AHCI_HBA_CAP_SMPS (0x1 << 28)
#define AHCI_HBA_CAP_SSNTF (0x1 << 29)
#define AHCI_HBA_CAP_SNCQ (0x1 << 30)
#define AHCI_HBA_CAP_S64A ((uint32_t)0x1 << 31)
#define AHCI_HBA_CAP_NCS_SHIFT 8
#define AHCI_HBA_CAP_ISS_SHIFT 20
#define AHCI_HBA_GHC_HR (0x1 << 0)
#define AHCI_HBA_GHC_IE (0x1 << 1)
#define AHCI_HBA_GHC_MRSM (0x1 << 2)
#define AHCI_HBA_GHC_AE ((uint32_t)0x1 << 31)
#define AHCI_HBA_CCC_CTL_EN 0x00000001
#define AHCI_HBA_CCC_CTL_INT_MASK (0x1f << 3)
#define AHCI_HBA_CCC_CTL_CC_MASK 0x0000ff00
#define AHCI_HBA_CCC_CTL_TV_MASK 0xffff0000
#define AHCI_HBA_CCC_CTL_INT_SHIFT 3
#define AHCI_HBA_CCC_CTL_CC_SHIFT 8
#define AHCI_HBA_CCC_CTL_TV_SHIFT 16
#define AHCI_HBA_EM_LOC_SZ_MASK 0x0000ffff
#define AHCI_HBA_EM_LOC_OFST_MASK 0xffff0000
#define AHCI_HBA_EM_LOC_OFST_SHIFT 16
#define AHCI_HBA_EM_CTL_STS_MR (0x1 << 0)
#define AHCI_HBA_EM_CTL_CTL_TM (0x1 << 8)
#define AHCI_HBA_EM_CTL_CTL_RST (0x1 << 9)
#define AHCI_HBA_EM_CTL_SUPP_LED (0x1 << 16)
#define AHCI_HBA_EM_CTL_SUPP_SAFTE (0x1 << 17)
#define AHCI_HBA_EM_CTL_SUPP_SES2 (0x1 << 18)
#define AHCI_HBA_EM_CTL_SUPP_SGPIO (0x1 << 19)
#define AHCI_HBA_EM_CTL_ATTR_SMB (0x1 << 24)
#define AHCI_HBA_EM_CTL_ATTR_XMT (0x1 << 25)
#define AHCI_HBA_EM_CTL_ATTR_ALHD (0x1 << 26)
#define AHCI_HBA_EM_CTL_ATTR_PM (0x1 << 27)
#define AHCI_HBA_CAP2_BOH (0x1 << 0)
#define AHCI_HBA_CAP2_NVMP (0x1 << 1)
#define AHCI_HBA_CAP2_APST (0x1 << 2)
#define AHCI_HBA_CAP2_SDS (0x1 << 3)
#define AHCI_HBA_CAP2_SADM (0x1 << 4)
#define AHCI_HBA_CAP2_DESO (0x1 << 5)
#define AHCI_GLOBAL_OFFSET(ahci_ctlp) (ahci_ctlp->ahcictl_ahci_addr)
#define AHCI_GLOBAL_CAP(ahci_ctlp) (AHCI_GLOBAL_OFFSET(ahci_ctlp) + 0x00)
#define AHCI_GLOBAL_GHC(ahci_ctlp) (AHCI_GLOBAL_OFFSET(ahci_ctlp) + 0x04)
#define AHCI_GLOBAL_IS(ahci_ctlp) (AHCI_GLOBAL_OFFSET(ahci_ctlp) + 0x08)
#define AHCI_GLOBAL_PI(ahci_ctlp) (AHCI_GLOBAL_OFFSET(ahci_ctlp) + 0x0c)
#define AHCI_GLOBAL_VS(ahci_ctlp) (AHCI_GLOBAL_OFFSET(ahci_ctlp) + 0x10)
#define AHCI_GLOBAL_CCC_CTL(ahci_ctlp) (AHCI_GLOBAL_OFFSET(ahci_ctlp) + 0x14)
#define AHCI_GLOBAL_CCC_PORTS(ahci_ctlp) \
(AHCI_GLOBAL_OFFSET(ahci_ctlp) + 0x18)
#define AHCI_GLOBAL_EM_LOC(ahci_ctlp) (AHCI_GLOBAL_OFFSET(ahci_ctlp) + 0x1c)
#define AHCI_GLOBAL_EM_CTL(ahci_ctlp) (AHCI_GLOBAL_OFFSET(ahci_ctlp) + 0x20)
#define AHCI_GLOBAL_CAP2(ahci_ctlp) (AHCI_GLOBAL_OFFSET(ahci_ctlp) + 0x24)
#define AHCI_GLOBAL_BOHC(ahci_ctlp) (AHCI_GLOBAL_OFFSET(ahci_ctlp) + 0x28)
#define AHCI_PORT_IMPLEMENTED(ahci_ctlp, port) \
((0x1 << port) & ahci_ctlp->ahcictl_ports_implemented)
#define AHCI_INTR_STATUS_DHRS (0x1 << 0)
#define AHCI_INTR_STATUS_PSS (0x1 << 1)
#define AHCI_INTR_STATUS_DSS (0x1 << 2)
#define AHCI_INTR_STATUS_SDBS (0x1 << 3)
#define AHCI_INTR_STATUS_UFS (0x1 << 4)
#define AHCI_INTR_STATUS_DPS (0x1 << 5)
#define AHCI_INTR_STATUS_PCS (0x1 << 6)
#define AHCI_INTR_STATUS_DMPS (0x1 << 7)
#define AHCI_INTR_STATUS_PRCS (0x1 << 22)
#define AHCI_INTR_STATUS_IPMS (0x1 << 23)
#define AHCI_INTR_STATUS_OFS (0x1 << 24)
#define AHCI_INTR_STATUS_INFS (0x1 << 26)
#define AHCI_INTR_STATUS_IFS (0x1 << 27)
#define AHCI_INTR_STATUS_HBDS (0x1 << 28)
#define AHCI_INTR_STATUS_HBFS (0x1 << 29)
#define AHCI_INTR_STATUS_TFES (0x1 << 30)
#define AHCI_INTR_STATUS_CPDS ((uint32_t)0x1 << 31)
#define AHCI_PORT_INTR_MASK 0xfec000ff
#define AHCI_CMD_STATUS_ST (0x1 << 0)
#define AHCI_CMD_STATUS_SUD (0x1 << 1)
#define AHCI_CMD_STATUS_POD (0x1 << 2)
#define AHCI_CMD_STATUS_CLO (0x1 << 3)
#define AHCI_CMD_STATUS_FRE (0x1 << 4)
#define AHCI_CMD_STATUS_CCS (0x1f << 8)
#define AHCI_CMD_STATUS_MPSS (0x1 << 13)
#define AHCI_CMD_STATUS_FR (0x1 << 14)
#define AHCI_CMD_STATUS_CR (0x1 << 15)
#define AHCI_CMD_STATUS_CPS (0x1 << 16)
#define AHCI_CMD_STATUS_PMA (0x1 << 17)
#define AHCI_CMD_STATUS_HPCP (0x1 << 18)
#define AHCI_CMD_STATUS_MPSP (0x1 << 19)
#define AHCI_CMD_STATUS_CPD (0x1 << 20)
#define AHCI_CMD_STATUS_ESP (0x1 << 21)
#define AHCI_CMD_STATUS_ATAPI (0x1 << 24)
#define AHCI_CMD_STATUS_DLAE (0x1 << 25)
#define AHCI_CMD_STATUS_ALPE (0x1 << 26)
#define AHCI_CMD_STATUS_ASP (0x1 << 27)
#define AHCI_CMD_STATUS_ICC (0xf << 28)
#define AHCI_CMD_STATUS_CCS_SHIFT 8
#define AHCI_CMD_STATUS_ICC_SHIFT 28
#define AHCI_TFD_STS_MASK 0x000000ff
#define AHCI_TFD_ERR_MASK 0x0000ff00
#define AHCI_TFD_STS_BSY (0x1 << 7)
#define AHCI_TFD_STS_DRQ (0x1 << 3)
#define AHCI_TFD_STS_ERR (0x1 << 0)
#define AHCI_TFD_ERR_SHIFT 8
#define AHCI_TFD_ERR_SGS (0x1 << 0)
#define AHCI_FBS_SWE_MASK (0xf << 16)
#define AHCI_FBS_ADO_MASK (0xf << 12)
#define AHCI_FBS_DEV_MASK (0xf << 8)
#define AHCI_FBS_SDE (0x1 << 2)
#define AHCI_FBS_DEC (0x1 << 1)
#define AHCI_FBS_EN (0x1 << 0)
#define AHCI_SERROR_CLEAR_ALL 0xffffffff
#define AHCI_SNOTIF_CLEAR_ALL 0xffffffff
#define AHCI_PORT_OFFSET(ahci_ctlp, port) \
(ahci_ctlp->ahcictl_ahci_addr + (0x100 + (port * 0x80)))
#define AHCI_PORT_PxCLB(ahci_ctlp, port) \
(AHCI_PORT_OFFSET(ahci_ctlp, port) + 0x00)
#define AHCI_PORT_PxCLBU(ahci_ctlp, port) \
(AHCI_PORT_OFFSET(ahci_ctlp, port) + 0x04)
#define AHCI_PORT_PxFB(ahci_ctlp, port) \
(AHCI_PORT_OFFSET(ahci_ctlp, port) + 0x08)
#define AHCI_PORT_PxFBU(ahci_ctlp, port) \
(AHCI_PORT_OFFSET(ahci_ctlp, port) + 0x0c)
#define AHCI_PORT_PxIS(ahci_ctlp, port) \
(AHCI_PORT_OFFSET(ahci_ctlp, port) + 0x10)
#define AHCI_PORT_PxIE(ahci_ctlp, port) \
(AHCI_PORT_OFFSET(ahci_ctlp, port) + 0x14)
#define AHCI_PORT_PxCMD(ahci_ctlp, port) \
(AHCI_PORT_OFFSET(ahci_ctlp, port) + 0x18)
#define AHCI_PORT_PxTFD(ahci_ctlp, port) \
(AHCI_PORT_OFFSET(ahci_ctlp, port) + 0x20)
#define AHCI_PORT_PxSIG(ahci_ctlp, port) \
(AHCI_PORT_OFFSET(ahci_ctlp, port) + 0x24)
#define AHCI_PORT_PxSSTS(ahci_ctlp, port) \
(AHCI_PORT_OFFSET(ahci_ctlp, port) + 0x28)
#define AHCI_PORT_PxSCTL(ahci_ctlp, port) \
(AHCI_PORT_OFFSET(ahci_ctlp, port) + 0x2c)
#define AHCI_PORT_PxSERR(ahci_ctlp, port) \
(AHCI_PORT_OFFSET(ahci_ctlp, port) + 0x30)
#define AHCI_PORT_PxSACT(ahci_ctlp, port) \
(AHCI_PORT_OFFSET(ahci_ctlp, port) + 0x34)
#define AHCI_PORT_PxCI(ahci_ctlp, port) \
(AHCI_PORT_OFFSET(ahci_ctlp, port) + 0x38)
#define AHCI_PORT_PxSNTF(ahci_ctlp, port) \
(AHCI_PORT_OFFSET(ahci_ctlp, port) + 0x3c)
#define AHCI_PORT_PxFBS(ahci_ctlp, port) \
(AHCI_PORT_OFFSET(ahci_ctlp, port) + 0x40)
#define AHCI_SLOT_MASK(ahci_ctlp) \
((ahci_ctlp->ahcictl_num_cmd_slots == AHCI_PORT_MAX_CMD_SLOTS) ? \
0xffffffff : ((0x1 << ahci_ctlp->ahcictl_num_cmd_slots) - 1))
#define AHCI_NCQ_SLOT_MASK(ahci_portp) \
((ahci_portp->ahciport_max_ncq_tags == AHCI_PORT_MAX_CMD_SLOTS) ? \
0xffffffff : ((0x1 << ahci_portp->ahciport_max_ncq_tags) - 1))
#define AHCI_PMPORT_MASK(ahci_portp) \
((0x1 << ahci_portp->ahciport_pmult_info->ahcipmi_num_dev_ports) - 1)
#define AHCI_SIGNATURE_PORT_MULTIPLIER 0x96690101
#define AHCI_SIGNATURE_ATAPI 0xeb140101
#define AHCI_SIGNATURE_DISK 0x00000101
#define AHCI_H2D_REGISTER_FIS_TYPE 0x27
#define AHCI_H2D_REGISTER_FIS_LENGTH 5
#define AHCI_CMDHEAD_ATAPI 0x1
#define AHCI_CMDHEAD_DATA_WRITE 0x1
#define AHCI_CMDHEAD_DATA_READ 0x0
#define AHCI_CMDHEAD_PREFETCHABLE 0x1
typedef struct ahci_fis_h2d_register {
uint32_t ahcifhr_type_pmp_rsvd_cmddevctl_cmd_features;
#define SET_FIS_TYPE(fis, type) \
(fis->ahcifhr_type_pmp_rsvd_cmddevctl_cmd_features |= (type & 0xff))
#define SET_FIS_PMP(fis, pmp) \
(fis->ahcifhr_type_pmp_rsvd_cmddevctl_cmd_features |= \
((pmp & 0xf) << 8))
#define SET_FIS_CDMDEVCTL(fis, cmddevctl) \
(fis->ahcifhr_type_pmp_rsvd_cmddevctl_cmd_features |= \
((cmddevctl & 0x1) << 15))
#define GET_FIS_COMMAND(fis) \
((fis->ahcifhr_type_pmp_rsvd_cmddevctl_cmd_features >> 16) & 0xff)
#define SET_FIS_COMMAND(fis, command) \
(fis->ahcifhr_type_pmp_rsvd_cmddevctl_cmd_features |= \
((command & 0xff) << 16))
#define GET_FIS_FEATURES(fis) \
((fis->ahcifhr_type_pmp_rsvd_cmddevctl_cmd_features >> 24) & 0xff)
#define SET_FIS_FEATURES(fis, features) \
(fis->ahcifhr_type_pmp_rsvd_cmddevctl_cmd_features |= \
((features & 0xff) << 24))
uint32_t ahcifhr_sector_cyllow_cylhi_devhead;
#define GET_FIS_SECTOR(fis) \
(fis->ahcifhr_sector_cyllow_cylhi_devhead & 0xff)
#define SET_FIS_SECTOR(fis, sector) \
(fis->ahcifhr_sector_cyllow_cylhi_devhead |= ((sector & 0xff)))
#define GET_FIS_CYL_LOW(fis) \
((fis->ahcifhr_sector_cyllow_cylhi_devhead >> 8) & 0xff)
#define SET_FIS_CYL_LOW(fis, cyl_low) \
(fis->ahcifhr_sector_cyllow_cylhi_devhead |= ((cyl_low & 0xff) << 8))
#define GET_FIS_CYL_HI(fis) \
((fis->ahcifhr_sector_cyllow_cylhi_devhead >> 16) & 0xff)
#define SET_FIS_CYL_HI(fis, cyl_hi) \
(fis->ahcifhr_sector_cyllow_cylhi_devhead |= ((cyl_hi & 0xff) << 16))
#define GET_FIS_DEV_HEAD(fis) \
((fis->ahcifhr_sector_cyllow_cylhi_devhead >> 24) & 0xff)
#define SET_FIS_DEV_HEAD(fis, dev_head) \
(fis->ahcifhr_sector_cyllow_cylhi_devhead |= ((dev_head & 0xff) << 24))
uint32_t ahcifhr_sectexp_cyllowexp_cylhiexp_featuresexp;
#define GET_FIS_SECTOR_EXP(fis) \
(fis->ahcifhr_sectexp_cyllowexp_cylhiexp_featuresexp & 0xff)
#define SET_FIS_SECTOR_EXP(fis, sectorexp) \
(fis->ahcifhr_sectexp_cyllowexp_cylhiexp_featuresexp |= \
((sectorexp & 0xff)))
#define GET_FIS_CYL_LOW_EXP(fis) \
((fis->ahcifhr_sectexp_cyllowexp_cylhiexp_featuresexp >> 8) & 0xff)
#define SET_FIS_CYL_LOW_EXP(fis, cyllowexp) \
(fis->ahcifhr_sectexp_cyllowexp_cylhiexp_featuresexp |= \
((cyllowexp & 0xff) << 8))
#define GET_FIS_CYL_HI_EXP(fis) \
((fis->ahcifhr_sectexp_cyllowexp_cylhiexp_featuresexp >> 16) & 0xff)
#define SET_FIS_CYL_HI_EXP(fis, cylhiexp) \
(fis->ahcifhr_sectexp_cyllowexp_cylhiexp_featuresexp |= \
((cylhiexp & 0xff) << 16))
#define SET_FIS_FEATURES_EXP(fis, features_exp) \
(fis->ahcifhr_sectexp_cyllowexp_cylhiexp_featuresexp |= \
((features_exp & 0xff) << 24))
uint32_t ahcifhr_sectcount_sectcountexp_rsvd_devctl;
#define GET_FIS_SECTOR_COUNT(fis) \
(fis->ahcifhr_sectcount_sectcountexp_rsvd_devctl & 0xff)
#define SET_FIS_SECTOR_COUNT(fis, sector_count) \
(fis->ahcifhr_sectcount_sectcountexp_rsvd_devctl |= \
((sector_count & 0xff)))
#define GET_FIS_SECTOR_COUNT_EXP(fis) \
((fis->ahcifhr_sectcount_sectcountexp_rsvd_devctl >> 8) & 0xff)
#define SET_FIS_SECTOR_COUNT_EXP(fis, sector_count_exp) \
(fis->ahcifhr_sectcount_sectcountexp_rsvd_devctl |= \
((sector_count_exp & 0xff) << 8))
#define SET_FIS_DEVCTL(fis, devctl) \
(fis->ahcifhr_sectcount_sectcountexp_rsvd_devctl |= \
((devctl & 0xff) << 24))
uint32_t ahcifhr_rsvd3[1];
} ahci_fis_h2d_register_t;
typedef struct ahci_fis_d2h_register {
uint32_t ahcifdr_type_intr_rsvd_status_error;
#define GET_RFIS_STATUS(fis) \
((fis->ahcifdr_type_intr_rsvd_status_error >> 16) & 0xff)
#define GET_RFIS_ERROR(fis) \
((fis->ahcifdr_type_intr_rsvd_status_error >> 24) & 0xff)
uint32_t ahcifdr_sector_cyllow_cylhi_devhead;
#define GET_RFIS_CYL_LOW(fis) \
(fis->ahcifdr_sector_cyllow_cylhi_devhead & 0xff)
#define GET_RFIS_CYL_MID(fis) \
((fis->ahcifdr_sector_cyllow_cylhi_devhead >> 8) & 0xff)
#define GET_RFIS_CYL_HI(fis) \
((fis->ahcifdr_sector_cyllow_cylhi_devhead >> 16) & 0xff)
#define GET_RFIS_DEV_HEAD(fis) \
((fis->ahcifdr_sector_cyllow_cylhi_devhead >> 24) & 0xff)
uint32_t ahcifdr_sectexp_cyllowexp_cylhiexp_rsvd;
#define GET_RFIS_CYL_LOW_EXP(fis) \
(fis->ahcifdr_sectexp_cyllowexp_cylhiexp_rsvd & 0xff)
#define GET_RFIS_CYL_MID_EXP(fis) \
((fis->ahcifdr_sectexp_cyllowexp_cylhiexp_rsvd >> 8) & 0xff)
#define GET_RFIS_CYL_HI_EXP(fis) \
((fis->ahcifdr_sectexp_cyllowexp_cylhiexp_rsvd >> 16) & 0xff)
uint32_t ahcifdr_sectcount_sectcountexp_rsvd;
#define GET_RFIS_SECTOR_COUNT(fis) \
(fis->ahcifdr_sectcount_sectcountexp_rsvd & 0xff)
#define GET_RFIS_SECTOR_COUNT_EXP(fis) \
((fis->ahcifdr_sectcount_sectcountexp_rsvd >> 8) & 0xff)
uint32_t ahcifdr_rsvd;
} ahci_fis_d2h_register_t;
typedef struct ahci_fis_set_device_bits {
uint32_t ahcifsdb_type_rsvd_intr_status_error;
#define GET_N_BIT_OF_SET_DEV_BITS(fis) \
((fis->ahcifsdb_type_rsvd_intr_status_error >> 15) & 0x1)
uint32_t ahcifsdb_rsvd;
} ahci_fis_set_device_bits_t;
typedef struct ahci_fis_dma_setup {
uint32_t ahcifds_type_rsvd_direction_intr_rsvd;
uint32_t ahcifds_dma_buffer_identifier_low;
uint32_t ahcifds_dma_buffer_identifier_high;
uint32_t ahcifds_rsvd1;
uint32_t ahcifds_dma_buffer_offset;
uint32_t ahcifds_dma_transfer_count;
uint32_t ahcifds_rsvd2;
} ahci_fis_dma_setup_t;
typedef struct ahci_fis_pio_setup {
uint32_t ahcifps_type_rsvd_direction_intr_status_error;
uint32_t ahcifps_sector_cyllow_cylhi_devhead;
uint32_t ahcifps_sectexp_cyllowexp_cylhiexp_rsvd;
uint32_t ahcifps_sectcount_sectcountexp_rsvd_e_status;
uint32_t ahcifps_transfer_count_rsvd;
} ahci_fis_pio_setup_t;
typedef struct ahci_fis_bist_active {
uint32_t ahcifba_type_rsvd_pattern_rsvd;
uint32_t ahcifba_data1;
uint32_t ahcifba_data2;
} ahci_fis_bist_active_t;
typedef struct ahci_fis_unknown {
uint32_t ahcifu_first_dword;
uint32_t ahcifu_dword[15];
} ahci_fis_unknown_t;
typedef struct ahci_fis_command {
union {
ahci_fis_h2d_register_t ahcifc_h2d_register;
ahci_fis_bist_active_t ahcifc_bist_active;
} ahcifc_fis;
uint32_t ahcifc_rsvd3[11];
} ahci_fis_command_t;
typedef struct ahci_rcvd_fis {
ahci_fis_dma_setup_t ahcirf_dma_setup_fis;
uint32_t ahcirf_fis_rsvd1;
ahci_fis_pio_setup_t ahcirf_pio_setup_fis;
uint32_t ahcirf_fis_rsvd2[3];
ahci_fis_d2h_register_t ahcirf_d2h_register_fis;
uint32_t ahcirf_fis_rsvd3;
ahci_fis_set_device_bits_t ahcirf_set_device_bits_fis;
ahci_fis_unknown_t ahcirf_unknown_fis;
uint32_t ahcirf_fis_rsvd4[24];
} ahci_rcvd_fis_t;
typedef struct ahci_prdt_item {
uint32_t ahcipi_data_base_addr;
uint32_t ahcipi_data_base_addr_upper;
uint32_t ahcipi_rsvd;
uint32_t ahcipi_descr_info;
#define GET_PRDT_ITEM_INTR_ON_COMPLETION(prdt_item) \
((prdt_item.ahcipi_descr_info >> 31) & 0x01)
#define GET_PRDT_ITEM_DATA_BYTE_COUNT(prdt_item) \
(prdt_item.ahcipi_descr_info & 0x3fffff)
} ahci_prdt_item_t;
typedef struct ahci_cmd_table {
ahci_fis_command_t ahcict_command_fis;
uint8_t ahcict_atapi_cmd[SATA_ATAPI_MAX_CDB_LEN];
uint32_t ahcict_rsvd[12];
ahci_prdt_item_t ahcict_prdt[AHCI_PRDT_NUMBER];
} ahci_cmd_table_t;
typedef struct ahci_cmd_header {
uint32_t ahcich_descr_info;
#define BZERO_DESCR_INFO(cmd_header) \
(cmd_header->ahcich_descr_info = 0)
#define GET_PRD_TABLE_LENGTH(cmd_header) \
((cmd_header->ahcich_descr_info >> 16) & 0xffff)
#define SET_PRD_TABLE_LENGTH(cmd_header, length) \
(cmd_header->ahcich_descr_info |= ((length & 0xffff) << 16))
#define GET_PORT_MULTI_PORT(cmd_header) \
((cmd_header->ahcich_descr_info >> 12) & 0x0f)
#define SET_PORT_MULTI_PORT(cmd_header, flags) \
(cmd_header->ahcich_descr_info |= ((flags & 0x0f) << 12))
#define GET_CLEAR_BUSY_UPON_R_OK(cmd_header) \
((cmd_header->ahcich_descr_info >> 10) & 0x01)
#define SET_CLEAR_BUSY_UPON_R_OK(cmd_header, flags) \
(cmd_header->ahcich_descr_info |= ((flags & 0x01) << 10))
#define GET_BIST(cmd_header) \
((cmd_header->ahcich_descr_info >> 9) & 0x01)
#define GET_RESET(cmd_header) \
((cmd_header->ahcich_descr_info >> 8) & 0x01)
#define SET_RESET(cmd_header, features_exp) \
(cmd_header->ahcich_descr_info |= ((features_exp & 0x01) << 8))
#define GET_PREFETCHABLE(cmd_header) \
((cmd_header->ahcich_descr_info >> 7) & 0x01)
#define SET_PREFETCHABLE(cmd_header, flags) \
(cmd_header->ahcich_descr_info |= ((flags & 0x01) << 7))
#define GET_WRITE(cmd_header) \
((cmd_header->ahcich_descr_info >> 6) & 0x01)
#define SET_WRITE(cmd_header, flags) \
(cmd_header->ahcich_descr_info |= ((flags & 0x01) << 6))
#define GET_ATAPI(cmd_header) \
((cmd_header->ahcich_descr_info >> 5) & 0x01)
#define SET_ATAPI(cmd_header, flags) \
(cmd_header->ahcich_descr_info |= ((flags & 0x01) << 5))
#define GET_COMMAND_FIS_LENGTH(cmd_header) \
(cmd_header->ahcich_descr_info && 0x1f)
#define SET_COMMAND_FIS_LENGTH(cmd_header, length) \
(cmd_header->ahcich_descr_info |= (length & 0x1f))
uint32_t ahcich_prd_byte_count;
#define BZERO_PRD_BYTE_COUNT(cmd_header) \
(cmd_header->ahcich_prd_byte_count = 0)
uint32_t ahcich_cmd_tab_base_addr;
#define SET_COMMAND_TABLE_BASE_ADDR(cmd_header, base_address) \
(cmd_header->ahcich_cmd_tab_base_addr = base_address)
uint32_t ahcich_cmd_tab_base_addr_upper;
#define SET_COMMAND_TABLE_BASE_ADDR_UPPER(cmd_header, base_address) \
(cmd_header->ahcich_cmd_tab_base_addr_upper = base_address)
uint32_t ahcich_rsvd[4];
} ahci_cmd_header_t;
#ifdef __cplusplus
}
#endif
#endif