Commit Graph

63 Commits

Author SHA1 Message Date
Pedro F. Giffuni
73a1170a8c sys/dev: use our nitems() macro when it is avaliable through param.h.
No functional change, only trivial cases are done in this sweep,
Drivers that can get further enhancements will be done independently.

Discussed in:	freebsd-current
2016-04-19 23:37:24 +00:00
Ruslan Ermilov
9fddcc6661 Fix our ioctl(2) implementation when the argument is "int". New
ioctls passing integer arguments should use the _IOWINT() macro.
This fixes a lot of ioctl's not working on sparc64, most notable
being keyboard/syscons ioctls.

Full ABI compatibility is provided, with the bonus of fixing the
handling of old ioctls on sparc64.

Reviewed by:	bde (with contributions)
Tested by:	emax, marius
MFC after:	1 week
2006-09-27 19:57:02 +00:00
John Baldwin
aeeb017bd6 - Push Giant down into linker_reference_module().
- Add a new function linker_release_module() as a more intuitive complement
  to linker_reference_module() that wraps linker_file_unload().
  linker_release_module() can either take the module name and version info
  passed to linker_reference_module() or it can accept the linker file
  object returned by linker_reference_module().
2006-06-20 20:54:13 +00:00
John Baldwin
bc5521260c Only reference the firmware module once rather than twice. The extra call
was accidentally added in 1.55 and resulted in an extra reference count
being held on the linker file.

MFC after:	1 week
2006-05-25 22:04:46 +00:00
Poul-Henning Kamp
733634738e Eliminate two unused arguments to ttycreate(). 2005-10-16 20:22:56 +00:00
Andre Oppermann
fb2c9853a7 Increase boot-time DigiBIOS initialization timeout to allow
for a larger number of chained port modules.

PR:		kern/55018
Submitted by:	Cyrill Shevchuk <cyrill at cyrills.net>
2005-09-14 15:18:12 +00:00
Sam Leffler
d40b07dfe4 o avoid potential null ptr deref if symbol lookup fails
o unload module if symbol lookup fails

Noticed by:	Coverity Prevent analysis tool (null ptr deref)
Reviewed by:	bms, imp, dwhite
2005-02-25 20:50:20 +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
3a5f9a2bd2 Use generic tty code instead of local copies. 2004-10-06 20:01:49 +00:00
Poul-Henning Kamp
2abf3a8c5a Remove buggy (root filesystems may not have cdev) and pointless
customization of an error message.
2004-07-28 21:06:13 +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
65a311fcb2 Give kldunload a -f(orce) argument.
Add a MOD_QUIESCE event for modules.  This should return error (EBUSY)
of the module is in use.

MOD_UNLOAD should now only fail if it is impossible (as opposed to
inconvenient) to unload the module.  Valid reasons are memory references
into the module which cannot be tracked down and eliminated.

When kldunloading, we abandon if MOD_UNLOAD fails, and if -force is
not given, MOD_QUIESCE failing will also prevent the unload.

For backwards compatibility, we treat EOPNOTSUPP from MOD_QUIESCE as
success.

Document that modules should return EOPNOTSUPP for unknown events.
2004-07-13 19:36:59 +00:00
Poul-Henning Kamp
911dbd84c7 Introduce ttygone() which indicates that the hardware is detached.
Move dtrwait logic to the generic TTY level.
2004-07-11 15:18:39 +00:00
Poul-Henning Kamp
b4994e318a Define the tty methods as typedefs.
Change the return type for t_break to void.

Add t_ioctl (more about this later).
2004-06-30 21:38:08 +00:00
Poul-Henning Kamp
96df2b0bfb Use generic support for BREAK and modem control ioctls. 2004-06-25 10:54:05 +00:00
Poul-Henning Kamp
ec66f15d14 Put the pre FreeBSD-2.x tty compat code under BURN_BRIDGES. 2004-06-21 22:57:16 +00:00
Poul-Henning Kamp
f3732fd15b Second half of the dev_t cleanup.
The big lines are:
	NODEV -> NULL
	NOUDEV -> NODEV
	udev_t -> dev_t
	udev2dev() -> findcdev()

Various minor adjustments including handling of userland access to kernel
space struct cdev etc.
2004-06-17 17:16:53 +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
Poul-Henning Kamp
1930e303cf Deorbit COMPAT_SUNOS.
We inherited this from the sparc32 port of BSD4.4-Lite1.  We have neither
a sparc32 port nor a SunOS4.x compatibility desire these days.
2004-06-11 11:16:26 +00:00
Poul-Henning Kamp
13e84a71e0 Centralize the line discipline optimization determination in a function
called ttyldoptim().

Use this function from all the relevant drivers.

I belive no drivers finger linesw[] directly anymore, paving the way for
locking and refcounting.
2004-06-04 21:55:55 +00:00
Poul-Henning Kamp
fe3ec6224a Manual edits to change linesw[]-frobbing to ttyld_*() calls. 2004-06-04 20:04:52 +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
e451f9b758 Make the remaining serial drivers call ttyioctl() rather than calling
the linedisc directly.
2004-06-04 08:02:37 +00:00
Poul-Henning Kamp
be9bd88238 There is no need to explicitly call the stop function. In all likelyhood
->l_close() did it and ttyclose certainly will.
2004-06-01 11:57:15 +00:00
Poul-Henning Kamp
fe12f24bb0 Add missing <sys/module.h> includes 2004-05-30 20:08:47 +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
ff2cf8a51d Eliminate bogus use of makedev(): rather than synthesize the dev_t, use
our already cached copy.
2003-09-26 09:05:57 +00:00
John Baldwin
8b149b5131 Consistently use the BSD u_int and u_short instead of the SYSV uint and
ushort.  In most of these files, there was a mixture of both styles and
this change just makes them self-consistent.

Requested by:	bde (kern_ktrace.c)
2003-08-07 15:04:27 +00:00
Poul-Henning Kamp
182a9f7455 Make nokqfilter() return the correct return value.
Ditch the D_KQFILTER flag which was used to prevent calling NULL pointers.
2003-03-03 16:24:47 +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
95e4359c8e Use canonical format for cdevsw initialization. 2003-03-02 18:51:46 +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
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
Poul-Henning Kamp
37c841831f Be consistent about "static" functions: if the function is marked
static in its prototype, mark it static at the definition too.

Inspired by:    FlexeLint warning #512
2002-09-28 17:15:38 +00:00
Brian Somers
b2d8576794 Make delay iteration counts a function of hz as the delay period in each
loop is inversly proportional to hz.

This makes things more sane for configurations with hz > 100.

Submitted by:	Peter Jeremy <peter.jeremy@alcatel.com.au>
2002-04-17 15:13:52 +00:00
Brian Somers
ef94eb4588 Yet another adjustment of digi_delay(). The delay is now consistent
irrespective of whether tsleep() or DELAY() is used.
2002-04-10 14:32:55 +00:00
Brian Somers
6e5b29b08e Change more uses of tsleep() to digi_delay() and make the loop counts more
sane.
2002-04-10 12:03:36 +00:00
Brian Somers
0df8bd54e6 Add a digi_delay() function and use it instead of tsleep() when polling
the card for command completion.

digi_delay() uses either tsleep() or DELAY() depending on the value of
``cold''.

Pointed in the right direction by: jhb
2002-04-10 03:13:28 +00:00
Brian Somers
b50da81d3a Use the PCI port for pci cards, not just for PCIXR cards.
Add the card name to the error message for the first initialisation
failure, giving us more info about what was actually discovered.

This code has been tested by Robert Suetterlin <robert@mpe.mpg.de>
to work on a PCI Xem card.
2002-04-10 01:15:23 +00:00
Brian Somers
96987c74d6 Change linker_reference_module() so that it's passed a struct
mod_depend * (which may be NULL).  The only consumer of this
function at the moment is digi_loadmoduledata(), and that passes
a NULL mod_depend *.

In linker_reference_module(), check to see if we've already got
the required module loaded.  If we have, bump the reference count
and return that, otherwise continue the module search as normal.
2002-04-10 01:13:57 +00:00
Brian Somers
a1b85c51bb Add some missing MODULE_VERSIONs
Without these, the kern_linker interface doesn't record these pseudo-drivers,
making them unavailable via modlist_lookup2*().
2002-04-10 01:12:55 +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
John Baldwin
c145dd8340 Use suser() instead of checking cr_uid against 0 directly. 2002-03-26 18:01:38 +00:00
Peter Wemm
f7afd87572 Fix warnings. The driver would be more useful with a DRIVER_MODULE()
entry so that it actually can do something.
2002-02-27 23:47:45 +00:00
Bruce Evans
89f37afac5 #include "opt_compat.h" so that the support for old ioctls can actually
be compiled.  Old tty ioctls are still used (possibly ifdef'ed) in at
least the following programs in the src tree:
  atc des ee fontedit gdb gdbserver lock ntp perl5 tcsh telnet top vttest

rp.c:
Unremoved used variables so that the support for old ioctls actually
compiles.

Not tested at runtime by:	bde
2002-02-15 08:28:34 +00:00
Mike Smith
172f13eb36 Staticise the con_bios and digi_devclass variables, since they aren't needed
by anything else.
2002-01-08 10:24:34 +00:00
Andrew R. Reiter
1f4bb1673d - Fix a bunch of malloc calls where the M_FLAG is incorrectly used; it
should be M_WAITOK.

Spotted by: des
2001-12-07 17:59:15 +00:00
Poul-Henning Kamp
86af0d1529 devsw_add() and cdevsw_remove() are no longer needed. 2001-11-04 15:52:44 +00:00