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

Function apb_alloc_resource

freebsd/mips/atheros/apb.c:164–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162}
163
164static struct resource *
165apb_alloc_resource(device_t bus, device_t child, int type, int *rid,
166 rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
167{
168 struct apb_softc *sc = device_get_softc(bus);
169 struct apb_ivar *ivar = device_get_ivars(child);
170 struct resource *rv;
171 struct resource_list_entry *rle;
172 struct rman *rm;
173 int isdefault, needactivate, passthrough;
174
175 isdefault = (RMAN_IS_DEFAULT_RANGE(start, end));
176 needactivate = flags & RF_ACTIVE;
177 /*
178 * Pass memory requests to nexus device
179 */
180 passthrough = (device_get_parent(child) != bus);
181 rle = NULL;
182
183 dprintf("%s: entry (%p, %p, %d, %d, %p, %p, %jd, %d)\n",
184 __func__, bus, child, type, *rid, (void *)(intptr_t)start,
185 (void *)(intptr_t)end, count, flags);
186
187 if (passthrough)
188 return (BUS_ALLOC_RESOURCE(device_get_parent(bus), child, type,
189 rid, start, end, count, flags));
190
191 /*
192 * If this is an allocation of the "default" range for a given RID,
193 * and we know what the resources for this device are (ie. they aren't
194 * maintained by a child bus), then work out the start/end values.
195 */
196
197 if (isdefault) {
198 rle = resource_list_find(&ivar->resources, type, *rid);
199 if (rle == NULL) {
200 return (NULL);
201 }
202
203 if (rle->res != NULL) {
204 panic("%s: resource entry is busy", __func__);
205 }
206 start = rle->start;
207 end = rle->end;
208 count = rle->count;
209
210 dprintf("%s: default resource (%p, %p, %ld)\n",
211 __func__, (void *)(intptr_t)start,
212 (void *)(intptr_t)end, count);
213 }
214
215 switch (type) {
216 case SYS_RES_IRQ:
217 rm = &sc->apb_irq_rman;
218 break;
219 case SYS_RES_MEMORY:
220 rm = &sc->apb_mem_rman;
221 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