Changeset 832cbe7 in mainline for uspace/lib


Ignore:
Timestamp:
2025-02-05T12:30:20Z (9 months 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).

Location:
uspace/lib
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/device/hw_res.c

    r0dab4850 r832cbe7  
    11/*
    2  * Copyright (c) 2024 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * Copyright (c) 2010 Lenka Trochtova
    44 * All rights reserved.
     
    162162}
    163163
    164 /** Get bus flags.
     164/** Query legacy IO claims.
    165165 *
    166166 * @param sess HW res session
    167  * @param rflags Place to store the flags
    168  *
    169  * @return Error code.
    170  *
    171  */
    172 errno_t hw_res_get_flags(async_sess_t *sess, hw_res_flags_t *rflags)
    173 {
    174         async_exch_t *exch = async_exchange_begin(sess);
    175 
    176         sysarg_t flags;
     167 * @param rclaims Place to store the claims
     168 *
     169 * @return Error code.
     170 *
     171 */
     172errno_t hw_res_query_legacy_io(async_sess_t *sess, hw_res_claims_t *rclaims)
     173{
     174        async_exch_t *exch = async_exchange_begin(sess);
     175
     176        sysarg_t claims;
    177177        const errno_t ret = async_req_1_1(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
    178             HW_RES_GET_FLAGS, &flags);
     178            HW_RES_QUERY_LEGACY_IO, &claims);
    179179
    180180        async_exchange_end(exch);
    181181
    182182        if (ret == EOK)
    183                 *rflags = flags;
     183                *rclaims = claims;
     184
     185        return ret;
     186}
     187
     188/** Claim legacy IO devices.
     189 *
     190 * @param sess HW res session
     191 * @param claims Claims
     192 *
     193 * @return Error code.
     194 *
     195 */
     196errno_t hw_res_claim_legacy_io(async_sess_t *sess, hw_res_claims_t claims)
     197{
     198        async_exch_t *exch = async_exchange_begin(sess);
     199
     200        const errno_t ret = async_req_2_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
     201            HW_RES_CLAIM_LEGACY_IO, claims);
     202
     203        async_exchange_end(exch);
    184204
    185205        return ret;
  • uspace/lib/c/include/device/hw_res.h

    r0dab4850 r832cbe7  
    11/*
    2  * Copyright (c) 2024 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * Copyright (c) 2010 Lenka Trochtova
    44 * All rights reserved.
     
    5757        HW_RES_DMA_CHANNEL_SETUP,
    5858        HW_RES_DMA_CHANNEL_REMAIN,
    59         HW_RES_GET_FLAGS
     59        HW_RES_QUERY_LEGACY_IO,
     60        HW_RES_CLAIM_LEGACY_IO
    6061} hw_res_method_t;
    6162
     
    118119}
    119120
     121/** Claims to legacy devices */
    120122typedef enum {
    121         /** This is an PCI/ISA bridge, not 'classic' ISA bus */
    122         hwf_isa_bridge = 0x1
    123 } hw_res_flags_t;
     123        /** 'Legacy' ISA IDE I/O ranges */
     124        hwc_isa_ide = 0x1
     125} hw_res_claims_t;
    124126
    125127extern errno_t hw_res_get_resource_list(async_sess_t *, hw_resource_list_t *);
     
    131133    uint32_t, uint8_t);
    132134extern errno_t hw_res_dma_channel_remain(async_sess_t *, unsigned, size_t *);
    133 extern errno_t hw_res_get_flags(async_sess_t *, hw_res_flags_t *);
     135extern errno_t hw_res_query_legacy_io(async_sess_t *, hw_res_claims_t *);
     136extern errno_t hw_res_claim_legacy_io(async_sess_t *, hw_res_claims_t);
    134137
    135138#endif
  • uspace/lib/device/include/devman.h

    r0dab4850 r832cbe7  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * Copyright (c) 2010 Lenka Trochtova
    44 * All rights reserved.
     
    5252extern errno_t devman_drv_fun_online(devman_handle_t);
    5353extern errno_t devman_drv_fun_offline(devman_handle_t);
     54extern errno_t devman_drv_fun_wait_stable(devman_handle_t);
    5455
    5556extern async_sess_t *devman_device_connect(devman_handle_t, unsigned int);
  • uspace/lib/device/include/ipc/devman.h

    r0dab4850 r832cbe7  
    11/*
     2 * Copyright (c) 2025 Jiri Svoboda
    23 * Copyright (c) 2010 Lenka Trochtova
    34 * All rights reserved.
     
    147148        DEVMAN_DRV_FUN_ONLINE,
    148149        DEVMAN_DRV_FUN_OFFLINE,
     150        DEVMAN_DRV_FUN_WAIT_STABLE,
    149151        DEVMAN_REMOVE_FUNCTION
    150152} driver_to_devman_t;
  • uspace/lib/device/src/devman.c

    r0dab4850 r832cbe7  
    11/*
     2 * Copyright (c) 2025 Jiri Svoboda
    23 * Copyright (c) 2007 Josef Cejka
    3  * Copyright (c) 2013 Jiri Svoboda
    44 * Copyright (c) 2010 Lenka Trochtova
    55 * All rights reserved.
     
    343343}
    344344
     345errno_t devman_drv_fun_wait_stable(devman_handle_t funh)
     346{
     347        async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_DRIVER);
     348        if (exch == NULL)
     349                return ENOMEM;
     350
     351        errno_t retval = async_req_1_0(exch, DEVMAN_DRV_FUN_WAIT_STABLE, funh);
     352
     353        devman_exchange_end(exch);
     354        return retval;
     355}
     356
    345357async_sess_t *devman_parent_device_connect(devman_handle_t handle,
    346358    unsigned int flags)
  • uspace/lib/drv/generic/driver.c

    r0dab4850 r832cbe7  
    11/*
     2 * Copyright (c) 2025 Jiri Svoboda
    23 * Copyright (c) 2010 Lenka Trochtova
    3  * Copyright (c) 2011 Jiri Svoboda
    44 * All rights reserved.
    55 *
     
    971971}
    972972
     973/** Wait for function to enter stable state.
     974 *
     975 * @param fun Function
     976 * @return EOK on success or an error code
     977 */
     978errno_t ddf_fun_wait_stable(ddf_fun_t *fun)
     979{
     980        return devman_drv_fun_wait_stable(fun->handle);
     981}
     982
    973983errno_t ddf_driver_main(const driver_t *drv)
    974984{
  • uspace/lib/drv/generic/remote_hw_res.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
     
    4848static void remote_hw_res_dma_channel_setup(ddf_fun_t *, void *, ipc_call_t *);
    4949static void remote_hw_res_dma_channel_remain(ddf_fun_t *, void *, ipc_call_t *);
    50 static void remote_hw_res_get_flags(ddf_fun_t *, void *, ipc_call_t *);
     50static void remote_hw_res_query_legacy_io(ddf_fun_t *, void *, ipc_call_t *);
     51static void remote_hw_res_claim_legacy_io(ddf_fun_t *, void *, ipc_call_t *);
    5152
    5253static const remote_iface_func_ptr_t remote_hw_res_iface_ops [] = {
     
    5758        [HW_RES_DMA_CHANNEL_SETUP] = &remote_hw_res_dma_channel_setup,
    5859        [HW_RES_DMA_CHANNEL_REMAIN] = &remote_hw_res_dma_channel_remain,
    59         [HW_RES_GET_FLAGS] = &remote_hw_res_get_flags
     60        [HW_RES_QUERY_LEGACY_IO] = &remote_hw_res_query_legacy_io,
     61        [HW_RES_CLAIM_LEGACY_IO] = &remote_hw_res_claim_legacy_io
    6062};
    6163
     
    174176}
    175177
    176 static void remote_hw_res_get_flags(ddf_fun_t *fun, void *ops,
    177     ipc_call_t *call)
    178 {
    179         hw_res_ops_t *hw_res_ops = ops;
    180 
    181         if (hw_res_ops->get_flags == NULL) {
    182                 async_answer_0(call, ENOTSUP);
    183                 return;
    184         }
    185 
    186         hw_res_flags_t flags = 0;
    187         const errno_t ret = hw_res_ops->get_flags(fun, &flags);
    188         async_answer_1(call, ret, flags);
     178static void remote_hw_res_query_legacy_io(ddf_fun_t *fun, void *ops,
     179    ipc_call_t *call)
     180{
     181        hw_res_ops_t *hw_res_ops = ops;
     182
     183        if (hw_res_ops->query_legacy_io == NULL) {
     184                async_answer_0(call, ENOTSUP);
     185                return;
     186        }
     187
     188        hw_res_claims_t claims = 0;
     189        const errno_t ret = hw_res_ops->query_legacy_io(fun, &claims);
     190        async_answer_1(call, ret, claims);
     191}
     192
     193static void remote_hw_res_claim_legacy_io(ddf_fun_t *fun, void *ops,
     194    ipc_call_t *call)
     195{
     196        hw_res_ops_t *hw_res_ops = ops;
     197        hw_res_claims_t claims;
     198
     199        if (hw_res_ops->claim_legacy_io == NULL) {
     200                async_answer_0(call, ENOTSUP);
     201                return;
     202        }
     203
     204        claims = DEV_IPC_GET_ARG1(*call);
     205
     206        const errno_t ret = hw_res_ops->claim_legacy_io(fun, claims);
     207        async_answer_0(call, ret);
    189208}
    190209
  • uspace/lib/drv/include/ddf/driver.h

    r0dab4850 r832cbe7  
    11/*
     2 * Copyright (c) 2025 Jiri Svoboda
    23 * Copyright (c) 2010 Lenka Trochtova
    3  * Copyright (c) 2011 Jiri Svoboda
    44 * All rights reserved.
    55 *
     
    133133extern void ddf_fun_set_conn_handler(ddf_fun_t *, async_port_handler_t);
    134134extern errno_t ddf_fun_add_to_category(ddf_fun_t *, const char *);
     135extern errno_t ddf_fun_wait_stable(ddf_fun_t *);
    135136
    136137#endif
  • uspace/lib/drv/include/ops/hw_res.h

    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
     
    5050        errno_t (*dma_channel_setup)(ddf_fun_t *, unsigned, uint32_t, uint32_t, uint8_t);
    5151        errno_t (*dma_channel_remain)(ddf_fun_t *, unsigned, size_t *);
    52         errno_t (*get_flags)(ddf_fun_t *, hw_res_flags_t *);
     52        errno_t (*query_legacy_io)(ddf_fun_t *, hw_res_claims_t *);
     53        errno_t (*claim_legacy_io)(ddf_fun_t *, hw_res_claims_t);
    5354} hw_res_ops_t;
    5455
Note: See TracChangeset for help on using the changeset viewer.