Discussion:
[OpenRISC] [Openrisc] [Newlib] Board exit should cause sim exit
Matthew Hicks
2014-10-27 17:17:54 UTC
Permalink
It would be nice if the board exit stub caused the simulator to exit.
Attached is a patch that implements this.

diff --git a/libgloss/or1k/board_tmpl.S b/libgloss/or1k/board_tmpl.S
index d45b072..5a1c545 100644
--- a/libgloss/or1k/board_tmpl.S
+++ b/libgloss/or1k/board_tmpl.S
@@ -27,7 +27,7 @@ _board_uart_IRQ: .long 0
// TODO: Board exit function, default: loop
.weak _board_exit
_board_exit:
- OR1K_DELAYED_NOP(l.j _board_exit)
+ OR1K_EXIT_NOP(l.j _board_exit)

// TODO: Early initialization (if really needed!)
.global _board_init_early
diff --git a/libgloss/or1k/de0_nano.S b/libgloss/or1k/de0_nano.S
index 6370c57..e87fe1c 100644
--- a/libgloss/or1k/de0_nano.S
+++ b/libgloss/or1k/de0_nano.S
@@ -24,7 +24,7 @@ _board_uart_IRQ: .long 13

.weak _board_exit
_board_exit:
- OR1K_DELAYED_NOP(l.j _board_exit)
+ OR1K_EXIT_NOP(l.j _board_exit)

.global _board_init_early
_board_init_early:
diff --git a/libgloss/or1k/ml501.S b/libgloss/or1k/ml501.S
index b8adfe8..f3dbfed 100644
--- a/libgloss/or1k/ml501.S
+++ b/libgloss/or1k/ml501.S
@@ -24,7 +24,7 @@ _board_uart_IRQ: .long 2

.weak _board_exit
_board_exit:
- OR1K_DELAYED_NOP(l.j _board_exit)
+ OR1K_EXIT_NOP(l.j _board_exit)

.global _board_init_early
_board_init_early:
diff --git a/libgloss/or1k/or1ksim-uart.S b/libgloss/or1k/or1ksim-uart.S
index abf2c6a..d664bd4 100644
--- a/libgloss/or1k/or1ksim-uart.S
+++ b/libgloss/or1k/or1ksim-uart.S
@@ -27,8 +27,7 @@ _board_uart_IRQ: .long 13

.weak _board_exit
_board_exit:
- l.nop NOP_EXIT_SILENT
- OR1K_DELAYED_NOP(l.j _board_exit)
+ OR1K_EXIT_NOP(l.j _board_exit)

.global _board_init_early
_board_init_early:
diff --git a/libgloss/or1k/or1ksim.S b/libgloss/or1k/or1ksim.S
index 1aae0ba..363ec09 100644
--- a/libgloss/or1k/or1ksim.S
+++ b/libgloss/or1k/or1ksim.S
@@ -25,8 +25,7 @@ _board_uart_IRQ: .long 13

.weak _board_exit
_board_exit:
- l.nop NOP_EXIT_SILENT
- OR1K_DELAYED_NOP(l.j _board_exit)
+ OR1K_EXIT_NOP(l.j _board_exit)

.global _board_init_early
_board_init_early:
diff --git a/libgloss/or1k/ordb1a3pe1500.S b/libgloss/or1k/ordb1a3pe1500.S
index 4db8f2a..19bb734 100644
--- a/libgloss/or1k/ordb1a3pe1500.S
+++ b/libgloss/or1k/ordb1a3pe1500.S
@@ -24,7 +24,7 @@ _board_uart_IRQ: .long 2

.weak _board_exit
_board_exit:
- OR1K_DELAYED_NOP(l.j _board_exit)
+ OR1K_EXIT_NOP(l.j _board_exit)

.global _board_init_early
_board_init_early:
diff --git a/libgloss/or1k/ordb2a.S b/libgloss/or1k/ordb2a.S
index 3208a49..dca979a 100644
--- a/libgloss/or1k/ordb2a.S
+++ b/libgloss/or1k/ordb2a.S
@@ -24,7 +24,7 @@ _board_uart_IRQ: .long 2

.weak _board_exit
_board_exit:
- OR1K_DELAYED_NOP(l.j _board_exit)
+ OR1K_EXIT_NOP(l.j _board_exit)

.global _board_init_early
_board_init_early:
diff --git a/libgloss/or1k/orpsocrefdesign.S
b/libgloss/or1k/orpsocrefdesign.S
index dabcda6..1724db3 100644
--- a/libgloss/or1k/orpsocrefdesign.S
+++ b/libgloss/or1k/orpsocrefdesign.S
@@ -24,7 +24,7 @@ _board_uart_IRQ: .long 2

.weak _board_exit
_board_exit:
- OR1K_DELAYED_NOP(l.j _board_exit)
+ OR1K_EXIT_NOP(l.j _board_exit)

.global _board_init_early
_board_init_early:
diff --git a/newlib/libc/machine/or1k/include/or1k-asm.h
b/newlib/libc/machine/or1k/include/or1k-asm.h
index 0e45939..0e91606 100644
--- a/newlib/libc/machine/or1k/include/or1k-asm.h
+++ b/newlib/libc/machine/or1k/include/or1k-asm.h
@@ -27,6 +27,7 @@

#define OR1K_DELAYED(a, b) a; b
#define OR1K_DELAYED_NOP(a) a
+#define OR1K_EXIT_NOP(a) l.nop 0x1; a

/* Go ahead and emit the .nodelay directive when in no-delay mode, so
that the flags are appropriately set in the binary. */
@@ -36,11 +37,13 @@

#define OR1K_DELAYED(a, b) b; a
#define OR1K_DELAYED_NOP(a) a; l.nop
+#define OR1K_EXIT_NOP(a) a; l.nop 0x1

#elif defined(__OR1K_DELAY_COMPAT__)

#define OR1K_DELAYED(a, b) a; b; l.nop
#define OR1K_DELAYED_NOP(a) a; l.nop
+#define OR1K_EXIT_NOP(a) a; l.nop 0x1

#else
Stefan Wallentowitz
2014-11-04 08:06:29 UTC
Permalink
Post by Matthew Hicks
It would be nice if the board exit stub caused the simulator to exit.
Attached is a patch that implements this.
I changed it slightly, as permanently issuing the EXIT nop may get
annoying if the system continues running:
https://github.com/wallento/or1k-newlib/commit/648698ac76ec8feb2ad7ec334908c578483b44c7

Thanks a lot.

Bye,
Stefan

Loading...