Date: Wed, 11 Feb 1998 18:58:24 -0500 From: Michael Imor <umji@cs.sunyit.edu> To: freebsd-multimedia@FreeBSD.ORG Subject: mremap linux patches (for Quake 2) Message-ID: <199802112004.UAA13533@fang.cs.sunyit.edu>
next in thread | raw e-mail | index | archive | help
Here's the patches for the linux emulation lkm that allow Quake2 to be
played. It'll work in single player but it dies when trying to connect to
a server.
Mike
Here's the original email:
At 08:47 PM 1/26/98 -0500, Luoqi Chen wrote:
>After hacked a version of mremap() that only implements shrinking, I was
>able to play single-player games (softx version). But I had trouble with
>network mode. When I chose join a game from the multiplayer menu, it exited
>before showing the server and port menu. The error printed was Net_Sendpacket
>error -99, which is EADDRNOTAVAIL. I did a ktrace, it was a sendto() call
>to broadcast address 255.255.255.255, and since my default route is a non-
>broadcastable ppp link, it returned error EADDRNOTAVAIL. So I added a piece
>of code in linux_sendto(), whenever it saw a 0xffffffff address, I changed
>to broadcast address of my ethernet card (not connected). The -99 error
>message went away, but quake2 still shutdown at the same point. Does anyone
>have any idea? It seems that networking code has changed a lot from quake
>to quake2.
>
>-lq
>
Index: linux.h
===================================================================
RCS file: /fun/cvs/src/sys/i386/linux/linux.h,v
retrieving revision 1.19
diff -u -r1.19 linux.h
--- linux.h 1997/12/15 06:09:11 1.19
+++ linux.h 1998/01/25 11:34:56
@@ -407,6 +407,9 @@
#define LINUX_MAP_FIXED 0x0010
#define LINUX_MAP_ANON 0x0020
+/* mremap options */
+#define LINUX_MREMAP_MAYMOVE 1
+
/* SystemV ipc defines */
#define LINUX_SEMOP 1
#define LINUX_SEMGET 2
Index: linux_misc.c
===================================================================
RCS file: /fun/cvs/src/sys/i386/linux/linux_misc.c,v
retrieving revision 1.33
diff -u -r1.33 linux_misc.c
--- linux_misc.c 1997/11/06 19:28:58 1.33
+++ linux_misc.c 1998/01/27 17:00:06
@@ -628,6 +628,37 @@
}
int
+linux_mremap(struct proc *p, struct linux_mremap_args *args)
+{
+ struct munmap_args /* {
+ void *addr;
+ size_t len;
+ } */ bsd_args;
+ int error = 0;
+
+#ifdef DEBUG
+ printf("Linux-emul(%d): mremap(%08x, %08x, %08x, %08x)\n",
+ p->p_pid, args->addr, args->old_len, args->new_len, args->flags);
+#endif
+ args->new_len = round_page(args->new_len);
+ args->old_len = round_page(args->old_len);
+
+ if (args->new_len > args->old_len) {
+ p->p_retval[0] = 0;
+ return ENOMEM;
+ }
+
+ if (args->new_len < args->old_len) {
+ bsd_args.addr = args->addr + args->new_len;
+ bsd_args.len = args->old_len - args->new_len;
+ error = munmap(p, &bsd_args);
+ }
+
+ p->p_retval[0] = error ? 0 : (int)args->addr;
+ return error;
+}
+
+int
linux_pipe(struct proc *p, struct linux_pipe_args *args)
{
int error;
Index: linux_proto.h
===================================================================
RCS file: /fun/cvs/src/sys/i386/linux/linux_proto.h,v
retrieving revision 1.7
diff -u -r1.7 linux_proto.h
--- linux_proto.h 1997/12/17 03:16:05 1.7
+++ linux_proto.h 1998/01/25 11:25:45
@@ -362,6 +362,12 @@
int len;
int fl;
};
+struct linux_mremap_args {
+ caddr_t addr;
+ int old_len;
+ int new_len;
+ int flags;
+};
int linux_setup __P((struct proc *, struct linux_setup_args *));
int linux_fork __P((struct proc *, struct linux_fork_args *));
int linux_open __P((struct proc *, struct linux_open_args *));
@@ -456,6 +462,7 @@
int linux_getdents __P((struct proc *, struct linux_getdents_args *));
int linux_newselect __P((struct proc *, struct linux_newselect_args *));
int linux_msync __P((struct proc *, struct linux_msync_args *));
+int linux_mremap __P((struct proc *, struct linux_mremap_args *));
#ifdef COMPAT_43
Index: linux_syscall.h
===================================================================
RCS file: /fun/cvs/src/sys/i386/linux/linux_syscall.h,v
retrieving revision 1.5
diff -u -r1.5 linux_syscall.h
--- linux_syscall.h 1997/12/17 03:16:08 1.5
+++ linux_syscall.h 1998/01/25 11:25:45
@@ -148,4 +148,5 @@
#define LINUX_SYS_linux_msync 144
#define LINUX_SYS_readv 145
#define LINUX_SYS_writev 146
-#define LINUX_SYS_MAXSYSCALL 147
+#define LINUX_SYS_linux_mremap 163
+#define LINUX_SYS_MAXSYSCALL 164
Index: linux_sysent.c
===================================================================
RCS file: /fun/cvs/src/sys/i386/linux/linux_sysent.c,v
retrieving revision 1.10
diff -u -r1.10 linux_sysent.c
--- linux_sysent.c 1997/12/17 03:16:11 1.10
+++ linux_sysent.c 1998/01/25 11:25:45
@@ -168,4 +168,21 @@
{ 3, (sy_call_t *)linux_msync }, /* 144 = linux_msync */
{ 3, (sy_call_t *)readv }, /* 145 = readv */
{ 3, (sy_call_t *)writev }, /* 146 = writev */
+ { 0, (sy_call_t *)nosys }, /* 147 = getsid */
+ { 0, (sy_call_t *)nosys }, /* 148 = fdatasync */
+ { 0, (sy_call_t *)nosys }, /* 149 = sysctl */
+ { 0, (sy_call_t *)nosys }, /* 150 = mlock */
+ { 0, (sy_call_t *)nosys }, /* 151 = munlock */
+ { 0, (sy_call_t *)nosys }, /* 152 = mlockall */
+ { 0, (sy_call_t *)nosys }, /* 153 = munlockall */
+ { 0, (sy_call_t *)nosys }, /* 154 = sys_sched_setparam */
+ { 0, (sy_call_t *)nosys }, /* 155 = sys_sched_getparam */
+ { 0, (sy_call_t *)nosys }, /* 156 = sys_sched_setscheduler */
+ { 0, (sy_call_t *)nosys }, /* 157 = sys_sched_getscheduler */
+ { 0, (sy_call_t *)nosys }, /* 158 = sys_sched_yield */
+ { 0, (sy_call_t *)nosys }, /* 159 = sys_sched_get_priority_max */
+ { 0, (sy_call_t *)nosys }, /* 160 = sys_sched_get_priority_min */
+ { 0, (sy_call_t *)nosys }, /* 161 = sys_sched_rr_get_interval */
+ { 0, (sy_call_t *)nosys }, /* 162 = sys_nanosleep */
+ { 4, (sy_call_t *)linux_mremap }, /* 163 = linux_mremap */
};
Index: syscalls.master
===================================================================
RCS file: /fun/cvs/src/sys/i386/linux/syscalls.master,v
retrieving revision 1.6
diff -u -r1.6 syscalls.master
--- syscalls.master 1997/12/17 03:12:35 1.6
+++ syscalls.master 1998/01/25 11:25:41
@@ -207,3 +207,21 @@
u_int iovcnt); }
146 NOPROTO LINUX { int writev(int fd, struct iovec *iovp, \
u_int iovcnt); }
+147 UNIMPL LINUX getsid
+148 UNIMPL LINUX fdatasync
+149 UNIMPL LINUX sysctl
+150 UNIMPL LINUX mlock
+151 UNIMPL LINUX munlock
+152 UNIMPL LINUX mlockall
+153 UNIMPL LINUX munlockall
+154 UNIMPL LINUX sys_sched_setparam
+155 UNIMPL LINUX sys_sched_getparam
+156 UNIMPL LINUX sys_sched_setscheduler
+157 UNIMPL LINUX sys_sched_getscheduler
+158 UNIMPL LINUX sys_sched_yield
+159 UNIMPL LINUX sys_sched_get_priority_max
+160 UNIMPL LINUX sys_sched_get_priority_min
+161 UNIMPL LINUX sys_sched_rr_get_interval
+162 UNIMPL LINUX sys_nanosleep
+163 STD LINUX { int linux_mremap(caddr_t addr, int old_len, \
+ int new_len, int flags); }
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-multimedia" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199802112004.UAA13533>
