| 164 | } |
| 165 | |
| 166 | static struct resource * |
| 167 | xlp_simplebus_alloc_resource(device_t bus, device_t child, int type, int *rid, |
| 168 | rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) |
| 169 | { |
| 170 | struct rman *rm; |
| 171 | struct resource *rv; |
| 172 | struct resource_list_entry *rle; |
| 173 | struct simplebus_softc *sc; |
| 174 | struct simplebus_devinfo *di; |
| 175 | bus_space_tag_t bustag; |
| 176 | int j, isdefault, passthrough, needsactivate; |
| 177 | |
| 178 | passthrough = (device_get_parent(child) != bus); |
| 179 | needsactivate = flags & RF_ACTIVE; |
| 180 | sc = device_get_softc(bus); |
| 181 | di = device_get_ivars(child); |
| 182 | rle = NULL; |
| 183 | bustag = NULL; |
| 184 | |
| 185 | if (!passthrough) { |
| 186 | isdefault = RMAN_IS_DEFAULT_RANGE(start, end); |
| 187 | if (isdefault) { |
| 188 | rle = resource_list_find(&di->rl, type, *rid); |
| 189 | if (rle == NULL) |
| 190 | return (NULL); |
| 191 | if (rle->res != NULL) |
| 192 | panic("%s: resource entry is busy", __func__); |
| 193 | start = rle->start; |
| 194 | count = ulmax(count, rle->count); |
| 195 | end = ulmax(rle->end, start + count - 1); |
| 196 | } |
| 197 | if (type == SYS_RES_MEMORY) { |
| 198 | /* Remap through ranges property */ |
| 199 | for (j = 0; j < sc->nranges; j++) { |
| 200 | if (start >= sc->ranges[j].bus && end < |
| 201 | sc->ranges[j].bus + sc->ranges[j].size) { |
| 202 | start -= sc->ranges[j].bus; |
| 203 | start += sc->ranges[j].host; |
| 204 | end -= sc->ranges[j].bus; |
| 205 | end += sc->ranges[j].host; |
| 206 | break; |
| 207 | } |
| 208 | } |
| 209 | if (j == sc->nranges && sc->nranges != 0) { |
| 210 | if (bootverbose) |
| 211 | device_printf(bus, "Could not map resource " |
| 212 | "%#jx-%#jx\n", start, end); |
| 213 | return (NULL); |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | switch (type) { |
| 218 | case SYS_RES_IRQ: |
| 219 | rm = &irq_rman; |
| 220 | break; |
| 221 | case SYS_RES_IOPORT: |
| 222 | rm = &port_rman; |
| 223 | bustag = rmi_bus_space; |
nothing calls this directly
no test coverage detected