Changeset 3de67b4c in mainline for uspace/drv/block/ata_bd/main.c


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).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.");
Note: See TracChangeset for help on using the changeset viewer.