Skip to content

Commit 3440aec

Browse files
Francisco Javier Trujillo Matafjtrujy
authored andcommitted
Add specific r5900 machine and ps2 sys
- Do not use libgloss (we have ps2sdk) - Use newlib reentrant syscalls - Use posix functions - Exclude OPENDIR functions - Add -G0 in the newlib_cflags - Fix time.h should have nanosleep defined - Fix setjmp for R5900 CPU - Add _POSIX_MONOTONIC_CLOCK to features - Create dummy.c file because looks to have an issue in newlib
1 parent cbea62b commit 3440aec

13 files changed

Lines changed: 179 additions & 2 deletions

File tree

newlib/configure.host

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ case "${host_cpu}" in
248248
mep)
249249
machine_dir=mep
250250
;;
251+
mips64r5900*)
252+
machine_dir=r5900
253+
newlib_cflags="${newlib_cflags} -DMALLOC_ALIGNMENT=16"
254+
;;
251255
mips*)
252256
machine_dir=mips
253257
libm_machine_dir=mips
@@ -539,6 +543,11 @@ case "${host}" in
539543
microblaze*-*-*)
540544
machine_dir=microblaze
541545
;;
546+
mips*-ps2-*)
547+
sys_dir=ps2
548+
posix_dir=posix
549+
newlib_cflags="${newlib_cflags} -G0 -DHAVE_NANOSLEEP -DHAVE_OPENDIR"
550+
;;
542551
mmix-knuth-mmixware)
543552
sys_dir=mmixware
544553
;;
@@ -778,6 +787,10 @@ newlib_cflags="${newlib_cflags} -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DEXIT_PROVID
778787
default_newlib_io_long_long="yes"
779788
newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
780789
;;
790+
mips*-ps2-elf*)
791+
syscall_dir=syscalls
792+
default_newlib_io_long_long="yes"
793+
;;
781794
mips*-*-elf*)
782795
default_newlib_io_long_long="yes"
783796
newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"

newlib/libc/acinclude.m4

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ m4_foreach_w([SYS_DIR], [
1919
m88kbug mmixware
2020
netware
2121
or1k
22+
ps2
2223
rdos rtems
2324
sh sysmec sysnec810 sysnecv850 sysvi386 sysvnecv70
2425
tic80 tirtos
@@ -54,7 +55,7 @@ m4_foreach_w([MACHINE], [
5455
nds32 necv70 nios2 nvptx
5556
or1k
5657
powerpc pru
57-
riscv rl78 rx
58+
r5900 riscv rl78 rx
5859
sh sparc spu
5960
tic4x tic6x tic80
6061
v850 visium

newlib/libc/include/machine/setjmp.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,17 @@ _BEGIN_STD_C
129129

130130
#ifdef __mips__
131131
# if defined(__mips64)
132-
# define _JBTYPE long long
132+
# if defined(_MIPS_ARCH_R5900)
133+
typedef unsigned int jbtype128 __attribute__(( mode(TI) ));
134+
# define _JBTYPE jbtype128
135+
# else
136+
# define _JBTYPE long long
137+
# endif
133138
# endif
134139
# ifdef __mips_soft_float
135140
# define _JBLEN 11
141+
# elif defined(_MIPS_ARCH_R5900)
142+
# define _JBLEN 14
136143
# else
137144
# define _JBLEN 23
138145
# endif

newlib/libc/include/sys/features.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,11 @@ extern "C" {
570570

571571
#endif /* __CYGWIN__ */
572572

573+
#ifdef _MIPS_ARCH_R5900
574+
# define _POSIX_TIMERS 1
575+
# define _POSIX_MONOTONIC_CLOCK 200112L
576+
#endif
577+
573578
#ifdef __cplusplus
574579
}
575580
#endif

newlib/libc/machine/Makefile.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ endif
127127
if HAVE_LIBC_MACHINE_PRU
128128
include %D%/pru/Makefile.inc
129129
endif
130+
if HAVE_LIBC_MACHINE_R5900
131+
include %D%/r5900/Makefile.inc
132+
endif
130133
if HAVE_LIBC_MACHINE_RISCV
131134
include %D%/riscv/Makefile.inc
132135
endif
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
libc_a_SOURCES += %D%/setjmp.S

newlib/libc/machine/r5900/setjmp.S

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/* This is a simple version of setjmp and longjmp.
2+
* Floating point support in. */
3+
4+
#define O_S0 0x00
5+
#define O_S1 0x10
6+
#define O_S2 0x20
7+
#define O_S3 0x30
8+
#define O_S4 0x40
9+
#define O_S5 0x50
10+
#define O_S6 0x60
11+
#define O_S7 0x70
12+
#define O_FP 0x80
13+
#define O_SP 0x90
14+
#define O_RA 0xa0
15+
#define O_F20 0xb0
16+
#define O_F21 0xb4
17+
#define O_F22 0xb8
18+
#define O_F23 0xbc
19+
#define O_F24 0xc0
20+
#define O_F25 0xc4
21+
#define O_F26 0xc8
22+
#define O_F27 0xcc
23+
#define O_F28 0xd0
24+
#define O_F29 0xd4
25+
#define O_F30 0xd8
26+
#define O_F31 0xdc
27+
28+
/* int setjmp (jmp_buf); */
29+
.globl setjmp
30+
.ent setjmp
31+
setjmp:
32+
.frame $sp,0,$31
33+
34+
sq $s0, O_S0($a0)
35+
sq $s1, O_S1($a0)
36+
sq $s2, O_S2($a0)
37+
sq $s3, O_S3($a0)
38+
sq $s4, O_S4($a0)
39+
sq $s5, O_S5($a0)
40+
sq $s6, O_S6($a0)
41+
sq $s7, O_S7($a0)
42+
sq $fp, O_FP($a0)
43+
sq $sp, O_SP($a0)
44+
sq $ra, O_RA($a0)
45+
46+
swc1 $f20, O_F20($a0)
47+
swc1 $f21, O_F21($a0)
48+
swc1 $f22, O_F22($a0)
49+
swc1 $f23, O_F23($a0)
50+
swc1 $f24, O_F24($a0)
51+
swc1 $f25, O_F25($a0)
52+
swc1 $f26, O_F26($a0)
53+
swc1 $f27, O_F27($a0)
54+
swc1 $f28, O_F28($a0)
55+
swc1 $f29, O_F29($a0)
56+
swc1 $f30, O_F30($a0)
57+
swc1 $f31, O_F31($a0)
58+
59+
60+
move $v0, $0
61+
62+
jr $ra
63+
64+
.end setjmp
65+
66+
/* volatile void longjmp (jmp_buf, int); */
67+
.globl longjmp
68+
.ent longjmp
69+
longjmp:
70+
.frame $sp,0,$31
71+
72+
lq $s0, O_S0($a0)
73+
lq $s1, O_S1($a0)
74+
lq $s2, O_S2($a0)
75+
lq $s3, O_S3($a0)
76+
lq $s4, O_S4($a0)
77+
lq $s5, O_S5($a0)
78+
lq $s6, O_S6($a0)
79+
lq $s7, O_S7($a0)
80+
lq $fp, O_FP($a0)
81+
lq $sp, O_SP($a0)
82+
lq $ra, O_RA($a0)
83+
84+
lwc1 $f20, O_F20($a0)
85+
lwc1 $f21, O_F21($a0)
86+
lwc1 $f22, O_F22($a0)
87+
lwc1 $f23, O_F23($a0)
88+
lwc1 $f24, O_F24($a0)
89+
lwc1 $f25, O_F25($a0)
90+
lwc1 $f26, O_F26($a0)
91+
lwc1 $f27, O_F27($a0)
92+
lwc1 $f28, O_F28($a0)
93+
lwc1 $f29, O_F29($a0)
94+
lwc1 $f30, O_F30($a0)
95+
lwc1 $f31, O_F31($a0)
96+
97+
bne $a0, $0, 1f
98+
li $a0, 1
99+
1:
100+
move $v0, $a0
101+
102+
jr $ra
103+
104+
.end longjmp

newlib/libc/sys/Makefile.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ endif
3131
if HAVE_LIBC_SYS_OR1K_DIR
3232
include %D%/or1k/Makefile.inc
3333
endif
34+
if HAVE_LIBC_SYS_PS2_DIR
35+
include %D%/ps2/Makefile.inc
36+
endif
3437
if HAVE_LIBC_SYS_RDOS_DIR
3538
include %D%/rdos/Makefile.inc
3639
endif

newlib/libc/sys/ps2/Makefile.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
libc_a_SOURCES += %D%/dummy.c

newlib/libc/sys/ps2/crt0.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/* The real crt0.c lives in PS2SDK. */
2+
3+
void _start() { }

0 commit comments

Comments
 (0)