Changeset 832cbe7 in mainline for uspace/drv/bus
- Timestamp:
- 2025-02-05T12:30:20Z (13 months ago)
- 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)
- Location:
- uspace/drv/bus
- Files:
-
- 3 edited
-
isa/isa.c (modified) (3 diffs)
-
pci/pciintel/pci.c (modified) (5 diffs)
-
pci/pciintel/pci.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/isa/isa.c
r0dab4850 r832cbe7 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2025 Jiri Svoboda 3 3 * Copyright (c) 2010 Lenka Trochtova 4 4 * Copyright (c) 2011 Jan Vesely … … 206 206 } 207 207 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 */ 214 static errno_t isa_fun_query_legacy_io(ddf_fun_t *fnode, 215 hw_res_claims_t *rclaims) 209 216 { 210 217 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; 219 248 return EOK; 220 249 } … … 227 256 .dma_channel_setup = isa_fun_setup_dma, 228 257 .dma_channel_remain = isa_fun_remain_dma, 229 . get_flags = isa_fun_get_flags258 .query_legacy_io = isa_fun_query_legacy_io 230 259 }; 231 260 -
uspace/drv/bus/pci/pciintel/pci.c
r0dab4850 r832cbe7 1 1 /* 2 * Copyright (c) 20 19Jiri Svoboda2 * Copyright (c) 2025 Jiri Svoboda 3 3 * Copyright (c) 2010 Lenka Trochtova 4 4 * All rights reserved. … … 143 143 } 144 144 145 /** Handle legacy IO availability query from function. 146 * 147 * @param fnode Function performing the query 148 * @param rclaims Place to store the legacy IO claims bitmask 149 * @return EOK on success or an error code 150 */ 151 static errno_t pciintel_query_legacy_io(ddf_fun_t *fnode, 152 hw_res_claims_t *rclaims) 153 { 154 pci_fun_t *fun = pci_fun(fnode); 155 pci_bus_t *bus = fun->busptr; 156 pci_fun_t *f; 157 hw_res_claims_t claims; 158 159 /* 160 * We need to wait for enumeration to complete so that we give 161 * the PCI IDE driver a chance to claim the legacy ISA IDE 162 * ranges. 163 */ 164 ddf_msg(LVL_DEBUG, "pciintel_query_legacy_io"); 165 166 fun->querying = true; 167 168 fibril_mutex_lock(&bus->enum_done_lock); 169 while (!bus->enum_done) 170 fibril_condvar_wait(&bus->enum_done_cv, &bus->enum_done_lock); 171 fibril_mutex_unlock(&bus->enum_done_lock); 172 173 ddf_msg(LVL_DEBUG, "Wait for PCI devices to stabilize"); 174 175 f = pci_fun_first(bus); 176 while (f != NULL) { 177 if (!f->querying) 178 ddf_fun_wait_stable(f->fnode); 179 f = pci_fun_next(f); 180 } 181 182 /* Devices are stable. Now we can determine if ISA IDE was claimed. */ 183 184 claims = 0; 185 186 ddf_msg(LVL_DEBUG, "PCI devices stabilized, leg_ide_claimed=%d\n", 187 (int)bus->leg_ide_claimed); 188 if (bus->leg_ide_claimed != false) { 189 ddf_msg(LVL_NOTE, "Legacy IDE I/O ports claimed by PCI driver."); 190 claims |= hwc_isa_ide; 191 } 192 193 fun->querying = false; 194 *rclaims = claims; 195 return EOK; 196 } 197 198 /** Handle legacy IO claim from function. 199 * 200 * @param fnode Function claiming the legacy I/O ports 201 * @param claims Bitmask of claimed I/O 202 * @return EOK on success or an error code 203 */ 204 static errno_t pciintel_claim_legacy_io(ddf_fun_t *fnode, 205 hw_res_claims_t claims) 206 { 207 pci_fun_t *fun = pci_fun(fnode); 208 pci_bus_t *bus = fun->busptr; 209 210 ddf_msg(LVL_DEBUG, "pciintel_claim_legacy_io() claims=%x", claims); 211 if ((claims & hwc_isa_ide) != 0) 212 bus->leg_ide_claimed = true; 213 214 return EOK; 215 } 216 145 217 static pio_window_t *pciintel_get_pio_window(ddf_fun_t *fnode) 146 218 { … … 211 283 .disable_interrupt = &pciintel_disable_interrupt, 212 284 .clear_interrupt = &pciintel_clear_interrupt, 285 .query_legacy_io = &pciintel_query_legacy_io, 286 .claim_legacy_io = &pciintel_claim_legacy_io 213 287 }; 214 288 … … 755 829 list_initialize(&bus->funs); 756 830 fibril_mutex_initialize(&bus->conf_mutex); 831 fibril_mutex_initialize(&bus->enum_done_lock); 832 fibril_condvar_initialize(&bus->enum_done_cv); 757 833 758 834 bus->dnode = dnode; … … 863 939 hw_res_clean_resource_list(&hw_resources); 864 940 941 ddf_msg(LVL_DEBUG, "Bus enumeration done."); 942 943 fibril_mutex_lock(&bus->enum_done_lock); 944 bus->enum_done = true; 945 fibril_mutex_unlock(&bus->enum_done_lock); 946 fibril_condvar_broadcast(&bus->enum_done_cv); 947 865 948 return EOK; 866 867 949 fail: 868 950 if (got_res) -
uspace/drv/bus/pci/pciintel/pci.h
r0dab4850 r832cbe7 1 1 /* 2 * Copyright (c) 2025 Jiri Svoboda 2 3 * Copyright (c) 2010 Lenka Trochtova 3 * Copyright (c) 2011 Jiri Svoboda4 4 * All rights reserved. 5 5 * … … 41 41 #include <ddf/driver.h> 42 42 #include <fibril_synch.h> 43 #include <stdbool.h> 43 44 44 45 #define PCI_MAX_HW_RES 10 … … 54 55 /** List of functions (of pci_fun_t) */ 55 56 list_t funs; 57 /** Enumeration is done */ 58 bool enum_done; 59 /** Synchronize enum_done */ 60 fibril_mutex_t enum_done_lock; 61 /** Signal change to enum_done */ 62 fibril_condvar_t enum_done_cv; 63 /** @c true iff legacy IDE range is claimed by PCI IDE driver */ 64 bool leg_ide_claimed; 56 65 } pci_bus_t; 57 66 … … 72 81 uint8_t prog_if; 73 82 uint8_t revision; 83 bool querying; 74 84 hw_resource_list_t hw_resources; 75 85 hw_resource_t resources[PCI_MAX_HW_RES];
Note:
See TracChangeset
for help on using the changeset viewer.
