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