BUS_ADJUST_RESOURCE(9)
π BUS_ADJUST_RESOURCE(9) π
ok so bestie, this is a page from the Kernel Developer's Manual, and today's main character is bus_adjust_resource β she adjusts resources that got allocated from a parent bus. yes she's niche. yes she's iconic. let's get into it π
β¨ NAME β¨
bus_adjust_resource β adjust resource allocated from a parent bus
like. the whole vibe is "hey parent bus, can we move this thing a lil bit" π¦
β¨ SYNOPSIS β¨
#include <sys/param.h>
#include <sys/bus.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <machine/resource.h>
int
bus_adjust_resource(device_t dev, int type, struct resource *r,
rman_res_t start, rman_res_t end);
look at those includes. four files. she's high maintenance and she's worth it π
β¨ DESCRIPTION β¨
okay so here's the tea β β this function is literally you going up to the parent bus and being like "hi bestie, can we adjust the resource range assigned to this resource i already allocated?" and the parent bus is like "bet."
the resource r should have been allocated by a previous call to bus_alloc_resource(9). no bootlegging. no vibes-based resources. you gotta have actually gotten it from there first π«Ά
the new resource range must overlap the existing range of r. that's not a suggestion, that's the law. if it doesn't overlap, we're not doing this (see ERRORS, she will not be happy).
and the type argument? it should match the type argument you passed to bus_alloc_resource(9) back when the resource was initially allocated. consistency is the whole aesthetic, fr fr β¨
π¨ okay this is the important part, do NOT skip it β none of the constraints of the original allocation request β like alignment or boundary restrictions β are checked by bus_adjust_resource(). she does not check them. she will not check them. it is the caller's responsibility to enforce any such requirements. that's you. you're the caller. it's giving main character energy and also it's giving "you're on your own, babe" π
β¨ RETURN VALUES β¨
the bus_adjust_resource() method returns zero on success or an error code on failure.
zero = slay. error code = not slay but at least she told you π
β¨ EXAMPLES β¨
here's a lil demo where we grow an existing memory resource by 4096 bytes. glow up, but make it hardware π§
struct resource *res;
int error;
error = bus_adjust_resource(dev, SYS_RES_MEMORY, res,
rman_get_start(res), rman_get_end(res) + 0x1000);
look at that + 0x1000. that's 4096 in hex. she ate that π
β¨ ERRORS β¨
bus_adjust_resource() will fail if:
[EINVAL]β Thedevdevice does not have a parent device. orphan behavior. no parent, no adjustment, no service π₯²[EINVAL]β Therresource is a shared resource. sharing is caring but not here bestie, she said no π«[EINVAL]β The new address range does not overlap with the existing address range ofr. remember that whole overlap rule from DESCRIPTION? yeah. this is what happens when you ignore it π€[EBUSY]β The new address range conflicts with another allocated resource. somebody else already called dibs. respectfully, find another range πΈ
β¨ SEE ALSO β¨
the whole friend group π«Ά go read them too, they're all valid
and that's the whole page, bestie!! no cap, you now understand bus_adjust_resource better than like 90% of people who have ever typed rman_res_t. periodt. π
this one came from <strong>Debian</strong>, dated <strong>April 23, 2016</strong> β yes she's an elder but she's still serving looks β¨ go forth and adjust responsibly, and remember: overlap the range, match the type, and enforce your own alignment constraints like a grown-up ππ
π¦ 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) 2011 Hudson River Trading LLC
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms