Commit Graph

1182 Commits

Author SHA1 Message Date
Mark Peek
5e3939b59b Clock frequencies reported by sysctl should be unsigned values. Discovered
when machdep.tsc_freq returned a negative number on a 2.2GHz Xeon.

Submitted by:	Brian Harrison <bharrison@ironport.com>
Reviewed by:	phk
MFC after:	1 week
2002-06-22 16:30:18 +00:00
Joerg Wunsch
a2642c4d67 After some comments from bde, rewrite the loops to avoid turning the
previously used "micro-optimization" (count-down loop) into a
pessimization.  Now the loops are written in the more natural count-up
form.

Also, while being there, i made the logic in out_fdc() similar to the
logic in in_fdc().  The old implementation was a bit bogus anyway
since it first tested the DIO bit and only afterwards the RQM bit.
However, according to the description of the i82077, the DIO bit is
only guaranteed to be valid once the RQM bit is set.  Thus, the old
implementatoin would have had the chance to misbehave on a controller
that is implemented in accordance with the i82077 description (but is
not bug-for-bug compatible).

MFC after:	3 days
2002-05-14 21:28:45 +00:00
Joerg Wunsch
8a0ba81859 style(9) changes before further editing that region:
. add unnecessary parenthesis around return values
. put body of an "if" statement onto a line of its own
2002-05-13 10:28:20 +00:00
Joerg Wunsch
5613959d84 Hide the fd autoselection messages behind the bootverbose case so they
stop bothering people on their consoles.
2002-05-12 17:17:46 +00:00
Joerg Wunsch
cb38bb6c36 Increase the PIO timeout to approximately the value it used to have
before rev 1.229 (~ 100 ms).  According to bde, some (old) broken
hardware could require it.  In order to make timing more accurate than
what could be achieved with a loop around DELAY(1), increase loop
timing after the initial ~ 1 ms.

Also, move the declaration of FDSTS_TIMEOUT out from fdreg.h into fd.c
where it actually belongs to.

MFC after:	2 days
2002-05-12 15:24:21 +00:00
Joerg Wunsch
d0900d6bc0 Change the PIO loops from a hard counter into a loop that calls DELAY()
in each cycle, with a tunable max cycle count defined in fdreg.h.

This is said to fix the problem on some Compaq hardware (and perhaps
on other machines using the Natsemi PC87317 chip) where the fdc(4)
driver failed to operate at all.

PR:		kern/21397
Submitted by:	Jung-uk Kim <jkim@niksun.com>
MFC after:	3 days
2002-05-10 17:56:39 +00:00
Poul-Henning Kamp
2266fe776e Don't export timecounter structures under debug. with sysctl, they
contain no truly interesting data anymore.
2002-04-30 19:34:31 +00:00
Poul-Henning Kamp
7e2d76ff05 Remove the tc_update() function. Any frequency change to the
timecounter will be used starting at the next second, which is
good enough for sysctl purposes.  If better adjustment is needed
the NTP PLL should be used.
2002-04-26 10:06:26 +00:00
Poul-Henning Kamp
2ce7d7a033 GC various bits and pieces of USERCONFIG from all over the place. 2002-04-09 11:18:46 +00:00
Joerg Wunsch
84954bb898 When reading a UFS-style label from a floppy, don't attempt to use a
"raw partition" of any kind since the floppy driver doesn't support
UFS-style partitions at all.

Reported by:	"Crist J. Clark" <crist.clark@attbi.com>
Reviewed by:	bde
MFC after:	3 days
2002-04-02 18:29:43 +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
Matthew Dillon
d74ac6819b Compromise for critical*()/cpu_critical*() recommit. Cleanup the interrupt
disablement assumptions in kern_fork.c by adding another API call,
cpu_critical_fork_exit().  Cleanup the td_savecrit field by moving it
from MI to MD.  Temporarily move cpu_critical*() from <arch>/include/cpufunc.h
to <arch>/<arch>/critical.c (stage-2 will clean this up).

Implement interrupt deferral for i386 that allows interrupts to remain
enabled inside critical sections.  This also fixes an IPI interlock bug,
and requires uses of icu_lock to be enclosed in a true interrupt disablement.

This is the stage-1 commit.  Stage-2 will occur after stage-1 has stabilized,
and will move cpu_critical*() into its own header file(s) + other things.
This commit may break non-i386 architectures in trivial ways.  This should
be temporary.

Reviewed by:	core
Approved by:	core
2002-03-27 05:39:23 +00:00
Poul-Henning Kamp
d306122d60 Push BIO_FORMAT into a local hack inside the floppy drivers where
it belongs.
2002-03-26 19:16:37 +00:00
Nicolas Souchu
ddd22fb7fb Restore the original copyright 2002-03-23 15:36:13 +00:00
Alfred Perlstein
89c9a48352 Remove __P. 2002-03-20 07:51:46 +00:00
Alfred Perlstein
14e10f9952 Remove __P. 2002-03-20 05:14:42 +00:00
Alfred Perlstein
85f190e4d1 Fixes to make select/poll mpsafe.
Problem:
  selwakeup required calling pfind which would cause lock order
  reversals with the allproc_lock and the per-process filedesc lock.
Solution:
  Instead of recording the pid of the select()'ing process into the
  selinfo structure, actually record a pointer to the thread.  To
  avoid dereferencing a bad address all the selinfo structures that
  are in use by a thread are kept in a list hung off the thread
  (protected by sellock).  When a selwakeup occurs the selinfo is
  removed from that threads list, it is also removed on the way out
  of select or poll where the thread will traverse its list removing
  all the selinfos from its own list.

Problem:
  Previously the PROC_LOCK was used to provide the mutual exclusion
  needed to ensure proper locking, this couldn't work because there
  was a single condvar used for select and poll and condvars can
  only be used with a single mutex.
Solution:
  Introduce a global mutex 'sellock' which is used to provide mutual
  exclusion when recording events to wait on as well as performing
  notification when an event occurs.

Interesting note:
  schedlock is required to manipulate the per-thread TDF_SELECT
  flag, however if given its own field it would not need schedlock,
  also because TDF_SELECT is only manipulated under sellock one
  doesn't actually use schedlock for syncronization, only to protect
  against corruption.

Proc locks are no longer used in select/poll.

Portions contributed by: davidc
2002-03-14 01:32:30 +00:00
Takanori Watanabe
03b8237df8 Add SONY VAIO psm controller ISA-PnP ID. 2002-03-10 12:22:17 +00:00
Matthew Dillon
181df8c9d4 revert last commit temporarily due to whining on the lists. 2002-02-26 20:33:41 +00:00
Matthew Dillon
f96ad4c223 STAGE-1 of 3 commit - allow (but do not require) interrupts to remain
enabled in critical sections and streamline critical_enter() and
critical_exit().

This commit allows an architecture to leave interrupts enabled inside
critical sections if it so wishes.  Architectures that do not wish to do
this are not effected by this change.

This commit implements the feature for the I386 architecture and provides
a sysctl, debug.critical_mode, which defaults to 1 (use the feature).  For
now you can turn the sysctl on and off at any time in order to test the
architectural changes or track down bugs.

This commit is just the first stage.  Some areas of the code, specifically
the MACHINE_CRITICAL_ENTER #ifdef'd code, is strictly temporary and will
be cleaned up in the STAGE-2 commit when the critical_*() functions are
moved entirely into MD files.

The following changes have been made:

	* critical_enter() and critical_exit() for I386 now simply increment
	  and decrement curthread->td_critnest.  They no longer disable
	  hard interrupts.  When critical_exit() decrements the counter to
	  0 it effectively calls a routine to deal with whatever interrupts
	  were deferred during the time the code was operating in a critical
	  section.

	  Other architectures are unaffected.

	* fork_exit() has been conditionalized to remove MD assumptions for
	  the new code.  Old code will still use the old MD assumptions
	  in regards to hard interrupt disablement.  In STAGE-2 this will
	  be turned into a subroutine call into MD code rather then hardcoded
	  in MI code.

	  The new code places the burden of entering the critical section
	  in the trampoline code where it belongs.

	* I386: interrupts are now enabled while we are in a critical section.
	  The interrupt vector code has been adjusted to deal with the fact.
	  If it detects that we are in a critical section it currently defers
	  the interrupt by adding the appropriate bit to an interrupt mask.

	* In order to accomplish the deferral, icu_lock is required.  This
	  is i386-specific.  Thus icu_lock can only be obtained by mainline
	  i386 code while interrupts are hard disabled.  This change has been
	  made.

	* Because interrupts may or may not be hard disabled during a
	  context switch, cpu_switch() can no longer simply assume that
	  PSL_I will be in a consistent state.  Therefore, it now saves and
	  restores eflags.

	* FAST INTERRUPT PROVISION.  Fast interrupts are currently deferred.
	  The intention is to eventually allow them to operate either while
	  we are in a critical section or, if we are able to restrict the
	  use of sched_lock, while we are not holding the sched_lock.

	* ICU and APIC vector assembly for I386 cleaned up.  The ICU code
	  has been cleaned up to match the APIC code in regards to format
	  and macro availability.  Additionally, the code has been adjusted
	  to deal with deferred interrupts.

	* Deferred interrupts use a per-cpu boolean int_pending, and
	  masks ipending, spending, and fpending.  Being per-cpu variables
	  it is not currently necessary to lock; bus cycles modifying them.

	  Note that the same mechanism will enable preemption to be
	  incorporated as a true software interrupt without having to
	  further hack up the critical nesting code.

	* Note: the old critical_enter() code in kern/kern_switch.c is
	  currently #ifdef to be compatible with both the old and new
	  methodology.  In STAGE-2 it will be moved entirely to MD code.

Performance issues:

	One of the purposes of this commit is to enhance critical section
	performance, specifically to greatly reduce bus overhead to allow
	the critical section code to be used to protect per-cpu caches.
	These caches, such as Jeff's slab allocator work, can potentially
	operate very quickly making the effective savings of the new
	critical section code's performance very significant.

	The second purpose of this commit is to allow architectures to
	enable certain interrupts while in a critical section.  Specifically,
	the intention is to eventually allow certain FAST interrupts to
	operate rather then defer.

	The third purpose of this commit is to begin to clean up the
	critical_enter()/critical_exit()/cpu_critical_enter()/
	cpu_critical_exit() API which currently has serious cross pollution
	in MI code (in fork_exit() and ast() for example).

	The fourth purpose of this commit is to provide a framework that
	allows kernel-preempting software interrupts to be implemented
	cleanly.  This is currently used for two forward interrupts in I386.
	Other architectures will have the choice of using this infrastructure
	or building the functionality directly into critical_enter()/
	critical_exit().

	Finally, this commit is designed to greatly improve the flexibility
	of various architectures to manage critical section handling,
	software interrupts, preemption, and other highly integrated
	architecture-specific details.
2002-02-26 17:06:21 +00:00
Alfred Perlstein
0077e8223b Fix style bugs:
Missing `const' qualifier.
Initialization in declaration.

Submitted by: mike
2002-02-24 23:24:01 +00:00
Alfred Perlstein
b2e4739f7e Give a little more information as to why pnp configuration of a device
may have failed.

Submitted by: Terry Lambert <tlambert2@mindspring.com>
2002-02-24 22:27:54 +00:00
Poul-Henning Kamp
817988be19 Disksort will not "munge" requests, BIO_ORDERED or not, so remove
use of BIO_ORDERED.
2002-02-22 09:14:06 +00:00
Seigo Tanimura
38b968c3a5 - Do not hang if the resource allocation fails.
- Add another quirk entry of SB AWE64.

PR:		kern/32530
Submitted by:	Magnus Backstrom <b@etek.chalmers.se>
2002-02-05 06:52:56 +00:00
Bruce Evans
586079cc26 Don't include <isa/isavar.h> or compile code depending on it when isa
is not configured.  Including <isa/isavar.h> when it is not used is
harmful as well as bogus, since it includes "isa_if.h" which is not
generated when isa is not configured.

This was fixed in 1999 but was broken by unconditionalizing PNPBIOS.
2002-01-30 12:41:12 +00:00
Thomas Moestl
01f1aed259 Use the new resource_list_print_type() function.
Pass the bus device to isa_init() (this is needed for the sparc64
version).
2001-12-21 21:54:56 +00:00
John Baldwin
98f9879242 Introduce a standard name for the lock protecting an interrupt controller
and it's associated state variables: icu_lock with the name "icu".  This
renames the imen_mtx for x86 SMP, but also uses the lock to protect
access to the 8259 PIC on x86 UP.  This also adds an appropriate lock to
the various Alpha chipsets which fixes problems with Alpha SMP machines
dropping interrupts with an SMP kernel.
2001-12-20 23:48:31 +00:00
Sheldon Hearn
604fb1c032 Add another PS2 PNP id.
PR:		32973
Submitted by:	KT Sin <ktsin@acm.org>
2001-12-19 13:32:21 +00:00
Joerg Wunsch
038d1bbd1a Change the test for _MACHINE_ARCH == i386 into #ifdef __i386__ since it
otherwise breaks on the Alpha arch.  I think this is wrong since i'd
actually like to probe for a PC architecture, not for a particular CPU
type.  Anyway, now it's again the way it used to be.
2001-12-18 22:16:33 +00:00
Yoshihiro Takahashi
5229d0a11d Remove PC98 code. This file is not used by PC98. 2001-12-16 05:37:22 +00:00
Joerg Wunsch
1a6bed6863 Long promised major enhancement set for the floppy disk driver:
. The main device node now supports automatic density selection for
  commonly used media densities.  So you can stuff your 1.44 MB and
  720 KB media into your drive and just access /dev/fd0, no questions
  asked.  It's all that easy, isn't it? :)

. Device density handling has been completely overhauled.  The old way
  of hardwired kernel density knowledge is no longer there.  Instead,
  the kernel now implements 16 subdevices per drive.  The first
  subdevice uses automatic density selection, while the remaining 15
  devices are freely programmable.  They can be assigned an arbitrary
  name of the form /dev/fd[:digit]+.[:digit:]{1,4}, where the second
  number is meant to either implement device names that are mnemonic
  for their raw capacity (as it used to be), or they can alternatively
  be created as "anonymous" devices like fd0.1 through fd0.15,
  depending on the taste of the administrator.  After creating a
  subdevice, it is initialized to the maximal native density of the
  respective drive type, so it needs to be customized for other
  densities by using fdcontrol(8).  Pseudo-partition devices (fd0a
  through fd0h) are still supported as symlinks.

. The old hack to use flags 0x1 to always assume drive 0 were there is
  no longer supported; this is now supposed to be done by wiring the
  devices down from the loader via device flags.  On IA32
  architectures, the first two drives are looked up in the CMOS
  configuration records though.  On PCMCIA (i. e., the Y-E Data
  controller of the Toshiba Libretto), a single drive is always
  assumed.

. Other specialities like disabling the FIFO and not probing the drive
  at boot-time are selected by per-controller or per-drive flags, too.

. Unit attentions (media has been changed) are supposed to be detected
  now; density autoselection only occurs after a unit attention.  (Can
  be turned off by a per-drive flag, this will cause each Fdopen() to
  perform the autoselection.)

. FM floppies can be handled now (on controllers that actually support
  it -- not all do these days).

. Fdopen() can be told to avoid density selection by setting
  O_NONBLOCK; this leaves the descriptor in a half-opened state where
  only a few ioctls are accepted.  This is necessary to run fdformat
  on a device that uses automatic density selection (since you cannot
  autoselect on an unformatted medium, obviously).

. Just differentiate between a plain old NE765 and the enhanced chips,
  but don't try more; the existing code was wrong and only misdetected
  the chips anyway.

BUGS and TODOs:

. All documentation update still needs to be done.

. Formatting not-so-standard format yields unpredictable results; i
  have yet to figure out why this happens.  "Standard" formats like
  720 and 1440 KB do work, however.

. rc scripts are needed to setup device nodes with nonstandard
  densities (like the old /dev/fdN.MMM we used to have).

. Obtaining device flags from the kernel environment doesn't work yet,
  thus currently only drives that are present in (IA32) CMOS are
  really detected.  Someone who knows the odds and ends about device
  flags is needed here, i can't figure out what i'm doing wrong.

. 2.88 MB still needs to be done.
2001-12-15 19:09:04 +00:00
David E. O'Brien
6e551fb628 Update to C99, s/__FUNCTION__/__func__/,
also don't use ANSI string concatenation.
2001-12-10 08:09:49 +00:00
Warner Losh
c74f37cea7 Moved to dev/joy 2001-12-05 09:10:47 +00:00
Mitsuru IWASAKI
f9390180fe Some fix for the recent apm module changes.
- Now that apm loadable module can inform its existence to other kernel
   components  (e.g. i386/isa/clock.c:startrtclock()'s TCS hack).
 - Exchange priority of SI_SUB_CPU and SI_SUB_KLD for above purpose.
 - Add simple arbitration mechanism for APM vs. ACPI.  This prevents
   the kernel enables both of them.
 - Remove obsolete `#ifdef DEV_APM' related code.
 - Add abstracted interface for Powermanagement operations.  Public apm(4)
   functions, such as apm_suspend(), should be replaced new interfaces.
   Currently only power_pm_suspend (successor of apm_suspend) is implemented.

Reviewed by:	peter, arch@ and audit@
2001-11-01 16:34:07 +00:00
Warner Losh
2ce87d3448 Break out the bus front ends into their own files. Rewrite
sio_pccard_detach to use new siodetach.  Add an extra arg to sioprobe
to tell driver to probe/not probe the device for IRQs.

This incorporates most of Bruce's review material.  I'm at a good
checkpoint, but there will be more to come based on bde's further
reviews.

Reviewed by: bde
2001-10-23 15:17:33 +00:00
Warner Losh
d75c1b4a90 First commit after a repo copy of isa/sio* -> dev/sio:
Move sio from isa/sio.c to dev/sio/sio.c.  The next step is to break
out the front end attachments, improve support for these parts on
different busses, and maybe, if we're lucky, merging in pc98 support.
It will also be MI and live in conf/files rather than files.*.

Approved by: bde
Tested with: i386, pc98
2001-10-22 02:48:38 +00:00
John Baldwin
76e296aa31 - Make the sio_inited handling more properly MP safe.
- If we are booting with a serial console, then pass the MTX_QUIET flag to
  mtx_init of the sio lock as otherwise KTR_VERBOSE simply doesn't work.
2001-10-20 03:32:33 +00:00
Kazutaka YOKOTA
8166ba27bd Hack for the "out-of-sync" error.
- Count the number of this error.
- When the error is detected for the first time, the psm driver will
  throw few data bytes (up to entire packet size) and see if it can
  get back to sync.
- If the error still persists, the psm driver disable/enable the mouse
  and see if it works.
- If the error still persists and the count goes up to 20,
  the psm driver reset and reinitialize the mouse. The counter
  is reset to zero.
- It also discards an incomplete data packet when the interval
  between two consequtive bytes are longer than pre-defined timeout
  (2 seconds).  The last byte which arrived late will be regarded as
  the first byte of a new packet.  This is louie's idea.

You may see the following error logs during the above operations:

  "psmintr: delay too long; resetting byte count"
  "psmintr: out of sync (%04x != %04x)"
  "psmintr: discard a byte (%d)"
  "psmintr: re-enable the mouse"
  "psmintr: reset the mouse"

MFC after:	1 month
2001-10-13 10:28:02 +00:00
Robert Drehmel
1e8ff53804 Remove an unneeded variable declaration and statement.
Approved by:	jake
2001-10-09 16:06:28 +00:00
Takanori Watanabe
c84f2b288e Add PnP ID 'IBM3781' for TP240 mouse. 2001-10-03 07:26:28 +00:00
Jonathan Lemon
750c427849 Add support for 28800 baud to sio.
PR: 30906
Submitted by: "Daniel O'Connor" <darius@chowder.dons.net.au>
2001-09-29 04:49:11 +00:00
Jonathan Lemon
3a163803b7 Gate low level console output on mtx_lock_spin(&sio_lock), if the
sio_lock has been initialized.  This prevents the low level console
output (kernel printf) from clobbering the sio settings if the system
happens to be in the middle of comstart().
2001-09-27 17:00:25 +00:00
Kazutaka YOKOTA
d4b248f23e Yet another turn of workaround for psm/ACPI/PnP BIOS
problems currently experienced in -CURRENT.

This should fix the problem that the PS/2 mouse is detected
twice if the acpi module is not loaded on some systems.
2001-09-25 16:59:28 +00:00
Kazutaka YOKOTA
275658afcc Reinitialize the keyboard after the ACPI resume event.
I am not sure if this is absolutely necessary on all systems.  Yet,
there certainly are motherboards and notebook systems which require
this, although there are other systems which just don't.  I hope we
shall know when to do this on which systems, as the development of our
ACPI subsystem progresses...  (I know we didn't need this for the APM
resume.)
2001-09-23 08:42:06 +00:00
Doug Rabson
8beffae7be Tweak so I can use a serial console on ia64. 2001-09-22 19:44:37 +00:00
Murray Stokely
0aef0b4d6b Recognize two cheap PCI 16550 devices :
CyberSerial (1-port) 16550
  Oxford Semiconductor Dual Port 16550

Sort the list of PCI devices while I'm here.
2001-09-16 11:14:56 +00:00
Kazutaka YOKOTA
d117cb4e19 Handle "identifier strings" right. Each ISA PnP card must have a
mandatory "card" identifier string.  A logical devices on the ISA PnP
card may optionally have a "device" identifier string. Do not confuse
them.

The "card" identifier string is assigned to a logical device as the
default description string when the device is found. (If the "card"
identifier string has not been found, use the EISA PnP ID string.
Strictly speaking, this is an error.)  We will override it when a
"device" identifier string is found later.
2001-09-15 10:18:56 +00:00
Kazutaka YOKOTA
cd6cd68d18 Refine ACPI/PnP BIOS probe/attach routines a bit.
- Add workaround for the problematic PnP BIOS which does not assign
  irq resource for the PS/2 mouse device node; if there is no irq
  assigned for the PS/2 mouse node, refer to device.hints for an
  irq number. If we still don't find an irq number in the hints
  database, use a hard-coded value.
- Delete unused ivars.
- Bit of clean up in probe/attach.
- Add PnP ID for the PS/2 mouse port on some IBM ThinkPad models.
2001-09-15 04:38:20 +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
Dima Dorfman
610dcffd26 Add a missing newline to an error message.
PR:		30436
Submitted by:	Joerg Lehners <Lehners@Informatik.Uni-Oldenburg.DE>
2001-09-09 14:48:52 +00:00