deischen [Wed, 24 Jan 2001 13:03:38 +0000 (13:03 +0000)]
Add weak definitions for wrapped system calls. In general:
_foo - wrapped system call
foo - weak definition to _foo
and for cancellation points:
_foo - wrapped system call
__foo - enter cancellation point, call _foo(), leave
cancellation point
foo - weak definition to __foo
Change use of global _thread_run to call a function to get the
currently running thread.
Make all pthread_foo functions weak definitions to _pthread_foo,
where _pthread_foo is the implementation. This allows an application
to provide its own pthread functions.
Provide slightly different versions of pthread_mutex_lock and
pthread_mutex_init so that we can tell the difference between
a libc mutex and an application mutex. Threads holding mutexes
internal to libc should never be allowed to exit, call signal
handlers, or cancel.
deischen [Wed, 24 Jan 2001 13:01:12 +0000 (13:01 +0000)]
Remove _THREAD_SAFE and make libc thread-safe by default by
adding (weak definitions to) stubs for some of the pthread
functions. If the threads library is linked in, the real
pthread functions will pulled in.
Use the following convention for system calls wrapped by the
threads library:
__sys_foo - actual system call
_foo - weak definition to __sys_foo
foo - weak definition to __sys_foo
Change all libc uses of system calls wrapped by the threads
library from foo to _foo. In order to define the prototypes
for _foo(), we introduce namespace.h and un-namespace.h
(suggested by bde). All files that need to reference these
system calls, should include namespace.h before any standard
includes, then include un-namespace.h after the standard
includes and before any local includes. <db.h> is an exception
and shouldn't be included in between namespace.h and
un-namespace.h namespace.h will define foo to _foo, and
un-namespace.h will undefine foo.
Try to eliminate some of the recursive calls to MT-safe
functions in libc/stdio in preparation for adding a mutex
to FILE. We have recursive mutexes, but would like to avoid
using them if possible.
Remove uneeded includes of <errno.h> from a few files.
Add $FreeBSD$ to a few files in order to pass commitprep.
jhb [Wed, 24 Jan 2001 12:23:17 +0000 (12:23 +0000)]
Argh, I didn't get this test right when I converted it. Break this up
into two separate if's instead of nested if's. Also, reorder things
slightly to avoid unnecessary mutex operations.
jhb [Wed, 24 Jan 2001 11:25:56 +0000 (11:25 +0000)]
- Catch up to proc flag changes.
- Proc locking in a few places.
- faultin() now must be called with the proc lock held.
- Split up swappable() into a couple of tests so that it can be locke in
swapout_procs().
- Use queue macros.
jhb [Wed, 24 Jan 2001 11:15:24 +0000 (11:15 +0000)]
- Catch up to proc flag changes.
- Update stopevent() to assert that the proc lock is held when it is
held and is not recursed. Note that the STOPEVENT() macro obtains
the proc lock when calling this function.
jhb [Wed, 24 Jan 2001 11:10:55 +0000 (11:10 +0000)]
- Catch up to proc flag changes.
- Add in some locking ops that might fix SIGXCPU, but don't enable them
yet.
- Assert that sched_lock is not recursed when mi_switch() is called.
jhb [Wed, 24 Jan 2001 10:57:01 +0000 (10:57 +0000)]
- Don't use a union and fun tricks to shave one extra pointer off of struct
mtx right now as it makes debugging harder. When we are in optimizing
mode, we can revisit this.
- Fix the KTR trace messages to use %p rather than 0x%p to avoid duplicate
0x's in KTR output.
- During witness_fixup, release Giant so that witness doesn't get confused.
Also, grab all_mtx while walking the list of mutexes.
- Remove w_sleep and w_recurse. Instead, perform checks on mutexes using
the mutex's mtx_flags field.
- Allow debug.witness_ddb and debug.witness_skipspin to be set from the
loader.
- Add Giant to the front of existing order_list entries to help ensure
Giant is always first.
- Add an order entry for the various proc locks. Note that this only
helps keep proc in order mostly as the allproc and proctree mutexes are
only obtained during a lockmgr operation on the specified mutex.
jhb [Wed, 24 Jan 2001 10:40:56 +0000 (10:40 +0000)]
- Catch up to p_sflag changes.
- The MD code now initializes proc0.p_heldmtx, proc0.p_contested, and
curproc.
- The MD code calls here with Giant already held.
- Proc locking.
jhb [Wed, 24 Jan 2001 10:23:21 +0000 (10:23 +0000)]
- Change userret() to take a struct trapframe * as its second argument and
to extract the PC from that to send to addupc_task() so that it can be
called from MI code.
- Remove all traces of have_giant with extreme prejudice and use
mtx_owned(&Giant) instead where appropriate.
- Proc locking.
- P_FOO -> PS_FOO.
- Don't grab Giant just to look in curproc's p_addr during a trap since we
may choose to immediately exit. Instead, delay grabbing Giant a bit
until we actually need it.
- Don't reset 'p' to 'curproc' in syscall() to handle the case of a child
returning from fork1() since children don't return via syscall().
- Remove an XXX comment in ast() that questions the correctness of the
userland check. The code is correct.
jhb [Wed, 24 Jan 2001 10:16:01 +0000 (10:16 +0000)]
- Proc locking.
- Don't send IPIs for pmap_invalidate_page() or pmap_invalidate_all()
in the UP case.
- Catch up to cpuno -> cpuid.
- Convert some sanity checks that were #ifdef DIAGNOSTIC to KASSERT()'s.
jhb [Wed, 24 Jan 2001 10:13:13 +0000 (10:13 +0000)]
- Adjust some whitespace to reduce diffs with the i386 version.
- Rename the per-CPU variable 'cpuno' to 'cpuid'. This was done so that
there is one consistent name across all architectures for a logical
CPU id.
- Remove all traces of IRQ forwarding.
- Add globaldata_register() hook called by globaldata_init() to register
globaldata structures in the cpuid_to_globaldata array.
- Catch up to P_FOO -> PS_FOO.
- Bring across some fixes for forwarded_statclock() from the i386 version
to handle ithreads and idleproc properly.
- Rename addugd_intr_forwarded() to addupc_intr_forwarded() so that it is
the same name on all architectures.
- Set flags in p_sflag instead of calling psignal() from
forward_hardclock().
- Proc locking.
- When we handle an IPI, turn off its bit in the mask of IPI's we are
currently handling so that an IPI doesn't send a CPU into an infinite
loop.
jhb [Wed, 24 Jan 2001 10:07:42 +0000 (10:07 +0000)]
- Initialize curproc, proc0.p_heldmtx, and proc0.p_contested earlier so
that mutex operations work.
- Enter Giant earlier so we hold it during boot.
- Proc locking.
- Move globaldata_init() into here from mp_machdep.c so that UP kernels
don't depend on mp_machdep.c. Use a callout in the SMP case to register
the boot processor's globaldata in the cpuid_to_globaldata array.
jhb [Wed, 24 Jan 2001 09:53:49 +0000 (09:53 +0000)]
- Kill the have_giant parameter to userret() along with all instances of
that name as a variable. Use mtx_owned(&Giant) where appropriate
instead.
- Proc locking.
- P_FOO -> PS_FOO.
- Update comments about enable interrupts during trap and why this may be
bad if we trap while holding a spin mutex.
- Don't bother resetting p to curproc in syscall() in case we are the child
returning from fork. The child hasn't returned from fork through syscall
in a while.
- Remove fork_return() as it has been superseded by the MI version.
jhb [Wed, 24 Jan 2001 09:48:52 +0000 (09:48 +0000)]
- Relocate portions of this file to get it into an order closer to that of
the alpha mp_machdep.c.
- Proc locking.
- Catch up to the P_FOO -> PS_FOO proc flags changes.
- Stick ap_init()'s prototype with the other prototypes.
- Remove the Xforwardirq IPI.
- Remove unused simplelocks.
- Don't try to psignal() from forward_statclock(), but set the appropriate
signal pending flag in p_sflag instead.
- Add in KTR_SMP tracepoints for various SMP functions. (Brought over
from the alpha port)
jhb [Wed, 24 Jan 2001 09:45:20 +0000 (09:45 +0000)]
- Proc locking.
- Setup proc0.p_heldmtx, proc0.contested, and curproc earlier so that we
can use mutexes.
- Initialize sched_lock and Giant earlier and enter Giant during init386.
- Use suser(9) instead of checking cr_uid directly.
jhb [Wed, 24 Jan 2001 09:41:03 +0000 (09:41 +0000)]
- Split p_flag up into two fields. p_flag keeps most of the previous flags
and is protected by the proc lock. p_sflag is protected by sched_lock
and holds the following flags: PS_INMEM, PS_OWEUPC, PS_PROFIL, PS_SINTR,
PS_TIMEOUT, PS_ALRMPEND, PS_PROFPEND, PS_CVWAITQ, PS_SWAPINREQ, and
PS_SWAPPING.
- p_klist is definitely locked now by the proc lock.
- p_runtime, p_[usi]u are locked by sched_lock.
- Add a new P_KTHREAD flag set for kernel threads created via
kthread_create(9).
- STOPEVENT() only needs the proc lock, it does not need Giant.
- faultin() already checks PS_INMEM, so simplify the check in PHOLD() so
that we only need to grab the proc lock and let faultin() perform the
PS_INMEM check.
- Add a prototype for zpfind().
- Add prototypes for the new fork_exit() and fork_return() MI functions
that manage the fork return path.
- Add a prototype for the MD function userret() so that it can be called
from fork_return().
- Add needed include of <machine/frame.h> in the kernel.
sobomax [Wed, 24 Jan 2001 09:05:35 +0000 (09:05 +0000)]
Minor fixes:
- Use "OPOST | ONLCR" as a c_oflag in the raw mode instead of 0, which should
make debug output mode readable;
- flush input buffer when switching to/from raw mode. This should prevent
leaking raw scancodes into your shell prompt when program called
VGLKeyboardEnd() w/o processing all scancodes in the buffer.
hm [Wed, 24 Jan 2001 08:41:52 +0000 (08:41 +0000)]
remove redundant definitions of card types:
- remove all occurances of FLAG_XXX values and replace with CARD_TYPEP_XXX
- remove sc_flag from isic softc and replace it with sc_cardtyp
remove some left over redundant definitions from isic and i4b_l1.h
remove left over cvs id from i4b cvs repository
jhb [Wed, 24 Jan 2001 00:36:03 +0000 (00:36 +0000)]
Don't grab Giant when calling kmem_alloc/kmem_free as this is just
encouraging other people to follow the same practice. If this is going
to be done, then it should be done inside of those two functions instead.
mjacob [Tue, 23 Jan 2001 23:22:17 +0000 (23:22 +0000)]
Allow fxp to configure in I/O space if the user wants it and specifies
an override as a loader settable variable (fxp_iomap). fxp_iomap is
a bitmap of fxp units that should be configured to use PCI I/O space
in stead of PCI Memory space.
Reviewed by: Kees Jan Koster <dutchman@tccn.cs.kun.nl>, dg@freebsd.org