From 19c9bba94152148523ba0f7ef7cffe3d45656b11 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Tue, 29 Apr 1997 21:13:14 +0000 Subject: Import of Linux/MIPS 2.1.36 --- arch/mips/mm/Makefile | 2 +- arch/mips/mm/andes.c | 1 - arch/mips/mm/extable.c | 33 ++++++++++----------- arch/mips/mm/fault.c | 15 ++++++---- arch/mips/mm/init.c | 22 +++++++++----- arch/mips/mm/loadmmu.c | 1 - arch/mips/mm/r2300.c | 9 +++--- arch/mips/mm/r4xx0.c | 79 ++++++++++++++++++++++++++------------------------ arch/mips/mm/r6000.c | 1 - arch/mips/mm/stack.c | 27 +++++++++++++++++ arch/mips/mm/tfp.c | 1 - 11 files changed, 112 insertions(+), 79 deletions(-) create mode 100644 arch/mips/mm/stack.c (limited to 'arch/mips/mm') diff --git a/arch/mips/mm/Makefile b/arch/mips/mm/Makefile index 1205b2bf3..d12159903 100644 --- a/arch/mips/mm/Makefile +++ b/arch/mips/mm/Makefile @@ -9,6 +9,6 @@ O_TARGET := mm.o O_OBJS := extable.o init.o fault.o r4xx0.o r2300.o r6000.o tfp.o \ - andes.o loadmmu.o + andes.o loadmmu.o stack.o include $(TOPDIR)/Rules.make diff --git a/arch/mips/mm/andes.c b/arch/mips/mm/andes.c index 977fa1a30..ee0771a74 100644 --- a/arch/mips/mm/andes.c +++ b/arch/mips/mm/andes.c @@ -10,7 +10,6 @@ #include #include -#include #include #include diff --git a/arch/mips/mm/extable.c b/arch/mips/mm/extable.c index c46568ab1..a92fdc482 100644 --- a/arch/mips/mm/extable.c +++ b/arch/mips/mm/extable.c @@ -29,27 +29,24 @@ search_one_table(const struct exception_table_entry *first, return 0; } -unsigned long search_exception_table(unsigned long addr) +unsigned long +search_exception_table(unsigned long addr) { - unsigned ret; -#ifdef CONFIG_MODULES - struct module *mp; -#endif + unsigned long ret; - /* Search the kernel's table first. */ - ret = search_one_table(__start___ex_table, - __stop___ex_table-1, addr); - if (ret) - return ret; - -#ifdef CONFIG_MODULES +#ifndef CONFIG_MODULES + /* There is only the kernel to search. */ + ret = search_one_table(__start___ex_table, __stop___ex_table-1, addr); + if (ret) return ret; +#else + /* The kernel is the last "module" -- no need to treat it special. */ + struct module *mp; for (mp = module_list; mp != NULL; mp = mp->next) { - if (mp->exceptinfo.start != NULL) { - ret = search_one_table(mp->exceptinfo.start, - mp->exceptinfo.stop-1, addr); - if (ret) - return ret; - } + if (mp->ex_table_start == NULL) + continue; + ret = search_one_table(mp->ex_table_start, + mp->ex_table_end - 1, addr); + if (ret) return ret; } #endif diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c index 1ad0ff48e..4fdd98155 100644 --- a/arch/mips/mm/fault.c +++ b/arch/mips/mm/fault.c @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include #include @@ -41,8 +43,9 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long writeaccess, struct mm_struct *mm = tsk->mm; unsigned long fixup; + lock_kernel(); #if 0 - printk("[%s:%d:%08lx:%ld:%08lx]", current->comm, current->pid, + printk("[%s:%d:%08lx:%ld:%08lx]\n", current->comm, current->pid, address, writeaccess, regs->cp0_epc); #endif down(&mm->mmap_sem); @@ -70,7 +73,7 @@ good_area: handle_mm_fault(vma, address, writeaccess); up(&mm->mmap_sem); - return; + goto out; /* * Something tried to access memory that isn't in our memory map.. @@ -84,10 +87,10 @@ bad_area: if (fixup) { long new_epc; new_epc = fixup_exception(dpf_reg, fixup, regs->cp0_epc); - printk("Taking exception at %lx (%lx)\n", + printk(KERN_DEBUG "Exception at [<%lx>] (%lx)\n", regs->cp0_epc, new_epc); regs->cp0_epc = new_epc; - return; + goto out; } if (user_mode(regs)) { @@ -106,7 +109,7 @@ bad_area: current->tss.cp0_badvaddr = address; current->tss.error_code = writeaccess; force_sig(SIGSEGV, tsk); - return; + goto out; } /* * Oops. The kernel tried to access some bad page. We'll have to @@ -116,4 +119,6 @@ bad_area: "address %08lx, epc == %08lx\n", address, regs->cp0_epc); die_if_kernel("Oops", regs, writeaccess); do_exit(SIGKILL); +out: + unlock_kernel(); } diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c index cfcfcaf00..7a4b6df4b 100644 --- a/arch/mips/mm/init.c +++ b/arch/mips/mm/init.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #ifdef CONFIG_SGI #include @@ -35,6 +34,8 @@ extern void deskstation_tyne_dma_init(void); extern void show_net_buffers(void); +const char bad_pmd_string[] = "Bad pmd in pte_alloc: %08lx\n"; + asmlinkage int sys_cacheflush(void *addr, int bytes, int cache) { /* XXX Just get it working for now... */ @@ -181,10 +182,10 @@ void show_mem(void) total++; if (PageReserved(mem_map+i)) reserved++; - else if (!mem_map[i].count) + else if (!atomic_read(&mem_map[i].count)) free++; else - shared += mem_map[i].count-1; + shared += atomic_read(&mem_map[i].count) - 1; } printk("%d pages of RAM\n", total); printk("%d free pages\n", free); @@ -217,7 +218,7 @@ void mem_init(unsigned long start_mem, unsigned long end_mem) #endif end_mem &= PAGE_MASK; - max_mapnr = MAP_NR(end_mem); + max_mapnr = num_physpages = MAP_NR(end_mem); high_memory = (void *)end_mem; /* clear the zero-page */ @@ -243,7 +244,7 @@ void mem_init(unsigned long start_mem, unsigned long end_mem) #ifdef CONFIG_SGI - prom_fixup_mem_map(start_mem, high_memory); + prom_fixup_mem_map(start_mem, (unsigned long)high_memory); #endif #ifdef CONFIG_DESKSTATION_TYNE @@ -267,7 +268,7 @@ void mem_init(unsigned long start_mem, unsigned long end_mem) datapages++; continue; } - mem_map[MAP_NR(tmp)].count = 1; + atomic_set(&mem_map[MAP_NR(tmp)].count, 1); #ifdef CONFIG_BLK_DEV_INITRD if (!initrd_start || (tmp < initrd_start || tmp >= initrd_end)) @@ -284,6 +285,11 @@ void mem_init(unsigned long start_mem, unsigned long end_mem) return; } +void free_initmem(void) +{ + /* To be written */ +} + void si_meminfo(struct sysinfo *val) { int i; @@ -297,9 +303,9 @@ void si_meminfo(struct sysinfo *val) if (PageReserved(mem_map+i)) continue; val->totalram++; - if (!mem_map[i].count) + if (!atomic_read(&mem_map[i].count)) continue; - val->sharedram += mem_map[i].count-1; + val->sharedram += atomic_read(&mem_map[i].count) - 1; } val->totalram <<= PAGE_SHIFT; val->sharedram <<= PAGE_SHIFT; diff --git a/arch/mips/mm/loadmmu.c b/arch/mips/mm/loadmmu.c index 9a0c33328..4ca1326f7 100644 --- a/arch/mips/mm/loadmmu.c +++ b/arch/mips/mm/loadmmu.c @@ -10,7 +10,6 @@ #include #include -#include #include #include #include diff --git a/arch/mips/mm/r2300.c b/arch/mips/mm/r2300.c index b43d7a2bc..2e57625df 100644 --- a/arch/mips/mm/r2300.c +++ b/arch/mips/mm/r2300.c @@ -10,7 +10,6 @@ #include #include -#include #include #include @@ -80,11 +79,11 @@ static void r2300_copy_page(unsigned long to, unsigned long from) "lw\t%3,-12(%1)\n\t" "lw\t%4,-8(%1)\n\t" "lw\t%5,-4(%1)\n\t" - "sd\t%2,-16(%0)\n\t" - "sd\t%3,-12(%0)\n\t" - "sd\t%4,-8(%0)\n\t" + "sw\t%2,-16(%0)\n\t" + "sw\t%3,-12(%0)\n\t" + "sw\t%4,-8(%0)\n\t" "bne\t$1,%0,1b\n\t" - "sd\t%5,-4(%0)\n\t" + "sw\t%5,-4(%0)\n\t" ".set\tat\n\t" ".set\treorder" :"=r" (dummy1), "=r" (dummy2), diff --git a/arch/mips/mm/r4xx0.c b/arch/mips/mm/r4xx0.c index ea983656b..5f1bcbfa6 100644 --- a/arch/mips/mm/r4xx0.c +++ b/arch/mips/mm/r4xx0.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -151,11 +150,11 @@ static void r4k_copy_page_d16(unsigned long to, unsigned long from) "lw\t%3,-12(%1)\n\t" "lw\t%4,-8(%1)\n\t" "lw\t%5,-4(%1)\n\t" - "sd\t%2,-16(%0)\n\t" - "sd\t%3,-12(%0)\n\t" - "sd\t%4,-8(%0)\n\t" + "sw\t%2,-16(%0)\n\t" + "sw\t%3,-12(%0)\n\t" + "sw\t%4,-8(%0)\n\t" "bne\t$1,%0,1b\n\t" - "sd\t%5,-4(%0)\n\t" + "sw\t%5,-4(%0)\n\t" ".set\tmips0\n\t" ".set\tat\n\t" ".set\treorder" @@ -208,11 +207,11 @@ static void r4k_copy_page_d32(unsigned long to, unsigned long from) "lw\t%3,-12(%1)\n\t" "lw\t%4,-8(%1)\n\t" "lw\t%5,-4(%1)\n\t" - "sd\t%2,-16(%0)\n\t" - "sd\t%3,-12(%0)\n\t" - "sd\t%4,-8(%0)\n\t" + "sw\t%2,-16(%0)\n\t" + "sw\t%3,-12(%0)\n\t" + "sw\t%4,-8(%0)\n\t" "bne\t$1,%0,1b\n\t" - "sd\t%5,-4(%0)\n\t" + "sw\t%5,-4(%0)\n\t" ".set\tmips0\n\t" ".set\tat\n\t" ".set\treorder" @@ -1663,7 +1662,7 @@ static void r4k_flush_page_to_ram_d32i32_r4600(unsigned long page) { page &= PAGE_MASK; if((page >= KSEG0 && page < KSEG1) || (page >= KSEG2)) { - unsigned long flags, tmp1, tmp2; + unsigned long flags; #ifdef DEBUG_CACHE /* #if 1 */ @@ -1678,34 +1677,37 @@ static void r4k_flush_page_to_ram_d32i32_r4600(unsigned long page) blast_dcache32_page(page); blast_dcache32_page(page ^ 0x2000); #ifdef CONFIG_SGI - /* - * SGI goo. Have to check this closer ... - */ - __asm__ __volatile__(" - .set noreorder - .set mips3 - li %0, 0x1 - dsll %0, 31 - or %0, %0, %2 - lui %1, 0x9000 - dsll32 %1, 0 - or %0, %0, %1 - daddu %1, %0, 0x0fe0 - li %2, 0x80 - mtc0 %2, $12 - nop; nop; nop; nop; -1: sw $0, 0(%0) - bltu %0, %1, 1b - daddu %0, 32 - mtc0 $0, $12 - nop; nop; nop; nop; - mtc0 %3, $12 - nop; nop; nop; nop; - .set mips0 - .set reorder" - : "=&r" (tmp1), "=&r" (tmp2), - "=&r" (page), "=&r" (flags) - : "2" (page & 0x0007f000), "3" (flags)); + { + unsigned long tmp1, tmp2; + /* + * SGI goo. Have to check this closer ... + */ + __asm__ __volatile__(" + .set noreorder + .set mips3 + li %0, 0x1 + dsll %0, 31 + or %0, %0, %2 + lui %1, 0x9000 + dsll32 %1, 0 + or %0, %0, %1 + daddu %1, %0, 0x0fe0 + li %2, 0x80 + mtc0 %2, $12 + nop; nop; nop; nop; +1: sw $0, 0(%0) + bltu %0, %1, 1b + daddu %0, 32 + mtc0 $0, $12 + nop; nop; nop; nop; + mtc0 %3, $12 + nop; nop; nop; nop; + .set mips0 + .set reorder" + : "=&r" (tmp1), "=&r" (tmp2), + "=&r" (page), "=&r" (flags) + : "2" (page & 0x0007f000), "3" (flags)); + } #endif /* CONFIG_SGI */ } } @@ -2452,5 +2454,6 @@ try_again: flush_cache_all(); write_32bit_cp0_register(CP0_WIRED, 0); + write_32bit_cp0_register(CP0_PAGEMASK, PM_4K); flush_tlb_all(); } diff --git a/arch/mips/mm/r6000.c b/arch/mips/mm/r6000.c index ad9332d3f..04c19b322 100644 --- a/arch/mips/mm/r6000.c +++ b/arch/mips/mm/r6000.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include diff --git a/arch/mips/mm/stack.c b/arch/mips/mm/stack.c new file mode 100644 index 000000000..89fb6dc64 --- /dev/null +++ b/arch/mips/mm/stack.c @@ -0,0 +1,27 @@ +/* + * Kernel stack allocation/deallocation + * + * 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, 1997 by Ralf Baechle + * + * (This is _bad_ if the free page pool is fragmented ...) + */ +#include +#include +#include + +extern unsigned long alloc_kernel_stack(struct task_struct *tsk) +{ + unsigned long stack; + stack = __get_free_pages(GFP_KERNEL, 1, 0); + + return stack; +} + +extern void free_kernel_stack(unsigned long stack) +{ + free_pages(stack, 1); +} diff --git a/arch/mips/mm/tfp.c b/arch/mips/mm/tfp.c index 9bd7f2b4a..cdc61f1f6 100644 --- a/arch/mips/mm/tfp.c +++ b/arch/mips/mm/tfp.c @@ -10,7 +10,6 @@ #include #include -#include #include #include -- cgit v1.2.3