fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / libgloss / mips / cygmon.c
blob506e853b65b13ba2f1ee5bc10ddeaaa090585ac1
1 /* cygmon.c -- Glue code for linking apps to run on top of Cygmon.
3 * Copyright (c) 1998, 1999, 2000 Red Hat, Inc.
5 * The authors hereby grant permission to use, copy, modify, distribute,
6 * and license this software and its documentation for any purpose, provided
7 * that existing copyright notices are retained in all copies and that this
8 * notice is included verbatim in any distributions. No written agreement,
9 * license, or royalty fee is required for any of the authorized uses.
10 * Modifications to this software may be copyrighted by their authors
11 * and need not follow the licensing terms described here, provided that
12 * the new terms are clearly indicated on the first page of each file where
13 * they apply.
16 #include "syscall.h"
18 int
19 write ( int file,
20 char *buf,
21 int nbytes)
23 return sysCall(SYS_write, file, (unsigned long)buf, nbytes);
26 int
27 read (int file,
28 char *buf,
29 int nbytes)
31 return sysCall(SYS_read, file, (unsigned long)buf, nbytes);
34 int
35 outbyte (unsigned char c)
37 return sysCall(SYS_write, 0, (unsigned long)&c, 1);
40 unsigned char
41 inbyte (void)
43 char c;
44 sysCall(SYS_read, 0, (unsigned long)&c, 1);
45 return c;
49 /* Structure filled in by get_mem_info. Only the size field is
50 actually used (by sbrk), so the others aren't even filled in. */
51 struct s_mem
53 unsigned int size;
54 unsigned int icsize;
55 unsigned int dcsize;
58 // Perform a system call.
59 // Unused parameters should be set to 0.
60 int sysCall(unsigned long func, unsigned long p1, unsigned long p2, unsigned long p3)
62 int ret = 0;
63 asm volatile ( " \n\
64 move $4, %1 \n\
65 move $5, %2 \n\
66 move $6, %3 \n\
67 move $7, %4 \n\
68 syscall \n\
69 nop \n\
70 move %0, $2" : "=r"(ret) : "r"(func), "r"(p1), "r"(p2), "r"(p3));
71 return ret;
74 // These need to be kept in sync with the definitions in Cygmon.
75 #define SYS_meminfo 1001
77 void *
78 get_mem_info (mem)
79 struct s_mem *mem;
81 unsigned long totmem = 0, topmem = 0;
82 int numbanks;
84 numbanks = sysCall(SYS_meminfo, (unsigned long)&totmem, (unsigned long)&topmem, 0);
85 mem->size = totmem;
86 return (void*)topmem;