Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/block/ahci/ahci_hw.h

    r730dce77 reb3683a  
    3535
    3636#include <sys/types.h>
     37
     38/*----------------------------------------------------------------------------*/
     39/*-- AHCI standard constants -------------------------------------------------*/
     40/*----------------------------------------------------------------------------*/
     41
     42/** AHCI standard 1.3 - maximum ports. */
     43#define AHCI_MAX_PORTS  32
    3744
    3845/*----------------------------------------------------------------------------*/
     
    198205typedef union {
    199206        struct {
    200                  /** Header layout. */
     207                /** Header layout. */
    201208                unsigned int hl : 7;
    202                 /** Multi function device. */
     209                /** Multi function device flag. */
    203210                unsigned int mfd : 1;
    204211        };
     
    281288typedef struct
    282289{
    283         /** Indicates the minimum grant time (in ? microseconds)
    284          * that the device wishes grant asserted.
     290        /** Indicates the minimum grant time that the device
     291         * wishes grant asserted.
    285292         */
    286293        uint8_t u8;
     
    297304/*-- AHCI Memory Registers ---------------------------------------------------*/
    298305/*----------------------------------------------------------------------------*/
     306
     307/** Number of pages for ahci memory registers. */
     308#define AHCI_MEMREGS_PAGES_COUNT  8
    299309
    300310/** AHCI Memory register Generic Host Control - HBA Capabilities. */
     
    371381
    372382/** AHCI Memory register Interrupt pending register. */
    373 typedef struct {
    374         /** Interrupt pending status, if set, indicates that
    375          * the corresponding port has an interrupt pending.
    376          */
    377         uint32_t u32;
    378 } ahci_ghc_is_t;
     383typedef uint32_t ahci_ghc_is_t;
     384
     385/** AHCI GHC register offset. */
     386#define AHCI_GHC_IS_REGISTER_OFFSET  2
     387
     388/** AHCI ports registers offset. */
     389#define AHCI_PORTS_REGISTERS_OFFSET  64
     390
     391/** AHCI port registers size. */
     392#define AHCI_PORT_REGISTERS_SIZE  32
     393
     394/** AHCI port IS register offset. */
     395#define AHCI_PORT_IS_REGISTER_OFFSET  4
    379396
    380397/** AHCI Memory register Ports implemented. */
     
    427444        /** Size of the transmit message buffer area in dwords. */
    428445        uint16_t sz;
    429         /* Offset of the transmit message buffer area in dwords
     446        /*
     447         * Offset of the transmit message buffer area in dwords
    430448         * from the beginning of ABAR
    431449         */
     
    462480                /** Activity LED hardware driven. */
    463481                unsigned int alhd : 1;
    464                 /** port multiplier support. */
     482                /** Port multiplier support. */
    465483                unsigned int pm : 1;
    466484                /** Reserved. */
     
    509527typedef struct
    510528{
    511         /** Host Capabilities. */
     529        /** Host Capabilities */
    512530        uint32_t cap;
    513         /** Global Host Control. */
     531        /** Global Host Control */
    514532        uint32_t ghc;
    515         /** Interrupt Status. */
    516         uint32_t is;
    517         /** Ports Implemented. */
     533        /** Interrupt Status */
     534        ahci_ghc_is_t is;
     535        /** Ports Implemented */
    518536        uint32_t pi;
    519         /** Version. */
     537        /** Version */
    520538        uint32_t vs;
    521         /** Command Completion Coalescing Control. */
     539        /** Command Completion Coalescing Control */
    522540        uint32_t ccc_ctl;
    523         /** Command Completion Coalsecing Ports. */
     541        /** Command Completion Coalescing Ports */
    524542        uint32_t ccc_ports;
    525         /** Enclosure Management Location. */
     543        /** Enclosure Management Location */
    526544        uint32_t em_loc;
    527         /** Enclosure Management Control. */
     545        /** Enclosure Management Control */
    528546        uint32_t em_ctl;
    529         /** Host Capabilities Extended. */
     547        /** Host Capabilities Extended */
    530548        uint32_t cap2;
    531         /** BIOS/OS Handoff Control and Status. */
     549        /** BIOS/OS Handoff Control and Status */
    532550        uint32_t bohc;
    533551} ahci_ghc_t;
     
    586604
    587605/** AHCI Memory register Port x Interrupt Status. */
    588 typedef union {
    589         struct {
    590                 /** Device to Host Register FIS Interrupt. */
    591                 unsigned int dhrs : 1;
    592                 /** PIO Setup FIS Interrupt. */
    593                 unsigned int pss : 1;
    594                 /** DMA Setup FIS Interrupt. */
    595                 unsigned int dss : 1;
    596                 /** Set Device Bits Interrupt. */
    597                 unsigned int sdbs : 1;
    598                 /** Unknown FIS Interrupt. */
    599                 unsigned int ufs : 1;
    600                 /** Descriptor Processed. */
    601                 unsigned int dps : 1;
    602                 /** Port Connect Change Status. */
    603                 unsigned int pcs : 1;
    604                 /** Device Mechanical Presence Status. */
    605                 unsigned int dmps : 1;
    606                 /** Reserved. */
    607                 unsigned int reserved1 : 14;
    608                 /** PhyRdy Change Status. */
    609                 unsigned int prcs : 1;
    610                 /** Incorrect Port Multiplier Status. */
    611                 unsigned int ipms : 1;
    612                 /** Overflow Status. */
    613                 unsigned int ofs : 1;
    614                 /** Reserved. */
    615                 unsigned int reserved2 : 1;
    616                 /** Interface Non-fatal Error Status. */
    617                 unsigned int infs : 1;
    618                 /** Interface Fatal Error Status. */
    619                 unsigned int ifs : 1;
    620                 /** Host Bus Data Error Status. */
    621                 unsigned int hbds : 1;
    622                 /** Host Bus Fatal Error Status. */
    623                 unsigned int hbfs : 1;
    624                 /** Task File Error Status. */
    625                 unsigned int tfes : 1;
    626                 /** Cold Port Detect Status. */
    627                 unsigned int cpds : 1;
    628         };
    629         uint32_t u32;
    630 } ahci_port_is_t;
     606typedef uint32_t ahci_port_is_t;
    631607
    632608#define AHCI_PORT_IS_DHRS  (1 << 0)
     
    683659static inline int ahci_port_is_end_of_operation(ahci_port_is_t port_is)
    684660{
    685         return port_is.u32 & AHCI_PORT_END_OF_OPERATION;
     661        return port_is & AHCI_PORT_END_OF_OPERATION;
    686662}
    687663
     
    695671static inline int ahci_port_is_error(ahci_port_is_t port_is)
    696672{
    697         return port_is.u32 & AHCI_PORT_IS_ERROR;
     673        return port_is & AHCI_PORT_IS_ERROR;
    698674}
    699675
     
    707683static inline int ahci_port_is_permanent_error(ahci_port_is_t port_is)
    708684{
    709         return port_is.u32 & AHCI_PORT_IS_PERMANENT_ERROR;
     685        return port_is & AHCI_PORT_IS_PERMANENT_ERROR;
    710686}
    711687
     
    719695static inline int ahci_port_is_tfes(ahci_port_is_t port_is)
    720696{
    721         return port_is.u32 & AHCI_PORT_IS_TFES;
     697        return port_is & AHCI_PORT_IS_TFES;
    722698}
    723699
     
    817793                 * Values:
    818794                 * 7h - fh Reserved,
    819                  * 6h Slumber - This shall cause the HBA to request a transition of the
    820                  *   interface to the Slumber state,
     795                 * 6h Slumber - This shall cause the HBA to request a transition
     796                 * of the interface to the Slumber state,
    821797                 * 3h - 5h Reserved,
    822                  * 2h Partial - This shall cause the HBA to request a transition of the
    823                  *   interface to the Partial state,
     798                 * 2h Partial - This shall cause the HBA to request a transition
     799                 * of the interface to the Partial state,
    824800                 * 1h Active,
    825801                 * 0h No-Op / Idle.
     
    856832                /** LBA Mid Register */
    857833                uint8_t lba_mr;
    858                 /**  LBA High Register */
     834                /** LBA High Register */
    859835                uint8_t lba_hr;
    860836        };
     
    876852        uint32_t u32;
    877853} ahci_port_ssts_t;
     854
     855/** Device detection active status. */
     856#define AHCI_PORT_SSTS_DET_ACTIVE  3
    878857
    879858/** AHCI Memory register Port x Serial ATA Control (SCR2: SControl). */
     
    974953        uint32_t pxfbu;
    975954        /** Port x Interrupt Status. */
    976         uint32_t pxis;
     955        ahci_port_is_t pxis;
    977956        /** Port x Interrupt Enable. */
    978957        uint32_t pxie;
     
    1010989        ahci_ghc_t ghc;
    1011990        /** Reserved. */
    1012         uint8_t reserved[52];
     991        uint32_t reserved[13];
    1013992        /** Reserved for NVMHCI. */
    1014         uint8_t reservedfornvmhci[64];
     993        uint32_t reservedfornvmhci[16];
    1015994        /** Vendor Specific registers. */
    1016         uint8_t vendorspecificsregs[96];
     995        uint32_t vendorspecificsregs[24];
    1017996        /** Ports. */
    1018         ahci_port_t ports[32];
     997        ahci_port_t ports[AHCI_MAX_PORTS];
    1019998} ahci_memregs_t;
    1020999
    1021 /** AHCI Command header entry. */
     1000/** AHCI Command header entry.
     1001 *
     1002 * This structure is not an AHCI register.
     1003 *
     1004 */
    10221005typedef volatile struct {
    10231006        /** Flags. */
     
    10331016} ahci_cmdhdr_t;
    10341017
    1035 /** AHCI Command Physical Region Descriptor entry. */
     1018/** Clear Busy upon R_OK (C) flag. */
     1019#define AHCI_CMDHDR_FLAGS_CLEAR_BUSY_UPON_OK  0x0400
     1020
     1021/** Write operation flag. */
     1022#define AHCI_CMDHDR_FLAGS_WRITE  0x0040
     1023
     1024/** 2 DW length command flag. */
     1025#define AHCI_CMDHDR_FLAGS_2DWCMD  0x0002
     1026
     1027/** 5 DW length command flag. */
     1028#define AHCI_CMDHDR_FLAGS_5DWCMD  0x0005
     1029
     1030/** AHCI Command Physical Region Descriptor entry.
     1031 *
     1032 * This structure is not an AHCI register.
     1033 *
     1034 */
    10361035typedef volatile struct {
    10371036        /** Word aligned 32-bit data base address. */
     
    10451044        /** Reserved */
    10461045        unsigned int reserved2 : 9;
    1047         /** Interrupt on completion */
     1046        /** Set Interrupt on each operation completion */
    10481047        unsigned int ioc : 1;
    10491048} ahci_cmd_prdt_t;
Note: See TracChangeset for help on using the changeset viewer.