Commit Graph

596 Commits

Author SHA1 Message Date
Jake Burkholder
8ba3d077ff Add an MD callout like cpu_exit, but which is called after sched_lock is
obtained, when all other scheduling activity is suspended.  This is needed
on sparc64 to deactivate the vmspace of the exiting process on all cpus.
Otherwise if another unrelated process gets the exact same vmspace structure
allocated to it (same address), its address space will not be activated
properly.  This seems to fix some spontaneous signal 11 problems with smp
on sparc64.
2002-06-24 15:48:02 +00:00
Jonathan Mini
01ad8a53db Remove unused diagnostic function cread_free_thread().
Approved by:	alfred
2002-06-24 06:22:00 +00:00
Ian Dowse
2f384b348a Make vm_pindex_t 64-bit on all platforms. This is necessary to avoid
overflows with the large file sizes that UFS2 permits.

Reviewed by:	dillon, alc, tegge
2002-06-23 21:57:19 +00:00
Peter Wemm
b23619e02a Deorbit suibyte(). It was only used for split address space systems
for supporting UIO_USERISPACE (ie: it wasn't used).
2002-06-20 07:13:35 +00:00
Peter Wemm
2f9267ec23 Move the "- 1" into the RQB_FFS(mask) macro itself so that
implementations can provide a base zero ffs function if they wish.
This changes
  #define RQB_FFS(mask) (ffs64(mask))
  foo = RQB_FFS(mask) - 1;
to
  #define RQB_FFS(mask) (ffs64(mask) - 1)
  foo = RQB_FFS(mask);
On some platforms we can get the "- 1" for free, eg: those that use the
C code for ffs64().

Reviewed by:	jake (in principle)
2002-06-20 06:21:20 +00:00
John Baldwin
99cca534f3 - Fixup / remove obsolete comments.
- ktrace no longer requires Giant so do ktrace syscall events before and
  after acquiring and releasing Giant, respectively.
- For i386, ia32 syscalls on ia64, powerpc, and sparc64, get rid of the
  goto bad hack and instead use the model on ia64 and alpha were we
  skip the actual syscall invocation if error != 0.  This fixes a bug
  where if we the copyin() of the arguments failed for a syscall that
  was not marked MP safe, we would try to release Giant when we had
  not acquired it.
2002-06-07 05:47:35 +00:00
Doug Rabson
99bd783419 Move the definition of ElfN_Hashelt to common headers. The only platform
which has a different definition for this is alpha.
2002-05-30 08:32:18 +00:00
Benno Rice
c05529221e The stack is not at the top of the user struct. 2002-05-28 12:31:34 +00:00
Benno Rice
3cdee89f99 Remove an assertion as to whether the current thread already had the FPU or
not.  It may be desirable to put something similar back, but it's getting in
the way in it's current form.
2002-05-28 12:28:22 +00:00
Benno Rice
60ead00ef8 - Move macros that represent where syscall args are kept in a trapframe from
trap.c to frame.h
- Use the macros in vm_machdep.c:cpu_fork() to set up the trap frame of the
  new thread.
2002-05-28 12:24:29 +00:00
Benno Rice
8e36f0ec3f Remove the old prototype for kcopy. It's in cpu.h now. 2002-05-28 09:38:02 +00:00
Benno Rice
25e2288dd7 Implement pmap_copy and pmap_copy_page. 2002-05-28 07:38:55 +00:00
Benno Rice
37d87c9ff8 Move the kcopy() function from trap.c to machdep.c. Add a prototype. 2002-05-28 07:36:36 +00:00
Benno Rice
31956eeb9e Print srr1 in printtrap()
Submitted by:	Peter Grehan <peterg@ptree32.com.au>
2002-05-27 11:20:19 +00:00
Benno Rice
31c82d0332 Get the correct memory regions from OpenFirmware. We were getting the
"available" ranges, not the "physical" ranges.  Clean up some of the
bootstrap code in the process.

Submitted by:	Peter Grehan <peterg@ptree32.com.au>
2002-05-27 11:18:12 +00:00
Benno Rice
7ed61facaa Use correct types in [sf]uword32. 2002-05-27 10:50:47 +00:00
Doug Rabson
396a429cfd Add declarations of suword32 and suword64. Add implementations of one or
the other (or both) to all the platforms. Similar for fuword32 and
fuword64.
2002-05-26 16:03:13 +00:00
Jake Burkholder
d2ac231616 Make the run queue parameters machine dependent. Optimize 64 bit
architectures by using a 64 bit word for the bit array which keeps
track of non-empty queues.

Reviewed by:	peter
2002-05-25 01:12:23 +00:00
Benno Rice
84b3ce6811 Make this more FreeBSD-ish.
Requested by:	jhb
2002-05-19 08:16:25 +00:00
Benno Rice
76a118f236 - Do a quick style pass.
- Correct the implementation of fix_unaligned to use a thread, not a proc.
- GC some #if 0'd stuff.
2002-05-19 04:04:12 +00:00
Benno Rice
4ca98df6b2 Add the PSL_VEC flag for AltiVec (no, it's not here yet =)) 2002-05-19 04:03:11 +00:00
Benno Rice
96269f7e26 - Rename the _C_LABEL macro to CNAME.
- Rename the _ASM_LABEL macro to ASMNAME.
- Add the HIDENAME macro which is used in libc's syscall stuff.
2002-05-17 01:44:55 +00:00
Benno Rice
b635dacd57 Fix commenting around NetBSD version string. 2002-05-17 01:41:01 +00:00
David E. O'Brien
ae8f9dd13f An exact copy of i386/include/float.h will work here. 2002-05-15 20:54:35 +00:00
Poul-Henning Kamp
6380601f64 Move MI stuff out of MD param.h files.
It can all still be overridden in the MD files should need suddenly arise.
2002-05-14 20:35:29 +00:00
Poul-Henning Kamp
4c51ae2155 Remove the unused definitions of ctod() and dotc(). 2002-05-14 20:01:34 +00:00
Benno Rice
eeaa897915 FPU support.
Obtained from:	NetBSD (portions)
2002-05-13 07:44:48 +00:00
Benno Rice
608cd3ca29 More locking fixes. 2002-05-12 13:43:21 +00:00
Benno Rice
a397544c6b Do the correct locking on processes for DSI and ISI traps.
Copied from:	sparc64
2002-05-12 06:06:24 +00:00
Benno Rice
0f92104c14 Implement the following functions:
- pmap_addr_hint
- pmap_change_wiring
- pmap_extract
- pmap_is_modified
2002-05-10 14:21:48 +00:00
Benno Rice
e89482f7cb Install the system call trap handler. 2002-05-10 14:19:44 +00:00
Benno Rice
fafc736254 Improve our detection of an attempted duplicate entry. We may be trying to
change the page protection bits.
2002-05-10 06:27:08 +00:00
Benno Rice
f2b85e7c82 Remove a debugging printf that escaped. 2002-05-10 06:26:19 +00:00
Benno Rice
a51eb7c321 Increase the size of the kstack. 2002-05-10 05:16:40 +00:00
David E. O'Brien
c7e401fbc3 Gcc 3.1 varargs support. 2002-05-10 02:12:04 +00:00
Benno Rice
3779a55671 Update to newer trap code from NetBSD.
Obtained from:	NetBSD
2002-05-09 14:22:55 +00:00
Benno Rice
afb7382655 Add an assertion that we have a current pmap set before we try and return. 2002-05-09 14:15:51 +00:00
Benno Rice
1d61c15b8a The per-cpu curpmap is now set by pmap_activate. We don't need to do it here
anymore.
2002-05-09 14:13:29 +00:00
Benno Rice
8c2b091ea2 - Add a prototype for the setfault() function.
- Remove some stray printf()s.
2002-05-09 14:11:17 +00:00
Benno Rice
8207b3627b 1. Better track the executable status of mappings.
2.  Set a pcpu variable to the real address of the active pmap (used when
    exiting from traps.

Obtained from:	NetBSD (1)
2002-05-09 14:09:19 +00:00
Benno Rice
3bc5121f01 Rename the constants for the contents of the PVR register so as not to
conflict with cpu names used in config files..
2002-05-09 14:04:43 +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
Benno Rice
b57e802a85 Commit of stuff that's been sitting in my tree for a while.
Highlights include:
- New low-level trap code from NetBSD.  The high level code still needs a lot
  of work.
- Fixes for some pmap handling in thread switching.
- The kernel will now get to attempting to jump into init in user mode.  There
  are some pmap/trap issues which prevent it from actually getting there though.

Obtained from:	NetBSD (parts)
2002-04-29 12:14:31 +00:00
Benno Rice
d809b79220 - Add back calls to setfault that were removed when these functions were moved. 2002-04-29 09:28:56 +00:00
Peter Wemm
db17c6fc07 Tidy up some loose ends.
i386/ia64/alpha - catch up to sparc64/ppc:
- replace pmap_kernel() with refs to kernel_pmap
- change kernel_pmap pointer to (&kernel_pmap_store)
  (this is a speedup since ld can set these at compile/link time)
all platforms (as suggested by jake):
- gc unused pmap_reference
- gc unused pmap_destroy
- gc unused struct pmap.pm_count
(we never used pm_count - we track address space sharing at the vmspace)
2002-04-29 07:43:16 +00:00
Alan Cox
72ba293d78 MFi386 1.222: Remove vm_map_growstack() and acquisition and release of Giant
around vm_fault() in trap_pfault().
2002-04-27 17:00:28 +00:00
Marcel Moolenaar
d297ad160e Don't use the symbol name to lookup the symbol value when we can use
the symbol index defined by the relocation. The elf_lookup() support
function is to be used by elf_reloc() when symbol lookups need to be
done. The elf_lookup() function operates on the symbol index and
will do a symbol name based lookup when such is required, otherwise
it uses the symbol index directly. This solves the problem seen on
ia64 where the symbol hash table does not contain local symbols and
a symbol name based lookup would fail for those symbols.

Don't pass the symbol name to elf_reloc(), as it isn't used any more.
2002-04-25 01:22:16 +00:00
Benno Rice
f6310641b9 Replace inline asm with it's inline function wrapper. 2002-04-20 10:06:22 +00:00
Benno Rice
864bc5205b Correct a comment. 2002-04-16 12:15:17 +00:00
Benno Rice
e79f59e84c Implement the following functions:
- pmap_kextract
	- pmap_object_init_pt
	- pmap_protect
	- pmap_remove_pages

I'm pretty sure pmap_remove_pages is at least somewhat bogus.
2002-04-16 12:13:10 +00:00
Benno Rice
27dbf9d5e8 Remove some dead code. 2002-04-16 12:10:04 +00:00
Benno Rice
d080d5fd7c Use mtsrin() instead of inline asm. 2002-04-16 12:07:41 +00:00
Benno Rice
a8aaf02c3c Change the value of PMAP_BOOTSTRAP so we don't stomp on the PTE index value. 2002-04-16 12:00:43 +00:00
Benno Rice
b2df36e7d2 Add inlines for mtsrin and mfsrin. 2002-04-16 11:45:09 +00:00
Peter Wemm
1a87a0da66 Pass vm_page_t instead of physical addresses to pmap_zero_page[_area]()
and pmap_copy_page().  This gets rid of a couple more physical addresses
in upper layers, with the eventual aim of supporting PAE and dealing with
the physical addressing mostly within pmap.  (We will need either 64 bit
physical addresses or page indexes, possibly both depending on the
circumstances.  Leaving this to pmap itself gives more flexibilitly.)

Reviewed by:	jake
Tested on:	i386, ia64 and (I believe) sparc64. (my alpha was hosed)
2002-04-15 16:00:03 +00:00
Benno Rice
2819d0ade2 Add ofwd to the GENERIC config for powerpc. 2002-04-15 12:30:18 +00:00
Benno Rice
3e0ec88767 Add a nexus device.
Copied from:	sparc64
2002-04-15 12:29:18 +00:00
Benno Rice
52a3cde55d Turn some CTR's into CTR0's. 2002-04-15 12:11:18 +00:00
Benno Rice
da57e52add GC an extraneous prototype of delay(). 2002-04-15 12:02:43 +00:00
Mike Barcroft
795aff0ed9 Include <sys/cdefs.h> for definition of __BSD_VISIBLE.
Pointy hat to:	mike
2002-04-12 15:56:45 +00:00
Mike Barcroft
49285705cc Remove the hack for segsz_t from <sys/types.h>; use the normal
_BSD_FOO_T_ method for defining segsz_t.
2002-04-10 15:58:13 +00:00
Mike Barcroft
7f0f1cfd57 Add manifest constants: _LITTLE_ENDIAN, _BIG_ENDIAN, _PDP_ENDIAN, and
_BYTE_ORDER.  These are far more useful than their non-underscored
equivalents as these can be used in restricted namespace environments.
Mark the non-underscored variants as deprecated.
2002-04-10 14:39:14 +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
Poul-Henning Kamp
67ec58a802 GC the "dumplo" variable, which is no longer used.
A lot of sys/*/*/machdep.c seems not to be.
2002-04-07 21:01:37 +00:00
John Baldwin
c53c013bae - Move the MI mutexes sched_lock and Giant from being declared in the
various machdep.c's to being declared in kern_mutex.c.
- Add a new function mutex_init() used to perform early initialization
  needed for mutexes such as setting up thread0's contested lock list
  and initializing MI mutexes.  Change the various MD startup routines
  to call this function instead of duplicating all the code themselves.

Tested on:	alpha, i386
2002-04-02 22:19:16 +00:00
Matthew Dillon
182da8209d Stage-2 commit of the critical*() code. This re-inlines cpu_critical_enter()
and cpu_critical_exit() and moves associated critical prototypes into their
own header file, <arch>/<arch>/critical.h, which is only included by the
three MI source files that need it.

Backout and re-apply improperly comitted syntactical cleanups made to files
that were still under active development.  Backout improperly comitted program
structure changes that moved localized declarations to the top of two
procedures.  Partially re-apply one of the program structure changes to
move 'mask' into an intermediate block rather then in three separate
sub-blocks to make the code more readable.  Re-integrate bug fixes that Jake
made to the sparc64 code.

Note: In general, developers should not gratuitously move declarations out
of sub-blocks.  They are where they are for reasons of structure, grouping,
readability, compiler-localizability, and to avoid developer-introduced bugs
similar to several found in recent years in the VFS and VM code.

Reviewed by:	jake
2002-04-01 23:51:23 +00:00
Poul-Henning Kamp
8d19a26558 Centralize the "bootdev" and "dumpdev" variables. They are still pretty
bogus all things considered, but at least now they don't camouflage as
being MD variables.
2002-03-31 07:15:28 +00:00
Alan Cox
6ef4be047a Use the MI vm_map_growstack() instead of the MD grow_stack() in trap(). Remove
the MD grow_stack().
2002-03-30 20:44:31 +00:00
Jeff Roberson
f22a4b62f5 Add a new mtx_init option "MTX_DUPOK" which allows duplicate acquires of locks
with this flag.  Remove the dup_list and dup_ok code from subr_witness.  Now
we just check for the flag instead of doing string compares.

Also, switch the process lock, process group lock, and uma per cpu locks over
to this interface.  The original mechanism did not work well for uma because
per cpu lock names are unique to each zone.

Approved by:	jhb
2002-03-27 09:23:41 +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
David E. O'Brien
c543d983fa Guard against redefining __gnuc_va_list. 2002-03-24 11:25:46 +00:00
David E. O'Brien
439a4003ab ASM versions of __FBSDID. 2002-03-23 02:01:27 +00:00
Benno Rice
bf76ba7826 Collect all functions for copying to and from userspace into the one file.
This allows me to reimplement [sf]u{byte,word} as separate functions and not
as calls to copy{in,out}.
2002-03-21 23:45:59 +00:00
Benno Rice
6da4e60a23 - Make all inlines for manipulating supervisor-level registers accept/return
register_t values.
- Implement an inline for isync.
2002-03-21 13:07:31 +00:00
Benno Rice
54551c77ee GC some unused, bogus interrupt functions and replace them with proper
implementations of intr_disable and intr_restore.
2002-03-21 12:04:58 +00:00
Jeff Roberson
378862a72d Remove references to vm_zone.h and switch over to the new uma API. 2002-03-21 01:11:31 +00:00
Alfred Perlstein
812344bc0b Remove __P.
Reveiwed by: benno
2002-03-20 23:17:50 +00:00
John Baldwin
f25fcd64b8 Change the way we ensure td_ucred is NULL if DIAGNOSTIC is defined.
Instead of caching the ucred reference, just go ahead and eat the
decerement and increment of the refcount.  Now that Giant is pushed down
into crfree(), we no longer have to get Giant in the common case.  In the
case when we are actually free'ing the ucred, we would normally free it on
the next kernel entry, so the cost there is not new, just in a different
place.  This also removse td_cache_ucred from struct thread.  This is
still only done #ifdef DIAGNOSTIC.

Tested on:	i386, alpha
2002-03-20 21:09:09 +00:00
Benno Rice
21d7ec8915 Increment pmap_pvo_count in the right place. 2002-03-20 05:25:33 +00:00
Jeff Roberson
8355f576a9 This is the first part of the new kernel memory allocator. This replaces
malloc(9) and vm_zone with a slab like allocator.

Reviewed by:	arch@
2002-03-19 09:11:49 +00:00
Benno Rice
49f8f7273b Changes and fixes in preparation for UMA:
- Bootstrap pvo entries are now allocated by stealing pages.
- Just return if we're pmap_enter'ing a mapping that's already there.  Don't
  remove it and re-enter it.
2002-03-17 23:58:12 +00:00
Benno Rice
508473baea Lowercase all of the trap names. 2002-03-17 23:55:11 +00:00
Benno Rice
9737e23c11 Clean up and fix up copyin and copyout. 2002-03-17 23:54:55 +00:00
Dag-Erling Smørgrav
a2e0658045 Move the definition of PT_[GS]ET{,DB,FP}REGS from the MD ptrace.h to the
MI ptrace.h, since all platforms define them.  Keep the MD ptrace.h around
for FIX_SSTEP (which is currently only needed on Alpha).
2002-03-16 00:25:53 +00:00
Benno Rice
8862232d7b Correct a typo. (* that should've been &) 2002-03-11 07:09:42 +00:00
Mike Barcroft
d846855da8 o Don't require long long support in bswap64() functions.
o In i386's <machine/endian.h>, macros have some advantages over
  inlines, so change some inlines to macros.
o In i386's <machine/endian.h>, ungarbage collect word_swap_int()
  (previously __uint16_swap_uint32), it has some uses on i386's with
  PDP endianness.

Submitted by:	bde

o Move a comment up in <machine/endian.h> that was accidentially moved
  down a few revisions ago.
o Reenable userland's use of optimized inline-asm versions of
  byteorder(3) functions.
o Fix ordering of prototypes vs. redefinition of byteorder(3)
  functions, so that the non-GCC (libc asm) case has proper
  prototypes.
o Add proper prototypes for byteorder(3) functions in <sys/param.h>.
o Prevent redundant duplicate prototypes by making use of the
  _BYTEORDER_PROTOTYPED define.
o Move the bswap16(), bswap32(), bswap64() C functions into MD space
  for platforms in which asm versions don't exist.  This significantly
  reduces the complexity of some things at the cost of duplicate code.

Reviewed by:	bde
2002-03-09 21:02:16 +00:00
Benno Rice
db9e94f707 Install the DSI and ISI trap handlers and their appropriate locations. 2002-03-07 12:22:44 +00:00
Benno Rice
3e4409437f Copy the "implementation" of pmap_prefault from sparc64. 2002-03-07 12:22:08 +00:00
Benno Rice
9164438ed2 Move tunable initialisation so it can get access to physmem. 2002-03-07 10:15:17 +00:00
Benno Rice
d2c1f57685 Calculate physmem. 2002-03-07 10:09:24 +00:00
Andrew R. Reiter
66c862bc1b - Move a comment from being on the same line as a #ifdef to the line
following it.  This should have gone in the previous commit, but
  misviewed Bruce's patch.

Requested by: bde
2002-02-28 21:52:08 +00:00
Benno Rice
677bcc872c cpu_switch now works, for kthreads at least. 2002-02-28 12:06:49 +00:00
Benno Rice
0e1338662a Various cleanups. 2002-02-28 12:00:24 +00:00
Benno Rice
b8160b5af4 - Prevent the decrementer interrupt handler from nesting.
- Catch some more cases of PSL_EE and PSL_RI getting out of sync.
2002-02-28 11:57:47 +00:00
Benno Rice
ac6ba8bd4a - Modify pmap_activate so it only marks the pmap as active.
- Add a pmap_deactivate function.
2002-02-28 11:55:44 +00:00
Benno Rice
3301d20ad9 GC an unused variable in cpu_fork(). 2002-02-28 08:48:58 +00:00
Andrew R. Reiter
216ae18217 - Fix panic() message and a couple style nits that snuck in from the
recent diagnostics commit (rev. 1.84).
2002-02-28 08:28:14 +00:00
Benno Rice
4eed0cf1be Make fork work, at least for kthreads. Switching still has some issues. 2002-02-28 03:24:07 +00:00
Benno Rice
b7ac845009 - Rearrange the sequence of events in powerpc_init() somewhat.
- Catch another instance of PSL_EE being cleared without PSL_RI.
2002-02-28 03:15:49 +00:00
Benno Rice
3c854532b0 - When enabling/disabling interrupts, set/clear both PSL_EE and PSL_RI, not
just PSL_EE.
- Make cpu_critical_enter/exit independant of save_intr/restore_intr.
2002-02-28 03:07:48 +00:00
Benno Rice
9a7fefa51e Add a missing (. 2002-02-28 03:04:33 +00:00
Benno Rice
88afb2a31b Implement the following functions:
- pmap_remove
	- pmap_kremove
	- pmap_qremove
2002-02-28 02:54:16 +00:00
Benno Rice
54eb8bbc14 Remove most of the usage of critical_enter/exit.
I put these in to match the use of spl*() in the NetBSD code I was basing this
on, but it appears to cause problems.

I'm doing this in a separate commit so as to be able to refer back if locking
becomes an issue at a later stage.
2002-02-28 02:45:10 +00:00
Mike Silbersack
7f3a40933b Fix a horribly suboptimal algorithm in the vm_daemon.
In order to determine what to page out, the vm_daemon checks
reference bits on all pages belonging to all processes.  Unfortunately,
the algorithm used reacted badly with shared pages; each shared page
would be checked once per process sharing it; this caused an O(N^2)
growth of tlb invalidations.  The algorithm has been changed so that
each page will be checked only 16 times.

Prior to this change, a fork/sleepbomb of 1300 processes could cause
the vm_daemon to take over 60 seconds to complete, effectively
freezing the system for that time period.  With this change
in place, the vm_daemon completes in less than a second.  Any system
with hundreds of processes sharing pages should benefit from this change.

Note that the vm_daemon is only run when the system is under extreme
memory pressure.  It is likely that many people with loaded systems saw
no symptoms of this problem until they reached the point where swapping
began.

Special thanks go to dillon, peter, and Chuck Cranor, who helped me
get up to speed with vm internals.

PR:		33542, 20393
Reviewed by:	dillon
MFC after:	1 week
2002-02-27 18:03:02 +00:00
Thomas Moestl
90ce56c287 Add the following functions/macros to support byte order conversions and
device drivers for bus system with other endinesses than the CPU (using
interfaces compatible to NetBSD):

- bwap16() and bswap32(). These have optimized implementations on some
  architectures; for those that don't, there exist generic implementations.
- macros to convert from a certain byte order to host byte order and vice
  versa, using a naming scheme like le16toh(), htole16().
  These are implemented using the bswap functions.
- stream bus space access functions, which do not perform a byte order
  conversion (while the normal access functions would if the bus endianess
  differs from the CPU endianess).

htons(), htonl(), ntohs() and ntohl() are implemented using the new
functions above for kernel usage. None of the above interfaces is currently
exported to user land.

Make use of the new functions in a few places where local implementations
of the same functionality existed.

Reviewed by:	mike, bde
Tested on alpha by:	mike
2002-02-27 17:16:18 +00:00
Benno Rice
4b1211c7cc Add makeoptions NO_WERROR=true so that we can build. =) 2002-02-26 09:55:17 +00:00
Benno Rice
dfc02c301d Make atomic_cmpset_32 correctly return 0 on failure. 2002-02-24 23:31:49 +00:00
Benno Rice
f8e03c1093 Don't call critical_enter()/critical_exit() around calls to pmap_pvo_enter()
as it does it's own handling of critical sections.
2002-02-23 05:55:51 +00:00
Julian Elischer
77c4066424 Add some DIAGNOSTIC code.
While in userland, keep the thread's ucred reference in a shadow
field so that the usual place to store it is NULL.
If DIAGNOSTIC is not set, the thread ucred is kept valid until the next
kernel entry, at which time it is checked against the process cred
and possibly corrected. Produces a BIG speedup in
kernels with INVARIANTS set. (A previous commit corrected it
for the non INVARIANTS case already)

Reviewed by:	dillon@freebsd.org
2002-02-22 23:58:22 +00:00
Julian Elischer
bc08443ef1 Add change to teh PPC to keep it in step with i386 and MI code
Pointy hat this direction please...
2002-02-19 03:27:08 +00:00
Mike Barcroft
fd8e4ebc8c o Move NTOHL() and associated macros into <sys/param.h>. These are
deprecated in favor of the POSIX-defined lowercase variants.
o Change all occurrences of NTOHL() and associated marcros in the
  source tree to use the lowercase function variants.
o Add missing license bits to sparc64's <machine/endian.h>.
  Approved by: jake
o Clean up <machine/endian.h> files.
o Remove unused __uint16_swap_uint32() from i386's <machine/endian.h>.
o Remove prototypes for non-existent bswapXX() functions.
o Include <machine/endian.h> in <arpa/inet.h> to define the
  POSIX-required ntohl() family of functions.
o Do similar things to expose the ntohl() family in libstand, <netinet/in.h>,
  and <sys/param.h>.
o Prepend underscores to the ntohl() family to help deal with
  complexities associated with having MD (asm and inline) versions, and
  having to prevent exposure of these functions in other headers that
  happen to make use of endian-specific defines.
o Create weak aliases to the canonical function name to help deal with
  third-party software forgetting to include an appropriate header.
o Remove some now unneeded pollution from <sys/types.h>.
o Add missing <arpa/inet.h> includes in userland.

Tested on:	alpha, i386
Reviewed by:	bde, jake, tmm
2002-02-18 20:35:27 +00:00
David E. O'Brien
334bb4125f style(9) 2002-02-18 06:24:55 +00:00
Garrett Wollman
3b7a4c4b1d Resurrect one of the easiest changes from my big include files roll-up
patch from a year ago: give file flags their own type.  This does not
(yet) change the type used by system calls or library functions.
The underlying type was chosen to match what is returned by stat().
2002-02-15 22:15:39 +00:00
Benno Rice
5244eac968 Complete rework of the PowerPC pmap and a number of other bits in the early
boot sequence.

The new pmap.c is based on NetBSD's newer pmap.c (for the mpc6xx processors)
which is 70% faster than the older code that the original pmap.c was based
on.  It has also been based on the framework established by jake's initial
sparc64 pmap.c.

There is no change to how far the kernel gets (it makes it to the mountroot
prompt in psim) but the new pmap code is a lot cleaner.

Obtained from:	NetBSD (pmap code)
2002-02-14 01:39:11 +00:00
Julian Elischer
079b7badea Pre-KSE/M3 commit.
this is a low-functionality change that changes the kernel to access the main
thread of a process via the linked list of threads rather than
assuming that it is embedded in the process. It IS still embeded there
but remove all teh code that assumes that in preparation for the next commit
which will actually move it out.

Reviewed by: peter@freebsd.org, gallatin@cs.duke.edu, benno rice,
2002-02-07 20:58:47 +00:00
Poul-Henning Kamp
e0ee6f5629 GC the PC_SWITCH* symbols which are not used in assembly anymore. 2002-02-07 10:27:58 +00:00
Bruce Evans
55a9536b65 Compile osigreturn() unconditionally since it will always be needed on
some arches and the syscall table is machine-independent.  It was
(bogusly) conditional on COMPAT_43, so this usually makes no difference.

ia64: in addition:
- replace the bogus cloned comment before osigreturn() by a correct one.
  osigreturn() is just a stub fo ia64's.
- fix the formatting of cloned comment before sigreturn().
- fix the return code.  use nosys() instead of returning ENOSYS to get
  the same semantics as if the syscall is not in the syscall table.
  Generating SIGSYS is actually correct here.
- fix style bugs.

powerpc: copy the cleaned up ia64 stub.  This mainly fixes a bogus comment.

sparc64: copy the cleaned up the ia64 stub, since there was no stub before.
2002-02-01 15:44:03 +00:00
Andrew Gallatin
350cb38b1f Simple fixes to get the powerpc kernel compiling again.
Reviewed by:	mp
2002-01-28 14:07:36 +00:00
John Baldwin
7e1f6dfe9d Modify the critical section API as follows:
- The MD functions critical_enter/exit are renamed to start with a cpu_
  prefix.
- MI wrapper functions critical_enter/exit maintain a per-thread nesting
  count and a per-thread critical section saved state set when entering
  a critical section while at nesting level 0 and restored when exiting
  to nesting level 0.  This moves the saved state out of spin mutexes so
  that interlocking spin mutexes works properly.
- Most low-level MD code that used critical_enter/exit now use
  cpu_critical_enter/exit.  MI code such as device drivers and spin
  mutexes use the MI wrappers.  Note that since the MI wrappers store
  the state in the current thread, they do not have any return values or
  arguments.
- mtx_intr_enable() is replaced with a constant CRITICAL_FORK which is
  assigned to curthread->td_savecrit during fork_exit().

Tested on:	i386, alpha
2001-12-18 00:27:18 +00:00
John Baldwin
0bbc882680 Overhaul the per-CPU support a bit:
- The MI portions of struct globaldata have been consolidated into a MI
  struct pcpu.  The MD per-CPU data are specified via a macro defined in
  machine/pcpu.h.  A macro was chosen over a struct mdpcpu so that the
  interface would be cleaner (PCPU_GET(my_md_field) vs.
  PCPU_GET(md.md_my_md_field)).
- All references to globaldata are changed to pcpu instead.  In a UP kernel,
  this data was stored as global variables which is where the original name
  came from.  In an SMP world this data is per-CPU and ideally private to each
  CPU outside of the context of debuggers.  This also included combining
  machine/globaldata.h and machine/globals.h into machine/pcpu.h.
- The pointer to the thread using the FPU on i386 was renamed from
  npxthread to fpcurthread to be identical with other architectures.
- Make the show pcpu ddb command MI with a MD callout to display MD
  fields.
- The globaldata_register() function was renamed to pcpu_init() and now
  init's MI fields of a struct pcpu in addition to registering it with
  the internal array and list.
- A pcpu_destroy() function was added to remove a struct pcpu from the
  internal array and list.

Tested on:	alpha, i386
Reviewed by:	peter, jake
2001-12-11 23:33:44 +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
David E. O'Brien
acdff873d8 style(9) 2001-12-09 19:12:07 +00:00
Matthew Dillon
66a11b9fb1 Allow maxusers to be specified as 0 in the kernel config, which will
cause the system to auto-size to between 32 and 512 depending on the
amount of memory.

MFC after:	1 week
2001-12-09 01:57:09 +00:00
John Baldwin
aee9d2774f Add multiple inclusion protection. 2001-12-06 18:17:02 +00:00
Mike Barcroft
de2656d0ed o Stop abusing MD headers with non-MD types.
o Hide nonstandard functions and types in <netinet/in.h> when
  _POSIX_SOURCE is defined.
o Add some missing types (required by POSIX.1-200x) to <netinet/in.h>.
o Restore vendor ID from Rev 1.1 in <netinet/in.h> and make use of new
  __FBSDID() macro.
o Fix some miscellaneous issues in <arpa/inet.h>.
o Correct final argument for the inet_ntop() function (POSIX.1-200x).
o Get rid of the namespace pollution from <sys/types.h> in
  <arpa/inet.h>.

Reviewed by:		fenner
Partially submitted by:	bde
2001-12-01 03:43:01 +00:00
John Baldwin
b9c1b06bd7 The interrupt nesting level is per-thread not per-CPU on FreeBSD. 2001-11-14 01:00:40 +00:00
Mark Peek
e398651c46 Don't enable FP in the kernel. It is not needed when -msoft-float is used.
Reminded by:	benno
2001-11-13 00:44:21 +00:00
Mark Peek
0308a57783 Clean up the trap handling code and make it consistent with the other platforms.
Submitted by:	jhb
2001-11-05 00:49:03 +00:00
Mark Peek
8f718dfdc3 Add enable_fpu/save_fpu for handling the floating point registers in the PCB.
Obtained from:	NetBSD
2001-11-05 00:45:33 +00:00
Mike Barcroft
0ac2d551f2 o Add new header <sys/stdint.h>.
o Make <stdint.h> a symbolic link to <sys/stdint.h>.
o Move most of <sys/inttypes.h> into <sys/stdint.h>, as per C99.
o Remove <sys/inttypes.h>.
o Adjust includes in sys/types.h and boot/efi/include/ia64/efibind.h
  to reflect new location of integer types in <sys/stdint.h>.
o Remove previously symbolicly linked <inttypes.h>, instead create a
  new file.
o Add MD headers <machine/_inttypes.h> from NetBSD.
o Include <sys/stdint.h> in <inttypes.h>, as required by C99; and
  include <machine/_inttypes.h> in <inttypes.h>, to fill in the
  remaining requirements for <inttypes.h>.
o Add additional integer types in <machine/ansi.h> and
  <machine/limits.h> which are included via <sys/stdint.h>.

Partially obtain from:	NetBSD
Tested on:		alpha, i386
Discussed on:		freebsd-standards@bostonradio.org
Reviewed by:		bde, fenner, obrien, wollman
2001-11-02 18:05:43 +00:00
Mike Barcroft
3a72286480 Remove funky right justification.
Pointed out by:	bde
2001-10-23 00:42:15 +00:00
Dag-Erling Smørgrav
7c62990641 Move procfs_* from procfs_machdep.c into sys_process.c, and rename them to
proc_* in the process; procfs_machdep.c is no longer needed.

Run-tested on i386, build-tested on Alpha, untested on other platforms.
2001-10-21 23:57:24 +00:00
Dag-Erling Smørgrav
1f04261973 [partially forced commit due to pilot error in earlier commit attempt]
{set,fill}_{,fp,db}regs() fixup:

 - Add dummy {set,fill}_dbregs() on architectures that don't have them.

 - KSEfy the powerpc versions (struct proc -> struct thread).

 - Some architectures had the prototypes in md_var.h, some in reg.h, and
   some in both; for consistency, move them to reg.h on all platforms.

These functions aren't really MD (the implementation is MD, but the interface
is MI), so they should move to an MI header, but I haven't figured out which
one yet.

Run-tested on i386, build-tested on Alpha, untested on other platforms.
2001-10-21 22:16:48 +00:00
Mark Peek
94e0b85e76 Fix includes based on recent changes to lock.h, mutex.h and ktr.h. 2001-10-19 22:45:46 +00:00
David E. O'Brien
9f9bd82e15 Try two on the preprocessing logic.
Reviewed by:	ru
2001-10-19 20:01:01 +00:00
Mark Peek
6b2d0a7791 Cleanup of the stdarg code.
Submitted by:	ru
2001-10-19 16:15:46 +00:00
Mark Peek
ad91c1e7bd Add support for the gcc-2.95 stdarg implementation. 2001-10-18 19:11:12 +00:00
David E. O'Brien
e3ddd70789 My attempts at minimizing the number of #def's got me in trouble. 2001-10-18 16:07:21 +00:00
David E. O'Brien
4a3391b5a1 Add support for "__gnuc_va_list". Some overly "smart" libraries assume
the existence of the __gnuc_va_list type[*] because our compiler is GCC.

[*] __gnuc_va_list is defined in the GCC ginclude/stdarg.h replacement
headerwhich we don't use.
2001-10-18 00:27:39 +00:00
Benno Rice
f3ca814471 Flesh out cpu_fork() and cpu_set_fork_handler(). This is a work in progress. 2001-10-15 12:24:43 +00:00
Benno Rice
d163144b45 - Correct the type of the argument to delay() so as to not conflict with
sys/boot/common/bootstrap.h.
- Add a prototype for fork_trampoline().
2001-10-15 12:23:10 +00:00
Mark Peek
585cf148b6 Fix typo. 2001-10-15 01:04:49 +00:00
Mark Peek
422ec2ace1 Save WIP. Partial rewrite of cpu_switch() and savectx(). This makes it closer
to working but still needs some work to properly switch the full context
(such as saving the fpu registers, switch stacks, etc.).  Also, remove some
dead code that was mixed in.
2001-10-15 00:37:45 +00:00
Benno Rice
bdf71f568b Implement pmap_mapdev. 2001-10-14 08:38:16 +00:00
Mark Peek
5930786540 Add memory disk support to allow the boot process to proceed a bit further. 2001-10-12 20:02:50 +00:00
Mark Peek
f57f841372 Modify a virtual address check to allow use of the openfirmware callback
used by the PowerPC simulator (PSIM).
2001-10-12 19:55:04 +00:00
Mark Peek
03ea73346d Add standard calls to device_add_child() and root_bus_configure(). 2001-10-12 19:53:22 +00:00
Paul Saab
cbc89bfbfe Make MAXTSIZ, DFLDSIZ, MAXDSIZ, DFLSSIZ, MAXSSIZ, SGROWSIZ loader
tunable.

Reviewed by:	peter
MFC after:	2 weeks
2001-10-10 23:06:54 +00:00
Mark Peek
351bd3334f Add a call to init_param() to initialize some necessary variables. 2001-10-08 00:44:21 +00:00
Dag-Erling Smørgrav
3da3249106 Dissociate ptrace from procfs.
Until now, the ptrace syscall was implemented as a wrapper that called
various functions in procfs depending on which ptrace operation was
requested.  Most of these functions were themselves wrappers around
procfs_{read,write}_{,db,fp}regs(), with only some extra error checks,
which weren't necessary in the ptrace case anyway.

This commit moves procfs_rwmem() from procfs_mem.c into sys_process.c
(renaming it to proc_rwmem() in the process), and implements ptrace()
directly in terms of procfs_{read,write}_{,db,fp}regs() instead of
having it fake up a struct uio and then call procfs_do{,db,fp}regs().

It also moves the prototypes for procfs_{read,write}_{,db,fp}regs()
and proc_rwmem() from proc.h to ptrace.h, and marks all procfs files
except procfs_machdep.c as "optional procfs" instead of "standard".
2001-10-07 20:08:42 +00:00
Matt Jacob
22883e3c68 Fix problem where a user buffer outside of the area being tested
will be corrupted.

PR:		29194
Obtained from:	Tor.Egge@fast.no
MFC after:	2 weeks
2001-10-02 18:34:20 +00:00
Mark Peek
6e5e7555b3 Catch up to recent removal of curpcb from globals.h. 2001-09-24 02:58:49 +00:00
Mark Peek
d699b539c2 Add missing include file. 2001-09-20 15:32:56 +00:00
Mark Peek
3d88852a1e Don't include NFS headers.
Reported by:	dfr
2001-09-20 15:31:58 +00:00
Peter Wemm
55f25b39e9 Replicate a change from alpha/genassym.c to other arches. This should
fix nfs-related build breakage.
2001-09-20 02:49:59 +00:00
Mark Peek
06fdffd84d Use BATL/BATU macros instead of hardcoded hex constants. 2001-09-20 00:48:30 +00:00
Mark Peek
5fd2c51edb Update PowerPC MD code to compile and do initial bootstrap based on
recent changes (KSE and VM requiring physmem to be setup).

Reviewed by:	benno, jhb, julian
2001-09-20 00:47:17 +00:00
Peter Wemm
eb25edbda3 Cleanup and split of nfs client and server code.
This builds on the top of several repo-copies.
2001-09-18 23:32:09 +00:00
John Baldwin
5560ed7825 GC obsolete cruft from this file. 2001-09-18 21:53:25 +00:00
John Baldwin
fdca1cb1ef Whitespace fixes. 2001-09-18 21:52:15 +00:00
John Baldwin
fd54558a83 - If we ever do the per-cpu KTR stuff, the index won't be volatile as it
will be private to each CPU.
- Re-style(9) the globaldata structures.  There really needs to be a MI
  struct pcpu that has a MD struct mdpcpu member at some point.
2001-09-18 21:46:26 +00:00
John Baldwin
63077d1623 - Fix a missed idleproc -> idlethread conversion.
- Remove redundany fpucurproc (fpucurthread already existed)
2001-09-18 21:37:09 +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
Peter Wemm
eb30c1c0b9 Rip some well duplicated code out of cpu_wait() and cpu_exit() and move
it to the MI area.  KSE touched cpu_wait() which had the same change
replicated five ways for each platform.  Now it can just do it once.
The only MD parts seemed to be dealing with fpu state cleanup and things
like vm86 cleanup on x86.  The rest was identical.

XXX: ia64 and powerpc did not have cpu_throw(), so I've put a functional
stub in place.

Reviewed by:	jake, tmm, dillon
2001-09-10 04:28:58 +00:00
Peter Wemm
660c5377fd Missing part of dillon's coredump commit. cpu_coredump() was still
passing IO_NODELOCKED to vn_rdwr(), this would cause operations on the
unlocked core vnode and softupdates nastiness if an a.out binary cored.
2001-09-08 22:18:58 +00:00
David E. O'Brien
1792335469 style(9) the structure definitions. 2001-09-05 01:36:46 +00:00
Peter Wemm
cfbf880deb Zap #if 0'ed map init code that got moved to the MI area.
Convert the powerpc tree to use the common code.
2001-09-04 08:42:35 +00:00
Peter Wemm
b53f9c45f9 Nuke #if 0'ed "setredzone()" stub. We never used it, and probably
never will.  I've implemented an optional redzone as part of the KSE
upage breakup.
2001-09-04 08:36:46 +00:00
John Baldwin
8c8a7645c7 Axe stale mp_fixme(). 2001-09-01 00:49:29 +00:00
Peter Wemm
b8603f0e57 Similar to changes on i386/alpha/etc pmap.c; converge on a similar
look/feel on pmap_new_proc() with some cosmetic style changes.
2001-08-31 06:42:45 +00:00
Mike Barcroft
03516cfeb0 o Remove some GCCisms in src/powerpc/include/endian.h.
o Unify <machine/endian.h>'s across all architectures.
o Make bswapXX() functions use a different spelling of u_int16_t and
  friends to reduce namespace pollution.  The bswapXX() functions
  don't actually exist, but we'll probably import these at some
  point.  Atleast one driver (if_de) depends on bswapXX() for big
  endian cases.
o Deprecate byteorder(3) prototypes from <sys/types.h>, these are
  now prototyped indirectly in <arpa/inet.h>.
o Deprecate in_addr_t and in_port_t typedefs in <sys/types.h>, these
  are now typedef'd in <arpa/inet.h>.
o Change byteorder(3) prototypes to use standards compliant uint32_t
  (spelled __uint32_t to reduce namespace pollution).
o Document new preferred headers and standards compliance.

Discussed with:	bde
PR:		29946
Reviewed by:	bmilekic
2001-08-30 00:04:19 +00:00
Peter Wemm
547a9e66fd vm_page_zero_idle() is no longer MD. 2001-08-25 04:54:25 +00:00
Peter Wemm
e8ebc08f80 Make COMPAT_43 optional again. XXX we need COMPAT_FBSD3 etc for this
stuff.
2001-08-21 02:32:59 +00:00
David E. O'Brien
a6b989ffbf Minor style(9)'ing 2001-08-16 10:13:34 +00:00
David E. O'Brien
589278dbae style(9) and make consistent across platforms 2001-08-16 09:29:35 +00:00
Andrey A. Chernov
2a54e09dff OFF_T -> OFF (more standard style) 2001-08-15 19:50:59 +00:00
John Baldwin
d89c83bef1 The 'astpending' variable is already declared in trap.c (and unused in
FreeBSD besides).
2001-08-15 19:39:54 +00:00
John Baldwin
bf3db3eacb FreeBSD doesn't use a want_resched variable. Instead, the PS_NEEDRESCHED
p_sflag is managed in a MI fashion.
2001-08-15 19:39:09 +00:00
Andrey A. Chernov
a6314641a4 Add OFF_T_MAX/OFF_T_MIN 2001-08-15 19:25:08 +00:00
David E. O'Brien
059d1e91d8 Style changes to commonize the various platforms. 2001-08-15 04:02:41 +00:00
John Baldwin
688ebe120c - Close races with signals and other AST's being triggered while we are in
the process of exiting the kernel.  The ast() function now loops as long
  as the PS_ASTPENDING or PS_NEEDRESCHED flags are set.  It returns with
  preemption disabled so that any further AST's that arrive via an
  interrupt will be delayed until the low-level MD code returns to user
  mode.
- Use u_int's to store the tick counts for profiling purposes so that we
  do not need sched_lock just to read p_sticks.  This also closes a
  problem where the call to addupc_task() could screw up the arithmetic
  due to non-atomic reads of p_sticks.
- Axe need_proftick(), aston(), astoff(), astpending(), need_resched(),
  clear_resched(), and resched_wanted() in favor of direct bit operations
  on p_sflag.
- Fix up locking with sched_lock some.  In addupc_intr(), use sched_lock
  to ensure pr_addr and pr_ticks are updated atomically with setting
  PS_OWEUPC.  In ast() we clear pr_ticks atomically with clearing
  PS_OWEUPC.  We also do not grab the lock just to test a flag.
- Simplify the handling of Giant in ast() slightly.

Reviewed by:	bde (mostly)
2001-08-10 22:53:32 +00:00
Peter Wemm
2aca0c28d3 Zap 'ptrace(PT_READ_U, ...)' and 'ptrace(PT_WRITE_U, ...)' since they
are a really nasty interface that should have been killed long ago
when 'ptrace(PT_[SG]ETREGS' etc came along.  The entity that they
operate on (struct user) will not be around much longer since it
is part-per-process and part-per-thread in a post-KSE world.

gdb does not actually use this except for the obscure 'info udot'
command which does a hexdump of as much of the child's 'struct user'
as it can get.  It carries its own #defines so it doesn't break
compiles.
2001-08-08 05:25:15 +00:00
John Baldwin
f5b0911ca7 Axe unused and invalid astpending globaldata member. 2001-08-04 20:47:54 +00:00
John Baldwin
74c2df808a Axe unused and invalid GD_ASTPENDING symbol. 2001-08-04 20:46:46 +00:00
Jake Burkholder
7e5102989e Use a machine dependent type, Elf_Hashelt, for the elements of the elf
dynamic symbol table buckets and chains.  The sparc64 toolchain uses 32
bit .hash entries, unlike other 64 bits architectures (alpha), which use
64 bit entries.

Discussed with: dfr, jdp
2001-07-31 03:46:39 +00:00
Peter Wemm
0b27d7104f Make PMAP_SHPGPERPROC tunable. One shouldn't need to recompile a kernel
for this, since it is easy to run into with large systems with lots of
shared mmap space.

Obtained from:	yahoo
2001-07-27 01:08:59 +00:00
Bosko Milekic
49f854f926 - Do not handle the per-CPU containers in mbuf code as though the cpuids
were indices in a dense array. The cpuids are a sparse set and treat
  them as such, setting up containers only for CPUs activated during
  mb_init().

- Fix netstat(1) and systat(1) to treat the per-CPU stats area as a sparse
  map, in accordance with the above.

This allows us to properly boot with certain CPUs disactivated. However, if
we later decide to re-activate said CPUs, we will barf until we decide to
implement CPU spinon/spinoff callback hooks to allow for said CPUs' per-CPU
containers to get configured on their activation.

Reported by: mjacob
Partially (sys/ diffs) Submitted by: mjacob
2001-07-26 18:47:46 +00:00
Matthew Dillon
7197571105 Move vm_page_zero_idle() from machine-dependant sections to a
machine-independant source file, vm/vm_zeroidle.c.  It was exactly the
same for all platforms and updating them all was getting annoying.
2001-07-05 01:32:42 +00:00
Matthew Dillon
6d03d577a5 Reorg vm_page.c into vm_page.c, vm_pageq.c, and vm_contig.c (for contigmalloc).
Also removed some spl's and added some VM mutexes, but they are not actually
used yet, so this commit does not really make any operational changes
to the system.

vm_page.c relates to vm_page_t manipulation, including high level deactivation,
activation, etc...  vm_pageq.c relates to finding free pages and aquiring
exclusive access to a page queue (exclusivity part not yet implemented).
And the world still builds... :-)
2001-07-04 23:27:09 +00:00
Matthew Dillon
0cddd8f023 With Alfred's permission, remove vm_mtx in favor of a fine-grained approach
(this commit is just the first stage).  Also add various GIANT_ macros to
formalize the removal of Giant, making it easy to test in a more piecemeal
fashion. These macros will allow us to test fine-grained locks to a degree
before removing Giant, and also after, and to remove Giant in a piecemeal
fashion via sysctl's on those subsystems which the authors believe can
operate without Giant.
2001-07-04 16:20:28 +00:00
John Baldwin
d2a5bcc3d3 Allow Giant to be recursed when a process terminates. 2001-07-03 05:09:48 +00:00
Warner Losh
1f94b9005c Don't need the .keep_me files. Obrien and I committed past each other.
Add 0-9 to the list of possible kernel names at matsushita-san's
suggestion.

Submitted by: Makoto MATSUSHITA-san <matusita@jp.FreeBSD.org>
2001-07-01 23:35:44 +00:00
Benno Rice
640ce680dc Don't include machine/autoconf.h for now. It's not used and is breaking the
build.
2001-07-01 02:45:15 +00:00
Benno Rice
b7ac1056e7 Register definitions for the OpenPIC used in various models of
iMac/PowerMac/iBook/PowerBook.

Obtained from:	NetBSD
2001-07-01 02:43:38 +00:00
Benno Rice
c791ba59c0 Add TRAPF_* macros required by MI-ification of ast() and userret().
Submitted by:	Mark Peek <mark@whistle.com>
2001-07-01 02:38:38 +00:00
David E. O'Brien
5e6ded4212 Ensure sys/${MACHINE}/compile/FOO exists
Reviewed by: arch, imp, peter, and the USENIX terminal room secret kernel cabal
2001-06-30 15:16:29 +00:00
Warner Losh
e1d0d8a941 Really do proper keepme files in the compile directories. Use
.cvsignore file for [A-Za-z]* to keep these directories around rather
than waste a file on .keepme.  This should also make people's built
trees place nice with CVS.

Idea for .cvsignore: peter (although I suggested the regexp)
Pointed out by: Makoto MATSUSHITA-san <matusita@jp.FreeBSD.org>
Llama's costuming by: Fernamdo Llamas
2001-06-30 14:38:32 +00:00
David E. O'Brien
791eca5f7b Ensure sys/${MACHINE}/compile/FOO exists
Reviewed by: arch, imp, peter and
  the USENIX terminal room secret kernel cabal
2001-06-30 07:12:34 +00:00
John Baldwin
7aa7260e4a Move ast() and userret() to sys/kern/subr_trap.c now that they are MI. 2001-06-29 19:51:37 +00:00
John Baldwin
6be523bca7 Add a new MI pointer to the process' trapframe p_frame instead of using
various differently named pointers buried under p_md.

Reviewed by:	jake (in principle)
2001-06-29 11:10:41 +00:00
Benno Rice
ddfe059bf8 Put back the two semicolons I accidentally lost while reformatting this to
bring it closer to style(9).

Spotted by:	Mark Peek <mark@whistle.com>
2001-06-28 09:56:59 +00:00
Benno Rice
bda034cf8f Code for dealing with external interrupts.
Obtained from:	NetBSD
2001-06-27 12:33:51 +00:00
Benno Rice
111c77dcef Fix comment breakage. 2001-06-27 12:20:48 +00:00
Benno Rice
abc5579e8c Fix the atomic_*_32 operations. These were written before I had the ability
to test them properly and before I had a working knowledge of GCC asm
constraints.
2001-06-27 12:17:23 +00:00
Benno Rice
7a0e745f1a Don't initialise ret in atomic_cmpset_32.
Add more synchronisation.
2001-06-26 13:54:17 +00:00
Benno Rice
e2d53d7c4a Fix asm constraints for atomic_cmpset_32. This fix may also be needed
elsewhere.
2001-06-24 06:36:28 +00:00
Benno Rice
5fa25b1b0e More verbose version of identifycpu() which also contains many more CPU
versions/revisions.

Modified from the original patch to mark G3 and G4 processors as such.

Submitted by:	Jeff Schottmiller <jeff@neoscale.com>
2001-06-19 13:27:33 +00:00
Benno Rice
c585bae1c2 The final commit for the first phase of PowerPC support.
This adds the config stuff needed to build kernels.

Reviewed by:	obrien
2001-06-17 09:39:44 +00:00
Benno Rice
d27f1d4c12 This commit (along with one pending in sys/dev/ofw and one in sys/conf) give
us our first minimal glimpse of PowerPC support.

With this code we can get to the "mountroot>" prompt on my Apple iMac.  We
can't get any further due to lack of clock and interrupt handling, among other
things.  This does however mean that pmap and VM are initialising.

We're fairly dependant on OpenFirmware at this point, but I hope to add
support for other classes of firmware at a later stage.

Reviewed by:	obrien, dfr
2001-06-16 07:14:07 +00:00
David E. O'Brien
09e40de52f Add CVS id. 2001-06-15 22:54:33 +00:00
Benno Rice
f9bac91b18 Bring in NetBSD code used in the PowerPC port.
Reviewed by:	obrien, dfr
Obtained from:	NetBSD
2001-06-10 02:39:37 +00:00
David E. O'Brien
d520fe23e8 fix RCS ID style nit 2001-06-09 16:54:11 +00:00
David E. O'Brien
75f4a9b206 ID style nit. 2001-06-09 05:24:14 +00:00
David E. O'Brien
cb16c2c40c Style fix FreeBSD ID, and change continuation style slightly. 2001-06-09 05:01:24 +00:00
Poul-Henning Kamp
0d31cbfab7 Properly wrap mtx_intr_enable() macro in "do $bla while (0)" 2001-06-02 08:17:42 +00:00
John Baldwin
d0605c94ed GC #if 0'd calls to releasing and acquiring the old style giant kernel
lock.
2001-05-29 23:35:48 +00:00
Ruslan Ermilov
99d300a1ec - FDESC, FIFO, NULL, PORTAL, PROC, UMAP and UNION file
systems were repo-copied from sys/miscfs to sys/fs.

- Renamed the following file systems and their modules:
  fdesc -> fdescfs, portal -> portalfs, union -> unionfs.

- Renamed corresponding kernel options:
  FDESC -> FDESCFS, PORTAL -> PORTALFS, UNION -> UNIONFS.

- Install header files for the above file systems.

- Removed bogus -I${.CURDIR}/../../sys CFLAGS from userland
  Makefiles.
2001-05-23 09:42:29 +00:00
Andrew Gallatin
2ee7c91e2e catch these files up to their i386 neighbors to make alpha boot
prior to the vm_mtx
2001-05-21 16:04:24 +00:00
David E. O'Brien
02c629d468 Make _BSD_TIME_T_ (time_t) an int' rather than long'. This will help
flag errors where programmers assume time_t is a long, which it is not on
64-bit platforms.

Submitted by:	bde
2001-05-18 01:43:25 +00:00
David E. O'Brien
ef76752043 Style changes -- revert ordering to mostly two revs ago.
Embellish some comments, fix tab'ing.

Requested by:	bde
2001-05-18 01:40:40 +00:00
David E. O'Brien
0dfc89c188 Consistently define the rune types.
Follow NetBSD's lead and add a _BSD_MBSTATE_T_ type.
2001-05-16 22:32:44 +00:00
David E. O'Brien
1123bf8862 Move the int typedefs to the top so they can be used in defining other types.
Ensure every platform has __offsetof.
Make multiple inclusion detection consistent with other
  <platform>/include/*.h files.
2001-05-16 22:21:43 +00:00
John Baldwin
f0ba29575d Lock the procfs functions for doing a single step and reading/writing
registers better.  Hold sched_lock not only for checking the flag but
also while performing the actual operation to ensure the process doesn't
get swapped out by another CPU while we the operation is being performed.
2001-05-16 00:47:27 +00:00
John Baldwin
f2909e6cd8 Trim lots of stuff that is now in MI code along with MD alpha code. 2001-05-10 17:58:35 +00:00
Mark Murray
fb919e4d5a Undo part of the tangle of having sys/lock.h and sys/mutex.h included in
other "system" header files.

Also help the deprecation of lockmgr.h by making it a sub-include of
sys/lock.h and removing sys/lockmgr.h form kernel .c files.

Sort sys/*.h includes where possible in affected files.

OK'ed by:	bde (with reservations)
2001-05-01 08:13:21 +00:00
John Baldwin
6caa8a1501 Overhaul of the SMP code. Several portions of the SMP kernel support have
been made machine independent and various other adjustments have been made
to support Alpha SMP.

- It splits the per-process portions of hardclock() and statclock() off
  into hardclock_process() and statclock_process() respectively.  hardclock()
  and statclock() call the *_process() functions for the current process so
  that UP systems will run as before.  For SMP systems, it is simply necessary
  to ensure that all other processors execute the *_process() functions when the
  main clock functions are triggered on one CPU by an interrupt.  For the alpha
  4100, clock interrupts are delievered in a staggered broadcast fashion, so
  we simply call hardclock/statclock on the boot CPU and call the *_process()
  functions on the secondaries.  For x86, we call statclock and hardclock as
  usual and then call forward_hardclock/statclock in the MD code to send an IPI
  to cause the AP's to execute forwared_hardclock/statclock which then call the
  *_process() functions.
- forward_signal() and forward_roundrobin() have been reworked to be MI and to
  involve less hackery.  Now the cpu doing the forward sets any flags, etc. and
  sends a very simple IPI_AST to the other cpu(s).  AST IPIs now just basically
  return so that they can execute ast() and don't bother with setting the
  astpending or needresched flags themselves.  This also removes the loop in
  forward_signal() as sched_lock closes the race condition that the loop worked
  around.
- need_resched(), resched_wanted() and clear_resched() have been changed to take
  a process to act on rather than assuming curproc so that they can be used to
  implement forward_roundrobin() as described above.
- Various other SMP variables have been moved to a MI subr_smp.c and a new
  header sys/smp.h declares MI SMP variables and API's.   The IPI API's from
  machine/ipl.h have moved to machine/smp.h which is included by sys/smp.h.
- The globaldata_register() and globaldata_find() functions as well as the
  SLIST of globaldata structures has become MI and moved into subr_smp.c.
  Also, the globaldata list is only available if SMP support is compiled in.

Reviewed by:	jake, peter
Looked over by:	eivind
2001-04-27 19:28:25 +00:00
John Baldwin
bf4c03d0e9 Initialize p_md.md_kernnest to 1 for newly fork'd processes since they
start off in the kernel.
2001-04-26 23:52:40 +00:00
John Baldwin
9e438eb4f5 Add a new field 'md_kernnest' to the alpha machine dependent process
structure.  This field keeps track of how many levels deep we are nested
into the kernel.  The nesting level is bumped at the start of a trap,
interrupt, syscall, or exception and is decremented on return.  This is
used to detect the case when the kernel is returning back to a kernel
context in exception_return().  If we are returning to the kernel we need
to update the globaldata pointer register saved in the stack frame in case
we have switched CPU's between taking the initial interrupt that saved the
frame and returning.  If we don't do this fixup it is possible for a CPU to
use the wrong per-cpu data.  On UP systems this is not a problem, so the
code is conditional on SMP.

A count was used instead of simply checking the process status register in
the frame during exception_return() since there are critical sections at
the very start and end of a trap, exception, or interrupt from userland in
which we could trash the t7 register being used in userland.  The counter
is incremented after adn before these critical sections respectively so
that we will not overwrite the saved t7 register if we are interrupted
during one of these critical sections.
2001-04-24 21:06:53 +00:00
Matt Jacob
ac60aa4908 Fix includes so it compiles again. 2001-04-23 18:08:54 +00:00
John Baldwin
08b0f4f908 Convert the protection of hte i8254 from critical_enter/exit like it is
on the x86.
2001-04-18 21:47:48 +00:00
John Baldwin
abd9053ee4 Blow away the panic mutex in favor of using a single atomic_cmpset() on a
panic_cpu shared variable.  I used a simple atomic operation here instead
of a spin lock as it seemed to be excessive overhead.  Also, this can avoid
recursive panics if, for example, witness is broken.
2001-04-17 04:18:08 +00:00
John Baldwin
192846463a Rework the witness code to work with sx locks as well as mutexes.
- Introduce lock classes and lock objects.  Each lock class specifies a
  name and set of flags (or properties) shared by all locks of a given
  type.  Currently there are three lock classes: spin mutexes, sleep
  mutexes, and sx locks.  A lock object specifies properties of an
  additional lock along with a lock name and all of the extra stuff needed
  to make witness work with a given lock.  This abstract lock stuff is
  defined in sys/lock.h.  The lockmgr constants, types, and prototypes have
  been moved to sys/lockmgr.h.  For temporary backwards compatability,
  sys/lock.h includes sys/lockmgr.h.
- Replace proc->p_spinlocks with a per-CPU list, PCPU(spinlocks), of spin
  locks held.  By making this per-cpu, we do not have to jump through
  magic hoops to deal with sched_lock changing ownership during context
  switches.
- Replace proc->p_heldmtx, formerly a list of held sleep mutexes, with
  proc->p_sleeplocks, which is a list of held sleep locks including sleep
  mutexes and sx locks.
- Add helper macros for logging lock events via the KTR_LOCK KTR logging
  level so that the log messages are consistent.
- Add some new flags that can be passed to mtx_init():
  - MTX_NOWITNESS - specifies that this lock should be ignored by witness.
    This is used for the mutex that blocks a sx lock for example.
  - MTX_QUIET - this is not new, but you can pass this to mtx_init() now
    and no events will be logged for this lock, so that one doesn't have
    to change all the individual mtx_lock/unlock() operations.
- All lock objects maintain an initialized flag.  Use this flag to export
  a mtx_initialized() macro that can be safely called from drivers.  Also,
  we on longer walk the all_mtx list if MUTEX_DEBUG is defined as witness
  performs the corresponding checks using the initialized flag.
- The lock order reversal messages have been improved to output slightly
  more accurate file and line numbers.
2001-03-28 09:03:24 +00:00
John Baldwin
6283b7d01b - Switch from using save/disable/restore_intr to using critical_enter/exit
and change the u_int mtx_saveintr member of struct mtx to a critical_t
  mtx_savecrit.
- On the alpha we no longer need a custom _get_spin_lock() macro to avoid
  an extra PAL call, so remove it.
- Partially fix using mutexes with WITNESS in modules.  Change all the
  _mtx_{un,}lock_{spin,}_flags() macros to accept explicit file and line
  parameters and rename them to use a prefix of two underscores.  Inside
  of kern_mutex.c, generate wrapper functions for
  _mtx_{un,}lock_{spin,}_flags() (only using a prefix of one underscore)
  that are called from modules.  The macros mtx_{un,}lock_{spin,}_flags()
  are mapped to the __mtx_* macros inside of the kernel to inline the
  usual case of mutex operations and map to the internal _mtx_* functions
  in the module case so that modules will use WITNESS and KTR logging if
  the kernel is compiled with support for it.
2001-03-28 02:40:47 +00:00
John Baldwin
82da2f64b3 - Include <machine/prom.h> to get the prototype for prom_halt().
- If there is no gdb device, just return without trying to return any
  value since gdb_handle_exception() returns void.
- When calling prom_halt(), pass in a value telling it to actually halt
  and not to randomly choose whether or not to halt or reboot depending on
  whatever value happened to be in a0 when the call was made.
2001-03-28 01:54:06 +00:00
Hajimu UMEMOTO
8b625cb701 Unbreak build on alpha.
- Move in_port_t to sys/types.h.
  - Nuke in_addr_t from each endian.h.

Reported by:	jhb
2001-03-24 15:17:27 +00:00
Peter Wemm
6eb39ac8fc Use a generic implementation of the Fowler/Noll/Vo hash (FNV hash).
Make the name cache hash as well as the nfsnode hash use it.

As a special tweak, create an unsigned version of register_t.  This allows
us to use a special tweak for the 64 bit versions that significantly
speeds up the i386 version (ie: int64 XOR int64 is slower than int64
XOR int32).

The code layout is a little strange for the string function, but I was
able to get between 5 to 10% improvement over the original version I
started with. The layout affects gcc code generation choices and this way
was fastest on x86 and alpha.

Note that 'CPUTYPE=p3' etc makes a fair difference to this.  It is
around 45% faster with -march=pentiumpro on a p6 cpu.
2001-03-17 09:31:06 +00:00
Andrew Gallatin
64007795de remove bogus check -- for kernel threads we fork off of proc0, not curproc
This was causing panics when modules which create kthreads were loaded
after boot.

pointed out by: jake, jhb
2001-03-15 02:32:26 +00:00
John Baldwin
5db078a9be Fix mtx_legal2block. The only time that it is bad to block on a mutex is
if we hold a spin mutex, since we can trivially get into deadlocks if we
start switching out of processes that hold spinlocks.  Checking to see if
interrupts were disabled was a sort of cheap way of doing this since most
of the time interrupts were only disabled when holding a spin lock.  At
least on the i386.  To fix this properly, use a per-process counter
p_spinlocks that counts the number of spin locks currently held, and
instead of checking to see if interrupts are disabled in the witness code,
check to see if we hold any spin locks.  Since child processes always
start up with the sched lock magically held in fork_exit(), we initialize
p_spinlocks to 1 for child processes.  Note that proc0 doesn't go through
fork_exit(), so it starts with no spin locks held.

Consulting from:	cp
2001-03-09 07:24:17 +00:00
John Baldwin
ff655691d8 Use the proc lock to protect p_pptr when waking up our parent in cpu_exit()
and remove the mpfixme() message that is now fixed.
2001-03-07 03:20:15 +00:00
John Baldwin
938f15c7c4 Rename switch_trampoline() to fork_trampoline() on the alpha and ia64.
Suggested by:	dfr
2001-02-22 16:56:53 +00:00
John Baldwin
0246af0995 GC unused and now obsolete assertion macros. 2001-02-22 15:45:49 +00:00
John Baldwin
5813dc03bd - Don't call clear_resched() in userret(), instead, clear the resched flag
in mi_switch() just before calling cpu_switch() so that the first switch
  after a resched request will satisfy the request.
- While I'm at it, move a few things into mi_switch() and out of
  cpu_switch(), specifically set the p_oncpu and p_lastcpu members of
  proc in mi_switch(), and handle the sched_lock state change across a
  context switch in mi_switch().
- Since cpu_switch() no longer handles the sched_lock state change, we
  have to setup an initial state for sched_lock in fork_exit() before we
  release it.
2001-02-20 05:26:15 +00:00
Hajimu UMEMOTO
e335205699 Correct disordering which is corresponding to bde's fix to
i386/include/ansi.h.
2001-02-17 14:51:11 +00:00
Hajimu UMEMOTO
ad9fdc8f4d Correct 2nd argument of getnameinfo(3) to socklen_t.
Reviewed by:	itojun
2001-02-15 10:35:55 +00:00
Mark Murray
d888fc4e73 RIP <machine/lock.h>.
Some things needed bits of <i386/include/lock.h> - cy.c now has its
own (only) copy of the COM_(UN)LOCK() macros, and IMASK_(UN)LOCK()
has been moved to <i386/include/apic.h> (AKA <machine/apic.h>).
Reviewed by:	jhb
2001-02-11 10:44:09 +00:00
John Baldwin
142ba5f3d7 - Make astpending and need_resched process attributes rather than CPU
attributes.  This is needed for AST's to be properly posted in a preemptive
  kernel.  They are backed by two new flags in p_sflag: PS_ASTPENDING and
  PS_NEEDRESCHED.  They are still accesssed by their old macros:
  aston(), astoff(), etc.  For completeness, an astpending() macro has been
  added to check for a pending AST, and clear_resched() has been added to
  clear need_resched().
- Rename syscall2() on the x86 back to syscall() to be consistent with
  other architectures.
2001-02-10 02:20:34 +00:00
John Baldwin
e109e2b4cd Add a macro mtx_intr_enable() to alter a spin lock such that interrupts
will be enabled when it is released.
2001-02-10 02:15:18 +00:00
Bosko Milekic
9ed346bab0 Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:

mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)

similarily, for releasing a lock, we now have:

mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.

The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.

Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:

MTX_QUIET and MTX_NOSWITCH

The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:

mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.

Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.

Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.

Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.

Finally, caught up to the interface changes in all sys code.

Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
Doug Rabson
c586bc8e57 * Move exception_return to exception.s which is a more logical home for it.
* Optimise the return path for syscalls so that they only restore a minimal
  set of registers instead of performing a full exception_return.

A new flag in the trapframe indicates that the frame only holds partial
state. When it is necessary to perform a full state restore (e.g. after an
execve or signal), the flag is cleared to force a full restore.
2001-01-31 11:17:00 +00:00
John Baldwin
a0346459f1 Update some comments, s0 in the pcb of a child returning from fork1() is
now passed in as a0 to fork_exit() and and s2 is passed in as a1.
2001-01-26 23:32:38 +00:00