History log of /freebsd-current/sys/dev/ofw/ofwbus.c
Revision Date Author Comments
# 9dbf5b0e 13-Mar-2024 John Baldwin <jhb@FreeBSD.org>

new-bus: Remove the 'rid' and 'type' arguments from BUS_RELEASE_RESOURCE

The public bus_release_resource() API still accepts both forms, but
the internal kobj method no longer passes the arguments.
Implementations which need the rid or type now use rman_get_rid() or
rman_get_type() to fetch the value from the allocated resource.

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


# fdafd315 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

sys: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 9105ba04 25-May-2023 Christos Margiolis <christos@FreeBSD.org>

ofw: remove redundant calls in ofwbus_attach()

Since commit ecaecbc7d8bc212d8e854088106b3b21e631bb52, calling
ofw_bus_gen_setup_devinfo() is redundant, as the call to
device_set_ivars() now happens inside simplebus_add_device().

Reviewed by: markj
Approved by: markj (mentor)
Differential Revision: https://reviews.freebsd.org/D40271


# 38594ff9 10-Apr-2023 Christos Margiolis <christos@FreeBSD.org>

ofw: fix memory leak in ofwbus_attach()

PR: 269509
Reported by: Jaroslaw Pelczar <jarek@jpelczar.com>
Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D38903


# afca197f 13-Feb-2023 Mitchell Horne <mhorne@FreeBSD.org>

ofwbus: only allow unit number zero

ofwbus has always been the root of attachment for OFW/FDT platforms. It
may have simplebus children, but we expect only one instance of the
ofwbus driver, added directly by nexus. We may as well ensure this
remains the case.

Reviewed by: jhb
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D38493


# 53d5e65e 13-Feb-2023 Mitchell Horne <mhorne@FreeBSD.org>

ofwbus: remove arm64 ifdefs

Rather than using the DEVICE_IDENTIFY method, let's have other
ofwbus-using platforms add ofwbus0 explicitly in nexus, like arm64. This
gives them the same flexibility, e.g. if riscv starts supporting ACPI,
and cleans up the #ifdefs.

We were doing this already on riscv, but adjust the 'order' parameters.

Reviewed by: andrew, jhb
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D38492


# 99553344 13-Feb-2023 Mitchell Horne <mhorne@FreeBSD.org>

ofwbus: trim includes

Nothing in the file today relies on these.

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D38491


# f9bdaab9 08-Feb-2023 Elliott Mitchell <ehem+freebsd@m5p.com>

ofwbus: remove handling of resources from ofwbus

The architecture nexus should handle allocation and release of memory and
interrupts. This is to ensure that system-wide resources such as these
are available to all devices, not just children of ofwbus0.

On powerpc this moves the ownership of these resources up one level,
from ofwbus0 to nexus0. Other architectures already have the required
logic in their nexus implementation, so this eliminates the duplication
of resources. An implementation of nexus_adjust_resource() is added for
arm, arm64, and riscv.

As noted by ian@ in the review, resource handling was the main bit of
logic distinguishing ofwbus from simplebus. With some attention to
detail, it should be possible to merge the two in the future.

Co-authored by: mhorne
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D30554


# 03f6459c 09-May-2022 John Baldwin <jhb@FreeBSD.org>

ofw drivers: Remove unused devclass arguments to DRIVER_MODULE.


# 895c8b1c 19-Aug-2016 Michal Meloun <mmel@FreeBSD.org>

INTRNG: Rework handling with resources. Partially revert r301453.
- Read interrupt properties at bus enumeration time and store
it into global mapping table.
- At bus_activate_resource() time, given mapping entry is resolved and
connected to real interrupt source. A copy of mapping entry is attached
to given resource.
- At bus_setup_intr() time, mapping entry stored in resource is used
for delivery of requested interrupt configuration.
- For MSI/MSIX interrupts, mapping entry is created within
pci_alloc_msi()/pci_alloc_msix() call.
- For legacy PCI interrupts, mapping entry must be created within
pcib_route_interrupt() by pcib driver itself.

Reviewed by: nwhitehorn, andrew
Differential Revision: https://reviews.freebsd.org/D7493


# ad5244ec 05-Jun-2016 Svatopluk Kraus <skra@FreeBSD.org>

INTRNG - change the way how an interrupt mapping data are provided
to the framework in OFW (FDT) case.

This is a follow-up to r301451.

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


# da1b038a 17-Mar-2016 Justin Hibbits <jhibbits@FreeBSD.org>

Use uintmax_t (typedef'd to rman_res_t type) for rman ranges.

On some architectures, u_long isn't large enough for resource definitions.
Particularly, powerpc and arm allow 36-bit (or larger) physical addresses, but
type `long' is only 32-bit. This extends rman's resources to uintmax_t. With
this change, any resource can feasibly be placed anywhere in physical memory
(within the constraints of the driver).

Why uintmax_t and not something machine dependent, or uint64_t? Though it's
possible for uintmax_t to grow, it's highly unlikely it will become 128-bit on
32-bit architectures. 64-bit architectures should have plenty of RAM to absorb
the increase on resource sizes if and when this occurs, and the number of
resources on memory-constrained systems should be sufficiently small as to not
pose a drastic overhead. That being said, uintmax_t was chosen for source
clarity. If it's specified as uint64_t, all printf()-like calls would either
need casts to uintmax_t, or be littered with PRI*64 macros. Casts to uintmax_t
aren't horrible, but it would also bake into the API for
resource_list_print_type() either a hidden assumption that entries get cast to
uintmax_t for printing, or these calls would need the PRI*64 macros. Since
source code is meant to be read more often than written, I chose the clearest
path of simply using uintmax_t.

Tested on a PowerPC p5020-based board, which places all device resources in
0xfxxxxxxxx, and has 8GB RAM.
Regression tested on qemu-system-i386
Regression tested on qemu-system-mips (malta profile)

Tested PAE and devinfo on virtualbox (live CD)

Special thanks to bz for his testing on ARM.

Reviewed By: bz, jhb (previous)
Relnotes: Yes
Sponsored by: Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D4544


# 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


# e2d4f32f 18-Feb-2016 Zbigniew Bodek <zbb@FreeBSD.org>

Fix bug in ofwbus_release_resource() for non-ofwbus descendants

Resource list for devices that are not ofwbus descendants, but
got to ofwbus method via bus_generic_release_resource() call chain,
cannot be found using BUS_GET_RESOURCE_LIST() used by ofwbus.
In that case, changing device's resource list should be avoided
(will not contain resource list prepared by ofw or simplebus).

Pointy-hat to: zbb
Reviewed by: wma
Obtained from: Semihalf
Sponsored by: Cavium
Differential Revision: https://reviews.freebsd.org/D5304


# 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


# 2c0d026b 05-May-2015 Andrew Turner <andrew@FreeBSD.org>

Move the point we attach the ofw driver on arm64 to nexus.c. This will
allow us to have a single place to decide to use ofw or acpi.


# ecaecbc7 27-Mar-2015 Ian Lepore <ian@FreeBSD.org>

Make simplebus a base class of ofwbus. This allows the elimination of
duplicated code in the two classes, and also allows devices in FDT-based
systems to declare simplebus as their parent and still work correctly
when the FDT data describes the device at the root of the tree rather
than as a child of a simplebus (which is common for interrupt, clock,
and power controllers).

Differential Revision: https://reviews.freebsd.org/D1990
Submitted by: Michal Meloun


# 4b3d9160 12-Jan-2015 Zbigniew Bodek <zbb@FreeBSD.org>

Introduce ofw_bus_reg_to_rl() to replace part of common bus code

Instead of reusing the same reg parsing code, create one, common function
that puts reg contents to the resource list. Address cells and size cells
are passed rather than acquired here so that any bus can have different
default values.

Obtained from: Semihalf
Reviewed by: andrew, ian, nwhitehorn
Sponsored by: The FreeBSD Foundation


# 76a8ef26 07-Nov-2014 Zbigniew Bodek <zbb@FreeBSD.org>

Avoid panic in ofwbus caused by not released resource list entry

After resource allocation and release, resource list entry
stays non-NULL. This causes panic in ofwbus_alloc_resource()
on subsequent resource allocation.
Clean appropriate list entry on release to avoid this.

Obtained from: Semihalf
Reviewed by: ian
Sponsored by: The FreeBSD Foundation


# c47d4cde 25-Sep-2014 Ian Lepore <ian@FreeBSD.org>

Replace multiple nearly-identical copies of code to walk through an FDT
node's interrupts=<...> property creating resource list entries with a
single common implementation. This change makes ofw_bus_intr_to_rl() the
one true copy of that code and removes the copies of it from other places.

This also adds handling of the interrupts-extended property, which allows
specifying multiple interrupts for a node where each interrupt can have a
separate interrupt-parent. The bindings for this state that the property
cells contain an xref phandle to the interrupt parent followed by whatever
interrupt info that parent normally expects. This leads to having a
variable number of icells per interrupt in the property. For example you
could have <&intc1 1 &intc2 26 9 0 &intc3 9 4>.

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


# 752ba930 01-Sep-2014 Ian Lepore <ian@FreeBSD.org>

Rename OF_xref_phandle() to OF_node_from_xref() and add a new function
that provides the inverse translation, OF_xref_from_node().

Discussed with: nwhitehorn


# c654477e 09-Aug-2014 Ian Lepore <ian@FreeBSD.org>

Handle various ways that interrupt config data can be malformed by
warning and assuming more or less reasonable values.


# 1fb6bc18 09-Aug-2014 Ian Lepore <ian@FreeBSD.org>

Use a separate variable for resource id, because 'i' may increment at a
rate greater than 1 on each iteration.


# 633dbf2e 05-Aug-2014 Ian Lepore <ian@FreeBSD.org>

Adjust ofwbus and simplebus to attach at BUS_PASS_ORDER_MIDDLE, so that
a platform can attach some other bus first if necessary.


# 2d12d35c 05-Aug-2014 Ian Lepore <ian@FreeBSD.org>

Set ofwbus and simplebus to attach during BUS_PASS_BUS.


# e2fc1af4 11-May-2014 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

OF_peer() in IEEE 1275 returns 0 if no peer exists, not -1.


# 65d08437 05-Feb-2014 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Move Open Firmware device root on PowerPC, ARM, and MIPS systems to
a sub-node of nexus (ofwbus) rather than direct attach under nexus. This
fixes FDT on x86 and will make coexistence with ACPI on ARM systems easier.
SPARC is unchanged.

Reviewed by: imp, ian