summaryrefslogtreecommitdiffstats
path: root/sys/vm
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2009-06-26 04:47:43 +0000
committeralc <alc@FreeBSD.org>2009-06-26 04:47:43 +0000
commit91cafd48b17a27bda3cfbc38e8460a14c273ba9a (patch)
treebe473333ccc371c232599396e7b5253cdbad245b /sys/vm
parent9a472dd5889ffcc7520ed12bf9cbc791eb34eab7 (diff)
downloadFreeBSD-src-91cafd48b17a27bda3cfbc38e8460a14c273ba9a.zip
FreeBSD-src-91cafd48b17a27bda3cfbc38e8460a14c273ba9a.tar.gz
This change is the next step in implementing the cache control functionality
required by video card drivers. Specifically, this change introduces vm_cache_mode_t with an appropriate VM_CACHE_DEFAULT definition on all architectures. In addition, this changes adds a vm_cache_mode_t parameter to kmem_alloc_contig() and vm_phys_alloc_contig(). These will be the interfaces for allocating mapped kernel memory and physical memory, respectively, with non-default cache modes. In collaboration with: jhb
Diffstat (limited to 'sys/vm')
-rw-r--r--sys/vm/vm.h8
-rw-r--r--sys/vm/vm_contig.c8
-rw-r--r--sys/vm/vm_extern.h2
-rw-r--r--sys/vm/vm_phys.c2
-rw-r--r--sys/vm/vm_phys.h2
5 files changed, 16 insertions, 6 deletions
diff --git a/sys/vm/vm.h b/sys/vm/vm.h
index 57f2163..832c335 100644
--- a/sys/vm/vm.h
+++ b/sys/vm/vm.h
@@ -61,6 +61,14 @@
#ifndef VM_H
#define VM_H
+#include <machine/vm.h>
+
+/*
+ * The exact set of cache control codes is machine dependent. However, every
+ * machine is required to define VM_CACHE_DEFAULT.
+ */
+typedef char vm_cache_mode_t; /* cache control codes */
+
typedef char vm_inherit_t; /* inheritance codes */
#define VM_INHERIT_SHARE ((vm_inherit_t) 0)
diff --git a/sys/vm/vm_contig.c b/sys/vm/vm_contig.c
index 8dec3b5..d2b6703 100644
--- a/sys/vm/vm_contig.c
+++ b/sys/vm/vm_contig.c
@@ -236,7 +236,7 @@ contigmalloc(
void *ret;
ret = (void *)kmem_alloc_contig(kernel_map, size, flags, low, high,
- alignment, boundary);
+ alignment, boundary, VM_CACHE_DEFAULT);
if (ret != NULL)
malloc_type_allocated(type, round_page(size));
return (ret);
@@ -244,7 +244,8 @@ contigmalloc(
vm_offset_t
kmem_alloc_contig(vm_map_t map, vm_size_t size, int flags, vm_paddr_t low,
- vm_paddr_t high, unsigned long alignment, unsigned long boundary)
+ vm_paddr_t high, unsigned long alignment, unsigned long boundary,
+ vm_cache_mode_t mode)
{
vm_offset_t ret;
vm_page_t pages;
@@ -255,7 +256,8 @@ kmem_alloc_contig(vm_map_t map, vm_size_t size, int flags, vm_paddr_t low,
npgs = size >> PAGE_SHIFT;
tries = 0;
retry:
- pages = vm_phys_alloc_contig(npgs, low, high, alignment, boundary);
+ pages = vm_phys_alloc_contig(npgs, low, high, alignment, boundary,
+ mode);
if (pages == NULL) {
if (tries < ((flags & M_NOWAIT) != 0 ? 1 : 3)) {
vm_page_lock_queues();
diff --git a/sys/vm/vm_extern.h b/sys/vm/vm_extern.h
index 69bf64c..7bacde4 100644
--- a/sys/vm/vm_extern.h
+++ b/sys/vm/vm_extern.h
@@ -43,7 +43,7 @@ int kernacc(void *, int, int);
vm_offset_t kmem_alloc(vm_map_t, vm_size_t);
vm_offset_t kmem_alloc_contig(vm_map_t map, vm_size_t size, int flags,
vm_paddr_t low, vm_paddr_t high, unsigned long alignment,
- unsigned long boundary);
+ unsigned long boundary, vm_cache_mode_t mode);
vm_offset_t kmem_alloc_nofault(vm_map_t, vm_size_t);
vm_offset_t kmem_alloc_wait(vm_map_t, vm_size_t);
void kmem_free(vm_map_t, vm_offset_t, vm_size_t);
diff --git a/sys/vm/vm_phys.c b/sys/vm/vm_phys.c
index f64bc9c..58e71d0 100644
--- a/sys/vm/vm_phys.c
+++ b/sys/vm/vm_phys.c
@@ -588,7 +588,7 @@ vm_phys_zero_pages_idle(void)
*/
vm_page_t
vm_phys_alloc_contig(unsigned long npages, vm_paddr_t low, vm_paddr_t high,
- unsigned long alignment, unsigned long boundary)
+ unsigned long alignment, unsigned long boundary, vm_cache_mode_t mode)
{
struct vm_freelist *fl;
struct vm_phys_seg *seg;
diff --git a/sys/vm/vm_phys.h b/sys/vm/vm_phys.h
index 0e012c3..483ab91 100644
--- a/sys/vm/vm_phys.h
+++ b/sys/vm/vm_phys.h
@@ -43,7 +43,7 @@
void vm_phys_add_page(vm_paddr_t pa);
vm_page_t vm_phys_alloc_contig(unsigned long npages,
vm_paddr_t low, vm_paddr_t high,
- unsigned long alignment, unsigned long boundary);
+ unsigned long alignment, unsigned long boundary, vm_cache_mode_t mode);
vm_page_t vm_phys_alloc_pages(int pool, int order);
vm_paddr_t vm_phys_bootstrap_alloc(vm_size_t size, unsigned long alignment);
void vm_phys_free_pages(vm_page_t m, int order);
OpenPOWER on IntegriCloud