Commit Graph

751 Commits

Author SHA1 Message Date
Neel Natu
f978c8f2c3 - Consolidate the the cache coherence attribute definitions in a single place.
Adapted from Juli's changes to pte.h in the octeon branch:
  http://svn.freebsd.org/viewvc/base/user/jmallett/octeon/sys/mips/include/pte.h

- Set the KX and UX bits in the status register for n64 kernels.

Reviewed by:	jmallett
2010-08-07 01:49:44 +00:00
John Baldwin
d9d8d1449d Add a new ipi_cpu() function to the MI IPI API that can be used to send an
IPI to a specific CPU by its cpuid.  Replace calls to ipi_selected() that
constructed a mask for a single CPU with calls to ipi_cpu() instead.  This
will matter more in the future when we transition from cpumask_t to
cpuset_t for CPU masks in which case building a CPU mask is more expensive.

Submitted by:	peter, sbruno
Reviewed by:	rookie
Obtained from:	Yahoo! (x86)
MFC after:	1 month
2010-08-06 15:36:59 +00:00
Jayachandran C.
b1f19c11b6 Fix issue reported by alc :
MIPS doesn't really need to use atomic_cmpset_int() in situations like
 this because the software dirty bit emulation in trap.c acquires
 the pmap lock.  Atomics like this appear to be a carryover from i386
 where the hardware-managed TLB might concurrently set the modified bit.

Reviewed by:	alc
2010-08-06 09:25:42 +00:00
Jayachandran C.
a178ce03e1 Fix the issue reported by alc:
pmap_page_wired_mappings() counts the number of pv entries for the
 specified page that have the pv entry wired flag set to TRUE.
 pmap_enter() correctly initializes this flag.  However,
 pmap_change_wiring() doesn't update the corresponding pv entry flag,
 only the PTE.  So, the count returned by pmap_page_wired_mappings()
 will sometimes be wrong.

 In the short term, the best fix would be to eliminate the pv entry
 flag and use only the PTE.  That flag is wasting non-trivial memory.

Remove pv_wired flag, and use PTE flag to count the wired mappings.

Reviewed by:	alc
2010-08-06 07:32:33 +00:00
Neel Natu
3ca4a6cdd3 Remove redundant declaration of 'pcib_driver' class from sb_zbpci.c. This
causes a compilation error.

The declaration is provided by sys/dev/pci/pcib_private.h starting from r210864.
2010-08-06 07:03:22 +00:00
Neel Natu
d3c1485e8f Use a signed integer to hold the address of a register.
This does the right thing by sign extending the address when compiling for
the n64 abi.
2010-08-06 05:30:55 +00:00
Neel Natu
482287c6af uint64_t is 'unsigned long' in n64 build, so compiler is unhappy if the
format specifier in printf is "%llu".

Use "%ju" instead.
2010-08-06 05:24:41 +00:00
Oleksandr Tymoshenko
d8484ec681 - Add interrupts counter for PCI devices 2010-08-05 21:31:29 +00:00
Neel Natu
f49fde7faf Fix a race between clock_intr() and tick_ticker() when updating
'counter_upper' and 'counter_lower_last'. The race exists because
interrupts are enabled even though tick_ticker() executes in a
critical section.

Fix a bug in clock_intr() in how it updates the cached values of
'counter_upper' and 'counter_lower_last'. They are updated only
when the COUNT register rolls over. More interestingly it will *never*
update the cached values if 'counter_lower_last' happens to be zero.

Get rid of superfluous critical section in clock_intr(). There is no
reason to do this because clock_intr() executes in hard interrupt
context.

Switch back to using 'tick_ticker()' as the cpu ticker for Sibyte.

Reviewed by:	jmallett, mav
2010-08-05 04:59:54 +00:00
Jayachandran C.
442d536595 Add 3 level page tables for MIPS in n64.
- 32 bit compilation will still use old 2 level page tables
- re-arrange pmap code so that adding another level is easier
- pmap code for 3 level page tables for n64
- update TLB handler to traverse 3 levels in n64

Reviewed by:	jmallett
2010-08-04 14:12:09 +00:00
Jayachandran C.
cb5e82a0b4 ithd_name no longer defined, use td_name. Fix compile with KTR enabled. 2010-08-04 14:03:23 +00:00
Jayachandran C.
9ca746fb79 Use PTR_ADDU to change sp, so that it works for n64 too. 2010-07-31 19:13:08 +00:00
Jayachandran C.
dcd2709851 Use fuword32() to fetch instructions, this will work on both 32 and 64 bit
compilation.
2010-07-31 19:11:38 +00:00
Jayachandran C.
55bf3928c0 n64 support - enable UX bit in STATUS for kernel and userspace.
- enable UX in kernel start, and kernel entry
- keep UX flag in cpu_fork and cpu_set_upcall
- enable UX for userspace
2010-07-30 12:45:00 +00:00
Jayachandran C.
654969d149 MIPS n64 support - support kstack in XKSEG.
- enable KX on entry from user-space, we need KX set to save to XKSEG
  addresses.
- add MIPS_XKSEG_START to genassym.c
- Add n64 case for swth.S
2010-07-30 09:38:47 +00:00
Jayachandran C.
42963f5a48 Update rge driver for 64 bit kernel.
- stored virtual addresses should be 64bit
- physical memory can be directly accessed using XKPHYS pointers in 64 bit.
- no need to enable KX
2010-07-29 20:41:40 +00:00
Jayachandran C.
fbbf115e35 Prepare for 3 level page tables for MIPS.
- Move page table second level shift and mask to param.h
- rename SEGOFSET to SEGMASK
- fix values for 64 bit maximum kernel and user addresses.
2010-07-29 20:02:56 +00:00
Jayachandran C.
a9ec9e9b03 Add fuiword() in n64 for completeness. 2010-07-29 19:47:15 +00:00
Jayachandran C.
9f91a43769 MIPS 64 bit support. Define fuword64() for n64 compilation, fuword() should
be fuword64() in 64 bit.
2010-07-29 19:14:06 +00:00
Jayachandran C.
56e6260883 Update MIPS _stdint.h for 64 bit. Initial 64 bit changes for profile.h. 2010-07-29 14:04:29 +00:00
Jayachandran C.
63ba49fd5f Fix RQB_FFS for 64 bit, we need to use ffsl() for 64bit.
Use 'ifdef __mips_n64' instead of 'if defined' to be consistant with other
usage.
2010-07-29 13:52:46 +00:00
Neel Natu
2a3232d9d6 Fix build for o32 kernels.
The emulation of 'ld' and 'sd' instructions only works for ABIs that support
64-bit registers and the instructions 'ldl' and 'ldr' that operate on those
registers.

Reviewed by:	jmallett
2010-07-29 05:14:59 +00:00
Juli Mallett
864ec37f39 o) Subtract 64K from the default userland stack pointer. GCC generate code
that with a 32-bit ABI on a system with 64-bit registers can attempt to
   access an invalid (well, kernel) memory address rather than the intended
   user address for stack-relative loads and stores.  Lowering the stack
   pointer works around this. [1]
o) Make TRAP_DEBUG code conditional on the trap_debug variable.  Make
   trap_debug default to 0 instead of 1 now but make it possible to change it
   at runtime using sysctl.
o) Kill programs that attempt an unaligned access of a kernel address.  Note
   that with some ABIs, calling useracc() is not sufficient since the register
   may be 64-bit but vm_offset_t is 32-bit so a kernel address could be
   truncated to what looks like a valid user address, allowing the user to
   crash the kernel.
o) Clean up unaligned access emulation to support unaligned 16-bit and 64-bit
   accesses.  (For 16-bit accesses it was checking for user access to too much
   memory (4 bytes) and there was no 64-bit support.)  This still lacks support
   for unaligned load-linked and store-conditional.

Reviewed by:	[1] gonzo
2010-07-29 02:32:21 +00:00
John Baldwin
a3870a1826 Very rough first cut at NUMA support for the physical page allocator. For
now it uses a very dumb first-touch allocation policy.  This will change in
the future.
- Each architecture indicates the maximum number of supported memory domains
  via a new VM_NDOMAIN parameter in <machine/vmparam.h>.
- Each cpu now has a PCPU_GET(domain) member to indicate the memory domain
  a CPU belongs to.  Domain values are dense and numbered from 0.
- When a platform supports multiple domains, the default freelist
  (VM_FREELIST_DEFAULT) is split up into N freelists, one for each domain.
  The MD code is required to populate an array of mem_affinity structures.
  Each entry in the array defines a range of memory (start and end) and a
  domain for the range.  Multiple entries may be present for a single
  domain.  The list is terminated by an entry where all fields are zero.
  This array of structures is used to split up phys_avail[] regions that
  fall in VM_FREELIST_DEFAULT into per-domain freelists.
- Each memory domain has a separate lookup-array of freelists that is
  used when fulfulling a physical memory allocation.  Right now the
  per-domain freelists are listed in a round-robin order for each domain.
  In the future a table such as the ACPI SLIT table may be used to order
  the per-domain lookup lists based on the penalty for each memory domain
  relative to a specific domain.  The lookup lists may be examined via a
  new vm.phys.lookup_lists sysctl.
- The first-touch policy is implemented by using PCPU_GET(domain) to
  pick a lookup list when allocating memory.

Reviewed by:	alc
2010-07-27 20:33:50 +00:00
Jayachandran C.
257ee8a425 mips/rmi/bus_space_rmi_pci.c is needed even when PCI is disabled. This
file really provides a bus that does byteswapping, and can be used by
non-PCI components too.
2010-07-27 19:31:10 +00:00
Jayachandran C.
ee37b5e791 The changes in r210542 moved setting counter_upper and counter_lower_last
outside the critical section - fix that.

Reported by:	mav
2010-07-27 17:33:51 +00:00
Jayachandran C.
707fd442af The count/compare values have to be tracked per CPU.
Reviewed by:	mav
2010-07-27 15:10:05 +00:00
Jayachandran C.
135fcc6da0 Fixup mips/rmi for the new mips timer code(r210403). This will get XLR
booting again.

The code is a copy of the mips/mips/tick.c with minor modifications for
XLR interrupt handling. Disable mips/rmi/clock.c for now, the PIC based
timer code will be added later.
2010-07-27 09:22:41 +00:00
Warner Losh
5343524a9e Get N64 building by defining VM_FREELIST_DIRECT to be
VM_FREELIST_DEFAULT.  I believe this is correct, since KX is set in
n64, and thus all RAM can be direct mapped.
2010-07-25 04:19:05 +00:00
Alexander Motin
a6cca5d8a1 Add some comments. 2010-07-23 08:20:14 +00:00
Alexander Motin
44d1534122 Update MIPS timer code (except RMI) to utilize new MI event timer
infrastructure.

Reviewed by:	neel
2010-07-23 07:46:55 +00:00
Jayachandran C.
49ca10d40c Redo the page table page allocation on MIPS, as suggested by
alc@.

The UMA zone based allocation is replaced by a scheme that creates
a new free page list for the KSEG0 region, and a new function
in sys/vm that allocates pages from a specific free page list.

This also fixes a race condition introduced by the UMA based page table
page allocation code. Dropping the page queue and pmap locks before
the call to uma_zfree, and re-acquiring them afterwards  will introduce
a race condtion(noted by alc@).

The changes are :
- Revert the earlier changes in MIPS pmap.c that added UMA zone for
page table pages.
- Add a new freelist VM_FREELIST_HIGHMEM to MIPS vmparam.h for memory that
is not directly mapped (in 32bit kernel). Normal page allocations will first
try the HIGHMEM freelist and then the default(direct mapped) freelist.
- Add a new function 'vm_page_t vm_page_alloc_freelist(int flind, int
order, int req)' to vm/vm_page.c to allocate a page from a specified
freelist. The MIPS page table pages will be allocated using this function
from the freelist containing direct mapped pages.
- Move the page initialization code from vm_phys_alloc_contig() to a
new function vm_page_alloc_init(), and use this function to initialize
pages in vm_page_alloc_freelist() too.
- Split the  function vm_phys_alloc_pages(int pool, int order) to create
vm_phys_alloc_freelist_pages(int flind, int pool, int order), and use
this function from both vm_page_alloc_freelist() and vm_phys_alloc_pages().

Reviewed by:	alc
2010-07-21 09:27:00 +00:00
Juli Mallett
32272e3b0a Remove unused file. Replaced by tlb.c. 2010-07-20 21:17:33 +00:00
Juli Mallett
bfa39fa09f o) Add the "octusb" controller which supports the first port of the Octeon
on-board USB controller.  It is not currently enabled because there are
   known problems with device communication and until those are fixed I am not
   certain that it won't destabilize the system. [1]
o) Add the "cryptocteon" opencrypto device based on the OCF device written by
   David McCullough.  It is not currently enabled because until support for
   saving/restoring coprocessor 2 state on context switch is available, it runs
   with interrupts disabled, which tends to pessimize performance over using a
   software crypto facility.  Tests using this driver which are not negatively
   affected by it running with interrupts disabled show it to be substantially
   faster than software for large blocks.

Submitted by:	hps [1]
2010-07-20 19:32:25 +00:00
Juli Mallett
cea2b8b915 Update the port of FreeBSD to Cavium Octeon to use the Cavium Simple Executive
library:
o) Increase inline unit / large function growth limits for MIPS to accommodate
   the needs of the Simple Executive, which uses a shocking amount of inlining.
o) Remove TARGET_OCTEON and use CPU_CNMIPS to do things required by cnMIPS and
   the Octeon SoC.
o) Add OCTEON_VENDOR_LANNER to use Lanner's allocation of vendor-specific
   board numbers, specifically to support the MR320.
o) Add OCTEON_BOARD_CAPK_0100ND to hard-wire configuration for the CAPK-0100nd,
   which improperly uses an evaluation board's board number and breaks board
   detection at runtime.  This board is sold by Portwell as the CAM-0100.
o) Add support for the RTC available on some Octeon boards.
o) Add support for the Octeon PCI bus.  Note that rman_[sg]et_virtual for IO
   ports can not work unless building for n64.
o) Clean up the CompactFlash driver to use Simple Executive macros and
   structures where possible (it would be advisable to use the Simple Executive
   API to set the PIO mode, too, but that is not done presently.)  Also use
   structures from FreeBSD's ATA layer rather than structures copied from
   Linux.
o) Print available Octeon SoC features on boot.
o) Add support for the Octeon timecounter.
o) Use the Simple Executive's routines rather than local copies for doing reads
   and writes to 64-bit addresses and use its macros for various device
   addresses rather than using local copies.
o) Rename octeon_board_real to octeon_is_simulation to reduce differences with
   Cavium-provided code originally written for Linux.  Also make it use the
   same simplified test that the Simple Executive and Linux both use rather
   than our complex one.
o) Add support for the Octeon CIU, which is the main interrupt unit, as a bus
   to use normal interrupt allocation and setup routines.
o) Use the Simple Executive's bootmem facility to allocate physical memory for
   the kernel, rather than assuming we know which addresses we can steal.
   NB: This may reduce the amount of RAM the kernel reports you as having if
       you are leaving large temporary allocations made by U-Boot allocated
       when starting FreeBSD.
o) Add a port of the Cavium-provided Ethernet driver for Linux.  This changes
   Ethernet interface naming from rgmxN to octeN.  The new driver has vast
   improvements over the old one, both in performance and functionality, but
   does still have some features which have not been ported entirely and there
   may be unimplemented code that can be hit in everyday use.  I will make
   every effort to correct those as they are reported.
o) Support loading the kernel on non-contiguous cores.
o) Add very conservative support for harvesting randomness from the Octeon
   random number device.
o) Turn SMP on by default.
o) Clean up the style of the Octeon kernel configurations a little and make
   them compile with -march=octeon.
o) Add support for the Lanner MR320 and the CAPK-0100nd to the Simple
   Executive.
o) Modify the Simple Executive to build on FreeBSD and to build without
   executive-config.h or cvmx-config.h.  In the future we may want to
   revert part of these changes and supply executive-config.h and
   cvmx-config.h and access to the options contained in those files via
   kernel configuration files.
o) Modify the Simple Executive USB routines to support getting and setting
   of the USB PID.
2010-07-20 19:25:11 +00:00
Warner Losh
f1d242081d Move common macros into asm.h. Replace MIPS_CPU_NOP_DELAY with
HAZARD_DELAY.  Move HAZARD_DELAY and ITLBNOPFIX into asm.h, for
possible later optimization...

Reviewed by:	jmallet, jchandra
2010-07-16 06:35:17 +00:00
Warner Losh
8bf733e458 This file appears not to be used. 2010-07-16 06:31:37 +00:00
Warner Losh
e0e27ec197 Use #define for get_cyclecount rather than inline function.
mips_rd_count() isn't defined in userland, and cpu.h is included there
in alias_scpt.h (maybe they don't need it in the first place).
2010-07-16 06:09:51 +00:00
Warner Losh
4fc94b98b1 Better description of this file 2010-07-15 21:56:45 +00:00
Jayachandran C.
068c7ecd98 Fix for 64 bit compilation.
RMI bootloader passes argv[] and envp[] as an array of 32 bit pointers.
Convert the pointers to correct pointer type before use.
2010-07-15 16:39:17 +00:00
Warner Losh
0a94adbf70 Move TLB definitions to tlb.h 2010-07-15 03:56:08 +00:00
Warner Losh
8ccfc6442d This file has been unused for a while now... 2010-07-15 03:36:50 +00:00
Warner Losh
9d1f4f86c5 Remove unused stuff from cpu.h.
Move inappropriate stuff in cpu.h elsewhere:
{s,g}et_intr_mask -> md_var.h
num_tlbentries -> tlb.h
Remove #define clockframe trapframe and fix clock, which was the only place
this was used.
All the rest of this stuff was unused.

# we're not quite minimal yet, since we duplicate a few status register things
# here...

Inspired by: bde@
2010-07-15 01:58:20 +00:00
Warner Losh
fde8aa4e5c We don't need sys/cdefs.h for __CONCAT here. 2010-07-15 01:55:28 +00:00
Warner Losh
3e2b3b68d2 Remove i386-ish sysctls. Also, make the bootinfo sysctl OID_AUTO. 2010-07-15 01:53:17 +00:00
Warner Losh
b82b0cb2b1 Remove one layer of indirection. No need to call cpu_throw which then
calls mips_cpu_call via an obfuscated assembler call.  Instead, delete
the current cpu_throw, and rename mips_cpu_throw to cpu_throw.  This
is nicer to the cache on each context switch (since fixed jumps can be
prefected, while jumps through a register can't).  Incidentally, it
also saves about 5 or 6 instructions.

Reviewed by:	jmallet@
2010-07-15 01:47:47 +00:00
Warner Losh
b995e62fd0 Use cpuregs.h spellings over the cpu.h spellings. 2010-07-14 00:52:29 +00:00
Warner Losh
209e9e4670 Remove the unused part of cpu.h now that the rest of the tree has been
transitioned to use cpuregs.h spellings.  Now we're only 4x too big,
according to the bde-ometer.
2010-07-14 00:47:37 +00:00
Warner Losh
cded61cee5 Prefer the cpuregs.h spellings of register and bit names over cpu.h. 2010-07-14 00:41:22 +00:00
Warner Losh
396bf45a4f union cpuprid is also unused now 2010-07-13 22:36:45 +00:00