Ignore:
File:
1 edited

Legend:

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

    r645d3832 r2a5d4649  
    11/*
    2  * Copyright (c) 2024 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    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
     
    133135        pci_ide_ctrl_t *ctrl;
    134136        pci_ide_hwres_t res;
     137        async_sess_t *parent_sess;
     138        unsigned chans;
    135139        errno_t rc;
    136140
     
    154158                goto error;
    155159
     160        chans = 0;
     161
    156162        rc = pci_ide_channel_init(ctrl, &ctrl->channel[0], 0, &res);
    157         if (rc == ENOENT)
     163        if (rc == EOK)
     164                ++chans;
     165        else if (rc != ENOENT)
    158166                goto error;
    159167
    160168        rc = pci_ide_channel_init(ctrl, &ctrl->channel[1], 1, &res);
    161         if (rc == ENOENT)
    162                 goto error;
    163 
    164         if (rc != EOK) {
    165                 ddf_msg(LVL_ERROR, "Failed initializing ATA controller.");
     169        if (rc == EOK)
     170                ++chans;
     171        else if (rc != ENOENT)
     172                goto error;
     173
     174        if (chans == 0) {
     175                ddf_msg(LVL_ERROR, "No PCI IDE devices found.");
     176                rc = EIO;
     177                goto error;
     178        }
     179
     180        parent_sess = ddf_dev_parent_sess_get(dev);
     181        if (parent_sess == NULL) {
     182                rc = ENOMEM;
     183                goto error;
     184        }
     185
     186        /* Claim legacy I/O range to prevent ISA IDE from attaching there. */
     187        rc = hw_res_claim_legacy_io(parent_sess, hwc_isa_ide);
     188        if (rc != EOK) {
     189                ddf_msg(LVL_ERROR, "Failed claiming legacy I/O range.");
    166190                rc = EIO;
    167191                goto error;
     
    352376}
    353377
     378static errno_t pci_ide_dev_quiesce(ddf_dev_t *dev)
     379{
     380        pci_ide_ctrl_t *ctrl = (pci_ide_ctrl_t *)ddf_dev_data_get(dev);
     381
     382        ddf_msg(LVL_DEBUG, "pci_ide_dev_quiesce(%p)", dev);
     383
     384        pci_ide_channel_quiesce(&ctrl->channel[0]);
     385        pci_ide_channel_quiesce(&ctrl->channel[1]);
     386
     387        return EOK;
     388}
     389
    354390static errno_t pci_ide_fun_online(ddf_fun_t *fun)
    355391{
Note: See TracChangeset for help on using the changeset viewer.