Commit Graph

42 Commits

Author SHA1 Message Date
Peter Wemm
664a31e496 Change #ifdef KERNEL to #ifdef _KERNEL in the public headers. "KERNEL"
is an application space macro and the applications are supposed to be free
to use it as they please (but cannot).  This is consistant with the other
BSD's who made this change quite some time ago.  More commits to come.
1999-12-29 04:46:21 +00:00
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Bruce Evans
eec2e836e9 Go back to the old (icu.s rev.1.7 1993) way of keeping the AST-pending
bit separate from ipending, since this is simpler and/or necessary for
SMP and may even be better for UP.

Reviewed by:	alc, luoqi, tegge
1999-07-10 15:28:01 +00:00
Dmitrij Tejblum
0666dbe1cf Moved cpu_set_fork_handler's prototype from <machine/cpu.h> to <sys/proc.h>.
Suggested by:	bde
1999-04-23 20:22:44 +00:00
Bruce Evans
79a2501238 Added a hopefully-machine-independent macro for determining if a
reschedule is pending.
1999-02-02 09:08:23 +00:00
Matthew Dillon
3cfc69e6c2 More -Wall / -Wcast-qual cleanup. Also, EXEC_SET can't use
C_DECLARE_MODULE due to the linker_file_sysinit() function
    making modifications to the data.
1999-01-29 08:36:45 +00:00
KATO Takenori
582e52862a - hw.machine_arch returns cpu architecture type.
- moved definition of MACHINE_ARCH from cpu.h to parm.h as alpha.
- Added definitions of _MACHINE and _MACHINE_ARCH.
- Added hw.ispc98. The hw.ispc98 is 1 in PC98 kernel and is 0 in
  IBM-PC kernel.

Discussed with:	John Birrell <jb@FreeBSD.ORG>
1998-08-31 08:41:58 +00:00
Bruce Evans
7f47cf2f4a Don't include <machine/cputypes.h> or declare cputype/class interfaces
in <machine/cpu.h>.  Moved the declarations to <machine/cputypes.h>.
Fixed style bugs in the moved code.  Fixed everything that depended on
the nested include.  Don't include <machine/cpu.h> (in the changed files)
unless something in it is used directly.
1997-10-28 11:43:57 +00:00
Bruce Evans
4090154b9e Moved declaration of etext from <machine/md_var.h> to <machine/cpu.h>
and fixed everything that dependended on it being declared in the old
place.  It is used in "machine-independent" code in subr_prof.c.

Moved declaration of btext from subr_prof.c to <machine/cpu.h>.  It
is machine-dependent.
1997-10-27 17:23:18 +00:00
KATO Takenori
662f9a6987 Move MACHINE_ARCH definition from <machine/param.h> to <machine/cpu.h>.
Submitted by:	Bruce Evans <bde@zeta.org.au>
1997-08-30 02:52:04 +00:00
Philippe Charnier
40d5099441 Revert my previous commit about using CS_SECURE macro.
Requested by:	Bruce.
1997-08-21 06:33:04 +00:00
Philippe Charnier
15f3549108 Use CS_SECURE macro.
Reviewed by:	John Dyson
1997-08-18 06:58:59 +00:00
John Dyson
48a09cf276 VM86 kernel support.
Work done by BSDI, Jonathan Lemon <jlemon@americantv.com>,
	Mike Smith <msmith@gsoft.com.au>, Sean Eric Fagan <sef@kithrup.com>,
	and probably alot of others.
Submitted by:	Jnathan Lemon <jlemon@americantv.com>
1997-08-09 00:04:06 +00:00
Peter Wemm
a2a1c95c10 The biggie: Get rid of the UPAGES from the top of the per-process address
space. (!)

Have each process use the kernel stack and pcb in the kvm space.  Since
the stacks are at a different address, we cannot copy the stack at fork()
and allow the child to return up through the function call tree to return
to user mode - create a new execution context and have the new process
begin executing from cpu_switch() and go to user mode directly.
In theory this should speed up fork a bit.

Context switch the tss_esp0 pointer in the common tss.  This is a lot
simpler since than swithching the gdt[GPROC0_SEL].sd.sd_base pointer
to each process's tss since the esp0 pointer is a 32 bit pointer, and the
sd_base setting is split into three different bit sections at non-aligned
boundaries and requires a lot of twiddling to reset.

The 8K of memory at the top of the process space is now empty, and unmapped
(and unmappable, it's higher than VM_MAXUSER_ADDRESS).

Simplity the pmap code to manage process contexts, we no longer have to
double map the UPAGES, this simplifies and should measuably speed up fork().

The following parts came from John Dyson:

Set PG_G on the UPAGES that are now in kernel context, and invalidate
them when swapping them out.

Move the upages object (upobj) from the vmspace to the proc structure.

Now that the UPAGES (pcb and kernel stack) are out of user space, make
rfork(..RFMEM..) do what was intended by sharing the vmspace
entirely via reference counting rather than simply inheriting the mappings.
1997-04-07 07:16:06 +00:00
Peter Wemm
6875d25465 Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are not
ready for it yet.
1997-02-22 09:48:43 +00:00
KATO Takenori
d5605f2a31 Deleted i386_cpus[]. i386_cpus[] is a static variable in identcpu.c.
Found-by: lint
1997-02-02 10:43:35 +00:00
Jordan K. Hubbard
1130b656e5 Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore.  This update would have been
insane otherwise.
1997-01-14 07:20:47 +00:00
Bruce Evans
79df6d8597 trap.c:
Fixed profiling of system times.  It was pre-4.4Lite and didn't support
statclocks.  System times were too small by a factor of 8.

Handle deferred profiling ticks the 4.4Lite way: use addupc_task() instead
of addupc().  Call addupc_task() directly instead of using the ADDUPC()
macro.

Removed vestigial support for PROFTIMER.

switch.s:
Removed addupc().

resourcevar.h:
Removed ADDUPC() and declarations of addupc().

cpu.h:
Updated a comment.  i386's never were tahoe's, and the deferred profiling
tick became (possibly) multiple ticks in 4.4Lite.

Obtained from:	mostly from NetBSD
1996-06-25 20:02:16 +00:00
Bruce Evans
73dc05d67c Moved declaration of bootverbose to a better place. It isn't
machine-dependent.

Moved declaration of cpu_fork() to a better place.  Only its
implementation is machine-dependent.
1996-04-07 16:44:28 +00:00
Andrey A. Chernov
fe0d5f43c5 Add wall_cmos_clock sysctl variable, needed to manage adjkerntz even for
UTC cmos clocks (needed for Local Timezone FSes)
1996-04-05 03:36:31 +00:00
Bruce Evans
78966e20d9 Parenthesized macros.
Fixed munged tabs.
1996-03-29 14:14:07 +00:00
Poul-Henning Kamp
7a2dada545 Make the bootinfo structure visible from sysctl.
This can be used in libdisk to guess a better bios-geometry.
1995-07-16 10:33:38 +00:00
David Greenman
85eaa94715 Correct the definition for the (unused) cpu_setstack(). 1995-05-04 07:50:06 +00:00
Bruce Evans
91290462f6 Disable CLKF_BASEPRI() again. I forgot to edit an unwanted change out of
the diffs for the previous commit.
1994-12-03 10:18:24 +00:00
Bruce Evans
b39b673d37 i386/exception.s,
Keep track of interrupt nesting level.  It is normally 0
	for syscalls and traps, but is fudged to 1 for their exit
	processing in case they metamorphose into an interrupt
	handler.

i386/genassym.c;
	Remove support for the obsolete pcb_iml and pcb_cmap2.

	Add support for pcb_inl.

i386/swtch.s:
	Fudge the interrupt nesting level across context switches and in
	the idle loop so that the work for preemptive context switches
	gets counted as interrupt time, the work for voluntary context
	switches gets counted mostly as system time (the part when
	curproc == 0 gets counted as interrupt time), and only truly idle
	time gets counted as idle time.

	Remove obsolete support (commented out and otherwise) for pcb_iml.

	Load curpcb just before curproc instead of just after so that
	curpcb is always valid if curproc is.  A few more changes like
	this may fix tracing through context switches.

	Remove obsolete function swtch_to_inactive().

include/cpu.h:
	Use the new interrupt nesting level variable to implement a
	non-fake CLF_INTR() so that accounting for the interrupt state
	works.

	You can use top, iostat or (best) an up to date systat to see
	interrupt overheads.  I see the expected huge interrupt overheads
	for ISA devices (on a 486DX/33, about 55% for an IDE drive
	transferring 1250K/sec and the same for a WD8013EBT network card
	transferring 1100K/sec).  The huge interrupt overheads for serial
	devices are unfortunately normally invisible.

include/pcb.h:
	Remove the obsolete pcb_iml and pcb_cmap2.  Replace them by
	padding to preserve binary compatibility.

	Use part of the new padding for pcb_inl.

isa/icu.s:
isa/vector.s:
	Keep track of interrupt nesting level.
1994-12-03 10:03:19 +00:00
Poul-Henning Kamp
0a6a925d04 Declare "extern int bootverbose", so that device-drivers and others
easily can find it.
1994-11-26 09:27:58 +00:00
Bruce Evans
c342b9faa3 Disable the direct call from hardclock() to softclock(). Support
for it is incomplete and buggy.  There is no problem unless Xintr0()
is reentered or should be reentered, but high clock interrupt
frequencies for pcaudio cause Xintr0() to be reentered (or clock
ticks to be lost when Xintr0() should have been reentered but
wasn't), and we lose little by delaying the call to softclock().

Move declarations related to the clock driver to clock.h.

Move declarations related to the npx driver to npx.h.

Clean up the remaining declarations.
1994-11-05 22:44:34 +00:00
Andrey A. Chernov
37b28ca421 Remove CPU_COLORDISP, GIO_COLOR now exists 1994-10-18 03:42:18 +00:00
Andrey A. Chernov
9d40918f0f CPU_COLORDISP sysctl added for console display type 1994-10-15 21:18:11 +00:00
Poul-Henning Kamp
a12dee4de7 Cosmetics. Added a prototype. 1994-10-10 01:06:48 +00:00
Poul-Henning Kamp
50a1a05445 Added prototypes. 1994-10-08 22:21:34 +00:00
Andrey A. Chernov
f80d8a2e88 CPU_DISRTCSET added to disable resettodr(), needed in adjkerntz -i,
per Bruce suggestion
1994-10-04 18:25:51 +00:00
Andrey A. Chernov
e79033e4cf resettodr() now exists, enable it 1994-09-20 00:32:40 +00:00
Bruce Evans
e4b7e53da8 Clean up #includes. <machine/spl.h> has to be included by almost everything
in case an spl inline is used, so this is not the place to include it.

Uniformize idempotency #ifdef.
1994-09-18 21:37:56 +00:00
Andrey A. Chernov
dd067f0809 CPU_ADJKERNTZ added for resettodtr() 1994-09-16 01:05:24 +00:00
Garrett Wollman
f540b1065a Change all #includes to follow the current Berkeley style. Some of these
``changes'' are actually not changes at all, but CVS sometimes has trouble
telling the difference.

This also includes support for second-directory compiles.  This is not
quite complete yet, as `config' doesn't yet do the right thing.  You can
still make it work trivially, however, by doing the following:

rm /sys/compile
mkdir /usr/obj/sys/compile
ln -s M-. /sys/compile
cd /sys/i386/conf
config MYKERNEL
cd ../../compile/MYKERNEL
ln -s /sys @
rm machine
ln -s @/i386/include machine
make depend
make
1994-08-13 03:50:34 +00:00
Rodney W. Grimes
26f9a76710 The big 4.4BSD Lite to FreeBSD 2.0.0 (Development) patch.
Reviewed by:	Rodney W. Grimes
Submitted by:	John Dyson and David Greenman
1994-05-25 09:21:21 +00:00
David Greenman
d230622648 New interrupt code from Bruce Evans. In additional to Bruce's attached
list of changes, I've made the following additional changes:

1) i386/include/ipl.h renamed to spl.h as the name conflicts with the
   file of the same name in i386/isa/ipl.h.
2) changed all use of *mask (i.e. netmask, biomask, ttymask, etc) to
   *_imask (net_imask, etc).
3) changed vestige of splnet use in if_is to splimp.
4) got rid of "impmask" completely (Bruce had gotten rid of netmask),
   and are now using net_imask instead.
5) dozens of minor cruft to glue in Bruce's changes.

   These require changes I made to config(8) as well, and thus it must
be rebuilt.

-DG

from Bruce Evans:

sio:
	o No diff is supplied.  Remove the define of setsofttty().  I hope
	  that is enough.

*.s:
	o i386/isa/debug.h no longer exists.  The event counters became too
	  much trouble to maintain.  All function call entry and exception
	  entry counters can be recovered by using profiling kernel (the new
	  profiling supports all entry points; however, it is too slow to
	  leave enabled all the time; it also).  Only BDBTRAP() from debug.h
	  is now used.  That is moved to exception.s.  It might be worth
	  preserving SHOW_BITS() and calling it from _mcount() (if enabled).
	o T_ASTFLT is now only set just before calling trap().
	o All exception handlers set SWI_AST_MASK in cpl as soon as possible
	  after entry and arrange for _doreti to restore it atomically with
	  exiting.  It is not possible to set it atomically with entering
	  the kernel, so it must be checked against the user mode bits in
	  the trap frame before committing to using it.  There is no place
	  to store the old value of cpl for syscalls or traps, so there are
	  some complications restoring it.

Profiling stuff (mostly in *.s):
	o Changes to kern/subr_mcount.c, gcc and gprof are not supplied yet.
	o All interesting labels `foo' are renamed `_foo' and all
	  uninteresting labels `_bar' are renamed `bar'.  A small change
	  to gprof allows ignoring labels not starting with underscores.
	o MCOUNT_LABEL() is to provide names for counters for times spent
	  in exception handlers.
	o FAKE_MCOUNT() is a version of MCOUNT() suitable for exception
	  handlers.  Its arg is the pc where the exception occurred.  The
	  new mcount() pretends that this was a call from that pc to a
	  suitable MCOUNT_LABEL().
	o MEXITCOUNT is to turn off any timer started by MCOUNT().

/usr/src/sys/i386/i386/exception.s:
	o The non-BDB BPTTRAP() macros were doing a sti even when interrupts
	  were disabled when the trap occurred.  The sti (fixed) sti is
	  actually a no-op unless you have my changes to machdep.c that make
	  the debugger trap gates interrupt gates, but fixing that would
	  make the ifdefs messier.  ddb seems to be unharmed by both
	  interrupts always disabled and always enabled (I had the branch in
	  the fix back to front for some time :-().
	o There is no known pushal bug.
	o tf_err can be left as garbage for syscalls.

/usr/src/sys/i386/i386/locore.s:
	o Fix and update BDE_DEBUGGER support.
	o ENTRY(btext) before initialization was dangerous.
	o Warm boot shot was longer than intended.

/usr/src/sys/i386/i386/machdep.c:
	o DON'T APPLY ALL OF THIS DIFF.  It's what I'm using, but may require
	  other changes.
	  Use the following:
		o Remove aston() and setsoftclock().
	  Maybe use the following:
		o No netisr.h.
		o Spelling fix.
		o Delay to read the Rebooting message.
		o Fix for vm system unmapping a reduced area of memory
		  after bounds_check_with_label() reduces the size of
		  a physical i/o for a partition boundary.  A similar
		  fix is required in kern_physio.c.
		o Correct use of __CONCAT.  It never worked here for non-
		  ANSI cpp's.  Is it time to drop support for non-ANSI?
		o gdt_segs init.  0xffffffffUL is bogus because ssd_limit
		  is not 32 bits.  The replacement may have the same
		  value :-), but is more natural.
		o physmem was one page too low.  Confusing variable names.
	  Don't use the following:
		o Better numbers of buffers.  Each 8K page requires up to
		  16 buffer headers.  On my system, this results in 5576
		  buffers containing [up to] 2854912 bytes of memory.
		  The usual allocation of about 384 buffers only holds
		  192K of disk if you use it on an fs with a block size
		  of 512.
		o gdt changes for bdb.
		o *TGT -> *IDT changes for bdb.
		o #ifdefed changes for bdb.

/usr/src/sys/i386/i386/microtime.s:
	o Use the correct asm macros.  I think asm.h was copied from Mach
	  just for microtime and isn't used now.  It certainly doesn't
	  belong in <sys>.  Various macros are also duplicated in
	  sys/i386/boot.h and libc/i386/*.h.
	o Don't switch to and from the IRR; it is guaranteed to be selected
	  (default after ICU init and explicitly selected in isa.c too, and
	  never changed until the old microtime clobbered it).

/usr/src/sys/i386/i386/support.s:
	o Non-essential changes (none related to spls or profiling).
	o Removed slow loads of %gs again.  The LDT support may require
	  not relying on %gs, but loading it is not the way to fix it!
	  Some places (copyin ...) forgot to load it.  Loading it clobbers
	  the user %gs.  trap() still loads it after certain types of
	  faults so that fuword() etc can rely on it without loading it
	  explicitly.  Exception handlers don't restore it.  If we want
	  to preserve the user %gs, then the fastest method is to not
	  touch it except for context switches.  Comparing with
	  VM_MAXUSER_ADDRESS and branching takes only 2 or 4 cycles on
	  a 486, while loading %gs takes 9 cycles and using it takes
	  another.
	o Fixed a signed branch to unsigned.

/usr/src/sys/i386/i386/swtch.s:
	o Move spl0() outside of idle loop.
	o Remove cli/sti from idle loop.  sw1 does a cli, and in the
	  unlikely event of an interrupt occurring and whichqs becoming
	  zero, sw1 will just jump back to _idle.
	o There's no spl0() function in asm any more, so use splz().
	o swtch() doesn't need to be superaligned, at least with the
	  new mcounting.
	o Fixed a signed branch to unsigned.
	o Removed astoff().

/usr/src/sys/i386/i386/trap.c:
	o The decentralized extern decls were inconsistent, of course.
	o Fixed typo MATH_EMULTATE in comments. */
	o Removed unused variables.
	o Old netmask is now impmask; print it instead.  Perhaps we
	  should print some of the new masks.
	o BTW, trap() should not print anything for normal debugger
	  traps.

/usr/src/sys/i386/include/asmacros.h:
	o DON'T APPLY ALL OF THIS DIFF.  Just use some of the null macros
	  as necessary.

/usr/src/sys/i386/include/cpu.h:
	o CLKF_BASEPRI() changes since cpl == SWI_AST_MASK is now normal
	  while the kernel is running.
	o Don't use var++ to set boolean variables.  It fails after a mere
	  4G times :-) and is slower than storing a constant on [3-4]86s.

/usr/src/sys/i386/include/cpufunc.h:
	o DON'T APPLY ALL OF THIS DIFF.  You need mainly the include of
	  <machine/ipl.h>.  Unfortunately, <machine/ipl.h> is needed by
	  almost everything for the inlines.

/usr/src/sys/i386/include/ipl.h:
	o New file.  Defines spl inlines and SWI macros and declares most
	  variables related to hard and soft interrupt masks.

/usr/src/sys/i386/isa/icu.h:
	o Moved definitions to <machine/ipl.h>

/usr/src/sys/i386/isa/icu.s:
	o Software interrupts (SWIs) and delayed hardware interrupts (HWIs)
	  are now handled uniformally, and dispatching them from splx() is
	  more like dispatching them from _doreti.  The dispatcher is
	  essentially *(handler[ffs(ipending & ~cpl)]().
	o More care (not quite enough) is taken to avoid unbounded nesting
	  of interrupts.
	o The interface to softclock() is changed so that a trap frame is
	  not required.
	o Fast interrupt handlers are now handled more uniformally.
	  Configuration is still too early (new handlers would require
	  bits in <machine/ipl.h> and functions to vector.s).
	o splnnn() and splx() are no longer here; they are inline functions
	  (could be macros for other compilers).  splz() is the nontrivial
	  part of the old splx().

/usr/src/sys/i386/isa/ipl.h
	o New file.  Supposed to have only bus-dependent stuff.  Perhaps
	  the h/w masks should be declared here.

/usr/src/sys/i386/isa/isa.c:
	o DON'T APPLY ALL OF THIS DIFF.  You need only things involving
	  *mask and *MASK and comments about them.  netmask is now a pure
	  software mask.  It works like the softclock mask.

/usr/src/sys/i386/isa/vector.s:
	o Reorganize AUTO_EOI* macros.
	o Option FAST_INTR_HANDLER_USERS_ES for people who don't trust
	  fastintr handlers.
	o fastintr handlers need to metamorphose into ordinary interrupt
	  handlers if their SWI bit has become set.  Previously, sio had
	  unintended latency for handling output completions and input
	  of SLIP framing characters because this was not done.

/usr/src/sys/net/netisr.h:
	o The machine-dependent stuff is now imported from <machine/ipl.h>.

/usr/src/sys/sys/systm.h
	o DON'T APPLY ALL OF THIS DIFF.  You need mainly the different
	  splx() prototype.  The spl*() prototypes are duplicated as
	  inlines in <machine/ipl.h> but they need to be duplicated here
	  in case there are no inlines.  I sent systm.h and cpufunc.h
	  to Garrett.  We agree that spl0 should be replaced by splnone
	  and not the other way around like I've done.

/usr/src/sys/kern/kern_clock.c
	o splsoftclock() now lowers cpl so the direct call to softclock()
	  works as intended.
	o softclock() interface changed to avoid passing the whole frame
	  (some machines may need another change for profile_tick()).
	o profiling renamed _profiling to avoid ANSI namespace pollution.
	  (I had to improve the mcount() interface and may as well fix it.)
	  The GUPROF variant doesn't actually reference profiling here,
	  but the 'U' in GUPROF should mean to select the microtimer
	  mcount() and not change the interface.
1994-04-02 07:00:53 +00:00
Garrett Wollman
6e393973f5 Made all header files idempotent and moved incorrect common data from
headers into a related source file.  Added cons.h as first step towards
moving i386/i386/cons.h to machine/cons.h where it belongs.
1993-11-07 17:43:17 +00:00
Rodney W. Grimes
09f07fb057 All:
Remove patch kit headers, and add $Id$
	This is mostly to align some more code with NetBSD.

cpu.h:
	Remove the old function vs. include configuration stuff that was
	ifdefed out when we went to inline functions.
	Remove the define of resettodr that made it a nop, there is
	already a function that makes it a nop, no need to #define one.
	Remove the #defines of processor types, they are now defined
	in cputypes.h, #include that file.
	Add struct cpu_nameclass for support of cpu types.

frame.h:
	include sys/signal.h, it will be needed in the future.
	put the sigframe structure here that was in machdep.c

pcb.h:
	Add multiple inclusion protection.
	Add pcb_ldt and pcb_ldt_len to pcb structure, this is for the
	user mode ldt.
1993-10-08 20:51:00 +00:00
David Greenman
269312019a * Applied fixes from Bruce Evans to fix COW bugs, >1MB kernel loading,
profiling, and various protection checks that cause security holes
  and system crashes.
* Changed min/max/bcmp/ffs/strlen to be static inline functions
  - included from cpufunc.h in via systm.h. This change
  improves performance in many parts of the kernel - up to 5% in the
  networking layer alone. Note that this requires systm.h to be included
  in any file that uses these functions otherwise it won't be able to
  find them during the load.
* Fixed incorrect call to splx() in if_is.c
* Fixed bogus variable assignment to splx() in if_ed.c
1993-07-27 10:52:31 +00:00
Rodney W. Grimes
5b81b6b301 Initial import, 0.1 + pk 0.2.4-B1 1993-06-12 14:58:17 +00:00