Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Jan 2011 19:18:43 +0530
From:      "Jayachandran C." <c.jayachandran@gmail.com>
To:        freebsd-mips@freebsd.org
Subject:   [PATCH] update sf_buf and uio for n64
Message-ID:  <AANLkTik%2BpMOxCaD70oZJPsmKa4mNCviZmzLhxe8wQR-y@mail.gmail.com>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
This is one of the remaining pieces in n64 work from Juli's octeon
branch. The attached patch updates the sf_buf code and uio_machdep.c
in n64 compilation to use direct mapping.

Planning to check this in later this week, if there are no objections.

JC.

[-- Attachment #2 --]
Index: sys/mips/include/sf_buf.h
===================================================================
--- sys/mips/include/sf_buf.h	(revision 217808)
+++ sys/mips/include/sf_buf.h	(working copy)
@@ -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
 struct vm_page;
 
 struct sf_buf {
@@ -52,5 +79,6 @@
 
 	return (sf->m);
 }
+#endif
 
 #endif /* !_MACHINE_SF_BUF_H_ */
Index: sys/mips/mips/vm_machdep.c
===================================================================
--- sys/mips/mips/vm_machdep.c	(revision 217808)
+++ sys/mips/mips/vm_machdep.c	(working copy)
@@ -82,6 +82,7 @@
 #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 @@
 } sf_freelist;
 
 static u_int	sf_buf_alloc_want;
+#endif
 
 /*
  * Finish a fork operation, with process p2 nearly set up.
@@ -458,6 +460,7 @@
 /*
  * 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,13 +482,27 @@
 	}
 	sf_buf_alloc_want = 0;
 }
+#endif
 
 /*
  * Get an sf_buf from the freelist.  Will block if none are available.
  */
+#ifdef __mips_n64
 struct sf_buf *
 sf_buf_alloc(struct vm_page *m, int flags)
 {
+
+	return ((struct sf_buf *)m);
+}
+
+void
+sf_buf_free(struct sf_buf *sf)
+{
+}
+#else
+struct sf_buf *
+sf_buf_alloc(struct vm_page *m, int flags)
+{
 	struct sf_buf *sf;
 	int error;
 
@@ -531,6 +548,7 @@
 		wakeup(&sf_freelist);
 	mtx_unlock(&sf_freelist.sf_lock);
 }
+#endif
 
 /*
  * Software interrupt handler for queued VM system processing.
Index: sys/mips/mips/uio_machdep.c
===================================================================
--- sys/mips/mips/uio_machdep.c	(revision 217808)
+++ sys/mips/mips/uio_machdep.c	(working copy)
@@ -92,9 +92,9 @@
 		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

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTik%2BpMOxCaD70oZJPsmKa4mNCviZmzLhxe8wQR-y>