Module Name: src Committed By: reinoud Date: Mon Jun 4 19:53:01 UTC 2018
Modified Files: src/sys/arch/usermode/include: thunk.h src/sys/arch/usermode/usermode: thunk.c Log Message: Enhance the NetBSD/usermode thunk interface To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/sys/arch/usermode/include/thunk.h cvs rdiff -u -r1.89 -r1.90 src/sys/arch/usermode/usermode/thunk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/usermode/include/thunk.h diff -u src/sys/arch/usermode/include/thunk.h:1.64 src/sys/arch/usermode/include/thunk.h:1.65 --- src/sys/arch/usermode/include/thunk.h:1.64 Fri Jun 1 08:04:57 2018 +++ src/sys/arch/usermode/include/thunk.h Mon Jun 4 19:53:01 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.h,v 1.64 2018/06/01 08:04:57 reinoud Exp $ */ +/* $NetBSD: thunk.h,v 1.65 2018/06/04 19:53:01 reinoud Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill <jmcne...@invisible.ca> @@ -92,6 +92,7 @@ timer_t thunk_timer_attach(void); int thunk_timer_start(timer_t, int); int thunk_timer_getoverrun(timer_t); +void thunk_kill(pid_t pid, int sig); void thunk_exit(int); void thunk_abort(void); @@ -136,6 +137,8 @@ int thunk_sigfillset(sigset_t *sa_mask); void thunk_sigaddset(sigset_t *sa_mask, int sig); int thunk_sigprocmask(int how, const sigset_t * set, sigset_t *oset); int thunk_atexit(void (*function)(void)); +pid_t thunk_fork(void); +int thunk_ioctl(int fd, unsigned long request, void *opaque); int thunk_aio_read(struct aiocb *); int thunk_aio_write(struct aiocb *); @@ -166,6 +169,8 @@ int thunk_open_tap(const char *); int thunk_pollin_tap(int, int); int thunk_pollout_tap(int, int); +int thunk_assert_presence(vaddr_t from, size_t size); + typedef struct { unsigned int sample_rate; unsigned int precision; Index: src/sys/arch/usermode/usermode/thunk.c diff -u src/sys/arch/usermode/usermode/thunk.c:1.89 src/sys/arch/usermode/usermode/thunk.c:1.90 --- src/sys/arch/usermode/usermode/thunk.c:1.89 Fri Jun 1 08:04:57 2018 +++ src/sys/arch/usermode/usermode/thunk.c Mon Jun 4 19:53:01 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.c,v 1.89 2018/06/01 08:04:57 reinoud Exp $ */ +/* $NetBSD: thunk.c,v 1.90 2018/06/04 19:53:01 reinoud Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill <jmcne...@invisible.ca> @@ -28,7 +28,7 @@ #include <sys/cdefs.h> #ifdef __NetBSD__ -__RCSID("$NetBSD: thunk.c,v 1.89 2018/06/01 08:04:57 reinoud Exp $"); +__RCSID("$NetBSD: thunk.c,v 1.90 2018/06/04 19:53:01 reinoud Exp $"); #endif #define _KMEMUSER @@ -36,6 +36,7 @@ __RCSID("$NetBSD: thunk.c,v 1.89 2018/06 #define _I386_MACHTYPES_H_ #include "../include/types.h" + #include <sys/mman.h> #include <stdarg.h> #include <sys/reboot.h> @@ -344,6 +345,12 @@ thunk_usleep(useconds_t microseconds) } void +thunk_kill(pid_t pid, int sig) +{ + kill(pid, sig); +} + +void thunk_exit(int status) { return exit(status); @@ -646,6 +653,18 @@ thunk_atexit(void (*function)(void)) return atexit(function); } +pid_t +thunk_fork(void) +{ + return fork(); +} + +int +thunk_ioctl(int fd, unsigned long request, void *opaque) +{ + return ioctl(fd, request, opaque); +} + int thunk_aio_read(struct aiocb *aiocbp) { @@ -862,6 +881,21 @@ thunk_pollout_tap(int fd, int timeout) return poll(fds, __arraycount(fds), timeout); } + +/* simply make sure its present... yeah its silly */ +int +thunk_assert_presence(vaddr_t from, size_t size) +{ + vaddr_t va; + int t = 0; + + for (va = from; va < from + (vaddr_t) size; va += PAGE_SIZE) { + t += *(int *) va; + } + return t; +} + + int thunk_audio_open(const char *path) {