Changeset 07039850 in mainline


Ignore:
Timestamp:
2025-03-05T21:41:03Z (11 hours ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Parents:
a64970e1
Message:

Implement quiesce in ISA and PCI IDE and in PC Floppy.

Location:
uspace
Files:
12 edited

Legend:

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

    ra64970e1 r07039850  
    101101        ata_params_t params;
    102102
    103         ddf_msg(LVL_DEBUG, "isa_ide_ctrl_init()");
     103        ddf_msg(LVL_DEBUG, "isa_ide_channel_init()");
    104104
    105105        memset(&params, 0, sizeof(params));
     
    135135        irq_inited = true;
    136136
    137         ddf_msg(LVL_DEBUG, "isa_ide_ctrl_init(): Initialize IDE channel");
     137        ddf_msg(LVL_DEBUG, "isa_ide_channel_init(): Initialize IDE channel");
    138138
    139139        params.arg = (void *)chan;
     
    163163                goto error;
    164164
    165         ddf_msg(LVL_DEBUG, "isa_ide_ctrl_init: DONE");
     165        ddf_msg(LVL_DEBUG, "isa_ide_channel_init: DONE");
    166166        return EOK;
    167167error:
     
    181181        errno_t rc;
    182182
    183         ddf_msg(LVL_DEBUG, ": isa_ide_ctrl_remove()");
     183        ddf_msg(LVL_DEBUG, ": isa_ide_channel_fini()");
    184184
    185185        fibril_mutex_lock(&chan->lock);
     
    196196
    197197        return EOK;
     198}
     199
     200/** Quiesce ISA IDE channel. */
     201void isa_ide_channel_quiesce(isa_ide_channel_t *chan)
     202{
     203        ddf_msg(LVL_DEBUG, ": isa_ide_channel_quiesce()");
     204
     205        fibril_mutex_lock(&chan->lock);
     206        ata_channel_quiesce(chan->channel);
     207        fibril_mutex_unlock(&chan->lock);
    198208}
    199209
  • uspace/drv/block/isa-ide/isa-ide.h

    ra64970e1 r07039850  
    11/*
    2  * Copyright (c) 2024 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    104104    unsigned, isa_ide_hwres_t *);
    105105extern errno_t isa_ide_channel_fini(isa_ide_channel_t *);
     106extern void isa_ide_channel_quiesce(isa_ide_channel_t *);
    106107
    107108#endif
  • uspace/drv/block/isa-ide/main.c

    ra64970e1 r07039850  
    4949static errno_t isa_ide_dev_remove(ddf_dev_t *dev);
    5050static errno_t isa_ide_dev_gone(ddf_dev_t *dev);
     51static errno_t isa_ide_dev_quiesce(ddf_dev_t *dev);
    5152static errno_t isa_ide_fun_online(ddf_fun_t *fun);
    5253static errno_t isa_ide_fun_offline(ddf_fun_t *fun);
     
    5556
    5657static driver_ops_t driver_ops = {
    57         .dev_add = &isa_ide_dev_add,
    58         .dev_remove = &isa_ide_dev_remove,
    59         .dev_gone = &isa_ide_dev_gone,
    60         .fun_online = &isa_ide_fun_online,
    61         .fun_offline = &isa_ide_fun_offline
     58        .dev_add = isa_ide_dev_add,
     59        .dev_remove = isa_ide_dev_remove,
     60        .dev_gone = isa_ide_dev_gone,
     61        .dev_quiesce = isa_ide_dev_quiesce,
     62        .fun_online = isa_ide_fun_online,
     63        .fun_offline = isa_ide_fun_offline
    6264};
    6365
     
    379381}
    380382
     383static errno_t isa_ide_dev_quiesce(ddf_dev_t *dev)
     384{
     385        isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)ddf_dev_data_get(dev);
     386
     387        ddf_msg(LVL_DEBUG, "isa_ide_dev_quiesce(%p)", dev);
     388
     389        isa_ide_channel_quiesce(&ctrl->channel[0]);
     390        isa_ide_channel_quiesce(&ctrl->channel[1]);
     391        return EOK;
     392}
     393
    381394static errno_t isa_ide_fun_online(ddf_fun_t *fun)
    382395{
  • uspace/drv/block/pc-floppy/main.c

    ra64970e1 r07039850  
    4747static errno_t pc_fdc_dev_remove(ddf_dev_t *dev);
    4848static errno_t pc_fdc_dev_gone(ddf_dev_t *dev);
     49static errno_t pc_fdc_dev_quiesce(ddf_dev_t *dev);
    4950static errno_t pc_fdc_fun_online(ddf_fun_t *fun);
    5051static errno_t pc_fdc_fun_offline(ddf_fun_t *fun);
    5152
    5253static driver_ops_t driver_ops = {
    53         .dev_add = &pc_fdc_dev_add,
    54         .dev_remove = &pc_fdc_dev_remove,
    55         .dev_gone = &pc_fdc_dev_gone,
    56         .fun_online = &pc_fdc_fun_online,
    57         .fun_offline = &pc_fdc_fun_offline
     54        .dev_add = pc_fdc_dev_add,
     55        .dev_remove = pc_fdc_dev_remove,
     56        .dev_gone = pc_fdc_dev_gone,
     57        .dev_quiesce = pc_fdc_dev_quiesce,
     58        .fun_online = pc_fdc_fun_online,
     59        .fun_offline = pc_fdc_fun_offline
    5860};
    5961
     
    183185}
    184186
     187/** Quiesce FDC device.
     188 *
     189 * @param dev Device
     190 * @return EOK on success or an error code
     191 */
     192static errno_t pc_fdc_dev_quiesce(ddf_dev_t *dev)
     193{
     194        pc_fdc_t *fdc = (pc_fdc_t *)ddf_dev_data_get(dev);
     195        pc_fdc_quiesce(fdc);
     196        return EOK;
     197}
     198
    185199/** Online FDC function.
    186200 *
  • uspace/drv/block/pc-floppy/pc-floppy.c

    ra64970e1 r07039850  
    11/*
    2  * Copyright (c) 2024 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    256256}
    257257
     258/** Quiesce floppy controller.
     259 *
     260 * @param fdc Floppy controller
     261 */
     262void pc_fdc_quiesce(pc_fdc_t *fdc)
     263{
     264        (void)pc_fdc_reset(fdc);
     265}
     266
    258267/** Enable device I/O.
    259268 *
  • uspace/drv/block/pc-floppy/pc-floppy.h

    ra64970e1 r07039850  
    11/*
    2  * Copyright (c) 2024 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    9797
    9898extern errno_t pc_fdc_create(ddf_dev_t *, pc_fdc_hwres_t *, pc_fdc_t **);
     99extern void pc_fdc_quiesce(pc_fdc_t *);
    99100extern errno_t pc_fdc_destroy(pc_fdc_t *);
    100101
  • uspace/drv/block/pci-ide/main.c

    ra64970e1 r07039850  
    4949static errno_t pci_ide_dev_remove(ddf_dev_t *dev);
    5050static errno_t pci_ide_dev_gone(ddf_dev_t *dev);
     51static errno_t pci_ide_dev_quiesce(ddf_dev_t *dev);
    5152static errno_t pci_ide_fun_online(ddf_fun_t *fun);
    5253static errno_t pci_ide_fun_offline(ddf_fun_t *fun);
     
    5556
    5657static driver_ops_t driver_ops = {
    57         .dev_add = &pci_ide_dev_add,
    58         .dev_remove = &pci_ide_dev_remove,
    59         .dev_gone = &pci_ide_dev_gone,
    60         .fun_online = &pci_ide_fun_online,
    61         .fun_offline = &pci_ide_fun_offline
     58        .dev_add = pci_ide_dev_add,
     59        .dev_remove = pci_ide_dev_remove,
     60        .dev_gone = pci_ide_dev_gone,
     61        .dev_quiesce = pci_ide_dev_quiesce,
     62        .fun_online = pci_ide_fun_online,
     63        .fun_offline = pci_ide_fun_offline
    6264};
    6365
     
    367369}
    368370
     371static errno_t pci_ide_dev_quiesce(ddf_dev_t *dev)
     372{
     373        pci_ide_ctrl_t *ctrl = (pci_ide_ctrl_t *)ddf_dev_data_get(dev);
     374
     375        ddf_msg(LVL_DEBUG, "pci_ide_dev_quiesce(%p)", dev);
     376
     377        pci_ide_channel_quiesce(&ctrl->channel[0]);
     378        pci_ide_channel_quiesce(&ctrl->channel[1]);
     379
     380        return EOK;
     381}
     382
    369383static errno_t pci_ide_fun_online(ddf_fun_t *fun)
    370384{
  • uspace/drv/block/pci-ide/pci-ide.c

    ra64970e1 r07039850  
    331331}
    332332
     333/** Quiesce PCI IDE channel. */
     334void pci_ide_channel_quiesce(pci_ide_channel_t *chan)
     335{
     336        ddf_msg(LVL_DEBUG, ": pci_ide_channel_quiesce()");
     337
     338        fibril_mutex_lock(&chan->lock);
     339        ata_channel_quiesce(chan->channel);
     340        fibril_mutex_unlock(&chan->lock);
     341}
     342
    333343/** Enable device I/O. */
    334344static errno_t pci_ide_init_io(pci_ide_channel_t *chan)
  • uspace/drv/block/pci-ide/pci-ide.h

    ra64970e1 r07039850  
    11/*
    2  * Copyright (c) 2024 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    129129    unsigned, pci_ide_hwres_t *);
    130130extern errno_t pci_ide_channel_fini(pci_ide_channel_t *);
     131extern void pci_ide_channel_quiesce(pci_ide_channel_t *);
    131132
    132133#endif
  • uspace/lib/ata/include/ata/ata.h

    ra64970e1 r07039850  
    11/*
    2  * Copyright (c) 2024 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    201201extern errno_t ata_channel_initialize(ata_channel_t *);
    202202extern errno_t ata_channel_destroy(ata_channel_t *);
     203extern void ata_channel_quiesce(ata_channel_t *);
    203204extern void ata_channel_irq(ata_channel_t *, uint8_t);
    204205extern void ata_connection(ipc_call_t *, ata_device_t *);
  • uspace/lib/ata/include/ata/ata_hw.h

    ra64970e1 r07039850  
    11/*
    2  * Copyright (c) 2024 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    106106#define REG_COMMAND offsetof(ata_cmd_t, command)
    107107#define REG_FEATURES offsetof(ata_cmd_t, features)
     108#define REG_DEVCTL offsetof(ata_ctl_t, device_control)
    108109
    109110enum devctl_bits {
  • uspace/lib/ata/src/ata.c

    ra64970e1 r07039850  
    8484static uint8_t ata_read_cmd_8(ata_channel_t *, uint16_t);
    8585static void ata_write_cmd_8(ata_channel_t *, uint16_t, uint8_t);
     86static void ata_write_ctl_8(ata_channel_t *, uint16_t, uint8_t);
    8687
    8788static errno_t ata_bd_init_irq(ata_channel_t *);
     
    279280}
    280281
     282/** Quiesce ATA channel. */
     283void ata_channel_quiesce(ata_channel_t *chan)
     284{
     285        ata_msg_debug(chan, ": ata_channel_quiesce()");
     286
     287        fibril_mutex_lock(&chan->lock);
     288        ata_write_ctl_8(chan, REG_DEVCTL, DCR_SRST | DCR_nIEN);
     289        fibril_mutex_unlock(&chan->lock);
     290}
     291
    281292/** Add ATA device.
    282293 *
     
    348359{
    349360        return chan->params.write_cmd_8(chan->params.arg, port, value);
     361}
     362
     363/** Write 8 bits to 8-bit control port.
     364 *
     365 * @param chan ATA channel
     366 * @param port Port number
     367 * @param value Register value
     368 */
     369static void ata_write_ctl_8(ata_channel_t *chan, uint16_t port, uint8_t value)
     370{
     371        return chan->params.write_ctl_8(chan->params.arg, port, value);
    350372}
    351373
Note: See TracChangeset for help on using the changeset viewer.