Commit graph

783 commits

Author SHA1 Message Date
Matt Jacob 9b63136347 Add support for the LSI-Logic Fusion/MP architecture.
This is an architecture that present a thing message passing interface
to the OS. You can query as to how many ports and what kind are attached
and enable them and so on.

A less grand view is that this is just another way to package SCSI (SPI or
FC) and FC-IP into a one-driver interface set.

This driver support the following hardware:

LSI FC909:	Single channel, 1Gbps, Fibre Channel (FC-SCSI only)
LSI FC929:	Dual Channel, 1-2Gbps, Fibre Channel (FC-SCSI only)
LSI 53c1020:	Single Channel, Ultra4 (320M) (Untested)
LSI 53c1030:	Dual Channel, Ultra4 (320M)

Currently it's in fair shape, but expect a lot of changes over the
next few weeks as it stabilizes.

Credits:

The driver is mostly from some folks from Jeff Roberson's company- I've
been slowly migrating it to broader support that I it came to me as.

The hardware used in developing support came from:

	FC909: LSI-Logic, Advansys (now Connetix)
	FC929: LSI-Logic
	53c1030: Antares Microsystems (they make a very fine board!)

MFC after:	3 weeks
2002-08-11 23:34:20 +00:00
Jake Burkholder 5aebb40291 Auto size available kernel virtual address space based on phsyical memory
size.  This avoids blowing out kva in kmeminit() on large memory machines
(4 gigs or more).

Reviewed by:	tmm
2002-08-10 22:14:16 +00:00
Alan Cox 10864380ab o Remove the setting and clearing of the PG_MAPPED flag. (This flag is
obsolete.)
2002-08-10 17:14:14 +00:00
Brooks Davis 05c872ad62 Make ppp(4) devices clonable and unloadable. 2002-08-09 15:30:48 +00:00
Alan Cox 33559722db o Introduce pmap_page_is_mapped(). Its purpose is to obsolete
the PG_MAPPED flag.
2002-08-07 18:03:00 +00:00
Alan Cox 7ffcf9ec77 o Don't set PG_MAPPED or PG_WRITEABLE when a page is mapped
using pmap_kenter() or pmap_qenter().
 o Use VM_ALLOC_WIRED in pmap_new_thread().
2002-08-05 00:04:18 +00:00
Jake Burkholder ab1cee3d3d se -> sab. 2002-08-04 19:07:15 +00:00
Jake Burkholder 4fbe520926 Forgot to commit this.
Spotted by:	scottl
2002-08-01 21:39:54 +00:00
Marc Fonvieille c0727dcbfe Fix the link to the Handbook 2002-08-01 17:21:18 +00:00
Jake Burkholder 256e0b2bbb Modify the cache handling code to assume 2 virtual colours, which is much
simpler and easier to get right.  Add comments.  Add more statistic
gathering on cacheable and uncacheable mappings.
2002-08-01 00:16:22 +00:00
Jake Burkholder b519494ef1 Add some statistic gathering for cache flushes. 2002-07-31 23:39:50 +00:00
Jake Burkholder 055ca86c52 These file are no longer used (moved to userland and/or merged into
pmap.c).
2002-07-31 16:23:27 +00:00
Jake Burkholder da1416c80c These were repo-copied to have a .S extension. 2002-07-31 15:56:15 +00:00
Jake Burkholder 61f869600d Add definitions for statistical and high-resolution profiling. The calling
conventions for _mcount and __cyg_profile_func_enter are different, so
statistical profiling kernels build and link but don't actually work.
IWBNI one could tell gcc to only generate calls to the former.

Define uintfptr_t properly for userland, but not for the kernel (I hope).
2002-07-30 06:14:34 +00:00
Jake Burkholder c465faf9d4 The data cache on UltraSPARC III is not directly mapped, so don't assert
that.  This breaks assumptions made by some of the cache flushing code,
but UltraSPARC III has different methods for invalidating cache lines
anyway.
2002-07-30 05:48:33 +00:00
Jake Burkholder 4cfeb177e8 Panic if the data cache has too many virtual colors (more than 2). 2002-07-30 04:19:07 +00:00
Jake Burkholder 7968e6d2b2 Use _ALIGN_DATA and _ALIGN_TEXT. 2002-07-30 02:27:24 +00:00
Mike Barcroft 49545b3891 Create a new header <machine/_stdint.h> for storing MD parts of
<stdint.h>.  Previously, parts were defined in <machine/ansi.h> and
<machine/limits.h>.  This resulted in two problems:
  (1) Defining macros in <machine/ansi.h> gets in the way of that
      header only defining types.
  (2) Defining C99 limits in <machine/limits.h> adds pollution to
      <limits.h>.
2002-07-29 17:41:23 +00:00
Jake Burkholder 55328d51ba Add routines needed for high resolution profiling. 2002-07-29 00:45:13 +00:00
Jake Burkholder fa4a902a13 Add a symbol for btext. 2002-07-29 00:42:00 +00:00
Jake Burkholder 7cde6cc16c Remove a stale comment. 2002-07-29 00:40:48 +00:00
Jake Burkholder edfdadb6c3 Use _ALIGN_TEXT. Implement __cyg_profile_func_enter and
__cyg_profile_func_exit for GUPROF.
2002-07-29 00:39:46 +00:00
Jake Burkholder d40e229819 Add _ALIGN_DATA and _ALIGN_TEXT macros. 2002-07-29 00:38:07 +00:00
Jake Burkholder 45b84327f9 Remove some stuff that snuck in last commit. 2002-07-29 00:37:05 +00:00
Jake Burkholder b44ba1a844 Fix a bug introduced in previous commit. Due to the interaction of the
direct physical mappings with virtual page colour, we need to flush the
data cache when a page changes colour.  I missed one case which broke
pipes.
2002-07-28 19:15:34 +00:00
Mike Barcroft 7a415ec906 Revert the previous delta; uintfptr_t needs to be available to
userland for libc/gmon to compile, so the typedef in <machine/types.h>
isn't good enough.  This is really ugly since we end up with the
actual value which uintfptr_t is typedef'd from, in multiple places.
This is bug for bug compatible with the other FreeBSD architectures.

Noticed by:	sparc64 tinderbox
2002-07-28 15:59:51 +00:00
Jake Burkholder 839b2e106a Add declarations for btext and etext. 2002-07-28 01:01:14 +00:00
Jake Burkholder 7d8a5be3ea uintfptr_t has moved to machine/types.h. 2002-07-27 23:36:51 +00:00
Jake Burkholder 30bbe52432 Implement a direct mapped address region, like alpha and ia64. This
basically maps all of physical memory 1:1 to a range of virtual addresses
outside of normal kva.  The advantage of doing this instead of accessing
phsyical addresses directly is that memory accesses will go through the
data cache, and will participate in the normal cache coherency algorithm
for invalidating lines in our own and in other cpus' data caches.  So
we don't have to flush the cache manually or send IPIs to do so on other
cpus.  Also, since the mappings never change, we don't have to flush them
from the tlb manually.
This makes pmap_copy_page and pmap_zero_page MP safe, allowing the idle
zero proc to run outside of giant.

Inspired by:	ia64
2002-07-27 21:57:38 +00:00
Mike Barcroft 601016470b Catch up to rev 1.339 of src/sys/conf/options (PCI_ENABLE_IO_MODES is
now a sysctl and is enabled by default).
2002-07-27 15:28:35 +00:00
Jake Burkholder dab4349561 Remove the tlb argument to tlb_page_demap (itlb or dtlb), in order to better
match the pmap_invalidate api.
2002-07-26 15:54:04 +00:00
Matt Jacob 1936600631 Set interrupt clear pointer for SBus slots to point to correct spot. 2002-07-25 20:14:59 +00:00
Peter Wemm b618108fff de-count pci 2002-07-23 06:38:47 +00:00
Peter Wemm fc147d7fe9 Add explicit unit count on 'device pci' for ahc/ahd 2002-07-21 23:07:31 +00:00
Peter Wemm 3ebc124838 Infrastructure tweaks to allow having both an Elf32 and an Elf64 executable
handler in the kernel at the same time.  Also, allow for the
exec_new_vmspace() code to build a different sized vmspace depending on
the executable environment.  This is a big help for execing i386 binaries
on ia64.   The ELF exec code grows the ability to map partial pages when
there is a page size difference, eg: emulating 4K pages on 8K or 16K
hardware pages.

Flesh out the i386 emulation support for ia64.  At this point, the only
binary that I know of that fails is cvsup, because the cvsup runtime
tries to execute code in pages not marked executable.

Obtained from:  dfr (mostly, many tweaks from me).
2002-07-20 02:56:12 +00:00
John Baldwin dde0429505 Various comment and minor style fixes. No actual content changes.
Inspired by:	bde
2002-07-16 18:20:17 +00:00
Thomas Moestl f42d907165 When multiple IOMMUs are present in a system, use a single TSB for all
of them, and couple them by always performing all operations on all
present IOMMUs. This is required because with the current API there
is no way to determine on which bus a busdma operation is performed.

While being there, clean up the iommu code a bit.

This should be a step in the direction of allow some of larger machines
to work; tests have shown that there still seem to be problems left.
2002-07-16 18:17:03 +00:00
Thomas Moestl 1ab480b27b Add new UltraSPARC-III VIS II instructions. 2002-07-16 17:44:01 +00:00
Thomas Moestl fe905bcb53 Add new LSU bits for UltraSPARC-III. 2002-07-16 16:24:03 +00:00
Thomas Moestl 63ebf186a7 Add ASI definitions of UltraSPARC-III (Cu) processors, and add some
previously missing US-I and II ones.
2002-07-16 16:22:25 +00:00
Alan Cox 9b973ca71f o Lock page queue accesses by vm_page_wire(). 2002-07-14 23:23:47 +00:00
Jake Burkholder e32cbadc61 Try both upa-portid and portid properties when finding the module id of a
secondary cpu.  Its called portid on UltraSPARCIII machines.
2002-07-14 00:08:58 +00:00
Jake Burkholder 1ff72decea Remove debug code. 2002-07-14 00:01:16 +00:00
Alan Cox 1f54526952 o Complete the locking of page queue accesses by vm_page_unwire().
o Assert that the page queues lock is held in vm_page_unwire().
 o Make vm_page_lock_queues() and vm_page_unlock_queues() visible
   to kernel loadable modules.
2002-07-13 20:55:21 +00:00
Jonathan Mini 08b38412c8 Add additional cred_free_thread() calls that I had missed the first time.
Pointed out by:	jhb
2002-07-13 04:36:50 +00:00
Jake Burkholder d73b19ef9d Use a fixed address for KERNBASE, so it doesn't change if the size of KVA
is increased.  Its confusing for all the kernel addresses to change, and
doesn't serve much purpose as far as conserving address space.
2002-07-13 03:29:10 +00:00
Jake Burkholder 5d5d3157fb Identify UltraSPARC-III and UltraSPARC-III+ cpus. 2002-07-13 03:23:29 +00:00
John Baldwin 33d7ad1abe Set the thread state of the newly chosen to run thread to TDS_RUNNING in
choosethread() in MI C code instead of doing it in in assembly in all the
various cpu_switch() functions.  This fixes problems on ia64 and sparc64.

Reviewed by:	julian, peter, benno
Tested on:	i386, alpha, sparc64
2002-07-12 18:34:22 +00:00
Thomas Moestl a935ed4fae When sending cache flushing IPIs, don't try to IPI the triggering CPU
itself; this causes undefined behaviour on UltraSPARCs. In particular,
the interrupt packet data words will not necessarily be delivered
correctly, which would result in a crash.
This bug also caused the cache-flushing work to be done twice on the
triggering CPU (when it did not cause crashes).

Reviewed by:	jake
2002-07-12 16:26:49 +00:00
John Baldwin 78dee2638a thread_exit() requires PROC_LOCK to be held, so lock it. 2002-07-11 22:13:33 +00:00
Mike Barcroft f889202ba4 Remove label_t and physadr, which seem to have never been used in
FreeBSD.

Submitted by:	bde
2002-07-10 15:47:59 +00:00
Mike Barcroft ba5fe51088 Move __offsetof() macro from <machine/ansi.h> to <sys/cdefs.h>. It's
hardly MD, since all our platforms share the same macro.  It's not
really compiler dependent either, but this helps in reducing
<machine/ansi.h> to only type definitions.
2002-07-08 16:43:35 +00:00
Peter Wemm a58b3a6878 Add a special page zero entry point intended to be called via the single
threaded VM pagezero kthread outside of Giant.  For some platforms, this
is really easy since it can just use the direct mapped region.  For others,
IPI sending is involved or there are other issues, so grab Giant when
needed.

We still have preemption issues to deal with, but Alan Cox has an
interesting suggestion on how to minimize the problem on x86.

Use Luigi's hack for preserving the (lack of) priority.

Turn the idle zeroing back on since it can now actually do something useful
outside of Giant in many cases.
2002-07-08 04:24:26 +00:00
Peter Wemm a136efe9b6 Collect all the (now equivalent) pmap_new_proc/pmap_dispose_proc/
pmap_swapin_proc/pmap_swapout_proc functions from the MD pmap code
and use a single equivalent MI version.  There are other cleanups
needed still.

While here, use the UMA zone hooks to keep a cache of preinitialized
proc structures handy, just like the thread system does.  This eliminates
one dependency on 'struct proc' being persistent even after being freed.
There are some comments about things that can be factored out into
ctor/dtor functions if it is worth it.  For now they are mostly just
doing statistics to get a feel of how it is working.
2002-07-07 23:05:27 +00:00
Peter Wemm 61695d7ac8 Fix (s/proc/thread/) some typos in two panic messages. 2002-07-07 22:50:41 +00:00
Peter Wemm 7b719ec324 Back out proc part of last commit. UMA manages the thread cache only, and
we just have to deal with the kstack when told to.  We do not have a
UMA-managed cache for the proc struct and its associated upage yet.  So,
go back to the old lazy mechanism.  Note that if UMA destroys pages that
used to contain proc structures, we'll lose the corresponding upage
forever.  (zones never did this - once a page was allocated, it stayed
attached to the proc zone forever)
2002-07-05 01:27:35 +00:00
Peter Wemm 0b306e55c6 Take a shot at implementing changes from i386/pmap.c rev 1.328-1.331. 2002-07-05 00:38:43 +00:00
Mike Barcroft a19d429398 Since printf(3) now supports the `j' conversion specifier, use that
when printing intmax_t and uintmax_t.

Forgotten by:	mike
Noticed by:	bde
2002-06-30 05:48:03 +00:00
Robert Watson 006f19e4f2 Remove ALT_BREAK_TO_DEBUGGER. This was inconsistent (both in form
and function) with existing configuration choices.  Arguably if
ALT_BREAK_TO_DEBUGGER was present, so should have been
BREAK_TO_DEBUGGER.  Regardless, it broke the option sort order in
these kernel configuration files.

Requested by:	bde
2002-06-30 04:12:21 +00:00
Julian Elischer 8540497c50 Fix reverse ordering of locks. add a comment about locks on some platforms.
Submitted by:	jhb@freebsd.org
2002-06-29 23:58:50 +00:00
Julian Elischer e602ba25fd Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)

Reviewed by:	Almost everyone who counts
	(at various times, peter, jhb, matt, alfred, mini, bernd,
	and a cast of thousands)

	NOTE: this is still Beta code, and contains lots of debugging stuff.
	expect slight instability in signals..
2002-06-29 17:26:22 +00:00
Julian Elischer 44990b8cb8 Add files that are new for KSE. 2002-06-29 07:04:59 +00:00
Jake Burkholder eecc66a7d2 Fix a deletion during traversal tailq bug. 2002-06-29 06:37:24 +00:00
David E. O'Brien 4f1daba8df Do NOT enable ATA_STATIC_ID -- cmd646 controller will be !ata2!,
and you will not mount an ATA /:
	mountroot> ufs:/ad0a
	Mounting root from ufs:/ad0a
	setrootbyname failed
	ffs_mountroot: can't find rootvp
2002-06-29 04:42:03 +00:00
Peter Wemm 160554fbf4 Remove a couple of __P() stragglers. 2002-06-29 02:32:34 +00:00
Maxime Henrion 0dc658c141 GENERIC now builds with -Werror, so remove NO_WERROR.
Approved by:	jake
2002-06-27 14:43:27 +00:00
Jake Burkholder 218fd301cd pmap_kremove can no longer be used to remove the magic device mappings
installed with pmap_kenter_flags, since the physical addresses may not
have an associated vm_page.  Add a function to do this.

Tested by:	Tomi Vainio <Tomi.Vainio@Sun.COM>
2002-06-25 15:13:09 +00:00
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
Maxime Henrion 584884ca0c Add a missing prototype to fix a warning. 2002-06-23 21:29:00 +00:00
Maxime Henrion a3dc999469 Include machine/critical.h to get missing prototypes.
Reviewed by:	tmm
2002-06-23 14:38:41 +00:00
Jake Burkholder f5885ad905 Fix a bug related to marking pages virtually uncacheable due to illegal
dcache aliasing.  A page that already had more than 1 mapping of the
same virtual colour would not be correctly uncached.

Noticed by:	Artur Grabowski <art@openbsd.org>
2002-06-22 23:55:15 +00:00
Maxime Henrion ea8be05a6f Warning fix.
Reviewed by:	peter
2002-06-22 20:46:59 +00:00
Jake Burkholder 4e4c1993b9 {f,s}usword -> {f,s}uword16. Implement {f,s}uword32.
Requested by:	peter
2002-06-20 20:41:57 +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
David E. O'Brien 10f80f494c Sync with i386. 2002-06-18 01:11:04 +00:00
Jake Burkholder e3957e9d67 Add constants for the min and max prom addresses. Use these instead of
magic numbers.  Use stxa_sync instead of stxa; membar #Sync; to ensure
that no instruction is placed between the two.  This can cause random
corruption even though interrupts are already disabled.
2002-06-17 15:44:10 +00:00
Thomas Moestl 5fb49f9fd6 Add PCI bus enumeration and latency timer setup to the sparc64 MD PCI
code. Both tasks are not always performed completely by the firmware.
The former is required to get some e450 models to boot; the latter fixes
the repeated fifo underruns with hme(4)s and gem(4)s observed on some
machines (and probably performance problems with other peripherals as
well).
2002-06-12 19:20:57 +00:00
Jake Burkholder 25be55bdc3 Add code to drop to ddb when a process gets a fatal signal that usually
suggests kernel bugs (4, 10, 11).  Add a sysctl debug.debugger_on_signal
which turns this on and off, default off.
2002-06-08 07:36:28 +00:00
Jake Burkholder 1b5e0369d7 Re-enable SMP by default. 2002-06-08 07:22:36 +00:00
Jake Burkholder 6b3d95e2cf Remove test code. 2002-06-08 07:21:52 +00:00
Jake Burkholder f5ee661c9b Remove code from trap which is handled in userland now. 2002-06-08 07:17:19 +00:00
Jake Burkholder acb941ef8f Fix bizarre SMP problems. The secondary cpus sometimes start up with junk
in their tlb which the prom doesn't clear out, so we have to do so manually
before mapping the kernel page table or the cpu can hang due various
conditions which cause undefined behaviour from the tlb.
2002-06-08 07:10:28 +00:00
Jake Burkholder a682b4e6e7 Comment out options SMP for now until I figure out what's going on. 2002-06-07 15:36:42 +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
Jake Burkholder a41c3573fa Use pmap_map instead of pmap_kenter to map the message buffer. Its too
early for pmap_kenter.
2002-06-05 15:36:57 +00:00
Jake Burkholder e7dc92f0f9 Bump TSB_PAGES_SHIFT to 4. Less sucks too much. 2002-06-04 19:40:45 +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
Jake Burkholder 626d38b529 Forgot to commit this file. Catch up to loader->kernel abi changes. 2002-05-29 19:48:03 +00:00
Jake Burkholder f7e0360261 Forward declare struct trapframe. 2002-05-29 19:25:14 +00:00
Jake Burkholder 819c7d570b Remove BOOTP_WIRED_TO= since I keep forgetting to take this out and screwing
over people with gems.
2002-05-29 19:22:17 +00:00
Jake Burkholder a2b4810ee7 Don't try to flush illegal alises from the data cache in vmapbuf and
vunmapbuf, this is handled by pmap now.
2002-05-29 06:16:47 +00:00
Jake Burkholder 20bd6675fb Add an MD page flag for tracking if a page is cacheable or not, so that
we don't flush all mappings of a physical page in order to make it
virtually cachable again, if it is already cachable.
2002-05-29 06:12:13 +00:00
Jake Burkholder 468303c500 Remove an unused variable. 2002-05-29 06:10:37 +00:00
Jake Burkholder 1982efc5c2 Merge the code in pv.c into pmap.c directly. Place all page mappings onto
the pv lists in the vm_page, even unmanaged kernel mappings.  This is so
that the virtual cachability of these mappings can be tracked when a page
is mapped to more than one virtual address.  All virtually cachable
mappings of a physical page must have the same virtual colour, or illegal
alises can be created in the data cache.  This is a bit tricky because we
still have to recognize managed and unmanaged mappings, even though they
are all on the pv lists.
2002-05-29 06:08:45 +00:00
Jake Burkholder e793e4d0b3 Add pv list linkage and a pmap pointer to struct tte. Remove separately
allocated pv entries and use the linkage in the tte for pv operations.
2002-05-29 05:56:05 +00:00
Jake Burkholder 35738638d6 Use a contrived 'tlb_entry' structure for passing the mappings for the
kernel text and data from the loader to the kernel, so that the tte format
is not part of the loader->kernel ABI.
2002-05-29 05:49:59 +00:00
Jake Burkholder b08270ba0f Remove pmap.pm_pvlist and make the functions that use it no-ops. These are
all optimizations for architectures which have large sparse page tables,
and/or can't put the pv linkage inside of the page table entries.
2002-05-29 05:24:16 +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 4d574756ac Convert the interrupt queue from an array to a linked list. Implement
intr_dequeue in asm so that it can easily be modified to do light weight
context switching.
2002-05-25 02:39:28 +00:00
Jake Burkholder 0679dc5f91 Try to handle "double faults" occuring at more trap levels (ie 4 :)). 2002-05-25 01:45:11 +00:00
Jake Burkholder 597e13d8c5 Minor style. 2002-05-25 01:44:08 +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
Jake Burkholder 2dbb68a495 Update tsb_tte_enter prototype per tsb.c rev 1.20. 2002-05-21 02:15:37 +00:00
Jake Burkholder 38c04dc163 Rewrite pmap_enter to avoid copying ttes in all cases.
Pass the tte data to tsb_tte_enter instead of a whole tte, also to avoid
copying.
2002-05-21 02:14:11 +00:00
Jake Burkholder f631b588f5 Redefine the tte accessor macros to take a pointer to a tte, instead of the
value of the tag or data field.
Add macros for getting the page shift, size and mask for the physical page
that a tte maps (which may be one of several sizes).
Use the new cache functions for invalidating single pages.
2002-05-21 00:29:02 +00:00
Jake Burkholder b78213fb0b Add SMP aware cache flushing functions, which operate on a single physical
page.  These send IPIs if necessary in order to keep the caches in sync on
all cpus.
2002-05-20 16:30:47 +00:00
Jake Burkholder 856316e9c6 Forward declare struct trapframe. 2002-05-20 16:12:35 +00:00
Jake Burkholder f7c81a5182 De-inline the tlb demap functions. These were so big that gcc3.1 refused
to inline them anyway.  ;)
2002-05-20 16:10:17 +00:00
Eric Melville 13d362233e Banish "priviledged" from kernel source. 2002-05-16 22:41:48 +00:00
David E. O'Brien 5aecc48bb0 style sync with other platforms. 2002-05-15 16:40:25 +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
Jake Burkholder 20409ddf22 Fix IF_SEXT(val, 32). The constants need to have type long to
handle size > 16.
2002-05-13 04:26:38 +00:00
Jake Burkholder c0db03795f Add another copy of the ia64 dump_machdep.c. 2002-05-13 02:39:19 +00:00
Jake Burkholder 63fd3b0af9 Enable KTR_TRAP by default. 2002-05-12 18:10:48 +00:00
Jake Burkholder 025c284b8d Add a support macro to convert the 5-bit packed register field of
a floating point instruction into a 6-bit register number for
double and quad arguments.
Make use of the new INSFPdq_RN macro where apporpriate; this
is required for correctly handling the "high" fp registers
(>= %f32).
Fix a number of bugs related to the handling of the high registers
which were caused by using __fpu_[gs]etreg() where __fpu_[gs]etreg64()
should be used (the former can only access the low, single-precision,
registers).

Submitted by:	tmm
2002-05-11 21:20:05 +00:00
David E. O'Brien fc336fdfbb Gcc 3.1 varargs support. 2002-05-10 02:02:54 +00:00
David E. O'Brien 3393d027da Comment two values I was looking at for GDB. 2002-05-09 02:07:51 +00:00
Jake Burkholder 51ceaefac4 Remove unneeded include. 2002-05-08 04:21:58 +00:00
Jake Burkholder ea4ad4bb29 Make a macro for the guts of tl0_immu_miss, like dmmu_miss and prot.
Rearrange things slightly so that the contents of the tag access
register are read and restored outside of the macros.  The intention
is to pass the page size to look up as an argument to the macros.
2002-05-08 04:14:16 +00:00
Juli Mallett ea0b7a7699 Typo fix: detects -> detect.
Reviewed by:	phk
2002-05-03 17:59:25 +00:00
Jake Burkholder e289cb8fe7 Add support for an alternate signal trampoline; add a sysarch call to register
an alternate trampoling with the kernel.
2002-04-29 18:08:26 +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
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
Jake Burkholder 11dcdc976b Avoid using pmap_kenter "early", since it may need to dink with vm_page
structures, which may not be setup yet.  Minor cleanups.
2002-04-21 22:57:42 +00:00
Jake Burkholder 9ba847abf3 MFi386 1.222. Remove vm_map_growstack and acquisition and release of Giant
from trap_pfault.
2002-04-20 17:28:08 +00:00
Jake Burkholder d1fef1792c Check the alignment of the stack pointer before copying in windows from the
user stack in response to a failed window fill, allowing the process to be
killed if its wrong.  This caused user programs which misalign their stack
pointer to get stuck in an infinite loop at the kernel-userland boundary,
which is mostly harmless.

The same thing causes a fatal RED state exception on OpenBSD and probably
NetBSD.

Inspired by:	art@openbsd.org
2002-04-20 16:23:52 +00:00
Jake Burkholder bb52b4f3fc Fix off by one errors in cache flush calls (mostly harmless). 2002-04-20 15:58:40 +00:00
Jake Burkholder 26956cba94 Add needed include of tick.h. 2002-04-20 15:52:53 +00:00
Robert Watson 91e007dc70 Since WITNESS doesn't just do mutexes, remove "mutex" from the WITNESS
comment in GENERIC config files of appropriate platforms.  For whatever
reason, powerpc didn't use WITNESS in GENERIC.
2002-04-18 03:44:44 +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
David E. O'Brien 9b019189c4 option<space><tab> 2002-04-15 09:21:51 +00:00
Alan Cox 80eef17ba9 o Remove vm_map_growstack() and useracc() from sendsig(). Copyout() and
suword() will automatically grow the stack if needed.
 o Add a comment that osigreturn() and sigreturn() are MPSAFE.
2002-04-13 19:17:49 +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
Jake Burkholder 22d67801e6 Forgot these files in previous commit to frame.h. Also add needed include
of machine/emul.h.
2002-04-09 01:43:07 +00:00
Jake Burkholder d134a05e90 Oops. machine/emul.h didn't exist yet. 2002-04-09 01:42:19 +00:00
Jake Burkholder 82436f1067 Rename some fields in struct frame to be compatible with NetBSD/OpenBSD,
and add some compatibility defines.  Add fields for ins and locals to
struct reg also for the same reason; these aren't filled in yet because
getting at those registers sucks and I'd rather not save them in the
trapframe just for this.  Reorder struct reg to be ABI compatible as
well.  Add needed include of machine/emul.h.

This gets pmdb (poor man's debugger) from OpenBSD mostly compiling but it
doesn't work yet :(
2002-04-09 00:57:23 +00:00
Jake Burkholder 530faa0f9e Add device se (commented out, most people won't find this useful yet). 2002-04-09 00:37:33 +00:00
Jake Burkholder 16b7e738de Enable device pass. 2002-04-08 23:21:31 +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
Jake Burkholder c8eabf779c Enable isp and ispfw. Remove the nonexistant SUN_DISKLABEL and
ATA_ENABLE_BUSMATER.
2002-04-06 09:33:24 +00:00
Jake Burkholder 274ae7b653 Provide an implementation of KTR_CPU that doesn't use pcpu, so we don't
crash and burn if its not setup yet.  Add timestamp, cpu, and (fake) file
and line recording to the asm version of CTR.
2002-04-06 08:40:59 +00:00
Jake Burkholder c4c03d1766 Remove invalid KASSERTS. 2002-04-06 08:21:43 +00:00
Thomas Moestl 6ed31e9112 Add missing header for the eeprom driver frontents. 2002-04-05 02:40:54 +00:00
Thomas Moestl 36c009a428 Add MD frontents for the mk48txx driver, ported from NetBSD, and remove
stub implementations of inittodr() and resettodr(), now that the MI ones
are used.
2002-04-04 23:58:50 +00:00
John Baldwin 6008862bc2 Change callers of mtx_init() to pass in an appropriate lock type name. In
most cases NULL is passed, but in some cases such as network driver locks
(which use the MTX_NETWORK_LOCK macro) and UMA zone locks, a name is used.

Tested on:	i386, alpha, sparc64
2002-04-04 21:03:38 +00:00
Bruce Evans 79065dba2a Moved signal handling and rescheduling from userret() to ast() so that
they aren't in the usual path of execution for syscalls and traps.
The main complication for this is that we have to set flags to control
ast() everywhere that changes the signal mask.

Avoid locking in userret() in most of the remaining cases.

Submitted by:	luoqi (first part only, long ago, reorganized by me)
Reminded by:	dillon
2002-04-04 17:49:48 +00:00
Ruslan Ermilov 12c79eb288 Dike out a highly insecure UCONSOLE option.
TIOCCONS must be able to VOP_ACCESS() /dev/console to succeed.

Obtained from:	OpenBSD
2002-04-03 10:56:59 +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
Thomas Moestl 816663a0b3 Fix crashes that would happen when more than one 4MB page was used to
hold the kernel text, data and loader metadata by not using a fixed slot
to store the TSB page(s) into. Enter fake 8k page entries into the kernel
TSB that cover the 4M kernel page(s), sot that pmap_kenter() will work
without having to treat these pages as a special case.

Problem reported by:	mjacob, obrien
Problem spotted and 4M page handling proposed by:       jake
2002-04-02 17:50:13 +00:00
Thomas Moestl 5320165b09 Remove the superfluous second argument from the IOTSBSLOT() macro. 2002-04-02 17:41:06 +00:00
Thomas Moestl 910d801895 Lower UPA_MEMSTART to 0x1c000000000. This is required for some larger
Enterprise machines.
2002-04-02 17:38:52 +00:00
Thomas Moestl bca61dd95d Set mp_maxid so that UMA works with SMP.
Submitted by:	jake
2002-04-02 17:37:06 +00:00
Thomas Moestl 3191e556ea Do not try to set up the PCI bus B error interrupt on "sabre"s, since
it is only available on "psycho"s. The same applies to the power
management interrupt, which is not enabled by default though.
2002-04-02 17:27:35 +00:00
Thomas Moestl 3d6d9df323 Remove a debugging panic that was triggered when a resource that was out
of range was tried to be allocated; just return failure instead.
2002-04-02 17:23:45 +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
Jake Burkholder d86b2422b9 Move the CTASSERT macro from MD code to systm.h alongside KASSERT so other
code can use it.  This takes a single constant argument and fails to compile
if it is 0 (false).  The main application of this is to make assertions about
structure sizes at compile time, in order to validate assumptions made in
other code.  Examples:

CTASSERT(sizeof(struct foo) == FOO_SIZEOF);
CTASSERT(sizeof(struct foo) == (1 << FOO_SHIFT));

Requested by:	jhb, phk
2002-04-01 21:55:00 +00:00
Jake Burkholder 60a57b73ef ktr changes to improve performance and make writing a userland utility to
dump the trace buffer feasible.
- Remove KTR_EXTEND.  This changes the format of the trace entries when
  activated, making writing a userland tool which is not tied to a specific
  kernel configuration difficult.
- Use get_cyclecount() for timestamps.  nanotime() is much too heavy weight
  and requires recursion protection due to ktr traces occuring as a result
  of ktr traces.  KTR_VERBOSE may still require recursion protection, which
  is now conditional on it.
- Allow KTR_CPU to be overridden by MD code.  This is so that it is possible
  to trace early in startup before pcpu and/or curthread are setup.
- Add a version number for the ktr interface.  A userland tool can check this
  to detect mismatches.
- Use an array for the parameters to make decoding in userland easier.
- Add file and line recording to the non-extended traces now that the extended
  version is no more.

These changes will break gdb macros to decode the extended version of the
trace buffer which are floating around.  Users of these macros should either
use the show ktr command in ddb, or use the userland utility which can be run
on a core dump.

Approved by:	jhb
Tested on:	i386, sparc64
2002-04-01 05:35:26 +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 af3e811fd3 Correct a comment: sendsig() calls the MI vm_map_growstack() but
the corresponding comment refers to a MD grow_stack() that doesn't exist.
2002-03-30 20:58:08 +00:00
Jake Burkholder d0ce9a7e07 Remove abuse of intr_disable/restore in MI code by moving the loop in ast()
back into the calling MD code.  The MD code must ensure no races between
checking the astpening flag and returning to usermode.

Submitted by:	peter (ia64 bits)
Tested on:	alpha (peter, jeff), i386, ia64 (peter), sparc64
2002-03-29 16:35:26 +00:00
David E. O'Brien d8738722bd Don't be too fancy with null'ed out functions.
Requested by:	jake
2002-03-28 04:33:51 +00:00
David E. O'Brien 838e4a7d9d Add sysbeep() for the msmith RAID drivers. 2002-03-28 04:19:16 +00:00
David E. O'Brien ae7c70d595 style(9)
Approved by:	jake
2002-03-28 02:54:44 +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
Jake Burkholder fb893e9c13 Fix style bugs. 2002-03-27 06:50:34 +00:00
Jake Burkholder 3d58262f2f Fix breakage. 2002-03-27 06:45:48 +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
Thomas Moestl 1ca3bc9097 Add missing includes for the KTRACE case. 2002-03-25 04:54:19 +00:00
Thomas Moestl 6267df8595 Add missing declarations. 2002-03-25 04:53:18 +00:00
Thomas Moestl 2ef66f9259 Make this compile (submitted by jake), add a missing include. 2002-03-25 04:38:48 +00:00
Thomas Moestl 937b1ef9e2 Remove second copy of iommu_decode_fault() which I accidentially added.
Pointy hat to:	tmm
2002-03-25 04:34:52 +00:00
David E. O'Brien c543d983fa Guard against redefining __gnuc_va_list. 2002-03-24 11:25:46 +00:00
Thomas Moestl e8e2c56650 Revamp the busdma implementation a bit:
- change the IOMMU support code so that it supports overcommittting the
  available DVMA memory, while still allocating as lazily as possible.
  This is achieved by limiting the preallocation, and deferring the
  allocation to map load time when it fails. In the latter case, the
  DVMA memory reserved for unloaded maps can be stolen to free up enough
  memory for loading a map.
- allow NULL settings in the method tables, and search the parent tags
  until an appropriate implementation is found. This allows to remove some
  kluges in the old implementation.
2002-03-24 02:50:53 +00:00
Thomas Moestl 494fde77c9 Fix sparc64_bus_mem_unmap() to pass the right address to kmem_free(). 2002-03-24 02:33:09 +00:00
Thomas Moestl 464ae30ee6 Make the OpenFirmware interrupt mapping code more generic, to reduce
the bus-dependent code and to be able to support more systems. The core
of the new code is mostly obtained from NetBSD.
Kluge the interrupt routing methods of the psycho and apb drivers so
that an intline of 0 can be handled for now; real routing is still not
possible (all intline registers are preinitialized instead); this will
require a sparc64-specific adaption of the driver for generic PCI-PCI
bridges with a custom routing method to work right.
2002-03-24 02:11:06 +00:00
Thomas Moestl 1734bea4fb Map the device memory belonging to resources of type SYS_RES_MEMORY into
KVA upon activation so that rman_get_virtual() works as expected.
2002-03-24 01:51:29 +00:00
Thomas Moestl 4b5504494d Add code to print the fault virtual address for uncorrectable DMA errors
caused by IOMMU misses to aid debugging. This will only work on
UltraSPARC-IIi and IIe.
2002-03-23 20:42:23 +00:00
Thomas Moestl d1e39d7347 De-__P(), de-K&R, remove superfluous comments and prototypes, some
style fixes. No functional changes.
2002-03-23 20:27:32 +00:00
Thomas Moestl 8d515e67fa De-K&R. 2002-03-23 20:22:19 +00:00
Thomas Moestl bbe4a6c452 Fix syscall ktraceing. 2002-03-23 20:11:38 +00:00
Thomas Moestl 676c54ffe6 Make this compile without options DDB; use intr_disable() instead of
fiddling with PSTATE_IE manually.
2002-03-23 20:09:48 +00:00
Thomas Moestl 69f2effbd9 Decruft some #if 0'ed code. 2002-03-23 20:05:42 +00:00
Thomas Moestl bc4e9bed7c Add PCIfunctions 2 and 3 of the PCIO2 chip to the intpin quirk table. 2002-03-23 20:04:10 +00:00
Jake Burkholder f4db8e245f Machine must be non-static for COMPAT_43 to compile. This is used in bsd/os
1.x compatibility code, which I'm sure we all use every day.
2002-03-23 17:13:45 +00:00
Jake Burkholder b7cbb37042 Cleanup the trace back routine slightly. Print the leaf return value so
that traps inside of leaf functions are less confusing.  Add a function
to print a non-symbolic trace of the user stack.
2002-03-23 17:04:41 +00:00
Jake Burkholder c8c751181e Sync with other arches; add bloat. 2002-03-23 16:55:37 +00:00
Jake Burkholder f1bb97a884 Fix a deadlock condition with tlb shootdown ipi delivery. Since ipis are
not blocked by raising the pil, a reciever may be interrupted while holding
a spinlock.  If the sender does not defer interrupts throughout the entire
operation it may be interrupted and try to acquire a spinlock held by a
reciever, leading to a deadlock due to the synchronization used by the
ipi handlers themselves.

Submitted by:	tmm
2002-03-23 04:20:00 +00:00
Jake Burkholder 44a7aea1d7 Backout intrusive ktr traces in tlb fault handlers which have served their
purpose.
2002-03-23 03:25:09 +00:00
David E. O'Brien 439a4003ab ASM versions of __FBSDID. 2002-03-23 02:01:27 +00:00
Warner Losh 03742795eb intr_disable returns register_t 2002-03-21 06:21:32 +00:00
Jeff Roberson 74cbb73ba8 Remove references to vm_zone.h and switch over to the new uma API.
Reviewed by:	jake
2002-03-21 02:30:27 +00:00
Alfred Perlstein 91f5bcb812 Remove __P.
profile.h and bus.h were excluded because there is currently WIP.

Reviewed by: tmm
2002-03-21 00:06:55 +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
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
Jake Burkholder 9bc8610af5 Don't demap the requested page from the tlb in pmap_kenter or pmap_kremove,
even on the local cpu.  These are no longer used unsafely in MI code, and
the MD code has been adjusted to compensate.
2002-03-17 01:53:51 +00:00
Jake Burkholder bfd501b637 Fix a problem where kernel text could become unmapped when clearing out all
the user mappings from the tlb due to the context numbers rolling over.  The
store to the internal mmu register must be followed by a membar #Sync before
much else happens to "avoid data corruption", so we use special inlines which
both disable interrupts and ensure that the compiler will not insert extra
instructions between the two.  Also, load the tte tag and check if the context
is nucleus context, rather than relying on the priviledged bit which doesn't
actually serve any purpose in our design, and check the lock bit too for
sanity.
2002-03-17 01:51:32 +00:00
Jake Burkholder 2f3e2b8795 Use the tlb data access register to map the kernel tsb, rather than the data
in register.  The latter uses the random replacment algorithm to pick the
slot, we want a specific slot.
2002-03-17 01:45:29 +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
Jake Burkholder 9ad1d32f3d Fix ifdef LOCORE protection. 2002-03-13 06:04:36 +00:00
Jake Burkholder 76cf1369d7 Add a DEBUGGER_ON_POWERFAIL option. This makes the power button on ultra 10s
work like an NMI button.
2002-03-13 05:58:45 +00:00
Jake Burkholder 064d9e8af4 Fix braino. 2002-03-13 05:54:00 +00:00
Jake Burkholder 5ce88ec47e Add support for starting and stopping cpus with ipis.
Stop the other cpus when shutting down or entering the debugger.

Submitted by:	tmm
2002-03-13 04:59:01 +00:00
Jake Burkholder 63a33ce158 Use intr_disable/intr_restore instead of doing it manually.
Submitted by:	tmm
2002-03-13 04:43:45 +00:00
Jake Burkholder 4968137eb9 Add support for driving the clocks on secondary cpus.
Submitted by:	tmm
2002-03-13 04:38:33 +00:00
Jake Burkholder 8f5eafcdd1 Fix a bug where the wrong number of windows were copied for a failed fill
on return to user mode.  We may not have frame pointers setup for more
than 1 on return from exec.
2002-03-13 04:02:27 +00:00
Jake Burkholder 37453e292e White space. 2002-03-13 03:55:28 +00:00
Jake Burkholder 1bc589c745 Make IPI_WAIT use a bit mask of the cpus that a pmap is active on and only
wait for those cpus, instead of all of them by using a count.  Oops.
Make the pointer to the mask that the primary cpu spins on volatile, so
gcc doesn't optimize out an important load.  Oops again.
Activate tlb shootdown ipi synchronization now that it works.  We have
all involved cpus wait until all the others are done.  This may not be
necessary, it is mostly for sanity.
Make the trigger level interrupt ipi handler work.

Submitted by:	tmm
2002-03-13 03:43:00 +00:00
Jake Burkholder 453e54056e Add an ATOMIC_CLEAR_INT macro.
Submitted by:	tmm
2002-03-13 03:28:47 +00:00
Thomas Moestl 9390de81a1 Fix the type of some constants, and make some macros safer by casting
the argument.
2002-03-11 03:04:28 +00:00
Thomas Moestl 25aab485b6 Add convenience macros to extract the cc0 and cc1 from format 2 and 3
instructions.
2002-03-11 03:03:35 +00:00
Jake Burkholder a46877abfc Increase VM_KMEM_SIZE to 16 megs from 12. Define VM_KMEM_SIZE_SCALE so that
the number of physical pages per KVA page allocated scales properly with
memory size.  This fixes problems with kmem_map being too small.

Noticed by:	mike, wollman
Submitted by:	tmm
2002-03-09 23:35:50 +00:00
Thomas Moestl 0c530eb321 Add a driver for the mem and kmem devices, based off the i386 version. 2002-03-09 22:33:16 +00:00
Thomas Moestl d4f1dcab55 Set the interrupt map type accordingly if we need to fall back to using
the PCI bus interrupt map.
2002-03-09 22:02:02 +00:00
Thomas Moestl db20923f96 Fix a warning by adding a missing include. 2002-03-09 22:00:30 +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
Jake Burkholder 4f91e3efb2 Implement delivery of tlb shootdown ipis. This is currently more fine grained
than the other implementations; we have complete control over the tlb, so we
only demap specific pages.  We take advantage of the ranged tlb flush api
to send one ipi for a range of pages, and due to the pm_active optimization
we rarely send ipis for demaps from user pmaps.

Remove now unused routines to load the tlb; this is only done once outside
of the tlb fault handlers.
Minor cleanups to the smp startup code.

This boots multi user with both cpus active on a dual ultra 60 and on a
dual ultra 2.
2002-03-07 06:01:40 +00:00
Jake Burkholder 39028e8396 Modify the tlb demap API to take a pmap instead of a tlb context number.
Due to allocating tlb contexts on the fly, we only ever need to demap the
primary context, non-primary contexts have already been implicitly flushed
by context switching.  All we really need to tell is if its a kernel demap
or not, and its easier just to compare against the kernel_pmap which is a
constant.
2002-03-07 05:25:15 +00:00
Jake Burkholder bc9b764621 Implement kthread context stealing. This is a bit of a misnomer because
the context is not actually stolen, as it would be for i386.  Instead of
deactivating a user vmspace immediately when switching out, and recycling
its tlb context, wait until the next context switch to a different user
vmspace.  In this way we can switch from a user process to any number of
kernel threads and back to the same user process again, without losing any
of its mappings in the tlb that would not already be knocked by the automatic
replacement algorithm.  This is not expected to have a measurable performance
improvement on the machines we currently run on, but it sounds cool and makes
the sparc64 port SMPng buzz word compliant.
2002-03-07 05:15:43 +00:00
Jake Burkholder eb5b9c0be3 Add support for starting secondary cpus in kernel, as opposed to relying
on the loader to do it.  Improve smp startup code to be less racy and to
defer certain things until the right time.  This almost boots single user
on my dual ultra 60, it is still very fragile:

SMP: AP CPU #1 Launched!
Enter full pathname of shell or RETURN for /bin/sh:
# ls
Debugger("trapsig")
Stopped at      Debugger+0x1c:  ta              %xcc, 1
db> heh
No such command
db>
2002-03-04 07:12:36 +00:00
Jake Burkholder 907164660a Dig the information about which tlb slots were used to map the kernel out
of the metadata passed by the loader.
2002-03-04 07:07:10 +00:00
Jake Burkholder 5573db3f0b Allocate tlb contexts on the fly in cpu_switch, instead of statically 1 to 1
with pmaps.  When the context numbers wrap around we flush all user mappings
from the tlb.  This makes use of the array indexed by cpuid to allow a pmap
to have a different context number on a different cpu.  If the context numbers
are then divided evenly among cpus such that none are shared, we can avoid
sending tlb shootdown ipis in an smp system for non-shared pmaps.  This also
removes a limit of 8192 processes (pmaps) that could be active at any given
time due to running out of tlb contexts.

Inspired by:		the brown book
Crucial bugfix from:	tmm
2002-03-04 05:20:29 +00:00
Jake Burkholder 34aef253aa Fix obscure problems with vfork where part of the parent's stack could be
clobbered by the child.  This is more complicated than usual because the
window that could get clobbered is pushed in kernel mode, so a lot of
registers would have to be saved in other registers in userland and we
don't have enough.  What we do have is space in the pcb to temporarily
store user windows that were spilled in kernel mode, but could not be
immediately stored to the user stack.  So we copy in the parent's topmost
window and save it in the pcb, and arrange for it to be copied back out
when the child is done frobbing the stack.

Reviewed by:	tmm
2002-03-04 05:07:22 +00:00
Jake Burkholder e45a21d07a We don't need KTR_COMPILE in assym.s, its already in opt_global.h. Add
assyms for more ktr trace classes.
2002-03-01 16:22:06 +00:00
Jake Burkholder b8c926a9ab Use a better trace class for ktr traces in the tlb fault handlers, which are
rather loud.
2002-03-01 16:17:50 +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
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
Mike Silbersack f4e18c9afd Fix a minor swap leak.
Previously, the UPAGES/KSTACK area of processes/threads would leak memory
at the time that a previously swapped process was terminated.  Lukcily, the
leak was only 12K/proc, so it was unlikely to be a major problem unless you
had an undersized swap partition.

Submitted by:	dillon
Reviewed by:	silby
MFC after:	1 week
2002-02-28 07:41:12 +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
Jake Burkholder df38f87be1 Minimal testing has shown that a 4 page tsb is a nice sweet spot for current
work loads.  It tapers off after that as gcc's working set generally just fits.

compiling bin/csh:

TSB_PAGES = 2
	213.33 real        77.59 user       110.01 sys
TSB_PAGES = 4
	116.43 real        75.78 user        19.16 sys
TSB_PAGES = 8
	119.27 real        76.38 user        18.12 sys

Testing by:	tmm
2002-02-27 06:18:02 +00:00
Jake Burkholder 95a44511f3 Parameterize the number of pages to allocate for the per-cpu area on
PCPU_PAGES.
2002-02-27 06:08:13 +00:00
Jake Burkholder 62ad058292 Make cpu_identify take the value of the ver register and cpuid as arguments
so we can print nice things about non-current cpus.
2002-02-27 06:05:50 +00:00
Jake Burkholder ad414cb452 Minor cleanup. 2002-02-27 00:31:31 +00:00
Jake Burkholder d689965cb4 Wrap long lines. 2002-02-27 00:28:35 +00:00
Jake Burkholder 9d16662aa3 Use pcpu.pc_cpumask instead of computing 1 << cpuid. 2002-02-27 00:27:05 +00:00
Jake Burkholder 5d60dc233a Add a macro for shift of an integer (1 << shift == sizeof). Move the pointer
define to live alongside it.  For kicks assert at compile time that they are
correct.  Use these instead of magic numbers.
2002-02-27 00:21:04 +00:00
Jake Burkholder 7a8ee66881 Wrap long lines. 2002-02-27 00:03:01 +00:00
David E. O'Brien db3442f54d Define basic macros required by GDB. 2002-02-26 21:49:46 +00:00
Jake Burkholder c7f9e1fdbf Apparently gcc3.1 is now using deprcated v8 instructions in v9 code
due to them being faster in certain cases.  Therefore we need to save
and restore the v8 %y register around traps in kernel mode as well as
traps in usermode.

Tested by:	obrien, tmm
2002-02-26 17:09:24 +00:00
Jake Burkholder de3fee8992 Convert pmap.pm_context to an array of contexts indexed by cpuid. This
doesn't make sense for SMP right now, but it is a means to an end.
2002-02-26 06:57:30 +00:00
Jake Burkholder 200e6309c9 Pu back a call to pmap_context_destroy which was accidentily removed
in the previous commit.

Spotted by:	tmm
2002-02-26 06:39:38 +00:00
Jake Burkholder 6e5f3d0f0f Allow the user tsb to span multiple pages. Make the default 2 pages for now
until we do some testing to see what's best.  This gives a massive reduction
in system time for processes with a relatively large working set.  The size
of the tsb directly affects the rss size that a user process can keep mapped.
When it starts to get full replacements occur and the process takes a lot of
soft vm faults.  Increasing the default from 1 page to 2 gives the following
before and after numbers for compiling vfs_bio.c:

before:
       14.27 real         6.56 user         5.69 sys
after:
        8.57 real         6.11 user         1.62 sys

This should make self hosted builds more tolerable.
2002-02-26 02:37:43 +00:00
Jake Burkholder 07d99740b6 Remove code to lock the user tsb into the tlb. We can handle faults on it
now, as we do for normal wired kernel memory.
2002-02-25 22:58:41 +00:00
David E. O'Brien 65955377e3 I was able to boot this kernel using the latest WIP kernel sources.
I don't believe anyone is quite using the sparc64 kernel sources in CVS
yet -- things aren't just quite ready (but almost).  So this commit should
be OK to make.
2002-02-25 22:13:44 +00:00
Jake Burkholder 4c4a1a19e8 Implement a nested window state. This avoids attempting to spill a user
window to the user stack while in a nested kernel trap.  We do this for
entry to the kernel from user mode, but if we get an interrupt in kernel
mode while there are still user windows in the cpu, and we attempt to spill
to the user stack, we may take too many nested traps and overflow the trap
stack, causing a red state exception.  This is needed by upcoming changes
to allow the user tsb to not be locked in the tlb.

Reviewed by:	tmm
2002-02-25 18:37:17 +00:00
Jake Burkholder 3c997c536c Modify the tte format to not include the tlb context number and to store the
virtual page number in a much more convenient way; all in one piece.  This
greatly simplifies the comparison for a matching tte, and allows the fault
handlers to be much simpler due to not having to load wierd masks.
Rewrite the tlb fault handlers to account for the new format.  These are also
written to allow faults on the user tsb inside of the fault handlers; the
kernel fault handler must be aware of this and not clobber the other's
registers.  The faults do not yet occur due to other support that is needed
(and still under my desk).

Bug fixes from:	tmm
2002-02-25 04:56:50 +00:00