Commit Graph

751 Commits

Author SHA1 Message Date
Neel Natu
01ab508d37 Fix mips kernel build breakage caused by revision 208504. 2010-05-25 05:42:12 +00:00
Alan Cox
567e51e18c Roughly half of a typical pmap_mincore() implementation is machine-
independent code.  Move this code into mincore(), and eliminate the
page queues lock from pmap_mincore().

Push down the page queues lock into pmap_clear_modify(),
pmap_clear_reference(), and pmap_is_modified().  Assert that these
functions are never passed an unmanaged page.

Eliminate an inaccurate comment from powerpc/powerpc/mmu_if.m:
Contrary to what the comment says, pmap_mincore() is not simply an
optimization.  Without a complete pmap_mincore() implementation,
mincore() cannot return either MINCORE_MODIFIED or MINCORE_REFERENCED
because only the pmap can provide this information.

Eliminate the page queues lock from vfs_setdirty_locked_object(),
vm_pageout_clean(), vm_object_page_collect_flush(), and
vm_object_page_clean().  Generally speaking, these are all accesses
to the page's dirty field, which are synchronized by the containing
vm object's lock.

Reduce the scope of the page queues lock in vm_object_madvise() and
vm_page_dontneed().

Reviewed by:	kib (an earlier version)
2010-05-24 14:26:57 +00:00
Jayachandran C.
f66c469335 Remove unused code in sys/mips/rmi :
- ehcireg.h,ehcivar.h : USB related files from old merge
 - pcibus.c : was merged into xlr_pci.c earlier
 - xlr_boot1_console.c : obsolete console code using bootloader hooks
 - sys/mips/rmi/perfmon* : obsolete custom performance monitoring code

Approved by:	rrs (mentor)
2010-05-24 06:01:37 +00:00
Konstantin Belousov
afe1a68827 Reorganize syscall entry and leave handling.
Extend struct sysvec with three new elements:
sv_fetch_syscall_args - the method to fetch syscall arguments from
  usermode into struct syscall_args. The structure is machine-depended
  (this might be reconsidered after all architectures are converted).
sv_set_syscall_retval - the method to set a return value for usermode
  from the syscall. It is a generalization of
  cpu_set_syscall_retval(9) to allow ABIs to override the way to set a
  return value.
sv_syscallnames - the table of syscall names.

Use sv_set_syscall_retval in kern_sigsuspend() instead of hardcoding
the call to cpu_set_syscall_retval().

The new functions syscallenter(9) and syscallret(9) are provided that
use sv_*syscall* pointers and contain the common repeated code from
the syscall() implementations for the architecture-specific syscall
trap handlers.

Syscallenter() fetches arguments, calls syscall implementation from
ABI sysent table, and set up return frame. The end of syscall
bookkeeping is done by syscallret().

Take advantage of single place for MI syscall handling code and
implement ptrace_lwpinfo pl_flags PL_FLAG_SCE, PL_FLAG_SCX and
PL_FLAG_EXEC. The SCE and SCX flags notify the debugger that the
thread is stopped at syscall entry or return point respectively.  The
EXEC flag augments SCX and notifies debugger that the process address
space was changed by one of exec(2)-family syscalls.

The i386, amd64, sparc64, sun4v, powerpc and ia64 syscall()s are
changed to use syscallenter()/syscallret(). MIPS and arm are not
converted and use the mostly unchanged syscall() implementation.

Reviewed by:	jhb, marcel, marius, nwhitehorn, stas
Tested by:	marcel (ia64), marius (sparc64), nwhitehorn (powerpc),
	stas (mips)
MFC after:	1 month
2010-05-23 18:32:02 +00:00
Neel Natu
9f3b3fe64a - Use ptpgzone zone to allocate page table pages irrespective of the amount of
memory on a platform. Tested on the Sibyte with 256MB and 1GB memory
  configurations.

- Replace vtophys() with MIPS_KSEG0_TO_PHYS() to convert a page table
  page's virtual address to physical. We can safely do this because
  page table pages are allocated out of KSEG0.

- Add an assertion to verify that when a page table page is freed it
  contains all zeroes. We can now use it after allocation without
  zeroing it.
2010-05-22 21:38:57 +00:00
John Baldwin
e826ef1ec4 - Adjust the whitespace for the lines that output fields in 'show pcpu' in
DDB so that all the fields line up.
- Print out the tid of the per-CPU idlethread instead of the pid since
  the idle process is now shared across all idle threads.

MFC after:	1 month
2010-05-21 17:17:56 +00:00
Jayachandran C.
1a9950f319 Changes to boot on a subset of threads on an XLR/XLS core.
- Adds re-partitioning TLB per core for enabled threads.
- Adds hardware thread id to cpuid mapping
- updates rge driver packet distribution and message ring handling
  threads to be started based on hardware thread id.
- remove unused early debugging code to set control registers.
- coding style fixes

Approved by:	rrs (mentor)
2010-05-21 05:34:19 +00:00
Rui Paulo
fae088e873 Add a device description. 2010-05-18 17:01:07 +00:00
Neel Natu
c0fd703892 Fix Sibyte SMP kernel breakage caused by r208249.
We need to include the header file that provides declaration of the
smp_topo_none() function.
2010-05-18 05:12:54 +00:00
Randall Stewart
50e5b49dea Adds the file I forgot to add... that handles
the mpwait.S for RMI

Approved by:	JC
2010-05-18 04:08:58 +00:00
Randall Stewart
bc198428ea Adds JC's cleanup patches that fix it so
we call an platform dependant topo function as
well as clean up all the XLR specific ifdefs around
smp platform init.

Obtained from:	JC
2010-05-18 04:02:34 +00:00
Alan Cox
9ab6032f73 On entry to pmap_enter(), assert that the page is busy. While I'm
here, make the style of assertion used by pmap_enter() consistent
across all architectures.

On entry to pmap_remove_write(), assert that the page is neither
unmanaged nor fictitious, since we cannot remove write access to
either kind of page.

With the push down of the page queues lock, pmap_remove_write() cannot
condition its behavior on the state of the PG_WRITEABLE flag if the
page is busy.  Assert that the object containing the page is locked.
This allows us to know that the page will neither become busy nor will
PG_WRITEABLE be set on it while pmap_remove_write() is running.

Correct a long-standing bug in vm_page_cowsetup().  We cannot possibly
do copy-on-write-based zero-copy transmit on unmanaged or fictitious
pages, so don't even try.  Previously, the call to pmap_remove_write()
would have failed silently.
2010-05-16 23:45:10 +00:00
Randall Stewart
4542827d4d This pushes all of JC's patches that I have in place. I
am now able to run 32 cores ok.. but I still will hang
on buildworld with a NFS problem. I suspect I am missing
a patch for the netlogic rge driver.

JC check and see if I am missing anything except your
core-mask changes

Obtained from:	JC
2010-05-16 19:43:48 +00:00
Warner Losh
be73c87b5c Remove some stray ';'s
Submitted by:	marc balmer
2010-05-13 01:50:29 +00:00
Alan Cox
3c4a24406b Push down the page queues into vm_page_cache(), vm_page_try_to_cache(), and
vm_page_try_to_free().  Consequently, push down the page queues lock into
pmap_enter_quick(), pmap_page_wired_mapped(), pmap_remove_all(), and
pmap_remove_write().

Push down the page queues lock into Xen's pmap_page_is_mapped().  (I
overlooked the Xen pmap in r207702.)

Switch to a per-processor counter for the total number of pages cached.
2010-05-08 20:34:01 +00:00
Alan Cox
d238560c7c Eliminate dead code. 2010-05-06 04:23:52 +00:00
Neel Natu
7ee44a58d7 Fix DDB backtrace involving kernel modules.
We can no longer assume that all valid program counter values reside
within the kernel object file.
2010-05-05 04:37:45 +00:00
Maxim Sobolev
e50d35e6c6 Add new tunable 'net.link.ifqmaxlen' to set default send interface
queue length. The default value for this parameter is 50, which is
quite low for many of today's uses and the only way to modify this
parameter right now is to edit if_var.h file. Also add read-only
sysctl with the same name, so that it's possible to retrieve the
current value.

MFC after:	1 month
2010-05-03 07:32:50 +00:00
Marius Strobl
f6ffc3c26b Remove redundant checking of sc_leaving (uart_intr() already handles this).
Approved by:	marcel
2010-05-02 19:07:19 +00:00
Warner Losh
a932985f50 Enable AH_RXCFG_SDMAMW_4BYTES option. See NOTES file for why this is
workaround (WAR) is needed.
2010-05-01 16:39:46 +00:00
Warner Losh
7e005410db Put the -current debugging options back into AR71XX. 2010-05-01 16:38:40 +00:00
Randall Stewart
ad30c76f94 Bug in the memory mapping module. The wrong
physaddr was being used in the macro (1 should be
used not 2)...

Obtained from:	JC
2010-04-30 17:12:20 +00:00
Kip Macy
2965a45315 On Alan's advice, rather than do a wholesale conversion on a single
architecture from page queue lock to a hashed array of page locks
(based on a patch by Jeff Roberson), I've implemented page lock
support in the MI code and have only moved vm_page's hold_count
out from under page queue mutex to page lock. This changes
pmap_extract_and_hold on all pmaps.

Supported by: Bitgravity Inc.

Discussed with: alc, jeffr, and kib
2010-04-30 00:46:43 +00:00
Alan Cox
030d4cda77 Adapt i386 r207205 to mips: Clearing PV_TABLE_REF and setting the page's
PG_REFERENCED flag in pmap_protect() can't really be justified, so don't
do it.
2010-04-28 04:25:36 +00:00
Konstantin Belousov
8bac98182a Style: use #define<TAB> instead of #define<SPACE>.
Noted by:	bde, pluknet gmail com
MFC after:	11 days
2010-04-27 09:48:43 +00:00
Alan Cox
7b85f59183 Resurrect pmap_is_referenced() and use it in mincore(). Essentially,
pmap_ts_referenced() is not always appropriate for checking whether or
not pages have been referenced because it clears any reference bits
that it encounters.  For example, in mincore(), clearing the reference
bits has two negative consequences.  First, it throws off the activity
count calculations performed by the page daemon.  Specifically, a page
on which mincore() has called pmap_ts_referenced() looks less active
to the page daemon than it should.  Consequently, the page could be
deactivated prematurely by the page daemon.  Arguably, this problem
could be fixed by having mincore() duplicate the activity count
calculation on the page.  However, there is a second problem for which
that is not a solution.  In order to clear a reference on a 4KB page,
it may be necessary to demote a 2/4MB page mapping.  Thus, a mincore()
by one process can have the side effect of demoting a superpage
mapping within another process!
2010-04-24 17:32:52 +00:00
Konstantin Belousov
ed7806879b Move the constants specifying the size of struct kinfo_proc into
machine-specific header files. Add KINFO_PROC32_SIZE for struct
kinfo_proc32 for architectures providing COMPAT_FREEBSD32. Add
CTASSERT for the size of struct kinfo_proc32.

Submitted by:	pluknet
Reviewed by:	imp, jhb, nwhitehorn
MFC after:	2 weeks
2010-04-24 12:49:52 +00:00
Juli Mallett
07b9cc2f46 Most MIPS systems have a comparatively-sparse physical memory layout. Switch
to using the sparse physseg layout in the VM system.
2010-04-24 03:11:35 +00:00
Juli Mallett
c805ff09d5 Build some nops into CLEAR_STATUS here to make sure that the following
instructions can't be interrupted.
2010-04-23 19:48:31 +00:00
Juli Mallett
38f836dbb3 o) Remove default MAXMEM on SWARM; pmap can readily use lmem for >512M
physical addresses.
o) Set a local maxmem in sb_machdep.c to avoid trying to use pages over 2^64
   under 32-bit ABIs.  Our pmap needs corrected to use vm_paddr_t consistently,
   then we can make vm_paddr_t 64-bit under 32-bit ABIs and add code in pmap
   to limit phys_avail by the maximum PFN that a 32-bit PTE can hold.
2010-04-23 19:20:56 +00:00
Juli Mallett
562d4fbb7c Large memory mappings are always CPU local and always done with interrupts
disabled.  Be doubly-sure that we don't try to do a TLB shootdown on SMP
systems for those mappings.

Submitted by:	C. Jayachandran
2010-04-23 18:53:17 +00:00
Neel Natu
efa50b120d Fix compilation error.
tick.c:298:5: error: "KDTRACE_HOOKS" is not defined
2010-04-23 01:34:01 +00:00
Andrew Thompson
b850ecc180 Change USB_DEBUG to #ifdef and allow it to be turned off. Previously this had
the illusion of a tunable setting but was always turned on regardless.

MFC after:	1 week
2010-04-22 21:31:34 +00:00
Rui Paulo
0017771c68 Add the necessary hooks for dtrace cyclic module. 2010-04-20 17:22:20 +00:00
Rui Paulo
153bfab76a Remove svn:executable prop. 2010-04-20 10:42:08 +00:00
Juli Mallett
fe7d6b6e69 Fix MALTA64 build. 2010-04-19 09:03:34 +00:00
Juli Mallett
540247e8c1 Remove unused file. 2010-04-19 07:51:57 +00:00
Juli Mallett
745bba1ab0 o) Eliminate the "stand" frame and its use. Use CALLFRAME_* everywhere.
o) Use <machine/asm.h> macros for register-width, etc., rather than doing it
   by hand in a few more assembly files.
o) Reduce diffs between various bits of TLB refill code in exception.S and
   between interrupt processing code.
o) Use PTR_* to operate on registers that are pointers (e.g. sp).
o) Add and use a macro, CLEAR_PTE_SWBITS rather than using the
   mysteriously-named WIRED_SHIFT to select bits to truncate when loading PTEs.
o) Don't doubly disable interrupts by moving zero to the status register,
   especially since that has the nasty side-effect of taking us out of 64-bit
   mode.
o) Use CLEAR_STATUS to disable interrupts the first time.
o) Keep SR_PX set as well as SR_[KSU]X when doing exception processing.  This
   is the bit that determines whether 64-bit operations are allowed.
o) Don't enable interrupts until configure_final(), like most other ports.
2010-04-19 07:34:26 +00:00
Juli Mallett
5f3173b517 o) Fix XKPHYS physical address extraction. Also define cache coherency
attributes for XKPHYS.
o) Make coprocessor 0 accessor function macros for register+selector registers
   take the full name so that e.g. (as done in this commit), prid selector 1
   can be written through mips_wr_ebase() rather than mips_wr_prid1().
o) Allow for sign extension of 32-bit segment addresses.
o) Remove an unused MIPS-I register number.
2010-04-19 06:01:58 +00:00
Juli Mallett
ca596a25f0 o) Add a VM find-space option, VMFS_TLB_ALIGNED_SPACE, which searches the
address space for an address as aligned by the new pmap_align_tlb()
   function, which is for constraints imposed by the TLB. [1]
o) Add a kmem_alloc_nofault_space() function, which acts like
   kmem_alloc_nofault() but allows the caller to specify which find-space
   option to use. [1]
o) Use kmem_alloc_nofault_space() with VMFS_TLB_ALIGNED_SPACE to allocate the
   kernel stack address on MIPS. [1]
o) Make pmap_align_tlb() on MIPS align addresses so that they do not start on
   an odd boundary within the TLB, so that they are suitable for insertion as
   wired entries and do not have to share a TLB entry with another mapping,
   assuming they are appropriately-sized.
o) Eliminate md_realstack now that the kstack will be appropriately-aligned on
   MIPS.
o) Increase the number of guard pages to 2 so that we retain the proper
   alignment of the kstack address.

Reviewed by:	[1] alc
X-MFC-after:	Making sure alc has not come up with a better interface.
2010-04-18 22:32:07 +00:00
Rui Paulo
685b0bb814 Delete svn:executable prop. 2010-04-18 18:43:36 +00:00
Juli Mallett
a27e66e8f5 o) Make pcb_onfault a pointer rather than an obscure integer value.
o) Mask off PAGE_MASK bits in pmap_update_page, etc., rather than modifying the
   badvaddr in trapframe.  Some nearby interfaces already did this.
o) Make PTEs "unsigned int" for now, not "unsigned long" -- we are only ready
   for them to be 32-bit on 64-bit platforms.
o) Rather than using pmap_segmap and calculating the offset into the page table
   by hand in trap.c, use pmap_pte().
o) Remove unused quad_syscall variable in trap.c.
o) Log things for illegal instructions like we do for bad page faults.
o) Various cast cleanups related to how to print registers.
o) When logging page faults, show the page table information not just for the
   program counter, but for the fault address.
o) Modify support.S to use ABI-neutral macros for operating on pointers.
o) Consistently use CALLFRAME_SIZ rather than STAND_FRAME_SIZE, etc.
o) Remove unused insque/remque functions.
o) Remove some coprocessor 0 accessor functions implemented in assembly that
   are unused and have inline assembly counterparts.
2010-04-17 09:42:07 +00:00
Juli Mallett
2ab78e3ca5 o) Add NPDEPG, like NPTEPG but for PDEs.
o) Remove NBPG, PGOFSET and PGSHIFT.  Use the standard names.
o) Remove some unused macros and move things from param.h to vmparam.h that
   belong in the latter.  (Actually, all of the kernel segment values, virtual
   addresses, etc., belong in one place, but this is a step in the right
   direction.)
2010-04-17 07:20:01 +00:00
Juli Mallett
b6777295a6 o) Add SMP support for Octeon using U-Boot to launch all the processors at the
same time.
o) Remove some unused trivial uart functions from octeon_machdep now that the
   uart part is fully working and they are unused.
o) Use __func__ instead of __FUNCTION__.
o) Use intr_*() instead of other routines that do the same thing.
o) Remove some duplicate printfs from the Octeon port, as well as duplicate
   setting of Maxmem.
o) Use the right frequency divider on Octeon.
o) Use PCPU_GET(cpuid) consistently to get the cpuid of the running core.
o) Remove some unused macros in the Octeon port.
o) Use mips_sync() around use of the global dpcpu, whose value may not be
   visible to APs at first.
o) When loading the first thread's stack, use macros to make the code correct
   for n64 as well.
o) Remove stub, do-nothing FAU init/enable/disable functions from the RGMX
   driver.
2010-04-17 03:08:13 +00:00
Juli Mallett
a97a1ee3d9 o) Back out my previous change to SWARM; some of it was to address an issue
that turned out to be unrelated, and the rest was, as pointed out by Neel,
   just wrong-headed.
o) Tweak mem.c to fix use of /dev/kmem for direct-mapped addresses.
2010-04-17 01:49:50 +00:00
Juli Mallett
b92f01b79c o) Use inline functions to access coprocessor 0 registers rather than external
ones implemented using assembly.
o) Use TRAPF_USERMODE() consistently rather than USERMODE().  Eliminate
   <machine/psl.h> as a result.
o) Use intr_*() rather than *intr(), consistently.
o) Use register_t instead of u_int in some trap code.
o) Merge some more endian-related macros to machine/asm.h from NetBSD.
o) Add PTR_LI macro, which loads an address with the correct sign-extension for
   a pointer.
o) Restore interrupts when bailing out due to an excessive IRQ in
   nexus_setup_intr().
o) Remove unused functions from psraccess.S.
o) Enter temporary virtual entries for large memory access into the page tables
   rather than simply hoping they stay resident in the TLB and we don't need to
   do a refill for them.
o) Abstract out large memory mapping setup/teardown using some macros.
o) Do mips_dcache_wbinv_range() when using temporary virtual addresses just
   like we do when we can use the direct map.
2010-04-17 01:17:31 +00:00
Juli Mallett
e586cf9a28 o) Remove code related to VM_ALLOC_WIRED_TLB_PG_POOL, VM_KERNEL_ALLOC_OFFSET
and floating pages.  They are unused and unsupported.
2010-04-17 00:05:22 +00:00
Juli Mallett
2ae5ecf8a2 Adjust limits and formats for ABIs with 64-bit longs. 2010-04-16 23:54:56 +00:00
Juli Mallett
11484eb34f o) Use the direct map where possible for uiomove_fromphys, based on code from
sparc64.
o) Use uiomove_fromphys rather than the broken fpage mechanism for /dev/mem.
o) Update sf_buf allocator to not share buffers and to do a pmap_qremove when
   done with an sf_buf so as to better track valid mappings.
2010-04-16 23:48:28 +00:00
Juli Mallett
d0985cfb41 o) Fix the intr_* functions to not spam the whole status register, just the IE
bit.
o) Remove some unused inlines.
o) Generate CP0 access functions for 64-bit TLB registers when building for
   n64.
o) Add an inline function version of the COP0_SYNC macro.
2010-04-16 23:46:30 +00:00
Juli Mallett
4e859425ae Set KERNLOADADDR and TARGET_BIG_ENDIAN for SWARM. 2010-04-16 23:42:19 +00:00
Juli Mallett
4076170459 Remove some unused header files. 2010-04-16 02:56:24 +00:00
Neel Natu
923ca9167b Destroy the pmap 'pm_mutex' in pmap_release() otherwise we will panic
subsequently in pmap_pinit() with the following signature:

panic: lock "pmap" 0xc7878bc8 already initialized

This bug was uncovered by the changes made to vm_map.c in r206140.
2010-04-14 01:57:53 +00:00
Neel Natu
0a5cd2607a Revert the vm_machdep.c part of r205072.
This causes a panic in vm_thread_dispose() when it tries to add this kstack
to the kstack cache. This happens only when 'td_kstack' is not (PAGE_SIZE * 2)
bytes aligned and we have unmapped the page at that address in cpu_thread_alloc.

Pointed out by: nwhitehorn@
2010-04-14 01:29:31 +00:00
Nathan Whitehorn
ad723e42a4 Fix a bug where bus_dma_load_xxx() would not bounce misaligned buffers
due to rounding the buffer's physical address to the beginning of its
page. This fixes a panic in arge(4) when using PPPoE.

Reported by:	Jakob van Santen <vansanten at wisc dot edu>
Reviewed by:	gonzo
Obtained from:	amd64
2010-04-09 01:14:11 +00:00
Warner Losh
b938b7a366 Add BUS_SPACE_UNRESTRICTED and define it to be ~0, just like all the
other platforms.
2010-04-08 19:34:55 +00:00
Oleksandr Tymoshenko
d51a8afbfe - Fix mutex type for miibus_mtx: it's not spinlock, it's def lock 2010-04-08 18:32:13 +00:00
Warner Losh
cd1c19dd7b Enable module builds now that the build completes for them. This
should get them into the universe rotation.
2010-03-29 22:03:55 +00:00
Neel Natu
bfd506a024 Replace sb_store64()/sb_load64() with mips3_sd()/mips3_ld() respectively.
Obtained from NetBSD.

Suggested by: jmallett@
2010-03-26 07:15:27 +00:00
Nathan Whitehorn
a107d8aac9 Change the arguments of exec_setregs() so that it receives a pointer
to the image_params struct instead of several members of that struct
individually. This makes it easier to expand its arguments in the future
without touching all platforms.

Reviewed by:	jhb
2010-03-25 14:24:00 +00:00
Neel Natu
b5f18aa6da Fix periodic "t_delta 16.01359db7eb5eb3c0 too long" messages on the console by
accounting for the "lost time" between when the timer interrupt fired
and when clock_intr() actually started executing.
2010-03-24 04:52:15 +00:00
Neel Natu
69a5a0bfea Sibyte provides a 64-bit read-only counter that counts at half the processor
frequency. This counter can be accessed coherently from both cores.

Use this as the preferred timecounter for the SWARM kernels.

The CP0 COUNT register is unusable as the timecounter on SMP platforms because
the COUNT registers on different CPUs are not guaranteed to be in sync.
2010-03-20 05:49:06 +00:00
Neel Natu
293f20dffb Make sure that the registers 'v0' and 'v1' are properly sign-extended
when sb_load64() returns.

Some 32-bit arithmetic operations (e.g. subu) have unpredicatable results
when operating on 64-bit registers that are not properly sign-extended.
2010-03-20 05:21:14 +00:00
Neel Natu
cf4459fb01 Get rid of unused macro MIPS_MEM_RID.
Suggested by: Alexandr Rybalko (ray@dlink.ua)
2010-03-20 05:10:44 +00:00
Neel Natu
de88808f0a This change enables use of physical memory that is beyond the direct
mapped kseg0 region.

The basic idea is to use KVA from the kseg2 region for mapping page
table pages that lie beyond the direct mapped region.

The TLB miss handler can now recursively fault into the TLB invalid
handler if it dereferences a kseg2 page table page address that is not
in the TLB.

Tested by: JC (c.jayachandran@gmail.com)
2010-03-20 05:07:15 +00:00
Warner Losh
560da96e36 Go ahead and add USB support to the generic config. 2010-03-14 19:04:42 +00:00
Juli Mallett
0c7964a064 o) Use octeon_fpa_alloc_phys in a situation in which we don't need a usable
pointer, rather than octeon_fpa_alloc.
o) Report half duplex status properly.
o) Do not unconditionally update the last known link status in the softc.  If
   report_link isn't set, when octeon_rgmx_config_speed is called the first
   time it will tell the driver (essentially) that we have already marked the
   interface up.  Likewise, don't change media speed and duplex if only the
   link status is at issue. [1]
o) Remove manual changing of link state and let octeon_rgmx_config_speed do the
   heavy lifting. [1]

Reviewed by:	[1] imp
Sponsored by:	Packet Forensics
2010-03-13 04:55:47 +00:00
Neel Natu
28b49236be - Enable kernel stack guard page.
- Unmap the unused kernel stack page that we cannot use because it is
  not aligned on a (PAGE_SIZE * 2) boundary.
2010-03-12 07:08:20 +00:00
Neel Natu
2200b28e5f Make the ddb command "show tlb" SMP friendly.
It now accepts an argument to dump out the tlb of a particular cpu.
2010-03-12 03:49:17 +00:00
Juli Mallett
f1112d2f47 o) Send packets being queued for transmission up to BPF if there's a listener.
o) Properly configure the CAM to handle IFF_PROMISC and note where IFF_ALLMULTI
   handling would go if we didn't already force the NIC to receive all
   multicast traffic.

Reviewed by:	imp
Sponsored by:	Packet Forensics
2010-03-12 02:56:45 +00:00
Juli Mallett
56c96c364e Add bpf and random to Octeon configurations, since they're needed to run
dhclient and ssh respectively.

Reviewed by:	imp
2010-03-11 22:29:45 +00:00
Juli Mallett
9b98f51885 Don't force single user on Octeon anymore. 2010-03-11 22:25:53 +00:00
Juli Mallett
58d4fd1fdc o) Eliminate use of sc->typestr, which is always NULL.
o) Inline octeon_rgmx_mark_ready into octeon_rgmx_init.
o) Add a media status handler that reports link and media status.
o) Set link state when if_init is called.
o) Remove some printfs related to driver state changes.
o) Remove some gratuitous comments.

Reviewed by:	imp
Sponsored by:	Packet Forensics
2010-03-11 22:22:06 +00:00
Neel Natu
6575ad7619 Stash the context of the running thread at the time an IPI_STOP is received
in 'stoppcbs[]'. We use the 'stoppcbs[]' context to generate the backtrace
of such stopped threads.
2010-03-11 07:17:14 +00:00
Juli Mallett
89cb44523c Check for device faults and for failures to set DRQ when expected, rather
than spinning forever.  This fixes booting with CF ejected.

NB: I've made the driver pretty chatty about errors in case there's hardware
    that operates differently to mine, so we can easily track down any issues.

Reviewed by:	imp
Sponsored by:	Packet Forensics
2010-03-06 05:49:15 +00:00
Juli Mallett
7d018a5c91 o) Consistently use MIPS_KSEGn_TO_PHYS instead of MIPS_{,UN}CACHED_TO_PHYS etc.
Get rid of the macros that spell KSEG0 CACHED and KSEG1 UNCACHED.
o) Get rid of some nearby duplicated and unused macros.

Reviewed by:	imp
2010-03-06 05:45:49 +00:00
Juli Mallett
9fabafd18a o) Simplify the implementation of bus read/write functions, and eliminate some
redundant implementations.
o) Use ABI, not ISA, to determine address length.
o) Disable and restore interrupts around any operation that uses all 64 bits of
   a register.  In kernels using the O32 ABI, the upper 32 bits of those
   registers is likely to be corrupted by an interrupt.

Sponsored by:	Packet Forensics
2010-03-05 22:48:34 +00:00
Juli Mallett
54e3435255 Properly detect a type of real board that claims to have a 0.0 revision.
This fixes at least memory detection on that board.

Sponsored by:	Packet Forensics
2010-03-05 22:46:11 +00:00
Juli Mallett
e0be9e6857 Do not mask off the low byte of the chipid, it makes some of the case
statements unreachable and seems to be wrong.  Fixes detection of the number
of ports available on some models.

Sponsored by:	Packet Forensics
2010-03-05 22:44:49 +00:00
Neel Natu
cefb7b77f8 Remove some unused cruft. 2010-03-04 05:37:19 +00:00
Neel Natu
6be470c077 Add support for CPUs with cache coherent DMA. The two main changes are:
- We don't need to fall back to uncacheable memory to satisfy BUS_DMA_COHERENT
  requests on these CPUs.

- The bus_dmamap_sync() is a no-op for these CPUs.

A side-effect of this change is rename DMAMAP_COHERENT flag to
DMAMAP_UNCACHEABLE. This conveys the purpose of the flag more accurately.

Reviewed by: gonzo, imp
2010-03-04 05:23:08 +00:00
Warner Losh
f96d8241e6 Looks like S8 and SP are reversed in setjmp, so longjmp doesn't work
as well as one would hope....

Submitted by:	Arten Belevich
2010-03-03 21:28:55 +00:00
Joel Dahl
1edcf74de7 The NetBSD Foundation has granted permission to remove clause 3 and 4 from
the software.

Obtained from:	NetBSD
2010-03-03 17:55:51 +00:00
George V. Neville-Neil
660df75e8b Add support for hwpmc(4) on the MIPS 24K, 32 bit, embedded processor.
Add macros for properly accessing coprocessor 0 registers that
support performance counters.

Reviewed by:	jkoshy rpaulo fabien imp
MFC after:	1 month
2010-03-03 15:05:58 +00:00
Warner Losh
9be0746b5f Spell START_FRAME CALLFRAME_SIZ now. 2010-03-03 02:46:36 +00:00
Randall Stewart
6b9c94873a - Move rmi_pci_bus_space to header and avoid extern
- remove unused and commented code (MIPS_BUS_SPACE_PCI, pic_usb_ack)
- use rmi_pci_bus_space for USB too (needs byteswap)
- uncomment xls_ehci.c in files.xlr
- changes to xls_ehci.c - updated with dev/usb/controller/ehci_*.c as

Obtained from:	JC - c.jayachandran@gmail.com
2010-03-02 12:11:00 +00:00
Warner Losh
efb8ec3eb7 Update macros for multiple ABI support from NetBSD.
Also update SZREG define in ucontext
2010-03-02 07:27:30 +00:00
Randall Stewart
fc8b40ff1c Fix another fo-pa of mine... duplicate patches should
not be applied and randy needs coffee in the morning
when working to help keep things sorted out... obviously :-)
2010-02-21 17:27:20 +00:00
Randall Stewart
7198148c8e Fix for the rge driver for boards without rge6 and rge7.
- changes to avoid adding theses instances on specific chips
Obtained from:	C. Jayachandran - JC - c.jayachandran@gmail.com
2010-02-20 17:24:33 +00:00
Randall Stewart
019ee9781a Changes for pci and pci-e support
- add bus_space_rmi_pci.c for PCI bus space
- files.xlr update for changes in files
- pcibus.c merged into xlr_pci.c (they were small files with inter-dependencies)
- xlr_pci.c - lot of changes here with few fixes, formatting cleanup
Obtained from:	C. Jayachandran (JC) - c.jayachandran@gmail.com
2010-02-20 17:19:16 +00:00
Randall Stewart
219c125a72 Opps forgot to add this:
- add bus_space_rmi_pci.c for PCI bus space

Obtained from:	C. Jayachandran -  <c.jayachandran@gmail.com>
2010-02-20 17:12:07 +00:00
Randall Stewart
ec1dd52fc8 Cleanups for sys/mips/rmi/bus_space_rmi.c
- remove pci related code from bus_space_rmi.c, we will have another
file for PCI bus space functions which will do byte-swapping.
- remove local SWAP implementation
- added TODO stub for unimplemented functions

Obtained from:	C. Jayachandran - c.jayachandran@gmail.com
2010-02-20 16:32:33 +00:00
Randall Stewart
0364c7f075 Some fixes to the current RMI interrupt handling, changes in this patch are:
- (cleanup) remove rmi specific 'struct mips_intrhand' - this is no
longer needed since 'struct intr_event' have all the required hooks
- add xlr_cpu_establish_hardintr, which has args for pre/post ithread
and filter hooks, so that the PCI code can add the PCI controller
interrupt ack code here
- make 'cpu_establish_hardintr' use the above function.
- (fix) change type of eirr/eimr from register_t to uint64_t. These
have to be 64bit otherwise we cannot handle interrupts from 32.
- (fix) use eimr to mask eirr before checking interrupts, so that we
will not handle masked interrupts.

Obtained from:  C. Jayachandran - c.jayachandran@gmail.com
2010-02-20 16:30:29 +00:00
Neel Natu
c03dee5d5b Fix DDB backtrace that includes a kernel exception frame.
The backtrace code tries to look for an instruction of the form "sw ra, x(sp)"
to figure out the program counter of the calling function. When we generate
the kernel exception frame we store the 'ra' at the time of the exception
using an instruction of the same form. The problem is that the 'ra' at the
time of the exception is not the same as the 'program counter' at the time
of the exception.

The fix is to save the 'exception program counter' register by staging
it through the 'ra' register.
2010-02-20 07:34:37 +00:00
Neel Natu
40e359dc3a Get rid of unused options: KERNPHYSADDR, KERNVIRTADDR, PHYSADDR, PHYS_ADDR_64BIT
Discussed with: gonzo, imp
2010-02-20 06:39:14 +00:00
Alexander Kabaev
779fea6010 Define DMA_RX_STATUS_OVERFLOW with correct value.
The RX overflow is reported in bit 2 on real hardware and Linux driver
for the same device already has this defined correctly.
This fixes frequent interrupt storms seen on RouterStation Pro boards.

Discussed with:	gonzo
2010-02-19 17:37:46 +00:00
Warner Losh
265deb36e6 Hack to make ALCHEMY compile again... 2010-02-18 19:41:38 +00:00
Warner Losh
a62e05a4e0 Make printfs work for both OCTEON1 and OCTEON1-32 2010-02-18 19:27:00 +00:00
Warner Losh
f976477f81 Parens around tertiary operator so that casting the result works... 2010-02-18 19:24:23 +00:00
Warner Losh
37b892b263 Use proper structure type for 64-bit headers
# this fixes the MALTA64 build
2010-02-18 19:02:33 +00:00
Neel Natu
6f3c632700 Kernel module support for mips.
Reviewed by: gonzo

Tested by: Alexandr Rybalko (ray@dlink.ua)
2010-02-18 05:49:52 +00:00
Neel Natu
f7bb996d92 Various fixes to get the SWARM config working on a big-endian Sibyte CPU.
Getting the little-endian PCI bus working on the big-endian CPU proved to be
quite challenging. We let the PCI devices be mapped in the "match byte lanes"
address window. This is where they are mapped by the CFE and DMA transfers
generated to or from addresses within this window are not subject to automatic
byte-swapping.

However any access by the driver to memory-mapped pci space is redirected
via the "match bit lanes" address window. We get the benefit of automatic
byte swapping through this address window and drivers don't need to change
to deal with CPU big-endianness.
2010-02-17 06:43:37 +00:00
Oleksandr Tymoshenko
f6951d3084 - Clean-up output of memory banks info 2010-02-16 00:08:42 +00:00
Attilio Rao
c1210a7d97 Adjust style (following the already existing rules) for the newly
introduced option DEADLKRES.

Reported by:	danfe, julian, avg
2010-02-15 23:44:48 +00:00
Neel Natu
9dcae110dc Remove the PCI_IOSPACE_SIZE and PCI_IOSPACE_ADDR hack from nexus.c. Implement
this in the Sibyte PCI hostbridge driver instead.

The nexus driver sees resource allocation requests for memory and irq
resources only. These are legitimate resources on all MIPS platforms.

Suggested by: imp
2010-02-12 02:59:49 +00:00
Attilio Rao
88cbfa852e Add the options DEADLKRES (introducing the deadlock resolver thread) in
the 'debugging' section of any HEAD kernel and enable for the mainstream
ones, excluding the embedded architectures.
It may, of course, enabled on a case-by-case basis.

Sponsored by:	Sandvine Incorporated
Requested by:	emaste
Discussed with:	kib
2010-02-10 16:30:04 +00:00
Randall Stewart
9518a2a361 If a mbuf is split across two pages, we
have code that detects this and makes two
transmit descriptors. However its possible
that the algorithm detects when the second
page is not used (when the data aligns perfectly
to the bottom of the page). This caused a 0
len descriptor to be added which locks up the
rge device. Skip such things with a continue.

JC provided this patch... Thanks JC :-)
Obtained from:	JC (c.jayachandran@gmail.com)
2010-02-10 13:48:34 +00:00
Neel Natu
bd43e0ce56 Code cleanup:
- make some variables static
- remove unused variables.
2010-02-10 06:57:05 +00:00
Neel Natu
73614b2316 Call profclock() and statclock() explicitly on all cpus. Prior to this
change these functions were called only on the BSP indirectly via hardclock().

top -P now shows usage statistics of all cpus.
2010-02-10 06:29:43 +00:00
Neel Natu
ed6933b252 Enable interrupts before doing AST processing to avoid a deadlock.
Specifically on an SMP kernel it was observed that if both the
processors are doing an exit1() via ast()->postsig()->sigexit()
then we will deadlock.

This happens because exit1() calls vmspace_exit() that in turn
calls pmap_invalidate_all(). This function tries to do a
smp_rendezvous() which blocks because the other processor is not
responding to IPIs - because it too is doing AST processing with
interrupts disabled.
2010-02-10 05:43:31 +00:00
Neel Natu
1d4fd9f5a8 SMP support for the mips port.
The platform that supports SMP currently is a SWARM with a dual-core Sibyte
processor. The kernel config file to use is SWARM_SMP.

Reviewed by: imp, rrs
2010-02-09 06:24:43 +00:00
Neel Natu
ca98449e12 Correct a comment - we are not setting the exception level but rather are
disabling interrupts.

Simplify register usage - we can directly load 'curpcb' into 'k1' after
interrupts are disabled. There is no need to do so indirectly through 'a1'.
2010-02-05 06:36:03 +00:00
Neel Natu
d3e24a4579 Initialize interrupt controller early on. 2010-02-05 03:22:04 +00:00
Neel Natu
c3f7e882dc Reimplement all functions to access the system control unit in C.
The only reason we need to have the sb_load64() and sb_store64()
functions in assembly is to cheat the compiler and generate the
'ld' and 'sd' instructions which it otherwise will not do when
compiling for a 32-bit architecture. There are some 64-bit
registers in the SCD unit that must be accessed using 64-bit
load and store instructions.
2010-02-05 03:20:47 +00:00
Neel Natu
c8f4860360 style: don't need to use braces for single line control statements. 2010-02-05 02:40:42 +00:00
Neel Natu
93db1e020b Compile SWARM with KTRACE support. 2010-02-04 06:44:42 +00:00
Neel Natu
ce735fb428 Get system call tracing using ktrace working for mips. 2010-02-04 06:42:30 +00:00
Neel Natu
674440a942 Clean up all places in exception.S that fiddle with 'pcpup' directly. We now
use the GET_CPU_PCPU() macro exclusively.

This isolates the users of pcpu data from its implementation details.

Reviewed by: imp
2010-02-04 05:25:59 +00:00
Neel Natu
ae50475f5d Reduce the size of the array used to store the TLB mappings for the kernel
stack from 3 to 2.

We only map in 2 pages for the kernel stack.

Approved by: imp (mentor)
2010-02-03 04:09:36 +00:00
Neel Natu
9dd3fbb0f2 Provide access to pcpu structures for SMP kernels.
The basic idea is to use a the same virtual address as a window onto
distinct physical memory locations - one per processor. The physical
address that you access through this mapping depends on which cpu you
are currently executing on. We can now use the same virtual address
on any processor to access its per-cpu area.

The details are:

- The virtual address for 'struct pcpu *pcpup' is obtained by
  stealing 2 pages worth of KVA in pmap_bootstrap().

- The mapping from the constant virtual address to a distinct
  physical page is done in cpu_pcpu_init() through a wired TLB entry.

- A side-effect of this is that we reserve 2 pages worth of memory
  for the pcpu but in reality it needs much less than that. The unused
  memory is now used as the boot stack for the BSP and APs.

Remove SMP-specific bits from locore.S. The plan is to use a separate
mpboot.S for AP bootstrap.

Discussed on: freebsd-mips

Approved by: imp (mentor)
2010-01-30 01:54:29 +00:00
Randall Stewart
e11f5db6ae Follow Neel's suggestion and switch to using
restoreint() in combination with saving off the
old level. That way we don't blast out the old
level.
2010-01-29 05:38:41 +00:00
Randall Stewart
0eaed6efad For our memory re-mapping trick to work
interrupts must be disabled through the
page_zero's or copys etc. Note that the
temporary mapping used by panic's may
cause us pain since int's may not be disabled.
When we get dumps working we may have to revist
this. Note that with this fix the build got
much much further.. until it hung on disk IO (I
would imagine thats the rge/msgring driver acting
up).
2010-01-29 04:07:38 +00:00
Randall Stewart
b8c910d9c7 Its possible that our RMI box has memory extending
above 4Gig. If so when we add the base address with
the size we will wrap. So for now we just ignore
such memory and only use what we can. When we
get 64 bit working then we will be much better ;->
2010-01-29 04:05:17 +00:00
Randall Stewart
d5455b8682 Move ID up into comment block.. per bsdimp 2010-01-29 04:03:36 +00:00
Oleksandr Tymoshenko
c1517c0df5 - Increase timeouts to 100 milliseconds, 1 millisecond is definitely not
enough for PCI controller to get into shape

Thanks to: adrian@
2010-01-28 21:55:56 +00:00
Warner Losh
fe36702132 Add Cavium's standard copyright to those files that are currently
lacking a copyright/license statement.  All these files were in the
Cavium FreeBSD source drop and appear to be written by Cavium (some
are nearly verbatim copies of files from the cnusers' 1.9.0 SDK, which
also uses this copyright).
2010-01-28 20:46:40 +00:00
Warner Losh
dd8b9d6300 We make it to single user well, but not so well to multi-user. Force
single user for the moment since that's a better experience for people
trying this code out...
2010-01-28 20:39:50 +00:00
Warner Losh
7f70425916 trim unused members of the softc. 2010-01-28 20:38:52 +00:00
Olivier Houchard
7bb6393c4f Comment out any reference to ALCHEMY.hints until it's committed, to unbreak
make universe.

Spotted out by:	gahr
2010-01-28 14:59:16 +00:00
Randall Stewart
e7017e7b1a Fix two of the extended memory hacks. The copy pages
routine in one place was setting the valid2 bit to
2 not 1. This meant the PTE was NOT valid and so
you would crash.

In Zero Page there was a incorrect setting of
the valid bit AFTER the actual zero (opps)..

Hopefully this will fix the 0xc0000000 crashes
that I have been seeing (unless of course there are
other problems with these old hacks of mine to get
to memory above 512Meg)
2010-01-28 14:09:16 +00:00
Randall Stewart
dcb38476b1 Adds additional hacks for proper bits so that
the RMI/XLR has the COP0 and COP2 bits enabled
Plus it needs SX too. Thanks again for JC in
catching this ;-)

Submitted by:	JC (jayachandranc@netlogicmicro.com
2010-01-28 14:03:06 +00:00
Randall Stewart
71913a3e36 Make compilable.. i.e. the FreeBSD id I added must
be in comments.
2010-01-28 14:01:47 +00:00
Randall Stewart
8a6f6fc9a7 Changes the msg ring so its a filter not a
handler. Somehow rrs missed this.. Thanks
to JC for catching this ;-)

Obtained from:	JC (jayachandranc@netlogicmicro.com
2010-01-28 14:01:16 +00:00
Alexander Kabaev
dbf6fb7226 Do not leave dirty cache lines behind if bus_dmamap_sync was called
to invalidate memory chunk that starts or ends in the middle of
cache line.

This was responsible for one half of the problem preventing umass
to work reliably on some MIPS32 platforms. USBng needs to stop
sharing cache lines between DMA-able memory and other structures
to cure the other half.

Discussed with: imp, gonzo
2010-01-27 17:15:17 +00:00
Warner Losh
1e027851aa Make a note that this file is the 64-bit version and experimental and
point people at the OCTEON1-32 file instead.
2010-01-27 16:21:32 +00:00
Warner Losh
44b945c904 Move back to physical address 0x01000000. 0x00100000 seems to have
problems sometimes for reasons I haven't tracked down.
2010-01-27 16:15:19 +00:00
Randall Stewart
0de4b0e622 Spacing changes in pic_ack and pic_delayed_ack 2010-01-26 14:33:57 +00:00
Randall Stewart
92a480b916 My current conf, that comes up but
locks up in make buildworld.

You need to follow the mips wiki for building
the nfs partition and setup things to mount there
(in the conf and in your bootp setup).
2010-01-26 05:17:03 +00:00
Randall Stewart
38c225d627 1) Make sure static is init'd to 0
2) In one place make sure we call the backup
   startup routine (from the timer).
2010-01-26 05:14:50 +00:00
Randall Stewart
e015b3b4f0 To prevent a LOR we need to pass in
a lock flag in the pic routines. In
some places we hold the pic lock, others
we do not.
2010-01-26 05:11:48 +00:00
Randall Stewart
21d18df712 Fix up the msg ring driver a bit tighter
so that we don't loose an interrupt which
we appeared to be doing.
2010-01-26 05:10:10 +00:00
Randall Stewart
7a46404742 Fixes setup of clock. It was not properly
initialized, thus backward time warnings
were being spewed to the console.
2010-01-26 05:07:41 +00:00
Neel Natu
d87b96dd84 Install the XTLB exception handler for Sibyte processors.
This is a workaround for the fact that the CFE is compiled as a 64-bit
application and therefore sets the SR_KX bit every time we call into
it (for e.g. console).

A TLB miss for any address above 0xc0000000 with the SR_KX bit set will
end up at the XTLB exception vector. We workaround this by copying the
standard TLB handler at the XTLB exception vector.

Approved by: imp (mentor)
2010-01-26 03:39:10 +00:00
Neel Natu
182003557b Add a DDB command "show trapframe" to dump out contents of the trapframe
specified by the first argument.

Approved by: imp (mentor)
2010-01-26 03:29:52 +00:00
Neel Natu
358be222bc Print the address of the base of the stackframe in DDB backtrace output.
Approved by: imp (mentor)
2010-01-26 03:24:11 +00:00
Warner Losh
3dae97d413 Doh. Remove extra pcpu initialization that I thought was needed, but
isn't needed since we moved all that into mips_pcpu0_init.
2010-01-26 02:39:14 +00:00
Neel Natu
49396cced3 Fix a problem seen when a new process was returning to userland
through fork_trampoline.

This was caused because we were clearing the SR_INT_IE and setting
SR_EXL bits of the status register at the same time. This meant
that if an interrupt happened while this MTC0 was making its way
through the pipeline the exception processing would see the
status register with SR_EXL bit set. This in turn would mean that
the COP_0_EXC_PC would not be updated so the return from exception
would be to an incorrect address.

It is easy to verify this fix by a program that forks in a loop
and the child just exits:

	while (1) {
	pid_t pid = vfork();
	if (pid == 0)
	       _exit(0);
	if (pid != -1)
	       waitpid(pid, NULL, 0);
	}

Also remove two instances where we set SR_EXL bit gratuitously in exception.S.

Approved by: imp (mentor)
2010-01-26 02:26:04 +00:00
Warner Losh
f17768d6df Export knowledge of the special bus space we use for the console to
obio.  Take advantage of the fact that obio only really supports uart
at the moment to use the uart bus tag always for IOPORT allocations.

# this needs to be redone to conform to FreeBSD standards and allow for
# additional drivers for SoC hardware to attach
2010-01-25 19:27:20 +00:00
Warner Losh
fe9df26a36 Turn on debugging on the fpa unit. Fix some printfs that were only
enabled for debugging.  This should be turned off before we release,
but we need it for the moment.
2010-01-25 19:25:21 +00:00
Warner Losh
98dfb6b77e Store the mutex in the correct location. Before, we were storing it
in the pcb at the td_lock offset, rather than in the struct thread at
the td_lock offset.  And we were storing a pointer to the old thread
rather than to the mutex.  Why this didn't always kill us, I'll never
know.

Fix an obsolete comment and update the prototype in the comments.
Also note what variables are in what registers since this function is
a little complex...

neel@ found this problem and proposed this fix.  This cures a number
of different problem reports out there, and gets us booting octeon to
the login prompt...

Submitted by:	neel@
Reviewed by:	rrs@, gonzo@
2010-01-25 19:01:38 +00:00