Ignore:
File:
1 edited

Legend:

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

    reb3683a r730dce77  
    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
    4437
    4538/*----------------------------------------------------------------------------*/
     
    205198typedef union {
    206199        struct {
    207                 /** Header layout. */
     200                 /** Header layout. */
    208201                unsigned int hl : 7;
    209                 /** Multi function device flag. */
     202                /** Multi function device. */
    210203                unsigned int mfd : 1;
    211204        };
     
    288281typedef struct
    289282{
    290         /** Indicates the minimum grant time that the device
    291          * wishes grant asserted.
     283        /** Indicates the minimum grant time (in ? microseconds)
     284         * that the device wishes grant asserted.
    292285         */
    293286        uint8_t u8;
     
    304297/*-- AHCI Memory Registers ---------------------------------------------------*/
    305298/*----------------------------------------------------------------------------*/
    306 
    307 /** Number of pages for ahci memory registers. */
    308 #define AHCI_MEMREGS_PAGES_COUNT  8
    309299
    310300/** AHCI Memory register Generic Host Control - HBA Capabilities. */
     
    381371
    382372/** AHCI Memory register Interrupt pending register. */
    383 typedef 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
     373typedef 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;
    396379
    397380/** AHCI Memory register Ports implemented. */
     
    444427        /** Size of the transmit message buffer area in dwords. */
    445428        uint16_t sz;
    446         /*
    447          * Offset of the transmit message buffer area in dwords
     429        /* Offset of the transmit message buffer area in dwords
    448430         * from the beginning of ABAR
    449431         */
     
    480462                /** Activity LED hardware driven. */
    481463                unsigned int alhd : 1;
    482                 /** Port multiplier support. */
     464                /** port multiplier support. */
    483465                unsigned int pm : 1;
    484466                /** Reserved. */
     
    527509typedef struct
    528510{
    529         /** Host Capabilities */
     511        /** Host Capabilities. */
    530512        uint32_t cap;
    531         /** Global Host Control */
     513        /** Global Host Control. */
    532514        uint32_t ghc;
    533         /** Interrupt Status */
    534         ahci_ghc_is_t is;
    535         /** Ports Implemented */
     515        /** Interrupt Status. */
     516        uint32_t is;
     517        /** Ports Implemented. */
    536518        uint32_t pi;
    537         /** Version */
     519        /** Version. */
    538520        uint32_t vs;
    539         /** Command Completion Coalescing Control */
     521        /** Command Completion Coalescing Control. */
    540522        uint32_t ccc_ctl;
    541         /** Command Completion Coalescing Ports */
     523        /** Command Completion Coalsecing Ports. */
    542524        uint32_t ccc_ports;
    543         /** Enclosure Management Location */
     525        /** Enclosure Management Location. */
    544526        uint32_t em_loc;
    545         /** Enclosure Management Control */
     527        /** Enclosure Management Control. */
    546528        uint32_t em_ctl;
    547         /** Host Capabilities Extended */
     529        /** Host Capabilities Extended. */
    548530        uint32_t cap2;
    549         /** BIOS/OS Handoff Control and Status */
     531        /** BIOS/OS Handoff Control and Status. */
    550532        uint32_t bohc;
    551533} ahci_ghc_t;
     
    604586
    605587/** AHCI Memory register Port x Interrupt Status. */
    606 typedef uint32_t ahci_port_is_t;
     588typedef 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;
    607631
    608632#define AHCI_PORT_IS_DHRS  (1 << 0)
     
    659683static inline int ahci_port_is_end_of_operation(ahci_port_is_t port_is)
    660684{
    661         return port_is & AHCI_PORT_END_OF_OPERATION;
     685        return port_is.u32 & AHCI_PORT_END_OF_OPERATION;
    662686}
    663687
     
    671695static inline int ahci_port_is_error(ahci_port_is_t port_is)
    672696{
    673         return port_is & AHCI_PORT_IS_ERROR;
     697        return port_is.u32 & AHCI_PORT_IS_ERROR;
    674698}
    675699
     
    683707static inline int ahci_port_is_permanent_error(ahci_port_is_t port_is)
    684708{
    685         return port_is & AHCI_PORT_IS_PERMANENT_ERROR;
     709        return port_is.u32 & AHCI_PORT_IS_PERMANENT_ERROR;
    686710}
    687711
     
    695719static inline int ahci_port_is_tfes(ahci_port_is_t port_is)
    696720{
    697         return port_is & AHCI_PORT_IS_TFES;
     721        return port_is.u32 & AHCI_PORT_IS_TFES;
    698722}
    699723
     
    793817                 * Values:
    794818                 * 7h - fh Reserved,
    795                  * 6h Slumber - This shall cause the HBA to request a transition
    796                  * of the interface to the Slumber state,
     819                 * 6h Slumber - This shall cause the HBA to request a transition of the
     820                 *   interface to the Slumber state,
    797821                 * 3h - 5h Reserved,
    798                  * 2h Partial - This shall cause the HBA to request a transition
    799                  * of the interface to the Partial state,
     822                 * 2h Partial - This shall cause the HBA to request a transition of the
     823                 *   interface to the Partial state,
    800824                 * 1h Active,
    801825                 * 0h No-Op / Idle.
     
    832856                /** LBA Mid Register */
    833857                uint8_t lba_mr;
    834                 /** LBA High Register */
     858                /**  LBA High Register */
    835859                uint8_t lba_hr;
    836860        };
     
    852876        uint32_t u32;
    853877} ahci_port_ssts_t;
    854 
    855 /** Device detection active status. */
    856 #define AHCI_PORT_SSTS_DET_ACTIVE  3
    857878
    858879/** AHCI Memory register Port x Serial ATA Control (SCR2: SControl). */
     
    953974        uint32_t pxfbu;
    954975        /** Port x Interrupt Status. */
    955         ahci_port_is_t pxis;
     976        uint32_t pxis;
    956977        /** Port x Interrupt Enable. */
    957978        uint32_t pxie;
     
    9891010        ahci_ghc_t ghc;
    9901011        /** Reserved. */
    991         uint32_t reserved[13];
     1012        uint8_t reserved[52];
    9921013        /** Reserved for NVMHCI. */
    993         uint32_t reservedfornvmhci[16];
     1014        uint8_t reservedfornvmhci[64];
    9941015        /** Vendor Specific registers. */
    995         uint32_t vendorspecificsregs[24];
     1016        uint8_t vendorspecificsregs[96];
    9961017        /** Ports. */
    997         ahci_port_t ports[AHCI_MAX_PORTS];
     1018        ahci_port_t ports[32];
    9981019} ahci_memregs_t;
    9991020
    1000 /** AHCI Command header entry.
    1001  *
    1002  * This structure is not an AHCI register.
    1003  *
    1004  */
     1021/** AHCI Command header entry. */
    10051022typedef volatile struct {
    10061023        /** Flags. */
     
    10161033} ahci_cmdhdr_t;
    10171034
    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  */
     1035/** AHCI Command Physical Region Descriptor entry. */
    10351036typedef volatile struct {
    10361037        /** Word aligned 32-bit data base address. */
     
    10441045        /** Reserved */
    10451046        unsigned int reserved2 : 9;
    1046         /** Set Interrupt on each operation completion */
     1047        /** Interrupt on completion */
    10471048        unsigned int ioc : 1;
    10481049} ahci_cmd_prdt_t;
Note: See TracChangeset for help on using the changeset viewer.