Changeset 04803bf in mainline for uspace/srv/bd/ata_bd/ata_bd.h


Ignore:
Timestamp:
2011-03-21T22:00:17Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
143932e3
Parents:
b50b5af2 (diff), 7308e84 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes (needs fixes).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/bd/ata_bd/ata_bd.h

    rb50b5af2 r04803bf  
    3030 * @{
    3131 */
    32 /** @file
     32/** @file ATA driver definitions.
    3333 */
    3434
     
    3737
    3838#include <sys/types.h>
    39 #include <fibril_sync.h>
     39#include <fibril_synch.h>
     40#include <str.h>
    4041
    41 enum {
    42         CTL_READ_START  = 0,
    43         CTL_WRITE_START = 1,
    44 };
    45 
    46 enum {
    47         STATUS_FAILURE  = 0
    48 };
    49 
    50 enum {
    51         MAX_DISKS       = 2
    52 };
    53 
    54 /** ATA Command Register Block. */
    55 typedef union {
    56         /* Read/Write */
    57         struct {
    58                 uint16_t data_port;
    59                 uint8_t sector_count;
    60                 uint8_t sector_number;
    61                 uint8_t cylinder_low;
    62                 uint8_t cylinder_high;
    63                 uint8_t drive_head;
    64                 uint8_t pad_rw0;               
    65         };
    66 
    67         /* Read Only */
    68         struct {
    69                 uint8_t pad_ro0;
    70                 uint8_t error;
    71                 uint8_t pad_ro1[5];
    72                 uint8_t status;
    73         };
    74 
    75         /* Write Only */
    76         struct {
    77                 uint8_t pad_wo0;
    78                 uint8_t features;
    79                 uint8_t pad_wo1[5];
    80                 uint8_t command;
    81         };
    82 } ata_cmd_t;
    83 
    84 typedef union {
    85         /* Read */
    86         struct {
    87                 uint8_t pad0[6];
    88                 uint8_t alt_status;
    89                 uint8_t drive_address;
    90         };
    91 
    92         /* Write */
    93         struct {
    94                 uint8_t pad1[6];
    95                 uint8_t device_control;
    96                 uint8_t pad2;
    97         };
    98 } ata_ctl_t;
    99 
    100 enum devctl_bits {
    101         DCR_SRST        = 0x04, /**< Software Reset */
    102         DCR_nIEN        = 0x02  /**< Interrupt Enable (negated) */
    103 };
    104 
    105 enum status_bits {
    106         SR_BSY          = 0x80, /**< Busy */
    107         SR_DRDY         = 0x40, /**< Drive Ready */
    108         SR_DWF          = 0x20, /**< Drive Write Fault */
    109         SR_DSC          = 0x10, /**< Drive Seek Complete */
    110         SR_DRQ          = 0x08, /**< Data Request */
    111         SR_CORR         = 0x04, /**< Corrected Data */
    112         SR_IDX          = 0x02, /**< Index */
    113         SR_ERR          = 0x01  /**< Error */
    114 };
    115 
    116 enum drive_head_bits {
    117         DHR_DRV         = 0x10
    118 };
    119 
    120 enum error_bits {
    121         ER_BBK          = 0x80, /**< Bad Block Detected */
    122         ER_UNC          = 0x40, /**< Uncorrectable Data Error */
    123         ER_MC           = 0x20, /**< Media Changed */
    124         ER_IDNF         = 0x10, /**< ID Not Found */
    125         ER_MCR          = 0x08, /**< Media Change Request */
    126         ER_ABRT         = 0x04, /**< Aborted Command */
    127         ER_TK0NF        = 0x02, /**< Track 0 Not Found */
    128         ER_AMNF         = 0x01  /**< Address Mark Not Found */
    129 };
    130 
    131 enum ata_command {
    132         CMD_IDENTIFY_DRIVE      = 0xEC,
    133         CMD_READ_SECTORS        = 0x20,
    134         CMD_WRITE_SECTORS       = 0x30
    135 };
     42/** Base addresses for ATA I/O blocks. */
     43typedef struct {
     44        uintptr_t cmd;  /**< Command block base address. */
     45        uintptr_t ctl;  /**< Control block base address. */
     46} ata_base_t;
    13647
    13748/** Timeout definitions. Unit is 10 ms. */
     
    14253};
    14354
     55enum ata_dev_type {
     56        ata_reg_dev,    /* Register device (no packet feature set support) */
     57        ata_pkt_dev     /* Packet device (supports packet feature set). */
     58};
     59
     60/** Register device block addressing mode. */
     61enum rd_addr_mode {
     62        am_chs,         /**< CHS block addressing */
     63        am_lba28,       /**< LBA-28 block addressing */
     64        am_lba48        /**< LBA-48 block addressing */
     65};
     66
     67/** Block coordinates */
     68typedef struct {
     69        enum rd_addr_mode amode;
     70
     71        union {
     72                /** CHS coordinates */
     73                struct {
     74                        uint8_t sector;
     75                        uint8_t cyl_lo;
     76                        uint8_t cyl_hi;
     77                };
     78                /** LBA coordinates */
     79                struct {
     80                        uint8_t c0;
     81                        uint8_t c1;
     82                        uint8_t c2;
     83                        uint8_t c3;
     84                        uint8_t c4;
     85                        uint8_t c5;
     86                };
     87        };
     88
     89        /** Lower 4 bits for device/head register */
     90        uint8_t h;
     91} block_coord_t;
     92
     93/** ATA device state structure. */
    14494typedef struct {
    14595        bool present;
    146         unsigned heads;
    147         unsigned cylinders;
    148         unsigned sectors;
     96
     97        /** Device type */
     98        enum ata_dev_type dev_type;
     99
     100        /** Addressing mode to use (if register device) */
     101        enum rd_addr_mode amode;
     102
     103        /*
     104         * Geometry. Only valid if operating in CHS mode.
     105         */
     106        struct {
     107                unsigned heads;
     108                unsigned cylinders;
     109                unsigned sectors;
     110        } geom;
     111
    149112        uint64_t blocks;
     113        size_t block_size;
     114
     115        char model[STR_BOUNDS(40) + 1];
    150116
    151117        fibril_mutex_t lock;
    152         dev_handle_t dev_handle;
     118        devmap_handle_t devmap_handle;
    153119} disk_t;
    154120
Note: See TracChangeset for help on using the changeset viewer.