Changeset 832cbe7 in mainline for uspace/drv/bus/isa/isa.c


Ignore:
Timestamp:
2025-02-05T12:30:20Z (9 days ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
accdf882
Parents:
0dab4850
git-author:
Jiri Svoboda <jiri@…> (2025-02-04 21:30:06)
git-committer:
Jiri Svoboda <jiri@…> (2025-02-05 12:30:20)
Message:

Add proper IDE PCI to ISA fallback mechanism.

To determine if legacy IDE I/O ports are free, isa-ide asks isa,
who asks pciintel. pciintel waits for bus enumeration to complete,
then waits for all functions except the one who is asking
(which is ISA bus) to stabilize. During attach pci-ide will claim
the legacy IDE ports. Thus, if at this point legacy IDE ports
are unclaimed, pciintel tells ISA they are free, which tells isa-ide,
which continues to attach. If they are not free, isa-ide will not
attach.

This works for all use cases, including system without PCI bus,
system with PCI bus, but no (or disabled) PCI IDE, system with PCI
IDE with unrecognized VID/PID (which we will handle in legacy ISA mode).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/isa/isa.c

    r0dab4850 r832cbe7  
    11/*
    2  * Copyright (c) 2024 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * Copyright (c) 2010 Lenka Trochtova
    44 * Copyright (c) 2011 Jan Vesely
     
    206206}
    207207
    208 static errno_t isa_fun_get_flags(ddf_fun_t *fnode, hw_res_flags_t *rflags)
     208/** Handle legacy IO availability query from function.
     209 *
     210 * @param fnode Function performing the query
     211 * @param rclaims Place to store the legacy IO claims bitmask
     212 * @return EOK on success or an error code
     213 */
     214static errno_t isa_fun_query_legacy_io(ddf_fun_t *fnode,
     215    hw_res_claims_t *rclaims)
    209216{
    210217        isa_fun_t *fun = isa_fun(fnode);
    211         hw_res_flags_t flags;
    212 
    213         flags = 0;
    214         if (fun->bus->pci_isa_bridge)
    215                 flags |= hwf_isa_bridge;
    216 
    217         ddf_msg(LVL_NOTE, "isa_fun_get_flags: returning 0x%x", flags);
    218         *rflags = flags;
     218        hw_res_claims_t claims;
     219        async_sess_t *sess;
     220        errno_t rc;
     221
     222        ddf_msg(LVL_DEBUG, "isa_fun_query_legacy_io()");
     223
     224        sess = ddf_dev_parent_sess_get(fun->bus->dev);
     225        if (sess == NULL) {
     226                ddf_msg(LVL_ERROR, "isa_dev_add failed to connect to the "
     227                    "parent driver.");
     228                return ENOENT;
     229        }
     230
     231        if (!fun->bus->pci_isa_bridge) {
     232                ddf_msg(LVL_NOTE, "isa_fun_query_legacy_io: classic ISA - "
     233                    "legacy IDE range is available");
     234                /* Classic ISA, we can be sure IDE is unclaimed by PCI */
     235                claims = 0;
     236        } else {
     237                ddf_msg(LVL_NOTE, "isa_fun_query_legacy_io: ISA bridge - "
     238                    "determine legacy IDE availability from PCI bus driver");
     239                rc = hw_res_query_legacy_io(sess, &claims);
     240                if (rc != EOK) {
     241                        ddf_msg(LVL_NOTE, "Error querying legacy IO claims.");
     242                        return rc;
     243                }
     244        }
     245
     246        ddf_msg(LVL_DEBUG, "isa_fun_query_legacy_io: returning 0x%x", claims);
     247        *rclaims = claims;
    219248        return EOK;
    220249}
     
    227256        .dma_channel_setup = isa_fun_setup_dma,
    228257        .dma_channel_remain = isa_fun_remain_dma,
    229         .get_flags = isa_fun_get_flags
     258        .query_legacy_io = isa_fun_query_legacy_io
    230259};
    231260
Note: See TracChangeset for help on using the changeset viewer.