Changeset 3de67b4c in mainline


Ignore:
Timestamp:
2013-06-27T20:43:29Z (11 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4339f09
Parents:
9f391e9
Message:

ata_bd needs to use hw_res (PIO resource configration protcol).

Location:
uspace/drv
Files:
4 edited

Legend:

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

    r9f391e9 r3de67b4c  
    8181 */
    8282static const size_t identify_data_size = 512;
    83 
    84 /** I/O base addresses for legacy (ISA-compatible) controllers. */
    85 static ata_base_t legacy_base[LEGACY_CTLS] = {
    86         { 0x1f0, 0x3f0 },
    87         { 0x170, 0x370 },
    88         { 0x1e8, 0x3e8 },
    89         { 0x168, 0x368 }
    90 };
    9183
    9284static int ata_bd_init_io(ata_ctrl_t *ctrl);
     
    145137
    146138/** Initialize ATA controller. */
    147 int ata_ctrl_init(ata_ctrl_t *ctrl)
     139int ata_ctrl_init(ata_ctrl_t *ctrl, ata_base_t *res)
    148140{
    149141        int i, rc;
    150142        int n_disks;
    151         unsigned ctl_num;
    152143
    153144        ddf_msg(LVL_DEBUG, "ata_ctrl_init()");
    154145
    155         ctl_num = 1;
    156 
    157146        fibril_mutex_initialize(&ctrl->lock);
    158         ctrl->cmd_physical = legacy_base[ctl_num - 1].cmd;
    159         ctrl->ctl_physical = legacy_base[ctl_num - 1].ctl;
     147        ctrl->cmd_physical = res->cmd;
     148        ctrl->ctl_physical = res->ctl;
    160149
    161150        ddf_msg(LVL_NOTE, "I/O address %p/%p", (void *) ctrl->cmd_physical,
  • uspace/drv/block/ata_bd/ata_bd.h

    r9f391e9 r3de67b4c  
    152152} ata_fun_t;
    153153
    154 extern int ata_ctrl_init(ata_ctrl_t *);
     154extern int ata_ctrl_init(ata_ctrl_t *, ata_base_t *);
    155155extern int ata_ctrl_remove(ata_ctrl_t *);
    156156extern int ata_ctrl_gone(ata_ctrl_t *);
  • uspace/drv/block/ata_bd/main.c

    r9f391e9 r3de67b4c  
    3636#include <ddf/driver.h>
    3737#include <ddf/log.h>
     38#include <device/hw_res_parsed.h>
    3839
    3940#include "ata_bd.h"
     
    6162};
    6263
     64static int ata_get_res(ddf_dev_t *dev, ata_base_t *ata_res)
     65{
     66        async_sess_t *parent_sess;
     67        hw_res_list_parsed_t hw_res;
     68        int rc;
     69
     70        parent_sess = ddf_dev_parent_sess_create(dev,
     71            EXCHANGE_SERIALIZE);
     72        if (parent_sess == NULL)
     73                return ENOMEM;
     74
     75        hw_res_list_parsed_init(&hw_res);
     76        rc = hw_res_get_list_parsed(parent_sess, &hw_res, 0);
     77        if (rc != EOK)
     78                return rc;
     79
     80        if (hw_res.io_ranges.count != 2) {
     81                rc = EINVAL;
     82                goto error;
     83                return EINVAL;
     84        }
     85
     86        ata_res->cmd = hw_res.io_ranges.ranges[0].address;
     87        ata_res->ctl = hw_res.io_ranges.ranges[1].address;
     88
     89        if (hw_res.io_ranges.ranges[0].size < sizeof(ata_ctl_t)) {
     90                rc = EINVAL;
     91                goto error;
     92        }
     93
     94        if (hw_res.io_ranges.ranges[1].size < sizeof(ata_cmd_t)) {
     95                rc = EINVAL;
     96                goto error;
     97        }
     98
     99        return EOK;
     100error:
     101        hw_res_list_parsed_clean(&hw_res);
     102        return rc;
     103}
    63104
    64105/** Add new device
     
    70111{
    71112        ata_ctrl_t *ctrl;
    72         int rc;
     113        ata_base_t res;
     114        int rc;
     115
     116        rc = ata_get_res(dev, &res);
     117        if (rc != EOK) {
     118                ddf_msg(LVL_ERROR, "Invalid HW resource configuration.");
     119                return EINVAL;
     120        }
    73121
    74122        ctrl = ddf_dev_data_alloc(dev, sizeof(ata_ctrl_t));
     
    81129        ctrl->dev = dev;
    82130
    83         rc = ata_ctrl_init(ctrl);
     131        rc = ata_ctrl_init(ctrl, &res);
    84132        if (rc != EOK) {
    85133                ddf_msg(LVL_ERROR, "Failed initializing ATA controller.");
  • uspace/drv/bus/isa/isa.dev

    r9f391e9 r3de67b4c  
    3232        io_range 70 2
    3333
    34 ata_bd:
     34ata-c1:
    3535        match 100 isa/ata_bd
     36        io_range 0x1f0 8
     37        io_range 0x3f0 8
     38
     39ata-c2:
     40        match 100 isa/ata_bd
     41        io_range 0x170 8
     42        io_range 0x370 8
     43
     44ata-c3:
     45        match 100 isa/ata_bd
     46        io_range 0x1e8 8
     47        io_range 0x3e8 8
     48
     49ata-c4:
     50        match 100 isa/ata_bd
     51        io_range 0x168 8
     52        io_range 0x368 8
Note: See TracChangeset for help on using the changeset viewer.