Changeset 2791fbb7 in mainline for uspace/drv/block/ata_bd/ata_bd.h


Ignore:
Timestamp:
2024-05-16T16:17:49Z (8 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
59c0f478
Parents:
64cf7a3
Message:

Move generic ATA code out to libata

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/block/ata_bd/ata_bd.h

    r64cf7a3 r2791fbb7  
    3636#define __ATA_BD_H__
    3737
    38 #include <async.h>
    39 #include <bd_srv.h>
     38#include <ata/ata.h>
     39#include <ata/ata_hw.h>
    4040#include <ddf/driver.h>
    4141#include <fibril_synch.h>
    4242#include <stdbool.h>
    43 #include <str.h>
    4443#include <stdint.h>
    45 #include <stddef.h>
    46 #include "ata_hw.h"
    4744
    4845#define NAME "ata_bd"
     
    5451        int irq;        /**< IRQ */
    5552} ata_hwres_t;
    56 
    57 /** Timeout definitions. Unit is 10 ms. */
    58 enum ata_timeout {
    59         TIMEOUT_PROBE   =  100, /*  1 s */
    60         TIMEOUT_BSY     =  100, /*  1 s */
    61         TIMEOUT_DRDY    = 1000  /* 10 s */
    62 };
    63 
    64 enum ata_dev_type {
    65         ata_reg_dev,    /* Register device (no packet feature set support) */
    66         ata_pkt_dev     /* Packet device (supports packet feature set). */
    67 };
    68 
    69 /** Register device block addressing mode. */
    70 enum rd_addr_mode {
    71         am_chs,         /**< CHS block addressing */
    72         am_lba28,       /**< LBA-28 block addressing */
    73         am_lba48        /**< LBA-48 block addressing */
    74 };
    75 
    76 /** Block coordinates */
    77 typedef struct {
    78         enum rd_addr_mode amode;
    79 
    80         union {
    81                 /** CHS coordinates */
    82                 struct {
    83                         uint8_t sector;
    84                         uint8_t cyl_lo;
    85                         uint8_t cyl_hi;
    86                 };
    87                 /** LBA coordinates */
    88                 struct {
    89                         uint8_t c0;
    90                         uint8_t c1;
    91                         uint8_t c2;
    92                         uint8_t c3;
    93                         uint8_t c4;
    94                         uint8_t c5;
    95                 };
    96         };
    97 
    98         /** Lower 4 bits for device/head register */
    99         uint8_t h;
    100 } block_coord_t;
    101 
    102 /** ATA device state structure. */
    103 typedef struct {
    104         bool present;
    105         struct ata_ctrl *ctrl;
    106         struct ata_fun *afun;
    107 
    108         /** Device type */
    109         enum ata_dev_type dev_type;
    110 
    111         /** Addressing mode to use (if register device) */
    112         enum rd_addr_mode amode;
    113 
    114         /*
    115          * Geometry. Only valid if operating in CHS mode.
    116          */
    117         struct {
    118                 unsigned heads;
    119                 unsigned cylinders;
    120                 unsigned sectors;
    121         } geom;
    122 
    123         uint64_t blocks;
    124         size_t block_size;
    125 
    126         char model[STR_BOUNDS(40) + 1];
    127 
    128         int disk_id;
    129 } disk_t;
    13053
    13154/** ATA controller */
     
    14770        cap_irq_handle_t ihandle;
    14871
    149         /** Per-disk state. */
    150         disk_t disk[MAX_DISKS];
    151 
    15272        /** Synchronize controller access */
    15373        fibril_mutex_t lock;
    154         /** Synchronize access to irq_fired/irq_status */
    155         fibril_mutex_t irq_lock;
    156         /** Signalled by IRQ handler */
    157         fibril_condvar_t irq_cv;
    158         /** Set to true when interrupt occurs */
    159         bool irq_fired;
    16074        /** Value of status register read by interrupt handler */
    16175        uint8_t irq_status;
     76
     77        /** Libata ATA channel */
     78        ata_channel_t *channel;
     79        struct ata_fun *fun[2];
    16280} ata_ctrl_t;
    16381
    16482typedef struct ata_fun {
    16583        ddf_fun_t *fun;
    166         disk_t *disk;
    167         bd_srvs_t bds;
     84        void *charg;
    16885} ata_fun_t;
    16986
     
    17289extern errno_t ata_ctrl_gone(ata_ctrl_t *);
    17390
    174 extern bd_ops_t ata_bd_ops;
    175 
    17691#endif
    17792
Note: See TracChangeset for help on using the changeset viewer.