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

Function octopci_alloc_resource

freebsd/mips/cavium/octopci.c:234–296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232}
233
234static struct resource *
235octopci_alloc_resource(device_t bus, device_t child, int type, int *rid,
236 rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
237{
238 struct octopci_softc *sc;
239 struct resource *res;
240 struct rman *rm;
241 int error;
242
243 sc = device_get_softc(bus);
244
245 switch (type) {
246 case SYS_RES_IRQ:
247 res = bus_generic_alloc_resource(bus, child, type, rid, start,
248 end, count, flags);
249 if (res != NULL)
250 return (res);
251 return (NULL);
252 case SYS_RES_MEMORY:
253 rm = &sc->sc_mem1;
254 break;
255 case SYS_RES_IOPORT:
256 rm = &sc->sc_io;
257 break;
258 default:
259 return (NULL);
260 }
261
262 res = rman_reserve_resource(rm, start, end, count, flags, child);
263 if (res == NULL)
264 return (NULL);
265
266 rman_set_rid(res, *rid);
267 rman_set_bustag(res, octopci_bus_space);
268
269 switch (type) {
270 case SYS_RES_MEMORY:
271 rman_set_bushandle(res, sc->sc_mem1_base + rman_get_start(res));
272 break;
273 case SYS_RES_IOPORT:
274 rman_set_bushandle(res, sc->sc_io_base + rman_get_start(res));
275#if __mips_n64
276 rman_set_virtual(res, (void *)rman_get_bushandle(res));
277#else
278 /*
279 * XXX
280 * We can't access ports via a 32-bit pointer.
281 */
282 rman_set_virtual(res, NULL);
283#endif
284 break;
285 }
286
287 if ((flags & RF_ACTIVE) != 0) {
288 error = bus_activate_resource(child, type, *rid, res);
289 if (error != 0) {
290 rman_release_resource(res);
291 return (NULL);

Callers

nothing calls this directly

Calls 11

device_get_softcFunction · 0.85
rman_reserve_resourceFunction · 0.85
rman_set_ridFunction · 0.85
rman_set_bustagFunction · 0.85
rman_set_bushandleFunction · 0.85
rman_get_startFunction · 0.85
rman_set_virtualFunction · 0.85
rman_get_bushandleFunction · 0.85
bus_activate_resourceFunction · 0.85
rman_release_resourceFunction · 0.85

Tested by

no test coverage detected