source: npl/system/klibc/patches/0003-add-mips64-support-arch-mips64-specific.patch

Last change on this file was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[c5c522c]1From: Dejan Latinovic <Dejan.Latinovic@imgtec.com>
2Date: Thu, 5 Mar 2015 16:51:45 -0800
3Subject: [PATCH 3/3] add-mips64-support-arch-mips64-specific
4Origin: https://git.kernel.org/cgit/libs/klibc/klibc.git/commit/?id=3438d861da2e6939a6b0d454ffe247c19ead5993
5
6Description: Adding mips64 specific chagnes.
7Modeled on mips 32 and adapted for 64 bit ABI.
8 - MCONFIG:  using existing klibc.ld scrpit
9 - crt0.S:   adapted gp initialization
10 - setjmp.S: do not save floating-point state
11---
12 usr/klibc/arch/mips64/MCONFIG  |  2 ++
13 usr/klibc/arch/mips64/crt0.S   | 31 ++++++++++++++++++++++++++
14 usr/klibc/arch/mips64/setjmp.S | 50 ++++++++++++++++++++++++++++++++++++++++++
15 3 files changed, 83 insertions(+)
16 create mode 100644 usr/klibc/arch/mips64/crt0.S
17 create mode 100644 usr/klibc/arch/mips64/setjmp.S
18
19diff --git a/usr/klibc/arch/mips64/MCONFIG b/usr/klibc/arch/mips64/MCONFIG
20index 5c50b8d..b37cc6a 100644
21--- a/usr/klibc/arch/mips64/MCONFIG
22+++ b/usr/klibc/arch/mips64/MCONFIG
23@@ -9,3 +9,5 @@
24 
25 KLIBCOPTFLAGS += -Os
26 KLIBCBITSIZE  = 64
27+
28+KLIBCSHAREDFLAGS  = -T $(src)/arch/mips/klibc.ld
29diff --git a/usr/klibc/arch/mips64/crt0.S b/usr/klibc/arch/mips64/crt0.S
30new file mode 100644
31index 0000000..775a919
32--- /dev/null
33+++ b/usr/klibc/arch/mips64/crt0.S
34@@ -0,0 +1,31 @@
35+#
36+# arch/mips64/crt0.S
37+#
38+# Does arch-specific initialization and invokes __libc_init
39+# with the appropriate arguments.
40+#
41+# See __static_init.c or __shared_init.c for the expected
42+# arguments.
43+#
44+
45+#include <machine/asm.h>
46+
47+NESTED(__start, 64, sp)
48+       daddiu  sp,sp,-64
49+       sd      zero, 32(sp)
50+
51+                                       # Initialize gp
52+       lui gp,%highest(_gp)            # load highest "halfword"
53+       daddiu gp,gp,%higher(_gp)       # merge next "halfword"
54+       dsll gp,gp,16                   # shift by one halfword
55+       daddiu gp,gp,%hi(_gp)           # merge next "halfword"
56+       dsll gp,gp,16                   # shift into final position
57+       daddiu gp,gp,%lo(_gp)           # merge lowest "halfword"
58+
59+       daddiu  a0, sp, 64              # Pointer to ELF entry structure
60+       move    a1, v0                  # Kernel-provided atexit() pointer
61+
62+       ld  t9, %call16(__libc_init)(gp)
63+       jalr t9
64+
65+       END(__start)
66diff --git a/usr/klibc/arch/mips64/setjmp.S b/usr/klibc/arch/mips64/setjmp.S
67new file mode 100644
68index 0000000..5d902e2
69--- /dev/null
70+++ b/usr/klibc/arch/mips64/setjmp.S
71@@ -0,0 +1,50 @@
72+#
73+# arch/mips64/setjmp.S
74+#
75+# setjmp/longjmp for the MIPS architecture
76+#
77+# The jmp_buf is assumed to contain the following, in order:
78+#      s0..s7
79+#      gp
80+#      sp
81+#      s8
82+#      ra
83+#
84+
85+#include <machine/asm.h>
86+
87+LEAF(setjmp)
88+       sd      s0,  0(a0)
89+       sd      s1,  8(a0)
90+       sd      s2, 16(a0)
91+       sd      s3, 24(a0)
92+       sd      s4, 32(a0)
93+       sd      s5, 40(a0)
94+       sd      s6, 48(a0)
95+       sd      s7, 56(a0)
96+       sd      gp, 64(a0)
97+       sd      sp, 72(a0)
98+       sd      s8, 80(a0)
99+       sd      ra, 88(a0)
100+       move    v0, zero
101+       jr      ra
102+
103+       END(setjmp)
104+
105+LEAF(longjmp)
106+       ld      s0,  0(a0)
107+       ld      s1,  8(a0)
108+       ld      s2, 16(a0)
109+       ld      s3, 24(a0)
110+       ld      s4, 32(a0)
111+       ld      s5, 40(a0)
112+       ld      s6, 48(a0)
113+       ld      s7, 56(a0)
114+       ld      gp, 64(a0)
115+       ld      sp, 72(a0)
116+       ld      s8, 80(a0)
117+       ld      ra, 88(a0)
118+       move    v0, a1
119+       jr      ra
120+
121+       END(longjmp)
122--
1232.4.5
124
Note: See TracBrowser for help on using the repository browser.