2001-02-28 Will Cohen <wcohen@redhat.com>
* src/libgloss/m68k/Makefile.in: Updated copyright and added rules to build simulator related libraries. (SIM_SCRIPTS): New variable. (SIM_LDFLAGS): New variable. (SIM_BSP): New variable. (SIM_CRT0): New variable. (SIM_OBJS): New variable. (SIM_TEST): New variable. (SIM_INSTALL): new variable. * src/libgloss/m68k/sim-abort.c: New file. * src/libgloss/m68k/sim-crt0.S: New file. * src/libgloss/m68k/sim-errno.c: New file. * src/libgloss/m68k/sim-funcs.c: New file. * src/libgloss/m68k/sim-inbyte.c: New file. * src/libgloss/m68k/sim-print.c: New file. * src/libgloss/m68k/sim-sbrk.c: New file. * src/libgloss/m68k/sim.ld: New file. * src/libgloss/m68k/simulator.S: New file.
This commit is contained in:
parent
2de7601434
commit
09ccfcee50
@ -1,3 +1,24 @@
|
||||
2001-02-28 Will Cohen <wcohen@redhat.com>
|
||||
|
||||
* src/libgloss/m68k/Makefile.in: Updated copyright and
|
||||
added rules to build simulator related libraries.
|
||||
(SIM_SCRIPTS): New variable.
|
||||
(SIM_LDFLAGS): New variable.
|
||||
(SIM_BSP): New variable.
|
||||
(SIM_CRT0): New variable.
|
||||
(SIM_OBJS): New variable.
|
||||
(SIM_TEST): New variable.
|
||||
(SIM_INSTALL): new variable.
|
||||
* src/libgloss/m68k/sim-abort.c: New file.
|
||||
* src/libgloss/m68k/sim-crt0.S: New file.
|
||||
* src/libgloss/m68k/sim-errno.c: New file.
|
||||
* src/libgloss/m68k/sim-funcs.c: New file.
|
||||
* src/libgloss/m68k/sim-inbyte.c: New file.
|
||||
* src/libgloss/m68k/sim-print.c: New file.
|
||||
* src/libgloss/m68k/sim-sbrk.c: New file.
|
||||
* src/libgloss/m68k/sim.ld: New file.
|
||||
* src/libgloss/m68k/simulator.S: New file.
|
||||
|
||||
2001-02-22 Jeff Johnston <jjohnstn@redhat.com>
|
||||
|
||||
* mn10200/access.c: With DJ Delorie's permission, this code is
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 1995, 1996 Cygnus Support
|
||||
# Copyright (c) 1995, 1996, 2001 Cygnus Support
|
||||
#
|
||||
# The authors hereby grant permission to use, copy, modify, distribute,
|
||||
# and license this software and its documentation for any purpose, provided
|
||||
@ -68,6 +68,17 @@ OBJS = close.o fstat.o getpid.o isatty.o kill.o \
|
||||
CFLAGS = -g
|
||||
# ARFLAGS = rv
|
||||
|
||||
|
||||
# Here is all of the simulator stuff
|
||||
SIM_SCRIPTS = sim.ld
|
||||
SIM_LDFLAGS = -Tsim.ld
|
||||
SIM_BSP = libsim.a
|
||||
SIM_CRT0 = sim-crt0.o
|
||||
SIM_OBJS = sim-print.o sim-inbyte.o sim-sbrk.o sim-abort.o sim-errno.o simulator.o sim-funcs.o unlink.o
|
||||
SIM_TEST =
|
||||
SIM_INSTALL = install-sim
|
||||
|
||||
|
||||
CRT0 = crt0.o
|
||||
#
|
||||
# here's all the MVME135 target stuff
|
||||
@ -111,11 +122,15 @@ DBUG_OBJS= dbug-exit.o dbug-inbyte.o dbug-outbyte.o
|
||||
# build a test program for each target board. Just trying to get
|
||||
# it to link is a good test, so we ignore all the errors for now.
|
||||
#
|
||||
all: ${CRT0} ${BCC_BSP} ${IDP_BSP} ${MVME135_BSP} ${MVME162_BSP} ${DBUG_BSP}
|
||||
all: ${SIM_CRT0} ${SIM_BSP} ${CRT0} ${BCC_BSP} ${IDP_BSP} ${MVME135_BSP} ${MVME162_BSP} ${DBUG_BSP}
|
||||
|
||||
#
|
||||
# here's where we build the board support packages for each target
|
||||
#
|
||||
${SIM_BSP}: ${SIM_OBJS}
|
||||
${AR} ${ARFLAGS} $@ ${SIM_OBJS}
|
||||
${RANLIB} $@
|
||||
|
||||
${BCC_BSP}: $(OBJS) ${BCC_OBJS}
|
||||
${AR} ${ARFLAGS} $@ $(OBJS) ${BCC_OBJS}
|
||||
${RANLIB} $@
|
||||
@ -214,9 +229,15 @@ dtor.x: dtor.o ${CRT0} ${srcdir}/mvme135.ld Makefile ${MVME135_BSP}
|
||||
${CC} -L${srcdir} -L${objdir} dtor.o -o $@ $(LIBS_FOR_TARGET) \
|
||||
-N -Wl,-Tmvme135.ld -nostdlib
|
||||
|
||||
unlink.o: $(srcdir)/../unlink.c
|
||||
|
||||
.PHONY: install info dvi doc install-info clean-info
|
||||
install:
|
||||
# install SIM stuff
|
||||
$(INSTALL_PROGRAM) $(SIM_CRT0) $(tooldir)/lib${MULTISUBDIR}/$(SIM_CRT0)
|
||||
$(INSTALL_PROGRAM) $(SIM_BSP) $(tooldir)/lib${MULTISUBDIR}/$(SIM_BSP)
|
||||
$(INSTALL_DATA) ${srcdir}/sim.ld $(tooldir)/lib${MULTISUBDIR}/sim.ld
|
||||
#
|
||||
$(INSTALL_PROGRAM) $(CRT0) $(tooldir)/lib${MULTISUBDIR}/$(CRT0)
|
||||
# install BCC stuff
|
||||
$(INSTALL_PROGRAM) $(BCC_BSP) $(tooldir)/lib${MULTISUBDIR}/$(BCC_BSP)
|
||||
|
21
libgloss/m68k/sim-abort.c
Normal file
21
libgloss/m68k/sim-abort.c
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* sim-abort.c -- m68k abort support when running under the simulator.
|
||||
*
|
||||
* Copyright (c) 1995, 2001 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.
|
||||
*/
|
||||
|
||||
void abort(void)
|
||||
{
|
||||
write (2, "Abort called.\n", sizeof("Abort called.\n")-1);
|
||||
exit (1);
|
||||
}
|
121
libgloss/m68k/sim-crt0.S
Normal file
121
libgloss/m68k/sim-crt0.S
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* crt0.S -- startup file for m68k-coff
|
||||
*
|
||||
* Copyright (c) 1995, 1996, 1998, 2001 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.
|
||||
*/
|
||||
|
||||
#include "asm.h"
|
||||
|
||||
.title "crt0.S for m68k-coff"
|
||||
#define STACKSIZE 0x4000
|
||||
|
||||
/*
|
||||
* Define an empty environment.
|
||||
*/
|
||||
.data
|
||||
.align 2
|
||||
SYM (environ):
|
||||
.long 0
|
||||
|
||||
.align 2
|
||||
.text
|
||||
|
||||
/*
|
||||
* These symbols are defined in C code, so they need to always be
|
||||
* named with SYM because of the difference between object file formats.
|
||||
*/
|
||||
|
||||
/* These are defined in C code. */
|
||||
.extern SYM (main)
|
||||
.extern SYM (exit)
|
||||
.extern SYM (atexit)
|
||||
.extern SYM(__do_global_dtors)
|
||||
|
||||
/*
|
||||
* These values are set in the linker script, so they must be
|
||||
* explicitly named here without SYM.
|
||||
*/
|
||||
.extern __stack
|
||||
.extern __bss_start
|
||||
.extern _end
|
||||
|
||||
/*
|
||||
* set things up so the application will run. This *must* be called start.
|
||||
*/
|
||||
.global SYM (start)
|
||||
|
||||
SYM (start):
|
||||
/* See if user supplied their own stack (__stack != 0). If not, then
|
||||
* default to using the value of %sp as set by the ROM monitor.
|
||||
*/
|
||||
movel IMM(__stack), a0
|
||||
cmpl IMM(0), a0
|
||||
jbeq 1f
|
||||
movel a0, sp
|
||||
1:
|
||||
/* set up initial stack frame */
|
||||
link a6, IMM(-8)
|
||||
|
||||
/*
|
||||
* zero out the bss section.
|
||||
*/
|
||||
movel IMM(__bss_start), d1
|
||||
movel IMM(_end), d0
|
||||
cmpl d0, d1
|
||||
jbeq 3f
|
||||
movl d1, a0
|
||||
subl d1, d0
|
||||
subql IMM(1), d0
|
||||
2:
|
||||
clrb (a0)+
|
||||
#ifndef __mcf5200__
|
||||
dbra d0, 2b
|
||||
clrw d0
|
||||
subql IMM(1), d0
|
||||
jbcc 2b
|
||||
#else
|
||||
subql IMM(1), d0
|
||||
jbpl 2b
|
||||
#endif
|
||||
|
||||
3:
|
||||
|
||||
/*
|
||||
* call the main routine from the application to get it going.
|
||||
* main (argc, argv, environ)
|
||||
* we pass argv as a pointer to NULL.
|
||||
*/
|
||||
|
||||
#ifdef ADD_DTORS
|
||||
/* put __do_global_dtors in the atexit list so the destructors get run */
|
||||
movel IMM (SYM(__do_global_dtors)),(sp)
|
||||
jsr SYM (atexit)
|
||||
#endif
|
||||
movel IMM (__FINI_SECTION__),(sp)
|
||||
jsr SYM (atexit)
|
||||
|
||||
jsr __INIT_SECTION__
|
||||
|
||||
pea 0
|
||||
pea SYM (environ)
|
||||
pea sp@(4)
|
||||
pea 0
|
||||
jsr SYM (main)
|
||||
movel d0, sp@-
|
||||
|
||||
/*
|
||||
* drop down into exit incase the user doesn't. This should drop
|
||||
* control back to the ROM monitor, if there is one. This calls the
|
||||
* exit() from the C library so the C++ tables get cleaned up right.
|
||||
*/
|
||||
jsr SYM (exit)
|
28
libgloss/m68k/sim-errno.c
Normal file
28
libgloss/m68k/sim-errno.c
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* sim-errno.c -- return address of errno for current thread.
|
||||
*
|
||||
* Copyright (c) 1995, 2001 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.
|
||||
*/
|
||||
|
||||
|
||||
/* syscall handler branches here in case of error. */
|
||||
|
||||
extern int *__errno();
|
||||
|
||||
int
|
||||
_cerror (e)
|
||||
int e;
|
||||
{
|
||||
*__errno() = e;
|
||||
return -1;
|
||||
}
|
29
libgloss/m68k/sim-funcs.c
Normal file
29
libgloss/m68k/sim-funcs.c
Normal file
@ -0,0 +1,29 @@
|
||||
/* sim-funcs.c - random needed simulator functions
|
||||
*
|
||||
* Copyright (c) 2001 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.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
kill(int pid, int sig)
|
||||
{
|
||||
exit(0xdead);
|
||||
}
|
||||
|
||||
pid_t
|
||||
getpid()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
|
26
libgloss/m68k/sim-inbyte.c
Normal file
26
libgloss/m68k/sim-inbyte.c
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* sim-inbyte.c -- read a character from standard input.
|
||||
*
|
||||
* Copyright (c) 1995, 2001 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.
|
||||
*/
|
||||
|
||||
int
|
||||
inbyte ()
|
||||
{
|
||||
char c;
|
||||
|
||||
if (read (0, &c, 1) <= 0)
|
||||
return -1;
|
||||
|
||||
return c;
|
||||
}
|
43
libgloss/m68k/sim-print.c
Normal file
43
libgloss/m68k/sim-print.c
Normal file
@ -0,0 +1,43 @@
|
||||
/* sim-print.c -- print a string on the output device.
|
||||
*
|
||||
* Copyright (c) 1995, 2001 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* print -- do a raw print of a string
|
||||
*/
|
||||
void
|
||||
print (ptr)
|
||||
char *ptr;
|
||||
{
|
||||
int len = 0;
|
||||
char *p = ptr;
|
||||
|
||||
while (*p != '\0')
|
||||
p++;
|
||||
|
||||
write (1, ptr, p-ptr);
|
||||
}
|
||||
|
||||
/*
|
||||
* outbyte -- write a single character.
|
||||
*/
|
||||
|
||||
void
|
||||
outbyte (c_int)
|
||||
int c_int;
|
||||
{
|
||||
char c = c_int;
|
||||
|
||||
write (1, &c, 1);
|
||||
}
|
30
libgloss/m68k/sim-sbrk.c
Normal file
30
libgloss/m68k/sim-sbrk.c
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* sim-sbrk.c -- m68k sbrk support when running under the simulator.
|
||||
*
|
||||
* Copyright (c) 1995, 2001 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.
|
||||
*/
|
||||
|
||||
extern char _end[];
|
||||
static char *curbrk = _end;
|
||||
|
||||
char *
|
||||
sbrk (incr)
|
||||
int incr;
|
||||
{
|
||||
char *oldbrk = curbrk;
|
||||
curbrk += incr;
|
||||
if (brk (curbrk) == -1)
|
||||
return (char *) -1;
|
||||
|
||||
return oldbrk;
|
||||
}
|
87
libgloss/m68k/sim.ld
Normal file
87
libgloss/m68k/sim.ld
Normal file
@ -0,0 +1,87 @@
|
||||
STARTUP(sim-crt0.o)
|
||||
OUTPUT_ARCH(m68k)
|
||||
|
||||
SEARCH_DIR(.)
|
||||
GROUP(-lsim -lc -lgcc -lsim)
|
||||
__DYNAMIC = 0;
|
||||
|
||||
|
||||
MEMORY
|
||||
{
|
||||
ram (rwx) : ORIGIN = 0x80000000, LENGTH = 1M
|
||||
}
|
||||
|
||||
PROVIDE (__stack = 0);
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
CREATE_OBJECT_SYMBOLS
|
||||
*(.text)
|
||||
|
||||
. = ALIGN(0x4);
|
||||
/* These are for running static constructors and destructors under ELF. */
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
|
||||
*(.rodata)
|
||||
|
||||
. = ALIGN(0x4);
|
||||
*(.gcc_except_table)
|
||||
|
||||
. = ALIGN(0x4);
|
||||
*(.eh_frame)
|
||||
|
||||
. = ALIGN(0x4);
|
||||
__INIT_SECTION__ = . ;
|
||||
LONG (0x4e560000) /* linkw %fp,#0 */
|
||||
*(.init)
|
||||
SHORT (0x4e5e) /* unlk %fp */
|
||||
SHORT (0x4e75) /* rts */
|
||||
|
||||
. = ALIGN(0x4);
|
||||
__FINI_SECTION__ = . ;
|
||||
LONG (0x4e560000) /* linkw %fp,#0 */
|
||||
*(.fini)
|
||||
SHORT (0x4e5e) /* unlk %fp */
|
||||
SHORT (0x4e75) /* rts */
|
||||
|
||||
_etext = .;
|
||||
*(.lit)
|
||||
} > ram
|
||||
|
||||
.data :
|
||||
{
|
||||
*(.shdata)
|
||||
*(.data)
|
||||
_edata = .;
|
||||
} > ram
|
||||
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(0x4);
|
||||
__bss_start = . ;
|
||||
*(.shbss)
|
||||
*(.bss)
|
||||
*(COMMON)
|
||||
_end = ALIGN (0x8);
|
||||
__end = _end;
|
||||
} > ram
|
||||
|
||||
.stab 0 (NOLOAD) :
|
||||
{
|
||||
*(.stab)
|
||||
}
|
||||
|
||||
.stabstr 0 (NOLOAD) :
|
||||
{
|
||||
*(.stabstr)
|
||||
}
|
||||
}
|
84
libgloss/m68k/simulator.S
Normal file
84
libgloss/m68k/simulator.S
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* simulator.S -- m68k simulator system calls.
|
||||
*
|
||||
* Copyright (c) 1995, 2001 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.
|
||||
*/
|
||||
|
||||
#include "asm.h"
|
||||
|
||||
#define SYSCALL(x) .word 0x4afc, x
|
||||
|
||||
#define FUNC_START(x) .globl x; x:
|
||||
#define FUNC_END(x)
|
||||
#define FUNC_NAME(x) SYM(x)
|
||||
|
||||
FUNC_START(_exit)
|
||||
SYSCALL(1)
|
||||
|
||||
/*
|
||||
* Insure that the debugger tells the client that the PC is in _exit,
|
||||
* not whatever function happens to follow this function.
|
||||
*/
|
||||
|
||||
0: nop
|
||||
jmp 0b /* we never should return, but... */
|
||||
|
||||
FUNC_END(_exit)
|
||||
|
||||
FUNC_START(read)
|
||||
SYSCALL(3)
|
||||
bcs FUNC_NAME(_cerror)
|
||||
rts
|
||||
FUNC_END(read)
|
||||
|
||||
FUNC_START(write)
|
||||
SYSCALL(4)
|
||||
bcs FUNC_NAME(_cerror)
|
||||
rts
|
||||
FUNC_END(write)
|
||||
|
||||
FUNC_START(open)
|
||||
SYSCALL(5)
|
||||
bcs FUNC_NAME(_cerror)
|
||||
rts
|
||||
FUNC_END(open)
|
||||
|
||||
FUNC_START(close)
|
||||
SYSCALL(6)
|
||||
bcs FUNC_NAME(_cerror)
|
||||
rts
|
||||
FUNC_END(close)
|
||||
|
||||
FUNC_START(brk)
|
||||
SYSCALL(17)
|
||||
bcs FUNC_NAME(_cerror)
|
||||
rts
|
||||
FUNC_END(brk)
|
||||
|
||||
FUNC_START(lseek)
|
||||
SYSCALL(199)
|
||||
bcs FUNC_NAME(_cerror)
|
||||
rts
|
||||
FUNC_END(lseek)
|
||||
|
||||
FUNC_START(fstat)
|
||||
SYSCALL(28)
|
||||
bcs FUNC_NAME(_cerror)
|
||||
rts
|
||||
FUNC_END(lseek)
|
||||
|
||||
FUNC_START(isatty)
|
||||
SYSCALL(29)
|
||||
bcs FUNC_NAME(_cerror)
|
||||
rts
|
||||
FUNC_END(isatty)
|
Loading…
x
Reference in New Issue
Block a user