diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2002-11-12 23:14:24 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2002-11-12 23:14:24 +0000 |
commit | 2d210c7fd118818417ab0f5205fd7b0b16cf6d0e (patch) | |
tree | 9ec3cb4aaeeee39e380b90236cd66e058a296937 /libgloss/mips/cygmon.c | |
parent | 944772c70a9e76c4f77c9b17593b433fd46558af (diff) | |
download | cygnal-2d210c7fd118818417ab0f5205fd7b0b16cf6d0e.tar.gz cygnal-2d210c7fd118818417ab0f5205fd7b0b16cf6d0e.tar.bz2 cygnal-2d210c7fd118818417ab0f5205fd7b0b16cf6d0e.zip |
2002-11-12 Jeff Johnston <jjohnstn@redhat.com>
* mips/Makefile.in: Add cygmon support.
* mips/configure.in: Ditto.
* mips/configure: Regenerated.
* mips/crt0_cygmon.S: New file.
* mips/cygmon.c: Ditto.
* mips/pmon.S: Minor formatting and copyright changes.
* mips/crt0.S: Ditto.
Diffstat (limited to 'libgloss/mips/cygmon.c')
-rw-r--r-- | libgloss/mips/cygmon.c | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/libgloss/mips/cygmon.c b/libgloss/mips/cygmon.c new file mode 100644 index 000000000..a5b004995 --- /dev/null +++ b/libgloss/mips/cygmon.c @@ -0,0 +1,87 @@ +/* cygmon.c -- Glue code for linking apps to run on top of Cygmon. + * + * Copyright (c) 1998, 1999, 2000 Red Hat, Inc. + * + * The authors hereby grant permission to use, copy, modify, distribute, + * and license this software and its documentation for any purpose, provided + * that existing copyright notices are retained in all copies and that this + * notice is included verbatim in any distributions. No written agreement, + * license, or royalty fee is required for any of the authorized uses. + * Modifications to this software may be copyrighted by their authors + * and need not follow the licensing terms described here, provided that + * the new terms are clearly indicated on the first page of each file where + * they apply. + */ + +#include "syscall.h" + +int +write ( int file, + char *buf, + int nbytes) +{ + return sysCall(SYS_write, file, (unsigned long)buf, nbytes); +} + +int +read (int file, + char *buf, + int nbytes) +{ + return sysCall(SYS_read, file, (unsigned long)buf, nbytes); +} + +int +outbyte (unsigned char c) +{ + return sysCall(SYS_write, 0, (unsigned long)&c, 1); +} + +unsigned char +inbyte (void) +{ + char c; + sysCall(SYS_read, 0, (unsigned long)&c, 1); + return c; +} + + +/* Structure filled in by get_mem_info. Only the size field is + actually used (by sbrk), so the others aren't even filled in. */ +struct s_mem +{ + unsigned int size; + unsigned int icsize; + unsigned int dcsize; +}; + +// Perform a system call. +// Unused parameters should be set to 0. +int sysCall(unsigned long func, unsigned long p1, unsigned long p2, unsigned long p3) +{ + int ret = 0; + asm volatile ( " + move $4, %1 + move $5, %2 + move $6, %3 + move $7, %4 + syscall + nop + move %0, $2" : "=r"(ret) : "r"(func), "r"(p1), "r"(p2), "r"(p3)); + return ret; +} + +// These need to be kept in sync with the definitions in Cygmon. +#define SYS_meminfo 1001 + +void * +get_mem_info (mem) + struct s_mem *mem; +{ + unsigned long totmem = 0, topmem = 0; + int numbanks; + + numbanks = sysCall(SYS_meminfo, (unsigned long)&totmem, (unsigned long)&topmem, 0); + mem->size = totmem; + return (void*)topmem; +} |