[committed] libgloss: pru: Add support for older PRU cores

Dimitar Dimitrov <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
Do not use FILL/ZERO instructions in CRT0 and syscalls.  These
instructions are not supported by older PRU cores in AM18xx SoCs.

Avoiding FILL/ZERO does increase the code size a bit, but it has no
impact on real projects because:
  - syscalls.S is used only by firmware built for the GNU Simulator.
  - Real firmware projects are supposed to use crt0-min.S, which is not
    impacted.
  - crt0.S is intended to be full-featured, so that can be used for
    regression testing GCC using GNU Simulator.

An alternative would be to add a special crt0-am18xx.S variant, but that
would add unnecessary complexity.

Pushed as 7f2a1f19b7badc63af121866c46d155591015407.

Signed-off-by: Dimitar Dimitrov <[email protected]>
---
 libgloss/pru/crt0.S     | 9 +++++++--
 libgloss/pru/syscalls.S | 8 ++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/libgloss/pru/crt0.S b/libgloss/pru/crt0.S
index ad31cc9cc..cf600d6e1 100644
--- a/libgloss/pru/crt0.S
+++ b/libgloss/pru/crt0.S
@@ -60,8 +60,13 @@ ctors_loop:
 	jmp	ctors_loop
 ctors_done:
 
-	/* Just in case main() tries to access argc, argv[] and envp. */
-	zero	r14, 3 * 4
+	/* Just in case main() tries to access argc, argv[] and envp.
+	   Do not use "zero" instruction because it is not available on
+	   older cores.  Increased code size is not a concern - real
+	   firmware projects should use crt0-minrt anyway.  */
+	ldi	r14, 0
+	ldi	r15, 0
+	ldi	r16, 0
 
 	.weak __c_args__
 	ldi32	r5, __c_args__
diff --git a/libgloss/pru/syscalls.S b/libgloss/pru/syscalls.S
index 80486d1f9..1e77fc0dd 100644
--- a/libgloss/pru/syscalls.S
+++ b/libgloss/pru/syscalls.S
@@ -45,8 +45,12 @@ __SC_ret:
 	ldi32	r1, _impure_ptr
 	lbbo	r1, r1, 0, 4
 	sbbo	r14, r1, 0, 4
-	/* Return -1 (for both int32_t or int64_t).  */
-	fill	r14, 8
+	/* Return -1 (for both int32_t or int64_t).
+	   Do not use "fill" instruction because it is not available on
+	   older cores.  Increased code size is not a concern - syscalls
+	   are used only by the simulator.  */
+	ldi32	r14, -1
+	ldi32	r15, -1
 
 __SC_ret_skip_errno_set:
 	ret
-- 
2.51.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.