History log of /freebsd-current/sys/dev/ofw/openfirm.c
Revision Date Author Comments
# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

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

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


# ec666d18 11-Aug-2022 Andrew Turner <andrew@FreeBSD.org>

Adjust function definition in ofw to avoid clang 15 warning

With clang 15, the following -Werror warning is produced:

sys/dev/ofw/openfirm.c:826:9: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
OF_enter()
^
void

This is because OF_enter() and OF_exit are declared with a (void)
argument list, but defined with an empty argument list. Make the
definition match the declaration.

Sponsored by: The FreeBSD Foundation


# f7604b1b 09-Apr-2018 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

Align OF_getencprop_alloc API with OF_getencprop and OF_getprop_alloc

Change OF_getencprop_alloc semantics to be combination of malloc and
OF_getencprop and return size of the property, not number of elements
allocated.

For the use cases where number of elements is preferred introduce
OF_getencprop_alloc_multi helper function that copies semantics
of OF_getencprop_alloc prior to this change.

This is to make OF_getencprop_alloc and OF_getencprop_alloc_multi
function signatures consistent with OF_getencprop_alloc and
OF_getencprop_alloc_multi.

Functionality-wise this patch is mostly rename of OF_getencprop_alloc
to OF_getencprop_alloc_multi except two calls in ofw_bus_setup_iinfo
where 1 was used as a block size.


# c581f24a 08-Apr-2018 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

Make OF_searchencprop signature consistent with OF_getencprop

Use pcell_t* as a destination buffer argument instead of void
pointer to be consistent with OF_getencprop signature.


# 217d17bc 08-Apr-2018 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

Clean up OF_getprop_alloc API

OF_getprop_alloc takes element size argument and returns number of
elements in the property. There are valid use cases for such behavior
but mostly API consumers pass 1 as element size to get string
properties. What API users would expect from OF_getprop_alloc is to be
a combination of malloc + OF_getprop with the same semantic of return
value. This patch modifies API signature to match these expectations.

For the valid use cases with element size != 1 and to reduce
modification scope new OF_getprop_alloc_multi function has been
introduced that behaves the same way OF_getprop_alloc behaved prior to
this patch.

Reviewed by: ian, manu
Differential Revision: https://reviews.freebsd.org/D14850


# 2bfca577 27-Nov-2017 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Back out OF module installation in the event of failure. PS3 firmware gives
some ancient FDT version (2) that fails the init check in OFW_FDT. It is
still possible to make progress, but not while the OF layer is going crazy.


# 718cf2cc 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/dev: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.


# bc90a48c 11-May-2016 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

Add OF_prop_free function as a counterpart for OF_*prop_alloc

- Introduce new OF API function OF_prop_free to free memory allocated by
OF_getprop_alloc and OF_getencprop_alloc. Current code just calls free(9)
with M_OFWPROP memory class which assumes knowledge about OF_*prop_alloc
functions' internals and leads to unneccessary code coupling

- Convert some of the free(..., M_OFWPROP) instances to OF_prop_free

Files affected by this commit are the ones I was able to test on real
hardware. The rest of free(..., M_OFWPROP) instances will be handled with
idividual maintainers

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D6315


# 073fae86 25-Jan-2016 Zbigniew Bodek <zbb@FreeBSD.org>

Do not destroy input buffer of the OF_getencprop() function on error

Currently when the OF_getprop() function returns with error,
the caller (OF_getencprop()) still changes the buffer endiannes.
This may destroy the default value passed in the input buffer if
used on a Little Endian platform.

Reviewed by: mmel
Submitted by: Zbigniew Bodek <zbb@semihalf.com>
Obtained from: Semihalf
Sponsored by: Cavium


# a7ce3cb1 24-Jan-2016 Andrew Turner <andrew@FreeBSD.org>

Fix the style of the reading of a nodes xref to make it readable.


# a8359209 30-Mar-2015 Zbigniew Bodek <zbb@FreeBSD.org>

Fix bug in xrefinfo_find() for 64-bit platforms

uintptr_t may be 64-bit on some platforms, therefore when
finding xrefinfo by pointer to device the high word is being
cut off due to cast to phandle_t which is 32-bit long by definition.
Due to that we loose the high word of the address to compare with
xi->dev's address.
To fix that, first argument of xrefinfo_find() is extended to
uintptr_t and is being cast to appropriate type (phandle_t)
when compared.

Submitted by: Zbigniew Bodek <zbb@semihalf.com>
Reviewed by: nwhitehorn
Obtained from: Semihalf


# 9855acef 30-Jan-2015 Luiz Otavio O Souza <loos@FreeBSD.org>

Do not leak the OFW memory when the result does not satisfy our alignment
requirement.

While here, fix style(9) issues.


# 26511eb0 06-Sep-2014 Ian Lepore <ian@FreeBSD.org>

When registering an association between a device and an xref phandle, create
an entry in the xref list if one doesn't already exist for the given handle.

On a system that uses phandle properties, the init-time scan of the tree
which builds the xref list will pre-create entries for every xref handle
that exists in the data. On systems where the xref and node handles are
synonymous there is no phandle property in referenced nodes, and the xref
list will initialize to an empty state. In the latter case, we still need
to be able to associate a device_t with an xref handle, so we create list
entries on the fly as needed. Since the node and xref handles are
synonymous, we have all the info needed to create a list entry at device
registration time.

The downside to this change is that it basically allows on the fly creation
of xref handles as synonyms of node handles, and the association of a
device_t with them. Whether this is a bug or a feature is in the eye of
the beholder, I guess.


# f021180b 06-Sep-2014 Ian Lepore <ian@FreeBSD.org>

Revert rr271190, it was based on a misunderstanding. The problem of
non-existant device<->xref info needs to be handled by creating the info,
which will come in a subsequent commit.


# 00eea22f 06-Sep-2014 Ian Lepore <ian@FreeBSD.org>

Add OF_xref_from_node_strict() which returns -1 if there is no xref handle
for the node. The default routine returns the untranslated handle, which
is sometimes useful, but sometimes you really need to know there's no
entry in the xref<->node<->device translation table.


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

Fix typo.

Pointy hat: ian


# 937f32c0 01-Sep-2014 Ian Lepore <ian@FreeBSD.org>

Add OF_xref_from_device() so that there's no need to have an intermediate
call to ofw_bus_get_node() to lookup info that's already in the xreflist.


# 274245c8 01-Sep-2014 Ian Lepore <ian@FreeBSD.org>

Create a mechanism for looking up a device_t associated with an ofw/fdt
xref handle, and for registering that association. Also use the same data
for faster translations between node and xref handles.

Now when fdt properties contain &othernode references, a driver can find
the device instance that corresponds to &othernode, and thus can use
interfaces provided by that instance.

Reviewed by: nwhitehorn


# 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


# d3a0a0f3 23-Oct-2013 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Make all Open Firmware internal interfaces endian-safe by using the new
OF_getencprop() API. This removes one explicit endianness conversion in
ofw_iicbus.c.


# 5e40646c 22-Oct-2013 Andreas Tobler <andreast@FreeBSD.org>

Fix build.


# 4231c48f 22-Oct-2013 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

A few other common cases for encode-int decoding: OF_getencprop_alloc()
and OF_searchencprop(). I thought about using the element size parameter
to OF_getprop_alloc() to do endian-switching automatically, but it breaks
use with structs and a *lot* of FDT code (which can hopefully be moved to
these new APIs).

MFC after: 2 weeks


# 29fdf9ef 22-Oct-2013 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Add a new function (OF_getencprop()) that undoes the transformation applied
by encode-int. Specifically, it takes a set of 32-bit cell values and
changes them to host byte order. Most non-string instances of OF_getprop()
should be using this function, which is a no-op on big-endian platforms.


# c0888418 15-Sep-2013 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Add a kernel interface (OF_xref_phandle()) for systems where phandles
used as cross-references in the device tree and phandles as used by the
Open Firmware client interface are in different namespaces. This include
IBM pSeries hardware as well as FDT systems. FDT certainly abuses
ihandles for this purpose and should be modified to use this API
eventually. This changes no behavior on systems where FreeBSD already
worked.

Reviewed by: marius
Approved by: re (kib)
MFC after: 2 weeks


# 26ca4965 18-Aug-2012 Hiroki Sato <hrs@FreeBSD.org>

- Add OF_hasprop() and ofw_bus_has_prop(). These can be used to check
existence of the property.

- Fix ofw_bus_is_compatible{,_strict}() to prevent substring match in the
compatible string.

Reviewed by: raj


# 1cbb2a24 27-Jan-2012 Marius Strobl <marius@FreeBSD.org>

Implement OF_printf() using kvprintf() directly, avoiding to use a
buffer and allowing to handle newlines properly


# 07042bef 02-Dec-2011 Jayachandran C. <jchandra@FreeBSD.org>

Fix OF_finddevice error return value in case of FDT.

According to the open firmware standard, finddevice call has to return
a phandle with value of -1 in case of error.

This commit is to:
- Fix the FDT implementation of this interface (ofw_fdt_finddevice) to
return (phandle_t)-1 in case of error, instead of 0 as it does now.
- Fix up the callers of OF_finddevice() to compare the return value with
-1 instead of 0 to check for errors.
- Since phandle_t is unsigned, the return value of OF_finddevice should
be checked with '== -1' rather than '<= 0' or '> 0', fix up these cases
as well.

Reported by: nwhitehorn

Reviewed by: raj
Approved by: raj, nwhitehorn


# d7ecd801 15-Nov-2011 Marius Strobl <marius@FreeBSD.org>

As it turns out, r186347 actually is insufficient to avoid the use of the
curthread-accessing part of mtx_{,un}lock(9) when using a r210623-style
curthread implementation on sparc64, crashing the kernel in its early
cycles as PCPU isn't set up, yet (and can't be set up as OFW is one of the
things we need for that, which leads to a chicken-and-egg problem). What
happens is that due to the fact that the idea of r210623 actually is to
allow the compiler to cache invocations of curthread, it factors out
obtaining curthread needed for both mtx_lock(9) and mtx_unlock(9) to
before the branch based on kobj_mutex_inited when compiling the kernel
without the debugging options. So change kobj_class_compile_static(9)
to just never acquire kobj_mtx, effectively restricting it to its
documented use, and add a kobj_init_static(9) for initializing objects
using a class compiled with the former and that also avoids using mutex(9)
(and malloc(9)). Also assert in both of these functions that they are
used in their intended way only.
While at it, inline kobj_register_method() and kobj_unregister_method()
as there wasn't much point for factoring them out in the first place
and so that a reader of the code has to figure out the locking for
fewer functions missing a KOBJ_ASSERT.
Tested on powerpc{,64} by andreast.

Reviewed by: nwhitehorn (earlier version), jhb
MFC after: 3 days


# 0bad71a3 09-Nov-2010 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Make all OF client interface calls return the maximum kind of
does-not-exist error when no client interface module is installed instead
of dereferencing NULL pointers. This eases implementation of platforms
that may or may not have Open Firmware.


# 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.


# cdb25d82 11-Sep-2010 Marius Strobl <marius@FreeBSD.org>

Change OF_interpret() to also take an array of cell_t (missed in r209801).

Reviewed by: nwhitehorn


# 054e5dcb 08-Jul-2010 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Change the argument type to OF_call_method to take an array of cell_t
instead of unsigned longs to prepare for platforms where they are not
the same.


# 8297758a 28-May-2010 Rafal Jaworowski <raj@FreeBSD.org>

Prepare and extend OFW layer for FDT support.

o Let OFW_INIT() and OF_init() return status value.

o Provide helper routines for 'compatible' property handling.

o Only compile OF and OFW code, which is relevant in FDT scenario.

o Other minor cosmetics

Reviewed by: imp
Sponsored by: The FreeBSD Foundation


# 4a26780b 16-May-2010 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Pull OF_quiesce() out of the MI Open Firmware layer and entirely into
PPC ofw_machdep.c, in recognition of its state as a machine specific hack.

Requested by: marius


# 79bf3fcd 16-May-2010 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

On PowerMac11,2 and (presumably) PowerMac12,1, we need to quiesce the
firmware in order to take over control of the SMU. Without doing this,
the firmware background process doing fan control will run amok as we
take over the system and crash the management chip.

This is limited to these two machines because our kernel is heavily
dependent on firmware accesses, and so quiescing firmware can cause
nasty problems.


# 481d6b54 13-Jun-2009 Marius Strobl <marius@FreeBSD.org>

Fix style.


# 49bbb93c 29-Mar-2009 Marius Strobl <marius@FreeBSD.org>

Unbreak OF_interpret() and its standard implementation after r186347.


# acb97117 03-Jan-2009 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Fix the OFW interrupt map parser to use its own idea of the number of interrupt
cells in the map, instead of using a value passed to it and then panicing if it
disagrees. This fixes interrupt map parsing for PCI bridges on some Apple
Uninorth PCI controllers.

Reported by: marcel
Tested on: G4 iBook, Sun Ultra 5


# 91416fb2 19-Dec-2008 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Modularize the Open Firmware client interface to allow run-time switching
of OFW access semantics, in order to allow future support for real-mode
OF access and flattened device frees. OF client interface modules are
implemented using KOBJ, in a similar way to the PPC PMAP modules.

Because we need Open Firmware to be available before mutexes can be used on
sparc64, changes are also included to allow KOBJ to be used very early in
the boot process by only using the mutex once we know it has been initialized.

Reviewed by: marius, grehan


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

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


# 89200512 05-Jul-2007 Peter Wemm <peter@FreeBSD.org>

Fix warnings.
nxge: cast page size fragments down to (int). If the vm's demand paging
PAGE_SIZE is ever too big for that, we've got far bigger problems.
ofw: move va_start() a little earlier. gcc-4.2 doesn't like us modifying
the last arg before the va_start().

Approved by: re (rwatson)


# adc40991 16-Jun-2007 Marius Strobl <marius@FreeBSD.org>

In OF_init() check the return value of OF_getprop().

Found with: Coverity Prevent(tm)
CID: 679


# 838f76c0 16-Jun-2007 Marius Strobl <marius@FreeBSD.org>

- Restore the machine independency of sys/dev/ofw/openfirm.{c,h} by
moving OF_set_mmfsa_traptable() (SUNW,set-trap-table with the two
arguments used here is specific to sun4v) to MD code.
- In sys/dev/ofw/openfirm.h remove prototypes for unimplemented
functions and unused Solaris compatibility macros.


# 7d62dd36 16-Jun-2007 Marius Strobl <marius@FreeBSD.org>

Sync the styles of sys/boot/ofw/libofw/openfirm.c and
sys/dev/ofw/openfirm.c with themselves, with each-other
and with style(9).


# e8bc49d7 10-Oct-2006 Kip Macy <kmacy@FreeBSD.org>

Using the ptr defines broke the powerpc build - convert set_mmfsa to the same
convention as the rest of openfirm.c


# 25e32849 08-Oct-2006 Kip Macy <kmacy@FreeBSD.org>

kernel clean up to make the sun4v kernel build

Reviewed by: jmg
Approved by: rwatson (mentor)


# 933b731c 22-Nov-2005 Marius Strobl <marius@FreeBSD.org>

Remove unused function and variables.


# 098ca2bd 05-Jan-2005 Warner Losh <imp@FreeBSD.org>

Start each of the license/copyright comments with /*-, minor shuffle of lines


# 39513fa6 16-Aug-2004 Marius Strobl <marius@FreeBSD.org>

Instead of "OpenFirmware", "openfirmware", etc. use the official spelling
"Open Firmware" from IEEE 1275 and OpenFirmware.org (no pun intended).

Ok'ed by: tmm


# a32a374c 22-May-2004 Marius Strobl <marius@FreeBSD.org>

- Rearrange a comment to fit in 80 chars per line, like the rest of this
file.
- Remove a superfluous ';'.


# aad970f1 24-Aug-2003 David E. O'Brien <obrien@FreeBSD.org>

Use __FBSDID().
Also some minor style cleanups.


# 2c7df6a5 07-Jun-2003 Jake Burkholder <jake@FreeBSD.org>

Implement OF_interpret.

Obtained from: netbsd


# a163d034 18-Feb-2003 Warner Losh <imp@FreeBSD.org>

Back out M_* changes, per decision of the TRB.

Approved by: trb


# 44956c98 21-Jan-2003 Alfred Perlstein <alfred@FreeBSD.org>

Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.


# 398e05ab 18-Nov-2001 Thomas Moestl <tmm@FreeBSD.org>

1. Add ofw_pci.h with definitions for the OpenFirmware PCI bindings
2. Add OF_getprop_alloc(), a helper function that will malloc() a sufficient
amount of memory and then retrieve a property value into it.

Approved by: benno
Obtained from: NetBSD (1)


# 8aa920fd 30-Jul-2001 Jake Burkholder <jake@FreeBSD.org>

Make the openfirmware functions work on 64 bit architectures by using
a standard cell_t type for the fields of all argument structs. Also
make ihandle_t and phandle_t unsigned to avoid sign extension problems.

Approved by: benno


# 97d9f676 26-Jun-2001 Benno Rice <benno@FreeBSD.org>

Garbage collect some debug code.


# 707fed20 16-Jun-2001 Benno Rice <benno@FreeBSD.org>

OpenFirmware kernel support, as used by the PowerPC and hopefully other
ports later on.

This includes the basic MI interface routines as well as a console driver.
The MD code is kept in the MD directories.

Reviewed by: obrien


# 4cc1860f 09-Nov-2000 Benno Rice <benno@FreeBSD.org>

OpenFirmware/PowerPC loader, part 2.

As of this patchset, the loader builds (under NetBSD/macppc), boots, interacts
and talks to BOOTP/NFS servers.

(main.c was moved from boot/ofw/libofw to boot/ofw/common but has no revision
history)

Reviewed by: obrien


# 146a7d53 16-Oct-2000 David E. O'Brien <obrien@FreeBSD.org>

"Ok, my loader's now up to putting up a prompt. It probes disks partially
but can't boot from them yet."

Thanks to Stephane Potvin for the some of the code in this set.

Submitted by: Benno Rice <benno@jeamland.net>