Commit 8fc41201 authored by Ralf Bächle's avatar Ralf Bächle Committed by Linus Torvalds

[PATCH] mips: IRIX 5 compat fixes

Start to resurrect the IRIX 5 binary compatibility code.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent e58595ec
/* /*
* irix5sys.h: 32-bit IRIX5 ABI system call table. * This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
* *
* Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) * 32-bit IRIX5 ABI system call table derived from original file 'irix5sys.h'
*/ * created by David S. Miller.
*
/* This file is being included twice - once to build a list of all * Copyright (C) 1996 - 2004 David S. Miller <dm@engr.sgi.com>
* syscalls and once to build a table of how many arguments each syscall * Copyright (C) 2004 Steven J. Hill <sjhill@realitydiluted.com>
* accepts. Syscalls that receive a pointer to the saved registers are
* marked as having zero arguments.
*/ */
#include <linux/config.h> #include <asm/asm.h>
/* Keys: /*
* Key:
* V == Valid and should work as expected for most cases. * V == Valid and should work as expected for most cases.
* HV == Half Valid, some things will work, some likely will not * HV == Half Valid, some things will work, some likely will not
* IV == InValid, certainly will not work at all yet * IV == InValid, certainly will not work at all yet
...@@ -19,7 +20,8 @@ ...@@ -19,7 +20,8 @@
* DC == Don't Care, a rats ass we couldn't give * DC == Don't Care, a rats ass we couldn't give
*/ */
#ifdef CONFIG_BINFMT_IRIX .macro irix5syscalltable
sys sys_syscall 0 /* 1000 sysindir() V*/ sys sys_syscall 0 /* 1000 sysindir() V*/
sys sys_exit 1 /* 1001 exit() V*/ sys sys_exit 1 /* 1001 exit() V*/
sys sys_fork 0 /* 1002 fork() V*/ sys sys_fork 0 /* 1002 fork() V*/
...@@ -247,7 +249,7 @@ ...@@ -247,7 +249,7 @@
sys irix_unimp 0 /* 1224 XXX psema_cntl() */ sys irix_unimp 0 /* 1224 XXX psema_cntl() */
sys irix_unimp 0 /* 1225 XXX restartreturn() */ sys irix_unimp 0 /* 1225 XXX restartreturn() */
/* Just to pad things out nicely. */ /* Just to pad things out nicely. */
sys irix_unimp 0 sys irix_unimp 0
sys irix_unimp 0 sys irix_unimp 0
sys irix_unimp 0 sys irix_unimp 0
...@@ -1022,8 +1024,18 @@ ...@@ -1022,8 +1024,18 @@
sys irix_unimp 0 sys irix_unimp 0
sys irix_unimp 0 sys irix_unimp 0
sys irix_unimp 0 sys irix_unimp 0
#else
mille sys_ni_syscall 0
#endif
/* YEEEEEEEEEEEEEEEEEE!!!! */ .endm
/*
* Pre-compute the number of _instruction_ bytes needed to load
* or store the arguments 6-8. Negative values are ignored.
*/
.macro sys function, nargs
PTR \function
LONG (\nargs << 2) - (5 << 2)
.endm
.align 4
EXPORT(sys_call_table_irix5)
irix5syscalltable
/* /*
* irixelf.c: Code to load IRIX ELF executables which conform to * This file is subject to the terms and conditions of the GNU General Public
* the MIPS ABI. * License. See the file "COPYING" in the main directory of this archive
* for more details.
* *
* Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) * irixelf.c: Code to load IRIX ELF executables conforming to the MIPS ABI.
* Based off of work by Eric Youngdale.
* *
* Based upon work which is: * Copyright (C) 1993 - 1994 Eric Youngdale <ericy@cais.com>
* Copyright 1993, 1994: Eric Youngdale (ericy@cais.com). * Copyright (C) 1996 - 2004 David S. Miller <dm@engr.sgi.com>
* Copyright (C) 2004 Steven J. Hill <sjhill@realitydiluted.com>
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/sched.h> #include <linux/sched.h>
...@@ -211,13 +212,13 @@ unsigned long * create_irix_tables(char * p, int argc, int envc, ...@@ -211,13 +212,13 @@ unsigned long * create_irix_tables(char * p, int argc, int envc,
__put_user((unsigned long)p,argv++); __put_user((unsigned long)p,argv++);
p += strlen_user(p); p += strlen_user(p);
} }
__put_user(NULL, argv); __put_user((unsigned long) NULL, argv);
current->mm->arg_end = current->mm->env_start = (unsigned long) p; current->mm->arg_end = current->mm->env_start = (unsigned long) p;
while (envc-->0) { while (envc-->0) {
__put_user((unsigned long)p,envp++); __put_user((unsigned long)p,envp++);
p += strlen_user(p); p += strlen_user(p);
} }
__put_user(NULL, envp); __put_user((unsigned long) NULL, envp);
current->mm->env_end = (unsigned long) p; current->mm->env_end = (unsigned long) p;
return sp; return sp;
} }
...@@ -622,6 +623,7 @@ static int load_irix_binary(struct linux_binprm * bprm, struct pt_regs * regs) ...@@ -622,6 +623,7 @@ static int load_irix_binary(struct linux_binprm * bprm, struct pt_regs * regs)
} }
retval = kernel_read(bprm->file, elf_ex.e_phoff, (char *)elf_phdata, size); retval = kernel_read(bprm->file, elf_ex.e_phoff, (char *)elf_phdata, size);
if (retval < 0) if (retval < 0)
goto out_free_ph; goto out_free_ph;
...@@ -934,7 +936,8 @@ unsigned long irix_mapelf(int fd, struct elf_phdr *user_phdrp, int cnt) ...@@ -934,7 +936,8 @@ unsigned long irix_mapelf(int fd, struct elf_phdr *user_phdrp, int cnt)
} }
#ifdef DEBUG_ELF #ifdef DEBUG_ELF
printk("irix_mapelf: Success, returning %08lx\n", user_phdrp->p_vaddr); printk("irix_mapelf: Success, returning %08lx\n",
(unsigned long) user_phdrp->p_vaddr);
#endif #endif
fput(filp); fput(filp);
return user_phdrp->p_vaddr; return user_phdrp->p_vaddr;
...@@ -1297,6 +1300,20 @@ static int irix_core_dump(long signr, struct pt_regs * regs, struct file *file) ...@@ -1297,6 +1300,20 @@ static int irix_core_dump(long signr, struct pt_regs * regs, struct file *file)
static int __init init_irix_binfmt(void) static int __init init_irix_binfmt(void)
{ {
int init_inventory(void);
extern asmlinkage unsigned long sys_call_table;
extern asmlinkage unsigned long sys_call_table_irix5;
init_inventory();
/*
* Copy the IRIX5 syscall table (8000 bytes) into the main syscall
* table. The IRIX5 calls are located by an offset of 8000 bytes
* from the beginning of the main table.
*/
memcpy((void *) ((unsigned long) &sys_call_table + 8000),
&sys_call_table_irix5, 8000);
return register_binfmt(&irix_format); return register_binfmt(&irix_format);
} }
......
...@@ -6,10 +6,8 @@ ...@@ -6,10 +6,8 @@
* Miguel de Icaza, 1997. * Miguel de Icaza, 1997.
*/ */
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <asm/uaccess.h>
#include <asm/inventory.h> #include <asm/inventory.h>
#include <asm/uaccess.h>
#define MAX_INVENTORY 50 #define MAX_INVENTORY 50
int inventory_items = 0; int inventory_items = 0;
...@@ -49,7 +47,7 @@ int dump_inventory_to_user (void *userbuf, int size) ...@@ -49,7 +47,7 @@ int dump_inventory_to_user (void *userbuf, int size)
return inventory_items * sizeof (inventory_t); return inventory_items * sizeof (inventory_t);
} }
static int __init init_inventory(void) int __init init_inventory(void)
{ {
/* /*
* gross hack while we put the right bits all over the kernel * gross hack while we put the right bits all over the kernel
...@@ -77,5 +75,3 @@ static int __init init_inventory(void) ...@@ -77,5 +75,3 @@ static int __init init_inventory(void)
return 0; return 0;
} }
module_init(init_inventory);
...@@ -624,7 +624,7 @@ asmlinkage int irix_waitsys(int type, int pid, struct irix5_siginfo *info, ...@@ -624,7 +624,7 @@ asmlinkage int irix_waitsys(int type, int pid, struct irix5_siginfo *info,
} }
goto end_waitsys; goto end_waitsys;
case TASK_ZOMBIE: case EXIT_ZOMBIE:
current->signal->cutime += p->utime + p->signal->cutime; current->signal->cutime += p->utime + p->signal->cutime;
current->signal->cstime += p->stime + p->signal->cstime; current->signal->cstime += p->stime + p->signal->cstime;
if (ru != NULL) if (ru != NULL)
......
...@@ -1648,7 +1648,7 @@ asmlinkage int irix_statvfs64(char *fname, struct irix_statvfs64 *buf) ...@@ -1648,7 +1648,7 @@ asmlinkage int irix_statvfs64(char *fname, struct irix_statvfs64 *buf)
struct kstatfs kbuf; struct kstatfs kbuf;
int error, i; int error, i;
printk("[%s:%d] Wheee.. irix_statvfs(%s,%p)\n", printk("[%s:%d] Wheee.. irix_statvfs64(%s,%p)\n",
current->comm, current->pid, fname, buf); current->comm, current->pid, fname, buf);
error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statvfs64)); error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statvfs64));
if(error) if(error)
...@@ -1694,7 +1694,7 @@ asmlinkage int irix_fstatvfs64(int fd, struct irix_statvfs *buf) ...@@ -1694,7 +1694,7 @@ asmlinkage int irix_fstatvfs64(int fd, struct irix_statvfs *buf)
struct file *file; struct file *file;
int error, i; int error, i;
printk("[%s:%d] Wheee.. irix_fstatvfs(%d,%p)\n", printk("[%s:%d] Wheee.. irix_fstatvfs64(%d,%p)\n",
current->comm, current->pid, fd, buf); current->comm, current->pid, fd, buf);
error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statvfs)); error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statvfs));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment