* Search the device enumeration table for a core matching @p descs, * * @param bp Platform state containing a valid EROM parser. * @param descs The core match descriptor table. * @param num_descs The number of match descriptors in @p descs. * @param[out] info If non-NULL, will be populated with the core * info. * @param[out] addr If non-NULL, will be populated with the core's *
| 182 | * physical register address. |
| 183 | */ |
| 184 | static int |
| 185 | bcm_find_core(struct bcm_platform *bp, const struct bhnd_core_match *descs, |
| 186 | size_t num_descs, struct bhnd_core_info *info, uintptr_t *addr) |
| 187 | { |
| 188 | bhnd_addr_t b_addr; |
| 189 | bhnd_size_t b_size; |
| 190 | int error; |
| 191 | |
| 192 | /* Fetch core info */ |
| 193 | for (size_t i = 0; i < num_descs; i++) { |
| 194 | error = bhnd_erom_lookup_core_addr(&bp->erom.obj, &descs[i], |
| 195 | BHND_PORT_DEVICE, 0, 0, info, &b_addr, &b_size); |
| 196 | |
| 197 | /* Terminate search on first match */ |
| 198 | if (error == 0) |
| 199 | break; |
| 200 | |
| 201 | /* Terminate on first error (other than core not found) */ |
| 202 | if (error != ENOENT) |
| 203 | return (error); |
| 204 | |
| 205 | /* Continue search ... */ |
| 206 | } |
| 207 | |
| 208 | /* Provide the core's base address */ |
| 209 | if (addr != NULL && b_addr > UINTPTR_MAX) { |
| 210 | BCM_ERR("core address %#jx overflows native address width\n", |
| 211 | (uintmax_t)b_addr); |
| 212 | return (ERANGE); |
| 213 | } |
| 214 | |
| 215 | if (addr != NULL) |
| 216 | *addr = b_addr; |
| 217 | |
| 218 | return (0); |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * Read a variable directly from NVRAM, decoding as @p type. |
no outgoing calls
no test coverage detected