BUS_GET_RESOURCE(9)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’… BUS_GET_RESOURCE(9) β€” bus_get_resource

okay so bestie, this is a page from the Kernel Developer's Manual (section 9, kernel dev stuff, iykyk) and it's about one little function that just… reads a resource. that's it. that's the whole vibe. and honestly? iconic. ✨


πŸ¦‹ NAME

bus_get_resource β€” read a resource range/value with a given resource ID

like, you give it an ID and it hands you back the range or the value. lowkey the whole personality right there. πŸŽ€


🌸 SYNOPSIS

#include <sys/param.h>
#include <sys/bus.h>
#include <sys/rman.h>

int
bus_get_resource(device_t dev, int type, int rid, rman_res_t *startp,
    rman_res_t *countp);

three includes, one function, zero drama. copy it exactly, please, do not freestyle the headers. 🫢


✨ DESCRIPTION

so the bus_get_resource() function reads the range or the value of the resource type, rid pair and stores it in the startp and countp arguments. that's the tea. πŸ”₯

the arguments are, and I'm gonna go through every single one because I would never leave you guessing:

  • dev β€” the device to read the resource from. the main character, basically. πŸ‘‘
  • type β€” the type of resource you want to read. it is one of:
    • SYS_RES_IRQ β€” for IRQs
    • SYS_RES_DRQ β€” for ISA DMA lines
    • SYS_RES_MEMORY β€” for I/O memory
    • SYS_RES_IOPORT β€” for I/O ports
  • rid β€” a bus-specific handle that identifies the resource being read. yes it's bus-specific, no you can't just make one up and expect it to slay. πŸ™ˆ
  • startp β€” a pointer to the start address of this resource. it's a pointer, bestie, so make sure it points somewhere real. πŸ’€
  • countp β€” a pointer to the length of the resource. for example, the size of the memory in bytes. so like, a number. a length. the whole point. πŸ“

⭐ RETURN VALUES

zero is returned on success, otherwise an error is returned.

no cap, that's it β€” 0 means you ate, anything else means something went sideways. do with that what you will. πŸ’…


πŸ’– SEE ALSO

go read them, they're friends of this page, fr fr. 🌈


🌷 AUTHORS

this manual page was written by Sascha Wildner. credit where credit is due, periodt. πŸ‘


⚠️ heads up bestie: startp and countp are pointers, so you're handing the function somewhere to write. make sure those pointers are valid before you call this, okay? love you, mean it. πŸ’œ

and that's the whole page!! written with love, shipped by Debian on September 26, 2015 β€” yeah she's a little vintage but she still serves πŸ’…βœ¨πŸŽ€ stay hydrated and check your return codes, mwah 🫢

πŸ“¦ where this page comes from