Commit Graph

125 Commits

Author SHA1 Message Date
Marius Strobl
e70415b38e Fix spelling and wording in a comment. 2006-09-01 20:12:12 +00:00
Poul-Henning Kamp
77dfeead45 Fix various typos and brainos in last commit.
Submmited by:	Andrew Turner <andrew@fubar.geek.nz>
2006-05-30 07:56:57 +00:00
Poul-Henning Kamp
05c3592e13 Update to new console api. 2006-05-26 18:25:34 +00:00
Marius Strobl
bba6f0a901 - 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
2005-11-22 16:37:45 +00:00
Marius Strobl
933b731c67 Remove unused function and variables. 2005-11-22 14:21:03 +00:00
Peter Grehan
a3624af7d8 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.
2005-10-31 03:09:38 +00:00
Poul-Henning Kamp
7423b2b40c Make ttyconsolemode() call ttsetwater() so that drivers don't have to. 2005-10-16 20:58:22 +00:00
Marius Strobl
99998ae585 Sync with openfirm(4) and check the return value of malloc() although
this isn't exactly necessary with M_WAITOK.
2005-05-19 15:23:17 +00:00
Marius Strobl
2ad154205f 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).
2005-05-19 15:22:16 +00:00
Marius Strobl
61e2f26526 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).
2005-02-12 19:12:17 +00:00
Warner Losh
098ca2bda9 Start each of the license/copyright comments with /*-, minor shuffle of lines 2005-01-06 01:43:34 +00:00
Peter Grehan
b8e106eadd 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...)
2004-12-28 05:07:49 +00:00
Peter Grehan
d626a8a238 GEOMify the OFW disk driver. Code taken unashamedly from
the preload case in dev/md/md.c.
2004-12-21 02:23:35 +00:00
Poul-Henning Kamp
95bc568977 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.
2004-10-18 21:51:27 +00:00
Poul-Henning Kamp
c5c5a2ad8a Add a couple of XXX comments and fix a couple of fine points.
I have not tried to make this a "canonical tty driver".
2004-10-12 21:23:33 +00:00
Marius Strobl
39513fa664 Instead of "OpenFirmware", "openfirmware", etc. use the official spelling
"Open Firmware" from IEEE 1275 and OpenFirmware.org (no pun intended).

Ok'ed by:	tmm
2004-08-16 15:45:27 +00:00
Marius Strobl
26280d88d7 - 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
2004-08-12 17:41:33 +00:00
Garance A Drosehn
b11ef345eb 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
2004-08-04 00:21:19 +00:00
Poul-Henning Kamp
672c05d49c 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.
2004-07-15 20:47:41 +00:00
Poul-Henning Kamp
3e019deaed 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".
2004-07-15 08:26:07 +00:00
Marcel Moolenaar
8cabb94fde 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().
2004-07-10 21:07:44 +00:00
Peter Grehan
aa77148daf - set resid correctly so that a failed seek (e.g. end of file) returns
correctly
- included required <sys/module.h>
2004-06-25 13:43:56 +00:00
David E. O'Brien
a82b25f9b2 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>
2004-06-24 02:57:11 +00:00
Poul-Henning Kamp
89c9c53da0 Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.
2004-06-16 09:47:26 +00:00
Marius Strobl
543912b386 Remove second <sys/cdefs.h> and __FBSDID. 2004-06-10 22:15:51 +00:00
Poul-Henning Kamp
2140d01b27 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.
2004-06-04 16:02:56 +00:00
Poul-Henning Kamp
138fbf675a Gainfully employ the new ttyioctl in the trivial cases. 2004-06-01 13:49:28 +00:00
Marius Strobl
a32a374caf - Rearrange a comment to fit in 80 chars per line, like the rest of this
file.
- Remove a superfluous ';'.
2004-05-22 16:45:19 +00:00
Marius Strobl
073e8552f8 - 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
2004-05-22 16:43:42 +00:00
Warner Losh
f36cfd49ad 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
2004-04-07 20:46:16 +00:00
Poul-Henning Kamp
dc08ffec87 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.
2004-02-21 21:10:55 +00:00
Poul-Henning Kamp
8e1f1df080 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.
2004-02-21 20:41:11 +00:00
Poul-Henning Kamp
c9c7976f7f 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.
2004-02-21 19:42:58 +00:00
Poul-Henning Kamp
0b7ed341e1 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.
2004-02-18 21:36:53 +00:00
Peter Grehan
1ac37de6b3 - 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
2004-02-04 12:52:57 +00:00
Peter Grehan
ad1c13f493 - 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.
2003-12-15 09:53:53 +00:00
Peter Grehan
2abd35bc59 - 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
2003-12-12 09:54:39 +00:00
Poul-Henning Kamp
24730dd78a Use bio_offset instead of bio_blkno 2003-10-18 17:26:13 +00:00
Jake Burkholder
278667afab Only create the ofwcons device nodes if it has been initialized, not
just probed.
2003-09-28 06:51:47 +00:00
Jake Burkholder
5dbb062210 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.
2003-09-28 05:38:37 +00:00
Poul-Henning Kamp
70cd771337 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.
2003-09-27 12:01:01 +00:00
Poul-Henning Kamp
3f99f14bf1 OK, I messed up /dev/console with what I had hoped would be compat
code.  Convert remaining console drivers and hope for the best.
2003-09-26 19:35:50 +00:00
Poul-Henning Kamp
2f06c3e7f2 Initialize the cn_name instead of the cn_dev 2003-09-26 10:55:07 +00:00
David E. O'Brien
aad970f1fe Use __FBSDID().
Also some minor style cleanups.
2003-08-24 17:55:58 +00:00
Jake Burkholder
1de46e12a3 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
2003-06-19 01:40:11 +00:00
Thomas Moestl
933c9a14ed - Add an OFIOCGETPROPLEN ioctl() to get the length of a property.
- Do not use a fixed major.
- Minor cleanups.
2003-06-11 18:33:03 +00:00
Jake Burkholder
2c7df6a555 Implement OF_interpret.
Obtained from:	netbsd
2003-06-07 18:34:04 +00:00
David E. O'Brien
8368cf8f75 Use __FBSDID rather than rcsid[]. 2003-04-03 21:36:33 +00:00
Dag-Erling Smørgrav
91b928c950 <sys/disk.h> -> <geom/geom_disk.h> 2003-04-03 16:28:57 +00:00
Poul-Henning Kamp
60794e0478 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.
2003-03-08 08:01:31 +00:00
Poul-Henning Kamp
7ac40f5f59 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)
2003-03-03 12:15:54 +00:00
Poul-Henning Kamp
e165e4d26a NO_GEOM cleanup:
Move to "struct disk *" centered API.

Fix some minor nits.
2003-02-23 19:15:34 +00:00
Poul-Henning Kamp
263444cfbf 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.
2003-02-20 20:54:45 +00:00
Warner Losh
a163d034fa Back out M_* changes, per decision of the TRB.
Approved by: trb
2003-02-19 05:47:46 +00:00
Hartmut Brandt
761f89f9d8 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)
2003-02-07 16:20:09 +00:00
Jake Burkholder
984e265523 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
2003-01-27 04:42:17 +00:00
Alfred Perlstein
44956c9863 Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
2003-01-21 08:56:16 +00:00
Jake Burkholder
a121cb6a7f 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.
2002-11-18 06:19:12 +00:00
Thomas Moestl
de540622df 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.
2002-10-18 15:23:43 +00:00
Thomas Moestl
89492ca471 Add an #ifdef _KERNEL to make it possible to include this file from
userland (to get the typedefs).
2002-10-18 15:21:09 +00:00
Peter Grehan
601385b7ca Add missing semicolon 2002-09-20 23:26:07 +00:00
Poul-Henning Kamp
7812d86f03 (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.
2002-09-20 19:36:05 +00:00
Benno Rice
d96118005f 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.
2002-04-15 10:54:22 +00:00
John Baldwin
44731cab3b 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@
2002-04-01 21:31:13 +00:00
Jake Burkholder
47a1c91514 Move the make_dev call from the cn_probe to a sysinit that runs at
SI_SUB_DRIVERS.  cnprobe is too early.
2002-01-09 04:03:55 +00:00
Jake Burkholder
cbecdd5743 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)
2002-01-01 21:45:30 +00:00
Thomas Moestl
398e05ab1c 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)
2001-11-18 20:38:44 +00:00
Julian Elischer
b40ce4165d 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
2001-09-12 08:38:13 +00:00
Jake Burkholder
8aa920fd1d 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
2001-07-31 03:36:26 +00:00
Jake Burkholder
c22c65b1d4 Quiet uninitialized variable warning (also a bug). 2001-07-31 03:32:24 +00:00
Benno Rice
62626b2c33 Bracket this file in the usual #ifndef/#define/#endif stuff to prevent
multiple inclusion.
2001-06-27 12:15:58 +00:00
Benno Rice
97d9f676e5 Garbage collect some debug code. 2001-06-27 12:15:12 +00:00
Benno Rice
707fed2004 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
2001-06-16 07:17:56 +00:00
Benno Rice
4cc1860f9b 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
2000-11-10 06:39:58 +00:00
David E. O'Brien
146a7d5318 "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>
2000-10-16 10:46:22 +00:00