From d6434e1042f3b0a6dfe1b1f615af369486f9b1fa Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Sat, 9 Oct 1999 00:00:47 +0000 Subject: Merge with 2.3.19. --- arch/mips/kernel/Makefile | 3 +- arch/mips/kernel/head.S | 31 ++++++---- arch/mips/kernel/init_task.c | 1 - arch/mips/kernel/irixelf.c | 96 ++++++++++--------------------- arch/mips/kernel/irixinv.c | 4 +- arch/mips/kernel/irixsig.c | 16 ++---- arch/mips/kernel/pci.c | 93 ------------------------------ arch/mips/kernel/process.c | 58 +++++++++++++++---- arch/mips/kernel/ptrace.c | 16 +++--- arch/mips/kernel/r2300_misc.S | 6 +- arch/mips/kernel/r4k_misc.S | 7 ++- arch/mips/kernel/r4k_switch.S | 13 ++--- arch/mips/kernel/semaphore.c | 129 ++++++++++++++++++++++++++++++++++++++++++ arch/mips/kernel/setup.c | 8 +-- arch/mips/kernel/signal.c | 8 +-- arch/mips/kernel/syscall.c | 38 +------------ arch/mips/kernel/syscalls.h | 4 +- arch/mips/kernel/sysirix.c | 10 ++-- arch/mips/kernel/sysmips.c | 6 +- arch/mips/kernel/time.c | 4 +- arch/mips/kernel/unaligned.c | 4 +- 21 files changed, 278 insertions(+), 277 deletions(-) delete mode 100644 arch/mips/kernel/pci.c create mode 100644 arch/mips/kernel/semaphore.c (limited to 'arch/mips/kernel') diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile index 89726e16d..4281d1641 100644 --- a/arch/mips/kernel/Makefile +++ b/arch/mips/kernel/Makefile @@ -1,3 +1,4 @@ +# $Id$ # # Makefile for the Linux/MIPS kernel. # @@ -13,7 +14,7 @@ all: kernel.o head.o init_task.o EXTRA_ASFLAGS = -mips3 -mcpu=r4000 O_TARGET := kernel.o O_OBJS := branch.o process.o signal.o entry.o traps.o ptrace.o vm86.o \ - ioport.o pci.o reset.o setup.o syscall.o sysmips.o ipc.o \ + ioport.o reset.o semaphore.o setup.o syscall.o sysmips.o ipc.o \ scall_o32.o softfp.o unaligned.o OX_OBJS := mips_ksyms.o diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S index 11dd160ec..7429a42bf 100644 --- a/arch/mips/kernel/head.S +++ b/arch/mips/kernel/head.S @@ -1,4 +1,4 @@ -/* $Id: head.S,v 1.14 1999/08/20 21:59:02 ralf Exp $ +/* $Id: head.S,v 1.15 1999/10/07 07:34:24 raiko Exp $ * * arch/mips/kernel/head.S * @@ -8,15 +8,16 @@ * * Copyright (C) 1994, 1995 Waldorf Electronics * Written by Ralf Baechle and Andreas Busse - * Copyright (C) 1995, 1996, 1997, 1998 Ralf Baechle + * Copyright (C) 1995 - 1999 Ralf Baechle * Copyright (C) 1996 Paul M. Antoine * Modified for DECStation and hence R3000 support by Paul M. Antoine * Further modifications by David S. Miller and Harald Koerfgen + * Copyright (C) 1999 Silicon Graphics, Inc. * * Head.S contains the MIPS exception handler and startup code. */ #include -#include +#include #include #include @@ -55,7 +56,8 @@ mfc0 k0, CP0_BADVADDR # Get faulting address _GET_CURRENT(k1) # get current task ptr srl k0, k0, 22 # get pgd only bits - lw k1, THREAD_PGDIR(k1) # get task pg_dir + lw k1, TASK_MM(k1) # get task pg_dir + lw k1, MM_PGD(k1) # get pgd pointer sll k0, k0, 2 addu k1, k1, k0 # add in pgd offset mfc0 k0, CP0_CONTEXT # get context reg @@ -82,7 +84,8 @@ mfc0 k0, CP0_BADVADDR _GET_CURRENT(k1) # get current task ptr srl k0, k0, 22 - lw k1, THREAD_PGDIR(k1) + lw k1, TASK_MM(k1) + lw k1, MM_PGD(k1) # get pgd pointer sll k0, k0, 2 addu k1, k1, k0 mfc0 k0, CP0_CONTEXT @@ -110,7 +113,8 @@ mfc0 k0, CP0_BADVADDR # Get faulting address _GET_CURRENT(k1) # get current task ptr srl k0, k0, 22 # get pgd only bits - lw k1, THREAD_PGDIR(k1) # get task pg_dir + lw k1, TASK_MM(k1) # get task pg_dir + lw k1, MM_PGD(k1) # get pgd pointer sll k0, k0, 2 addu k1, k1, k0 # add in pgd offset lw k1, (k1) @@ -136,7 +140,8 @@ mfc0 k0, CP0_BADVADDR _GET_CURRENT(k1) # get current task ptr srl k0, k0, 22 - lw k1, THREAD_PGDIR(k1) + lw k1, TASK_MM(k1) + lw k1, MM_PGD(k1) # get pgd pointer sll k0, k0, 2 addu k1, k1, k0 mfc0 k0, CP0_CONTEXT @@ -167,7 +172,8 @@ mfc0 k0, CP0_BADVADDR _GET_CURRENT(k1) # get current task ptr srl k0, k0, 22 - lw k1, THREAD_PGDIR(k1) + lw k1, TASK_MM(k1) + lw k1, MM_PGD(k1) # get pgd pointer sll k0, k0, 2 addu k1, k1, k0 mfc0 k0, CP0_CONTEXT @@ -198,7 +204,8 @@ mfc0 k0, CP0_BADVADDR _GET_CURRENT(k1) # get current task ptr srl k0, k0, 22 - lw k1, THREAD_PGDIR(k1) + lw k1, TASK_MM(k1) + lw k1, MM_PGD(k1) # get pgd pointer sll k0, k0, 2 addu k1, k1, k0 mfc0 k0, CP0_CONTEXT @@ -228,7 +235,8 @@ mfc0 k0, CP0_BADVADDR _GET_CURRENT(k1) # get current task ptr srl k0, k0, 22 - lw k1, THREAD_PGDIR(k1) + lw k1, TASK_MM(k1) + lw k1, MM_PGD(k1) # get pgd pointer sll k0, k0, 2 addu k1, k1, k0 mfc0 k0, CP0_CONTEXT @@ -261,8 +269,9 @@ .set mips1 mfc0 k0, CP0_BADVADDR _GET_CURRENT(k1) # get current task ptr + lw k1, TASK_MM(k1) srl k0, k0, 22 - lw k1, THREAD_PGDIR(k1) + lw k1, MM_PGD(k1) # get pgd pointer sll k0, k0, 2 addu k1, k1, k0 mfc0 k0, CP0_CONTEXT diff --git a/arch/mips/kernel/init_task.c b/arch/mips/kernel/init_task.c index baad4538c..fbf5bf9f0 100644 --- a/arch/mips/kernel/init_task.c +++ b/arch/mips/kernel/init_task.c @@ -6,7 +6,6 @@ static struct vm_area_struct init_mmap = INIT_MMAP; static struct fs_struct init_fs = INIT_FS; -static struct file * init_fd_array[NR_OPEN] = { NULL, }; static struct files_struct init_files = INIT_FILES; static struct signal_struct init_signals = INIT_SIGNALS; struct mm_struct init_mm = INIT_MM(init_mm); diff --git a/arch/mips/kernel/irixelf.c b/arch/mips/kernel/irixelf.c index 3eadd1832..86883ea45 100644 --- a/arch/mips/kernel/irixelf.c +++ b/arch/mips/kernel/irixelf.c @@ -1,4 +1,4 @@ -/* $Id: irixelf.c,v 1.20 1999/08/04 14:54:04 ulfc Exp $ +/* $Id: irixelf.c,v 1.21 1999/09/28 22:25:46 ralf Exp $ * * irixelf.c: Code to load IRIX ELF executables which conform to * the MIPS ABI. @@ -45,15 +45,13 @@ static int load_irix_binary(struct linux_binprm * bprm, struct pt_regs * regs); static int load_irix_library(int fd); -static int irix_core_dump(long signr, struct pt_regs * regs); +static int irix_core_dump(long signr, struct pt_regs * regs, + struct file *file); extern int dump_fpu (elf_fpregset_t *); static struct linux_binfmt irix_format = { -#ifndef MODULE - NULL, NULL, load_irix_binary, load_irix_library, irix_core_dump -#else - NULL, &__this_module.usecount, load_irix_binary, load_irix_library, irix_core_dump -#endif + NULL, THIS_MODULE, load_irix_binary, load_irix_library, + irix_core_dump, PAGE_SIZE }; #ifndef elf_addr_t @@ -739,9 +737,9 @@ static inline int do_load_irix_binary(struct linux_binprm * bprm, if(retval) { set_fs(old_fs); printk("Unable to load IRIX ELF interpreter\n"); - kfree(elf_phdata); send_sig(SIGSEGV, current, 0); - return 0; + retval = 0; + goto out_free_file; } } @@ -1089,9 +1087,11 @@ static int notesize(struct memelfnote *en) /* #define DEBUG */ #define DUMP_WRITE(addr, nr) \ - do { if (!dump_write(file, (addr), (nr))) return 0; } while(0) + if (!dump_write(file, (addr), (nr))) \ + goto end_coredump; #define DUMP_SEEK(off) \ - do { if (!dump_seek(file, (off))) return 0; } while(0) + if (!dump_seek(file, (off))) \ + goto end_coredump; static int writenote(struct memelfnote *men, struct file *file) { @@ -1109,30 +1109,30 @@ static int writenote(struct memelfnote *men, struct file *file) DUMP_SEEK(roundup((unsigned long)file->f_pos, 4)); /* XXX */ return 1; + +end_coredump: + return 0; } #undef DUMP_WRITE #undef DUMP_SEEK #define DUMP_WRITE(addr, nr) \ if (!dump_write(file, (addr), (nr))) \ - goto close_coredump; + goto end_coredump; #define DUMP_SEEK(off) \ if (!dump_seek(file, (off))) \ - goto close_coredump; + goto end_coredump; + /* Actual dumper. * * This is a two-pass process; first we find the offsets of the bits, * and then they are actually written out. If we run out of core limit * we just truncate. */ -static int irix_core_dump(long signr, struct pt_regs * regs) +static int irix_core_dump(long signr, struct pt_regs * regs, struct file *file) { int has_dumped = 0; - struct file *file; - struct dentry *dentry; - struct inode *inode; mm_segment_t fs; - char corefile[6+sizeof(current->comm)]; int segs; int i; size_t size; @@ -1145,10 +1145,6 @@ static int irix_core_dump(long signr, struct pt_regs * regs) struct elf_prstatus prstatus; /* NT_PRSTATUS */ elf_fpregset_t fpu; /* NT_PRFPREG */ struct elf_prpsinfo psinfo; /* NT_PRPSINFO */ - - if (!current->dumpable || limit < PAGE_SIZE) - return 0; - current->dumpable = 0; #ifndef CONFIG_BINFMT_IRIX MOD_INC_USE_COUNT; @@ -1180,7 +1176,7 @@ static int irix_core_dump(long signr, struct pt_regs * regs) elf.e_ident[EI_DATA] = ELFDATA2LSB; elf.e_ident[EI_VERSION] = EV_CURRENT; memset(elf.e_ident+EI_PAD, 0, EI_NIDENT-EI_PAD); - + elf.e_type = ET_CORE; elf.e_machine = ELF_ARCH; elf.e_version = EV_CURRENT; @@ -1198,27 +1194,6 @@ static int irix_core_dump(long signr, struct pt_regs * regs) fs = get_fs(); set_fs(KERNEL_DS); - memcpy(corefile,"core.", 5); -#if 0 - memcpy(corefile+5,current->comm,sizeof(current->comm)); -#else - corefile[4] = '\0'; -#endif - file = filp_open(corefile, O_CREAT | 2 | O_TRUNC | O_NOFOLLOW, 0600); - if (IS_ERR(file)) - goto end_coredump; - dentry = file->f_dentry; - inode = dentry->d_inode; - if (inode->i_nlink > 1) - goto close_coredump; /* multiple links - don't dump */ - - if (!S_ISREG(inode->i_mode)) - goto close_coredump; - if (!inode->i_op || !inode->i_op->default_file_ops) - goto close_coredump; - if (!file->f_op->write) - goto close_coredump; - has_dumped = 1; current->flags |= PF_DUMPCORE; @@ -1292,7 +1267,7 @@ static int irix_core_dump(long signr, struct pt_regs * regs) notes[2].type = NT_TASKSTRUCT; notes[2].datasz = sizeof(*current); notes[2].data = current; - + /* Try to dump the FPU. */ prstatus.pr_fpvalid = dump_fpu (&fpu); if (!prstatus.pr_fpvalid) { @@ -1303,7 +1278,7 @@ static int irix_core_dump(long signr, struct pt_regs * regs) notes[3].datasz = sizeof(fpu); notes[3].data = &fpu; } - + /* Write notes phdr entry. */ { struct elf_phdr phdr; @@ -1355,7 +1330,7 @@ static int irix_core_dump(long signr, struct pt_regs * regs) for(i = 0; i < numnote; i++) if (!writenote(¬es[i], file)) - goto close_coredump; + goto end_coredump; set_fs(fs); @@ -1382,37 +1357,24 @@ static int irix_core_dump(long signr, struct pt_regs * regs) (off_t) file->f_pos, offset); } - close_coredump: - filp_close(file, NULL); - - end_coredump: +end_coredump: set_fs(fs); -#ifndef CONFIG_BINFMT_ELF +#ifndef CONFIG_BINFMT_IRIX MOD_DEC_USE_COUNT; #endif return has_dumped; } -int __init init_irix_binfmt(void) +static int __init init_irix_binfmt(void) { return register_binfmt(&irix_format); } -#ifdef MODULE - -int init_module(void) -{ - /* Install the COFF, ELF and XOUT loaders. - * N.B. We *rely* on the table being the right size with the - * right number of free slots... - */ - return init_irix_binfmt(); -} - - -void cleanup_module( void) +static void __exit cleanup_module(void) { /* Remove the IRIX ELF loaders. */ unregister_binfmt(&irix_format); } -#endif + +module_init(init_irix_binfmt) +module_exit(exit_irix_binfmt) diff --git a/arch/mips/kernel/irixinv.c b/arch/mips/kernel/irixinv.c index 105b29f23..9028a27be 100644 --- a/arch/mips/kernel/irixinv.c +++ b/arch/mips/kernel/irixinv.c @@ -5,7 +5,7 @@ * * Miguel de Icaza, 1997. * - * $Id: irixinv.c,v 1.2 1997/12/06 23:52:04 ralf Exp $ + * $Id: irixinv.c,v 1.3 1998/04/05 11:23:51 ralf Exp $ */ #include #include @@ -53,7 +53,7 @@ dump_inventory_to_user (void *userbuf, int size) return inventory_items * sizeof (inventory_t); } -__initfunc(void init_inventory (void)) +void __init init_inventory (void) { /* gross hack while we put the right bits all over the kernel * most likely this will not let just anyone run the X server diff --git a/arch/mips/kernel/irixsig.c b/arch/mips/kernel/irixsig.c index 7ec7b175c..c07ce2062 100644 --- a/arch/mips/kernel/irixsig.c +++ b/arch/mips/kernel/irixsig.c @@ -3,7 +3,7 @@ * * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) * - * $Id: irixsig.c,v 1.11 1999/06/17 13:25:46 ralf Exp $ + * $Id: irixsig.c,v 1.12 1999/09/28 22:25:46 ralf Exp $ */ #include @@ -261,12 +261,8 @@ asmlinkage int do_irix_signal(sigset_t *oldset, struct pt_regs *regs) case SIGQUIT: case SIGILL: case SIGTRAP: case SIGABRT: case SIGFPE: case SIGSEGV: - lock_kernel(); - if (current->binfmt - && current->binfmt->core_dump - && current->binfmt->core_dump(signr, regs)) + if (do_coredump(signr, regs)) exit_code |= 0x80; - unlock_kernel(); /* FALLTHRU */ default: @@ -338,10 +334,10 @@ irix_sigreturn(struct pt_regs *regs) __get_user(regs->lo, &context->lo); if ((umask & 1) && context->usedfp) { - fregs = (u64 *) ¤t->tss.fpu; + fregs = (u64 *) ¤t->thread.fpu; for(i = 0; i < 32; i++) fregs[i] = (u64) context->fpregs[i]; - __get_user(current->tss.fpu.hard.control, &context->fpcsr); + __get_user(current->thread.fpu.hard.control, &context->fpcsr); } /* XXX do sigstack crapola here... XXX */ @@ -795,7 +791,7 @@ asmlinkage int irix_getcontext(struct pt_regs *regs) error = verify_area(VERIFY_WRITE, ctx, sizeof(*ctx)); if(error) goto out; - __put_user(current->tss.irix_oldctx, &ctx->link); + __put_user(current->thread.irix_oldctx, &ctx->link); __copy_to_user(&ctx->sigmask, ¤t->blocked, sizeof(irix_sigset_t)); @@ -867,7 +863,7 @@ asmlinkage unsigned long irix_setcontext(struct pt_regs *regs) /* XXX fpu context, blah... */ printk("Wheee, cannot restore FPU context yet...\n"); } - current->tss.irix_oldctx = ctx->link; + current->thread.irix_oldctx = ctx->link; error = regs->regs[2]; out: diff --git a/arch/mips/kernel/pci.c b/arch/mips/kernel/pci.c deleted file mode 100644 index 7861789d6..000000000 --- a/arch/mips/kernel/pci.c +++ /dev/null @@ -1,93 +0,0 @@ -/* $Id: pci.c,v 1.7 1999/01/03 17:50:51 ralf Exp $ - * - * 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. - * - * MIPS implementation of PCI BIOS services for PCI support. - * - * Copyright (C) 1997, 1998 Ralf Baechle - */ -#include -#include -#include -#include -#include -#include - -#ifdef CONFIG_PCI - -struct pci_ops *pci_ops; - -/* - * BIOS32 replacement. - */ -__initfunc(void pcibios_init(void)) -{ -} - -/* - * Following the generic parts of the MIPS BIOS32 code. - */ - -int pcibios_present (void) -{ - return pci_ops != NULL; -} - -/* - * The functions below are machine specific and must be reimplimented for - * each PCI chipset configuration. We just run the hook to the machine - * specific implementation. - */ -void pcibios_fixup (void) -{ - pci_ops->pcibios_fixup(); -} - -int pcibios_read_config_byte (unsigned char bus, unsigned char dev_fn, - unsigned char where, unsigned char *val) -{ - return pci_ops->pcibios_read_config_byte(bus, dev_fn, where, val); -} - -int pcibios_read_config_word (unsigned char bus, unsigned char dev_fn, - unsigned char where, unsigned short *val) -{ - return pci_ops->pcibios_read_config_word(bus, dev_fn, where, val); -} - -int pcibios_read_config_dword (unsigned char bus, unsigned char dev_fn, - unsigned char where, unsigned int *val) -{ - return pci_ops->pcibios_read_config_dword(bus, dev_fn, where, val); -} - -int pcibios_write_config_byte (unsigned char bus, unsigned char dev_fn, - unsigned char where, unsigned char val) -{ - return pci_ops->pcibios_write_config_byte(bus, dev_fn, where, val); -} - -int pcibios_write_config_word (unsigned char bus, unsigned char dev_fn, - unsigned char where, unsigned short val) -{ - return pci_ops->pcibios_write_config_word(bus, dev_fn, where, val); -} - -int pcibios_write_config_dword (unsigned char bus, unsigned char dev_fn, - unsigned char where, unsigned int val) -{ - return pci_ops->pcibios_write_config_dword(bus, dev_fn, where, val); -} - -__initfunc(char *pcibios_setup(char *str)) -{ - return str; -} - -__initfunc(void pcibios_fixup_bus(struct pci_bus *bus)) -{ -} - -#endif /* defined(CONFIG_PCI) */ diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index 8e1afd78f..ffd9fd990 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c @@ -1,10 +1,11 @@ -/* $Id: process.c,v 1.14 1999/08/09 19:43:14 harald Exp $ +/* $Id: process.c,v 1.15 1999/09/28 22:25:47 ralf Exp $ * * 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) 1994 - 1998 by Ralf Baechle and others. + * Copyright (C) 1994 - 1999 by Ralf Baechle and others. + * Copyright (C) 1999 Silicon Graphics, Inc. */ #include #include @@ -30,6 +31,42 @@ #include #include +asmlinkage int cpu_idle(void) +{ + unsigned long start_idle = 0; + + if (current->pid != 0) + return -EPERM; + + /* endless idle loop with no priority at all */ + current->priority = 0; + current->counter = 0; + for (;;) { + /* + * R4[36]00 have wait, R4[04]00 don't. + * FIXME: We should save power by reducing the clock where + * possible. Thiss will cut down the power consuption + * of R4200 systems to about 1/16th of normal, the + * same for logic clocked with the processor generated + * clocks. + */ + if (!start_idle) { + check_pgt_cache(); + start_idle = jiffies; + } + if (wait_available && !current->need_resched) + __asm__(".set\tmips3\n\t" + "wait\n\t" + ".set\tmips0"); + run_task_queue(&tq_scheduler); + if (current->need_resched) + start_idle = 0; + schedule(); + } + + return 0; +} + struct task_struct *last_task_used_math = NULL; asmlinkage void ret_from_sys_call(void); @@ -84,22 +121,21 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp, if (childregs->cp0_status & ST0_CU0) { childregs->regs[28] = (unsigned long) p; childregs->regs[29] = childksp; - p->tss.current_ds = KERNEL_DS; + p->thread.current_ds = KERNEL_DS; } else { childregs->regs[29] = usp; - p->tss.current_ds = USER_DS; + p->thread.current_ds = USER_DS; } - p->tss.reg29 = (unsigned long) childregs; - p->tss.reg31 = (unsigned long) ret_from_sys_call; + p->thread.reg29 = (unsigned long) childregs; + p->thread.reg31 = (unsigned long) ret_from_sys_call; /* * New tasks loose permission to use the fpu. This accelerates context * switching for most programs since they don't use the fpu. */ - p->tss.cp0_status = read_32bit_cp0_register(CP0_STATUS) & + p->thread.cp0_status = read_32bit_cp0_register(CP0_STATUS) & ~(ST0_CU3|ST0_CU2|ST0_CU1|KU_MASK); childregs->cp0_status &= ~(ST0_CU3|ST0_CU2|ST0_CU1); - p->mm->context = 0; return 0; } @@ -107,11 +143,11 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp, /* Fill in the fpu structure for a core dump.. */ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *r) { - /* We actually store the FPU info in the task->tss + /* We actually store the FPU info in the task->thread * area. */ if(regs->cp0_status & ST0_CU1) { - memcpy(r, ¤t->tss.fpu, sizeof(current->tss.fpu)); + memcpy(r, ¤t->thread.fpu, sizeof(current->thread.fpu)); return 1; } return 0; /* Task didn't use the fpu at all. */ @@ -129,7 +165,7 @@ void dump_thread(struct pt_regs *regs, struct user *dump) dump->u_ssize = (current->mm->start_stack - dump->start_stack + PAGE_SIZE - 1) >> PAGE_SHIFT; memcpy(&dump->regs[0], regs, sizeof(struct pt_regs)); - memcpy(&dump->regs[EF_SIZE/4], ¤t->tss.fpu, sizeof(current->tss.fpu)); + memcpy(&dump->regs[EF_SIZE/4], ¤t->thread.fpu, sizeof(current->thread.fpu)); } /* diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c index 68084ab3d..4eca68401 100644 --- a/arch/mips/kernel/ptrace.c +++ b/arch/mips/kernel/ptrace.c @@ -1,4 +1,4 @@ -/* $Id: ptrace.c,v 1.16 1999/08/18 23:37:43 ralf Exp $ +/* $Id: ptrace.c,v 1.17 1999/09/28 22:25:47 ralf Exp $ * * 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 @@ -143,7 +143,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) disable_cp1(); last_task_used_math = NULL; } - tmp = child->tss.fpu.hard.fp_regs[addr - 32]; + tmp = child->thread.fpu.hard.fp_regs[addr - 32]; } else { tmp = -1; /* FP not yet used */ } @@ -164,7 +164,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) tmp = regs->lo; break; case FPC_CSR: - tmp = child->tss.fpu.hard.control; + tmp = child->thread.fpu.hard.control; break; case FPC_EIR: { /* implementation / version register */ unsigned int flags; @@ -215,11 +215,11 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) } } else { /* FP not yet used */ - memset(&child->tss.fpu.hard, ~0, - sizeof(child->tss.fpu.hard)); - child->tss.fpu.hard.control = 0; + memset(&child->thread.fpu.hard, ~0, + sizeof(child->thread.fpu.hard)); + child->thread.fpu.hard.control = 0; } - fregs = child->tss.fpu.hard.fp_regs; + fregs = child->thread.fpu.hard.fp_regs; fregs[addr - FPR_BASE] = data; break; } @@ -233,7 +233,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) regs->lo = data; break; case FPC_CSR: - child->tss.fpu.hard.control = data; + child->thread.fpu.hard.control = data; break; default: /* The rest are not allowed. */ diff --git a/arch/mips/kernel/r2300_misc.S b/arch/mips/kernel/r2300_misc.S index 2d53e9503..82635c11f 100644 --- a/arch/mips/kernel/r2300_misc.S +++ b/arch/mips/kernel/r2300_misc.S @@ -1,4 +1,4 @@ -/* $Id: r2300_misc.S,v 1.5 1999/08/18 23:37:44 ralf Exp $ +/* $Id: r2300_misc.S,v 1.6 1999/09/27 11:13:47 raiko Exp $ * misc.S: Misc. exception handling code for R3000/R2000. * * Copyright (C) 1994, 1995, 1996 by Ralf Baechle and Andreas Busse @@ -41,7 +41,9 @@ mfc0 pte, CP0_BADVADDR; \ _GET_CURRENT(ptr); \ srl pte, pte, 22; \ - lw ptr, THREAD_PGDIR(ptr); \ + lw ptr, TASK_MM(ptr); \ + nop; \ + lw ptr, MM_PGD(ptr); \ sll pte, pte, 2; \ addu ptr, pte, ptr; \ mfc0 pte, CP0_CONTEXT; \ diff --git a/arch/mips/kernel/r4k_misc.S b/arch/mips/kernel/r4k_misc.S index d83f85b81..6e6ff5294 100644 --- a/arch/mips/kernel/r4k_misc.S +++ b/arch/mips/kernel/r4k_misc.S @@ -1,4 +1,4 @@ -/* $Id: r4k_misc.S,v 1.6 1999/08/18 23:37:44 ralf Exp $ +/* $Id: r4k_misc.S,v 1.7 1999/09/28 22:25:47 ralf Exp $ * * r4k_misc.S: Misc. exception handling code for r4k. * @@ -20,7 +20,7 @@ #include #include -#undef NOTLB_OPTIMIZE /* If you are paranoid, define this. */ +#define NOTLB_OPTIMIZE /* If you are paranoid, define this. */ /* ABUSE of CPP macros 101. */ @@ -33,7 +33,8 @@ srl pte, pte, 22; \ _GET_CURRENT(ptr); \ sll pte, pte, 2; \ - lw ptr, THREAD_PGDIR(ptr); \ + lw ptr, TASK_MM(ptr); \ + lw ptr, MM_PGD(ptr); \ addu ptr, pte, ptr; \ mfc0 pte, CP0_BADVADDR; \ lw ptr, (ptr); \ diff --git a/arch/mips/kernel/r4k_switch.S b/arch/mips/kernel/r4k_switch.S index 8f16bdd80..0ac3c532f 100644 --- a/arch/mips/kernel/r4k_switch.S +++ b/arch/mips/kernel/r4k_switch.S @@ -1,4 +1,4 @@ -/* $Id: r4k_switch.S,v 1.8 1999/08/09 19:43:15 harald Exp $ +/* $Id: r4k_switch.S,v 1.9 1999/08/18 23:37:44 ralf Exp $ * * 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 @@ -7,6 +7,7 @@ * Copyright (C) 1994, 1995, 1996, 1998, 1999 by Ralf Baechle * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) * Copyright (C) 1994, 1995, 1996, by Andreas Busse + * Copyright (C) 1999 Silicon Graphics, Inc. */ #include #include @@ -23,12 +24,12 @@ #include + .set mips3 + /* - * task_struct *r4xx0_resume(task_struct *prev, - * task_struct *next) + * task_struct *r4xx0_resume(task_struct *prev, task_struct *next) */ .set noreorder - .set mips3 .align 5 LEAF(resume) mfc0 t1, CP0_STATUS @@ -50,12 +51,8 @@ lw a2, THREAD_STATUS($28) nor a3, $0, a3 and a2, a3 - lw a3, TASK_MM($28) or a2, t1 - lw a3, MM_CONTEXT(a3) mtc0 a2, CP0_STATUS - andi a3, a3, 0xff - mtc0 a3, CP0_ENTRYHI jr ra move v0, a0 END(resume) diff --git a/arch/mips/kernel/semaphore.c b/arch/mips/kernel/semaphore.c new file mode 100644 index 000000000..d62b355e1 --- /dev/null +++ b/arch/mips/kernel/semaphore.c @@ -0,0 +1,129 @@ +/* + * Generic semaphore code. Buyer beware. Do your own + * specific changes in + */ + +#include +#include + +/* + * Semaphores are implemented using a two-way counter: + * The "count" variable is decremented for each process + * that tries to sleep, while the "waking" variable is + * incremented when the "up()" code goes to wake up waiting + * processes. + * + * Notably, the inline "up()" and "down()" functions can + * efficiently test if they need to do any extra work (up + * needs to do something only if count was negative before + * the increment operation. + * + * waking_non_zero() (from asm/semaphore.h) must execute + * atomically. + * + * When __up() is called, the count was negative before + * incrementing it, and we need to wake up somebody. + * + * This routine adds one to the count of processes that need to + * wake up and exit. ALL waiting processes actually wake up but + * only the one that gets to the "waking" field first will gate + * through and acquire the semaphore. The others will go back + * to sleep. + * + * Note that these functions are only called when there is + * contention on the lock, and as such all this is the + * "non-critical" part of the whole semaphore business. The + * critical part is the inline stuff in + * where we want to avoid any extra jumps and calls. + */ +void __up(struct semaphore *sem) +{ + wake_one_more(sem); + wake_up(&sem->wait); +} + +/* + * Perform the "down" function. Return zero for semaphore acquired, + * return negative for signalled out of the function. + * + * If called from __down, the return is ignored and the wait loop is + * not interruptible. This means that a task waiting on a semaphore + * using "down()" cannot be killed until someone does an "up()" on + * the semaphore. + * + * If called from __down_interruptible, the return value gets checked + * upon return. If the return value is negative then the task continues + * with the negative value in the return register (it can be tested by + * the caller). + * + * Either form may be used in conjunction with "up()". + * + */ + +#define DOWN_VAR \ + struct task_struct *tsk = current; \ + wait_queue_t wait; \ + init_waitqueue_entry(&wait, tsk); + +#define DOWN_HEAD(task_state) \ + \ + \ + tsk->state = (task_state); \ + add_wait_queue(&sem->wait, &wait); \ + \ + /* \ + * Ok, we're set up. sem->count is known to be less than zero \ + * so we must wait. \ + * \ + * We can let go the lock for purposes of waiting. \ + * We re-acquire it after awaking so as to protect \ + * all semaphore operations. \ + * \ + * If "up()" is called before we call waking_non_zero() then \ + * we will catch it right away. If it is called later then \ + * we will have to go through a wakeup cycle to catch it. \ + * \ + * Multiple waiters contend for the semaphore lock to see \ + * who gets to gate through and who has to wait some more. \ + */ \ + for (;;) { + +#define DOWN_TAIL(task_state) \ + tsk->state = (task_state); \ + } \ + tsk->state = TASK_RUNNING; \ + remove_wait_queue(&sem->wait, &wait); + +void __down(struct semaphore * sem) +{ + DOWN_VAR + DOWN_HEAD(TASK_UNINTERRUPTIBLE) + if (waking_non_zero(sem)) + break; + schedule(); + DOWN_TAIL(TASK_UNINTERRUPTIBLE) +} + +int __down_interruptible(struct semaphore * sem) +{ + int ret = 0; + DOWN_VAR + DOWN_HEAD(TASK_INTERRUPTIBLE) + + ret = waking_non_zero_interruptible(sem, tsk); + if (ret) + { + if (ret == 1) + /* ret != 0 only if we get interrupted -arca */ + ret = 0; + break; + } + schedule(); + DOWN_TAIL(TASK_INTERRUPTIBLE) + return ret; +} + +int __down_trylock(struct semaphore * sem) +{ + return waking_non_zero_trylock(sem); +} diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index fd6650b1c..9f4b5164a 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -1,4 +1,4 @@ -/* $Id: setup.c,v 1.18 1999/09/18 20:48:03 harald Exp $ +/* $Id: setup.c,v 1.19 1999/09/28 22:25:47 ralf Exp $ * * 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 @@ -126,13 +126,13 @@ unsigned long mips_io_port_base; */ unsigned long isa_slot_offset; -__initfunc(static void default_irq_setup(void)) +static void __init default_irq_setup(void) { panic("Unknown machtype in init_IRQ"); } -__initfunc(void setup_arch(char **cmdline_p, - unsigned long * memory_start_p, unsigned long * memory_end_p)) +void __init setup_arch(char **cmdline_p, + unsigned long * memory_start_p, unsigned long * memory_end_p) { unsigned long memory_end; #ifdef CONFIG_BLK_DEV_INITRD diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c index 0a7190412..92df924a5 100644 --- a/arch/mips/kernel/signal.c +++ b/arch/mips/kernel/signal.c @@ -1,4 +1,4 @@ -/* $Id: signal.c,v 1.21 1999/08/24 22:54:21 ralf Exp $ +/* $Id: signal.c,v 1.22 1999/09/28 22:25:48 ralf Exp $ * * 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 @@ -619,12 +619,8 @@ asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs) case SIGQUIT: case SIGILL: case SIGTRAP: case SIGABRT: case SIGFPE: case SIGSEGV: case SIGBUS: - lock_kernel(); - if (current->binfmt - && current->binfmt->core_dump - && current->binfmt->core_dump(signr, regs)) + if (do_coredump(signr, regs)) exit_code |= 0x80; - unlock_kernel(); /* FALLTHRU */ default: diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c index 67e550cf3..05e1fea1e 100644 --- a/arch/mips/kernel/syscall.c +++ b/arch/mips/kernel/syscall.c @@ -1,4 +1,4 @@ -/* $Id: syscall.c,v 1.9 1998/08/25 09:14:41 ralf Exp $ +/* $Id: syscall.c,v 1.10 1999/02/15 02:16:52 ralf Exp $ * * 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 @@ -77,42 +77,6 @@ out: return error; } -asmlinkage int sys_idle(void) -{ - unsigned long start_idle = 0; - - if (current->pid != 0) - return -EPERM; - - /* endless idle loop with no priority at all */ - current->priority = 0; - current->counter = 0; - for (;;) { - /* - * R4[36]00 have wait, R4[04]00 don't. - * FIXME: We should save power by reducing the clock where - * possible. Thiss will cut down the power consuption - * of R4200 systems to about 1/16th of normal, the - * same for logic clocked with the processor generated - * clocks. - */ - if (!start_idle) { - check_pgt_cache(); - start_idle = jiffies; - } - if (wait_available && !current->need_resched) - __asm__(".set\tmips3\n\t" - "wait\n\t" - ".set\tmips0"); - run_task_queue(&tq_scheduler); - if (current->need_resched) - start_idle = 0; - schedule(); - } - - return 0; -} - asmlinkage int sys_fork(struct pt_regs regs) { int res; diff --git a/arch/mips/kernel/syscalls.h b/arch/mips/kernel/syscalls.h index ef593845e..688162211 100644 --- a/arch/mips/kernel/syscalls.h +++ b/arch/mips/kernel/syscalls.h @@ -1,4 +1,4 @@ -/* $Id: syscalls.h,v 1.16 1999/07/11 23:56:29 ralf Exp $ +/* $Id: syscalls.h,v 1.17 1999/09/28 22:25:48 ralf Exp $ * * 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 @@ -127,7 +127,7 @@ SYS(sys_newfstat, 2) SYS(sys_uname, 1) SYS(sys_iopl, 0) /* Well, actually 17 args ... */ /* 4110 */ SYS(sys_vhangup, 0) -SYS(sys_idle, 0) +SYS(sys_ni_syscall, 0) /* was sys_idle() */ SYS(sys_vm86, 1) SYS(sys_wait4, 4) SYS(sys_swapoff, 1) /* 4115 */ diff --git a/arch/mips/kernel/sysirix.c b/arch/mips/kernel/sysirix.c index 338a1ce11..7dd1a21af 100644 --- a/arch/mips/kernel/sysirix.c +++ b/arch/mips/kernel/sysirix.c @@ -1,4 +1,4 @@ -/* $Id: sysirix.c,v 1.19 1999/06/13 16:30:33 ralf Exp $ +/* $Id: sysirix.c,v 1.20 1999/06/17 13:25:48 ralf Exp $ * * sysirix.c: IRIX system call emulation. * @@ -34,6 +34,8 @@ /* 2,526 lines of complete and utter shit coming up... */ +extern int max_threads; + /* The sysmp commands supported thus far. */ #define MP_NPROCS 1 /* # processor in complex */ #define MP_NAPROCS 2 /* # active processors in complex */ @@ -100,7 +102,7 @@ asmlinkage int irix_prctl(struct pt_regs *regs) case PR_MAXPROCS: printk("irix_prctl[%s:%ld]: Wants PR_MAXPROCS\n", current->comm, current->pid); - error = NR_TASKS; + error = max_threads; break; case PR_ISBLOCKED: { @@ -113,7 +115,7 @@ asmlinkage int irix_prctl(struct pt_regs *regs) error = -ESRCH; break; } - error = (task->next_run ? 0 : 1); + error = (task->run_list.next != NULL); /* Can _your_ OS find this out that fast? */ break; } @@ -359,7 +361,7 @@ asmlinkage int irix_syssgi(struct pt_regs *regs) retval = (MAX_ARG_PAGES >> 4); /* XXX estimate... */ goto out; case 2: - retval = NR_TASKS; + retval = max_threads; goto out; case 3: retval = HZ; diff --git a/arch/mips/kernel/sysmips.c b/arch/mips/kernel/sysmips.c index f3e8cb299..21ffd92e6 100644 --- a/arch/mips/kernel/sysmips.c +++ b/arch/mips/kernel/sysmips.c @@ -7,7 +7,7 @@ * * Copyright (C) 1995, 1996, 1997 by Ralf Baechle * - * $Id: sysmips.c,v 1.4 1998/05/07 15:20:05 ralf Exp $ + * $Id: sysmips.c,v 1.6 1998/08/25 09:14:42 ralf Exp $ */ #include #include @@ -91,8 +91,8 @@ sys_sysmips(int cmd, int arg1, int arg2, int arg3) goto out; case MIPS_FIXADE: - tmp = current->tss.mflags & ~3; - current->tss.mflags = tmp | (arg1 & 3); + tmp = current->thread.mflags & ~3; + current->thread.mflags = tmp | (arg1 & 3); retval = 0; goto out; diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c index ecb89b755..1a45ce783 100644 --- a/arch/mips/kernel/time.c +++ b/arch/mips/kernel/time.c @@ -1,4 +1,4 @@ -/* $Id: time.c,v 1.11 1999/02/15 02:16:53 ralf Exp $ +/* $Id: time.c,v 1.12 1999/06/13 16:30:34 ralf Exp $ * * Copyright (C) 1991, 1992, 1995 Linus Torvalds * Copyright (C) 1996, 1997, 1998 Ralf Baechle @@ -478,7 +478,7 @@ struct irqaction irq0 = { timer_interrupt, SA_INTERRUPT, 0, void (*board_time_init)(struct irqaction *irq); -__initfunc(void time_init(void)) +void __init time_init(void) { unsigned int epoch, year, mon, day, hour, min, sec; int i; diff --git a/arch/mips/kernel/unaligned.c b/arch/mips/kernel/unaligned.c index bdfc29ea1..591c1a47b 100644 --- a/arch/mips/kernel/unaligned.c +++ b/arch/mips/kernel/unaligned.c @@ -7,7 +7,7 @@ * * Copyright (C) 1996, 1998 by Ralf Baechle * - * $Id: unaligned.c,v 1.4 1998/08/25 09:14:44 ralf Exp $ + * $Id: unaligned.c,v 1.5 1999/05/01 22:40:39 ralf Exp $ * * This file contains exception handler for address error exception with the * special capability to execute faulting instructions in software. The @@ -398,7 +398,7 @@ asmlinkage void do_ade(struct pt_regs *regs) pc = regs->cp0_epc + ((regs->cp0_cause & CAUSEF_BD) ? 4 : 0); if (compute_return_epc(regs)) return; - if ((current->tss.mflags & MF_FIXADE) == 0) + if ((current->thread.mflags & MF_FIXADE) == 0) goto sigbus; emulate_load_store_insn(regs, regs->cp0_badvaddr, pc); -- cgit v1.2.3