diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1997-01-07 02:33:00 +0000 |
---|---|---|
committer | <ralf@linux-mips.org> | 1997-01-07 02:33:00 +0000 |
commit | beb116954b9b7f3bb56412b2494b562f02b864b1 (patch) | |
tree | 120e997879884e1b9d93b265221b939d2ef1ade1 /arch/mips/lib | |
parent | 908d4681a1dc3792ecafbe64265783a86c4cccb6 (diff) |
Import of Linux/MIPS 2.1.14
Diffstat (limited to 'arch/mips/lib')
-rw-r--r-- | arch/mips/lib/Makefile | 36 | ||||
-rw-r--r-- | arch/mips/lib/bcopy.c | 20 | ||||
-rw-r--r-- | arch/mips/lib/beep.S | 21 | ||||
-rw-r--r-- | arch/mips/lib/bitags.c | 161 | ||||
-rw-r--r-- | arch/mips/lib/checksum.c | 158 | ||||
-rw-r--r-- | arch/mips/lib/csum.S | 25 | ||||
-rw-r--r-- | arch/mips/lib/dump_tlb.c | 45 | ||||
-rw-r--r-- | arch/mips/lib/io.c | 24 | ||||
-rw-r--r-- | arch/mips/lib/memmove.c | 39 | ||||
-rw-r--r-- | arch/mips/lib/pmaxcon.c | 150 | ||||
-rw-r--r-- | arch/mips/lib/pmaxio.S | 78 | ||||
-rw-r--r-- | arch/mips/lib/strlen_user.S | 33 | ||||
-rw-r--r-- | arch/mips/lib/strncpy_user.S | 48 | ||||
-rw-r--r-- | arch/mips/lib/tinycon.c | 22 | ||||
-rw-r--r-- | arch/mips/lib/watch.S | 69 |
15 files changed, 848 insertions, 81 deletions
diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile index 56279fb3e..ac3cf45ad 100644 --- a/arch/mips/lib/Makefile +++ b/arch/mips/lib/Makefile @@ -1,33 +1,25 @@ # # Makefile for MIPS-specific library files.. # +# Some of these routines are just left over debugging trash of ancient +# times when I just could make my Tyne beep and so ... +# +# ...and for when I need to get the DECStation to use the boot prom to +# do things... Paul M. Antoine. +# -.c.s: - $(CC) $(CFLAGS) -S $< -.s.o: - $(AS) $(ASFLAGS) -o $*.o $< -.c.o: - $(CC) $(CFLAGS) -c $< .S.s: $(CPP) $(CFLAGS) $< -o $*.s .S.o: $(CC) $(CFLAGS) -c $< -o $*.o -OBJS = dump_tlb.o tinycon.o watch.o - -include ../../../.config - -lib.a: $(OBJS) - $(AR) rcs lib.a $(OBJS) - sync - -dep: - $(CPP) -M *.[cS] > .depend - -# -# include a dependency file if one exists -# -ifeq (.depend,$(wildcard .depend)) -include .depend +L_TARGET = lib.a +L_OBJS = beep.o bitags.o checksum.o csum.o dump_tlb.o io.o memmove.o \ + strncpy_user.o strlen_user.o watch.o +ifdef CONFIG_MIPS_DECSTATION +L_OBJS += pmaxcon.o pmaxio.o +else +L_OBJS += tinycon.o endif +include $(TOPDIR)/Rules.make diff --git a/arch/mips/lib/bcopy.c b/arch/mips/lib/bcopy.c new file mode 100644 index 000000000..4afd557bf --- /dev/null +++ b/arch/mips/lib/bcopy.c @@ -0,0 +1,20 @@ +/* + * arch/mips/lib/bcopy.c + * + * 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, 1995, 1996 by Ralf Baechle + * + * bcopy() only exists here such that it doesn't get compiled into + * lib/strings.o. Though it's more efficient ... + */ +#include <linux/string.h> + +char * bcopy(const char *src, char *dest, size_t count) +{ + __memcpy(dest, src, count); + + return dest; +} diff --git a/arch/mips/lib/beep.S b/arch/mips/lib/beep.S new file mode 100644 index 000000000..e74a63c0e --- /dev/null +++ b/arch/mips/lib/beep.S @@ -0,0 +1,21 @@ +#include <asm/asm.h> +#include <asm/regdef.h> + +/* + * Just for debugging... + */ + LEAF(beep) + lw t0,beepflag + bnez t0,1f + lbu t0,0xb4000061 + xori t0,3 + sb t0,0xb4000061 + li t0,1 + sw t0,beepflag +1: jr ra + END(beep) + + .bss +beepflag: .word 0 + .text + diff --git a/arch/mips/lib/bitags.c b/arch/mips/lib/bitags.c new file mode 100644 index 000000000..4427c4195 --- /dev/null +++ b/arch/mips/lib/bitags.c @@ -0,0 +1,161 @@ +/* + * milo/bitags.c -- handles the tags passed to the kernel + * + * Copyright (C) 1995 by Stoned Elipot <Stoned.Elipot@fnet.fr> + * written by Stoned Elipot from an original idea of + * Ralf Baechle <ralf@waldorf-gmbh.de> + * + * 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 + */ +#include <stdio.h> +#include <asm/bootinfo.h> + +static unsigned int debuglevel = 0; + +extern unsigned long mach_mem_upper; /* from milo.c */ +extern unsigned long mach_mem_lower; /* from milo.c */ + +static unsigned long next_tag = (unsigned long)NULL; + +/* + * Create a tag + * + * Parameters: tag - tag type to create + * size - tag's data size + * tagdata - pointer on tag's data + * + * returns : 0 - success + * 1 - failure + */ +int +bi_TagAdd(enum bi_tag type, unsigned long size, void *data) +{ + tag t; + unsigned long addr; + + t.tag = type; + t.size = size; + if (next_tag == (unsigned long)NULL) /* HuHo... first tag to create */ + { + if (mach_mem_upper != (unsigned long)NULL) /* RAM detection code had run */ + { + next_tag = mach_mem_upper; + } + else + /* RAM dectection code had not run, let's hope the + * tag we are creating is a memupper one, else fail + * ...miserably, hopelessly, lonely + */ + { + if (type != tag_memupper) + { + return 1; + } + else + { + /* + * saved, it's a memupper tag: put it's value in + * mach_mem_upper so launch() can pass it to the kernel + * in a0 and well we're going to create a tag anyway... + */ + next_tag = *(unsigned long*)data; + memcpy((void*)&mach_mem_upper, data, size); + } + } + } + addr = next_tag - (sizeof(tag)); + if (debuglevel >=2) + { + printk("bi_TagAdd: adding tag struct at %08x, tag: %d, size: %08x\r\n", addr, t.tag, t.size); + } + memcpy((void*)addr, (void*)&t, (size_t)(sizeof(tag))); + if (size != 0) + { + addr = addr - size; + if (debuglevel >=2) + { + printk("bi_TagAdd: adding tag value at %08x\r\n", addr); + } + memcpy((void*)addr, data, (size_t)(t.size)); + } + next_tag = addr; + return 0; +} + +/* + * Create tags from a "null-terminated" array of tag + * (tag type of the tag_def struct in array must be 'dummy') + * + * Parameter: taglist - tag array pointer + * + * returns : 0 - success + * 1 - failure + */ +int +bi_TagAddList(tag_def* taglist) +{ + int ret_val = 0; + for(; (taglist->t.tag != tag_dummy) && (!ret_val); taglist++) + { + /* + * we assume this tag is present in the default taglist + * for the machine we're running on + */ + if (taglist->t.tag == tag_memlower) + { + mach_mem_lower = (unsigned long)(*((unsigned long*)taglist->d)); +/* ajouter detection de memupper pour simplifier le code de bi_TagAdd: soit mach_mem_upper + a ete initialise par <machine_ident>() soit est initialise par le pre;ier tag de la list + par default pour la machine */ + } + ret_val = bi_TagAdd(taglist->t.tag, taglist->t.size, taglist->d); + } + return ret_val; +} + +/* + * Parse the tags present in upper memory to find out + * a pecular one. + * + * Parameter: type - tag type to find + * + * returns : NULL - failure + * !NULL - pointer on the tag structure found + * + * Note: Just a 'prototype', the kernel's one is in + * arch/mips/kernel/setup.c + */ +/* tag* */ +/* bi_TagFind(enum bi_tag type) */ +/* { */ +/* tag* t; */ +/* t = (tag*)(mach_mem_upper - sizeof(tag)); */ +/* while((t->tag != tag_dummy) && (t->tag != type)) */ +/* t = (tag*)(NEXTTAGPTR(t)); */ +/* if (t->tag == tag_dummy) */ +/* { */ +/* return (tag*)NULL; */ +/* } */ +/* return t; */ +/* } */ + + +/* + * Make a listing of tags available in memory: debug helper. + */ +/* void */ +/* bi_TagWalk(void) */ +/* { */ +/* tag* t; */ +/* int i=0; */ +/* t = (tag*)(mach_mem_upper - sizeof(tag)); */ +/* while(t->tag != tag_dummy) */ +/* { */ +/* printk("tag #02%dm addr: %08x, type %d, size %u\n\r", i, (void*)t, t->tag, t->size); */ +/* t = (tag*)(NEXTTAGPTR(t)); */ +/* i++; */ +/* } */ +/* return; */ +/* } */ + diff --git a/arch/mips/lib/checksum.c b/arch/mips/lib/checksum.c new file mode 100644 index 000000000..0e04ac5e8 --- /dev/null +++ b/arch/mips/lib/checksum.c @@ -0,0 +1,158 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * MIPS specific IP/TCP/UDP checksumming routines + * + * Authors: Ralf Baechle, <ralf@waldorf-gmbh.de> + * Lots of code moved from tcp.c and ip.c; see those files + * for more names. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ +#include <net/checksum.h> +#include <asm/string.h> + +/* + * computes a partial checksum, e.g. for TCP/UDP fragments + */ +unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum) +{ + unsigned long scratch1; + unsigned long scratch2; + + /* + * This is for 32-bit MIPS processors. + */ + __asm__(" + .set noreorder + .set noat + andi $1,%4,2 # Check alignment + beqz $1,2f # Branch if ok + nop # delay slot + subu $1,%3,2 # Alignment uses up two bytes + bgez $1,1f # Jump if we had at least two bytes + move %3,$1 # delay slot + j 4f + addiu %3,2 # delay slot; len was < 2. Deal with it + +1: lhu %2,(%4) + addiu %4,2 + addu %0,%2 + sltu $1,%0,%2 + addu %0,$1 + +2: srl %1,%3,5 + beqz %1,2f + sll %1,%1,5 # delay slot + + addu %1,%4 +1: lw %2,0(%4) + addu %4,32 + addu %0,%2 + sltu $1,%0,%2 + + lw %2,-28(%4) + addu %0,$1 + addu %0,%2 + sltu $1,%0,%2 + + lw %2,-24(%4) + addu %0,$1 + addu %0,%2 + sltu $1,%0,%2 + + lw %2,-20(%4) + addu %0,$1 + addu %0,%2 + sltu $1,%0,%2 + + lw %2,-16(%4) + addu %0,$1 + addu %0,%2 + sltu $1,%0,%2 + + lw %2,-12(%4) + addu %0,$1 + addu %0,%2 + sltu $1,%0,%2 + + lw %2,-8(%4) + addu %0,$1 + addu %0,%2 + sltu $1,%0,%2 + + lw %2,-4(%4) + addu %0,$1 + addu %0,%2 + sltu $1,%0,%2 + + bne %4,%1,1b + addu %0,$1 # delay slot + +2: andi %1,%3,0x1c + beqz %1,4f + addu %1,%4 # delay slot +3: lw %2,0(%4) + addu %4,4 + addu %0,%2 + sltu $1,%0,%2 + bne %4,%1,3b + addu %0,$1 # delay slot + +4: andi $1,%3,3 + beqz $1,7f + andi $1,%3,2 # delay slot + beqz $1,5f + move %2,$0 # delay slot + lhu %2,(%4) + addiu %4,2 # delay slot + +5: andi $1,%3,1 + beqz $1,6f + nop # delay slot + lbu %1,(%4) + sll %2,16\n\t" +#ifdef __MIPSEB__ + "sll %1,8\n\t" +#endif + "or %2,%1 +6: addu %0,%2 + sltu $1,%0,%2 + addu %0,$1 +7: .set at + .set reorder" + : "=r"(sum), + "=&r" (scratch1), + "=&r" (scratch2), + "=r" (len), + "=r" (buff) + : "0"(sum), "3"(len), "4"(buff) + : "$1"); + + return sum; +} + +/* + * copy while checksumming, otherwise like csum_partial + */ +unsigned int csum_partial_copy(const char *src, char *dst, + int len, unsigned int sum) +{ + /* + * It's 2:30 am and I don't feel like doing it right ... + * This is lots slower than the real thing (tm) + * + * XXX This may nuke the kernel for unaligned src addresses!!! + * (Due to software address error fixing no longer true, but + * seems to happen very rarely only anyway.) + */ + sum = csum_partial(src, len, sum); + memcpy(dst, src, len); + + return sum; +} diff --git a/arch/mips/lib/csum.S b/arch/mips/lib/csum.S new file mode 100644 index 000000000..08224e86b --- /dev/null +++ b/arch/mips/lib/csum.S @@ -0,0 +1,25 @@ +#include <asm/addrspace.h> +#include <asm/asm.h> +#include <asm/regdef.h> + +/* + * Compute kernel code checksum to check kernel code against corruption + * (Ancient debugging trash ...) + */ + LEAF(csum) + LONG_L t0,cacheflush + move t8,ra + jalr t0 + li t0,KSEG1 + la t1,final + li t2,KSEG1 + or t0,t2 + or t1,t2 + move v0,zero +1: lw t2,(t0) + addiu t0,4 + bne t0,t1,1b + xor v0,t2 + jr t8 + nop + END(csum) diff --git a/arch/mips/lib/dump_tlb.c b/arch/mips/lib/dump_tlb.c index f730b9fce..e7082e1ac 100644 --- a/arch/mips/lib/dump_tlb.c +++ b/arch/mips/lib/dump_tlb.c @@ -4,16 +4,20 @@ * Copyright (C) 1994, 1995 by Waldorf Electronics, * written by Ralf Baechle. */ - #include <linux/kernel.h> +#include <linux/mm.h> #include <linux/sched.h> #include <linux/string.h> #include <asm/bootinfo.h> -#include <asm/cachectl.h> +#include <asm/cache.h> +#include <asm/mipsconfig.h> #include <asm/mipsregs.h> +#include <asm/page.h> +#include <asm/pgtable.h> +#include <asm/uaccess.h> -static void +void dump_tlb(int first, int last) { int i; @@ -61,21 +65,20 @@ dump_tlb(int first, int last) void dump_tlb_all(void) { - dump_tlb(0, boot_info.tlb_entries - 1); + dump_tlb(0, mips_tlb_entries - 1); } void -dump_tlb_nonwired(void) +dump_tlb_wired(void) { - dump_tlb(read_32bit_cp0_register(CP0_WIRED), boot_info.tlb_entries - 1); + dump_tlb(0, read_32bit_cp0_register(CP0_WIRED)); } -#include <linux/kernel.h> -#include <linux/mm.h> - -#include <asm/mipsconfig.h> -#include <asm/page.h> -#include <asm/pgtable.h> +void +dump_tlb_nonwired(void) +{ + dump_tlb(read_32bit_cp0_register(CP0_WIRED), mips_tlb_entries - 1); +} void dump_list_process(struct task_struct *t, void *address) @@ -86,15 +89,15 @@ dump_list_process(struct task_struct *t, void *address) unsigned int addr; addr = (unsigned int) address; - printk("Addr == %08x\n", addr); - printk("tasks->tss.pg_dir == %08x\n", - (unsigned int) t->tss.pg_dir); + printk("Addr == %08x\n", addr); + printk("tasks->tss.pg_dir == %08x\n", (unsigned int) t->tss.pg_dir); + printk("tasks->mm.pgd == %08x\n", (unsigned int) t->mm->pgd); - page_dir = pgd_offset(t, 0); + page_dir = pgd_offset(t->mm, 0); printk("page_dir == %08x\n", (unsigned int) page_dir); - pgd = pgd_offset(t, addr); + pgd = pgd_offset(t->mm, addr); printk("pgd == %08x, ", (unsigned int) pgd); pmd = pmd_offset(pgd, addr); @@ -105,7 +108,6 @@ dump_list_process(struct task_struct *t, void *address) page = *pte; printk("page == %08x\n", (unsigned int) pte_val(page)); - } void @@ -125,8 +127,6 @@ dump_list_current(void *address) printk("%08x\n", *pt); } -#include <asm/segment.h> - unsigned int vtop(void *address) { @@ -135,8 +135,8 @@ vtop(void *address) pte_t *pte; unsigned int addr, paddr; - addr = (unsigned int) address; - pgd = pgd_offset(current, addr); + addr = (unsigned long) address; + pgd = pgd_offset(current->mm, addr); pmd = pmd_offset(pgd, addr); pte = pte_offset(pmd, addr); paddr = (KSEG1 | (unsigned int) pte_val(*pte)) & PAGE_MASK; @@ -158,4 +158,3 @@ dump16(unsigned long *p) (unsigned long)p, (unsigned long)*p++); } } - diff --git a/arch/mips/lib/io.c b/arch/mips/lib/io.c new file mode 100644 index 000000000..c3c3f68d7 --- /dev/null +++ b/arch/mips/lib/io.c @@ -0,0 +1,24 @@ +/* + * include/asm-mips/string.h + * + * 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, 1995, 1996 by Ralf Baechle + * + * For now io.c contains only the definition of isa_slot_offset. The + * real io.S doesn't assemble due to a GAS bug. + */ + +/* + * port_base is the begin of the address space to which x86 style + * I/O ports are mapped. + */ +unsigned long port_base; + +/* + * isa_slot_offset is the address where E(ISA) busaddress 0 is is mapped + * for the processor. + */ +unsigned long isa_slot_offset; diff --git a/arch/mips/lib/memmove.c b/arch/mips/lib/memmove.c new file mode 100644 index 000000000..c3927ad49 --- /dev/null +++ b/arch/mips/lib/memmove.c @@ -0,0 +1,39 @@ +/* + * arch/mips/lib/memmove.c + * + * 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, 1995, 1996 by Ralf Baechle + * + * Less stupid implementation of memmove. + */ +#include <linux/string.h> + +void __memmove(void *dest, const void *src, size_t n) +{ + if (!n) + return; + + if (dest < src + || dest > src + n) + /* Copy forward */ + __memcpy(dest, src, n); + else + /* Copy backwards */ + __asm__ __volatile__( + ".set\tnoreorder\n\t" + ".set\tnoat\n" + "1:\tlbu\t$1,-1(%1)\n\t" + "subu\t%1,1\n\t" + "sb\t$1,-1(%0)\n\t" + "subu\t%2,1\n\t" + "bnez\t%2,1b\n\t" + "subu\t%0,1\n\t" + ".set\tat\n\t" + ".set\treorder" + : "=r" (dest), "=r" (src), "=r" (n) + : "0" (dest + n), "1" (src + n), "2" (n) + : "$1","memory" ); +} diff --git a/arch/mips/lib/pmaxcon.c b/arch/mips/lib/pmaxcon.c new file mode 100644 index 000000000..3b2cb1216 --- /dev/null +++ b/arch/mips/lib/pmaxcon.c @@ -0,0 +1,150 @@ +/* ---------------------------------------------------------------------- + * console.c + * + * Copyright (C) 1994 by Waldorf Electronic, + * written by Ralf Baechle and Andreas Busse + * Copyright (C) 1995 Paul M. Antoine (PMAX) + * + * 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. + * ---------------------------------------------------------------------- */ +/* + * FIXME: This file is hacked to be hardwired for the Personal DECStation + * Only thought of as a debugging console output + */ + +#include <linux/tty.h> +#include <asm/bootinfo.h> + +static unsigned int size_x; +static unsigned int size_y; +static unsigned short cursor_x; +static unsigned short cursor_y; +static volatile unsigned short *vram_addr; +static int console_needs_init = 1; + +extern struct bootinfo boot_info; +extern struct screen_info screen_info; + +/* + * Here is the base address of the prom calls + */ +unsigned long pmax_rex_base = 0; + +/* ---------------------------------------------------------------------- + * init_console() + * ---------------------------------------------------------------------- */ + +void init_console(void) +{ + size_x = 80; + size_y = 50; + cursor_x = 0; + cursor_y = 0; + + vram_addr = (unsigned short *)0xe10b8000; + + console_needs_init = 0; +} + +void +set_size_x(unsigned int x) +{ + size_x = x; +} + +void +set_size_y(unsigned int y) +{ + size_y = y; +} + +void +set_vram(unsigned short *vram) +{ + vram_addr = vram; +} + +/* + * FIXME: Temporary hack - changed its name to avoid conflict in + * drivers/char/vga.c that shouldn't be there <sigh> PMA + */ +void +set_pmax_cursor(unsigned int x, unsigned int y) +{ + cursor_x = x; + cursor_y = y; +} + +void +print_char(unsigned int x, unsigned int y, unsigned char c) +{ + volatile unsigned short *caddr; + +/* caddr = vram_addr + (y * size_x) + x; + *caddr = (*caddr & 0xff00) | 0x0f00 | (unsigned short) c; +*/ + pmax_putch(c); +} + +static void +scroll(void) +{ + volatile unsigned short *caddr; + register int i; +/* + caddr = vram_addr; + for(i=0; i<size_x * (size_y-1); i++) + *(caddr++) = *(caddr + size_x); + + blank last line + + caddr = vram_addr + (size_x * (size_y-1)); + for(i=0; i<size_x; i++) + *(caddr++) = (*caddr & 0xff00) | (unsigned short) ' '; +*/ + pmax_putch('\n'); +} + +void print_string(const unsigned char *str) +{ + unsigned char c; + + if (console_needs_init) + init_console(); +/* + while((c = *str++)) + switch(c) + { + case '\n': + cursor_x = 0; + cursor_y++; + if(cursor_y == size_y) + { + scroll(); + cursor_y = size_y - 1; + } + break; + + default: + print_char(cursor_x, cursor_y, c); + cursor_x++; + if(cursor_x == size_x) + { + cursor_x = 0; + cursor_y++; + if(cursor_y == size_y) + { + scroll(); + cursor_y = size_y - 1; + } + } + break; + } +*/ + pmax_printf(str); + +} + +/* end of file */ diff --git a/arch/mips/lib/pmaxio.S b/arch/mips/lib/pmaxio.S new file mode 100644 index 000000000..97ee46a23 --- /dev/null +++ b/arch/mips/lib/pmaxio.S @@ -0,0 +1,78 @@ +#include <asm/regdef.h> +#include <asm/dec/decstation.h> + + .text + .set reorder +/* + * pmax_printf - call the PROM printf() function + */ + .globl pmax_printf +pmax_printf: + lw v0,pmax_rex_base + lw v0,REX_PRINTF(v0) + j v0 + +/* + * pmax_getchar - call the PROM getchar() function + */ + .globl pmax_getch +pmax_getch: + lw v0,pmax_rex_base + lw v0,REX_GETCHAR(v0) + j v0 + +/* + * pmax_putchar - call the PROM putchar() function + */ + .globl pmax_putch +pmax_putch: + lw v0,pmax_rex_base + lw v0,REX_PUTCHAR(v0) + j v0 + +/* + * pmax_callfn - call the PROM function + */ + .globl pmax_callfn +pmax_callfn: + lw v0,pmax_rex_base + addu v0,v0,a0 + lw v0,(v0) + j v0 + +/* + * pmax_getbitmap - call the PROM for memory bitmap function + */ + .globl pmax_getbitmap +pmax_getbitmap: + lw v0,pmax_rex_base + lw v0,REX_GETBITMAP(v0) + j v0 + +/* + * pmax_getgetenv - call the PROM to get environment variable + */ + .globl pmax_getenv +pmax_getenv: + lw v0,pmax_rex_base + lw v0,REX_GETENV(v0) + j v0 + +/* + * pmax_getsysid - call the PROM to get system id + */ + .globl pmax_getsysid +pmax_getsysid: + lw v0,pmax_rex_base + lw v0,REX_GETSYSID(v0) + j v0 + +/* + * pmax_halt - call the PROM halt() function + */ + .globl pmax_halt +pmax_halt: + lw v0,pmax_rex_base + lw v0,REX_HALT(v0) + j v0 + diff --git a/arch/mips/lib/strlen_user.S b/arch/mips/lib/strlen_user.S new file mode 100644 index 000000000..3ef8ed18d --- /dev/null +++ b/arch/mips/lib/strlen_user.S @@ -0,0 +1,33 @@ +/* + * arch/mips/lib/strlen_user.S + * + * 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 by Ralf Baechle + */ +#include <asm/asm.h> +#include <asm/regdef.h> +#include <asm/sgidefs.h> + +/* + * Return the size of a string (including the ending 0) + * + * Return 0 for error + */ +LEAF(__strlen_user) + move v0,zero +1: lb t0,(a0) + LONG_ADDIU v0,1 + LONG_ADDIU a0,1 + bnez t0,1b + jr ra + END(strlen_user) + + .section __ex_table,"a" + PTR 1b,fault + .text + +fault: move v0,zero + jr ra diff --git a/arch/mips/lib/strncpy_user.S b/arch/mips/lib/strncpy_user.S new file mode 100644 index 000000000..4230ffe6d --- /dev/null +++ b/arch/mips/lib/strncpy_user.S @@ -0,0 +1,48 @@ +/* + * arch/mips/lib/strncpy_user.S + * + * 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 by Ralf Baechle + */ +#include <linux/errno.h> + +#include <asm/asm.h> +#include <asm/regdef.h> + +/* + * Returns: -EFAULT if exception before terminator, N if the entire + * buffer filled, else strlen. + */ + +/* + * Ugly special case have to check: we might get passed a user space + * pointer which wraps into the kernel space ... + */ + +LEAF(__strncpy_from_user) + move v0,zero + move v1,a1 + .set noreorder +1: lbu t0,(v1) + LONG_ADDIU v1,1 + beqz t0,2f + sb t0,(a0) # delay slot + LONG_ADDIU v0,1 + bne v0,a2,1b + LONG_ADDIU a0,1 # delay slot + .set reorder +2: LONG_ADDU t0,a1,v0 + xor t0,a1 + bltz t0,fault + jr ra # return n + END(__strncpy_from_user) + +fault: li v0,-EFAULT + jr ra + + .section __ex_table,"a" + PTR 1b,fault + .text diff --git a/arch/mips/lib/tinycon.c b/arch/mips/lib/tinycon.c index 4410986d8..4b75dec20 100644 --- a/arch/mips/lib/tinycon.c +++ b/arch/mips/lib/tinycon.c @@ -1,5 +1,5 @@ -/* ---------------------------------------------------------------------- - * console.c +/* + * arch/mips/lib/console.c * * Copyright (C) 1994 by Waldorf Electronic, * written by Ralf Baechle and Andreas Busse @@ -7,10 +7,11 @@ * 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. - * ---------------------------------------------------------------------- */ -/* + * * FIXME: This file is hacked to be hardwired for the Deskstation - * Only thought as a debugging console output + * Only thought as a debugging console output. It's as inefficient + * as a piece of code can be but probably a good piece of code to + * implement a preliminary console for a new target. */ #include <linux/tty.h> @@ -23,7 +24,6 @@ static unsigned short cursor_y; static volatile unsigned short *vram_addr; static int console_needs_init = 1; -extern struct bootinfo boot_info; extern struct screen_info screen_info; /* ---------------------------------------------------------------------- @@ -33,11 +33,13 @@ extern struct screen_info screen_info; void init_console(void) { size_x = 80; - size_y = 50; + // size_y = 50; + size_y = 25; cursor_x = 0; cursor_y = 0; - vram_addr = (unsigned short *)0xe10b8000; + // vram_addr = (unsigned short *)0xe10b8000; + vram_addr = (unsigned short *)0xb00b8000; console_needs_init = 0; } @@ -61,7 +63,7 @@ set_vram(unsigned short *vram) } void -set_cursor(unsigned int x, unsigned int y) +set_crsr(unsigned int x, unsigned int y) { cursor_x = x; cursor_y = y; @@ -129,5 +131,3 @@ void print_string(const unsigned char *str) break; } } - -/* end of file */ diff --git a/arch/mips/lib/watch.S b/arch/mips/lib/watch.S index 36b54d5c0..e460de6db 100644 --- a/arch/mips/lib/watch.S +++ b/arch/mips/lib/watch.S @@ -1,15 +1,16 @@ /* * Kernel debug stuff to use the Watch registers. - * Usefull to find stack overflows etc. + * Usefull to find stack overflows, dangeling pointers etc. * * 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) 1995 Ralf Baechle + * Copyright (C) 1995, 1996 by Ralf Baechle */ #include <asm/asm.h> #include <asm/mipsregs.h> +#include <asm/regdef.h> .set noreorder /* @@ -19,30 +20,48 @@ * bit #0 to trap on store references * Results : none */ - LEAF(watch_set) + LEAF(__watch_set) li t0,0x80000000 subu a0,t0 ori a0,7 xori a0,7 or a0,a1 mtc0 a0,CP0_WATCHLO + sw a0,watch_savelo jr ra mtc0 zero,CP0_WATCHHI - END(watch_set) + END(__watch_set) /* - * The stuff below are just some kernel debugging gadgets. It will - * go away. + * Parameter: none + * Results : none */ + LEAF(__watch_clear) + jr ra + mtc0 zero,CP0_WATCHLO + END(__watch_clear) /* * Parameter: none * Results : none */ - LEAF(watch_clear) + LEAF(__watch_reenable) + lw t0,watch_savelo jr ra - mtc0 zero,CP0_WATCHLO - END(watch_clear) + mtc0 t0,CP0_WATCHLO + END(__watch_reenable) + +/* + * Saved value of the c0_watchlo register for watch_reenable() + */ + .data +watch_savelo: .word 0 + .text + +/* + * The stuff below are just some kernel debugging gadgets. It is only here + * because it had to be somewhere and will go away. + */ /* * Parameter: none @@ -75,28 +94,28 @@ * Parameter: none * Results : none */ - NESTED(print_sp, 24, sp) - .mask 0x80000000,16 - subu sp,24 - sw ra,16(sp) - move a1,sp + NESTED(print_sp, ((5*SZREG)+ALSZ)&ALMASK, sp) + .mask 0x80000000,4*SZREG + PTR_SUBU sp,((5*SZREG)+ALSZ)&ALMASK + REG_S ra,4*SZREG(sp) + move a1,sp PRINT("$sp == %08lx\n") - lw ra,16(sp) - jr ra - addiu sp,24 + REG_L ra,4*SZREG(sp) + jr ra + PTR_ADDU sp,((5*SZREG)+ALSZ)&ALMASK END(print_sp) /* * Parameter: none * Results : none */ - NESTED(print_st, 24, sp) - .mask 0x80000000,16 - subu sp,24 - sw ra,16(sp) - mfc0 a1,CP0_STATUS + NESTED(print_st, ((5*SZREG)+ALSZ)&ALMASK, sp) + .mask 0x80000000,4*SZREG + PTR_SUBU sp,((5*SZREG)+ALSZ)&ALMASK + REG_S ra,4*SZREG(sp) + mfc0 a1,CP0_STATUS PRINT("cp0_status == %08lx\n") - lw ra,16(sp) - jr ra - addiu sp,24 + REG_L ra,4*SZREG(sp) + jr ra + PTR_ADDU sp,((5*SZREG)+ALSZ)&ALMASK END(print_st) |