20000317 sourceware import

This commit is contained in:
Ranjith Kumaran
2000-03-17 22:48:54 +00:00
parent fae4c299f1
commit 03261851a1
420 changed files with 66815 additions and 0 deletions

144
libgloss/m32r/Makefile.in Normal file
View File

@ -0,0 +1,144 @@
# Makefile for libgloss/m32r
# Copyright (c) 1996, 1998 Cygnus Support.
# All rights reserved.
#
# Redistribution and use in source and binary forms are permitted
# provided that the above copyright notice and this paragraph are
# duplicated in all such forms and that any documentation,
# advertising materials, and other materials related to such
# distribution and use acknowledge that the software was developed
# at Cygnus Support, Inc. Cygnus Support, Inc. may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
VPATH = @srcdir@
srcdir = @srcdir@
objdir = .
srcroot = $(srcdir)/../..
objroot = $(objdir)/../..
host_alias = @host_alias@
target_alias = @target_alias@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
libdir = @libdir@
tooldir = $(exec_prefix)/$(target_alias)
TOP = ../..
SRCTOP = ../..
# Multilib support variables.
# TOP is used instead of MULTI{BUILD,SRC}TOP.
MULTISRCTOP =
MULTIBUILDTOP =
MULTIDIRS =
MULTISUBDIR =
MULTIDO = true
MULTICLEAN = true
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
SHELL = /bin/sh
CC = @CC@
AS = @AS@
AR = @AR@
LD = @LD@
RANLIB = @RANLIB@
AR_FLAGS = qv
BISON = bison
MAKEINFO = makeinfo
.NOEXPORT:
MAKEOVERRIDES=
TARGETDOC = ../../targetdep.tex
CRT0 = crt0.o
GDBLIB = m32r-lib.o
GDBSTUB = m32r-stub.o
EVASCRIPT = eva.ld
STUBSCRIPT = eva-stub.ld
GENERIC_LIBOBJS = \
chmod.o close.o exit.o fstat.o getpid.o isatty.o kill.o lseek.o \
open.o raise.o read.o sbrk.o stat.o unlink.o utime.o write.o
LIBOBJS = trap0.o $(GENERIC_LIBOBJS)
LIBGLOSS = libgloss.a
MONLIBOBJS = trapmon0.o $(GENERIC_LIBOBJS)
MONLIBGLOSS = libmon.a
MONSPECS = mon.specs
# Host specific makefile fragment comes in here.
@host_makefile_frag@
all: $(CRT0) $(LIBGLOSS) $(MONLIBGLOSS) $(GDBLIB) $(GDBSTUB)
m32r-stub.o: $(srcdir)/$(MULTISRCTOP)../../gdb/m32r-stub.c
$(CC) -c $(CFLAGS) -o $@ $(srcdir)/$(MULTISRCTOP)../../gdb/m32r-stub.c
libgloss.a: $(LIBOBJS)
$(AR) $(ARFLAGS) $@ $(LIBOBJS)
$(RANLIB) $@
libmon.a: $(MONLIBOBJS)
$(AR) $(ARFLAGS) $@ $(MONLIBOBJS)
$(RANLIB) $@
install:
$(INSTALL_DATA) $(CRT0) $(tooldir)/lib${MULTISUBDIR}/$(CRT0)
$(INSTALL_DATA) $(LIBGLOSS) $(tooldir)/lib${MULTISUBDIR}/$(LIBGLOSS)
$(INSTALL_DATA) $(MONLIBGLOSS) $(tooldir)/lib${MULTISUBDIR}/$(MONLIBGLOSS)
$(INSTALL_DATA) $(GDBLIB) $(tooldir)/lib${MULTISUBDIR}/$(GDBLIB)
$(INSTALL_DATA) $(GDBSTUB) $(tooldir)/lib${MULTISUBDIR}/$(GDBSTUB)
$(INSTALL_DATA) $(srcdir)/$(EVASCRIPT) $(tooldir)/lib/$(EVASCRIPT)
$(INSTALL_DATA) $(srcdir)/$(STUBSCRIPT) $(tooldir)/lib/$(STUBSCRIPT)
$(INSTALL_DATA) $(srcdir)/$(MONSPECS) $(tooldir)/lib/$(MONSPECS)
clean mostlyclean:
rm -f *~ *.[oa]
distclean maintainer-clean realclean: clean
rm -f Makefile config.status
info doc:
install-info:
clean-info:
Makefile: Makefile.in config.status @host_makefile_frag_path@
$(SHELL) config.status
config.status: configure
$(SHELL) config.status --recheck
# to support SunOS VPATH
crt0.o: crt0.S
m32r-lib.o: m32r-lib.c
chmod.o: chmod.c
close.o: close.c
exit.o: exit.c
fstat.o: fstat.c
getpid.o: getpid.c
isatty.o: isatty.c
kill.o: kill.c
lseek.o: lseek.c
open.o: open.c
raise.o: raise.c
read.o: read.c
sbrk.o: sbrk.c
stat.o: stat.c
unlink.o: unlink.c
utime.o: utime.c
write.o: write.c
trap0.o: trap0.S
trapmon0.o: trapmon0.c

10
libgloss/m32r/chmod.c Normal file
View File

@ -0,0 +1,10 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "syscall.h"
#include "eit.h"
int
_chmod (const char *path, short mode)
{
return TRAP0 (SYS_chmod, path, mode, 0);
}

10
libgloss/m32r/close.c Normal file
View File

@ -0,0 +1,10 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "syscall.h"
#include "eit.h"
int
_close (int file)
{
return TRAP0 (SYS_close, file, 0, 0);
}

1110
libgloss/m32r/configure vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,51 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.5)dnl
AC_INIT(crt0.S)
if test "${enable_shared}" = "yes" ; then
echo "Shared libraries not supported for cross compiling, ignored"
fi
if test "$srcdir" = "." ; then
if test "${with_target_subdir}" != "." ; then
libgloss_topdir="${srcdir}/${with_multisrctop}../../.."
else
libgloss_topdir="${srcdir}/${with_multisrctop}../.."
fi
else
libgloss_topdir="${srcdir}/../.."
fi
AC_CONFIG_AUX_DIR($libgloss_topdir)
AC_CANONICAL_SYSTEM
AC_ARG_PROGRAM
AC_PROG_INSTALL
AC_PROG_CC
AS=${AS-as}
AC_SUBST(AS)
AR=${AR-ar}
AC_SUBST(AR)
LD=${LD-ld}
AC_SUBST(LD)
AC_PROG_RANLIB
host_makefile_frag=${srcdir}/../config/default.mh
dnl We have to assign the same value to other variables because autoconf
dnl doesn't provide a mechanism to substitute a replacement keyword with
dnl arbitrary data or pathnames.
dnl
host_makefile_frag_path=$host_makefile_frag
AC_SUBST(host_makefile_frag_path)
AC_SUBST_FILE(host_makefile_frag)
AC_OUTPUT(Makefile,
. ${libgloss_topdir}/config-ml.in,
srcdir=${srcdir}
target=${target}
ac_configure_args="${ac_configure_args} --enable-multilib"
CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
libgloss_topdir=${libgloss_topdir}
)

51
libgloss/m32r/crt0.S Normal file
View File

@ -0,0 +1,51 @@
.text
.balign 4
.global _start
_start:
ld24 sp, _stack
ldi fp, #0
# Clear the BSS. Do it in two parts for efficiency: longwords first
# for most of it, then the remaining 0 to 3 bytes.
seth r2, #shigh(__bss_start)
add3 r2, r2, #low(__bss_start); R2 = start of BSS
seth r3, #shigh(_end)
add3 r3, r3, #low(_end) ; R3 = end of BSS + 1
sub r3, r2 ; R3 = BSS size in bytes
mv r4, r3
srli r4, #2 ; R4 = BSS size in longwords (rounded down)
ldi r1, #0 ; clear R1 for longword store
addi r2, #-4 ; account for pre-inc store
beqz r4, .Lendloop1 ; any more to go?
.Lloop1:
st r1, @+r2 ; yep, zero out another longword
addi r4, #-1 ; decrement count
bnez r4, .Lloop1 ; go do some more
.Lendloop1:
and3 r4, r3, #3 ; get no. of remaining BSS bytes to clear
addi r2, #4 ; account for pre-inc store
beqz r4, .Lendloop2 ; any more to go?
.Lloop2:
stb r1, @r2 ; yep, zero out another byte
addi r2, #1 ; bump address
addi r4, #-1 ; decrement count
bnez r4, .Lloop2 ; go do some more
.Lendloop2:
# Run code in the .init section.
# This will queue the .fini section to be run with atexit.
bl __init
# Call main, then exit.
bl main
bl exit
# If that fails just loop.
.Lexit:
bra .Lexit

13
libgloss/m32r/eit.h Normal file
View File

@ -0,0 +1,13 @@
/* M32R libgloss EIT interface.
Copyright (C) 1998, Cygnus Solutions.
At present we only document trap 0, the syscall interface.
In the future this can hold further EIT related stuff.
[The m32r manuals use the acronym EIT: exception, interrupt, trap.] */
#include <reent.h>
int __trap0 (int function, int p1, int p2, int p3, struct _reent *r);
#define TRAP0(f, p1, p2, p3) \
__trap0 (f, (int) (p1), (int) (p2), (int) (p3), _REENT)

111
libgloss/m32r/eva-stub.ld Normal file
View File

@ -0,0 +1,111 @@
OUTPUT_FORMAT("elf32-m32r", "elf32-m32r",
"elf32-m32r")
OUTPUT_ARCH(m32r)
ENTRY(_start)
/* Do we need any of these for elf?
__DYNAMIC = 0; */
INPUT(m32r-stub.o)
INPUT(m32r-lib.o)
INPUT(-lgloss)
SECTIONS
{
/* Read-only sections, merged into text segment: */
. = 0x200000;
.interp : { *(.interp) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.rel.text : { *(.rel.text) }
.rela.text : { *(.rela.text) }
.rel.data : { *(.rel.data) }
.rela.data : { *(.rela.data) }
.rel.rodata : { *(.rel.rodata) }
.rela.rodata : { *(.rela.rodata) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.bss : { *(.rel.bss) }
.rela.bss : { *(.rela.bss) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.init : { *(.init) } = 0
.plt : { *(.plt) }
.text :
{
*(.text)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
} = 0
_etext = .;
PROVIDE (etext = .);
.fini : { *(.fini) } = 0
.rodata : { *(.rodata) *(.gnu.linkonce.r*) }
.rodata1 : { *(.rodata1) }
/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */
. = ALIGN(32) + (ALIGN(8) & (32 - 1));
.data :
{
*(.data)
*(.gnu.linkonce.d*)
CONSTRUCTORS
}
.data1 : { *(.data1) }
.ctors :
{
*(.ctors)
}
.dtors :
{
*(.dtors)
}
.got : { *(.got.plt) *(.got) }
.dynamic : { *(.dynamic) }
/* We want the small data sections together, so single-instruction offsets
can access them all, and initialized data all before uninitialized, so
we can shorten the on-disk segment size. */
.sdata : { *(.sdata) }
_edata = .;
PROVIDE (edata = .);
__bss_start = .;
.sbss : { *(.sbss) *(.scommon) }
.bss :
{
*(.dynbss)
*(.bss)
*(COMMON)
}
_end = . ;
PROVIDE (end = .);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the .debug DWARF section are relative to the beginning of the
section so we begin .debug at 0. It's not clear yet what needs to happen
for the others. */
.debug 0 : { *(.debug) }
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_sfnames 0 : { *(.debug_sfnames) }
.line 0 : { *(.line) }
.stack 0x207ffc : { _stack = .; *(.stack) }
/* These must appear regardless of . */
}

97
libgloss/m32r/eva.ld Normal file
View File

@ -0,0 +1,97 @@
OUTPUT_FORMAT("elf32-m32r", "elf32-m32r",
"elf32-m32r")
OUTPUT_ARCH(m32r)
ENTRY(_start)
/* Do we need any of these for elf?
__DYNAMIC = 0; */
INPUT(-lgloss)
SECTIONS
{
/* Read-only sections, merged into text segment: */
. = 0x208000;
.interp : { *(.interp) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.rel.text : { *(.rel.text) }
.rela.text : { *(.rela.text) }
.rel.data : { *(.rel.data) }
.rela.data : { *(.rela.data) }
.rel.rodata : { *(.rel.rodata) }
.rela.rodata : { *(.rela.rodata) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.bss : { *(.rel.bss) }
.rela.bss : { *(.rela.bss) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.init : { *(.init) } =0
.plt : { *(.plt) }
.text :
{
*(.text)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
} =0
_etext = .;
PROVIDE (etext = .);
.fini : { *(.fini) } =0
.rodata : { *(.rodata) *(.gnu.linkonce.r*) }
.rodata1 : { *(.rodata1) }
/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */
. = ALIGN(32) + (ALIGN(8) & (32 - 1));
.data :
{
*(.data)
*(.gnu.linkonce.d*)
CONSTRUCTORS
}
.data1 : { *(.data1) }
.ctors : { *(.ctors) }
.dtors : { *(.dtors) }
.got : { *(.got.plt) *(.got)}
.dynamic : { *(.dynamic) }
/* We want the small data sections together, so single-instruction offsets
can access them all, and initialized data all before uninitialized, so
we can shorten the on-disk segment size. */
.sdata : { *(.sdata) }
_edata = .;
PROVIDE (edata = .);
__bss_start = .;
.sbss : { *(.sbss) *(.scommon) }
.bss : { *(.dynbss) *(.bss) *(COMMON) }
_end = . ;
PROVIDE (end = .);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the .debug DWARF section are relative to the beginning of the
section so we begin .debug at 0. It's not clear yet what needs to happen
for the others. */
.debug 0 : { *(.debug) }
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_sfnames 0 : { *(.debug_sfnames) }
.line 0 : { *(.line) }
.stack 0x5ffffc : { _stack = .; *(.stack) }
/* These must appear regardless of . */
}

10
libgloss/m32r/exit.c Normal file
View File

@ -0,0 +1,10 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "syscall.h"
#include "eit.h"
void
_exit (n)
{
TRAP0 (SYS_exit, n, 0, 0);
}

11
libgloss/m32r/fstat.c Normal file
View File

@ -0,0 +1,11 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "syscall.h"
#include "eit.h"
int
_fstat (int file, struct stat *st)
{
st->st_mode = S_IFCHR;
return 0;
}

6
libgloss/m32r/getpid.c Normal file
View File

@ -0,0 +1,6 @@
int
_getpid (int n)
{
return 1;
}

8
libgloss/m32r/isatty.c Normal file
View File

@ -0,0 +1,8 @@
/* FIXME: can we not nuke the 10,000 copies of this function
and fudge things (which is all this function does) in _fstat? */
int
isatty (int fd)
{
return 1;
}

9
libgloss/m32r/kill.c Normal file
View File

@ -0,0 +1,9 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "syscall.h"
#include "eit.h"
_kill (n, m)
{
return TRAP0 (SYS_exit, 0xdead, 0, 0);
}

10
libgloss/m32r/lseek.c Normal file
View File

@ -0,0 +1,10 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "syscall.h"
#include "eit.h"
int
_lseek (int file, int ptr, int dir)
{
return TRAP0 (SYS_lseek, file, ptr, dir);
}

142
libgloss/m32r/m32r-lib.c Normal file
View File

@ -0,0 +1,142 @@
/* Stand-alone library for M32R-EVA board.
*
* Copyright (c) 1996, 1998 Cygnus Support
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* 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
* they apply.
*/
/* #define REVC to enable handling of the original RevC board,
which is no longer the default, nor is it supported. */
#ifndef REVC
/* Serial I/O routines for MSA2000G01 board */
#define UART_INCHAR_ADDR 0xff004009
#define UART_OUTCHR_ADDR 0xff004007
#define UART_STATUS_ADDR 0xff004002
#else
/* Serial I/O routines for M32R-EVA board */
#define UART_INCHAR_ADDR 0xff102013
#define UART_OUTCHR_ADDR 0xff10200f
#define UART_STATUS_ADDR 0xff102006
#endif
#define UART_INPUT_EMPTY 0x4
#define UART_OUTPUT_EMPTY 0x1
static volatile char *rx_port = (unsigned char *) UART_INCHAR_ADDR;
static volatile char *tx_port = (char *) UART_OUTCHR_ADDR;
static volatile short *rx_status = (short *) UART_STATUS_ADDR;
static volatile short *tx_status = (short *) UART_STATUS_ADDR;
static int
rx_rdy()
{
#ifndef REVC
return (*rx_status & UART_INPUT_EMPTY);
#else
return !(*rx_status & UART_INPUT_EMPTY);
#endif
}
static int
tx_rdy()
{
return (*tx_status & UART_OUTPUT_EMPTY);
}
static unsigned char
rx_uchar()
{
return *rx_port;
}
void
tx_char(char c)
{
*tx_port = c;
}
int
getDebugChar()
{
while (!rx_rdy())
;
return rx_uchar();
}
void
putDebugChar(int c)
{
while (!tx_rdy())
;
tx_char(c);
}
void mesg(char *p)
{
while (*p)
{
if (*p == '\n')
putDebugChar('\r');
putDebugChar(*p++);
}
}
void phex(long x)
{
char buf[9];
int i;
buf[8] = '\0';
for (i = 7; i >= 0; i--)
{
char c = x & 0x0f;
buf[i] = c < 10 ? c + '0' : c - 10 + 'A';
x >>= 4;
}
mesg(buf);
}
/* Setup trap TT to go to ROUTINE. */
void
exceptionHandler (int tt, unsigned long routine)
{
#ifndef REVC
unsigned long *tb = (unsigned long *) 0x40; /* Trap vector base address */
tb[tt] = ((routine >> 2) | 0xff000000) - tt - (0x40 >> 2);
#else
unsigned long *tb = 0; /* Trap vector base address */
tb[tt] = ((routine >> 2) | 0xff000000) - tt;
#endif
}
/* Return the address of trap TT handler */
unsigned long
getExceptionHandler (int tt)
{
#ifndef REVC
unsigned long *tb = (unsigned long *) 0x40; /* Trap vector base address */
return ((tb[tt] + tt + (0x40 >> 2)) | 0xff000000) << 2;
#else
unsigned long *tb = 0; /* Trap vector base address */
return ((tb[tt] + tt) | 0xff000000) << 2;
#endif
}

3
libgloss/m32r/mon.specs Normal file
View File

@ -0,0 +1,3 @@
*endfile_cpu:
-lmon %{m32rx:m32rx/crtfini.o%s} %{!m32rx:crtfini.o%s}

10
libgloss/m32r/open.c Normal file
View File

@ -0,0 +1,10 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "syscall.h"
#include "eit.h"
int
_open (const char *path, int flags)
{
return TRAP0 (SYS_open, path, flags, 0);
}

5
libgloss/m32r/raise.c Normal file
View File

@ -0,0 +1,5 @@
/* ??? Needed? */
_raise ()
{
}

10
libgloss/m32r/read.c Normal file
View File

@ -0,0 +1,10 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "syscall.h"
#include "eit.h"
int
_read (int file, char *ptr, int len)
{
return TRAP0 (SYS_read, file, ptr, len);
}

34
libgloss/m32r/sbrk.c Normal file
View File

@ -0,0 +1,34 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "syscall.h"
#include "eit.h"
caddr_t
_sbrk (int incr)
{
/* `_end' is defined in the linker script.
We must handle it carefully as we don't want the compiler to think
it lives in the small data area. Use medium model to ensure 32 bit
addressability. */
extern char _end __attribute__ ((__model__(__medium__)));
static char *heap_end;
char *prev_heap_end;
char *sp = (char *)&sp;
if (heap_end == 0)
{
heap_end = &_end;
}
prev_heap_end = heap_end;
if (heap_end > sp)
{
_write (1, "Heap and stack collision\n", 25);
#if 0 /* Calling abort brings in the signal handling code. */
abort ();
#else
exit (1);
#endif
}
heap_end += incr;
return (caddr_t) prev_heap_end;
}

11
libgloss/m32r/stat.c Normal file
View File

@ -0,0 +1,11 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "syscall.h"
#include "eit.h"
int
_stat (const char *path, struct stat *st)
{
return TRAP0 (SYS_stat, path, st, 0);
}

16
libgloss/m32r/trap0.S Normal file
View File

@ -0,0 +1,16 @@
; Trap 0 handler (syscall interface).
;
; The trap handler returns the result in r0 and the error code (errno value)
; in r2. r1 is reserved in case an 8 byte quantity ever needs to be
; returned in registers.
.text
.global __trap0
__trap0:
trap #0 ; trap 0 returns result in r0, error code in r2
cmpui r2,#1 ; is error code zero?
bc .Lret ; yes, skip setting errno
ld r4,@(sp) ; no, set errno
st r2,@r4
.Lret:
jmp lr ; return to caller

53
libgloss/m32r/trapmon0.c Normal file
View File

@ -0,0 +1,53 @@
/*
* Mon2000 Trap handler (syscall interface).
*
* This trap handler is linked into the mon2000 libgloss (libmon).
*/
#include <reent.h>
#include "syscall.h"
int __trap0 (int function, int p1, int p2, int p3, struct _reent *r)
{
int rc = 0;
switch (function) {
case SYS_exit:
/* loop so GDB can't go past system exit call */
while (1) {
asm volatile ("
ldi r0, #0
trap #15 ; return control to Mon2000");
}
break;
case SYS_write:
{
int i;
for( i=0; i<p3; i++ ) {
asm volatile ("
ldi r0, #2
ldi r1, #15 ; load Ctrl-O (ASCII 15)
trap #15 ; write Ctrl-O for quoting purposes" );
asm volatile ("
ldi r0, #2
ldb r1, %0
trap #15 ; write character to console"
: /* no outputs */
: "m" (((char*)p2)[i]));
}
rc = p3; /* return number of chars written */
break;
}
default:
rc = 0;
break;
}
return rc;
}

10
libgloss/m32r/unlink.c Normal file
View File

@ -0,0 +1,10 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "syscall.h"
#include "eit.h"
int
_unlink ()
{
return -1;
}

12
libgloss/m32r/utime.c Normal file
View File

@ -0,0 +1,12 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "syscall.h"
#include "eit.h"
int
_utime (path, times)
const char *path;
char *times;
{
return TRAP0 (SYS_utime, path, times, 0);
}

10
libgloss/m32r/write.c Normal file
View File

@ -0,0 +1,10 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "syscall.h"
#include "eit.h"
int
_write (int file, char *ptr, int len)
{
return TRAP0 (SYS_write, file, ptr, len);
}