svn commit: r206232 - in user/jmallett/octeon/sys/mips: include mips
Juli Mallett
jmallett at FreeBSD.org
Tue Apr 6 01:08:21 UTC 2010
Author: jmallett
Date: Tue Apr 6 01:08:21 2010
New Revision: 206232
URL: http://svn.freebsd.org/changeset/base/206232
Log:
o) Add a UMA small allocator that uses XKPHYS for N64 kernels.
o) Sort some defines.
Modified:
user/jmallett/octeon/sys/mips/include/vmparam.h
user/jmallett/octeon/sys/mips/mips/vm_machdep.c
Modified: user/jmallett/octeon/sys/mips/include/vmparam.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/vmparam.h Tue Apr 6 01:06:52 2010 (r206231)
+++ user/jmallett/octeon/sys/mips/include/vmparam.h Tue Apr 6 01:08:21 2010 (r206232)
@@ -104,17 +104,18 @@
/* user/kernel map constants */
#define VM_MIN_ADDRESS ((vm_offset_t)0x00000000)
+#define VM_MAX_ADDRESS ((vm_offset_t)(intptr_t)(int32_t)0xffffffff)
+
#define VM_MAXUSER_ADDRESS ((vm_offset_t)(intptr_t)(int32_t)0x80000000)
#define VM_MAX_MMAP_ADDR VM_MAXUSER_ADDRESS
-#define VM_MAX_ADDRESS ((vm_offset_t)(intptr_t)(int32_t)0x80000000)
#ifndef VM_KERNEL_ALLOC_OFFSET
#define VM_KERNEL_ALLOC_OFFSET ((vm_offset_t)0x00000000)
#endif
#define VM_MIN_KERNEL_ADDRESS ((vm_offset_t)(intptr_t)(int32_t)0xC0000000)
+#define VM_MAX_KERNEL_ADDRESS ((vm_offset_t)(intptr_t)(int32_t)0xFFFFC000)
#define VM_KERNEL_WIRED_ADDR_END (VM_MIN_KERNEL_ADDRESS + VM_KERNEL_ALLOC_OFFSET)
-#define VM_MAX_KERNEL_ADDRESS ((vm_offset_t)(intptr_t)(int32_t)0xFFFFC000)
#if 0
#define KERNBASE (VM_MIN_KERNEL_ADDRESS)
#else
@@ -156,6 +157,11 @@
#define VM_INITIAL_PAGEIN 16
#endif
+/* provide our own memory allocator for small uma allocations */
+#if defined(__mips_n64)
+#define UMA_MD_SMALL_ALLOC
+#endif
+
/*
* max number of non-contig chunks of physical RAM you can have
*/
Modified: user/jmallett/octeon/sys/mips/mips/vm_machdep.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/vm_machdep.c Tue Apr 6 01:06:52 2010 (r206231)
+++ user/jmallett/octeon/sys/mips/mips/vm_machdep.c Tue Apr 6 01:08:21 2010 (r206232)
@@ -64,12 +64,15 @@ __FBSDID("$FreeBSD$");
#include <machine/pcb.h>
#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <sys/lock.h>
+#include <vm/vm_extern.h>
+#include <vm/pmap.h>
#include <vm/vm_kern.h>
-#include <vm/vm_page.h>
#include <vm/vm_map.h>
-#include <vm/vm_extern.h>
+#include <vm/vm_page.h>
+#include <vm/vm_pageout.h>
+#include <vm/vm_param.h>
+#include <vm/uma.h>
+#include <vm/uma_int.h>
#include <sys/user.h>
#include <sys/mbuf.h>
@@ -570,6 +573,56 @@ swi_vm(void *dummy)
{
}
+#if defined(__mips_n64)
+void *
+uma_small_alloc(uma_zone_t zone, int bytes, u_int8_t *flags, int wait)
+{
+ static vm_pindex_t color;
+ vm_paddr_t pa;
+ vm_page_t m;
+ int pflags;
+ void *va;
+
+ *flags = UMA_SLAB_PRIV;
+
+ if ((wait & (M_NOWAIT|M_USE_RESERVE)) == M_NOWAIT)
+ pflags = VM_ALLOC_INTERRUPT | VM_ALLOC_WIRED;
+ else
+ pflags = VM_ALLOC_SYSTEM | VM_ALLOC_WIRED;
+
+ if (wait & M_ZERO)
+ pflags |= VM_ALLOC_ZERO;
+
+ for (;;) {
+ m = vm_page_alloc(NULL, color++, pflags | VM_ALLOC_NOOBJ);
+ if (m == NULL) {
+ if (wait & M_NOWAIT)
+ return (NULL);
+ else
+ VM_WAIT;
+ } else
+ break;
+ }
+
+ pa = VM_PAGE_TO_PHYS(m);
+ va = (void *)MIPS_PHYS_TO_XKPHYS(MIPS_XKPHYS_CCA_CNC, pa);
+ if ((wait & M_ZERO) && (m->flags & PG_ZERO) == 0)
+ bzero(va, PAGE_SIZE);
+ return (va);
+}
+
+void
+uma_small_free(void *mem, int size, u_int8_t flags)
+{
+ vm_page_t m;
+
+ m = PHYS_TO_VM_PAGE(MIPS_XKPHYS_TO_PHYS((vm_offset_t)mem));
+ m->wire_count--;
+ vm_page_free(m);
+ atomic_subtract_int(&cnt.v_wire_count, 1);
+}
+#endif
+
int
cpu_set_user_tls(struct thread *td, void *tls_base)
{
More information about the svn-src-user
mailing list