fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / libgloss / mn10300 / cygmon.c
blob513115cd6e29374cc04ba43a93bfdbc9dfc1cc48
1 /* cygmon.c -- Glue code for linking apps to run on top of Cygmon.
3 * Copyright (c) 1998, 1999, 2000, 2001 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 <errno.h>
18 // These need to be kept in sync with the definitions in Cygmon.
19 #define SYS_meminfo 1001
20 #include "syscall.h"
22 /* Structure filled in by get_mem_info. Only the size field is
23 actually used (by sbrk), so the others aren't even filled in. */
24 struct s_mem
26 unsigned int size;
27 unsigned int icsize;
28 unsigned int dcsize;
31 // Perform a system call.
32 // Unused parameters should be set to 0.
33 int __trap0(unsigned long func, unsigned long p1, unsigned long p2, unsigned long p3)
35 int ret = 0;
36 #ifdef __AM33__
38 register unsigned long d0 asm ("d0") = func;
39 register unsigned long d1 asm ("d1") = p1;
40 register unsigned long d2 asm ("d2") = p2;
41 register unsigned long d3 asm ("d3") = p3;
42 asm volatile (" syscall 0\n"
43 " nop"
44 : "+d" (d0) : "d" (d1), "d" (d2), "d" (d3) : "memory");
45 ret = d0;
47 #endif
49 if (func == SYS_exit)
51 while (1)
53 asm volatile (" .byte 0xff "); // trigger a breakpoint to drop back into Cygmon
57 if (ret != 0)
58 errno = ret;
60 return ret;
63 void *
64 get_mem_info (mem)
65 struct s_mem *mem;
67 unsigned long totmem = 0, topmem = 0;
68 register int numbanks;
70 numbanks = __trap0(SYS_meminfo, (unsigned long)&totmem, (unsigned long)&topmem, 0);
71 mem->size = totmem;
72 return (void*)topmem;