OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [libgloss/] [mips/] [cygmon.c] - Blame information for rev 308

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/* cygmon.c -- Glue code for linking apps to run on top of Cygmon.
2
 *
3
 * Copyright (c) 1998, 1999, 2000 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 "syscall.h"
17
 
18
int
19
write ( int file,
20
        char *buf,
21
        int nbytes)
22
{
23
  return sysCall(SYS_write, file, (unsigned long)buf, nbytes);
24
}
25
 
26
int
27
read (int file,
28
      char *buf,
29
      int nbytes)
30
{
31
  return sysCall(SYS_read, file, (unsigned long)buf, nbytes);
32
}
33
 
34
int
35
outbyte (unsigned char c)
36
{
37
  return sysCall(SYS_write, 0, (unsigned long)&c, 1);
38
}
39
 
40
unsigned char
41
inbyte (void)
42
{
43
  char c;
44
  sysCall(SYS_read, 0, (unsigned long)&c, 1);
45
  return c;
46
}
47
 
48
 
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
52
{
53
  unsigned int size;
54
  unsigned int icsize;
55
  unsigned int dcsize;
56
};
57
 
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)
61
{
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;
72
}
73
 
74
// These need to be kept in sync with the definitions in Cygmon.
75
#define SYS_meminfo     1001
76
 
77
void *
78
get_mem_info (mem)
79
     struct s_mem *mem;
80
{
81
  unsigned long totmem = 0, topmem = 0;
82
  int numbanks;
83
 
84
  numbanks = sysCall(SYS_meminfo, (unsigned long)&totmem, (unsigned long)&topmem, 0);
85
  mem->size = totmem;
86
  return (void*)topmem;
87
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.