source: trunk/libs/newlib/src/libgloss/mn10300/cygmon.c @ 498

Last change on this file since 498 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.0 KB
Line 
1/* cygmon.c -- Glue code for linking apps to run on top of Cygmon.
2 *
3 * Copyright (c) 1998, 1999, 2000, 2001 Red Hat, Inc.
4 *
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.
14 */
15
16#include <errno.h>
17
18// These need to be kept in sync with the definitions in Cygmon.
19#define SYS_meminfo     1001
20#include "syscall.h"
21
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.  */
24struct s_mem
25{
26  unsigned int size;
27  unsigned int icsize;
28  unsigned int dcsize;
29};
30
31// Perform a system call.
32// Unused parameters should be set to 0.
33int __trap0(unsigned long func, unsigned long p1, unsigned long p2, unsigned long p3)
34{
35  int ret = 0;
36#ifdef __AM33__
37  {
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;
46  }
47#endif
48
49  if (func == SYS_exit)
50    {
51      while (1)
52        {
53          asm volatile (" .byte 0xff ");  // trigger a breakpoint to drop back into Cygmon
54        }
55    }
56
57  if (ret != 0)
58      errno = ret;
59
60  return ret;
61}
62
63void *
64get_mem_info (mem)
65     struct s_mem *mem;
66{
67  unsigned long totmem = 0, topmem = 0;
68  register int numbanks;
69
70  numbanks = __trap0(SYS_meminfo, (unsigned long)&totmem, (unsigned long)&topmem, 0);
71  mem->size = totmem;
72  return (void*)topmem;
73}
Note: See TracBrowser for help on using the repository browser.