BUS_SET_RESOURCE(9)
π BUS_SET_RESOURCE(9) π
okay bestie, so this is a page from the Kernel Developer's Manual, and it's all about bus_set_resource β the lil function that associates a definite resource with a given resource ID. yes, that's the whole NAME section, we're not skipping it, it's literally the vibe. π
β¨ SYNOPSIS β¨
so first you gotta pull in the headers, all of them, in this exact order, no skipping:
#include <sys/param.h>
#include <sys/bus.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <machine/resource.h>
and then the function itself, looking like this:
int
bus_set_resource(device_t dev, int type, int rid, rman_res_t start,
rman_res_t count);
that's it, that's the signature, memorise it bestie π
πΈ DESCRIPTION πΈ
so the bus_set_resource() function sets the start address of the type, rid pair to be count long. simple as.
now, lowkey important tea: typically, client drivers do not use this interface. nope, not for them. it's the bus drivers who are obsessed with it β they use it all the time to set up the resources that a client driver ends up using. so if you're writing a client driver and you're like "should I call this?" β¦ probably not, that's giving bus driver energy, not client driver energy. π
the arguments, one by one, no crumbs left:
devβ the device you're setting the resource on.typeβ the type of resource you want to allocate. it's one of these four, pick one, choose wisely:SYS_RES_IRQβ for IRQs β¨SYS_RES_DRQβ for ISA DMA lines πSYS_RES_IOPORTβ for I/O ports πSYS_RES_MEMORYβ for I/O memory π
ridβ a bus-specific handle that identifies the resource being allocated. it's the resource's little name tag fr fr π«Άstartβ the start address of this resource. where it begins, its origin story.countβ the length of the resource. for example, the size of the memory in bytes. so like, how much of it. π
β RETURN VALUES β
zero is returned on success. anything else means an error got returned instead. so like, 0 = slay, not-0 = not slay. that's the whole check, no cap. π
π¦ SEE ALSO π¦
go read these next, bestie, they're the friend group:
π AUTHORS π
this manual page was written by Warner Losh <imp@FreeBSD.org>. give them their flowers, periodt. π
and that's a wrap on this Debian page, dated March 29, 2003, filed under BUS_SET_RESOURCE(9) β iconic, historic, and now understood by you specifically. mwah. πβ¨π¦
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2003 M. Warner Losh
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms