History log of /freebsd-10.0-release/sys/dev/ofw/
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
259065 07-Dec-2013 gjb

- Copy stable/10 (r259064) to releng/10.0 as part of the
10.0-RELEASE cycle.
- Update __FreeBSD_version [1]
- Set branch name to -RC1

[1] 10.0-CURRENT __FreeBSD_version value ended at '55', so
start releng/10.0 at '100' so the branch is started with
a value ending in zero.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


255596 15-Sep-2013 nwhitehorn

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


255424 09-Sep-2013 nwhitehorn

Make the primary name of the OF console device /dev/ofwcons, and only
alias it to the contents of the output property if it is defined. This
avoids a panic when booting machines (QEMU) where the output-device
property is not defined.

Since output-device is free-form and potentially conflicts with other
entries in /dev, I also am not sure we should be doing the aliasing at
all, but this at least makes things work again.

Approved by: re (kib)


239366 18-Aug-2012 hrs

- 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


239273 15-Aug-2012 gonzo

Merging of projects/armv6, part 4

r232281:
Fix byte order.


233018 15-Mar-2012 nwhitehorn

Make ofw_bus_get_node() consistently return -1 when there is no associated
OF node, instead of a random mixture of 0 and -1. Update all checks for 0
to check for -1 instead.

MFC after: 4 weeks


230631 27-Jan-2012 marius

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


228631 17-Dec-2011 avg

kern cons: introduce infrastructure for console grabbing by kernel

At the moment grab and ungrab methods of all console drivers are no-ops.

Current intended meaning of the calls is that the kernel takes control of
console input. In the future the semantics may be extended to mean that
the calling thread takes full ownership of the console (e.g. console
output from other threads could be suspended).

Inspired by: bde
MFC after: 2 months


228201 02-Dec-2011 jchandra

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


227848 22-Nov-2011 marius

s,KOBJMETHOD_END,DEVMETHOD_END,g in order to fully hide the explicit mention
of kobj(9) from device drivers.


227537 15-Nov-2011 marius

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


226466 17-Oct-2011 jchandra

FDT changes for 64 bit kernel

Use the offset into the device tree from fdtp as the phandle instead
of using pointer into the device tree. This will make sure that the
phandle fits into a uint32_t type, even when compiled for 64bit.

Reviewed by: raj, nathanw, marcel


225214 27-Aug-2011 rwatson

Follow up to r225203 refining break-to-debugger run-time configuration
improvements:

(1) Implement new model in previously missed at91 UART driver
(2) Move BREAK_TO_DEBUGGER and ALT_BREAK_TO_DEBUGGER from opt_comconsole.h
to opt_kdb.h (spotted by np)
(3) Garbage collect now-unused opt_comconsole.h

MFC after: 3 weeks
Approved by: re (bz)


225203 26-Aug-2011 rwatson

Attempt to make break-to-debugger and alternative break-to-debugger more
accessible:

(1) Always compile in support for breaking into the debugger if options
KDB is present in the kernel.

(2) Disable both by default, but allow them to be enabled via tunables
and sysctls debug.kdb.break_to_debugger and
debug.kdb.alt_break_to_debugger.

(3) options BREAK_TO_DEBUGGER and options ALT_BREAK_TO_DEBUGGER continue
to behave as before -- only now instead of compiling in
break-to-debugger support, they change the default values of the
above sysctls to enable those features by default. Current kernel
configurations should, therefore, continue to behave as expected.

(4) Migrate alternative break-to-debugger state machine logic out of
individual device drivers into centralised KDB code. This has a
number of upsides, but also one downside: it's now tricky to release
sio spin locks when entering the debugger, so we don't. However,
similar logic does not exist in other device drivers, including uart.

(5) dcons requires some special handling; unlike other console types, it
allows overriding KDB's own debugger selection, so we need a new
interface to KDB to allow that to work.

GENERIC kernels in -CURRENT will now support break-to-debugger as long as
appropriate boot/run-time options are set, which should improve the
debuggability of BETA kernels significantly.

MFC after: 3 weeks
Reviewed by: kib, nwhitehorn
Approved by: re (bz)


215120 11-Nov-2010 raj

Return IEEE 1275 compliant error codes.

Submitted by: nwhitehorn


215049 09-Nov-2010 nwhitehorn

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.


212477 11-Sep-2010 marius

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

Reviewed by: nwhitehorn


212413 10-Sep-2010 avg

bus_add_child: change type of order parameter to u_int

This reflects actual type used to store and compare child device orders.
Change is mostly done via a Coccinelle (soon to be devel/coccinelle)
semantic patch.
Verified by LINT+modules kernel builds.

Followup to: r212213
MFC after: 10 days


209817 08-Jul-2010 nwhitehorn

Missed a file in r209803: this header contains a definition of
OFW_STD_32BIT.

Pointy hat to: me


209801 08-Jul-2010 nwhitehorn

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.


209298 18-Jun-2010 nwhitehorn

Provide for multiple, cascaded PICs on PowerPC systems, and extend the
OFW interrupt map interface to also return the device's interrupt parent.

MFC after: 8.1-RELEASE


208615 28-May-2010 raj

Initial implementation of the OFW i/f methods for FDT back-end.

Reviewed by: imp
Sponsored by: The FreeBSD Foundation


208614 28-May-2010 raj

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


208172 16-May-2010 nwhitehorn

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


208152 16-May-2010 nwhitehorn

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.


206116 02-Apr-2010 marius

With r205496 in place we should ensure that nargs and nreturns are always
set to sane values as they no longer default to 0, otherwise some OFW
implementation might copy in or out arguments not based on what the actual
function takes but what ever stack garbage nargs and nreturns supply.

Reviewed by: nwhitehorn


205496 23-Mar-2010 nwhitehorn

Do not declare the various OFW command buffers static. It does not
appear to be necessary on either sparc64 or powerpc, and is a
concurrency nightmare.

Reviewed by: marius


204520 01-Mar-2010 joel

The NetBSD Foundation has granted permission to remove clause 3 and 4 from
their software.

Obtained from: NetBSD


194139 14-Jun-2009 marius

Missed style fixes.


194138 14-Jun-2009 marius

Fix style.


194025 11-Jun-2009 avg

strict kobj signatures: some ofw_setprop fixes

propname parameter is const

Reviewed by: imp, current@
Approved by: jhb (mentor)


193018 29-May-2009 ed

Last minute TTY API change: remove mutex argument from tty_alloc().

I don't want people to override the mutex when allocating a TTY. It has
to be there, to keep drivers like syscons happy. So I'm creating a
tty_alloc_mutex() which can be used in those cases. tty_alloc_mutex()
should eventually be removed.

The advantage of this approach, is that we can just remove a function,
without breaking the regular API in the future.


190522 29-Mar-2009 marius

Unbreak OF_interpret() and its standard implementation after r186347.


189280 02-Mar-2009 nwhitehorn

Some Apple I2C buses give the device's I2C address in a property with the
name i2c-address instead of reg. Change the OFW I2C probe to check both
locations for the address.

Submitted by: Marco Trillo
Reported by: Justin Hibbits


187472 20-Jan-2009 nwhitehorn

Set the wrong softc size when defining the ofw_iicbus class. Change it to
the correct value.


187261 15-Jan-2009 nwhitehorn

Import an Open Firmware I2C bus module. This attaches firmware device tree
indicated I2C devices, and provides an ofw_bus interface for driver probing.
This should be MI, but is currently provided only on PowerPC due to lack of
sparc64 hardware with an I2C controller.

Discussed on: freebsd-arch


186728 03-Jan-2009 nwhitehorn

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


186347 20-Dec-2008 nwhitehorn

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


186133 15-Dec-2008 nwhitehorn

Unbreak ofwdump build by moving the pcell_t definition to after the kernel
types headers, and inside the _KERNEL ifdef.

Pointy hat to: me


186128 15-Dec-2008 nwhitehorn

Adapt parts of the sparc64 Open Firmware bus enumeration code (in particular,
the code for parsing interrupt maps) to PowerPC and reflect their new MI
status by moving them to the shared dev/ofw directory.

This commit also modifies the OFW PCI enumeration procedure on PowerPC to
allow the bus to find non-firmware-enumerated devices that Apple likes to add,
and adds some useful Open Firmware properties (compat and name) to the pnpinfo
string of children on OFW SBus, EBus, PCI, and MacIO links. Because of the
change to PCI enumeration on PowerPC, X has started working again on PPC
machines with Grackle hostbridges.

Reviewed by: marius
Obtained from: sparc64


184329 27-Oct-2008 ed

Remove unused consdev structure fields.

The cn_unit and cn_tp fields don't seem to be used anywhere. Some
drivers set them, while others don't. Just remove them, in an attempt to
make our consdev code a little easier to understand.


181905 20-Aug-2008 ed

Integrate the new MPSAFE TTY layer to the FreeBSD operating system.

The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:

- Improved driver model:

The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.

If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.

- Improved hotplugging:

With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).

The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.

- Improved performance:

One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.

Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.

Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan


178766 04-May-2008 peter

Expand kdb_alt_break a little, most commonly used with the option
ALT_BREAK_TO_DEBUGGER. In addition to "Enter ~ ctrl-B" (to enter the
debugger), there is now "Enter ~ ctrl-P" (force panic) and
"Enter ~ ctrl-R" (request clean reboot, ala ctrl-alt-del on syscons).

We've used variations of this at work. The force panic sequence is
best used with KDB_UNATTENDED for when you just want it to dump and
get on with it.

The reboot request is a safer way of getting into single user than
a power cycle. eg: you've hosed the ability to log in (pam, rtld, etc).
It gives init the reboot signal, which causes an orderly reboot.

I've taken my best guess at what the !x86 and non-sio code changes
should be.

This also makes sio release its spinlock before calling KDB/DDB.


177253 16-Mar-2008 rwatson

In keeping with style(9)'s recommendations on macros, use a ';'
after each SYSINIT() macro invocation. This makes a number of
lightweight C parsers much happier with the FreeBSD kernel
source, including cflow's prcc and lxr.

MFC after: 1 month
Discussed with: imp, rink


174898 25-Dec-2007 rwatson

Add a new 'why' argument to kdb_enter(), and a set of constants to use
for that argument. This will allow DDB to detect the broad category of
reason why the debugger has been entered, which it can use for the
purposes of deciding which DDB script to run.

Assign approximate why values to all current consumers of the
kdb_enter() interface.


174802 20-Dec-2007 marius

In openprom_ioctl() ensure appropriate permissions and that data isn't
NULL and doesn't point to a NULL pointer before dereferencing it. This
fixes a panic triggered by Xorg 7.3.

Reported and tested by: Bill Green
MFC after: 3 days


172836 20-Oct-2007 julian

Rename the kthread_xxx (e.g. kthread_create()) calls
to kproc_xxx as they actually make whole processes.
Thos makes way for us to add REAL kthread_create() and friends
that actually make theads. it turns out that most of these
calls actually end up being moved back to the thread version
when it's added. but we need to make this cosmetic change first.

I'd LOVE to do this rename in 7.0 so that we can eventually MFC the
new kthread_xxx() calls.


171265 06-Jul-2007 peter

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)


170842 16-Jun-2007 marius

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

Found with: Coverity Prevent(tm)
CID: 679


170841 16-Jun-2007 marius

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


170838 16-Jun-2007 marius

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


164049 06-Nov-2006 rwatson

Add missing includes of priv.h.


164033 06-Nov-2006 rwatson

Sweep kernel replacing suser(9) calls with priv(9) calls, assigning
specific privilege names to a broad range of privileges. These may
require some future tweaking.

Sponsored by: nCircle Network Security, Inc.
Obtained from: TrustedBSD Project
Discussed on: arch@
Reviewed (at least in part) by: mlaier, jmg, pjd, bde, ceri,
Alex Lyashkov <umka at sevcity dot net>,
Skip Ford <skip dot ford at verizon dot net>,
Antoine Brodin <antoine dot brodin at laposte dot net>


163221 11-Oct-2006 kmacy

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


163146 09-Oct-2006 kmacy

kernel clean up to make the sun4v kernel build

Reviewed by: jmg
Approved by: rwatson (mentor)


161836 01-Sep-2006 marius

Fix spelling and wording in a comment.


159065 30-May-2006 phk

Fix various typos and brainos in last commit.

Submmited by: Andrew Turner <andrew@fubar.geek.nz>


158964 26-May-2006 phk

Update to new console api.


152683 22-Nov-2005 marius

- Add a new method ofw_bus_default_get_devinfo() that allows to retrieve
a newly introduced struct ofw_bus_devinfo which can hold the OFW info
of a device recallable via the ofw_bus KOBJ interface. Introduce a set
of functions ofw_bus_gen_get_*() which use ofw_bus_default_get_devinfo()
to provide generic subroutines for implementing the rest of the ofw_bus
KOBJ interface in a bus driver.
This is inspired by bus_get_resource_list() and bus_generic_rl_*_resource()
and allows to reduce code duplication in bus drivers as they only have
to provide an ofw_bus_default_get_devinfo() implementation in order to
provide the ofw_bus KOBJ interface via ofw_bus_gen_get_*().
- While here add a comment to ofw_bus_if.m describing the intention of
the ofw_bus KOBJ interface.

Reviewed by: marcel


152682 22-Nov-2005 marius

Remove unused function and variables.


151894 31-Oct-2005 grehan

The mediasize shouldn't be multipled by the sector size when it was
in bytes to start off with. This caused the GPT geom sniffer to attempt
a seek just back from the end of the 'disk', which resulted in a > 4G
seek, causing gdb psim to exit since it only supports 32-bit seeks.

The size of the disk should really be specified in the psim device tree,
but for now do the minimal amount of work to get psim to run again.


151388 16-Oct-2005 phk

Make ttyconsolemode() call ttsetwater() so that drivers don't have to.


146401 19-May-2005 marius

Sync with openfirm(4) and check the return value of malloc() although
this isn't exactly necessary with M_WAITOK.


146400 19-May-2005 marius

Update the names of some member variables in comments to refect reality.
Apparently this was forgotten when this code was derived from the BSD
openprom(4).


141752 12-Feb-2005 marius

Merge revision 1.5 from NetBSD: Fix a typo in a comment.
NetBSD rev. 1.4 (addition of the OFW_PCI_PHYS_HI_BUS macro) had already
been merged prior to adding this file to FreeBSD (with the 1.3 tag though).


139749 06-Jan-2005 imp

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


139372 28-Dec-2004 grehan

Don't probe for a disk unless explicitly enabled by a tunable.
This allows boot to proceed on a real system until the issue
of calling back into certain OpenFirmware calls (e.g. finddevice)
in thread context is understood.

(this commit only affects psim users, of which I think I am the
only one...)


139100 21-Dec-2004 grehan

GEOMify the OFW disk driver. Code taken unashamedly from
the preload case in dev/md/md.c.


136680 18-Oct-2004 phk

Add new function ttyinitmode() which sets our systemwide default
modes on a tty structure.

Both the ".init" and the current settings are initialized allowing
the function to be used both at attach and open time.

The function takes an argument to decide if echoing should be enabled.
Echoing should not be enabled for regular physical serial ports
unless they are consoles, in which case they should be configured
by ttyconsolemode() instead.

Use the new function throughout.


136454 12-Oct-2004 phk

Add a couple of XXX comments and fix a couple of fine points.

I have not tried to make this a "canonical tty driver".


133862 16-Aug-2004 marius

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

Ok'ed by: tmm


133589 12-Aug-2004 marius

- Introduce an ofw_bus kobj-interface for retrieving the OFW node and a
subset ("compatible", "device_type", "model" and "name") of the standard
properties in drivers for devices on Open Firmware supported busses. The
standard properties "reg", "interrupts" und "address" are not covered by
this interface because they are only of interest in the respective bridge
code. There's a remaining standard property "status" which is unclear how
to support properly but which also isn't used in FreeBSD at present.
This ofw_bus kobj-interface allows to replace the various (ebus_get_node(),
ofw_pci_get_node(), etc.) and partially inconsistent (central_get_type()
vs. sbus_get_device_type(), etc.) existing IVAR ones with a common one.
This in turn allows to simplify and remove code-duplication in drivers for
devices that can hang off of more than one OFW supported bus.
- Convert the sparc64 Central, EBus, FHC, PCI and SBus bus drivers and the
drivers for their children to use the ofw_bus kobj-interface. The IVAR-
interfaces of the Central, EBus and FHC are entirely replaced by this. The
PCI bus driver used its own kobj-interface and now also uses the ofw_bus
one. The IVARs special to the SBus, e.g. for retrieving the burst size,
remain.
Beware: this causes an ABI-breakage for modules of drivers which used the
IVAR-interfaces, i.e. esp(4), hme(4), isp(4) and uart(4), which need to be
recompiled.
The style-inconsistencies introduced in some of the bus drivers will be
fixed by tmm@ in a generic clean-up of the respective drivers later (he
requested to add the changes in the "new" style).
- Convert the powerpc MacIO bus driver and the drivers for its children to
use the ofw_bus kobj-interface. This invloves removing the IVARs related
to the "reg" property which were unused and a leftover from the NetBSD
origini of the code. There's no ABI-breakage caused by this because none
of these driver are currently built as modules.
There are other powerpc bus drivers which can be converted to the ofw_bus
kobj-interface, e.g. the PCI bus driver, which should be done together
with converting powerpc to use the OFW PCI code from sparc64.
- Make the SBus and FHC front-end of zs(4) and the sparc64 eeprom(4) take
advantage of the ofw_bus kobj-interface and simplify them a bit.

Reviewed by: grehan, tmm
Approved by: re (scottl)
Discussed with: tmm
Tested with: Sun AX1105, AXe, Ultra 2, Ultra 60; PPC cross-build on i386


133096 04-Aug-2004 gad

Fix problems with the OFW console which happen when the system goes
into single-user mode (as seen on sparc64 and PPC). Problems were due
to a minor oversight in the changes committed in revision 1.25.

Submitted by: grehan
Tested by: gad & yongari


132226 15-Jul-2004 phk

Preparation commit for the tty cleanups that will follow in the near
future:

rename ttyopen() -> tty_open() and ttyclose() -> tty_close().

We need the ttyopen() and ttyclose() for the new generic cdevsw
functions for tty devices in order to have consistent naming.


132199 15-Jul-2004 phk

Do a pass over all modules in the kernel and make them return EOPNOTSUPP
for unknown events.

A number of modules return EINVAL in this instance, and I have left
those alone for now and instead taught MOD_QUIESCE to accept this
as "didn't do anything".


131916 10-Jul-2004 marcel

Update for the KDB framework:
o Make debugging code conditional upon KDB instead of DDB.
o Call kdb_alt_break() instead of db_alt_break().
o Call kdb_enter() instead of breakpoint().


131103 25-Jun-2004 grehan

- set resid correctly so that a failed seek (e.g. end of file) returns
correctly
- included required <sys/module.h>


131016 24-Jun-2004 obrien

Better OFW console support on Sun Ultra2 machines.
Ultra2 users may want to set OFWCONS_POLL_HZ to a value of '20'.
I have left default value at '4' as higher values can consume a more
than is acceptable amount of CPU, and we don't have a consensus yet
what is an optimal value.

Submitted by: Pyun YongHyeon <yongari@kt-is.co.kr>


130585 16-Jun-2004 phk

Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.


130323 10-Jun-2004 marius

Remove second <sys/cdefs.h> and __FBSDID.


130077 04-Jun-2004 phk

Machine generated patch which changes linedisc calls from accessing
linesw[] directly to using the ttyld...() functions

The ttyld...() functions ar inline so there is no performance hit.


129944 01-Jun-2004 phk

Gainfully employ the new ttyioctl in the trivial cases.


129588 22-May-2004 marius

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


129587 22-May-2004 marius

- Move OFW_NAME_MAX, used as a limit for OFW property names and device
identifiers, to openfirmio.h as OFIOCMAXNAME, so programs can use it
for buffer sizes etc.
Note: Although this is only a rough upper limit to make the code more
robust and to prevent the allocation of ridiculous amounts of memory,
the current limit of one page (8191 + '\0' in openfirm_getstr()) still
appears a bit high. The maximum length of OFW property names is 31.
I didn't find a maximum length for the device identifiers in the OFW
documentation but it certainly is much smaller than 8191, too.
- Enable the OFIOCSET ioctl, i.e. move it out from under #if 0.
- Don't use openfirm_getstr() for the property value in OFIOCSET, there
are also properties whose values aren't strings and it makes sense to
use a different maximum length for property values than OFW_NAME_MAX/
OFIOCMAXNAME. The maximum accepted property value is defined in
openfirmio.h as OFIOCMAXVALUE (currently the maximum size of the value
of the nvramrc property).
- Make OFIOCSET not return EINVAL when OF_setprop() returns a different
length for the written value than it was told to write, this is normal
for the text string values of the properties in the OFW /options node.
Instead, only return EINVAL if OF_setprop() returned -1 (value could
not be written or property could not be created). Add a comment about
the specialty of the OFW /options node.
- Make OFIOCSET return the length of the written value returned by
OF_setprop(), just like OF_getprop() does. Quite useful, at least for
debugging.

Reviewed by: tmm


128019 07-Apr-2004 imp

Remove advertising clause from University of California Regent's
license, per letter dated July 22, 1999 and email from Peter Wemm,
Alan Cox and Robert Watson.

Approved by: core, peter, alc, rwatson


126080 21-Feb-2004 phk

Device megapatch 4/6:

Introduce d_version field in struct cdevsw, this must always be
initialized to D_VERSION.

Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing
four D_NOGIANT flags and adding 145 D_NEEDGIANT flags.


126078 21-Feb-2004 phk

Device megapatch 3/6:

Add missing D_TTY flags to various drivers.

Complete asserts that dev_t's passed to ttyread(), ttywrite(),
ttypoll() and ttykqwrite() have (d_flags & D_TTY) and a struct tty
pointer.

Make ttyread(), ttywrite(), ttypoll() and ttykqwrite() the default
cdevsw methods for D_TTY drivers and remove the explicit initializations
in various drivers cdevsw structures.


126076 21-Feb-2004 phk

Device megapatch 1/6:

Free approx 86 major numbers with a mostly automatically generated patch.

A number of strategic drivers have been left behind by caution, and a few
because they still (ab)use their major number.


125975 18-Feb-2004 phk

Change the disk(9) API in order to make device removal more robust.

Previously the "struct disk" were owned by the device driver and this
gave us problems when the device disappared and the users of that device
were not immediately disappearing.

Now the struct disk is allocate with a new call, disk_alloc() and owned
by geom_disk and just abandonned by the device driver when disk_create()
is called.

Unfortunately, this results in a ton of "s/\./->/" changes to device
drivers.

Since I'm doing the sweep anyway, a couple of other API improvements
have been carried out at the same time:

The Giant awareness flag has been flipped from DISKFLAG_NOGIANT to
DISKFLAG_NEEDSGIANT

A version number have been added to disk_create() so that we can detect,
report and ignore binary drivers with old ABI in the future.

Manual page update to follow shortly.


125435 04-Feb-2004 grehan

- add an identify method, since the disk device used to be picked
up in the recursive OpenFirmware node walk. Rely on the psim config
file to have a "ofwdisk" device alias
- minor white space nits


123543 15-Dec-2003 grehan

- The last change conflicted with disks on a live system, as opposed to
the psim simulator. Look for the "file" property which only exists
on psim disks, and as a bonus, print the contents of this at boot-time,
which is the host file being used for the disk image.
- remove remaining warnings.


123490 12-Dec-2003 grehan

- accept device_type of "block", which is how psim/gdb6.0 defines
disks. continue to accept "disk" for psim/gdb5.x users.
- remove unneeded ofwd_identify


121209 18-Oct-2003 phk

Use bio_offset instead of bio_blkno


120544 28-Sep-2003 jake

Only create the ofwcons device nodes if it has been initialized, not
just probed.


120542 28-Sep-2003 jake

Make ofw_console a low priority console device, so that uart will be
preferred in all cases, even if the "remote" bit is not set.


120506 27-Sep-2003 phk

The present defaults for the open and close for device drivers which
provide no methods does not make any sense, and is not used by any
driver.

It is a pretty hard to come up with even a theoretical concept of
a device driver which would always fail open and close with ENODEV.

Change the defaults to be nullopen() and nullclose() which simply
does nothing.

Remove explicit initializations to these from the drivers which
already used them.


120491 26-Sep-2003 phk

OK, I messed up /dev/console with what I had hoped would be compat
code. Convert remaining console drivers and hope for the best.


120467 26-Sep-2003 phk

Initialize the cn_name instead of the cn_dev


119418 24-Aug-2003 obrien

Use __FBSDID().
Also some minor style cleanups.


116551 19-Jun-2003 jake

Add a solaris compatible ofw interface for third party software that
expects one to use. Only the functions used by XFree86 are actually
implemented.

Glanced at by: tmm


116210 11-Jun-2003 tmm

- Add an OFIOCGETPROPLEN ioctl() to get the length of a property.
- Do not use a fixed major.
- Minor cleanups.


115973 07-Jun-2003 jake

Implement OF_interpret.

Obtained from: netbsd


113038 03-Apr-2003 obrien

Use __FBSDID rather than rcsid[].


113020 03-Apr-2003 des

<sys/disk.h> -> <geom/geom_disk.h>


111979 08-Mar-2003 phk

Centralize the devstat handling for all GEOM disk device drivers
in geom_disk.c.

As a side effect this makes a lot of #include <sys/devicestat.h>
lines not needed and some biofinish() calls can be reduced to
biodone() again.


111815 03-Mar-2003 phk

Gigacommit to improve device-driver source compatibility between
branches:

Initialize struct cdevsw using C99 sparse initializtion and remove
all initializations to default values.

This patch is automatically generated and has been tested by compiling
LINT with all the fields in struct cdevsw in reverse order on alpha,
sparc64 and i386.

Approved by: re(scottl)


111340 23-Feb-2003 phk

NO_GEOM cleanup:

Move to "struct disk *" centered API.

Fix some minor nits.


111194 20-Feb-2003 phk

Change the console interface to pass a "struct consdev *" instead of a
dev_t to the method functions.

The dev_t can still be found at struct consdev *->cn_dev.

Add a void *cn_arg element to struct consdev which the drivers can use
for retrieving their softc.


111119 19-Feb-2003 imp

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

Approved by: trb


110509 07-Feb-2003 harti

Implement the ALT_BREAK_TO_DEBUGGER option for the ofw console. This is very
handy if the machine is on another floor. A minor issue with this is that
these functions are also used by the debugger, so its possible to break into
the debugger from the debugger.

PR: sparc64/47143
Reviewed by: benno
Approved by: jake (mentor)


109921 27-Jan-2003 jake

Change ofwcons to use the output-device property from the firmware for the
name of the device that it creates. Update /etc/ttys accordingly.

An alias is created for the old name so that old /etc/ttys will continue to
work, but due to aliases being implemented as symlinks in devfs you cannot
login as root when using the alias device.

Discussed with: grehan


109623 21-Jan-2003 alfred

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


107044 18-Nov-2002 jake

Create the ofwcons device at SI_SUB_CONFIGURE instead of SI_SUB_DRIVERS,
after configure() has run. Only create the device if ofwcons is the
highest priority console. Make a dev alias with the same name as the
firmware output-device property.


105398 18-Oct-2002 tmm

Add a pseudo device which allows to access the OpenFirmware device tree
via ioctl()s. This was ported from NetBSD and adapted a bit to better
match our OpenFirmware support code.


105397 18-Oct-2002 tmm

Add an #ifdef _KERNEL to make it possible to include this file from
userland (to get the typedefs).


103723 20-Sep-2002 grehan

Add missing semicolon


103714 20-Sep-2002 phk

(This commit touches about 15 disk device drivers in a very consistent
and predictable way, and I apologize if I have gotten it wrong anywhere,
getting prior review on a patch like this is not feasible, considering
the number of people involved and hardware availability etc.)

If struct disklabel is the messenger: kill the messenger.

Inside struct disk we had a struct disklabel which disk drivers used to
communicate certain metrics to the disklayer above (GEOM or the disk
mini-layer). This commit changes this communication to use four
explicit fields instead.

Amongst the benefits is that the fields do not get overwritten by
wrong or bogus on-disk disklabels.

Once that is clear, <sys/disk.h> which is included in the drivers
no longer need to pull <sys/disklabel.h> and <sys/diskslice.h> in,
the few places that needs them, have gotten explicit #includes for
them.

The disklabel inside struct disk is now only for internal use in
the disk mini-layer, so instead of embedding it, we malloc it as
we need it.

This concludes (modulus any mistakes) the series of disklabel related
commits.

I belive it all amounts to a NOP for all the rest of you :-)

Sponsored by: DARPA & NAI Labs.


94749 15-Apr-2002 benno

Basic OpenFirmware disk driver. It will attach to anything in OpenFirmware
that declares itself to be a disk, which may be the wrong thing to do in
the long term but it works well enough to attach to emulated disks in the
PowerPC simulator in gdb now that they have the proper device_type
property.


93593 01-Apr-2002 jhb

Change the suser() API to take advantage of td_ucred as well as do a
general cleanup of the API. The entire API now consists of two functions
similar to the pre-KSE API. The suser() function takes a thread pointer
as its only argument. The td_ucred member of this thread must be valid
so the only valid thread pointers are curthread and a few kernel threads
such as thread0. The suser_cred() function takes a pointer to a struct
ucred as its first argument and an integer flag as its second argument.
The flag is currently only used for the PRISON_ROOT flag.

Discussed on: smp@


89115 09-Jan-2002 jake

Move the make_dev call from the cn_probe to a sysinit that runs at
SI_SUB_DRIVERS. cnprobe is too early.


88792 01-Jan-2002 jake

1. Lower the poll timeout for the ofw console driver from hz / 50 to hz / 4.
This gives a bit of a sluggish console, but it prevents the console from
getting stuck if we poll too fast, as well as other badness on certain
machines.
2. Fix a test for != 0 that should have been > 0.

Noticed by: Jamey Wood <Jamey.Wood@Sun.COM> and myself
Submitted by: tmm (2)


86557 18-Nov-2001 tmm

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)


83366 12-Sep-2001 julian

KSE Milestone 2
Note ALL MODULES MUST BE RECOMPILED
make the kernel aware that there are smaller units of scheduling than the
process. (but only allow one thread per process at this time).
This is functionally equivalent to teh previousl -current except
that there is a thread associated with each process.

Sorry john! (your next MFC will be a doosie!)

Reviewed by: peter@freebsd.org, dillon@freebsd.org

X-MFC after: ha ha ha ha


80697 31-Jul-2001 jake

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


80696 31-Jul-2001 jake

Quiet uninitialized variable warning (also a bug).


78877 27-Jun-2001 benno

Bracket this file in the usual #ifndef/#define/#endif stuff to prevent
multiple inclusion.


78876 27-Jun-2001 benno

Garbage collect some debug code.


78346 16-Jun-2001 benno

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


68548 10-Nov-2000 benno

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


67204 16-Oct-2000 obrien

"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>