MCPcopy Create free account
hub / github.com/F-Stack/f-stack / apb_alloc_resource

Function apb_alloc_resource

freebsd/mips/atheros/ar531x/apb.c:268–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

266}
267
268static struct resource *
269apb_alloc_resource(device_t bus, device_t child, int type, int *rid,
270 rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
271{
272 struct apb_softc *sc = device_get_softc(bus);
273 struct apb_ivar *ivar = device_get_ivars(child);
274 struct resource *rv;
275 struct resource_list_entry *rle;
276 struct rman *rm;
277 int isdefault, needactivate, passthrough;
278
279 isdefault = (RMAN_IS_DEFAULT_RANGE(start, end));
280 needactivate = flags & RF_ACTIVE;
281 /*
282 * Pass memory requests to nexus device
283 */
284 passthrough = (device_get_parent(child) != bus);
285 rle = NULL;
286
287 dprintf("%s: entry (%p, %p, %d, %d, %p, %p, %jd, %d)\n",
288 __func__, bus, child, type, *rid, (void *)(intptr_t)start,
289 (void *)(intptr_t)end, count, flags);
290
291 if (passthrough)
292 return (BUS_ALLOC_RESOURCE(device_get_parent(bus), child, type,
293 rid, start, end, count, flags));
294
295 /*
296 * If this is an allocation of the "default" range for a given RID,
297 * and we know what the resources for this device are (ie. they aren't
298 * maintained by a child bus), then work out the start/end values.
299 */
300
301 if (isdefault) {
302 rle = resource_list_find(&ivar->resources, type, *rid);
303 if (rle == NULL) {
304 return (NULL);
305 }
306
307 if (rle->res != NULL) {
308 panic("%s: resource entry is busy", __func__);
309 }
310 start = rle->start;
311 end = rle->end;
312 count = rle->count;
313
314 dprintf("%s: default resource (%p, %p, %jd)\n",
315 __func__, (void *)(intptr_t)start,
316 (void *)(intptr_t)end, count);
317 }
318
319 switch (type) {
320 case SYS_RES_IRQ:
321 rm = &sc->apb_irq_rman;
322 break;
323 case SYS_RES_MEMORY:
324 rm = &sc->apb_mem_rman;
325 break;

Callers

nothing calls this directly

Calls 10

device_get_softcFunction · 0.85
device_get_ivarsFunction · 0.85
device_get_parentFunction · 0.85
resource_list_findFunction · 0.85
rman_reserve_resourceFunction · 0.85
rman_set_ridFunction · 0.85
bus_activate_resourceFunction · 0.85
rman_release_resourceFunction · 0.85
panicFunction · 0.50
printfFunction · 0.50

Tested by

no test coverage detected