Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump/net/lib/libshmif add a private hypercall to map the...
details: https://anonhg.NetBSD.org/src/rev/eb30cd4cc1ce
branches: trunk
changeset: 786467:eb30cd4cc1ce
user: pooka <pooka%NetBSD.org@localhost>
date: Mon Apr 29 13:17:32 2013 +0000
description:
add a private hypercall to map the bus into memory
diffstat:
sys/rump/net/lib/libshmif/if_shmem.c | 8 +++-----
sys/rump/net/lib/libshmif/rumpcomp_user.c | 26 +++++++++++++++++++++++++-
sys/rump/net/lib/libshmif/rumpcomp_user.h | 3 ++-
3 files changed, 30 insertions(+), 7 deletions(-)
diffs (87 lines):
diff -r dbd19be41221 -r eb30cd4cc1ce sys/rump/net/lib/libshmif/if_shmem.c
--- a/sys/rump/net/lib/libshmif/if_shmem.c Mon Apr 29 13:07:37 2013 +0000
+++ b/sys/rump/net/lib/libshmif/if_shmem.c Mon Apr 29 13:17:32 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_shmem.c,v 1.50 2013/04/28 13:17:25 pooka Exp $ */
+/* $NetBSD: if_shmem.c,v 1.51 2013/04/29 13:17:32 pooka Exp $ */
/*
* Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.50 2013/04/28 13:17:25 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.51 2013/04/29 13:17:32 pooka Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -205,9 +205,7 @@
volatile uint8_t *p;
int error;
- sc->sc_busmem = rumpuser_filemmap(memfd, 0, BUSMEM_SIZE,
- RUMPUSER_FILEMMAP_TRUNCATE | RUMPUSER_FILEMMAP_SHARED
- | RUMPUSER_FILEMMAP_READ | RUMPUSER_FILEMMAP_WRITE, &error);
+ sc->sc_busmem = rumpcomp_shmif_mmap(memfd, BUSMEM_SIZE, &error);
if (error)
return error;
diff -r dbd19be41221 -r eb30cd4cc1ce sys/rump/net/lib/libshmif/rumpcomp_user.c
--- a/sys/rump/net/lib/libshmif/rumpcomp_user.c Mon Apr 29 13:07:37 2013 +0000
+++ b/sys/rump/net/lib/libshmif/rumpcomp_user.c Mon Apr 29 13:17:32 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpcomp_user.c,v 1.5 2013/04/28 14:11:43 pooka Exp $ */
+/* $NetBSD: rumpcomp_user.c,v 1.6 2013/04/29 13:17:32 pooka Exp $ */
/*-
* Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved.
@@ -26,6 +26,7 @@
*/
#include <sys/types.h>
+#include <sys/mman.h>
#include <errno.h>
@@ -176,3 +177,26 @@
return 0;
}
#endif
+
+void *
+rumpcomp_shmif_mmap(int fd, size_t len, int *error)
+{
+ void *rv;
+
+ *error = 0;
+ if (ftruncate(fd, len) == -1) {
+ *error = errno;
+ return NULL;
+ }
+
+#if defined(__sun__) && !defined(MAP_FILE)
+#define MAP_FILE 0
+#endif
+
+ rv = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, 0);
+ if (rv == MAP_FAILED) {
+ *error = errno;
+ }
+
+ return rv;
+}
diff -r dbd19be41221 -r eb30cd4cc1ce sys/rump/net/lib/libshmif/rumpcomp_user.h
--- a/sys/rump/net/lib/libshmif/rumpcomp_user.h Mon Apr 29 13:07:37 2013 +0000
+++ b/sys/rump/net/lib/libshmif/rumpcomp_user.h Mon Apr 29 13:17:32 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpcomp_user.h,v 1.2 2013/04/28 10:53:22 pooka Exp $ */
+/* $NetBSD: rumpcomp_user.h,v 1.3 2013/04/29 13:17:33 pooka Exp $ */
/*
* Copyright (c) 2013 Antti Kantee. All Rights Reserved.
@@ -27,3 +27,4 @@
int rumpcomp_shmif_watchsetup(int, int, int *);
int rumpcomp_shmif_watchwait(int, int *);
+void *rumpcomp_shmif_mmap(int, size_t, int *);
Home |
Main Index |
Thread Index |
Old Index