Changeset 59c0f478 in mainline for uspace/drv/block/isa-ide/isa-ide.c


Ignore:
Timestamp:
2024-05-16T18:20:35Z (8 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
646849b3
Parents:
2791fbb7
Message:

Rename ata_bd → isa-ide

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/drv/block/isa-ide/isa-ide.c

    r2791fbb7 r59c0f478  
    2727 */
    2828
    29 /** @addtogroup ata_bd
     29/** @addtogroup isa-ide
    3030 * @{
    3131 */
     
    3333/**
    3434 * @file
    35  * @brief ISA ATA driver
     35 * @brief ISA IDE driver
    3636 *
    3737 * The driver services a single IDE channel.
     
    5252#include <errno.h>
    5353
    54 #include "ata_bd.h"
     54#include "isa-ide.h"
    5555#include "main.h"
    5656
    57 #define NAME       "ata_bd"
    58 
    59 static errno_t ata_bd_init_io(ata_ctrl_t *ctrl);
    60 static void ata_bd_fini_io(ata_ctrl_t *ctrl);
    61 static errno_t ata_bd_init_irq(ata_ctrl_t *ctrl);
    62 static void ata_bd_fini_irq(ata_ctrl_t *ctrl);
    63 static void ata_irq_handler(ipc_call_t *call, ddf_dev_t *dev);
    64 
    65 static void ata_write_data_16(void *, uint16_t *, size_t);
    66 static void ata_read_data_16(void *, uint16_t *, size_t);
    67 static void ata_write_cmd_8(void *, uint16_t, uint8_t);
    68 static uint8_t ata_read_cmd_8(void *, uint16_t);
    69 static void ata_write_ctl_8(void *, uint16_t, uint8_t);
    70 static uint8_t ata_read_ctl_8(void *, uint16_t);
    71 static errno_t ata_irq_enable(void *);
    72 static errno_t ata_irq_disable(void *);
    73 static errno_t ata_add_device(void *, unsigned, void *);
    74 static errno_t ata_remove_device(void *, unsigned);
    75 static void ata_msg_debug(void *, char *);
    76 static void ata_msg_note(void *, char *);
    77 static void ata_msg_warn(void *, char *);
    78 static void ata_msg_error(void *, char *);
    79 
    80 static const irq_pio_range_t ata_irq_ranges[] = {
     57static errno_t isa_ide_init_io(isa_ide_ctrl_t *ctrl);
     58static void isa_ide_fini_io(isa_ide_ctrl_t *ctrl);
     59static errno_t isa_ide_init_irq(isa_ide_ctrl_t *ctrl);
     60static void isa_ide_fini_irq(isa_ide_ctrl_t *ctrl);
     61static void isa_ide_irq_handler(ipc_call_t *call, ddf_dev_t *dev);
     62
     63static void isa_ide_write_data_16(void *, uint16_t *, size_t);
     64static void isa_ide_read_data_16(void *, uint16_t *, size_t);
     65static void isa_ide_write_cmd_8(void *, uint16_t, uint8_t);
     66static uint8_t isa_ide_read_cmd_8(void *, uint16_t);
     67static void isa_ide_write_ctl_8(void *, uint16_t, uint8_t);
     68static uint8_t isa_ide_read_ctl_8(void *, uint16_t);
     69static errno_t isa_ide_irq_enable(void *);
     70static errno_t isa_ide_irq_disable(void *);
     71static errno_t isa_ide_add_device(void *, unsigned, void *);
     72static errno_t isa_ide_remove_device(void *, unsigned);
     73static void isa_ide_msg_debug(void *, char *);
     74static void isa_ide_msg_note(void *, char *);
     75static void isa_ide_msg_warn(void *, char *);
     76static void isa_ide_msg_error(void *, char *);
     77
     78static const irq_pio_range_t isa_ide_irq_ranges[] = {
    8179        {
    8280                .base = 0,
     
    8583};
    8684
    87 /** ATA interrupt pseudo code. */
    88 static const irq_cmd_t ata_irq_cmds[] = {
     85/** IDE interrupt pseudo code. */
     86static const irq_cmd_t isa_ide_irq_cmds[] = {
    8987        {
    9088                .cmd = CMD_PIO_READ_8,
     
    9795};
    9896
    99 /** Initialize ATA controller. */
    100 errno_t ata_ctrl_init(ata_ctrl_t *ctrl, ata_hwres_t *res)
     97/** Initialize ISA IDE controller. */
     98errno_t isa_ide_ctrl_init(isa_ide_ctrl_t *ctrl, isa_ide_hwres_t *res)
    10199{
    102100        errno_t rc;
     
    104102        ata_params_t params;
    105103
    106         ddf_msg(LVL_DEBUG, "ata_ctrl_init()");
     104        ddf_msg(LVL_DEBUG, "isa_ide_ctrl_init()");
    107105
    108106        fibril_mutex_initialize(&ctrl->lock);
     
    115113
    116114        ddf_msg(LVL_DEBUG, "Init I/O");
    117         rc = ata_bd_init_io(ctrl);
     115        rc = isa_ide_init_io(ctrl);
    118116        if (rc != EOK)
    119117                return rc;
    120118
    121119        ddf_msg(LVL_DEBUG, "Init IRQ");
    122         rc = ata_bd_init_irq(ctrl);
     120        rc = isa_ide_init_irq(ctrl);
    123121        if (rc != EOK) {
    124122                ddf_msg(LVL_NOTE, "init IRQ failed");
     
    128126        irq_inited = true;
    129127
    130         ddf_msg(LVL_DEBUG, "ata_ctrl_init(): Initialize ATA channel");
     128        ddf_msg(LVL_DEBUG, "isa_ide_ctrl_init(): Initialize IDE channel");
    131129
    132130        params.arg = (void *)ctrl;
    133131        params.have_irq = (ctrl->irq >= 0) ? true : false;
    134         params.write_data_16 = ata_write_data_16;
    135         params.read_data_16 = ata_read_data_16;
    136         params.write_cmd_8 = ata_write_cmd_8;
    137         params.read_cmd_8 = ata_read_cmd_8;
    138         params.write_ctl_8 = ata_write_ctl_8;
    139         params.read_ctl_8 = ata_read_ctl_8;
    140         params.irq_enable = ata_irq_enable;
    141         params.irq_disable = ata_irq_disable;
    142         params.add_device = ata_add_device;
    143         params.remove_device = ata_remove_device;
    144         params.msg_debug = ata_msg_debug;
    145         params.msg_note = ata_msg_note;
    146         params.msg_warn = ata_msg_warn;
    147         params.msg_error = ata_msg_error;
     132        params.write_data_16 = isa_ide_write_data_16;
     133        params.read_data_16 = isa_ide_read_data_16;
     134        params.write_cmd_8 = isa_ide_write_cmd_8;
     135        params.read_cmd_8 = isa_ide_read_cmd_8;
     136        params.write_ctl_8 = isa_ide_write_ctl_8;
     137        params.read_ctl_8 = isa_ide_read_ctl_8;
     138        params.irq_enable = isa_ide_irq_enable;
     139        params.irq_disable = isa_ide_irq_disable;
     140        params.add_device = isa_ide_add_device;
     141        params.remove_device = isa_ide_remove_device;
     142        params.msg_debug = isa_ide_msg_debug;
     143        params.msg_note = isa_ide_msg_note;
     144        params.msg_warn = isa_ide_msg_warn;
     145        params.msg_error = isa_ide_msg_error;
    148146
    149147        rc = ata_channel_create(&params, &ctrl->channel);
     
    155153                goto error;
    156154
    157         ddf_msg(LVL_DEBUG, "ata_ctrl_init: DONE");
     155        ddf_msg(LVL_DEBUG, "isa_ide_ctrl_init: DONE");
    158156        return EOK;
    159157error:
    160158        if (irq_inited)
    161                 ata_bd_fini_irq(ctrl);
    162         ata_bd_fini_io(ctrl);
     159                isa_ide_fini_irq(ctrl);
     160        isa_ide_fini_io(ctrl);
    163161        return rc;
    164162}
    165163
    166 /** Remove ATA controller. */
    167 errno_t ata_ctrl_remove(ata_ctrl_t *ctrl)
    168 {
    169         errno_t rc;
    170 
    171         ddf_msg(LVL_DEBUG, ": ata_ctrl_remove()");
     164/** Remove ISA IDE controller. */
     165errno_t isa_ide_ctrl_remove(isa_ide_ctrl_t *ctrl)
     166{
     167        errno_t rc;
     168
     169        ddf_msg(LVL_DEBUG, ": isa_ide_ctrl_remove()");
    172170
    173171        fibril_mutex_lock(&ctrl->lock);
     
    179177        }
    180178
    181         ata_bd_fini_irq(ctrl);
    182         ata_bd_fini_io(ctrl);
     179        isa_ide_fini_irq(ctrl);
     180        isa_ide_fini_io(ctrl);
    183181        fibril_mutex_unlock(&ctrl->lock);
    184182
     
    186184}
    187185
    188 /** Surprise removal of ATA controller. */
    189 errno_t ata_ctrl_gone(ata_ctrl_t *ctrl)
    190 {
    191         errno_t rc;
    192 
    193         ddf_msg(LVL_DEBUG, "ata_ctrl_gone()");
     186/** Surprise removal of ISA IDE controller. */
     187errno_t isa_ide_ctrl_gone(isa_ide_ctrl_t *ctrl)
     188{
     189        errno_t rc;
     190
     191        ddf_msg(LVL_DEBUG, "isa_ide_ctrl_gone()");
    194192
    195193        fibril_mutex_lock(&ctrl->lock);
     
    201199        }
    202200
    203         ata_bd_fini_io(ctrl);
     201        isa_ide_fini_io(ctrl);
    204202        fibril_mutex_unlock(&ctrl->lock);
    205203
     
    208206
    209207/** Enable device I/O. */
    210 static errno_t ata_bd_init_io(ata_ctrl_t *ctrl)
     208static errno_t isa_ide_init_io(isa_ide_ctrl_t *ctrl)
    211209{
    212210        errno_t rc;
     
    232230
    233231/** Clean up device I/O. */
    234 static void ata_bd_fini_io(ata_ctrl_t *ctrl)
     232static void isa_ide_fini_io(isa_ide_ctrl_t *ctrl)
    235233{
    236234        (void) ctrl;
     
    239237
    240238/** Initialize IRQ. */
    241 static errno_t ata_bd_init_irq(ata_ctrl_t *ctrl)
     239static errno_t isa_ide_init_irq(isa_ide_ctrl_t *ctrl)
    242240{
    243241        irq_code_t irq_code;
     
    249247                return EOK;
    250248
    251         ranges = malloc(sizeof(ata_irq_ranges));
     249        ranges = malloc(sizeof(isa_ide_irq_ranges));
    252250        if (ranges == NULL)
    253251                return ENOMEM;
    254252
    255         cmds = malloc(sizeof(ata_irq_cmds));
     253        cmds = malloc(sizeof(isa_ide_irq_cmds));
    256254        if (cmds == NULL) {
    257255                free(cmds);
     
    259257        }
    260258
    261         memcpy(ranges, &ata_irq_ranges, sizeof(ata_irq_ranges));
     259        memcpy(ranges, &isa_ide_irq_ranges, sizeof(isa_ide_irq_ranges));
    262260        ranges[0].base = ctrl->cmd_physical;
    263         memcpy(cmds, &ata_irq_cmds, sizeof(ata_irq_cmds));
     261        memcpy(cmds, &isa_ide_irq_cmds, sizeof(isa_ide_irq_cmds));
    264262        cmds[0].addr = &ctrl->cmd->status;
    265263
    266         irq_code.rangecount = sizeof(ata_irq_ranges) / sizeof(irq_pio_range_t);
     264        irq_code.rangecount = sizeof(isa_ide_irq_ranges) / sizeof(irq_pio_range_t);
    267265        irq_code.ranges = ranges;
    268         irq_code.cmdcount = sizeof(ata_irq_cmds) / sizeof(irq_cmd_t);
     266        irq_code.cmdcount = sizeof(isa_ide_irq_cmds) / sizeof(irq_cmd_t);
    269267        irq_code.cmds = cmds;
    270268
    271269        ddf_msg(LVL_NOTE, "IRQ %d", ctrl->irq);
    272         rc = register_interrupt_handler(ctrl->dev, ctrl->irq, ata_irq_handler,
     270        rc = register_interrupt_handler(ctrl->dev, ctrl->irq, isa_ide_irq_handler,
    273271            &irq_code, &ctrl->ihandle);
    274272        if (rc != EOK) {
     
    288286
    289287/** Clean up IRQ. */
    290 static void ata_bd_fini_irq(ata_ctrl_t *ctrl)
     288static void isa_ide_fini_irq(isa_ide_ctrl_t *ctrl)
    291289{
    292290        errno_t rc;
     
    307305 * @param dev Device that caused the interrupt
    308306 */
    309 static void ata_irq_handler(ipc_call_t *call, ddf_dev_t *dev)
    310 {
    311         ata_ctrl_t *ctrl = (ata_ctrl_t *)ddf_dev_data_get(dev);
     307static void isa_ide_irq_handler(ipc_call_t *call, ddf_dev_t *dev)
     308{
     309        isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)ddf_dev_data_get(dev);
    312310        uint8_t status;
    313311        async_sess_t *parent_sess;
     
    322320/** Write the data register callback handler.
    323321 *
    324  * @param arg Argument (ata_ctrl_t *)
     322 * @param arg Argument (isa_ide_ctrl_t *)
    325323 * @param data Data
    326324 * @param nwords Number of words to write
    327325 */
    328 static void ata_write_data_16(void *arg, uint16_t *data, size_t nwords)
    329 {
    330         ata_ctrl_t *ctrl = (ata_ctrl_t *)arg;
     326static void isa_ide_write_data_16(void *arg, uint16_t *data, size_t nwords)
     327{
     328        isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)arg;
    331329        size_t i;
    332330
     
    337335/** Read the data register callback handler.
    338336 *
    339  * @param arg Argument (ata_ctrl_t *)
     337 * @param arg Argument (isa_ide_ctrl_t *)
    340338 * @param buf Destination buffer
    341339 * @param nwords Number of words to read
    342340 */
    343 static void ata_read_data_16(void *arg, uint16_t *buf, size_t nwords)
    344 {
    345         ata_ctrl_t *ctrl = (ata_ctrl_t *)arg;
     341static void isa_ide_read_data_16(void *arg, uint16_t *buf, size_t nwords)
     342{
     343        isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)arg;
    346344        size_t i;
    347345
     
    352350/** Write command register callback handler.
    353351 *
    354  * @param arg Argument (ata_ctrl_t *)
     352 * @param arg Argument (isa_ide_ctrl_t *)
    355353 * @param off Register offset
    356354 * @param value Value to write to command register
    357355 */
    358 static void ata_write_cmd_8(void *arg, uint16_t off, uint8_t value)
    359 {
    360         ata_ctrl_t *ctrl = (ata_ctrl_t *)arg;
     356static void isa_ide_write_cmd_8(void *arg, uint16_t off, uint8_t value)
     357{
     358        isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)arg;
    361359
    362360        pio_write_8(((ioport8_t *)ctrl->cmd) + off, value);
     
    365363/** Read command register callback handler.
    366364 *
    367  * @param arg Argument (ata_ctrl_t *)
     365 * @param arg Argument (isa_ide_ctrl_t *)
    368366 * @param off Register offset
    369367 * @return value Value read from command register
    370368 */
    371 static uint8_t ata_read_cmd_8(void *arg, uint16_t off)
    372 {
    373         ata_ctrl_t *ctrl = (ata_ctrl_t *)arg;
     369static uint8_t isa_ide_read_cmd_8(void *arg, uint16_t off)
     370{
     371        isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)arg;
    374372
    375373        return pio_read_8(((ioport8_t *)ctrl->cmd) + off);
     
    378376/** Write control register callback handler.
    379377 *
    380  * @param arg Argument (ata_ctrl_t *)
     378 * @param arg Argument (isa_ide_ctrl_t *)
    381379 * @param off Register offset
    382380 * @param value Value to write to control register
    383381 */
    384 static void ata_write_ctl_8(void *arg, uint16_t off, uint8_t value)
    385 {
    386         ata_ctrl_t *ctrl = (ata_ctrl_t *)arg;
     382static void isa_ide_write_ctl_8(void *arg, uint16_t off, uint8_t value)
     383{
     384        isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)arg;
    387385
    388386        pio_write_8(((ioport8_t *)ctrl->ctl) + off, value);
     
    391389/** Read control register callback handler.
    392390 *
    393  * @param arg Argument (ata_ctrl_t *)
     391 * @param arg Argument (isa_ide_ctrl_t *)
    394392 * @param off Register offset
    395393 * @return value Value read from control register
    396394 */
    397 static uint8_t ata_read_ctl_8(void *arg, uint16_t off)
    398 {
    399         ata_ctrl_t *ctrl = (ata_ctrl_t *)arg;
     395static uint8_t isa_ide_read_ctl_8(void *arg, uint16_t off)
     396{
     397        isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)arg;
    400398
    401399        return pio_read_8(((ioport8_t *)ctrl->ctl) + off);
     
    404402/** Enable IRQ callback handler
    405403 *
    406  * @param arg Argument (ata_ctrl_t *)
     404 * @param arg Argument (isa_ide_ctrl_t *)
    407405 * @return EOK on success or an error code
    408406 */
    409 static errno_t ata_irq_enable(void *arg)
    410 {
    411         ata_ctrl_t *ctrl = (ata_ctrl_t *)arg;
     407static errno_t isa_ide_irq_enable(void *arg)
     408{
     409        isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)arg;
    412410        async_sess_t *parent_sess;
    413411        errno_t rc;
     
    430428/** Disable IRQ callback handler
    431429 *
    432  * @param arg Argument (ata_ctrl_t *)
     430 * @param arg Argument (isa_ide_ctrl_t *)
    433431 * @return EOK on success or an error code
    434432 */
    435 static errno_t ata_irq_disable(void *arg)
    436 {
    437         ata_ctrl_t *ctrl = (ata_ctrl_t *)arg;
     433static errno_t isa_ide_irq_disable(void *arg)
     434{
     435        isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)arg;
    438436        async_sess_t *parent_sess;
    439437        errno_t rc;
     
    456454/** Add ATA device callback handler.
    457455 *
    458  * @param arg Argument (ata_ctrl_t *)
     456 * @param arg Argument (isa_ide_ctrl_t *)
    459457 * @param idx Device index
    460458 * $param charg Connection handler argument
    461459 * @return EOK on success or an error code
    462460 */
    463 static errno_t ata_add_device(void *arg, unsigned idx, void *charg)
    464 {
    465         ata_ctrl_t *ctrl = (ata_ctrl_t *)arg;
    466         return ata_fun_create(ctrl, idx, charg);
     461static errno_t isa_ide_add_device(void *arg, unsigned idx, void *charg)
     462{
     463        isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)arg;
     464        return isa_ide_fun_create(ctrl, idx, charg);
    467465}
    468466
    469467/** Remove ATA device callback handler.
    470468 *
    471  * @param arg Argument (ata_ctrl_t *)
     469 * @param arg Argument (isa_ide_ctrl_t *)
    472470 * @param idx Device index
    473471 * @return EOK on success or an error code
    474472 */
    475 static errno_t ata_remove_device(void *arg, unsigned idx)
    476 {
    477         ata_ctrl_t *ctrl = (ata_ctrl_t *)arg;
    478         return ata_fun_remove(ctrl, idx);
     473static errno_t isa_ide_remove_device(void *arg, unsigned idx)
     474{
     475        isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)arg;
     476        return isa_ide_fun_remove(ctrl, idx);
    479477}
    480478
    481479/** Debug message callback handler.
    482480 *
    483  * @param arg Argument (ata_ctrl_t *)
     481 * @param arg Argument (isa_ide_ctrl_t *)
    484482 * @param msg Message
    485483 */
    486 static void ata_msg_debug(void *arg, char *msg)
     484static void isa_ide_msg_debug(void *arg, char *msg)
    487485{
    488486        (void)arg;
     
    492490/** Notice message callback handler.
    493491 *
    494  * @param arg Argument (ata_ctrl_t *)
     492 * @param arg Argument (isa_ide_ctrl_t *)
    495493 * @param msg Message
    496494 */
    497 static void ata_msg_note(void *arg, char *msg)
     495static void isa_ide_msg_note(void *arg, char *msg)
    498496{
    499497        (void)arg;
     
    503501/** Warning message callback handler.
    504502 *
    505  * @param arg Argument (ata_ctrl_t *)
     503 * @param arg Argument (isa_ide_ctrl_t *)
    506504 * @param msg Message
    507505 */
    508 static void ata_msg_warn(void *arg, char *msg)
     506static void isa_ide_msg_warn(void *arg, char *msg)
    509507{
    510508        (void)arg;
     
    514512/** Error message callback handler.
    515513 *
    516  * @param arg Argument (ata_ctrl_t *)
     514 * @param arg Argument (isa_ide_ctrl_t *)
    517515 * @param msg Message
    518516 */
    519 static void ata_msg_error(void *arg, char *msg)
     517static void isa_ide_msg_error(void *arg, char *msg)
    520518{
    521519        (void)arg;
Note: See TracChangeset for help on using the changeset viewer.