URL
https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk
Subversion Repositories openrisc_2011-10-31
Compare Revisions
- This comparison shows the changes necessary to convert path
/openrisc
- from Rev 506 to Rev 507
- ↔ Reverse comparison
Rev 506 → Rev 507
/trunk/gnu-src/gcc-4.5.1/gcc/config/or32/or32.opt
61,14 → 61,10
Target Mask(MASK_ROR) |
Emit ROR instructions |
|
mor32-newlib |
Target RejectNegative |
Link with the OR32 newlib library |
mboard= |
Target RejectNegative Joined |
Link with libgloss configuration suitable for this board |
|
mor32-newlib-uart |
Target RejectNegative |
Link with the OR32 newlib UART library |
|
mnewlib |
Target Report RejectNegative Var(or32_libc,or32_libc_newlib) Init(OR32_LIBC_DEFAULT) |
Compile for the Linux/Gnu/newlib based toolchain |
/trunk/gnu-src/gcc-4.5.1/gcc/config/or32/or32.h
48,13 → 48,13
|
#undef CPP_SPEC |
#define CPP_SPEC \ |
"%{!mor32-newlib*:%{pthread:-D_XOPEN_SOURCE=700}}" \ |
"%{mor32-newlib*:-idirafter %(target_prefix)/newlib-include}" |
"%{!mnewlib*:%{pthread:-D_XOPEN_SOURCE=700}}" \ |
"%{mnewlib*:-idirafter %(target_prefix)/newlib-include}" |
|
/* Make sure we pick up the crti.o, crtbegin.o, crtend.o and crtn.o files. */ |
#undef STARTFILE_SPEC |
#define STARTFILE_SPEC "%{!shared:%{mor32-newlib*:%(target_prefix)/lib/crt0.o} \ |
%{!mor32-newlib*:crt0.o%s} crti.o%s crtbegin.o%s}" |
#define STARTFILE_SPEC "%{!shared:%{mnewlib:%(target_prefix)/lib/crt0.o} \ |
%{!mnewlib:crt0.o%s} crti.o%s crtbegin.o%s}" |
|
#undef ENDFILE_SPEC |
#define ENDFILE_SPEC "crtend.o%s crtn.o%s" |
61,20 → 61,22
|
/* Specify the newlib library path if necessary */ |
#undef LINK_SPEC |
#define LINK_SPEC "%{mor32-newlib*:-L%(target_prefix)/newlib}" |
#define LINK_SPEC "%{mnewlib:-L%(target_prefix)/newlib}" |
|
/* Override previous definitions (linux.h). Newlib doesn't have a profiling |
version of the library, but it does have a debugging version (libg.a) */ |
|
#undef LIB_SPEC |
#define LIB_SPEC "%{!mor32-newlib*:" \ |
#define LIB_SPEC "%{!mnewlib:" \ |
"%{pthread:" \ |
"--whole-archive -lpthread --no-whole-archive} " \ |
"%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}} \ |
%{mor32-newlib:%{!g:-lc -lor32 -u free -lc} \ |
%{g:-lg -lor32 -u free -lg}} \ |
%{mor32-newlib-uart:%{!g:-lc -lor32uart -u free -lc} \ |
%{g:-lg -lor32uart -u free -lg}}" |
%{mnewlib:%{!g:-lc -lor32 -lboard -u free -lc} \ |
%{g:-lg -lor32 -lboard -u free -lg} \ |
%{mboard=*:-L%(target_prefix)/lib/boards/%*} \ |
%{!mboard=*:-L%(target_prefix)/lib/boards/or1ksim}}" |
|
|
#define TARGET_VERSION fprintf (stderr, " (OpenRISC 1000) Mask 0x%x", MASK_HARD_MUL); |
|
/* Run-time compilation parameters selecting different hardware subsets. */ |
trunk/gnu-src/newlib-1.18.0/libgloss/or32/lseek-uart.c
Property changes :
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Deleted: svn:keywords
## -1 +0,0 ##
-Id
\ No newline at end of property
Index: trunk/gnu-src/newlib-1.18.0/libgloss/or32/write-uart.c
===================================================================
--- trunk/gnu-src/newlib-1.18.0/libgloss/or32/write-uart.c (revision 506)
+++ trunk/gnu-src/newlib-1.18.0/libgloss/or32/write-uart.c (nonexistent)
@@ -1,93 +0,0 @@
-/* write-uart.c. Implementation of the _write syscall for newlib with UART
-
- Copyright (C) 2004, Jacob Bower
- Copyright (C) 2010, Embecosm Limited
-
- Contributor Jeremy Bennett
-
- This file is part of Newlib.
-
- The original work by Jacob Bower is provided as-is without any kind of
- warranty. Use it at your own risk!
-
- All subsequent work is bound by version 3 of the GPL as follows.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 3 of the License, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along
- with this program. If not, see . */
-/* -------------------------------------------------------------------------- */
-/* This program is commented throughout in a fashion suitable for processing
- with Doxygen. */
-/* -------------------------------------------------------------------------- */
-
-#include
-#include
-
-#include "uart.h"
-
-
-#undef errno
-extern int errno;
-
-
-/* -------------------------------------------------------------------------- */
-/*!Write a single character to standard output for the UART
-
- @param[in] c The character to write */
-/* -------------------------------------------------------------------------- */
-static void
-outbyte (char c)
-{
- __uart_putc (c);
-
-} /* outbyte () */
-
-
-/* -------------------------------------------------------------------------- */
-/*!Write a buffer to a file.
-
- Only output to stdout or stderr is supported, and both of those are
- directed to the single output stream.
-
- Remember that this function is *not* reentrant, so no static state should
- be held.
-
- @param[in] file The fileno for output.
- @param[in] buf The bytes to write.
- @param[in] nbytes The number of bytes to write.
-
- @return The number of bytes written on success, or -1 with an error code
- in the global variable errno on failure. */
-/* -------------------------------------------------------------------------- */
-int
-_write (int file,
- char *buf,
- int nbytes)
-{
- int i;
-
- /* We only handle stdout and stderr */
- if ((file != STDOUT_FILENO) && (file != STDERR_FILENO))
- {
- errno = EBADF;
- return -1;
- }
-
- /* Output character at at time */
- for (i = 0; i < nbytes; i++)
- {
- outbyte (buf[i]);
- }
-
- return nbytes;
-
-} /* _write () */
trunk/gnu-src/newlib-1.18.0/libgloss/or32/write-uart.c
Property changes :
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Deleted: svn:keywords
## -1 +0,0 ##
-Id
\ No newline at end of property
Index: trunk/gnu-src/newlib-1.18.0/libgloss/or32/fstat-uart.c
===================================================================
--- trunk/gnu-src/newlib-1.18.0/libgloss/or32/fstat-uart.c (revision 506)
+++ trunk/gnu-src/newlib-1.18.0/libgloss/or32/fstat-uart.c (nonexistent)
@@ -1,69 +0,0 @@
-/* fstat-uart.c. Implementation of the _fstat syscall for newlib with UART
-
- Copyright (C) 2004, Jacob Bower
- Copyright (C) 2010, Embecosm Limited
-
- Contributor Jeremy Bennett
-
- This file is part of Newlib.
-
- The original work by Jacob Bower is provided as-is without any kind of
- warranty. Use it at your own risk!
-
- All subsequent work is bound by version 3 of the GPL as follows.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 3 of the License, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along
- with this program. If not, see . */
-/* -------------------------------------------------------------------------- */
-/* This program is commented throughout in a fashion suitable for processing
- with Doxygen. */
-/* -------------------------------------------------------------------------- */
-
-#include
-#include
-#include
-
-
-#undef errno
-extern int errno;
-
-
-/* -------------------------------------------------------------------------- */
-/*!Status of an open file when using a UART
-
- We only know about stdin, stdout and stderr, and treat these as character
- special files. All other files are erroneous.
-
- Remember that this function is *not* reentrant, so no static state should
- be held.
-
- @return 0 on success, with the struct stat appropriately updated. -1 on
- failure, with an error code in the global variable errno. */
-/* -------------------------------------------------------------------------- */
-int
-_fstat (int file,
- struct stat *st)
-{
- if ((STDIN_FILENO == file) ||
- (STDERR_FILENO == file) ||
- (STDOUT_FILENO == file))
- {
- st->st_mode = S_IFCHR;
- return 0;
- }
- else
- {
- errno = EBADF;
- return -1;
- }
-} /* _fstat () */
trunk/gnu-src/newlib-1.18.0/libgloss/or32/fstat-uart.c
Property changes :
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Deleted: svn:keywords
## -1 +0,0 ##
-Id
\ No newline at end of property
Index: trunk/gnu-src/newlib-1.18.0/libgloss/or32/isatty-uart.c
===================================================================
--- trunk/gnu-src/newlib-1.18.0/libgloss/or32/isatty-uart.c (revision 506)
+++ trunk/gnu-src/newlib-1.18.0/libgloss/or32/isatty-uart.c (nonexistent)
@@ -1,68 +0,0 @@
-/* isatty-uart.c. Implementation of the _isatty syscall for newlib with UART
-
- Copyright (C) 2004, Jacob Bower
- Copyright (C) 2010, Embecosm Limited
-
- Contributor Jeremy Bennett
-
- This file is part of Newlib.
-
- The original work by Jacob Bower is provided as-is without any kind of
- warranty. Use it at your own risk!
-
- All subsequent work is bound by version 3 of the GPL as follows.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 3 of the License, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along
- with this program. If not, see . */
-/* -------------------------------------------------------------------------- */
-/* This program is commented throughout in a fashion suitable for processing
- with Doxygen. */
-/* -------------------------------------------------------------------------- */
-
-#include
-#include
-
-
-#undef ERRNO
-extern int errno;
-
-
-/* -------------------------------------------------------------------------- */
-/*!Is a file a TTY when using a UART?
-
- We only support stdin, stdout and stderr to the console, so we are always a
- TTY for these.
-
- Remember that this function is *not* reentrant, so no static state should
- be held.
-
- @param[in] file The fileno to check.
-
- @return 1 if we are a TTY, 0 otherwise, with an error code in the global
- variable errno. */
-/* -------------------------------------------------------------------------- */
-int
-_isatty (int file)
-{
- if ((file == STDIN_FILENO) ||
- (file == STDOUT_FILENO) ||
- (file == STDERR_FILENO))
- {
- return 1;
- }
- else
- {
- errno = EBADF;
- return -1;
- }
-} /* _isatty () */
trunk/gnu-src/newlib-1.18.0/libgloss/or32/isatty-uart.c
Property changes :
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Deleted: svn:keywords
## -1 +0,0 ##
-Id
\ No newline at end of property
Index: trunk/gnu-src/newlib-1.18.0/libgloss/or32/read-uart.c
===================================================================
--- trunk/gnu-src/newlib-1.18.0/libgloss/or32/read-uart.c (revision 506)
+++ trunk/gnu-src/newlib-1.18.0/libgloss/or32/read-uart.c (nonexistent)
@@ -1,85 +0,0 @@
-/* read-uart.c. Implementation of the _read syscall for newlib with UART.
-
- Copyright (C) 2004, Jacob Bower
- Copyright (C) 2010, Embecosm Limited
-
- Contributor Jeremy Bennett
-
- This file is part of Newlib.
-
- The original work by Jacob Bower is provided as-is without any kind of
- warranty. Use it at your own risk!
-
- All subsequent work is bound by version 3 of the GPL as follows.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 3 of the License, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along
- with this program. If not, see . */
-/* -------------------------------------------------------------------------- */
-/* This program is commented throughout in a fashion suitable for processing
- with Doxygen. */
-/* -------------------------------------------------------------------------- */
-
-#include
-#include
-
-
-#undef errno
-extern int errno;
-
-
-/* -------------------------------------------------------------------------- */
-/*!Read from a file with a UART.
-
- We only support reading from stdin.
-
- Remember that this function is *not* reentrant, so no static state should
- be held.
-
- @param[in] file The fileno to read.
- @param[in] buf Buffer into which to read.
- @param[in] len Number of bytes to read.
-
- @return number of bytes read if the file is stdin, otherwise -1 to
- indicate failure, with an error code in the global variable
- errno. */
-/* -------------------------------------------------------------------------- */
-int
-_read (int file,
- char *buf,
- int len)
-{
- if (STDIN_FILENO == file)
- {
- int i;
-
- for (i = 0; i < len; i++)
- {
- buf[i] = __uart_getc ();
-#ifdef UART_AUTO_ECHO
- __uart_putc (buf[i]);
-#endif
- /* Return partial buffer if we get EOL */
- if ('\n' == buf[i])
- {
- return i;
- }
- }
-
- return i; /* Filled the buffer */
- }
- else
- {
- errno = EBADF;
- return -1;
- }
-} /* _read () */
trunk/gnu-src/newlib-1.18.0/libgloss/or32/read-uart.c
Property changes :
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Deleted: svn:keywords
## -1 +0,0 ##
-Id
\ No newline at end of property
Index: trunk/gnu-src/newlib-1.18.0/libgloss/or32/or1ksim-board.h
===================================================================
--- trunk/gnu-src/newlib-1.18.0/libgloss/or32/or1ksim-board.h (revision 506)
+++ trunk/gnu-src/newlib-1.18.0/libgloss/or32/or1ksim-board.h (nonexistent)
@@ -1,61 +0,0 @@
-/* Newlib board descriptions for Or1ksim
-
- Copyright (C)
- Copyright (C) 2008, 2010 Embecosm Limited
-
- Contributor
- Contributor Jeremy Bennett
-
- This file is part of Newlib.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 3 of the License, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along
- with this program. If not, see . */
-/* -------------------------------------------------------------------------- */
-/* This program is commented throughout in a fashion suitable for processing
- with Doxygen. */
-/* -------------------------------------------------------------------------- */
-
-/* This machine configuration matches the Or1ksim configuration file in this
- directory. */
-
-#ifndef OR1KSIM_BOARD__H
-#define OR1KSIM_BOARD__H
-
-/* Cache information (no longer used, cache configured through UPR and CCFGRs)*/
-#define IC_ENABLE 1
-#define IC_SIZE 8192
-
-#define DC_ENABLE 0
-#define DC_SIZE 8192
-
-#define SDRAM_BASE_ADDR 0x00000000
-#define SDRAM_TMS_VAL 0x07248230
-
-/* UART information */
-#define IN_CLK 25000000 /*!< 25 MHz */
-#define UART_BAUD_RATE 115200 /*!< 115.2 kHz */
-
-#define UART_BASE 0x90000000
-#define UART_IRQ 19
-
-/* l.nop constants */
-#define NOP_EXIT 0x0001 /*!< End of simulation */
-#define NOP_PUTC 0x0004 /*!< Put a character */
-
-/*! Define UART_AUTO_ECHO to have the UART echo reads. */
-#undef UART_AUTO_ECHO
-
-/*! 8-bit register access macro */
-#define REG8(add) *((volatile unsigned char *) (add))
-
-#endif /* OR1KSIM_BOARD__H */
trunk/gnu-src/newlib-1.18.0/libgloss/or32/or1ksim-board.h
Property changes :
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Deleted: svn:keywords
## -1 +0,0 ##
-Id
\ No newline at end of property
Index: trunk/gnu-src/newlib-1.18.0/libgloss/or32/Makefile.in
===================================================================
--- trunk/gnu-src/newlib-1.18.0/libgloss/or32/Makefile.in (revision 506)
+++ trunk/gnu-src/newlib-1.18.0/libgloss/or32/Makefile.in (revision 507)
@@ -3,8 +3,10 @@
# Copyright (c) 1998 Cygnus Support
# Copyright (C) 2004, Jacob Bower
# Copyright (C) 2010, Embecosm Limited
+# Copyright (C) 2011, ORSoC AB
# Contributor Jeremy Bennett
+# Contributor Julius Baxter
# This file is part of Newlib.
@@ -70,73 +72,62 @@
# Add our own flags for C compilation
CFLAGS = -g
+# List new boards here - should be accompanied by own .[cS]
+BOARDS = or1ksim or1ksim-uart orpsocrefdesign ordb1a3pe1500 ml501
+
+BOARD_OBJS = $(addsuffix .o,$(BOARDS))
+BOARD_LIBS = $(addsuffix .a,$(BOARDS))
+
+# Generic name, used after install for each of these libraries
+LIBBOARD = libboard.a
+
# Our own C runtime startup and BSPs
-CRT0 = crt0.o
-BSP = libor32.a
-BSP_UART = libor32uart.a
+CRT0 = crt0.o
+LIBOR32 = libor32.a
-OUTPUTS = $(CRT0) $(BSP) $(BSP_UART)
+OUTPUTS = $(CRT0) $(LIBOR32)
-# The object files for each BSP
-OBJS = _exit.o \
- close.o \
- environ.o \
- execve.o \
- fork.o \
- fstat.o \
- getpid.o \
- isatty.o \
- kill.o \
- link.o \
- lseek.o \
- open.o \
- read.o \
- sbrk.o \
- stat.o \
- times.o \
- uart-dummy.o \
- unlink.o \
- wait.o \
- write.o
+# The standard object files for the library
+LIBOR32_OBJS = _exception_handler.o \
+ _cache.o \
+ _exit.o \
+ _interrupt_handler.o \
+ close.o \
+ environ.o \
+ execve.o \
+ fork.o \
+ fstat.o \
+ getpid.o \
+ isatty.o \
+ kill.o \
+ link.o \
+ lseek.o \
+ open.o \
+ read.o \
+ sbrk.o \
+ stat.o \
+ times.o \
+ uart.o \
+ unlink.o \
+ wait.o \
+ write.o
-UART_OBJS = _exit.o \
- close.o \
- environ.o \
- execve.o \
- fork.o \
- fstat-uart.o \
- getpid.o \
- isatty-uart.o \
- kill.o \
- link.o \
- lseek-uart.o \
- open.o \
- read-uart.o \
- sbrk.o \
- stat.o \
- times.o \
- uart.o \
- unlink.o \
- wait.o \
- write-uart.o
-
# Host specific makefile fragment specifies the automatic rules
@host_makefile_frag@
-# Build crt0.o and all the BSPs
-all: ${CRT0} ${BSP} ${BSP_UART}
+# Build what we need out
+all: $(OUTPUTS) $(BOARD_LIBS)
# Rules to build the BSPs from their objects. No need for a rule to build
# crt0.o, that happens autmatically from .S
-$(BSP): $(OBJS)
- ${AR} ${ARFLAGS} $@ $(OBJS)
+$(LIBOR32): $(LIBOR32_OBJS)
+ ${AR} ${ARFLAGS} $@ $^
${RANLIB} $@
-$(BSP_UART): $(UART_OBJS)
- ${AR} ${ARFLAGS} $@ $(UART_OBJS)
+%.a: %.o
+ ${AR} ${ARFLAGS} $@ $^
${RANLIB} $@
-
# Standard clean up rules.
clean mostlyclean:
rm -f $(OUTPUTS) *.i *~ *.o *-test *.srec *.dis *.map *.x
@@ -144,7 +135,11 @@
distclean maintainer-clean realclean: clean
rm -f Makefile config.status *~
-# Standard install rules
+# Standard install rules for libor32 and crt0
+# Boards installed into lib/board/$${board} and named board.a. GCC links against with
+# board specified by -mboard=whichboard and adds
+# -lboard -L/lib/board/whichboard
+#
.PHONY: install info install-info clean-info
install:
@for outputs in ${OUTPUTS}; do\
@@ -151,6 +146,11 @@
mkdir -p $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}; \
$(INSTALL_PROGRAM) $${outputs} \
$(DESTDIR)$(tooldir)/lib${MULTISUBDIR}; \
+ done; \
+ for board in ${BOARDS}; do\
+ mkdir -p $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/boards/$${board}; \
+ $(INSTALL_PROGRAM) $${board}.a \
+ $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/boards/$${board}/$(LIBBOARD); \
done
# Deal with info if we had any.
/trunk/gnu-src/newlib-1.18.0/libgloss/or32/sim.cfg
61,7 → 61,7
options in or1ksim_board.h and the version of the library selected. */ |
|
section ic |
enabled = 1 |
enabled = 0 |
nsets = 256 |
nways = 1 |
blocksize = 16 |
/trunk/gnu-src/newlib-1.18.0/libgloss/or32/or1ksim.S
0,0 → 1,22
/* |
* Define symbols to be used during startup - file is linked at compile time |
* |
*/ |
.global _board_mem_base |
.global _board_mem_size |
.global _board_clk_freq |
|
_board_mem_base: .long 0x0 |
_board_mem_size: .long 0x800000 |
|
_board_clk_freq: .long 100000000 |
|
/* Peripheral information - Set base to 0 if not present*/ |
.global _board_uart_base |
.global _board_uart_baud |
.global _board_uart_IRQ |
|
_board_uart_base: .long 0x0 |
_board_uart_baud: .long 115200 |
_board_uart_IRQ: .long 13 |
|
/trunk/gnu-src/newlib-1.18.0/libgloss/or32/ordb1a3pe1500.S
0,0 → 1,21
/* |
* Define symbols to be used during startup - file is linked at compile time |
* |
*/ |
.global _board_mem_base |
.global _board_mem_size |
.global _board_clk_freq |
|
_board_mem_base: .long 0x0 |
_board_mem_size: .long 0x02000000 |
|
_board_clk_freq: .long 20000000 |
|
/* Peripheral information - Set base to 0 if not present*/ |
.global _board_uart_base |
.global _board_uart_baud |
.global _board_uart_IRQ |
|
_board_uart_base: .long 0x90000000 |
_board_uart_baud: .long 115200 |
_board_uart_IRQ: .long 2 |
/trunk/gnu-src/newlib-1.18.0/libgloss/or32/read.c
32,6 → 32,7
#include <errno.h> |
#include <unistd.h> |
|
#include "or1k-support.h" |
|
#undef errno |
extern int errno; |
40,14 → 41,13
/* -------------------------------------------------------------------------- */ |
/*!Read from a file. |
|
We don't support reading. However for stdin, it's better if we return 0 |
(indicating EOF) rather than fail. |
Depending on board support, we may attempt to read from UART. |
|
Remember that this function is *not* reentrant, so no static state should |
be held. |
|
@param[in] file The fileno to read. |
@param[in] ptr Buffer into which to read. |
@param[in] buf Buffer into which to read. |
@param[in] len Number of bytes to read. |
|
@return 0 to indicate EOF if the file is stdin, otherwise -1 to indicate |
55,16 → 55,42
/* -------------------------------------------------------------------------- */ |
int |
_read (int file, |
char *ptr, |
char *buf, |
int len) |
{ |
if (STDIN_FILENO == file) |
{ |
return 0; /* EOF */ |
} |
else |
{ |
errno = EBADF; |
return -1; |
} |
if (STDIN_FILENO == file) |
{ |
|
if (BOARD_HAS_UART) |
{ |
/* UART supported. Read from it */ |
|
|
int i; |
|
for (i = 0; i < len; i++) |
{ |
buf[i] = __uart_getc (); |
#ifdef UART_AUTO_ECHO |
__uart_putc (buf[i]); |
#endif |
/* Return partial buffer if we get EOL */ |
if ('\n' == buf[i]) |
{ |
return i; |
} |
} |
|
return i; /* Filled the buffer */ |
} |
else |
{ |
return 0; /* EOF */ |
} |
} |
else |
{ |
errno = EBADF; |
return -1; |
} |
} /* _read () */ |
/trunk/gnu-src/newlib-1.18.0/libgloss/or32/or1ksim-uart.S
0,0 → 1,23
/* |
* Define symbols to be used during startup - file is linked at compile time |
* |
*/ |
|
.global _board_mem_base |
.global _board_mem_size |
.global _board_clk_freq |
|
|
_board_mem_base: .long 0x0 |
_board_mem_size: .long 0x800000 |
_board_clk_freq: .long 100000000 |
|
|
/* Peripheral information - Set base to 0 if not present*/ |
.global _board_uart_base |
.global _board_uart_baud |
.global _board_uart_IRQ |
|
_board_uart_base: .long 0x90000000 |
_board_uart_baud: .long 115200 |
_board_uart_IRQ: .long 13 |
/trunk/gnu-src/newlib-1.18.0/libgloss/or32/_cache.S
0,0 → 1,142
/* _cache.S. OR1K cache initialisation function. |
|
Copyright (C) 2010, 2011, Authors, ORSoC AB |
|
Contributor Jonas Bonn <jonas.bonn@gmail.com> |
Contributor Julius Baxter <julius@opencores.org> |
|
This file is part of Newlib. |
|
This program is free software; you can redistribute it and/or modify it |
under the terms of the GNU General Public License as published by the Free |
Software Foundation; either version 3 of the License, or (at your option) |
any later version. |
|
This program is distributed in the hope that it will be useful, but WITHOUT |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
more details. |
|
You should have received a copy of the GNU General Public License along |
with this program. If not, see <http://www.gnu.org/licenses/>. */ |
|
/* |
This function is to be used ONLY during reset, before main() is called. |
TODO: Perhaps break into individual enable instruction/data cache |
sections functions, and provide disable functions, also, all |
callable from C |
|
*/ |
|
#include "spr-defs.h" |
|
.section .text |
.global _cache_init |
.type _cache_init,@function |
|
_cache_init: |
/* Instruction cache enable */ |
/* Check if IC present and skip enabling otherwise */ |
.L6: l.mfspr r24,r0,SPR_UPR |
l.andi r26,r24,SPR_UPR_ICP |
l.sfeq r26,r0 |
l.bf .L8 |
l.nop |
|
/* Disable IC */ |
l.mfspr r6,r0,SPR_SR |
l.addi r5,r0,-1 |
l.xori r5,r5,SPR_SR_ICE |
l.and r5,r6,r5 |
l.mtspr r0,r5,SPR_SR |
|
/* Establish cache block size |
If BS=0, 16; |
If BS=1, 32; |
r14 contain block size |
*/ |
l.mfspr r24,r0,SPR_ICCFGR |
l.andi r26,r24,SPR_ICCFGR_CBS |
l.srli r28,r26,7 |
l.ori r30,r0,16 |
l.sll r14,r30,r28 |
|
/* Establish number of cache sets |
r16 contains number of cache sets |
r28 contains log(# of cache sets) |
*/ |
l.andi r26,r24,SPR_ICCFGR_NCS |
l.srli r28,r26,3 |
l.ori r30,r0,1 |
l.sll r16,r30,r28 |
|
/* Invalidate IC */ |
l.addi r6,r0,0 |
l.sll r5,r14,r28 |
|
.L7: l.mtspr r0,r6,SPR_ICBIR |
l.sfne r6,r5 |
l.bf .L7 |
l.add r6,r6,r14 |
|
/* Enable IC */ |
l.mfspr r6,r0,SPR_SR |
l.ori r6,r6,SPR_SR_ICE |
l.mtspr r0,r6,SPR_SR |
l.nop |
l.nop |
l.nop |
l.nop |
l.nop |
l.nop |
l.nop |
l.nop |
|
/* Data cache enable */ |
/* Check if DC present and skip enabling otherwise */ |
.L8: l.mfspr r24,r0,SPR_UPR |
l.andi r26,r24,SPR_UPR_DCP |
l.sfeq r26,r0 |
l.bf .L10 |
l.nop |
/* Disable DC */ |
l.mfspr r6,r0,SPR_SR |
l.addi r5,r0,-1 |
l.xori r5,r5,SPR_SR_DCE |
l.and r5,r6,r5 |
l.mtspr r0,r5,SPR_SR |
/* Establish cache block size |
If BS=0, 16; |
If BS=1, 32; |
r14 contain block size |
*/ |
l.mfspr r24,r0,SPR_DCCFGR |
l.andi r26,r24,SPR_DCCFGR_CBS |
l.srli r28,r26,7 |
l.ori r30,r0,16 |
l.sll r14,r30,r28 |
/* Establish number of cache sets |
r16 contains number of cache sets |
r28 contains log(# of cache sets) |
*/ |
l.andi r26,r24,SPR_DCCFGR_NCS |
l.srli r28,r26,3 |
l.ori r30,r0,1 |
l.sll r16,r30,r28 |
/* Invalidate DC */ |
l.addi r6,r0,0 |
l.sll r5,r14,r28 |
|
.L9: l.mtspr r0,r6,SPR_DCBIR |
l.sfne r6,r5 |
l.bf .L9 |
l.add r6,r6,r14 |
/* Enable DC */ |
l.mfspr r6,r0,SPR_SR |
l.ori r6,r6,SPR_SR_DCE |
l.mtspr r0,r6,SPR_SR |
|
.L10: |
/* Return */ |
l.jr r9 |
l.nop |
/trunk/gnu-src/newlib-1.18.0/libgloss/or32/crt0.S
1,9 → 1,11
/* crt0.S. C Runtime startup file. |
/* crt0.S. C design runtime startup file. |
|
Copyright (C) 2004, Jacob Bower |
Copyright (C) 2010, Embecosm Limited <info@embecosm.com> |
Copyright (C) 2011, ORSoC AB |
|
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> |
Contributor Julius Baxter <julius.baxter@orsoc.se> |
|
This file is part of Newlib. |
|
30,79 → 32,36
/* -------------------------------------------------------------------------- */ |
|
#include "spr-defs.h" |
#include "or1ksim-board.h" |
|
|
/* -------------------------------------------------------------------------- */ |
/*!Macro for expressions which do not have their own handler. |
/*!Macro to load a symbol's address into a register. |
|
Construct the arguments for a call to printf, then exit. Being varargs, the |
arguments to printf must be on the stack, which we update using the |
standard prologue. |
|
@param[in] str Label for a string describing the macro, suitable for |
printf. */ |
@param[in] gpr General purpose register to load address into. |
@param[in] symbol Name of symbol to load. */ |
/* -------------------------------------------------------------------------- */ |
#define UNHANDLED_EXCEPTION(str) \ |
l.addi r1,r1,-20 /* Standard prologue */ ;\ |
l.sw 16(r1),r2 ;\ |
l.addi r2,r1,20 ;\ |
l.sw 12(r1),r9 ;\ |
;\ |
l.movhi r3,hi(.Lfmt) /* printf format string */ ;\ |
l.ori r3,r3,lo(.Lfmt) ;\ |
l.sw 0(r1),r3 ;\ |
l.movhi r4,hi(str) /* Name of exception */ ;\ |
l.ori r4,r4,lo(str) ;\ |
l.sw 4(r1),r4 ;\ |
l.mfspr r5,r0,SPR_EPCR_BASE /* Source of the interrupt */ ;\ |
l.jal printf ;\ |
l.sw 8(r1),r5 ;\ |
;\ |
l.ori r3,r0,0xffff /* Failure RC */ ;\ |
l.jal exit ;\ |
l.nop ;\ |
;\ |
l.rfe /* Never executed we hope */ |
#define LOAD_SYMBOL_2_GPR(gpr,symbol) \ |
.global symbol ; \ |
l.movhi gpr, hi(symbol) ; \ |
l.ori gpr, gpr, lo(symbol) |
|
/* -------------------------------------------------------------------------- */ |
/*!Macro to handle exceptions. |
|
Load NPC into r3, EPCR into r4 |
*/ |
/* -------------------------------------------------------------------------- */ |
/*!Text strings for the different exceptions */ |
/* -------------------------------------------------------------------------- */ |
.section .rodata |
.Lfmt: .string "Unhandled %s exception at address %08p\n" |
.L200: .string "bus error" |
.L300: .string "data page fault" |
.L400: .string "instruction page fault" |
.L500: .string "timer" |
.L600: .string "alignment" |
.L700: .string "illegal instruction" |
.L800: .string "external interrupt" |
.L900: .string "data TLB" |
.La00: .string "instruction TLB" |
.Lb00: .string "range" |
.Lc00: .string "syscall" |
.Ld00: .string "floating point" |
.Le00: .string "trap" |
.Lf00: .string "undefined 0xf00" |
.L1000: .string "undefined 0x1000" |
.L1100: .string "undefined 0x1100" |
.L1200: .string "undefined 0x1200" |
.L1300: .string "undefined 0x1300" |
.L1400: .string "undefined 0x1400" |
.L1500: .string "undefined 0x1500" |
.L1600: .string "undefined 0x1600" |
.L1700: .string "undefined 0x1700" |
.L1800: .string "undefined 0x1800" |
.L1900: .string "undefined 0x1900" |
.L1a00: .string "undefined 0x1a00" |
.L1b00: .string "undefined 0x1b00" |
.L1c00: .string "undefined 0x1c00" |
.L1d00: .string "undefined 0x1d00" |
.L1e00: .string "undefined 0x1e00" |
.L1f00: .string "undefined 0x1f00" |
// Size of redzone + size of space required to store state |
// This value must match that in _exception_handler.S |
#define EXCEPTION_STACK_SIZE 128 |
|
#define CALL_EXCEPTION_HANDLER \ |
l.addi r1, r1, -EXCEPTION_STACK_SIZE; \ |
l.sw 4(r1), r3; \ |
l.sw 8(r1), r4; \ |
l.mfspr r3,r0,SPR_NPC; \ |
l.j _exception_handler; \ |
l.mfspr r4,r0,SPR_EPCR_BASE |
|
|
/* -------------------------------------------------------------------------- */ |
/*!Exception vectors */ |
/* -------------------------------------------------------------------------- */ |
111,133 → 70,151
/* 0x100: RESET exception */ |
.org 0x100 |
__reset: |
l.movhi r0, 0 |
l.movhi r1, 0 |
l.movhi r2, 0 |
l.movhi r3, 0 |
l.movhi r4, 0 |
l.movhi r5, 0 |
l.movhi r6, 0 |
l.movhi r7, 0 |
l.movhi r8, 0 |
l.movhi r9, 0 |
l.movhi r10, 0 |
l.movhi r11, 0 |
l.movhi r12, 0 |
l.movhi r13, 0 |
l.movhi r14, 0 |
l.movhi r15, 0 |
l.movhi r16, 0 |
l.movhi r17, 0 |
l.movhi r18, 0 |
l.movhi r19, 0 |
l.movhi r20, 0 |
l.movhi r21, 0 |
l.movhi r22, 0 |
l.movhi r23, 0 |
l.movhi r24, 0 |
l.movhi r25, 0 |
l.movhi r26, 0 |
l.movhi r27, 0 |
l.movhi r28, 0 |
l.movhi r29, 0 |
l.movhi r30, 0 |
l.movhi r31, 0 |
|
/* Clear status register, set supervisor mode */ |
l.ori r1, r0, SPR_SR_SM |
l.mtspr r0, r1, SPR_SR |
/* Clear timer mode register*/ |
l.mtspr r0, r0, SPR_TTMR |
/* Jump to program initialisation code */ |
l.j _start |
LOAD_SYMBOL_2_GPR(r4, _start) |
l.jr r4 |
l.nop |
|
/* 0x200: BUS exception is special, because during startup we use it |
to detect where the stack should go. So we need some special code |
before we return, which wel will later overwrite with l.nop. We |
need to deal with the case when _start is called multiple times, so |
this code must be copied into the bus error vector each time. It is |
position independent to allow this copying. |
|
We use registers we know will not interfere in this case. */ |
.org 0x200 |
__buserr: |
l.nop /* Will be overwritten */ |
l.nop |
l.nop |
l.nop |
CALL_EXCEPTION_HANDLER |
|
__buserr_std: |
UNHANDLED_EXCEPTION (.L200) |
|
__buserr_special: |
l.mfspr r24,r0,SPR_EPCR_BASE |
l.addi r24,r24,4 /* Return one instruction on */ |
l.mtspr r0,r24,SPR_EPCR_BASE |
l.rfe |
|
/* 0x300: Data Page Fault exception */ |
.org 0x300 |
UNHANDLED_EXCEPTION (.L300) |
CALL_EXCEPTION_HANDLER |
|
/* 0x400: Insn Page Fault exception */ |
.org 0x400 |
UNHANDLED_EXCEPTION (.L400) |
CALL_EXCEPTION_HANDLER |
|
/* 0x500: Timer exception */ |
.org 0x500 |
UNHANDLED_EXCEPTION (.L500) |
CALL_EXCEPTION_HANDLER |
|
/* 0x600: Aligment exception */ |
.org 0x600 |
UNHANDLED_EXCEPTION (.L600) |
CALL_EXCEPTION_HANDLER |
|
/* 0x700: Illegal insn exception */ |
.org 0x700 |
UNHANDLED_EXCEPTION (.L700) |
CALL_EXCEPTION_HANDLER |
|
/* 0x800: External interrupt exception */ |
.org 0x800 |
UNHANDLED_EXCEPTION (.L800) |
CALL_EXCEPTION_HANDLER |
|
/* 0x900: DTLB miss exception */ |
.org 0x900 |
UNHANDLED_EXCEPTION (.L900) |
CALL_EXCEPTION_HANDLER |
|
/* 0xa00: ITLB miss exception */ |
.org 0xa00 |
UNHANDLED_EXCEPTION (.La00) |
CALL_EXCEPTION_HANDLER |
|
/* 0xb00: Range exception */ |
.org 0xb00 |
UNHANDLED_EXCEPTION (.Lb00) |
CALL_EXCEPTION_HANDLER |
|
/* 0xc00: Syscall exception */ |
.org 0xc00 |
UNHANDLED_EXCEPTION (.Lc00) |
CALL_EXCEPTION_HANDLER |
|
/* 0xd00: floating point exception */ |
.org 0xd00 |
UNHANDLED_EXCEPTION (.Ld00) |
CALL_EXCEPTION_HANDLER |
|
/* 0xe00: Trap exception */ |
.org 0xe00 |
UNHANDLED_EXCEPTION (.Le00) |
CALL_EXCEPTION_HANDLER |
|
/* 0xf00: Reserved exceptions */ |
.org 0xf00 |
UNHANDLED_EXCEPTION (.Lf00) |
CALL_EXCEPTION_HANDLER |
|
.org 0x1000 |
UNHANDLED_EXCEPTION (.L1000) |
CALL_EXCEPTION_HANDLER |
|
.org 0x1100 |
UNHANDLED_EXCEPTION (.L1100) |
CALL_EXCEPTION_HANDLER |
|
.org 0x1200 |
UNHANDLED_EXCEPTION (.L1200) |
CALL_EXCEPTION_HANDLER |
|
.org 0x1300 |
UNHANDLED_EXCEPTION (.L1300) |
CALL_EXCEPTION_HANDLER |
|
.org 0x1400 |
UNHANDLED_EXCEPTION (.L1400) |
CALL_EXCEPTION_HANDLER |
|
.org 0x1500 |
UNHANDLED_EXCEPTION (.L1500) |
CALL_EXCEPTION_HANDLER |
|
.org 0x1600 |
UNHANDLED_EXCEPTION (.L1600) |
CALL_EXCEPTION_HANDLER |
|
.org 0x1700 |
UNHANDLED_EXCEPTION (.L1700) |
CALL_EXCEPTION_HANDLER |
|
.org 0x1800 |
UNHANDLED_EXCEPTION (.L1800) |
CALL_EXCEPTION_HANDLER |
|
.org 0x1900 |
UNHANDLED_EXCEPTION (.L1900) |
CALL_EXCEPTION_HANDLER |
|
.org 0x1a00 |
UNHANDLED_EXCEPTION (.L1a00) |
CALL_EXCEPTION_HANDLER |
|
.org 0x1b00 |
UNHANDLED_EXCEPTION (.L1b00) |
CALL_EXCEPTION_HANDLER |
|
.org 0x1c00 |
UNHANDLED_EXCEPTION (.L1c00) |
CALL_EXCEPTION_HANDLER |
|
.org 0x1d00 |
UNHANDLED_EXCEPTION (.L1d00) |
CALL_EXCEPTION_HANDLER |
|
.org 0x1e00 |
UNHANDLED_EXCEPTION (.L1e00) |
CALL_EXCEPTION_HANDLER |
|
.org 0x1f00 |
UNHANDLED_EXCEPTION (.L1f00) |
CALL_EXCEPTION_HANDLER |
|
/* Pad to the end */ |
.org 0x1ffc |
255,7 → 232,6
- clear BSS |
- call global and static constructors |
- set up destructors to be called from exit |
- initialize the UART (may be dummy, if no UART supported) |
- jump to the main function |
- call exit if the main function ever returns. |
- loop forever (should never get here) */ |
262,187 → 238,41
/* -------------------------------------------------------------------------- */ |
/* The stack grows down from the top of writable memory. */ |
.section .data |
.global stack |
stack: .space 4,0 |
.global stack |
stack: .space 4,0 |
|
.section .text |
.global _start |
.type _start,@function |
|
_start: |
/* First, clear r0. */ |
l.movhi r0,0 |
/* Finding the end of stack means we need to handle the bus |
error. Patch in some special handler code. */ |
l.movhi r30,hi(__buserr) /* Where to copy to */ |
l.ori r30,r30,lo(__buserr) |
l.movhi r28,hi(__buserr_std) /* Where to stop copying */ |
l.ori r28,r28,lo(__buserr_std) |
l.movhi r26,hi(__buserr_special)/* Where to copy from */ |
l.ori r26,r26,lo(__buserr_special) |
|
.L11: l.sfeq r28,r30 |
l.bf .L12 |
l.nop |
|
l.lwz r24,0(r26) /* Get the instruction */ |
l.sw 0(r30),r24 /* Patch the instruction */ |
l.addi r26,r26,4 /* Next source instruction */ |
l.j .L11 |
l.addi r30,r30,4 /* Delay slot: next dest location */ |
/* Following externs from board-specific object passed at link time */ |
.extern _board_mem_base |
.extern _board_mem_size |
.extern _board_uart_base |
|
/* Determine where the stack should end. Must be somewhere above the |
end of loaded memory. We look in blocks of 64KB. */ |
.L12: l.movhi r30,hi(end) |
l.ori r30,r30,lo(end) |
l.srli r30,r30,16 /* Round down to 64KB boundary */ |
l.slli r30,r30,16 |
_start: |
/* Initialise stack and frame pointer (set to same value) */ |
l.movhi r1,hi(_board_mem_base) |
l.ori r1,r1,lo(_board_mem_base) |
l.lwz r1,0(r1) |
l.movhi r2,hi(_board_mem_size) |
l.ori r2,r2,lo(_board_mem_size) |
l.lwz r2,0(r2) |
l.add r1,r1,r2 |
l.or r2,r1,r1 |
|
l.addi r28,r0,1 /* Constant 64KB in register */ |
l.slli r28,r28,16 |
|
l.add r30,r30,r28 |
l.addi r30,r30,-4 /* SP one word inside next 64KB? */ |
|
l.movhi r26,0xaaaa /* Test pattern to store in memory */ |
l.ori r26,r26,0xaaaa |
|
/* Is this a writeable location? */ |
.L3: l.sw 0(r30),r26 |
l.lwz r24,0(r30) |
l.sfeq r24,r26 |
l.bnf .L4 |
l.nop |
|
l.j .L3 |
l.add r30,r30,r28 /* Try 64KB higher */ |
|
.L4: l.sub r30,r30,r28 /* Previous value was wanted */ |
/* Store stack address in stack variable */ |
l.movhi r26,hi(stack) |
l.ori r26,r26,lo(stack) |
l.sw 0(r26),r30 |
|
/* Initialise stack and frame pointer (set to same value) */ |
l.add r1,r30,r0 |
l.add r2,r30,r0 |
|
/* Clear out the bus error vector special code. */ |
l.movhi r30,hi(__buserr) |
l.ori r30,r30,lo(__buserr) |
l.movhi r28,hi(__buserr_std) |
l.ori r28,r28,lo(__buserr_std) |
l.movhi r26,0x1500 /* l.nop 0 */ |
l.ori r26,r26,0x0000 |
|
.L5: l.sfeq r28,r30 |
l.bf .L6 |
l.sw 0(r26),r1 |
|
/* Initialise cache */ |
/* TODO - potentially make this optional for simulation targets to save |
time during startup */ |
l.jal _cache_init |
l.nop |
|
l.sw 0(r30),r26 /* Patch the instruction */ |
l.j .L5 |
l.addi r30,r30,4 /* Delay slot: next instruction */ |
|
/* Instruction cache enable */ |
/* Check if IC present and skip enabling otherwise */ |
.L6: l.mfspr r24,r0,SPR_UPR |
l.andi r26,r24,SPR_UPR_ICP |
l.sfeq r26,r0 |
l.bf .L8 |
l.nop |
|
/* Disable IC */ |
l.mfspr r6,r0,SPR_SR |
l.addi r5,r0,-1 |
l.xori r5,r5,SPR_SR_ICE |
l.and r5,r6,r5 |
l.mtspr r0,r5,SPR_SR |
|
/* Establish cache block size |
If BS=0, 16; |
If BS=1, 32; |
r14 contain block size |
*/ |
l.mfspr r24,r0,SPR_ICCFGR |
l.andi r26,r24,SPR_ICCFGR_CBS |
l.srli r28,r26,7 |
l.ori r30,r0,16 |
l.sll r14,r30,r28 |
|
/* Establish number of cache sets |
r16 contains number of cache sets |
r28 contains log(# of cache sets) |
*/ |
l.andi r26,r24,SPR_ICCFGR_NCS |
l.srli r28,r26,3 |
l.ori r30,r0,1 |
l.sll r16,r30,r28 |
|
/* Invalidate IC */ |
l.addi r6,r0,0 |
l.sll r5,r14,r28 |
|
.L7: l.mtspr r0,r6,SPR_ICBIR |
l.sfne r6,r5 |
l.bf .L7 |
l.add r6,r6,r14 |
|
/* Enable IC */ |
l.mfspr r6,r0,SPR_SR |
l.ori r6,r6,SPR_SR_ICE |
l.mtspr r0,r6,SPR_SR |
l.nop |
l.nop |
l.nop |
l.nop |
l.nop |
l.nop |
l.nop |
l.nop |
|
/* Data cache enable */ |
/* Check if DC present and skip enabling otherwise */ |
.L8: l.mfspr r24,r0,SPR_UPR |
l.andi r26,r24,SPR_UPR_DCP |
l.sfeq r26,r0 |
l.bf .L10 |
l.nop |
/* Disable DC */ |
l.mfspr r6,r0,SPR_SR |
l.addi r5,r0,-1 |
l.xori r5,r5,SPR_SR_DCE |
l.and r5,r6,r5 |
l.mtspr r0,r5,SPR_SR |
/* Establish cache block size |
If BS=0, 16; |
If BS=1, 32; |
r14 contain block size |
*/ |
l.mfspr r24,r0,SPR_DCCFGR |
l.andi r26,r24,SPR_DCCFGR_CBS |
l.srli r28,r26,7 |
l.ori r30,r0,16 |
l.sll r14,r30,r28 |
/* Establish number of cache sets |
r16 contains number of cache sets |
r28 contains log(# of cache sets) |
*/ |
l.andi r26,r24,SPR_DCCFGR_NCS |
l.srli r28,r26,3 |
l.ori r30,r0,1 |
l.sll r16,r30,r28 |
/* Invalidate DC */ |
l.addi r6,r0,0 |
l.sll r5,r14,r28 |
|
.L9: l.mtspr r0,r6,SPR_DCBIR |
l.sfne r6,r5 |
l.bf .L9 |
l.add r6,r6,r14 |
/* Enable DC */ |
l.mfspr r6,r0,SPR_SR |
l.ori r6,r6,SPR_SR_DCE |
l.mtspr r0,r6,SPR_SR |
|
/* Clear BSS */ |
.L10: l.movhi r28,hi(__bss_start) |
l.ori r28,r28,lo(__bss_start) |
463,11 → 293,17
l.jal atexit |
l.ori r3,r3,lo(__fini) /* Delay slot */ |
|
/* Initialise UART in a C function. If the UART isn't present, we'll */ |
/* link against a dummy function. */ |
l.jal __uart_init |
/* Check if UART is to be initialised */ |
l.movhi r4,hi(_board_uart_base) |
l.ori r4,r4,lo(_board_uart_base) |
l.lwz r4,0(r4) |
l.sfne r4,r0 /* Is base set? If not, no UART */ |
l.bnf .L2 |
l.or r3,r0,r0 |
l.jal __uart_init |
l.nop |
|
.L2: |
/* Jump to main program entry point (argc = argv = envp = 0) */ |
l.or r3,r0,r0 |
l.or r4,r0,r0 |
479,7 → 315,7
l.addi r3,r11,0 /* Delay slot */ |
|
/* Loop forever */ |
.L2: l.j .L2 |
.L3: l.j .L3 |
l.nop |
|
.size _start, .-_start |
/trunk/gnu-src/newlib-1.18.0/libgloss/or32/or1k-support.h
0,0 → 1,51
/* OR1K support defines |
|
Copyright (C) 2011, ORSoC AB |
Copyright (C) 2008, 2010 Embecosm Limited |
|
Contributor Julius Baxter <julius.baxter@orsoc.se> |
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> |
|
This file is part of Newlib. |
|
This program is free software; you can redistribute it and/or modify it |
under the terms of the GNU General Public License as published by the Free |
Software Foundation; either version 3 of the License, or (at your option) |
any later version. |
|
This program is distributed in the hope that it will be useful, but WITHOUT |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
more details. |
|
You should have received a copy of the GNU General Public License along |
with this program. If not, see <http://www.gnu.org/licenses/>. */ |
/* -------------------------------------------------------------------------- */ |
/* This program is commented throughout in a fashion suitable for processing |
with Doxygen. */ |
/* -------------------------------------------------------------------------- */ |
|
/* This machine configuration matches the Or1ksim configuration file in this |
directory. */ |
|
#ifndef OR1K_SUPPORT__H |
#define OR1K_SUPPORT__H |
|
/* External symbols from each board's object file */ |
extern unsigned long _board_clk_freq; |
|
extern unsigned long _board_uart_base; |
extern unsigned long _board_uart_baud; |
extern unsigned long _board_uart_irq; |
|
/* Check if board has UART - test base address */ |
#define BOARD_HAS_UART (_board_uart_base) |
|
/* l.nop constants */ |
#define NOP_EXIT 0x0001 /*!< End of simulation */ |
#define NOP_PUTC 0x0004 /*!< Put a character */ |
|
/*! 8-bit register access macro */ |
#define REG8(add) *((volatile unsigned char *) (add)) |
|
#endif /* OR1K_SUPPORT__H */ |
trunk/gnu-src/newlib-1.18.0/libgloss/or32/or1k-support.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: trunk/gnu-src/newlib-1.18.0/libgloss/or32/lseek.c
===================================================================
--- trunk/gnu-src/newlib-1.18.0/libgloss/or32/lseek.c (revision 506)
+++ trunk/gnu-src/newlib-1.18.0/libgloss/or32/lseek.c (revision 507)
@@ -1,4 +1,4 @@
-/* lseek.c. Implementation of the _lseek syscall for newlib
+/* lseek-uart.c. Implementation of the _lseek syscall for newlib with UART
Copyright (C) 2004, Jacob Bower
Copyright (C) 2010, Embecosm Limited
@@ -32,6 +32,7 @@
#include
#include
+#include "or1k-support.h"
#undef errno
extern int errno;
@@ -38,7 +39,7 @@
/* -------------------------------------------------------------------------- */
-/*!Set a position in a file.
+/*!Set a position in a file when using a UART.
We only support stdin, stdout and stderr for which positioning is always to
offset 0.
@@ -57,7 +58,9 @@
int offset,
int whence)
{
- if ((STDOUT_FILENO == file) || (STDERR_FILENO == file))
+ if ((BOARD_HAS_UART && (STDIN_FILENO == file)) ||
+ (STDOUT_FILENO == file) ||
+ (STDERR_FILENO == file))
{
return 0;
}
@@ -64,6 +67,6 @@
else
{
errno = EBADF;
- return (long) -1;
+ return (long) -1;
}
} /* _lseek () */
/trunk/gnu-src/newlib-1.18.0/libgloss/or32/_interrupt_handler.S
0,0 → 1,222
/* _interrupt_handler.S. OR1K interrupt handling function. |
|
Copyright (C) 2010, 2011, ORSoC AB |
|
Constributor Julius Baxter <julius.baxter@orsoc.se> |
|
This file is part of Newlib. |
|
This program is free software; you can redistribute it and/or modify it |
under the terms of the GNU General Public License as published by the Free |
Software Foundation; either version 3 of the License, or (at your option) |
any later version. |
|
This program is distributed in the hope that it will be useful, but WITHOUT |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
more details. |
|
You should have received a copy of the GNU General Public License along |
with this program. If not, see <http://www.gnu.org/licenses/>. */ |
|
/* |
|
This function is to be called from the exception handler ONLY! It |
relies on the ability to trash all registers due to them having been |
saved on entry to the interrupt exception. |
|
This function should be installed in the exception handler's |
user interrupt exception function slot at reset. |
|
*/ |
|
#include "spr-defs.h" |
|
#define INTERRUPT_HANDLER_NOT_SET -1 |
|
.data |
.align 4 |
.global _interrupt_handler_table |
_interrupt_handler_table: |
_interrupt_handler0: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler1: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler2: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler3: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler4: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler5: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler6: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler7: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler8: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler9: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler10: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler11: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler12: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler13: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler14: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler15: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler16: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler17: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler18: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler19: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler20: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler21: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler22: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler23: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler24: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler25: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler26: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler27: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler28: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler29: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler30: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler31: .long INTERRUPT_HANDLER_NOT_SET |
|
.global _interrupt_handler_data_ptr_table |
_interrupt_handler_data_ptr_table: |
_interrupt_handler_data_ptr0: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr1: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr2: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr3: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr4: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr5: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr6: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr7: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr8: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr9: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr10: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr11: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr12: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr13: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr14: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr15: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr16: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr17: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr18: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr19: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr20: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr21: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr22: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr23: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr24: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr25: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr26: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr27: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr28: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr29: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr30: .long INTERRUPT_HANDLER_NOT_SET |
_interrupt_handler_data_ptr31: .long INTERRUPT_HANDLER_NOT_SET |
|
|
/* -------------------------------------------------------------------------- */ |
/*!Function to call appropriate interrupt handler |
*/ |
/* -------------------------------------------------------------------------- */ |
|
.section .text |
.global _interrupt_handler |
.type _interrupt_handler,@function |
|
_interrupt_handler: |
/* Make room on stack, save link register */ |
l.addi r1,r1,-12 |
l.sw 0(r1),r9 |
|
/* Read PICSR */ |
l.mfspr r3,r0,SPR_PICSR |
|
/* Load handler table base address */ |
l.movhi r7,hi(_interrupt_handler_table) |
l.ori r7,r7,lo(_interrupt_handler_table) |
/* Check to see if this handler has been set yet */ |
l.movhi r8,hi(INTERRUPT_HANDLER_NOT_SET) |
l.ori r8,r8,lo(INTERRUPT_HANDLER_NOT_SET) |
/* Load data pointer table base address */ |
l.movhi r12,hi(_interrupt_handler_data_ptr_table) |
l.ori r12,r12,lo(_interrupt_handler_data_ptr_table) |
|
.L0: |
/* Find first set bit in PICSR */ |
l.ff1 r4,r3 |
/* Any bits set? */ |
l.sfne r4,r0 |
/* If none, finish */ |
l.bnf .L2 |
l.nop |
/* What is IRQ function table offset? */ |
l.addi r5,r4,-1 |
l.slli r6,r5,2 |
/* Add this to table bases */ |
l.add r6,r6,r7 |
l.add r13,r6,r12 |
|
/* Fetch handler function address */ |
l.lwz r6,0(r6) |
|
/* Double check it's valid, compare against INTERRUPT_HANDLER_NOT_SET */ |
l.sfne r6,r8 |
/* Skip if no handler: TODO: Indicate interrupt fired but no handler*/ |
l.bnf .L1 |
l.nop |
|
/* Pull out data pointer from table, save r3, we'll write over it */ |
l.sw 4(r1),r3 |
l.lwz r3,0(r13) |
/* Call handler, save r5 in delay slot */ |
l.jalr r5 |
l.sw 8(r1),r5 |
|
/* Reload r3,r5 */ |
l.lwz r3,4(r1) |
l.lwz r5,8(r1) |
.L1: |
/* Clear bit from PICSR, return to start of checking loop */ |
l.ori r6,r0,1 |
l.sll r6,r6,r5 |
l.j .L0 |
l.xor r3,r3,r6 |
|
.L2: |
/* Finish up - write PICSR back, restore r9*/ |
l.lwz r9,0(r1) |
l.mtspr r0,r3,SPR_PICSR |
l.jr r9 |
l.addi r1,r1,12 |
|
|
|
/* -------------------------------------------------------------------------- */ |
/*!Function to add handler to table |
*/ |
/* -------------------------------------------------------------------------- */ |
.global _interrupt_handler_add |
.type _interrupt_handler_add,@function |
|
/* r3 should have IRQ line for peripheral */ |
/* r4 should have handler function address */ |
_interrupt_handler_add: |
l.addi r1,r1,-4 |
l.sw 0(r1),r6 |
/* Convert interrupt number into word address */ |
l.slli r3,r3,2 |
l.addi r3,r3,-4 |
/* Get address of interrupt handler table */ |
l.movhi r6,hi(_interrupt_handler_table) |
l.ori r6,r6,lo(_interrupt_handler_table) |
/* Add handler offset to table base */ |
l.add r6,r6,r3 |
/* Store handler function address */ |
l.sw 0(r6),r4 |
/* Get address of interrupt handler data ptr table */ |
l.movhi r6,hi(_interrupt_handler_data_ptr_table) |
l.ori r6,r6,lo(_interrupt_handler_data_ptr_table) |
/* Add handler offset to table base */ |
l.add r6,r6,r3 |
/* Store handler data pointer address */ |
l.sw 0(r6),r5 |
/* Restore r6 */ |
l.lwz r6,0(r1) |
/* Return via link register */ |
l.jr r9 |
/* Restore stack value */ |
l.addi r1,r1,4 |
|
/trunk/gnu-src/newlib-1.18.0/libgloss/or32/_exit.c
29,7 → 29,7
with Doxygen. */ |
/* -------------------------------------------------------------------------- */ |
|
#include "or1ksim-board.h" |
#include "or1k-support.h" |
|
|
/* -------------------------------------------------------------------------- */ |
/trunk/gnu-src/newlib-1.18.0/libgloss/or32/_exception_handler.S
0,0 → 1,205
/* _exception_handler.S. OR1K exception handling function. |
|
Copyright (C) 2010, 2011, ORSoC AB |
|
Constributor Julius Baxter <julius.baxter@orsoc.se> |
|
This file is part of Newlib. |
|
This program is free software; you can redistribute it and/or modify it |
under the terms of the GNU General Public License as published by the Free |
Software Foundation; either version 3 of the License, or (at your option) |
any later version. |
|
This program is distributed in the hope that it will be useful, but WITHOUT |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
more details. |
|
You should have received a copy of the GNU General Public License along |
with this program. If not, see <http://www.gnu.org/licenses/>. */ |
|
|
#include "spr-defs.h" |
|
// Warning - this must be the same as specified in crt0.S |
#define EXCEPTION_STACK_SIZE 128 |
|
// Value handler addresses are initialised to |
#define EXCEPTION_HANDLER_NOT_SET -1 |
|
.data |
.align 4 |
.global _exception_handler_table |
_exception_handler_table: |
_exception_handler_buserr: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_dpfault: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_ipfault: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_tick: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_align: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_illegal: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_interrupt: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_dtlbmiss: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_itlbmiss: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_range: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_systemcall: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_float: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_trap: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_reserved0: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_reserved1: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_reserved2: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_reserved3: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_reserved4: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_reserved5: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_reserved6: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_reserved7: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_reserved8: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_reserved9: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_reserved10: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_reserved11: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_reserved12: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_reserved13: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_reserved14: .long EXCEPTION_HANDLER_NOT_SET |
_exception_handler_reserved15: .long EXCEPTION_HANDLER_NOT_SET |
|
/* -------------------------------------------------------------------------- */ |
/*!Function to call appropriate exception handler |
*/ |
/* -------------------------------------------------------------------------- */ |
|
.section .text |
.global _exception_handler |
.type _exception_handler,@function |
|
/* |
r3 = address of exception vector |
r4 = address where exception occurred |
*/ |
|
_exception_handler: |
/* Store remainder of state (r3,r4 stored in vector entry)*/ |
l.sw 0x00(r1), r2 |
l.sw 0x0c(r1), r5 |
l.sw 0x10(r1), r6 |
l.sw 0x14(r1), r7 |
l.sw 0x18(r1), r8 |
l.sw 0x1c(r1), r9 |
l.sw 0x20(r1), r10 |
l.sw 0x24(r1), r11 |
l.sw 0x28(r1), r12 |
l.sw 0x2c(r1), r13 |
l.sw 0x30(r1), r14 |
l.sw 0x34(r1), r15 |
l.sw 0x38(r1), r16 |
l.sw 0x3c(r1), r17 |
l.sw 0x40(r1), r18 |
l.sw 0x44(r1), r19 |
l.sw 0x48(r1), r20 |
l.sw 0x4c(r1), r21 |
l.sw 0x50(r1), r22 |
l.sw 0x54(r1), r23 |
l.sw 0x58(r1), r24 |
l.sw 0x5c(r1), r25 |
l.sw 0x60(r1), r26 |
l.sw 0x64(r1), r27 |
l.sw 0x68(r1), r28 |
l.sw 0x6c(r1), r29 |
l.sw 0x70(r1), r30 |
l.sw 0x74(r1), r31 |
|
/* Determine offset in table of exception handler using r3*/ |
l.andi r13,r3,0xffff |
l.srli r13,r13,6 |
/* Substract 2 words, as we have no vector at 0 and no reset handler */ |
l.addi r13,r13,-8 |
/* r13 now contains offset in _exception_handler_table for function */ |
/* Get _exception_handler_table address */ |
l.movhi r14,hi(_exception_handler_table) |
l.ori r14,r14,lo(_exception_handler_table) |
/* r14 now contains base of exception handler table */ |
l.add r14,r14,r13 |
l.lwz r13, 0(r14) |
|
/* Check to see if this handler has been set yet */ |
l.movhi r15,hi(EXCEPTION_HANDLER_NOT_SET) |
l.ori r15,r15,lo(EXCEPTION_HANDLER_NOT_SET) |
l.sfne r13,r15 |
l.bnf .L1 |
l.nop |
|
/* Call exception handler, copy EPCR to r3 */ |
l.jalr r13 |
l.or r3,r4,r4 |
|
/* Restore state */ |
l.lwz r2, 0x00(r1) |
l.lwz r3, 0x04(r1) |
l.lwz r4, 0x08(r1) |
l.lwz r5, 0x0c(r1) |
l.lwz r6, 0x10(r1) |
l.lwz r7, 0x14(r1) |
l.lwz r8, 0x18(r1) |
l.lwz r9, 0x1c(r1) |
l.lwz r10, 0x20(r1) |
l.lwz r11, 0x24(r1) |
l.lwz r12, 0x28(r1) |
l.lwz r13, 0x2c(r1) |
l.lwz r14, 0x30(r1) |
l.lwz r15, 0x34(r1) |
l.lwz r16, 0x38(r1) |
l.lwz r17, 0x3c(r1) |
l.lwz r18, 0x40(r1) |
l.lwz r19, 0x44(r1) |
l.lwz r20, 0x48(r1) |
l.lwz r21, 0x4c(r1) |
l.lwz r22, 0x50(r1) |
l.lwz r23, 0x54(r1) |
l.lwz r24, 0x58(r1) |
l.lwz r25, 0x5c(r1) |
l.lwz r26, 0x60(r1) |
l.lwz r27, 0x64(r1) |
l.lwz r28, 0x68(r1) |
l.lwz r29, 0x6c(r1) |
l.lwz r30, 0x70(r1) |
l.lwz r31, 0x74(r1) |
|
l.addi r1, r1, EXCEPTION_STACK_SIZE |
|
l.rfe |
l.nop |
|
.L1: |
/* Exception handler not set, exit */ |
l.jal exit |
l.or r3,r4,r4 |
|
|
/* -------------------------------------------------------------------------- */ |
/*!Function to add handler to table |
*/ |
/* -------------------------------------------------------------------------- */ |
.global _exception_handler_add |
.type _exception_handler_add,@function |
|
/* r3 should have exception number (2 for buserr, 5 for tick, etc.) */ |
/* r4 should have handler function address */ |
_exception_handler_add: |
l.addi r1,r1,-4 |
l.sw 0(r1),r5 |
/* Convert exception number into word address */ |
l.slli r3,r3,2 |
l.addi r3,r3,-8 |
/* Get address of exception handler table */ |
l.movhi r5,hi(_exception_handler_table) |
l.ori r5,r5,lo(_exception_handler_table) |
/* Add handler offset to table base */ |
l.add r5,r5,r3 |
/* Store handler function address */ |
l.sw 0(r5),r4 |
/* Restore r5 */ |
l.lwz r5,0(r1) |
/* Return via link register */ |
l.jr r9 |
/* Restore stack value */ |
l.addi r1,r1,4 |
|
/trunk/gnu-src/newlib-1.18.0/libgloss/or32/uart.c
29,12 → 29,11
with Doxygen. */ |
/* -------------------------------------------------------------------------- */ |
|
#include "or1ksim-board.h" |
#include "or1k-support.h" |
#include "uart.h" |
|
|
/*! Macro to access a UART register */ |
#define UREG8(reg) REG8 (UART_BASE + reg) |
#define UREG8(reg) REG8 (_board_uart_base + reg) |
|
/*! Macro to check if transmit and transmit holding registers are both empty. */ |
#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) |
86,7 → 85,7
UREG8 (UART_LCR) = UART_LCR_WLEN8 & ~(UART_LCR_STOP | UART_LCR_PARITY); |
|
/* Set baud rate */ |
divisor = IN_CLK / (16 * UART_BAUD_RATE); |
divisor = _board_clk_freq / (16 * _board_uart_baud); |
|
UREG8 (UART_LCR) |= UART_LCR_DLAB; |
UREG8 (UART_DLL) = divisor & 0x000000ff; |
/trunk/gnu-src/newlib-1.18.0/libgloss/or32/orpsocrefdesign.S
0,0 → 1,21
/* |
* Define symbols to be used during startup - file is linked at compile time |
* |
*/ |
.global _board_mem_base |
.global _board_mem_size |
.global _board_clk_freq |
|
_board_mem_base: .long 0x0 |
_board_mem_size: .long 0x800000 |
|
_board_clk_freq: .long 50000000 |
|
/* Peripheral information - Set base to 0 if not present*/ |
.global _board_uart_base |
.global _board_uart_baud |
.global _board_uart_IRQ |
|
_board_uart_base: .long 0 |
_board_uart_baud: .long 115200 |
_board_uart_IRQ: .long 2 |
/trunk/gnu-src/newlib-1.18.0/libgloss/or32/isatty.c
1,4 → 1,4
/* isatty.c. Implementation of the _isatty syscall for newlib |
/* isatty-uart.c. Implementation of the _isatty syscall for newlib with UART |
|
Copyright (C) 2004, Jacob Bower |
Copyright (C) 2010, Embecosm Limited <info@embecosm.com> |
32,6 → 32,7
#include <errno.h> |
#include <unistd.h> |
|
#include "or1k-support.h" |
|
#undef ERRNO |
extern int errno; |
38,10 → 39,10
|
|
/* -------------------------------------------------------------------------- */ |
/*!Is a file a TTY? |
/*!Is a file a TTY when using a UART? |
|
We only support stdout and stderr to the console, so we are always a TTY |
for these. |
We only support stdin, stdout and stderr to the console, so we are always a |
TTY for these. |
|
Remember that this function is *not* reentrant, so no static state should |
be held. |
54,7 → 55,9
int |
_isatty (int file) |
{ |
if ((file == STDOUT_FILENO) || (file == STDERR_FILENO)) |
if ((BOARD_HAS_UART && (file == STDIN_FILENO)) || |
(file == STDOUT_FILENO) || |
(file == STDERR_FILENO)) |
{ |
return 1; |
} |
/trunk/gnu-src/newlib-1.18.0/libgloss/or32/ml501.S
0,0 → 1,21
/* |
* Define symbols to be used during startup - file is linked at compile time |
* |
*/ |
.global _board_mem_base |
.global _board_mem_size |
.global _board_clk_freq |
|
_board_mem_base: .long 0x0 |
_board_mem_size: .long 0x800000 |
|
_board_clk_freq: .long 66666666 |
|
/* Peripheral information - Set base to 0 if not present*/ |
.global _board_uart_base |
.global _board_uart_baud |
.global _board_uart_IRQ |
|
_board_uart_base: .long 0x90000000 |
_board_uart_baud: .long 115200 |
_board_uart_IRQ: .long 2 |
/trunk/gnu-src/newlib-1.18.0/libgloss/or32/fstat.c
1,4 → 1,4
/* fstat.c. Implementation of the _fstat syscall for newlib |
/* fstat-uart.c. Implementation of the _fstat syscall for newlib with UART |
|
Copyright (C) 2004, Jacob Bower |
Copyright (C) 2010, Embecosm Limited <info@embecosm.com> |
33,6 → 33,7
#include <sys/stat.h> |
#include <unistd.h> |
|
#include "or1k-support.h" |
|
#undef errno |
extern int errno; |
39,10 → 40,10
|
|
/* -------------------------------------------------------------------------- */ |
/*!Status of an open file. |
/*!Status of an open file when using a UART |
|
We only know about stdout and stderr, and treat these as character special |
files. All other files are erroneous. |
We only know about stdin, stdout and stderr, and treat these as character |
special files. All other files are erroneous. |
|
Remember that this function is *not* reentrant, so no static state should |
be held. |
54,7 → 55,9
_fstat (int file, |
struct stat *st) |
{ |
if ((STDOUT_FILENO == file) || (STDERR_FILENO == file)) |
if ((BOARD_HAS_UART && (STDIN_FILENO == file)) || |
(STDERR_FILENO == file) || |
(STDOUT_FILENO == file)) |
{ |
st->st_mode = S_IFCHR; |
return 0; |
/trunk/gnu-src/newlib-1.18.0/libgloss/or32/write.c
32,7 → 32,7
#include <errno.h> |
#include <unistd.h> |
|
#include "or1ksim-board.h" |
#include "or1k-support.h" |
|
|
#undef errno |
47,10 → 47,18
static void |
outbyte (char c) |
{ |
register char t1 asm ("r3") = c; |
|
asm volatile ("\tl.nop\t%0" : : "K" (NOP_PUTC), "r" (t1)); |
|
|
if (BOARD_HAS_UART) |
{ |
__uart_putc (c); |
} |
else |
{ |
register char t1 asm ("r3") = c; |
|
asm volatile ("\tl.nop\t%0" : : "K" (NOP_PUTC), "r" (t1)); |
} |
|
} /* outbyte () */ |
|
|
/trunk/gnu-src/boards/or32-elf-sim.exp
48,11 → 48,11
# doesn't work with the standard expect commands, and will end up generating a |
# blank -isystem option, which confuses things severely. |
|
# It's sufficient just to specify -mor32-newlib. Bit of a shame to specify it |
# both in cflags, which are also used when linking, so we'll get the libraries |
# OK as well. |
# It's sufficient just to specify -mnewlib. Bit of a shame to |
# specify it both in cflags, which are also used when linking, so we'll get |
# the libraries OK as well. |
set_board_info compiler "[find_gcc]" |
set_board_info cflags "-mor32-newlib" |
set_board_info cflags "-mnewlib -mboard=or1ksim" |
|
# No linker script needed. |
set_board_info ldscript "" |