summaryrefslogtreecommitdiffstats
path: root/sys/mips
diff options
context:
space:
mode:
authorjchandra <jchandra@FreeBSD.org>2011-01-27 14:49:22 +0000
committerjchandra <jchandra@FreeBSD.org>2011-01-27 14:49:22 +0000
commite0953f64d353b5b62c4b32e89ba2914eb1fdec24 (patch)
treefdd6ab84b1bcf99f7de8e8cc0debd0f9efaceb4d /sys/mips
parentcb008dd1afea31668df80b23122049573f039ea1 (diff)
downloadFreeBSD-src-e0953f64d353b5b62c4b32e89ba2914eb1fdec24.zip
FreeBSD-src-e0953f64d353b5b62c4b32e89ba2914eb1fdec24.tar.gz
Implement sf_buf using direct map (XKPHYS) in MIPS n64.
- Provide trivial implementation of sf_buf_alloc(), sf_buf_free(), sf_buf_kva() and sf_buf_page() using direct map for n64. - uio_machdep.c - use macros so that the direct map will be used in case of n64. Reviewed by: imp (earlier version) Obtained from: jmallett (user/jmallett/octeon)
Diffstat (limited to 'sys/mips')
-rw-r--r--sys/mips/include/sf_buf.h28
-rw-r--r--sys/mips/mips/uio_machdep.c4
-rw-r--r--sys/mips/mips/vm_machdep.c11
3 files changed, 40 insertions, 3 deletions
diff --git a/sys/mips/include/sf_buf.h b/sys/mips/include/sf_buf.h
index b6ee1cc..b9efaf0 100644
--- a/sys/mips/include/sf_buf.h
+++ b/sys/mips/include/sf_buf.h
@@ -29,8 +29,35 @@
#ifndef _MACHINE_SF_BUF_H_
#define _MACHINE_SF_BUF_H_
+#ifdef __mips_n64
+#include <vm/vm.h>
+#include <vm/vm_param.h>
+#include <vm/vm_page.h>
+#else
#include <sys/queue.h>
+#endif
+#ifdef __mips_n64
+/* In 64 bit the whole memory is directly mapped */
+struct sf_buf;
+
+static __inline vm_offset_t
+sf_buf_kva(struct sf_buf *sf)
+{
+ vm_page_t m;
+
+ m = (vm_page_t)sf;
+ return (MIPS_PHYS_TO_DIRECT(VM_PAGE_TO_PHYS(m)));
+}
+
+static __inline struct vm_page *
+sf_buf_page(struct sf_buf *sf)
+{
+
+ return ((vm_page_t)sf);
+}
+
+#else /* ! __mips_n64 */
struct vm_page;
struct sf_buf {
@@ -52,5 +79,6 @@ sf_buf_page(struct sf_buf *sf)
return (sf->m);
}
+#endif /* __mips_n64 */
#endif /* !_MACHINE_SF_BUF_H_ */
diff --git a/sys/mips/mips/uio_machdep.c b/sys/mips/mips/uio_machdep.c
index 4621c5a..a550ef0 100644
--- a/sys/mips/mips/uio_machdep.c
+++ b/sys/mips/mips/uio_machdep.c
@@ -92,9 +92,9 @@ uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, int n, struct uio *uio)
cnt = ulmin(cnt, PAGE_SIZE - page_offset);
m = ma[offset >> PAGE_SHIFT];
pa = VM_PAGE_TO_PHYS(m);
- if (pa < MIPS_KSEG0_LARGEST_PHYS) {
+ if (MIPS_DIRECT_MAPPABLE(pa)) {
sf = NULL;
- cp = (char *)MIPS_PHYS_TO_KSEG0(pa) + page_offset;
+ cp = (char *)MIPS_PHYS_TO_DIRECT(pa) + page_offset;
/*
* flush all mappings to this page, KSEG0 address first
* in order to get it overwritten by correct data
diff --git a/sys/mips/mips/vm_machdep.c b/sys/mips/mips/vm_machdep.c
index eb92090..47058ee 100644
--- a/sys/mips/mips/vm_machdep.c
+++ b/sys/mips/mips/vm_machdep.c
@@ -82,6 +82,7 @@ __FBSDID("$FreeBSD$");
#define NSFBUFS (512 + maxusers * 16)
#endif
+#ifndef __mips_n64
static void sf_buf_init(void *arg);
SYSINIT(sock_sf, SI_SUB_MBUF, SI_ORDER_ANY, sf_buf_init, NULL);
@@ -95,6 +96,7 @@ static struct {
} sf_freelist;
static u_int sf_buf_alloc_want;
+#endif
/*
* Finish a fork operation, with process p2 nearly set up.
@@ -458,6 +460,7 @@ kvtop(void *addr)
/*
* Allocate a pool of sf_bufs (sendfile(2) or "super-fast" if you prefer. :-))
*/
+#ifndef __mips_n64
static void
sf_buf_init(void *arg)
{
@@ -479,6 +482,7 @@ sf_buf_init(void *arg)
}
sf_buf_alloc_want = 0;
}
+#endif
/*
* Get an sf_buf from the freelist. Will block if none are available.
@@ -486,6 +490,7 @@ sf_buf_init(void *arg)
struct sf_buf *
sf_buf_alloc(struct vm_page *m, int flags)
{
+#ifndef __mips_n64
struct sf_buf *sf;
int error;
@@ -514,6 +519,9 @@ sf_buf_alloc(struct vm_page *m, int flags)
}
mtx_unlock(&sf_freelist.sf_lock);
return (sf);
+#else
+ return ((struct sf_buf *)m);
+#endif
}
/*
@@ -522,7 +530,7 @@ sf_buf_alloc(struct vm_page *m, int flags)
void
sf_buf_free(struct sf_buf *sf)
{
-
+#ifndef __mips_n64
pmap_qremove(sf->kva, 1);
mtx_lock(&sf_freelist.sf_lock);
SLIST_INSERT_HEAD(&sf_freelist.sf_head, sf, free_list);
@@ -530,6 +538,7 @@ sf_buf_free(struct sf_buf *sf)
if (sf_buf_alloc_want > 0)
wakeup(&sf_freelist);
mtx_unlock(&sf_freelist.sf_lock);
+#endif
}
/*
OpenPOWER on IntegriCloud