OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc1/] [libgloss/] [mips/] [cygmon.c] - Diff between revs 207 and 345

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 207 Rev 345
/* cygmon.c -- Glue code for linking apps to run on top of Cygmon.
/* cygmon.c -- Glue code for linking apps to run on top of Cygmon.
 *
 *
 * Copyright (c) 1998, 1999, 2000 Red Hat, Inc.
 * Copyright (c) 1998, 1999, 2000 Red Hat, Inc.
 *
 *
 * The authors hereby grant permission to use, copy, modify, distribute,
 * The authors hereby grant permission to use, copy, modify, distribute,
 * and license this software and its documentation for any purpose, provided
 * and license this software and its documentation for any purpose, provided
 * that existing copyright notices are retained in all copies and that this
 * that existing copyright notices are retained in all copies and that this
 * notice is included verbatim in any distributions. No written agreement,
 * notice is included verbatim in any distributions. No written agreement,
 * license, or royalty fee is required for any of the authorized uses.
 * license, or royalty fee is required for any of the authorized uses.
 * Modifications to this software may be copyrighted by their authors
 * Modifications to this software may be copyrighted by their authors
 * and need not follow the licensing terms described here, provided that
 * 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
 * the new terms are clearly indicated on the first page of each file where
 * they apply.
 * they apply.
 */
 */
 
 
#include "syscall.h"
#include "syscall.h"
 
 
int
int
write ( int file,
write ( int file,
        char *buf,
        char *buf,
        int nbytes)
        int nbytes)
{
{
  return sysCall(SYS_write, file, (unsigned long)buf, nbytes);
  return sysCall(SYS_write, file, (unsigned long)buf, nbytes);
}
}
 
 
int
int
read (int file,
read (int file,
      char *buf,
      char *buf,
      int nbytes)
      int nbytes)
{
{
  return sysCall(SYS_read, file, (unsigned long)buf, nbytes);
  return sysCall(SYS_read, file, (unsigned long)buf, nbytes);
}
}
 
 
int
int
outbyte (unsigned char c)
outbyte (unsigned char c)
{
{
  return sysCall(SYS_write, 0, (unsigned long)&c, 1);
  return sysCall(SYS_write, 0, (unsigned long)&c, 1);
}
}
 
 
unsigned char
unsigned char
inbyte (void)
inbyte (void)
{
{
  char c;
  char c;
  sysCall(SYS_read, 0, (unsigned long)&c, 1);
  sysCall(SYS_read, 0, (unsigned long)&c, 1);
  return c;
  return c;
}
}
 
 
 
 
/* Structure filled in by get_mem_info.  Only the size field is
/* Structure filled in by get_mem_info.  Only the size field is
   actually used (by sbrk), so the others aren't even filled in.  */
   actually used (by sbrk), so the others aren't even filled in.  */
struct s_mem
struct s_mem
{
{
  unsigned int size;
  unsigned int size;
  unsigned int icsize;
  unsigned int icsize;
  unsigned int dcsize;
  unsigned int dcsize;
};
};
 
 
// Perform a system call.
// Perform a system call.
// Unused parameters should be set to 0.
// Unused parameters should be set to 0.
int sysCall(unsigned long func, unsigned long p1, unsigned long p2, unsigned long p3)
int sysCall(unsigned long func, unsigned long p1, unsigned long p2, unsigned long p3)
{
{
  int ret = 0;
  int ret = 0;
  asm volatile ( "              \n\
  asm volatile ( "              \n\
          move $4, %1           \n\
          move $4, %1           \n\
          move $5, %2           \n\
          move $5, %2           \n\
          move $6, %3           \n\
          move $6, %3           \n\
          move $7, %4           \n\
          move $7, %4           \n\
          syscall               \n\
          syscall               \n\
          nop                   \n\
          nop                   \n\
          move %0, $2" : "=r"(ret) : "r"(func), "r"(p1), "r"(p2), "r"(p3));
          move %0, $2" : "=r"(ret) : "r"(func), "r"(p1), "r"(p2), "r"(p3));
  return ret;
  return ret;
}
}
 
 
// These need to be kept in sync with the definitions in Cygmon.
// These need to be kept in sync with the definitions in Cygmon.
#define SYS_meminfo     1001
#define SYS_meminfo     1001
 
 
void *
void *
get_mem_info (mem)
get_mem_info (mem)
     struct s_mem *mem;
     struct s_mem *mem;
{
{
  unsigned long totmem = 0, topmem = 0;
  unsigned long totmem = 0, topmem = 0;
  int numbanks;
  int numbanks;
 
 
  numbanks = sysCall(SYS_meminfo, (unsigned long)&totmem, (unsigned long)&topmem, 0);
  numbanks = sysCall(SYS_meminfo, (unsigned long)&totmem, (unsigned long)&topmem, 0);
  mem->size = totmem;
  mem->size = totmem;
  return (void*)topmem;
  return (void*)topmem;
}
}
 
 

powered by: WebSVN 2.1.0

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