History log of /freebsd-current/sys/sys/rman.h
Revision Date Author Comments
# cbcb9778 10-May-2024 Elliott Mitchell <ehem+freebsd@m5p.com>

kern/rman: mark rman get functions as taking constants

The arguments are left completely unchanged by these functions. This
allows passing constant pointers for verifying ownership, but not
modifying the contents.

Reviewed by: imp,jhb
Pull Request: https://github.com/freebsd/freebsd-src/pull/1224


# 037946dc 08-May-2024 Elliott Mitchell <ehem+freebsd@m5p.com>

kern/rman: remove rman_reserve_resource_bound(), partially revert 13fb6657723

Not once has rman_reserve_resource_bound() ever been used. There are
though several uses of RF_ALIGNMENT. In light of this remove this
extra and leave the actually used portion in place.

This partially reverts commit 13fb6657723c1e9cb47bbd286942b432a4306b96.

Reviewed by: imp,jhb
Pull Request: https://github.com/freebsd/freebsd-src/pull/1224


# b30a80b6 13-Mar-2024 John Baldwin <jhb@FreeBSD.org>

rman: Add rman_get/set_type

This permits associating a resource type (e.g. SYS_RES_MEMORY) with a
struct resource.

I considered adding a new field to struct rman to store the type and
only providing rman_get_type as an accessor. However, changing
'struct rman' is an ABI breakage. I might revisit this in main, but
the current approach is MFC'able.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D44122


# 04fc3fb8 27-Feb-2024 John Baldwin <jhb@FreeBSD.org>

rman: Remove rman_set_start/end

These functions are not safe as the rman implementation assumes that
all regions (including allocated resources) are sorted by address in
the internal linked-list.

Differential Revision: https://reviews.freebsd.org/D43936


# 95ee2897 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/


# 82a5a275 17-Dec-2018 Andriy Gapon <avg@FreeBSD.org>

add support for marking interrupt handlers as suspended

The goal of this change is to fix a problem with PCI shared interrupts
during suspend and resume.

I have observed a couple of variations of the following scenario.
Devices A and B are on the same PCI bus and share the same interrupt.
Device A's driver is suspended first and the device is powered down.
Device B generates an interrupt. Interrupt handlers of both drivers are
called. Device A's interrupt handler accesses registers of the powered
down device and gets back bogus values (I assume all 0xff). That data is
interpreted as interrupt status bits, etc. So, the interrupt handler
gets confused and may produce some noise or enter an infinite loop, etc.

This change affects only PCI devices. The pci(4) bus driver marks a
child's interrupt handler as suspended after the child's suspend method
is called and before the device is powered down. This is done only for
traditional PCI interrupts, because only they can be shared.

At the moment the change is only for x86.

Notable changes in core subsystems / interfaces:
- BUS_SUSPEND_INTR and BUS_RESUME_INTR methods are added to bus
interface along with convenience functions bus_suspend_intr and
bus_resume_intr;
- rman_set_irq_cookie and rman_get_irq_cookie functions are added to
provide a way to associate an interrupt resource with an interrupt
cookie;
- intr_event_suspend_handler and intr_event_resume_handler functions
are added to the MI interrupt handler interface.

I added two new interrupt handler flags, IH_SUSP and IH_CHANGED, to
implement the new intr_event functions. IH_SUSP marks a suspended
interrupt handler. IH_CHANGED is used to implement a barrier that
ensures that a change to the interrupt handler's state is visible
to future interrupts.
While there, I fixed some whitespace issues in comments and changed a
couple of logically boolean variables to be bool.

MFC after: 1 month (maybe)
Differential Revision: https://reviews.freebsd.org/D15755


# 9b10f59a 13-Dec-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

SPDX: mostly fixes to previous changes.

Introduce the recently approved BSD-1-Clause and replace 0BSD which
never did fit well our use cases.


# bd937497 09-Aug-2016 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

Consistently use `device_t`

Several files use the internal name of `struct device` instead of
`device_t` which is part of the public API. This patch changes all
`struct device *` to `device_t`.

The remaining occurrences of `struct device` are those referring to the
Linux or OpenBSD version of the structure, or the code is not built on
FreeBSD and it's unclear what to do.

Submitted by: Matthew Macy <mmacy@nextbsd.org> (previous version)
Approved by: emaste, jhibbits, sbruno
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D7447


# cc981af2 20-May-2016 John Baldwin <jhb@FreeBSD.org>

Add new bus methods for mapping resources.

Add a pair of bus methods that can be used to "map" resources for direct
CPU access using bus_space(9). bus_map_resource() creates a mapping and
bus_unmap_resource() releases a previously created mapping. Mappings are
described by 'struct resource_map' object. Pointers to these objects can
be passed as the first argument to the bus_space wrapper API used for bus
resources.

Drivers that wish to map all of a resource using default settings
(for example, using uncacheable memory attributes) do not need to change.
However, drivers that wish to use non-default settings can now do so
without jumping through hoops.

First, an RF_UNMAPPED flag is added to request that a resource is not
implicitly mapped with the default settings when it is activated. This
permits other activation steps (such as enabling I/O or memory decoding
in a device's PCI command register) to be taken without creating a
mapping. Right now the AGP drivers don't set RF_ACTIVE to avoid using
up a large amount of KVA to map the AGP aperture on 32-bit platforms.
Once RF_UNMAPPED is supported on all platforms that support AGP this
can be changed to using RF_UNMAPPED with RF_ACTIVE instead.

Second, bus_map_resource accepts an optional structure that defines
additional settings for a given mapping.

For example, a driver can now request to map only a subset of a resource
instead of the entire range. The AGP driver could also use this to only
map the first page of the aperture (IIRC, it calls pmap_mapdev() directly
to map the first page currently). I will also eventually change the
PCI-PCI bridge driver to request mappings of the subset of the I/O window
resource on its parent side to create mappings for child devices rather
than passing child resources directly up to nexus to be mapped. This
also permits bridges that do address translation to request suitable
mappings from a resource on the "upper" side of the bus when mapping
resources on the "lower" side of the bus.

Another attribute that can be specified is an alternate memory attribute
for memory-mapped resources. This can be used to request a
Write-Combining mapping of a PCI BAR in an MI fashion. (Currently the
drivers that do this call pmap_change_attr() directly for x86 only.)

Note that this commit only adds the MI framework. Each platform needs
to add support for handling RF_UNMAPPED and thew new
bus_map/unmap_resource methods. Generally speaking, any drivers that
are calling rman_set_bustag() and rman_set_bushandle() need to be
updated.

Discussed on: arch
Reviewed by: cem
Differential Revision: https://reviews.freebsd.org/D5237


# 886b793d 19-May-2016 John Baldwin <jhb@FreeBSD.org>

Remove dangling references to rman_await_resource().

This function was removed when RF_TIMESHARE was removed a couple of years
ago.

MFC after: 3 days


# 7c6f639b 04-May-2016 Enji Cooper <ngie@FreeBSD.org>

Revert r299096

The change broke buildworld when building lib/libkvm

This change likely needs to be run through a ports -exp run as a sanity
check, as it might break downstream consumers.

Pointyhat to: adrian
Reported by: kargl (confirmed on $work workstation)
Sponsored by: EMC / Isilon Storage Division


# 1b34262b 04-May-2016 Adrian Chadd <adrian@FreeBSD.org>

s/struct device */device_t/g

Submitted by: kmacy


# e9038569 19-Feb-2016 Justin Hibbits <jhibbits@FreeBSD.org>

Fix the definition of RM_MAX_END.

Even though casting from signed to unsigned is well-defined in C, it's better to
first cast to the larger unsigned type, then negate.


# 7915adb5 19-Feb-2016 Justin Hibbits <jhibbits@FreeBSD.org>

Introduce a RMAN_IS_DEFAULT_RANGE() macro, and use it.

This simplifies checking for default resource range for bus_alloc_resource(),
and improves readability.

This is part of, and related to, the migration of rman_res_t from u_long to
uintmax_t.

Discussed with: jhb
Suggested by: marcel


# 582d0519 26-Jan-2016 Justin Hibbits <jhibbits@FreeBSD.org>

Fix the build post-r294883.

Pointy-hat to: jhibbits
X-MFC with: r294883


# 2dd1bdf1 26-Jan-2016 Justin Hibbits <jhibbits@FreeBSD.org>

Convert rman to use rman_res_t instead of u_long

Summary:
Migrate to using the semi-opaque type rman_res_t to specify rman resources. For
now, this is still compatible with u_long.

This is step one in migrating rman to use uintmax_t for resources instead of
u_long.

Going forward, this could feasibly be used to specify architecture-specific
definitions of resource ranges, rather than baking a specific integer type into
the API.

This change has been broken out to facilitate MFC'ing drivers back to 10 without
breaking ABI.

Reviewed By: jhb
Sponsored by: Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D5075


# d3a68794 16-Jul-2014 Don Lewis <truckman@FreeBSD.org>

Nuke the never-used RF_TIMESHARE feature, reducing the complexity of the
code. The consensus on arch@ is that this feature might have been useful
in the distant past, but is now just unnecessary bloat.

The int_rman_activate_resource() and int_rman_deactivate_resource()
functions become trivial, so manually inline them.

The special deferred handling of RF_ACTIVE is no longer needed in
reserve_resource_bound(), so eliminate the associated code at the
end of the function.

These changes reduce the object file size by more than 500 bytes on i386.

Update the rman.9 man page to reflect the removal of the RF_TIMESHARE
feature.

MFC after: 2 weeks


# d7ccbd70 27-Feb-2012 John Baldwin <jhb@FreeBSD.org>

Typo.


# bb82622c 29-Apr-2011 John Baldwin <jhb@FreeBSD.org>

Extend the rman(9) API to support altering an existing resource.
Specifically, these changes allow a resource to back a relocatable and
resizable resource such as the I/O window decoders in PCI-PCI bridges.
- rman_adjust_resource() can adjust the start and end address of an
existing resource. It only succeeds if the newly requested address
space is already free. It also supports shrinking a resource in
which case the freed space will be marked unallocated in the rman.
- rman_first_free_region() and rman_last_free_region() return the
start and end addresses for the first or last unallocated region in
an rman, respectively. This can be used to determine by how much
the resource backing an rman must be adjusted to accomodate an
allocation request that does not fit into the existing rman.

While here, document the rm_start and rm_end fields in struct rman,
rman_is_region_manager(), the bound argument to
rman_reserve_resource_bound(), and rman_init_from_resource().


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# ccdc8d9b 11-Jun-2006 Warner Losh <imp@FreeBSD.org>

Add a convenience function rman_init_from_resource for initializing
a rman from a resource.

Also, include _bus.h since the implementation of bus_space isn't
needed here, just the definitions of the types.


# 8f405ed3 28-Apr-2006 Marcel Moolenaar <marcel@FreeBSD.org>

Remove the puc-specific hacks. The puc(4) driver now properly uses
the rman(9) interface.


# 06945066 06-Oct-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Eliminate __RMAN_RESOURCE_VISIBLE hack entirely by moving the struct
resource_ to subr_rman.c where it belongs.


# 64fd97df 28-Sep-2005 Poul-Henning Kamp <phk@FreeBSD.org>

puc(4) does strange things to resources in order to fool the
subdrivers to hook up.

It should probably be rewritten to implement a simple bus to which
the sub drivers attach using some kind of hint.

Until then, provide a couple of crutch functions with big warning
signs so it can survive the recent changes to struct resource.


# 2b35175c 25-Sep-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Add rman_is_region_manager() for the benefit of an alpha hack.


# ae7ff71f 24-Sep-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Split struct resource in an external and internal part.

The external part is still called 'struct resource' but the contents
is now visible to drivers etc. This makes it part of the device
driver ABI so it not be changed lightly. A comment to this effect
is in place.

The internal part is called 'struct resource_i' and contain its external
counterpart as one field.

Move the bus_space tag+handle into the external struct resource, this
removes the need for device drivers to even know about these fields
in order to use bus_space to access hardware. (More in following commit).


# a7789231 24-Sep-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Add two convenience functions for device drivers: bus_alloc_resources()
and bus_free_resources(). These functions take a list of resources
and handle them all in one go. A flag makes it possible to mark
a resource as optional.

A typical device driver can save 10-30 lines of code by using these.

Usage examples will follow RSN.

MFC: A good idea, eventually.


# f351862a 12-Apr-2005 Warner Losh <imp@FreeBSD.org>

rman_set_device() seems to have been omitted by mistake. Implement it.


# 60727d8b 06-Jan-2005 Warner Losh <imp@FreeBSD.org>

/* -> /*- for license, minor formatting changes


# d79af75b 09-Nov-2004 Warner Losh <imp@FreeBSD.org>

Learn that 'b' comes before 'e' in ISO-LATIN-1


# 889e265c 09-Nov-2004 Warner Losh <imp@FreeBSD.org>

Sort function names.


# d5daf6c0 10-Sep-2004 Warner Losh <imp@FreeBSD.org>

Add two spare fields to struct resource for some planned enhacenments
to make it possible to merge them w/o changing the size of struct resource
which some drivers unfortunately still need to know.


# deb96548 01-Jul-2004 Warner Losh <imp@FreeBSD.org>

Soften __RMAN_RESOURCE_VISIBLE a little: expose rman and the
resource_head types. Also add a way to set start and end so fewer
things need to reach into struct resource.

Pointy hat to: imp for breaking the build on so many platforms.


# 0363a126 30-Jun-2004 Warner Losh <imp@FreeBSD.org>

Hide struct resource and struct rman. You must define
__RMAN_RESOURCE_VISIBLE to see inside these now.

Reviewed by: dfr, njl (not njr)


# a757985c 30-May-2004 Warner Losh <imp@FreeBSD.org>

Include <machine/bus.h> and <machine/resource.h> here (only in the
kernel). No other sys/*.h file requires machine/foo.h to be included
before it. In addition, all the files that include rman.h would need
to include those two anyway. From these two perspectives, it is
traditional to include things like this.

This lets us stop treating sys/rman.h specially in every bus frontend
file.


# b235704d 12-Feb-2003 Warner Losh <imp@FreeBSD.org>

Implement rman_get_device

# I though this was alredy implemented

Pointy hat on my head shown by: peter


# 647501a0 26-Nov-2002 Warner Losh <imp@FreeBSD.org>

Make the rman_{get,set}_* macros into real functions. The macros
create an ABI that encodes offsets and sizes of structures into client
drivers. The functions isolate the ABI from changes to the resource
structure. Since these are used very rarely (once at startup), the
speed penalty will be down in the noise.

Also, add r_rid to the structure so that clients can save the 'rid' of
the resource in the struct resource, plus accessor functions. Future
additions to newbus will make use of this to present a simplified
interface for resource specification.

Approved by: re (jhb)
Reviewed by: jhb, jake


# 13fb6657 21-Dec-2001 Thomas Moestl <tmm@FreeBSD.org>

Add a rman_reserve_resource_bound() function that takes an additional
argument specifying the boundary for the resource allocation.
Use ulmin()/ulmax() instead of min()/max() in some places to correctly
deal with the u_long resource range specifications.


# 5752bffd 04-Sep-2001 David E. O'Brien <obrien@FreeBSD.org>

style(9) the structure definitions.


# 63fa9f4c 26-Aug-2001 Jonathan Chen <jon@FreeBSD.org>

Part two of this NEWCARD update:

Briefly, the significant changes include:
* Way better resource management in pccbb, pccard and cardbus.
* pccard hot-removal now appears to work.
* support pre-fetchable memory in cardbus.
* update cardbus to support new pci bus interface functions.
* Fix CIS reading to no longer use rman_get_virtual().

What's not there, but in the works:
* pccard needs to do interrupt properly and not read the ISR on single
function cards.
* real resource management for pccard
* a complete implementation of CIS parsing
* need to look into how to correctly use mutex in pccbb


# 1b367556 23-Jan-2001 Jason Evans <jasone@FreeBSD.org>

Convert all simplelocks to mutexes and remove the simplelock implementations.


# a077f635 14-Nov-2000 Kirk McKusick <mckusick@FreeBSD.org>

In preparation for deprecating CIRCLEQ macros in favor of TAILQ
macros which provide the same functionality and are a bit more
efficient, convert use of CIRCLEQ's in resource manager to TAILQ's.

Approved by: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>


# 6e379305 09-Nov-2000 Garrett Wollman <wollman@FreeBSD.org>

Fix a reference to ``Standard C'' to refer specifically to the 1990 version;
the requirement it describes is not in C99.


# edcb5775 09-Nov-2000 Mike Smith <msmith@FreeBSD.org>

Implement a trivial but effective interface for obtaining the kernel's
device tree and resource manager contents. This is the kernel side of
the upcoming libdevinfo, which will expose this information to userspace
applications in a trivial fashion.

Remove the now-obsolete DEVICE_SYSCTLS code.


# 7f9b2046 17-Oct-2000 Matthew N. Dodd <mdodd@FreeBSD.org>

Add rman_get_size(), which does what you would expect.

Further commits to make use of this will follow.


# 85d693f9 17-Oct-2000 Warner Losh <imp@FreeBSD.org>

Implement resource alignment as discussed in arch@ a long time ago.
This was implemented by Shigeru YAMAMOTO-san and Jonathan Chen. I've
cleaned them up somewhat and they seem to work well enough to boot
current (but given current's state it can be hard to tell). Doug
Rabson also reviewed the design and signed off on it.


# e3975643 25-May-2000 Jake Burkholder <jake@FreeBSD.org>

Back out the previous change to the queue(3) interface.
It was not discussed and should probably not happen.

Requested by: msmith and others


# 740a1973 23-May-2000 Jake Burkholder <jake@FreeBSD.org>

Change the way that the queue(3) structures are declared; don't assume that
the type argument to *_HEAD and *_ENTRY is a struct.

Suggested by: phk
Reviewed by: phk
Approved by: mdodd


# 0ac8befe 16-Apr-2000 Warner Losh <imp@FreeBSD.org>

Remove RF_PCCARD_ATTR. I should have done this before 4.0. It isn't part
of the API.


# 796b3a67 09-Jan-2000 Warner Losh <imp@FreeBSD.org>

Add new resource flag type: RF_PCCARD_ATTR for pccard's attribute memory.
This was suggested by Doug a while ago.


# 664a31e4 28-Dec-1999 Peter Wemm <peter@FreeBSD.org>

Change #ifdef KERNEL to #ifdef _KERNEL in the public headers. "KERNEL"
is an application space macro and the applications are supposed to be free
to use it as they please (but cannot). This is consistant with the other
BSD's who made this change quite some time ago. More commits to come.


# c3aac50f 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 6182fdbd 16-Apr-1999 Peter Wemm <peter@FreeBSD.org>

Bring the 'new-bus' to the i386. This extensively changes the way the
i386 platform boots, it is no longer ISA-centric, and is fully dynamic.
Most old drivers compile and run without modification via 'compatability
shims' to enable a smoother transition. eisa, isapnp and pccard* are
not yet using the new resource manager. Once fully converted, all drivers
will be loadable, including PCI and ISA.

(Some other changes appear to have snuck in, including a port of Soren's
ATA driver to the Alpha. Soren, back this out if you need to.)

This is a checkpoint of work-in-progress, but is quite functional.

The bulk of the work was done over the last few years by Doug Rabson and
Garrett Wollman.

Approved by: core


# af2a5c76 28-Oct-1998 Garrett Wollman <wollman@FreeBSD.org>

The new resource manager, hopefully in a reasonably stable form.