Subject: kern/11857: COMPAT_LINUX for powerpc preliminary work (but it says hello world!)
To: None <gnats-bugs@gnats.netbsd.org>
From: None <p99dreyf@criens.u-psud.fr>
List: netbsd-bugs
Date: 12/30/2000 18:22:36
>Number:         11857
>Category:       kern
>Synopsis:       COMPAT_LINUX for powerpc preliminary work (but it says hello world!)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Dec 30 18:23:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Emmanuel Dreyfus
>Release:        NetBSD-current/macppc
>Organization:
>Environment:
NetBSD oceane 1.5P NetBSD 1.5P (LCOMP1) #2: Fri Dec 29 06:09:38 CET 2000     manu@oceane:/usr/src/sys/arch/macppc/compile/LCOMP1 macppc
>Description:
Here are some patch to NetBSD kernel sources to bring COMPAT_LINUX to powerpc. The job is not finished, but this set of patch have minimal functionnality:
Things that works:
+ Kernel builds and boots with COMPAT_LINUX on macppc (and probably other powerpc platforms)
+ I was able to run a statically linked hello world program built on LinuxPPC  
Things missing (work remaining to be done)
- ptrace support is broken (sys/compat/linux/arch/powerpc/linux_ptrace.c needs to be rewritten)
- No signal support (sys/compat/linux/arch/powerpc/machdep.c functions need to be written, so does sys/arch/powerpc/powerpc/linux_sigcode.S)
- Dynamically built executables do not run yet (No idea why)
- Man pages options(4) and compat_linux(8) will need to be updated after all of this will have been done and fixed.

>How-To-Repeat:
1) Apply the patches
2) Go to sys/compat/linux/arch/powerpc, and type make two times (to generate a few files)
2) configure and compile the kernel with COMPAT_LINUX enabled 
3) compile this on a LinuxPPC box, with the -static flag
#include <stdio.h>
int main (int argc, char** argv) {
  printf("Hello world\n");
  return 0;
}
4) run it on the NetBSD/macppc box, it works at mine!
>Fix:
--- sys/arch/macppc/conf/files.macppc.orig	Sat Dec 23 11:18:17 2000
+++ sys/arch/macppc/conf/files.macppc	Wed Dec 27 11:38:42 2000
@@ -207,4 +207,13 @@
 include "dev/cardbus/files.cardbus"
 include "dev/pcmcia/files.pcmcia"
 
 file arch/macppc/macppc/rbus_machdep.c		cardbus
+
+# OSS audio driver compatibility
+file compat/ossaudio/ossaudio.c
+
+# Linux binary compatibility (COMPAT_LINUX)
+include "compat/linux/files.linux"
+include "compat/linux/arch/powerpc/files.linux_powerpc"
+#file  arch/powerpc/powerpc/linux_syscall.c      compat_linux
+file arch/powerpc/powerpc/linux_sigcode.S			 compat_linux
--- sys/arch/powerpc/powerpc/linux_sigcode.S.orig	Wed Dec 27 06:37:55 2000
+++ sys/arch/powerpc/powerpc/linux_sigcode.S	Fri Dec 29 13:31:42 2000
@@ -0,0 +1,60 @@
+/*	$NetBSD$ */
+
+/*
+ * The following code is just a copy from sys/arch/powerpc/powerpc/sigcode.S 
+ * Obviously, there are little chance that it works for Linux emulation, so 
+ * it will have to be rewritten. 
+ * Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr>
+ */
+
+/*
+ * Copyright (C) 1995, 1996 Wolfgang Solfrank.
+ * Copyright (C) 1995, 1996 TooLs GmbH.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by TooLs GmbH.
+ * 4. The name of TooLs GmbH may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+#include <sys/syscall.h>
+
+/*
+ * The following code gets copied to the top of the user stack on process
+ * execution.  It does signal trampolining on signal delivery.
+ *
+ * On entry r1 points to a struct sigframe at bottom of current stack.
+ * All other registers are unchanged.
+ */
+	.globl	_C_LABEL(linux_sigcode),_C_LABEL(linux_esigcode)
+_C_LABEL(linux_sigcode):
+	addi	1,1,-16			/* reserved space for callee */
+	blrl
+	addi	3,1,16+8		/* compute &sf_sc */
+	li	0,SYS___sigreturn14
+	sc				/* sigreturn(scp) */
+	li	0,SYS_exit
+	sc				/* exit(errno) */
+_C_LABEL(linux_esigcode):
--- sys/compat/linux/arch/powerpc/files.linux_powerpc.orig	Thu Dec 21 03:22:14 2000
+++ sys/compat/linux/arch/powerpc/files.linux_powerpc	Wed Dec 27 17:53:11 2000
@@ -0,0 +1,20 @@
+#	$NetBSD$
+#
+# Config file description for powerpc-dependent Linux compat code.
+
+file	compat/linux/arch/powerpc/linux_machdep.c		compat_linux
+file	compat/linux/arch/powerpc/linux_ptrace.c		compat_linux
+file	compat/linux/arch/powerpc/linux_syscalls.c		compat_linux
+file	compat/linux/arch/powerpc/linux_sysent.c		compat_linux
+file	compat/linux/arch/powerpc/linux_sigarray.c		compat_linux
+
+file    compat/linux/common/linux_pipe.c                compat_linux
+file    compat/linux/common/linux_ipccall.c             compat_linux
+file    compat/linux/common/linux_misc_notalpha.c       compat_linux
+file    compat/linux/common/linux_sig_notalpha.c        compat_linux
+file    compat/linux/common/linux_sigaction.c           compat_linux
+file    compat/linux/common/linux_socketcall.c          compat_linux
+file    compat/linux/common/linux_llseek.c              compat_linux
+file    compat/linux/common/linux_oldmmap.c             compat_linux
+file    compat/linux/common/linux_oldselect.c           compat_linux
+file    compat/linux/common/linux_olduname.c           compat_linux
--- sys/compat/linux/arch/powerpc/syscalls.master.orig	Thu Dec 21 03:22:18 2000
+++ sys/compat/linux/arch/powerpc/syscalls.master	Fri Dec 29 14:40:59 2000
@@ -0,0 +1,347 @@
+	$NetBSD$  
+
+;	@(#)syscalls.master	8.1 (Berkeley) 7/19/93
+
+; Derived from NetBSD's sys/compat/linux/arch/i386/syscalls.master
+; sys/compat/linux/arch/m68k/syscalls.master 
+; and from Linux's arch/ppc/kernel/misc.S 
+;
+; We have problems for a few syscalls, espcecially:
+; 59 sys_olduname -> UNIMPL
+; 70 linux_sys_setreuid -> UNIMPL   
+; 71 linux_sys_setregid -> UNIMPL 
+; 82 ppc_select -> old_select  Is that right?
+; 90 sys_mmap -> old_mmap      Is that right?
+; 95 linux_sys_fchown -> UNIMPL
+; 109 sys_uname -> UNIMPL
+; 110 sys_iopl -> UNIMPL
+; 113 sys_vm86 -> UNIMPL
+; 123 sys_modify_ldt -> sys_cacheflush
+; 142 ppc_select -> sys_select (Conflicts with 82 ???)
+; Most of syscalls after 182 that were intorduced in Linux-2.4 are also UNIMPL.
+;
+; Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr>
+
+; NetBSD powerpc COMPAT_LINUX system call name/number "master" file.
+; (See syscalls.conf to see what it is processed into.)
+;
+; Fields: number type [type-dependent ...]
+;	number	system call number, must be in order
+;	type	one of STD, OBSOL, UNIMPL, NODEF, NOARGS, or one of
+;		the compatibility options defined in syscalls.conf.
+;
+; types:
+;	STD	always included
+;	OBSOL	obsolete, not included in system
+;	UNIMPL	unimplemented, not included in system
+;	NODEF	included, but don't define the syscall number
+;	NOARGS	included, but don't define the syscall args structure
+;	INDIR	included, but don't define the syscall args structure
+;		and allow it to be "really" varargs.
+;
+; The compat options are defined in the syscalls.conf file, and the
+; compat option name is prefixed to the syscall name.  Other than
+; that, they're like NODEF (for 'compat' options), or STD (for
+; 'libcompat' options).
+;
+; The type-dependent arguments are as follows:
+; For STD, NODEF, NOARGS, and compat syscalls:
+;	{ pseudo-proto } [alias]
+; For other syscalls:
+;	[comment]
+;
+; #ifdef's, etc. may be included, and are copied to the output files.
+; #include's are copied to the syscall names and switch definition files only.
+
+#include "opt_compat_netbsd.h"
+#include "opt_compat_43.h"
+
+#include <sys/param.h>
+#include <sys/poll.h>
+#include <sys/systm.h>
+#include <sys/signal.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
+#include <compat/linux/common/linux_types.h>
+#include <compat/linux/common/linux_signal.h>
+#include <compat/linux/common/linux_siginfo.h>
+#include <compat/linux/common/linux_machdep.h>
+
+#include <compat/linux/linux_syscallargs.h>
+
+0	NOARGS		{ int sys_nosys(void); } syscall
+1	NOARGS		{ int sys_exit(int rval); }
+2	NOARGS		{ int sys_fork(void); }
+3	NOARGS		{ int sys_read(int fd, char *buf, u_int nbyte); }
+4	NOARGS		{ int sys_write(int fd, char *buf, u_int nbyte); }
+5	STD		{ int linux_sys_open(const char *path, int flags, \
+			    int mode); }
+6	NOARGS		{ int sys_close(int fd); }
+7	STD		{ int linux_sys_waitpid(int pid, int *status, \
+			    int options);}
+8	STD		{ int linux_sys_creat(const char *path, int mode); }
+9	STD		{ int linux_sys_link(const char *path, const char *link); }
+10	STD		{ int linux_sys_unlink(const char *path); }
+11	STD		{ int linux_sys_execve(const char *path, char **argp, \
+			    char **envp); }
+12	STD		{ int linux_sys_chdir(const char *path); }
+13	STD		{ int linux_sys_time(linux_time_t *t); }
+14	STD		{ int linux_sys_mknod(const char *path, int mode, \
+			    int dev); }
+15	STD		{ int linux_sys_chmod(const char *path, int mode); }
+16	STD		{ int linux_sys_lchown(const char *path, int uid, \
+			    int gid); }
+17	OBSOL		break
+18	OBSOL		ostat
+19	NOARGS		{ long compat_43_sys_lseek(int fd, long offset, \
+			    int whence); }
+20	NOARGS		{ pid_t sys_getpid(void); }
+21	UNIMPL		mount
+22	OBSOL		umount
+23	NOARGS		{ int sys_setuid(uid_t uid); }
+24	NOARGS		{ uid_t sys_getuid(void); }
+25	STD		{ int linux_sys_stime(linux_time_t *t); }
+26	STD		{ int linux_sys_ptrace(int request, int pid, \
+			  int addr, int data); }
+27	STD		{ int linux_sys_alarm(unsigned int secs); }
+28	OBSOL		ofstat
+29	STD		{ int linux_sys_pause(void); }
+30	STD		{ int linux_sys_utime(const char *path, \
+			    struct linux_utimbuf *times); }
+31	OBSOL		stty
+32	OBSOL		gtty
+33	STD		{ int linux_sys_access(const char *path, int flags); }
+34	STD		{ int linux_sys_nice(int incr); }
+35	OBSOL		ftime
+36	NOARGS		{ int sys_sync(void); }
+37	STD		{ int linux_sys_kill(int pid, int signum); }
+38	STD		{ int linux_sys_rename(const char *from, \
+			    const char *to); }
+39	STD		{ int linux_sys_mkdir(const char *path, int mode); }
+40	STD		{ int linux_sys_rmdir(const char *path); }
+41	NOARGS		{ int sys_dup(u_int fd); }
+42	STD		{ int linux_sys_pipe(int *pfds); }
+43	STD		{ int linux_sys_times(struct times *tms); }
+44	OBSOL		prof
+45	STD		{ int linux_sys_brk(char *nsize); }
+46	NOARGS		{ int sys_setgid(gid_t gid); }
+47	NOARGS		{ gid_t sys_getgid(void); }
+48	STD		{ int linux_sys_signal(int signum, \
+			    linux_handler_t handler); }
+49	NOARGS		{ uid_t sys_geteuid(void); }
+50	NOARGS		{ gid_t sys_getegid(void); }
+51	NOARGS		{ int sys_acct(char *path); }
+52	UNIMPL		umount
+53	OBSOL		lock
+54	STD		{ int linux_sys_ioctl(int fd, u_long com, \
+			    caddr_t data); }
+55	STD		{ int linux_sys_fcntl(int fd, int cmd, void *arg); }
+56	OBSOL		mpx
+57	NOARGS		{ int sys_setpgid(int pid, int pgid); }
+58	OBSOL		ulimit
+59	UNIMPL		oldolduname
+60	NOARGS		{ int sys_umask(int newmask); }
+61	NOARGS		{ int sys_chroot(char *path); }
+62	UNIMPL		ustat
+63	NOARGS		{ int sys_dup2(u_int from, u_int to); }
+64	NOARGS		{ pid_t sys_getppid(void); }
+65	NOARGS		{ int sys_getpgrp(void); }
+66	NOARGS		{ int sys_setsid(void); }
+67	STD		{ int linux_sys_sigaction(int signum, \
+			    const struct linux_old_sigaction *nsa, \
+			    struct linux_old_sigaction *osa); }
+68	STD		{ int linux_sys_siggetmask(void); }
+69	STD		{ int linux_sys_sigsetmask(linux_old_sigset_t mask); }
+70	UNIMPL		{ int linux_sys_setreuid(int ruid, int euid); } 
+71	UNIMPL		{ int linux_sys_setregid(int rgid, int egid); }
+72	STD		{ int linux_sys_sigsuspend(caddr_t restart, \
+			    int oldmask, int mask); }
+73	STD		{ int linux_sys_sigpending(linux_old_sigset_t *set); }
+74	NOARGS		{ int compat_43_sys_sethostname(char *hostname, \
+			    u_int len);}
+75	NOARGS		{ int compat_43_sys_setrlimit(u_int which, \
+			    struct orlimit *rlp); }
+76	NOARGS		{ int compat_43_sys_getrlimit(u_int which, \
+			    struct orlimit *rlp); }
+77	NOARGS		{ int sys_getrusage(int who, struct rusage *rusage); }
+78	NOARGS		{ int sys_gettimeofday(struct timeval *tp, \
+			    struct timezone *tzp); }
+79	NOARGS		{ int sys_settimeofday(struct timeval *tp, \
+			    struct timezone *tzp); }
+80	NOARGS		{ int sys_getgroups(u_int gidsetsize, gid_t *gidset); }
+81	NOARGS		{ int sys_setgroups(u_int gidsetsize, gid_t *gidset); }
+82	STD		{ int linux_sys_oldselect(struct linux_oldselect *lsp); }
+83	STD		{ int linux_sys_symlink(const char *path, \
+			    const char *to); }
+84	NOARGS		{ int compat_43_sys_lstat(const char *path, \
+			    struct stat43 *up); } oolstat
+85	STD		{ int linux_sys_readlink(const char *name, char *buf, \
+			    int count); }
+86	STD		{ int linux_sys_uselib(const char *path); }
+87	STD		{ int linux_sys_swapon(char *name); }
+88	STD		{ int linux_sys_reboot(int magic1, int magic2, \
+			    int cmd, void *arg); }
+89	STD		{ int linux_sys_readdir(int fd, caddr_t dent, \
+			    unsigned int count); }
+90	STD		{ int linux_sys_old_mmap(struct linux_oldmmap *lmp); }
+91	NOARGS		{ int sys_munmap(caddr_t addr, int len); }
+92	STD		{ int linux_sys_truncate(const char *path, \
+			    long length); }
+93	NOARGS		{ int compat_43_sys_ftruncate(int fd, long length); }
+94	NOARGS		{ int sys_fchmod(int fd, int mode); }
+95	UNIMPL		{ int linux_sys_fchown(int fd, int uid, int gid); }
+96	NOARGS		{ int sys_getpriority(int which, int who); }
+97	NOARGS		{ int sys_setpriority(int which, int who, int prio); }
+98	NOARGS		{ int sys_profil(caddr_t samples, u_int size, \
+			    u_int offset, u_int scale); }
+99	STD		{ int linux_sys_statfs(const char *path, \
+			    struct linux_statfs *sp); }
+100	STD		{ int linux_sys_fstatfs(int fd, \
+			    struct linux_statfs *sp); }
+101	STD	{ int linux_sys_ioperm(unsigned int lo, \
+             unsigned int hi, int val); }
+102	STD		{ int linux_sys_socketcall(int what, void *args); }
+103	UNIMPL		syslog
+104	NOARGS		{ int sys_setitimer(u_int which, \
+			    struct itimerval *itv, struct itimerval *oitv); }
+105	NOARGS		{ int sys_getitimer(u_int which, \
+			    struct itimerval *itv); }
+106	STD		{ int linux_sys_stat(const char *path, \
+			    struct linux_stat *sp); }
+107	STD		{ int linux_sys_lstat(const char *path, \
+			    struct linux_stat *sp); }
+108	STD		{ int linux_sys_fstat(int fd, struct linux_stat *sp); }
+109	UNIMPL		{ int linux_sys_olduname(struct linux_old_utsname *up); }
+110	STD		{ int linux_sys_iopl(int level); }
+111	UNIMPL		vhangup
+112	UNIMPL		idle
+113	UNIMPL		vm86old
+114	STD		{ int linux_sys_wait4(int pid, int *status, \
+			    int options, struct rusage *rusage); }
+115	STD      { int linux_sys_swapoff(const char *path); }
+116	STD      { int linux_sys_sysinfo(struct linux_sysinfo *arg); }
+117	STD		{ int linux_sys_ipc(int what, int a1, int a2, int a3, \
+			    caddr_t ptr); }
+118	NOARGS		{ int sys_fsync(int fd); }
+119	STD		{ int linux_sys_sigreturn(void); }
+120	STD		{ int linux_sys_clone(int flags, void *stack); }
+121	STD		{ int linux_sys_setdomainname(char *domainname, \
+             int len); }
+122	STD		{ int linux_sys_uname(struct linux_utsname *up); }
+123	UNIMPL		{ int linux_sys_cacheflush(unsigned long addr, \
+			    int scope, int cache, unsigned long len); }
+124	UNIMPL		adjtimex
+125	NOARGS		{ int sys_mprotect(caddr_t addr, int len, int prot); }
+126	STD		{ int linux_sys_sigprocmask(int how, \
+			    const linux_old_sigset_t *set, \
+			    linux_old_sigset_t *oset); }
+127	UNIMPL		create_module
+128	UNIMPL		init_module
+129	UNIMPL		delete_module
+130	UNIMPL		get_kernel_syms
+131	UNIMPL		quotactl
+132	STD		{ int linux_sys_getpgid(int pid); }
+133	NOARGS		{ int sys_fchdir(int fd); }
+134	UNIMPL		bdflush
+135	UNIMPL		sysfs
+136	STD		{ int linux_sys_personality(int per); }
+137	UNIMPL		afs_syscall
+138	STD		{ int linux_sys_setfsuid(uid_t uid); }
+139	NOARGS		{ int linux_sys_getfsuid(void); }
+140	STD		{ int linux_sys_llseek(int fd, u_int32_t ohigh, \
+			    u_int32_t olow, caddr_t res, int whence); }
+141	STD		{ int linux_sys_getdents(int fd, \
+			    struct linux_dirent *dent, unsigned int count); }
+142	STD		{ int linux_sys_select(int nfds, fd_set *readfds, \
+			    fd_set *writefds, fd_set *exceptfds, \
+			    struct timeval *timeout); }
+143	NOARGS		{ int sys_flock(int fd, int how); }
+144	STD		{ int linux_sys_msync(caddr_t addr, int len, int fl); }
+145	NOARGS		{ int sys_readv(int fd, struct iovec *iovp, \
+				u_int iovcnt); }
+146	NOARGS		{ int sys_writev(int fd, struct iovec *iovp, \
+				u_int iovcnt); }
+147	NOARGS		{ pid_t sys_getsid(pid_t pid); }
+148	STD		{ int linux_sys_fdatasync(int fd); }
+149	STD		{ int linux_sys___sysctl(struct linux___sysctl *lsp); }
+150	NOARGS		{ int sys_mlock(caddr_t addr, size_t len); }
+151	NOARGS		{ int sys_munlock(caddr_t addr, size_t len); }
+152	NOARGS		{ int sys_mlockall(int flags); }
+153	NOARGS		{ int sys_munlockall(void); }
+154	STD		{ int linux_sys_sched_setparam(pid_t pid, \
+			    const struct linux_sched_param *sp); }
+155	STD		{ int linux_sys_sched_getparam(pid_t pid, \
+			    struct linux_sched_param *sp); }
+156	STD		{ int linux_sys_sched_setscheduler(pid_t pid, \
+			    int policy, const struct linux_sched_param *sp); }
+157	STD		{ int linux_sys_sched_getscheduler(pid_t pid); }
+158	STD		{ int linux_sys_sched_yield(void); }
+159	STD		{ int linux_sys_sched_get_priority_max(int policy); }
+160	STD		{ int linux_sys_sched_get_priority_min(int policy); }
+161	UNIMPL		sched_rr_get_interval
+162	NOARGS		{ int sys_nanosleep(const struct timespec *rqtp, \
+				struct timespec *rmtp); }
+163	STD		{ void *linux_sys_mremap(void *old_address, \
+			    size_t old_size, size_t new_size, u_long flags); }
+164	STD		{ int linux_sys_setresuid(uid_t ruid, uid_t euid, \
+			    uid_t suid); }
+165	STD		{ int linux_sys_getresuid(uid_t *ruid, uid_t *euid, \
+			    uid_t *suid); }
+166	UNIMPL		query_module
+167	NOARGS		{ int sys_poll(struct pollfd *fds, u_int nfds, \
+			    int timeout); }
+168	UNIMPL		nfsservctl
+169	STD		{ int linux_sys_setresgid(gid_t rgid, gid_t egid, \
+			    gid_t sgid); }
+170	STD		{ int linux_sys_getresgid(gid_t *rgid, gid_t *egid, \
+			    gid_t *sgid); }
+171	UNIMPL		prctl
+172	STD		{ int linux_sys_rt_sigreturn(void); }
+173	STD		{ int linux_sys_rt_sigaction(int signum, \
+			    const struct linux_sigaction *nsa, \
+			    struct linux_sigaction *osa, \
+			    size_t sigsetsize); }
+174	STD		{ int linux_sys_rt_sigprocmask(int how, \
+			    const linux_sigset_t *set, \
+			    linux_sigset_t *oset, \
+			    size_t sigsetsize); }
+175	STD		{ int linux_sys_rt_sigpending( \
+			    linux_sigset_t *set, \
+			    size_t sigsetsize); }
+176	UNIMPL		rt_sigtimedwait
+; XXX XAX int here?  sigset_t here?  siginfo_t
+177	STD		{ int linux_sys_rt_queueinfo(int pid, int signum, \
+			    void *uinfo); }
+178	STD		{ int linux_sys_rt_sigsuspend(linux_sigset_t *unewset, \
+			    size_t sigsetsize); }
+179	STD		{ int linux_sys_pread(int fd, char *buf, \
+			    size_t nbyte, linux_off_t offset); }
+180	STD		{ int linux_sys_pwrite(int fd, char *buf, \
+			    size_t nbyte, linux_off_t offset); }
+181	STD		{ int linux_sys_chown(const char *path, \
+			    int uid, int gid); }
+182	NOARGS		{ int sys___getcwd(char *bufp, size_t length); }
+183	UNIMPL		capget
+184	UNIMPL		capset
+185	STD		{ int linux_sys_sigaltstack( \
+			    const struct linux_sigaltstack *ss, \
+			    struct linux_sigaltstack *oss); }
+186	UNIMPL		sendfile
+187	UNIMPL		getpmsg
+188	UNIMPL		putpmsg
+189	NOARGS		{ int sys___vfork14(void); }
+190	UNIMPL		sys_getrlimit
+191	UNIMPL		/* unused */
+192	UNIMPL		mmap2
+193	UNIMPL		truncate64
+194	UNIMPL		ftruncate64
+195	UNIMPL		stat64
+196	UNIMPL		lstat64
+197	UNIMPL		fstat64
+198	UNIMPL		sys_pciconfig_read
+199	UNIMPL		sys_pciconfig_write
+200	UNIMPL		sys_pciconfig_iobase
+201	UNIMPL		/* Unused (MacOnLinux project) */
+202	UNIMPL		sys_getdents64
+
--- sys/compat/linux/arch/powerpc/linux_exec.h.orig	Thu Dec 21 03:22:20 2000
+++ sys/compat/linux/arch/powerpc/linux_exec.h	Fri Dec 29 14:44:20 2000
@@ -0,0 +1,68 @@
+/*	$NetBSD$  */
+
+/* 
+ * Derived from NetBSD's sys/compat/linux/arch/i386/linux_exec.h
+ * and from Linux's include/linux/elf.h
+ * 
+ * a.out does not work yet. Do we need it? LinuxPPC seems to use ELF only
+ * Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr>  
+ */
+
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the NetBSD
+ *	Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _POWERPC_LINUX_EXEC_H
+#define _POWERPC_LINUX_EXEC_H
+
+/*
+ * Linux a.out format parameters
+ * XXX Can't find the appropriate value for LINUX_M_POWERPC in LinuxPPC sources
+ * But did they ever run a.out on LinuxPPC ?
+ */
+#define LINUX_M_POWERPC		1          /* XXX This is a WRONG value */		
+#define LINUX_MID_MACHINE	LINUX_M_POWERPC	
+
+/*
+ * Linux Elf32 format parameters
+ */
+#define LINUX_GCC_SIGNATURE	20 /* EM_PPC in Linux's include/linux/elf.h */
+
+#define LINUX_ELF_AUX_ARGSIZ \
+	(howmany(ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof(Elf32_Addr)))
+#ifdef ELF32NAME
+#define LINUX_COPYARGS_FUNCTION ELF32NAME(copyargs)
+#else
+#define LINUX_COPYARGS_FUNCTION ELFNAME(copyargs)
+#endif
+
+#endif /* !_POWERPC_LINUX_EXEC_H */
--- sys/compat/linux/arch/powerpc/linux_fcntl.h.orig	Tue Dec 26 14:54:00 2000
+++ sys/compat/linux/arch/powerpc/linux_fcntl.h	Fri Dec 29 14:45:06 2000
@@ -0,0 +1,93 @@
+/* $NetBSD$ */
+
+/* 
+ * Derived from NetBSD's sys/compat/linux/i386/linux_fcntl.h and
+ * from Linux's include/asm-ppc/fcntl.h
+ * Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr>
+ */
+
+/*-
+ * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Frank van der Linden and Eric Haszlakiewicz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the NetBSD
+ *	Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Various flag values used in Linux for open(2) and fcntl(2).
+ */
+
+#ifndef _POWERPC_LINUX_FCNTL_H
+#define _POWERPC_LINUX_FCNTL_H
+
+/* 
+ * read/write mode for open(2) are defined in common/linux_fcntl.h
+ */
+
+/* 
+ * flags used in open(2) 
+ * From Linux's include/asm-ppc/fcntl.h 
+ */
+#define LINUX_O_CREAT		0x0100
+#define LINUX_O_EXCL			0x0200	
+#define LINUX_O_NOCTTY		0x0400
+#define LINUX_O_TRUNC		0x01000
+#define LINUX_O_APPEND		0x02000
+#define LINUX_O_NONBLOCK   0x04000
+#define LINUX_O_NDELAY		LINUX_O_NONBLOCK
+#define LINUX_O_SYNC			0x010000
+
+#define LINUX_FASYNC			0x020000
+
+/* 
+ * fcntl(2) operations 
+ * From Linux's include/asm-ppc/fcntl.h 
+ */
+#define LINUX_F_DUPFD		0
+#define LINUX_F_GETFD		1
+#define LINUX_F_SETFD		2
+#define LINUX_F_GETFL		3
+#define LINUX_F_SETFL		4
+#define LINUX_F_GETLK		5
+#define LINUX_F_SETLK		6
+#define LINUX_F_SETLKW		7
+#define LINUX_F_SETOWN		8
+#define LINUX_F_GETOWN		9
+
+#define LINUX_F_RDLCK		0
+#define LINUX_F_WRLCK		1
+#define LINUX_F_UNLCK		2
+
+#define LINUX_LOCK_EX		4  /* F_EXLCK in Linux, and comment "or 3 " */
+#define LINUX_LOCK_SH		8  /* F_SHLCK in Linux, and comment "or 4'  */
+
+#endif /* !_POWERPC_LINUX_FCNTL_H */
--- sys/compat/linux/arch/powerpc/linux_types.h.orig	Sat Dec 23 11:33:04 2000
+++ sys/compat/linux/arch/powerpc/linux_types.h	Fri Dec 29 14:35:24 2000
@@ -0,0 +1,141 @@
+/*	$NetBSD$ */
+
+/* 
+ * Derived from NetBSD's sys/compat/linux/i386/linux_types.h and
+ * from various Linux header files 
+ * Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr>
+ */
+
+/*-
+ * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Frank van der Linden and Eric Haszlakiewicz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the NetBSD
+ *	Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _POWERPC_LINUX_TYPES_H
+#define _POWERPC_LINUX_TYPES_H
+
+/* 
+ * from Linux's include/asm-ppc/posix-types.h 
+ */
+typedef struct {
+	int	val[2];
+} linux_fsid_t;
+
+typedef unsigned int linux_uid_t;
+typedef unsigned int linux_gid_t;
+typedef unsigned int linux_dev_t;
+typedef unsigned int linux_ino_t;
+typedef unsigned int linux_mode_t;
+typedef unsigned short linux_nlink_t;
+typedef long linux_time_t;
+typedef long linux_clock_t;
+typedef long linux_off_t;
+typedef int linux_pid_t;
+
+/* 
+ * From Linux's include/asm-ppc/termbits.h 
+ */
+typedef unsigned char linux_cc_t;
+typedef unsigned int linux_speed_t;
+typedef unsigned int linux_tcflag_t;
+
+/* 
+ * From Linux's include/asm-ppc/statfs.h 
+ */
+struct linux_statfs {
+	long	l_ftype;	   /* Linux name -> NetBSD Linux emul name: s/f_/I_f/ */
+	long	l_fbsize;	
+	long	l_fblocks;	
+	long	l_fbfree;	
+	long	l_fbavail;	
+	long	l_ffiles;	
+	long	l_fffree;	
+	linux_fsid_t	l_ffsid;	
+	long	l_fnamelen;	
+	long	l_fspare[6];	
+};
+
+/* 
+ * From Linux's include/asm-ppc/stat.h 
+ */
+struct linux_stat {  /* warning: there is also a old_kernel_stat in Linux*/
+	linux_dev_t		lst_dev; 
+	linux_ino_t		lst_ino; /* expect for unused fileds, of course */
+	linux_mode_t		lst_mode;
+	linux_nlink_t		lst_nlink;
+	linux_uid_t		lst_uid;
+	linux_gid_t		lst_gid;
+	linux_dev_t		lst_rdev;
+	linux_off_t		lst_size;
+	unsigned long		lst_blksize;
+	unsigned long		lst_blocks;
+	unsigned long		lst_atime;
+	unsigned long		unused1;
+	unsigned long		lst_mtime;
+	unsigned long		unused2;
+	unsigned long		lst_ctime;
+	unsigned long		unused3;
+	unsigned long		unused4;
+	unsigned long		unused5;
+};
+
+/* 
+ * This matches struct stat64 in glibc2.1, hence the absolutely
+ * insane amounts of padding around dev_t's.
+ *
+ * Still from Linux'sinclude/asm-ppc/stat.h 
+ */  
+struct linux_stat64 {
+	unsigned long long	lst_dev;   
+	unsigned long long	lst_ino;
+	unsigned int	lst_mode;
+	unsigned int	lst_nlink;
+	unsigned int	lst_uid;
+	unsigned int	lst_gid;
+	unsigned long long	lst_rdev;
+	unsigned short	int __pad2;  
+	long long	lst_size;
+	long	lst_blksize;
+	long long	lst_blocks;	/* Number 512-byte blocks allocated. */
+	long	lst_atime;
+	unsigned long int	__unused1;
+	long	lst_mtime;
+	unsigned long int	__unused2;
+	long	lst_ctime;
+	unsigned long int	__unused3;
+	unsigned long int	__unused4;
+	unsigned long int	__unused5;
+};
+
+#endif /* !_POWERPC_LINUX_TYPES_H */
--- sys/compat/linux/arch/powerpc/linux_siginfo.h.orig	Sat Dec 23 12:42:51 2000
+++ sys/compat/linux/arch/powerpc/linux_siginfo.h	Fri Dec 29 14:28:54 2000
@@ -0,0 +1,129 @@
+/*	$NetBSD$ */
+
+/* 
+ * Derived from NetBSD's sys/compat/linux/i386/linux_siginfo.h and
+ * from Linux's include/asm-ppc/siginfo.h
+ * Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr>
+ */
+
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Eric Haszlakiewicz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the NetBSD
+ *	Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _POWERPC_LINUX_SIGINFO_H
+#define _POWERPC_LINUX_SIGINFO_H
+
+/* 
+ * Everything is from Linux's include/asm-ppc/siginfo.h 
+ */
+typedef union linux_sigval {
+	int	sival_int;
+	void	*sival_ptr;
+} linux_sigval_t;
+
+#define SI_MAX_SIZE	128
+#define SI_PAD_SIZE	((SI_MAX_SIZE/sizeof(int)) - 3)
+
+typedef struct linux_siginfo {
+	int	lsi_signo;
+	int	lsi_errno;
+	int	lsi_code;
+	union {
+		int _pad[SI_PAD_SIZE];
+
+		/* kill() */
+		struct {
+			linux_pid_t	_pid;
+			linux_uid_t	_uid;
+		} _kill;
+
+		/* POSIX.1b timers */
+		struct {
+			unsigned int _timer1;
+			unsigned int _timer2;
+		} _timer;
+
+		/* POSIX.1b signals */
+		struct {
+			linux_pid_t	_pid;
+			linux_uid_t	_uid;
+			linux_sigval_t	_sigval;
+		} _rt;
+
+		/* SIGCHLD */
+		struct {
+			linux_pid_t	_pid;
+			linux_uid_t	_uid;
+			int		_status;
+			linux_clock_t	_utime;
+			linux_clock_t	_stime;
+		} _sigchld;
+
+		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
+		struct {
+			void *_addr;
+		} _sigfault;
+
+		/* SIGPOLL */
+		struct {
+			int _band;
+			int _fd;
+		} _sigpoll;
+
+	} _sidata;
+} linux_siginfo_t;
+
+#define lsi_pid		_sidata._kill._pid
+#define lsi_uid		_sidata._kill._uid
+
+/*
+ * si_code values
+ * Digital reserves positive values for kernel-generated signals.
+ */
+#define LINUX__SI_CODE(T,N)  ((T) << 16 | ((N) & 0xffff))
+
+#define LINUX_SI_USER		0
+#define	LINUX_SI_KERNEL		0x80
+#define LINUX_SI_QUEUE		-1
+#define LINUX_SI_TIMER		LINUX__SI_CODE(__SI_TIMER,-2)
+#define LINUX_SI_MESGQ		-3
+#define LINUX_SI_ASYNCIO	-4
+#define LINUX_SI_SIGIO  	-5
+
+#define LINUX_SI_FROMUSER(sp)	((sp)->si_code <= 0)
+#define LINUX_SI_FROMKERENL(sp)	((sp)->si_code > 0)
+
+
+#endif /* !_POWERPC_LINUX_SIGINFO_H */
--- sys/compat/linux/arch/powerpc/linux_ioctl.h.orig	Sat Dec 23 13:02:30 2000
+++ sys/compat/linux/arch/powerpc/linux_ioctl.h	Fri Dec 29 14:45:23 2000
@@ -0,0 +1,60 @@
+/* $NetBSD$
+
+/* 
+ * Derived from NetBSD's sys/compat/linux/i386/linux_ioctl.h and
+ * from Linux's include/asm-ppc/ioctl.h
+ * Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr>
+ */
+
+/*-
+ * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Frank van der Linden and Eric Haszlakiewicz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the NetBSD
+ *	Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _POWERPC_LINUX_IOCTL_H
+#define _POWERPC_LINUX_IOCTL_H
+
+/* From Linux's include/asm-ppc/ioctl.h */
+#define _LINUX_IOC_NRBITS	 8
+#define _LINUX_IOC_TYPEBITS	 8
+#define _LINUX_IOC_SIZEBITS	13
+#define _LINUX_IOC_DIRBITS	 3
+
+#define _LINUX_IOC_NRSHIFT	 0
+
+#define _LINUX_IOC_NONE		1U
+#define _LINUX_IOC_READ		2U
+#define _LINUX_IOC_WRITE	4U
+
+#endif /* !_POWERPC_LINUX_IOCTL_H */
--- sys/compat/linux/arch/powerpc/linux_signal.h.orig	Sat Dec 23 13:06:19 2000
+++ sys/compat/linux/arch/powerpc/linux_signal.h	Fri Dec 29 14:28:43 2000
@@ -0,0 +1,148 @@
+/* $NetBSD$ */
+
+/* 
+ * Derived from NetBSD's sys/compat/linux/i386/linux_signal.h and
+ * from Linux's include/asm-ppc/signal.h
+ * Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr>
+ */
+
+/*-
+ * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Frank van der Linden and Eric Haszlakiewicz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the NetBSD
+ *	Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _POWERPC_LINUX_SIGNAL_H
+#define _POWERPC_LINUX_SIGNAL_H
+
+/* 
+ * Everything is from Linux's include/asm-ppc/signal.h 
+ */
+#define LINUX_SIGHUP	 1
+#define LINUX_SIGINT	 2
+#define LINUX_SIGQUIT	 3
+#define LINUX_SIGILL	 4
+#define LINUX_SIGTRAP	 5
+#define LINUX_SIGABRT	 6
+#define LINUX_SIGIOT	 6
+#define LINUX_SIGBUS	 7
+#define LINUX_SIGFPE	 8
+#define LINUX_SIGKILL	 9
+#define LINUX_SIGUSR1	10
+#define LINUX_SIGSEGV	11
+#define LINUX_SIGUSR2	12
+#define LINUX_SIGPIPE	13
+#define LINUX_SIGALRM	14
+#define LINUX_SIGTERM	15
+#define LINUX_SIGSTKFLT	16
+#define LINUX_SIGCHLD	17
+#define LINUX_SIGCONT	18
+#define LINUX_SIGSTOP	19
+#define LINUX_SIGTSTP	20
+#define LINUX_SIGTTIN	21
+#define LINUX_SIGTTOU	22
+#define LINUX_SIGURG	23
+#define LINUX_SIGXCPU	24
+#define LINUX_SIGXFSZ	25
+#define LINUX_SIGVTALRM	26
+#define LINUX_SIGPROF	27
+#define LINUX_SIGWINCH	28
+#define LINUX_SIGIO	29
+#define LINUX_SIGPOLL 	LINUX_SIGIO
+#define LINUX_SIGLOST	29
+#define LINUX_SIGPWR	30
+#define LINUX_SIGSYS	31
+#define LINUX_SIGUNUSED	31
+#define LINUX_SIGRTMIN  32
+/* #define LINUX_NSIG	32 */ /* XXX from i386. Does not exists for ppc */     
+
+#define LINUX__NSIG 		64
+#define LINUX__NSIG_BPW		32
+#define LINUX__NSIG_WORDS	(LINUX__NSIG / LINUX__NSIG_BPW)
+
+#define LINUX_SIG_BLOCK		0
+#define LINUX_SIG_UNBLOCK	1
+#define LINUX_SIG_SETMASK	2
+
+/* sa_flags */
+#define LINUX_SA_NOCLDSTOP	0x00000001
+#define LINUX_SA_SIGINFO	0x00000004
+#define LINUX_SA_ONSTACK	0x08000000
+#define LINUX_SA_RESTART	0x10000000
+#define LINUX_SA_INTERRUPT	0x20000000
+#define LINUX_SA_NODEFER	0x40000000
+#define LINUX_SA_RESETHAND 		0x80000000
+#define LINUX_SA_NOMASK		LINUX_SA_NODEFER
+#define LINUX_SA_ONESHOT	LINUX_SA_RESETHAND
+#define LINUX_SA_ALLBITS	0xf8000001  /* XXX from i386, not in ppc */
+
+typedef void	(*linux_handler_t) __P((int));
+
+typedef unsigned long	linux_old_sigset_t;
+typedef struct {
+	unsigned long sig[LINUX__NSIG_WORDS];
+} linux_sigset_t;
+
+struct linux_old_sigaction {
+	linux_handler_t		sa_handler;
+	linux_old_sigset_t	sa_mask;
+	unsigned long			sa_flags;
+	void			(*sa_restorer) __P((void));
+};
+
+/* Used in rt_* calls */
+struct linux_sigaction {
+	linux_handler_t		sa_handler;
+	unsigned long			sa_flags;
+	void			(*sa_restorer) __P((void));
+	linux_sigset_t		sa_mask;
+};
+
+struct linux_k_sigaction {
+	struct linux_sigaction sa;
+/* #define k_sa_restorer	sa.sa_restorer */ /* XXX from i386, not in ppc */
+};
+
+#define	LINUX_SS_ONSTACK	1
+#define	LINUX_SS_DISABLE	2
+
+#define	LINUX_MINSIGSTKSZ	2048
+#define	LINUX_SIGSTKSZ		8192
+
+struct linux_sigaltstack {
+	void *ss_sp;
+	int ss_flags;
+	size_t ss_size;
+};
+
+#endif /* !_POWERPC_LINUX_SIGNAL_H */
--- sys/compat/linux/arch/powerpc/linux_machdep.h.orig	Sat Dec 23 13:25:04 2000
+++ sys/compat/linux/arch/powerpc/linux_machdep.h	Fri Dec 29 13:59:31 2000
@@ -0,0 +1,175 @@
+/*	$NetBSD$ */
+
+/* 
+ * Derived from NetBSD's sys/compat/linux/i386/linux_machdep.h and
+ * various Linux header files
+ * Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr>
+ */
+
+/*-
+ * Copyright (c) 1995, 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Frank van der Linden.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the NetBSD
+ *	Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _POWERPC_LINUX_MACHDEP_H
+#define _POWERPC_LINUX_MACHDEP_H
+
+/* 
+ * From Linux's include/asm-ppc/ptrace.h 
+ * Needed for sigcontext 
+ */
+struct linux_pt_regs {
+   unsigned long lgpr[32];  
+   unsigned long lnip;
+   unsigned long lmsr;
+   unsigned long lorig_gpr3;   /* Used for restarting system calls */
+   unsigned long lctr;
+   unsigned long llink;
+   unsigned long lxer;
+   unsigned long lccr;
+   unsigned long lmq;    /* 601 only (not used at present) */
+               /* Used on APUS to hold IPL value. */
+   unsigned long ltrap;     /* Reason for being here */
+   unsigned long ldar;      /* Fault registers */
+   unsigned long ldsisr;
+   unsigned long lresult;      /* Result of a system call */
+};
+
+/* 
+ * From Linux's include/asm-ppc/sigcontext.h 
+ * Linux/ppc calls that struct sigcontect_struct 
+ */
+struct linux_sigcontext { 
+
+	unsigned long	_unused[4];
+	int				lsignal;  
+   unsigned long	lhandler;
+	unsigned long	lomask;
+	struct linux_pt_regs	*lregs;
+};
+
+/*
+ * We make the stack look like Linux expects it when calling a signal
+ * handler, but use the BSD way of calling the handler and sigreturn().
+ * This means that we need to pass the pointer to the handler too.
+ * It is appended to the frame to not interfere with the rest of it.
+ *
+ * XXX This is from NetBSD/i386. Hope it is not arch dependent...
+ */
+
+struct linux_sigframe {
+	int	sf_sig;
+	struct	linux_sigcontext sf_sc;
+	sig_t	sf_handler;
+};
+
+#ifdef _KERNEL
+__BEGIN_DECLS				/* XXX from NetBSD/i386. not arch dependent? */
+void linux_sendsig __P((sig_t, int, sigset_t *, u_long));
+dev_t linux_fakedev __P((dev_t));
+__END_DECLS
+#endif /* _KERNEL */
+
+/*
+ * Major device numbers of VT device on both Linux and NetBSD. Used in
+ * ugly patch to fake device numbers.
+ *
+ * LINUX_CONS_MAJOR is from Linux's include/linux/major.h
+ */
+#define LINUX_CONS_MAJOR   4  
+#define NETBSD_WSCONS_MAJOR 47
+
+/*
+ * Linux ioctl calls for the keyboard.
+ *
+ * From Linux's include/linux/kd.h 
+ */
+#define LINUX_KDGKBMODE   0x4b44
+#define LINUX_KDSKBMODE   0x4b45
+#define LINUX_KDMKTONE    0x4b30
+#define LINUX_KDSETMODE   0x4b3a
+#define LINUX_KDENABIO    0x4b36
+#define LINUX_KDDISABIO   0x4b37
+#define LINUX_KDGETLED    0x4b31
+#define LINUX_KDSETLED    0x4b32
+#define LINUX_KDGKBTYPE   0x4B33
+#define LINUX_KDGKBENT    0x4B46
+
+/*
+ * Mode for KDSKBMODE which we don't have (we just use plain mode for this)
+ *
+ * From Linux's include/linux/kd.h
+ */
+#define LINUX_K_MEDIUMRAW 2
+
+/*
+ * VT ioctl calls in Linux (the ones that the pcvt emulation in 
+ * wscons can handle)
+ *
+ * From Linux's include/linux/vt.h
+ */
+#define LINUX_VT_OPENQRY    0x5600
+#define LINUX_VT_GETMODE    0x5601
+#define LINUX_VT_SETMODE    0x5602
+#define LINUX_VT_GETSTATE   0x5603
+#define LINUX_VT_RELDISP    0x5605
+#define LINUX_VT_ACTIVATE   0x5606
+#define LINUX_VT_WAITACTIVE 0x5607
+#define LINUX_VT_DISALLOCATE	0x5608
+
+/*
+ * This range used by VMWare (XXX)
+ *
+ * From Linux's include/linux/vt.h
+ * XXX It's not sure this s needed for powerpc 
+ */
+#define LINUX_VMWARE_NONE 200
+#define LINUX_VMWARE_LAST 237
+
+/*
+ * Range of ioctls to just pass on, so that LKMs (like VMWare) can
+ * handle them.
+ * 
+ * From Linux's include/linux/vt.h
+ */
+#define LINUX_IOCTL_MIN_PASS	LINUX_VMWARE_NONE
+#define LINUX_IOCTL_MAX_PASS	(LINUX_VMWARE_LAST+8)
+
+#ifdef _KERNEL
+__BEGIN_DECLS /* XXX from NetBSD/i386. Not arch dependent? */
+void linux_syscall_intern __P((struct proc *));
+__END_DECLS
+#endif /* !_KERNEL */
+
+#endif /* _POWERPC_LINUX_MACHDEP_H */
--- sys/compat/linux/arch/powerpc/linux_sigarray.c.orig	Sun Dec 24 01:44:31 2000
+++ sys/compat/linux/arch/powerpc/linux_sigarray.c	Fri Dec 29 14:46:23 2000
@@ -0,0 +1,117 @@
+/*	$NetBSD$ */
+
+/* 
+ * Derived from NetBSD's sys/compat/linux/i386/linux_sigarray.c, 
+ * from NetBSD's sys/sys/signal.h and Linux's include/asm-ppc/signal.h
+ * Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr>
+ */
+
+/*-
+ * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Frank van der Linden and Eric Haszlakiewicz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the NetBSD
+ *	Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/signal.h>
+
+#include <compat/linux/common/linux_signal.h>
+
+int linux_to_native_sig[LINUX__NSIG] = {
+	0,			/* 0 */
+	SIGHUP,
+	SIGINT,
+	SIGQUIT,
+	SIGILL,
+	SIGTRAP,	/* 5 */
+	SIGABRT,
+	SIGBUS, 
+	SIGFPE,
+	SIGKILL,
+	SIGUSR1,	/* 10 */
+	SIGSEGV,
+	SIGUSR2,
+	SIGPIPE,
+	SIGALRM,
+	SIGTERM,	/* 15 */
+	0,			/* SIGSTKFLT */
+	SIGCHLD,
+	SIGCONT,
+	SIGSTOP,
+	SIGTSTP,	/* 20 */
+	SIGTTIN,
+	SIGTTOU,
+	SIGURG,
+	SIGXCPU,
+	SIGXFSZ,	/* 25 */
+	SIGVTALRM,
+	SIGPROF,
+	SIGWINCH,
+	SIGIO,
+	SIGPWR,	/* 30 */
+	SIGSYS,
+	0,			/* SIGUNUSED */
+	0,
+	0,
+	0,			/* 35 */
+	0,
+	0,
+	0,
+	0,
+	0,			/* 40 */
+	0,
+	0,
+	0,
+	0,
+	0,			/* 45 */
+	0,
+	0,
+	0,
+	0,
+	0,			/* 50 */
+	0,
+	0,
+	0,
+	0,
+	0,			/* 55 */
+	0,
+	0,
+	0,
+	0,
+	0,			/* 60 */
+	0,
+	0,
+	0,
+};
--- sys/compat/linux/arch/powerpc/linux_machdep.c.orig	Sun Dec 24 01:46:52 2000
+++ sys/compat/linux/arch/powerpc/linux_machdep.c	Fri Dec 29 13:54:17 2000
@@ -0,0 +1,235 @@
+/*	$NetBSD$ */
+
+/* 
+ * Derived from NetBSD's sys/compat/linux/i386/linux_machdep.c 
+ * This file is not finished yet.
+ * -functions to write:
+ *   linux_setregs()
+ *   linux_sendsig()
+ *   linux_sys_sigreturn()
+ *   linux_sys_modify_ldt()
+ *   linux_fakedev()
+ *   linux_sys_iopl()
+ *   linux_sys_ioperm()
+ * -functions to check (imported from i386):
+ *   linux_sys_sigreturn()
+ * Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr>
+ */
+
+/*-
+ * Copyright (c) 1995, 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Frank van der Linden.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the NetBSD
+ *	Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* #if defined(KERNEL) && !defined(_LKM)
+#include "opt_user_ldt.h"
+#endif */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/signalvar.h>
+#include <sys/kernel.h>
+#include <sys/map.h>
+#include <sys/proc.h>
+#include <sys/user.h>
+#include <sys/buf.h>
+#include <sys/reboot.h>
+#include <sys/conf.h>
+#include <sys/exec.h>
+#include <sys/file.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/msgbuf.h>
+#include <sys/mount.h>
+#include <sys/vnode.h>
+#include <sys/device.h>
+#include <sys/syscallargs.h>
+#include <sys/filedesc.h>
+#include <sys/exec_elf.h>
+#include <sys/disklabel.h>
+#include <miscfs/specfs/specdev.h>
+
+#include <compat/linux/common/linux_types.h>
+#include <compat/linux/common/linux_signal.h>
+#include <compat/linux/common/linux_util.h>
+#include <compat/linux/common/linux_ioctl.h>
+#include <compat/linux/common/linux_hdio.h>
+#include <compat/linux/common/linux_exec.h>
+#include <compat/linux/common/linux_machdep.h>
+
+#include <compat/linux/linux_syscallargs.h>
+
+#include <machine/cpu.h>
+#include <machine/psl.h>
+#include <machine/reg.h>
+#include <machine/vmparam.h>
+
+/*
+ * To see whether wscons is configured (for virtual console ioctl calls).
+ */
+#if defined(_KERNEL) && !defined(_LKM)
+#include "wsdisplay.h"
+#endif
+#if (NWSDISPLAY > 0)
+#include <sys/ioctl.h>
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsdisplay_usl_io.h>
+#if defined(_KERNEL) && !defined(_LKM)
+#endif
+#endif
+
+#ifdef USER_LDT
+#include <machine/cpu.h>
+int linux_read_ldt __P((struct proc *, struct linux_sys_modify_ldt_args *,
+    register_t *));
+int linux_write_ldt __P((struct proc *, struct linux_sys_modify_ldt_args *,
+    register_t *));
+#endif
+
+void
+linux_setregs(p, epp, stack)
+	struct proc *p;
+	struct exec_package *epp;
+	u_long stack;
+{
+  /* XXX write me */
+}
+
+/*
+ * Send an interrupt to process.
+ *
+ */
+
+void
+linux_sendsig(catcher, sig, mask, code)
+	sig_t catcher;
+	int sig;
+	sigset_t *mask;
+	u_long code;
+{
+  /* XXX write me */
+}
+
+/*
+ * System call to cleanup state after a signal
+ * has been taken.  Reset signal mask and
+ * stack state from context left by sendsig (above).
+ * Return to previous pc and psl as specified by
+ * context left by sendsig. Check carefully to
+ * make sure that the user has not modified the
+ * psl to gain improper privileges or to cause
+ * a machine fault.
+ */
+int
+linux_sys_rt_sigreturn(p, v, retval)
+	struct proc *p;
+	void *v;
+	register_t *retval;
+{
+	/* XXX XAX write me */
+	return(ENOSYS);
+}
+
+int
+linux_sys_sigreturn(p, v, retval)
+	struct proc *p;
+	void *v;
+	register_t *retval;
+{
+  /* XXX write me */
+  return 0;
+}
+
+
+int
+linux_sys_modify_ldt(p, v, retval)
+	struct proc *p;
+	void *v;
+	register_t *retval;
+{
+  /* XXX write me */
+  return 0;
+}
+
+/* hack to make svgalib work */
+dev_t
+linux_fakedev(dev)
+	dev_t dev;
+{
+  /* XXX write me */
+  return 0;
+}
+
+/*
+ * We come here in a last attempt to satisfy a Linux ioctl() call
+ */
+int
+linux_machdepioctl(p, v, retval)
+	struct proc *p;
+	void *v;
+	register_t *retval;
+{
+  /* XXX write me */
+  return 0;
+}
+
+/*
+ * Set I/O permissions for a process. Just set the maximum level
+ * right away (ignoring the argument), otherwise we would have
+ * to rely on I/O permission maps, which are not implemented.
+ */
+int
+linux_sys_iopl(p, v, retval)
+	struct proc *p;
+	void *v;
+	register_t *retval;
+{
+  /* XXX write me */
+	return 0;
+}
+
+/*
+ * See above. If a root process tries to set access to an I/O port,
+ * just let it have the whole range.
+ */
+int
+linux_sys_ioperm(p, v, retval)
+	struct proc *p;
+	void *v;
+	register_t *retval;
+{
+  /* XXX write me */
+	return 0;
+}
--- sys/compat/linux/arch/powerpc/linux_ptrace.c.orig	Sun Dec 24 01:53:39 2000
+++ sys/compat/linux/arch/powerpc/linux_ptrace.c	Fri Dec 29 14:08:17 2000
@@ -0,0 +1,324 @@
+/*	$NetBSD$ */
+
+/* 
+ * Derived from NetBSD's sys/compat/linux/i386/linux_ptrace.c and
+ * From various Linux header files
+ *
+ * Function linux_sys_ptrace_arch() is taken from NetBSD/i386 
+ * with some stuff deleted to get it compiling. It is not expected to 
+ * work, and it should be checked with care or re-write.
+ *
+ * Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr>
+ */
+
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matthias Scheler.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the NetBSD
+ *	Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/malloc.h>
+#include <sys/mount.h>
+#include <sys/proc.h>
+#include <sys/ptrace.h>
+#include <sys/systm.h>
+#include <sys/syscallargs.h>
+#include <uvm/uvm_extern.h>
+
+#include <machine/reg.h>
+
+#include <compat/linux/common/linux_types.h>
+#include <compat/linux/common/linux_ptrace.h>
+#include <compat/linux/common/linux_signal.h>
+
+#include <compat/linux/common/linux_util.h>
+#include <compat/linux/common/linux_machdep.h>
+#include <compat/linux/common/linux_emuldata.h>
+#include <compat/linux/common/linux_exec.h>	/* for emul_linux */
+
+#include <compat/linux/linux_syscallargs.h>
+
+#include <lib/libkern/libkern.h>	/* for offsetof() */
+
+/* 
+ * From Linux's include/asm-ppc/ptrace.h.  
+ * structure used for storing reg context:  defined in linux_machdep.h 
+ * structure used for storing floating point context:
+ * Linux just uses a double fpr[32], no struct 
+ */
+ 
+/* 
+ * user struct for linux process - this is used for Linux ptrace emulation 
+ * most of it is junk only used by gdb 
+ * 
+ * From Linux's include/asm-ppc/user.h 
+ */
+
+/* 
+ * XXX u_ar0 was a struct reg in Linux/powerpc 
+ * Can't find out what a struct regs is for Linux/powerpc, 
+ * so we use a struct pt_regs instead. don't know if this is right.
+ * Should we use the NetBSD's struct reg from machine/reg.h ? 
+ */
+
+struct linux_user {
+   struct linux_pt_regs regs;      
+   size_t      u_tsize;    
+   size_t      u_dsize;    
+   size_t      u_ssize;    
+   unsigned long  start_code;
+   unsigned long  start_data;
+   unsigned long  start_stack;
+   long int signal;     
+   struct linux_pt_regs *  u_ar0;         /* help gdb find registers */
+   unsigned long  magic;        
+   char     u_comm[32];    
+};
+
+#define lusr_startgdb regs
+#define LUSR_OFF(member)	offsetof(struct linux_user, member)
+#define ISSET(t, f)		((t) & (f))
+
+int
+linux_sys_ptrace_arch(p, v, retval)   /* XXX Check me! (From NetBSD/i386) */
+	struct proc *p;
+	void *v;
+	register_t *retval;
+{
+	struct linux_sys_ptrace_args /* {
+		syscallarg(int) request;
+		syscallarg(int) pid;
+		syscallarg(int) addr;
+		syscallarg(int) data;
+	} */ *uap = v;
+	int request, error;
+	struct proc *t;				/* target process */
+	struct reg *regs = NULL;
+	struct fpreg *fpregs = NULL;
+	struct linux_pt_regs *linux_regs = NULL;
+   double *linux_fpreg=NULL;  /* it's an array, not a struct */
+	int addr;
+	int i;
+
+	request = SCARG(uap, request);
+
+	if ((request != LINUX_PTRACE_PEEKUSR) &&
+	    (request != LINUX_PTRACE_POKEUSR) &&
+	    (request != LINUX_PTRACE_GETREGS) &&
+	    (request != LINUX_PTRACE_SETREGS) &&
+	    (request != LINUX_PTRACE_GETFPREGS) &&
+	    (request != LINUX_PTRACE_SETFPREGS))
+		return EIO;
+
+	/* Find the process we're supposed to be operating on. */
+	if ((t = pfind(SCARG(uap, pid))) == NULL)
+		return ESRCH;
+
+	/*
+	 * You can't do what you want to the process if:
+	 *	(1) It's not being traced at all,
+	 */
+	if (!ISSET(t->p_flag, P_TRACED))
+		return EPERM;
+
+	/*
+	 *	(2) it's being traced by procfs (which has
+	 *	    different signal delivery semantics),
+	 */
+	if (ISSET(t->p_flag, P_FSTRACE))
+		return EBUSY;
+
+	/*
+	 *	(3) it's not being traced by _you_, or
+	 */
+	if (t->p_pptr != p)
+		return EBUSY;
+
+	/*
+	 *	(4) it's not currently stopped.
+	 */
+	if (t->p_stat != SSTOP || !ISSET(t->p_flag, P_WAITED))
+		return EBUSY;
+
+	*retval = 0;
+
+	switch (request) {
+	case  LINUX_PTRACE_GETREGS:
+		MALLOC(regs, struct reg*, sizeof(struct reg), M_TEMP, M_WAITOK);
+		MALLOC(linux_regs, struct linux_pt_regs*, sizeof(struct linux_pt_regs),
+				 M_TEMP, M_WAITOK);
+
+		error = process_read_regs(t, regs);
+		if (error != 0)
+			goto out;
+
+		for (i=0; i<=31; i++) 
+			linux_regs->lgpr[i] = regs->fixreg[i];
+		linux_regs->lnip = 0;
+		linux_regs->lmsr = 0;
+		linux_regs->lorig_gpr3 = 0;
+      linux_regs->lctr = regs->ctr;
+		linux_regs->llink = 0;
+		linux_regs->lxer = regs->xer;
+		linux_regs->lccr = 0;
+		linux_regs->lmq = 0; 
+		linux_regs->ltrap = 0;
+		linux_regs->ldar = 0;
+		linux_regs->ldsisr = 0;
+		linux_regs->lresult = 0;
+
+		error = copyout(linux_regs, (caddr_t)SCARG(uap, data),
+		    sizeof(struct linux_pt_regs));
+		goto out;
+
+	case  LINUX_PTRACE_SETREGS:
+		MALLOC(regs, struct reg*, sizeof(struct reg), M_TEMP, M_WAITOK);
+		MALLOC(linux_regs, struct linux_pt_regs*, sizeof(struct linux_pt_regs),
+			M_TEMP, M_WAITOK);
+
+		error = copyin((caddr_t)SCARG(uap, data), linux_regs,
+		    sizeof(struct linux_pt_regs));
+		if (error != 0)
+			goto out;
+
+		for (i=0; i<=31; i++) 
+			regs->fixreg[i] = linux_regs->lgpr[i];
+		regs->lr = 0;
+		regs->cr = 0;
+		regs->xer = linux_regs->lxer;
+		regs->ctr = linux_regs->lctr;
+		regs->pc = 0; /* XXX obviously this won't work ;o) */
+
+		error = process_write_regs(t, regs);
+		goto out;
+
+	case  LINUX_PTRACE_GETFPREGS:
+		MALLOC(fpregs, struct fpreg *, sizeof(struct fpreg),
+			M_TEMP, M_WAITOK);
+		MALLOC(linux_fpreg, double *,
+			32*sizeof(double), M_TEMP, M_WAITOK);
+
+		error = process_read_fpregs(t, fpregs);
+		if (error != 0)
+			goto out;
+
+		/* zero the contents if NetBSD fpreg structure is smaller */
+		if (sizeof(struct fpreg) < (32*sizeof(double)))
+			memset(linux_fpreg, '\0', (32*sizeof(double)));
+
+		memcpy(linux_fpreg, fpregs,
+			min(32*sizeof(double), sizeof(struct fpreg)));
+		error = copyout(linux_fpreg, (caddr_t)SCARG(uap, data),
+		    32*sizeof(double));
+		goto out;
+
+	case  LINUX_PTRACE_SETFPREGS:
+		MALLOC(fpregs, struct fpreg *, sizeof(struct fpreg),
+			M_TEMP, M_WAITOK);
+		MALLOC(linux_fpreg, double *,
+			32*sizeof(double), M_TEMP, M_WAITOK);
+		error = copyin((caddr_t)SCARG(uap, data), linux_fpreg,
+		    32*sizeof(double));
+		if (error != 0)
+			goto out;
+
+		memset(fpregs, '\0', sizeof(struct fpreg));
+		memcpy(fpregs, linux_fpreg,
+			min(32*sizeof(double), sizeof(struct fpreg)));
+
+		error = process_write_regs(t, regs);
+		goto out;
+
+	case  LINUX_PTRACE_PEEKUSR:
+		addr = SCARG(uap, addr);
+
+		PHOLD(t);	/* need full process info */
+		error = 0;
+		 if (addr < LUSR_OFF(lusr_startgdb)) { 
+		 	error = 1;
+		} else if (addr == LUSR_OFF(u_tsize))
+			*retval = p->p_vmspace->vm_tsize;
+		else if (addr == LUSR_OFF(u_dsize))
+			*retval = p->p_vmspace->vm_dsize;
+		else if (addr == LUSR_OFF(u_ssize))
+			*retval = p->p_vmspace->vm_ssize;
+		else if (addr == LUSR_OFF(start_code))
+			*retval = (register_t) p->p_vmspace->vm_taddr;
+		else if (addr == LUSR_OFF(start_stack))
+			*retval = (register_t) p->p_vmspace->vm_minsaddr;
+		else if (addr == LUSR_OFF(u_ar0))
+			*retval = LUSR_OFF(regs);
+		else if (addr == LUSR_OFF(signal)) {
+			error = 1;
+		} else if (addr == LUSR_OFF(signal)) {
+			error = 1;
+		} else if (addr == LUSR_OFF(magic)) {
+			error = 1;
+		} else if (addr == LUSR_OFF(u_comm)) {
+			error = 1;
+		} else {
+#ifdef DEBUG_LINUX
+			printf("linux_ptrace: unsupported address: %d\n", addr);
+#endif
+			error = 1;
+		}
+
+		PRELE(t);
+
+		if (!error)
+			return 0;
+
+	case  LINUX_PTRACE_POKEUSR:
+		/* XXX We don't do much yet... */
+		addr = SCARG(uap, addr);
+		break;
+	default:
+		/* never reached */
+		break;
+	}
+
+	return EIO;
+
+    out:
+	if (regs)
+		FREE(regs, M_TEMP);
+	if (fpregs)
+		FREE(fpregs, M_TEMP);
+	if (linux_regs)
+		FREE(linux_regs, M_TEMP);
+	if (linux_fpreg)
+		FREE(linux_fpreg, M_TEMP);
+	return (error);
+}
--- sys/compat/linux/arch/powerpc/linux_socket.h.orig	Tue Dec 26 15:00:41 2000
+++ sys/compat/linux/arch/powerpc/linux_socket.h	Fri Dec 29 14:28:31 2000
@@ -0,0 +1,96 @@
+/*	$NetBSD: linux_socket.h,v 1.5 1998/10/04 00:02:27 fvdl Exp $	*/
+
+/* 
+ * Derived from NetBSD's sys/compat/linux/i386/linux_socket.h and
+ * from Linux's include/asm-ppc/socket.h
+ * Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr>
+ */
+
+/*-
+ * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Frank van der Linden and Eric Haszlakiewicz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the NetBSD
+ *	Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _POWERPC_LINUX_SOCKET_H
+#define _POWERPC_LINUX_SOCKET_H
+
+/* 
+ * Everything is from Linux's include/asm-ppc/socket.h 
+ */
+
+/*
+ * Option levels for [gs]etsockopt(2).  Only SOL_SOCKET is different,
+ * the rest matches IPPROTO_XXX
+ */
+#define LINUX_SOL_SOCKET	1
+
+/*
+ * Options for [gs]etsockopt(2), socket level.  For Linux, thay
+ * are not masks, but just increasing numbers.
+ */
+
+#define LINUX_SO_DEBUG		1
+#define LINUX_SO_REUSEADDR	2
+#define LINUX_SO_TYPE		3
+#define LINUX_SO_ERROR		4
+#define LINUX_SO_DONTROUTE	5
+#define LINUX_SO_BROADCAST	6
+#define LINUX_SO_SNDBUF		7
+#define LINUX_SO_RCVBUF		8
+#define LINUX_SO_KEEPALIVE	9
+#define LINUX_SO_OOBINLINE	10
+#define LINUX_SO_NO_CHECK	11
+#define LINUX_SO_PRIORITY	12
+#define LINUX_SO_LINGER		13
+#define LINUX_SO_BSDCOMPAT	14
+#define LINUX_SO_REUSEPORT	15	/* undef in Linux */
+#define LINUX_SO_RCVLOWAT	16
+#define LINUX_SO_SNDLOWAT	17
+#define LINUX_SO_RCVTIMEO	18
+#define LINUX_SO_SNDTIMEO	19
+#define LINUX_SO_PASSCRED	20
+#define LINUX_SO_PEERCRED	21
+#define LINUX_SO_SECURITY_AUTHENTICATION	22
+#define LINUX_SO_SECURITY_ENCRYPTION_TRANSPORT	23
+#define LINUX_SO_SECURITY_ENCRYPTION_NETWORK	24
+
+#define LINUX_SO_BINDTODEVICE	25
+#define LINUX_SO_ATTACH_FILTER	26
+#define LINUX_SO_DETACH_FILTER	27
+
+#define LINUX_SO_PEERNAME     28
+#define LINUX_SO_TIMESTAMP    29
+#define LINUX_SCM_TIMESTAMP      SO_TIMESTAMP
+
+#endif /* !_I386_POWERPC_SOCKET_H */
--- sys/compat/linux/arch/powerpc/linux_termios.h.orig	Tue Dec 26 15:06:19 2000
+++ sys/compat/linux/arch/powerpc/linux_termios.h	Fri Dec 29 14:33:02 2000
@@ -0,0 +1,277 @@
+/*	$NetBSD$ */
+
+/* 
+ * Derived from NetBSD's sys/compat/linux/i386/linux_termios.h and
+ * from various Linux header files 
+ * Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr>
+ */
+
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Eric Haszlakiewicz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the NetBSD
+ *	Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _POWERPC_LINUX_TERMIOS_H
+#define _POWERPC_LINUX_TERMIOS_H
+
+/* 
+ * From Linux's include/asm-ppc/termios.h 
+ */
+#define LINUX_TCGETS		_LINUX_IO('T', 19)
+#define LINUX_TCSETS		_LINUX_IO('T', 20)
+#define LINUX_TCSETSW		_LINUX_IO('T', 21)
+#define LINUX_TCSETSF		_LINUX_IO('T', 22)
+#define LINUX_TCGETA		_LINUX_IO('T', 24)
+#define LINUX_TCSETA		_LINUX_IO('T', 23)
+#define LINUX_TCSETAW		_LINUX_IO('T', 25)
+#define LINUX_TCSETAF		_LINUX_IO('T', 28)
+#define LINUX_TCSBRK		_LINUX_IO('T', 29)
+#define LINUX_TCXONC		_LINUX_IO('T', 30)
+#define LINUX_TCFLSH		_LINUX_IO('T', 31)
+#define LINUX_TIOCEXCL		0x540c /* _LINUX_IO('T', ) */
+#define LINUX_TIOCNXCL		0x540d /* _LINUX_IO('T', ) */
+#define LINUX_TIOCSCTTY		0x540e /* _LINUX_IO('T', ) */
+#define LINUX_TIOCGPGRP		_LINUX_IO('T', 119)
+#define LINUX_TIOCSPGRP		_LINUX_IO('T', 118)
+#define LINUX_TIOCOUTQ		_LINUX_IO('T', 115)
+#define LINUX_TIOCSTI		0x5412 /* _LINUX_IO('T', ) */
+#define LINUX_TIOCGWINSZ	_LINUX_IO('T', 104)
+#define LINUX_TIOCSWINSZ	_LINUX_IO('T', 103)
+#define LINUX_TIOCMGET		0x5415 /* _LINUX_IO('T', ) */
+#define LINUX_TIOCMBIS		0x5416 /* _LINUX_IO('T', ) */
+#define LINUX_TIOCMBIC		0x5417 /* _LINUX_IO('T', ) */
+#define LINUX_TIOCMSET		0x5418 /* _LINUX_IO('T', ) */
+#define LINUX_TIOCGSOFTCAR	0x5419 /* _LINUX_IO('T', ) */
+#define LINUX_TIOCSSOFTCAR	0x541a /* _LINUX_IO('T', ) */
+#define LINUX_FIONREAD		_LINUX_IO('F', 127)
+#define LINUX_TIOCINQ		LINUX_FIONREAD
+#define LINUX_TIOCLINUX		0x541c /* _LINUX_IO('T', ) */
+#define LINUX_TIOCCONS		0x541d /* _LINUX_IO('T', ) */
+#define LINUX_TIOCGSERIAL	0x541e /* _LINUX_IO('T', ) */
+#define LINUX_TIOCSSERIAL	0x541f /* _LINUX_IO('T', ) */
+#define LINUX_TIOCPKT		0x5420 /* _LINUX_IO('T', ) */
+#define LINUX_FIONBIO		_LINUX_IO('F', 126)
+#define LINUX_TIOCNOTTY		0x5422 /* _LINUX_IO('T', ) */
+#define LINUX_TIOCSETD		0x5423 /* _LINUX_IO('T', ) */
+#define LINUX_TIOCGETD		0x5424 /* _LINUX_IO('T', ) */
+#define LINUX_TCSBRKP		0x5435 /* _LINUX_IO('T', ) */
+#define LINUX_TIOCTTYGSTRUCT	0x5426 /*	_LINUX_IO('T', ) */
+
+#define LINUX_FIONCLEX		_LINUX_IO('F', 2)
+#define LINUX_FIOCLEX		_LINUX_IO('F', 1)
+#define LINUX_FIOASYNC		_LINUX_IO('F', 125)
+#define LINUX_TIOCSERCONFIG	0x5453 /* _LINUX_IO('T', 83) */
+#define LINUX_TIOCSERGWILD		0x5454 /* _LINUX_IO('T', 84) */
+#define LINUX_TIOCSERSWILD		0x5455 /* _LINUX_IO('T', 85) */
+#define LINUX_TIOCGLCKTRMIOS	0x5456 /* _LINUX_IO('T', 86) */
+#define LINUX_TIOCSLCKTRMIOS	0x5457 /* _LINUX_IO('T', 87) */
+#define LINUX_TIOCSERGSTRUCT	0x5458 /* _LINUX_IO('T', 88) */
+#define LINUX_TIOCSERGETLSR	0x5459 /* _LINUX_IO('T', 89) */
+
+/* 
+ * linux_termios c_cc chars: 
+ * From Linux include/asm-ppc/termios.h AND include/asm-ppc/termbits.h 
+ */
+#define LINUX_VINTR 0
+#define LINUX_VQUIT 1
+#define LINUX_VERASE 2
+#define LINUX_VKILL 3
+#define LINUX_VEOF 4
+#define LINUX_VMIN 5
+#define LINUX_VEOL 6
+#define LINUX_VTIME 7
+#define LINUX_VEOL2 8
+#define LINUX_VSWTC 9
+
+/* 
+ * The following is from include/asm-ppc/termbits.h only 
+ */
+#define LINUX_VWERASE   10
+#define LINUX_VREPRINT  11
+#define LINUX_VSUSP     12
+#define LINUX_VSTART    13
+#define LINUX_VSTOP     14
+#define LINUX_VLNEXT    15    
+#define LINUX_VDISCARD  16
+
+/* 
+ * Old style linux_termio 
+ * XXX Not found anywhere in Linux 
+ */
+#define	LINUX_OLD_VINTR		LINUX_VINTR
+#define	LINUX_OLD_VQUIT		LINUX_VQUIT
+#define	LINUX_OLD_VERASE	LINUX_VERASE
+#define	LINUX_OLD_VKILL		LINUX_VKILL
+#define	LINUX_OLD_VEOF		LINUX_VEOF
+#define	LINUX_OLD_VMIN		LINUX_VMIN
+#define	LINUX_OLD_VEOL		LINUX_VEOL
+#define	LINUX_OLD_VTIME		LINUX_VTIME
+#define	LINUX_OLD_VEOL2		LINUX_VEOL2
+#define	LINUX_OLD_VSWTC		LINUX_VSWTC
+
+/* 
+ * All the remaining stuff is from  Linux's include/asm-ppc/termbits.h 
+ * Linux c_iflag masks 
+ */
+#define LINUX_IGNBRK	0x0000001
+#define LINUX_BRKINT	0x0000002
+#define LINUX_IGNPAR	0x0000004
+#define LINUX_PARMRK	0x0000010
+#define LINUX_INPCK	0x0000020
+#define LINUX_ISTRIP	0x0000040
+#define LINUX_INLCR	0x0000100
+#define LINUX_IGNCR	0x0000200
+#define LINUX_ICRNL	0x0000400
+#define LINUX_IXON	0x0001000
+#define LINUX_IXOFF	0x0002000
+#define LINUX_IXANY	0x0004000
+#define LINUX_IUCLC	0x0010000
+#define LINUX_IMAXBEL	0x0002000
+
+/* 
+ * Linux c_oflag masks 
+ */
+#define LINUX_OPOST	0x0000001
+#define LINUX_ONLCR	0x0000002
+#define LINUX_OLCUC	0x0000004
+#define LINUX_OCRNL	0x0000010
+#define LINUX_ONOCR	0x0000020
+#define LINUX_ONLRET	0x0000040
+
+#define LINUX_OFILL  0x00000100
+#define LINUX_OFDEL  0x00000200
+#define LINUX_NLDLY  0x00001400
+#define LINUX_NL0  0x00000000
+#define LINUX_NL1  0x00000400
+#define LINUX_NL2  0x00001000
+#define LINUX_NL3  0x00001400
+#define LINUX_TABDLY 0x00006000
+#define LINUX_TAB0 0x00000000
+#define LINUX_TAB1 0x00002000
+#define LINUX_TAB2 0x00004000
+#define LINUX_TAB3 0x00006000
+#define LINUX_CRDLY  0x00030000
+#define LINUX_CR0  0x00000000
+#define LINUX_CR1  0x00010000
+#define LINUX_CR2  0x00020000
+#define LINUX_CR3  0x00030000
+#define LINUX_FFDLY  0x00040000
+#define LINUX_FF0  0x00000000
+#define LINUX_FF1  0x00040000
+#define LINUX_BSDLY  0x00100000
+#define LINUX_BS0  0x00000000
+#define LINUX_BS1  0x00100000
+#define LINUX_VTDLY  0x00200000
+#define LINUX_VT0  0x00000000
+#define LINUX_VT1  0x00200000
+#define LINUX_XTABS  0x01000000 /* Hmm.. Linux/i386 considers this part of TABDLY.. */
+
+/* 
+ * Linux c_cflag bit masks 
+ * XXX next two defines not found in Linux, and LINUX_NSPEEDS is needed to build
+ */
+#define LINUX_NSPEEDS   16 
+/* #define LINUX_NXSPEEDS   3 */ 	/* XXX Add B460800, NXSPEEDS=4 */
+
+#define LINUX_CBAUD  0x0000377
+#define LINUX_B0 0x0000000     /* hang up */
+#define LINUX_B50   0x0000001
+#define LINUX_B75   0x0000002
+#define LINUX_B110  0x0000003
+#define LINUX_B134  0x0000004
+#define LINUX_B150  0x0000005
+#define LINUX_B200  0x0000006
+#define LINUX_B300  0x0000007
+#define LINUX_B600  0x0000010
+#define LINUX_B1200 0x0000011
+#define LINUX_B1800 0x0000012
+#define LINUX_B2400 0x0000013
+#define LINUX_B4800 0x0000014
+#define LINUX_B9600 0x0000015
+#define LINUX_B19200   0x0000016
+#define LINUX_B38400   0x0000017
+#define LINUX_EXTA B19200
+#define LINUX_EXTB B38400
+#define LINUX_CBAUDEX 0x0000000
+#define LINUX_B57600   0x00020
+#define LINUX_B115200  0x00021
+#define LINUX_B230400  0x00022
+#define LINUX_B460800  0x00023
+#define LINUX_B500000  0x00024
+#define LINUX_B576000  0x00025
+#define LINUX_B921600  0x00026
+#define LINUX_B1000000  0x00027
+#define LINUX_B1152000  0x00030
+#define LINUX_B1500000  0x00031
+#define LINUX_B2000000  0x00032
+#define LINUX_B2500000  0x00033
+#define LINUX_B3000000  0x00034
+#define LINUX_B3500000  0x00035
+#define LINUX_B4000000  0x00036
+
+#define LINUX_CSIZE  0x00001400
+#define LINUX_CS5  0x00000000
+#define LINUX_CS6  0x00000400
+#define LINUX_CS7  0x00001000
+#define LINUX_CS8  0x00001400 
+   
+#define LINUX_CSTOPB 0x00002000 
+#define LINUX_CREAD  0x00004000 
+#define LINUX_PARENB 0x00010000 
+#define LINUX_PARODD 0x00020000 
+#define LINUX_HUPCL  0x00040000 
+   
+#define LINUX_CLOCAL 0x00100000
+#define LINUX_CRTSCTS     0x020000000000    /* flow control */
+
+/* 
+ * Linux c_lflag masks 
+ */
+#define LINUX_ISIG   0x00000080
+#define LINUX_ICANON 0x00000100
+#define LINUX_XCASE  0x00004000
+#define LINUX_ECHO   0x00000008
+#define LINUX_ECHOE  0x00000002
+#define LINUX_ECHOK  0x00000004
+#define LINUX_ECHONL 0x00000010
+#define LINUX_NOFLSH 0x80000000
+#define LINUX_TOSTOP 0x00400000
+#define LINUX_ECHOCTL   0x00000040
+#define LINUX_ECHOPRT   0x00000020
+#define LINUX_ECHOKE 0x00000001
+#define LINUX_FLUSHO 0x00800000
+#define LINUX_PENDIN 0x20000000
+#define LINUX_IEXTEN 0x00000400
+
+#endif /* !_POWERPC_LINUX_TERMIOS_H */
--- sys/compat/linux/arch/powerpc/linux_mmap.h.orig	Tue Dec 26 16:43:36 2000
+++ sys/compat/linux/arch/powerpc/linux_mmap.h	Fri Dec 29 14:02:07 2000
@@ -1,6 +1,11 @@
 /*	$NetBSD: linux_mmap.h,v 1.1 1998/09/30 21:55:59 erh Exp $	*/
 
+/* 
+ * Derived from existing linux_mmap.h file and from various Linux header files
+ * Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr>
+ */
+
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
@@ -35,15 +40,19 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef _PPC_LINUX_MMAP_H
-#define _PPC_LINUX_MMAP_H
-
-/* LINUX_PROT_* defined in common/linux_mmap.h */
+#ifndef _POWERPC_LINUX_MMAP_H
+#define _POWERPC_LINUX_MMAP_H
 
-/* LINUX_MAP_SHARED/PRIVATE defined in common/linux_mmap.h */
+/* 
+ * LINUX_PROT_* are defined in common/linux_mmap.h 
+ * LINUX_MAP_SHARED/PRIVATE are defined in common/linux_mmap.h 
+ */
 
+/* 
+ * From Linux's include/asm-ppc/mman.h 
+ */
 #define LINUX_MAP_FIXED		0x0010
 #define LINUX_MAP_ANON		0x0020
 
 /* Ignored */
@@ -51,7 +60,8 @@
 #define LINUX_MAP_GROWSDOWN	0x0100
 #define LINUX_MAP_DENYWRITE	0x0800
 #define	LINUX_MAP_EXECUTABLE	0x1000
 
-#define LINUX_MAP_IGNMASK	0x1940
+/* XXX not found in Linux */
+/* #define LINUX_MAP_IGNMASK	0x1940 */ 
 
-#endif /* !_PPC_LINUX_MMAP_H */
+#endif /* !_POWERPC_LINUX_MMAP_H */
--- sys/compat/linux/common/linux_types.h.orig	Sat Dec 23 11:25:51 2000
+++ sys/compat/linux/common/linux_types.h	Sat Dec 23 11:26:04 2000
@@ -52,9 +52,9 @@
 #include <compat/linux/arch/m68k/linux_types.h>
 #elif defined(__mips__)
 #include <compat/linux/arch/mips/linux_types.h>
 #elif defined(__powerpc__)
-#include <compat/linux/arch/power/linux_types.h>
+#include <compat/linux/arch/powerpc/linux_types.h>
 #endif
 
 /*
  * Structure for uname(2)
--- sys/compat/linux/common/linux_siginfo.h.orig	Sat Dec 23 12:40:32 2000
+++ sys/compat/linux/common/linux_siginfo.h	Sat Dec 23 12:41:39 2000
@@ -45,8 +45,10 @@
 #elif defined(__m68k__)
 #include <compat/linux/arch/m68k/linux_siginfo.h>
 #elif defined(__alpha__)
 #include <compat/linux/arch/alpha/linux_siginfo.h>
+#elif defined(__powerpc__)
+#include <compat/linux/arch/powerpc/linux_siginfo.h>
 #else
 #error Undefined linux_siginfo.h machine type.
 #endif
 
--- sys/compat/linux/common/linux_ioctl.h.orig	Sat Dec 23 13:00:54 2000
+++ sys/compat/linux/common/linux_ioctl.h	Sat Dec 23 13:02:13 2000
@@ -62,8 +62,10 @@
 #elif defined(__m68k__)
 #include <compat/linux/arch/m68k/linux_ioctl.h>
 #elif defined(__alpha__)
 #include <compat/linux/arch/alpha/linux_ioctl.h>
+#elif defined(__powerpc__)
+#include <compat/linux/arch/powerpc/linux_ioctl.h>
 #else
 #error Undefined linux_ioctl.h machine type.
 #endif
 
--- sys/compat/linux/common/linux_signal.h.orig	Sat Dec 23 13:05:34 2000
+++ sys/compat/linux/common/linux_signal.h	Sat Dec 23 13:05:58 2000
@@ -44,8 +44,10 @@
 #elif defined(__m68k__)
 #include <compat/linux/arch/m68k/linux_signal.h>
 #elif defined(__alpha__)
 #include <compat/linux/arch/alpha/linux_signal.h>
+#elif defined(__powerpc__)
+#include <compat/linux/arch/powerpc/linux_signal.h>
 #else
 #error Undefined linux_signal.h machine type.
 #endif
 
--- sys/compat/linux/common/linux_machdep.h.orig	Sat Dec 23 13:24:23 2000
+++ sys/compat/linux/common/linux_machdep.h	Sat Dec 23 13:24:44 2000
@@ -44,8 +44,10 @@
 #elif defined(__m68k__)
 #include <compat/linux/arch/m68k/linux_machdep.h>
 #elif defined(__alpha__)
 #include <compat/linux/arch/alpha/linux_machdep.h>
+#elif defined(__powerpc__)
+#include <compat/linux/arch/powerpc/linux_machdep.h>
 #else
 #error Undefined linux_machdep.h machine type.
 #endif
 
--- sys/compat/linux/common/linux_fcntl.h.orig	Tue Dec 26 14:48:09 2000
+++ sys/compat/linux/common/linux_fcntl.h	Tue Dec 26 14:48:35 2000
@@ -63,8 +63,10 @@
 #elif defined(__m68k__)
 #include <compat/linux/arch/m68k/linux_fcntl.h>
 #elif defined(__alpha__)
 #include <compat/linux/arch/alpha/linux_fcntl.h>
+#elif defined(__powerpc__)
+#include <compat/linux/arch/powerpc/linux_fcntl.h>
 #else
 #error Undefined linux_fcntl.h machine type.
 #endif
 
--- sys/compat/linux/common/linux_socket.h.orig	Tue Dec 26 14:51:04 2000
+++ sys/compat/linux/common/linux_socket.h	Tue Dec 26 14:51:31 2000
@@ -128,8 +128,10 @@
 #elif defined(__m68k__)
 #include <compat/linux/arch/m68k/linux_socket.h>
 #elif defined(__alpha__)
 #include <compat/linux/arch/alpha/linux_socket.h>
+#elif defined(__powerpc__)
+#include <compat/linux/arch/powerpc/linux_socket.h>
 #else
 #error Undefined linux_socket.h machine type.
 #endif
 
--- sys/compat/linux/common/linux_termios.h.orig	Tue Dec 26 14:51:46 2000
+++ sys/compat/linux/common/linux_termios.h	Tue Dec 26 14:52:12 2000
@@ -125,8 +125,10 @@
 #elif defined(__m68k__)
 #include <compat/linux/arch/m68k/linux_termios.h>
 #elif defined(__alpha__)
 #include <compat/linux/arch/alpha/linux_termios.h>
+#elif defined(__powerpc__)
+#include <compat/linux/arch/powerpc/linux_termios.h>
 #else
 #error Undefined linux_termios.h machine type.
 #endif
 #endif /* !_LINUX_TERMIOS_H */
--- sys/compat/linux/common/linux_file.c.orig	Wed Dec 27 15:27:32 2000
+++ sys/compat/linux/common/linux_file.c	Wed Dec 27 15:34:08 2000
@@ -713,9 +713,10 @@
 		(gid_t)-1 : SCARG(uap, gid);
 
 	return sys___posix_lchown(p, &bla, retval);
 }
-
+#endif /* __i386__ || __m68k__ */
+#if defined (__i386__) || defined (__m68k__) || defined (__powerpc__)
 int
 linux_sys_chown(p, v, retval)
 	struct proc *p;
 	void *v;
@@ -749,9 +750,9 @@
 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
 
 	return sys___posix_lchown(p, uap, retval);
 }
-#endif /* __i386__ || __m68k__ */
+#endif /* __i386__ || __m68k__ || __powerpc__ */
 
 int
 linux_sys_rename(p, v, retval)
 	struct proc *p;
--- sys/compat/linux/common/linux_misc.c.orig	Wed Dec 27 15:28:36 2000
+++ sys/compat/linux/common/linux_misc.c	Wed Dec 27 16:41:27 2000
@@ -866,9 +866,9 @@
 	retval[0] = 0;
 	return 0;
 }
 
-#if defined(__i386__) || defined(__m68k__)
+#if defined(__i386__) || defined(__m68k__) 
 /*
  * The calls are here because of type conversions.
  */
 int
--- sys/compat/linux/linux_syscallargs.h.orig	Tue Dec 26 16:39:33 2000
+++ sys/compat/linux/linux_syscallargs.h	Sat Dec 23 13:22:37 2000
@@ -44,8 +44,10 @@
 #elif defined(__m68k__)
 #include <compat/linux/arch/m68k/linux_syscallargs.h>
 #elif defined(__alpha__)
 #include <compat/linux/arch/alpha/linux_syscallargs.h>
+#elif defined(__powerpc__)
+#include <compat/linux/arch/powerpc/linux_syscallargs.h>
 #else
 #error Undefined linux_syscallargs.h machine type.
 #endif
 
--- sys/compat/linux/linux_syscall.h.orig	Tue Dec 26 16:39:54 2000
+++ sys/compat/linux/linux_syscall.h	Tue Dec 26 16:38:06 2000
@@ -44,8 +44,10 @@
 #elif defined(__m68k__)
 #include <compat/linux/arch/m68k/linux_syscall.h>
 #elif defined(__alpha__)
 #include <compat/linux/arch/alpha/linux_syscall.h>
+#elif defined(__powerpc__)
+#include <compat/linux/arch/powerpc/linux_syscall.h>
 #else
 #define	LINUX_SYS_MAXSYSCALL	0
 #endif
 
--- sys/compat/linux/linux_syscalls.c.orig	Tue Dec 26 16:40:57 2000
+++ sys/compat/linux/linux_syscalls.c	Tue Dec 26 16:41:23 2000
@@ -43,7 +43,9 @@
 #elif defined(__m68k__)
 #include "../../sys/compat/linux/arch/m68k/linux_syscalls.c"
 #elif defined(__alpha__)
 #include "../../sys/compat/linux/arch/alpha/linux_syscalls.c"
+#elif defined(__powerpc__)
+#include "../../sys/compat/linux/arch/powerpc/linux_syscalls.c"
 #else
 const char * const linux_syscallnames[] = { 0 };
 #endif
--- sys/compat/linux/common/linux_exec.h.orig   Fri Dec 29 16:06:51 2000
+++ sys/compat/linux/common/linux_exec.h        Fri Dec 29 16:07:19 2000
@@ -44,8 +44,10 @@
 #elif defined(__m68k__)
 #include <compat/linux/arch/m68k/linux_exec.h>
 #elif defined(__alpha__)
 #include <compat/linux/arch/alpha/linux_exec.h>
+#elif defined(__powerpc__)
+#include <compat/linux/arch/powerpc/linux_exec.h>
 #else
 #error Undefined linux_exec.h machine type.
 #endif

>Release-Note:
>Audit-Trail:
>Unformatted: