diff --git a/lib/linux/aarch64-mes-gcc/_exit.c b/lib/linux/aarch64-mes-gcc/_exit.c new file mode 100644 index 00000000..fcc148ec --- /dev/null +++ b/lib/linux/aarch64-mes-gcc/_exit.c @@ -0,0 +1,51 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen + * Copyright © 2019,2020 Danny Milosavljevic + * + * This file is part of GNU Mes. + * + * GNU Mes 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. + * + * GNU Mes 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 GNU Mes. If not, see . + */ + +#include "mes/lib-mini.h" + +// *INDENT-OFF* +#if !__TINYC__ +#define SYS_exit "93" +void +_exit (int code) +{ + asm ( + "mov x7, $"SYS_exit"\n\t" + "mov x0, %0\n\t" + "svc $0\n\t" + : // no outputs "=" (r) + : "r" (code) + : "x0", "x7" + ); + // not reached + _exit (0); +} +#else //__TINYC__ +#define SYS_exit 0x01 +void +_exit (int code) +{ + int c = SYS_exit; + __asm__ (".int 0xe51b7004\n"); //ldr r7, [fp, #-4] ; "c" + __asm__ (".int 0xe59b000c\n"); //ldr r0, [fp, #12] ; code + __asm__ (".int 0xef000000\n"); //svc 0x00000000 +} +#endif //__TINYC__ diff --git a/lib/linux/aarch64-mes-gcc/_write.c b/lib/linux/aarch64-mes-gcc/_write.c new file mode 100644 index 00000000..7e748757 --- /dev/null +++ b/lib/linux/aarch64-mes-gcc/_write.c @@ -0,0 +1,60 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen + * Copyright © 2019,2020 Danny Milosavljevic + * + * This file is part of GNU Mes. + * + * GNU Mes 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. + * + * GNU Mes 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 GNU Mes. If not, see . + */ + +#include "mes/lib-mini.h" + +// *INDENT-OFF* +#if !__TINYC__ +#define SYS_write "64" +ssize_t +_write (int filedes, void const *buffer, size_t size) +{ + long r; + asm ( + "mov x7, $"SYS_write"\n\t" + "mov x0, %1\n\t" + "mov x1, %2\n\t" + "mov x2, %3\n\t" + "svc $0\n\t" + "mov %0, x0\n\t" + : "=r" (r) + : "r" (filedes), "r" (buffer), "r" (size) + : "r0", "r1", "r2", "r7" + ); + return r; +} +#else //__TINYC__ +#define SYS_write 0x04 +ssize_t +_write (int filedes, void const *buffer, size_t size) +{ + long r; + int c = SYS_write; + __asm__ (".int 0xe51b7008\n"); //ldr r7, [fp, #-8] ; + __asm__ (".int 0xe59b000c\n"); //ldr r0, [fp, #12] ; filedes + __asm__ (".int 0xe59b1010\n"); //ldr r1, [fp, #16] ; buffer + __asm__ (".int 0xe59b2014\n"); //ldr r2, [fp, #20] ; size + __asm__ (".int 0xef000000\n"); //svc 0x00000000 + __asm__ (".int 0xe50b0004\n"); //str r0, [fp, #-4] + return r; +} +#endif //__TINYC__ +// *INDENT-ON* diff --git a/lib/linux/aarch64-mes-gcc/crt1.c b/lib/linux/aarch64-mes-gcc/crt1.c new file mode 100644 index 00000000..989497e1 --- /dev/null +++ b/lib/linux/aarch64-mes-gcc/crt1.c @@ -0,0 +1,154 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen + * Copyright © 2019,2020 Danny Milosavljevic + * + * This file is part of GNU Mes. + * + * GNU Mes 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. + * + * GNU Mes 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 GNU Mes. If not, see . + */ + +#include +//int main (int argc, char *argv[], char *envp[]); + +/* Note: GCC may or may not omit the frame pointer, + * depending on whether it thinks this is a leaf function. + */ +// *INDENT-OFF* +#if !__TINYC__ +void +_start () +{ + asm ( + "mov w0,#0\n\t" + "mov %0,w0\n" + : "=r" (__stdin) + : //no inputs "" + ); + + asm ( + "mov w0,#1\n\t" + "mov %0,w0\n" + : "=r" (__stdout) + : //no inputs "" + ); + + asm ( + "mov w0,#2\n\t" + "mov %0,w0\n" + : "=r" (__stderr) + : //no inputs "" + ); + + /* environ = argv + argc + 1 */ + asm ( + "ldr x0,[sp]\n\t" /* x0 = argc */ + "add x1,sp,#8\n\t" /* x1 = &argv[0] */ + "add x2,x0,#1\n\t" /* x2 = argc + 1 (skip zero word after argv) */ + "lsl x2,#3\n\t" /* x2 = (argc + 1) << 3 */ + "add x2,x2,x1\n\t" /* x2 = ((argc + 1) << 3) + &argv[0] */ + "stp x1,x2,[sp,#0x10]!\n\t" /* argv, envp */ + "stp xzr,x0,[sp,#0x10]!\n\t" /* 0, argc */ + "mov %0,x2\n\t" + : "=r" (environ) + : //no inputs "" + ); + asm ( + "ldp xzr,x0,[sp],#0x10\n\t" /* 0, argc */ + "ldp x1,x2,[sp],#0x10\n\t" /* argv, envp */ + "bl main\n\t" + "mov x7, #93\n\t" + "svc #0\n\t" + "wfi \n\t" + ); +} +#else //__TINYC__ +void +_start () +{ +#if 0 + __asm__ (".int 0xe320f000\n"); //nop {0} + __asm__ (".int 0xe320f000\n"); //nop {0} +#endif + + int *in = &__stdin; + int *out = &__stdout; + int *err = &__stderr; + char ***env = &environ; + +#if 0 + __asm__ (".int 0xe320f000\n"); //nop {0} + __asm__ (".int 0xe320f000\n"); //nop {0} + + __asm__ (".int 0xe320f000\n"); //nop {0} + *in = 0x22; + __asm__ (".int 0xe320f000\n"); //nop {0} + *out = 0x33; + __asm__ (".int 0xe320f000\n"); //nop {0} + *err = 0x44; + __asm__ (".int 0xe320f000\n"); //nop {0} + *env = 0x55; + __asm__ (".int 0xe320f000\n"); //nop {0} +#endif + + /* environ = argv + argc + 1 */ + __asm__ (".int 0xe59b000c\n"); //ldr r0, [fp, #12] + __asm__ (".int 0xe28b1010\n"); //add r1, fp, #16 + + __asm__ (".int 0xe2802001\n"); //add r2, r0, #1 + __asm__ (".int 0xe1a02102\n"); //lsl r2, r2, #2 + __asm__ (".int 0xe0822001\n"); //add r2, r2, r1 + + // setup argc, argv, envp parameters on stack + __asm__ (".int 0xe52d2004\n"); //push {r2} ; (str r2, [sp, #-4]!) + __asm__ (".int 0xe52d1004\n"); //push {r1} ; (str r1, [sp, #-4]!) + __asm__ (".int 0xe52d0004\n"); //push {r0} ; (str r0, [sp, #-4]!) + __asm__ (".int 0xe1a02002\n"); //mov r2, r2 + + // *in = 0; + __asm__ (".int 0xe3a01000\n"); //mov r1, #0 + __asm__ (".int 0xe51b0004\n"); //ldr r0, [fp, #-4] + __asm__ (".int 0xe5801000\n"); //str r1, [r0] + __asm__ (".int 0xe320f000\n"); //nop {0} + + // *out = 1; + __asm__ (".int 0xe3a01001\n"); //mov r1, #1 + __asm__ (".int 0xe51b0008\n"); //ldr r0, [fp, #-8] + __asm__ (".int 0xe5801000\n"); //str r1, [r0] + __asm__ (".int 0xe320f000\n"); //nop {0} + + // *err = 2; + __asm__ (".int 0xe3a01002\n"); //mov r1, #2 + __asm__ (".int 0xe51b000c\n"); //ldr r0, [fp, #-12] + __asm__ (".int 0xe5801000\n"); //str r1, [r0] + __asm__ (".int 0xe320f000\n"); //nop {0} + + // *env = [sp, #8] + __asm__ (".int 0xe59d1008\n"); //ldr r1, [sp, #8] + __asm__ (".int 0xe51b0010\n"); //ldr r0, [fp, #-16] + __asm__ (".int 0xe5801000\n"); //str r1, [r0] + __asm__ (".int 0xe320f000\n"); //nop {0} + + // setup argc, argv, envp parameters in registers + __asm__ (".int 0xe59d0000\n"); //ldr r0, [sp] + __asm__ (".int 0xe59d1004\n"); //ldr r1, [sp, #4] + __asm__ (".int 0xe59d2008\n"); //ldr r2, [sp, #8] + main (); + + __asm__ (".int 0xe3a07001\n"); //mov r7, #1 + __asm__ (".int 0xef000000\n"); //svc 0x00000000 + __asm__ (".int 0xe320f003\n"); //wfi + __asm__ (".int 0xe320f000\n"); //nop {0} +} +#endif //__TINYC__ diff --git a/lib/linux/aarch64-mes-gcc/crti.c b/lib/linux/aarch64-mes-gcc/crti.c new file mode 100644 index 00000000..e11c4684 --- /dev/null +++ b/lib/linux/aarch64-mes-gcc/crti.c @@ -0,0 +1,19 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2018 Jan (janneke) Nieuwenhuizen + * + * This file is part of GNU Mes. + * + * GNU Mes 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. + * + * GNU Mes 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 GNU Mes. If not, see . + */ diff --git a/lib/linux/aarch64-mes-gcc/crtn.c b/lib/linux/aarch64-mes-gcc/crtn.c new file mode 100644 index 00000000..e11c4684 --- /dev/null +++ b/lib/linux/aarch64-mes-gcc/crtn.c @@ -0,0 +1,19 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2018 Jan (janneke) Nieuwenhuizen + * + * This file is part of GNU Mes. + * + * GNU Mes 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. + * + * GNU Mes 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 GNU Mes. If not, see . + */ diff --git a/lib/linux/aarch64-mes-gcc/exit-42.S b/lib/linux/aarch64-mes-gcc/exit-42.S new file mode 100644 index 00000000..4c431e60 --- /dev/null +++ b/lib/linux/aarch64-mes-gcc/exit-42.S @@ -0,0 +1,31 @@ +/* + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2019 Jan (janneke) Nieuwenhuizen + * + * This file is part of GNU Mes. + * + * GNU Mes 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. + * + * GNU Mes 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 GNU Mes. If not, see . + */ + +/** Commentary: */ + +/** Code: */ + +.text +.globl _start +_start: + mov x8, #93 + mov x0, #42 + svc #0 + wfi diff --git a/lib/linux/aarch64-mes-gcc/hello-mes.S b/lib/linux/aarch64-mes-gcc/hello-mes.S new file mode 100644 index 00000000..ef63dc1d --- /dev/null +++ b/lib/linux/aarch64-mes-gcc/hello-mes.S @@ -0,0 +1,40 @@ +/* + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2019 Jan (janneke) Nieuwenhuizen + * + * This file is part of GNU Mes. + * + * GNU Mes 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. + * + * GNU Mes 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 GNU Mes. If not, see . + */ + +/** Commentary: */ + +/** Code: */ + +.text +.globl _start +_start: + mov x8, #64 + mov x0, #1 + mov x1, hello + mov x2, $(end-hello) + svc #0 + + mov x8, #93 + mov x0, xzr + svc #0 + wfi + +hello: .ascii "Hello, GNU Mes!\n" +end: diff --git a/lib/linux/aarch64-mes-gcc/syscall-internal.c b/lib/linux/aarch64-mes-gcc/syscall-internal.c new file mode 100644 index 00000000..b077a9be --- /dev/null +++ b/lib/linux/aarch64-mes-gcc/syscall-internal.c @@ -0,0 +1,66 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen + * + * This file is part of GNU Mes. + * + * GNU Mes 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. + * + * GNU Mes 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 GNU Mes. If not, see . + */ + +#include + +// *INDENT-OFF* +static long +__sys_call_internal (long sys_call) +{ + long r; + asm ( + "mov x7, %1\n\t" + "svc $0\n\t" + "mov %0, x0\n\t" + : "=r" (r) + : "r" (sys_call) + : "x0", "x7" + ); + return r; +} + +static long +__sys_call2_internal (long sys_call, long one, long two) +{ + long r; + asm ( + "mov x7, %1\n\t" + "mov x0, %2\n\t" + "mov x1, %3\n\t" + "swi $0\n\t" + "mov %0, x0\n\t" + : "=r" (r) + : "r" (sys_call), "r" (one), "r" (two) + : "x0", "x1", "x7" + ); + return r; +} +// *INDENT-ON* + +/* Returns < 0 on error (errno-like value from kernel), or 0 on success */ +int +__raise (int signum) +{ + long pid = __sys_call_internal (SYS_getpid); + if (pid < 0) + return pid; + else + return __sys_call2_internal (SYS_kill, pid, signum); +} diff --git a/lib/linux/aarch64-mes-gcc/syscall.c b/lib/linux/aarch64-mes-gcc/syscall.c new file mode 100644 index 00000000..b1a4329b --- /dev/null +++ b/lib/linux/aarch64-mes-gcc/syscall.c @@ -0,0 +1,276 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen + * + * This file is part of GNU Mes. + * + * GNU Mes 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. + * + * GNU Mes 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 GNU Mes. If not, see . + */ + +#include +#include + +#if !__TINYC__ +// *INDENT-OFF* +long +__sys_call (long sys_call) +{ + long r; + asm ( + "mov x7, %1\n\t" + "svc $0\n\t" + "mov %0, x0\n\t" + : "=r" (r) + : "r" (sys_call) + : "x0", "x7" + ); + return r; +} +#else //__TINYC__ +long +__sys_call (long sys_call) +{ + long r; + __asm__ (".int 0xe1a07000\n"); //mov r7, r0 + // __asm__ (".int 0xe1a00001\n"); //mov r0, r1 + // __asm__ (".int 0xe1a01002\n"); //mov r1, r2 + // __asm__ (".int 0xe1a02003\n"); //mov r2, r3 + // __asm__ (".int 0xe1a03004\n"); //mov r3, r4 + __asm__ (".int 0xef000000\n"); //svc 0x00000000 + __asm__ (".int 0xe50b0004\n"); //str r0, [fp, #-4] + return r; +} +#endif //__TINYC__ + +#if !__TINYC__ +long +__sys_call1 (long sys_call, long one) +{ + long r; + asm ( + "mov x7, %1\n\t" + "mov x0, %2\n\t" + "svc $0\n\t" + "mov %0, x0\n\t" + : "=r" (r) + : "r" (sys_call), "r" (one) + : "x0", "x7" + ); + return r; +} +#else //__TINYC__ +long +__sys_call1 (long sys_call, long one) +{ + long r; + __asm__ (".int 0xe1a07000\n"); //mov r7, r0 + __asm__ (".int 0xe1a00001\n"); //mov r0, r1 + // __asm__ (".int 0xe1a01002\n"); //mov r1, r2 + // __asm__ (".int 0xe1a02003\n"); //mov r2, r3 + // __asm__ (".int 0xe1a03004\n"); //mov r3, r4 + __asm__ (".int 0xef000000\n"); //svc 0x00000000 + __asm__ (".int 0xe50b0004\n"); //str r0, [fp, #-4] + return r; +} +#endif //__TINYC__ + +#if !__TINYC__ +long +__sys_call2 (long sys_call, long one, long two) +{ + long r; + asm ( + "mov x7, %1\n\t" + "mov x0, %2\n\t" + "mov x1, %3\n\t" + "svc $0\n\t" + "mov %0, x0\n\t" + : "=r" (r) + : "r" (sys_call), "r" (one), "r" (two) + : "x0", "x1", "x7" + ); + return r; +} +#else //__TINYC__ +long +__sys_call2 (long sys_call, long one, long two) +{ + long r; + __asm__ (".int 0xe1a07000\n"); //mov r7, r0 + __asm__ (".int 0xe1a00001\n"); //mov r0, r1 + __asm__ (".int 0xe1a01002\n"); //mov r1, r2 + // __asm__ (".int 0xe1a02003\n"); //mov r2, r3 + // __asm__ (".int 0xe1a03004\n"); //mov r3, r4 + __asm__ (".int 0xef000000\n"); //svc 0x00000000 + __asm__ (".int 0xe50b0004\n"); //str r0, [fp, #-4] + return r; +} +#endif //__TINYC__ + +#if !__TINYC__ +long +__sys_call3 (long sys_call, long one, long two, long three) +{ + long r; + asm ( + "mov x7, %1\n\t" + "mov x0, %2\n\t" + "mov x1, %3\n\t" + "mov x2, %4\n\t" + "svc $0\n\t" + "mov %0, r0\n\t" + : "=r" (r) + : "r" (sys_call), "r" (one), "r" (two), "r" (three) + : "x0", "x1", "x2", "x7" + ); + return r; +} +#else //__TINYC__ +long +__sys_call3 (long sys_call, long one, long two, long three) +{ + long r; + __asm__ (".int 0xe1a07000\n"); //mov r7, r0 + __asm__ (".int 0xe1a00001\n"); //mov r0, r1 + __asm__ (".int 0xe1a01002\n"); //mov r1, r2 + __asm__ (".int 0xe1a02003\n"); //mov r2, r3 + // __asm__ (".int 0xe1a03004\n"); //mov r3, r4 + __asm__ (".int 0xef000000\n"); //svc 0x00000000 + __asm__ (".int 0xe50b0004\n"); //str r0, [fp, #-4] + return r; +} +#endif //__TINYC__ + +#if !__TINYC__ +long +__sys_call4 (long sys_call, long one, long two, long three, long four) +{ + long r; + asm ( + "mov x7, %1\n\t" + "mov x0, %2\n\t" + "mov x1, %3\n\t" + "mov x2, %4\n\t" + "mov x3, %5\n\t" + "svc $0\n\t" + "mov %0, r0\n\t" + : "=r" (r) + : "r" (sys_call), "r" (one), "r" (two), "r" (three), "r" (four) + : "x0", "x1", "x2", "x3", "x7" + ); + return r; +} +#else //__TINYC__ +long +__sys_call4 (long sys_call, long one, long two, long three, long four) +{ + long r; + __asm__ (".int 0xe1a07000\n"); //mov r7, r0 + __asm__ (".int 0xe1a00001\n"); //mov r0, r1 + __asm__ (".int 0xe1a01002\n"); //mov r1, r2 + __asm__ (".int 0xe1a02003\n"); //mov r2, r3 + __asm__ (".int 0xe1a03004\n"); //mov r3, r4 + __asm__ (".int 0xef000000\n"); //svc 0x00000000 + __asm__ (".int 0xe50b0004\n"); //str r0, [fp, #-4] + return r; +} +#endif //__TINYC__ + +// *INDENT-ON* + +long +_sys_call (long sys_call) +{ + long r = __sys_call (sys_call); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call1 (long sys_call, long one) +{ + long r = __sys_call1 (sys_call, one); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call2 (long sys_call, long one, long two) +{ + long r = __sys_call2 (sys_call, one, two); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call3 (long sys_call, long one, long two, long three) +{ + long r = __sys_call3 (sys_call, one, two, three); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call4 (long sys_call, long one, long two, long three, long four) +{ + long r = __sys_call4 (sys_call, one, two, three, four); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +#if 0 +long +_sys_call6 (long sys_call, long one, long two, long three, long four, long five, long six) +{ + long r = __sys_call6 (sys_call, one, two, three, four, five, six); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} +#endif diff --git a/lib/linux/aarch64-mes/elf64-0exit-42.hex2 b/lib/linux/aarch64-mes/elf64-0exit-42.hex2 new file mode 100644 index 00000000..8ffa00ff --- /dev/null +++ b/lib/linux/aarch64-mes/elf64-0exit-42.hex2 @@ -0,0 +1,7 @@ +:ELF_text +a8 0b 80 d2 # mov x8, #93 +40 05 80 d2 # mov x0, #42 +01 00 00 d4 # svc #0 +7f 20 03 d5 # wfi + +:ELF_end diff --git a/lib/linux/aarch64-mes/elf64-0header.hex2 b/lib/linux/aarch64-mes/elf64-0header.hex2 new file mode 100644 index 00000000..073b563a --- /dev/null +++ b/lib/linux/aarch64-mes/elf64-0header.hex2 @@ -0,0 +1,75 @@ +### Copyright (C) 2016 Jeremiah Orians +### Copyright (C) 2017 Jan Nieuwenhuizen +### Copyright (C) 2020 deesix +### This file is part of M2-Planet. +### +### M2-Planet 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. +### +### M2-Planet 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 M2-Planet. If not, see . + +### stage0's hex2 format +### !