diff options
Diffstat (limited to 'riscv_new/rtl/linux/riscv32')
-rw-r--r-- | riscv_new/rtl/linux/riscv32/bsyscall.inc | 1 | ||||
-rw-r--r-- | riscv_new/rtl/linux/riscv32/cprt0.as | 139 | ||||
-rw-r--r-- | riscv_new/rtl/linux/riscv32/dllprt0.as | 80 | ||||
-rw-r--r-- | riscv_new/rtl/linux/riscv32/gprt0.as | 118 | ||||
-rw-r--r-- | riscv_new/rtl/linux/riscv32/prt0.as | 85 | ||||
-rw-r--r-- | riscv_new/rtl/linux/riscv32/sighnd.inc | 44 | ||||
-rw-r--r-- | riscv_new/rtl/linux/riscv32/sighndh.inc | 47 | ||||
-rw-r--r-- | riscv_new/rtl/linux/riscv32/stat.inc | 72 | ||||
-rw-r--r-- | riscv_new/rtl/linux/riscv32/syscall.inc | 141 | ||||
-rw-r--r-- | riscv_new/rtl/linux/riscv32/syscallh.inc | 35 | ||||
-rw-r--r-- | riscv_new/rtl/linux/riscv32/sysnr.inc | 413 |
11 files changed, 1175 insertions, 0 deletions
diff --git a/riscv_new/rtl/linux/riscv32/bsyscall.inc b/riscv_new/rtl/linux/riscv32/bsyscall.inc new file mode 100644 index 0000000000..c690ebeb2c --- /dev/null +++ b/riscv_new/rtl/linux/riscv32/bsyscall.inc @@ -0,0 +1 @@ +{ nothing } diff --git a/riscv_new/rtl/linux/riscv32/cprt0.as b/riscv_new/rtl/linux/riscv32/cprt0.as new file mode 100644 index 0000000000..5b9474e9c3 --- /dev/null +++ b/riscv_new/rtl/linux/riscv32/cprt0.as @@ -0,0 +1,139 @@ +/* Startup code for ARM & ELF + Copyright (C) 1995, 1996, 1997, 1998, 2001, 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. */ + +/* This is the canonical entry point, usually the first thing in the text + segment. + + Note that the code in the .init section has already been run. + This includes _init and _libc_init + + + At this entry point, most registers' values are unspecified, except: + + a1 Contains a function pointer to be registered with `atexit'. + This is how the dynamic linker arranges to have DT_FINI + functions called for shared libraries that have been loaded + before this code runs. + + sp The stack contains the arguments and environment: + 0(sp) argc + 4(sp) argv[0] + ... + (4*argc)(sp) NULL + (4*(argc+1))(sp) envp[0] + ... + NULL +*/ + + .text + .globl _start + .type _start,function +_start: + /* Clear the frame pointer since this is the outermost frame. */ + mov fp, #0 + ldmia sp!, {a2} + + /* Pop argc off the stack and save a pointer to argv */ + ldr ip,=operatingsystem_parameter_argc + ldr a3,=operatingsystem_parameter_argv + str a2,[ip] + + /* calc envp */ + add a4,a2,#1 + add a4,sp,a4,LSL #2 + ldr ip,=operatingsystem_parameter_envp + + str sp,[a3] + str a4,[ip] + + /* Save initial stackpointer */ + ldr ip,=__stkptr + str sp,[ip] + + /* Fetch address of fini */ + ldr ip, =_fini + + /* argc already loaded to a2*/ + + /* load argv */ + mov a3, sp + + /* Push stack limit */ + str a3, [sp, #-4]! + + /* Push rtld_fini */ + str a1, [sp, #-4]! + + /* Set up the other arguments in registers */ + ldr a1, =PASCALMAIN + ldr a4, =_init + + /* Push fini */ + str ip, [sp, #-4]! + + /* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end) */ + + /* Let the libc call main and exit with its return code. */ + bl __libc_start_main + + /* should never get here....*/ + bl abort + + .globl _haltproc + .type _haltproc,function +_haltproc: + ldr r0,=operatingsystem_result + ldrb r0,[r0] + swi 0x900001 + b _haltproc + + /* Define a symbol for the first piece of initialized data. */ + .data + .globl __data_start +__data_start: + .long 0 + .weak data_start + data_start = __data_start + +.bss + .comm __stkptr,4 + + .comm operatingsystem_parameter_envp,4 + .comm operatingsystem_parameter_argc,4 + .comm operatingsystem_parameter_argv,4 + + .section ".comment" + .byte 0 + .ascii "generated by FPC http://www.freepascal.org\0" + +/* We need this stuff to make gdb behave itself, otherwise + gdb will chokes with SIGILL when trying to debug apps. +*/ + .section ".note.ABI-tag", "a" + .align 4 + .long 1f - 0f + .long 3f - 2f + .long 1 +0: .asciz "GNU" +1: .align 4 +2: .long 0 + .long 2,0,0 +3: .align 4 + +.section .note.GNU-stack,"",%progbits diff --git a/riscv_new/rtl/linux/riscv32/dllprt0.as b/riscv_new/rtl/linux/riscv32/dllprt0.as new file mode 100644 index 0000000000..a7b7ee585d --- /dev/null +++ b/riscv_new/rtl/linux/riscv32/dllprt0.as @@ -0,0 +1,80 @@ +/* + * This file is part of the Free Pascal run time library. + * Copyright (c) 2011 by Thomas Schatzl, + * member of the Free Pascal development team. + * + * Startup code for shared libraries, ARM version. + * + * See the file COPYING.FPC, included in this distribution, + * for details about the copyright. + * + * This program 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. + */ + +.file "dllprt0.as" +.text + .globl _startlib + .type _startlib,function +_startlib: + .globl FPC_SHARED_LIB_START + .type FPC_SHARED_LIB_START,function +FPC_SHARED_LIB_START: + sw x1, -4(x2) + sw x8, -8(x2) + addi x8, x2, 0 + addi x2, x2, -8 + + /* a1 contains argc, a2 contains argv and a3 contains envp */ + lui x15, %hi(operatingsystem_parameter_argc) + addi x15,x15,%lo(operatingsystem_parameter_argc) + sw a1, (x15) + + lui x15, %hi(operatingsystem_parameter_argv) + addi x15,x15,%lo(operatingsystem_parameter_argv) + sw a2, (x15) + + lui x15, %hi(operatingsystem_parameter_envp) + addi x15,x15,%lo(operatingsystem_parameter_envp) + sw a3, (x15) + + /* save initial stackpointer */ + lui x15, %hi(__stklen) + addi x15,x15,%lo(__stklen) + sw x2, (x15) + + /* call main and exit normally */ + jal x1, PASCALMAIN + lw x8, -8(x8) + lw x1, -4(x8) + + jalr x0, x1 + + .globl _haltproc + .type _haltproc,function +_haltproc: + /* reload exitcode */ + lui x10, %hi(operatingsystem_result) + addi x10,x10,%lo(operatingsystem_result) + addi x17, x0, 248 + scall + jal x0, _haltproc + +.data + + .type operatingsystem_parameters,object + .size operatingsystem_parameters,12 +operatingsystem_parameters: + .skip 3*4 + .global operatingsystem_parameter_envp + .global operatingsystem_parameter_argc + .global operatingsystem_parameter_argv + .set operatingsystem_parameter_envp,operatingsystem_parameters+0 + .set operatingsystem_parameter_argc,operatingsystem_parameters+4 + .set operatingsystem_parameter_argv,operatingsystem_parameters+8 + +.bss + + .comm __stkptr,4 + diff --git a/riscv_new/rtl/linux/riscv32/gprt0.as b/riscv_new/rtl/linux/riscv32/gprt0.as new file mode 100644 index 0000000000..d7d6337e55 --- /dev/null +++ b/riscv_new/rtl/linux/riscv32/gprt0.as @@ -0,0 +1,118 @@ +/* + Start-up code for Free Pascal Compiler when linking with C library + with profiling support. + + Written by Edmund Grimley Evans in 2015 and released into the public domain. +*/ + + .text + .align 2 + + .globl _start + .type _start,#function +_start: + /* Initialise FP to zero */ + mov x29,#0 + + /* This is rtld_fini */ + mov x5,x0 + + /* Get argc, argv, envp */ + ldr x1,[sp] + add x2,sp,#8 + add x11,x1,#1 + add x11,x2,x11,lsl #3 + + /* Save argc, argv, envp, and initial stack pointer */ + adrp x10,:got:operatingsystem_parameter_argc + ldr x10,[x10,#:got_lo12:operatingsystem_parameter_argc] + str x1,[x10] + adrp x10,:got:operatingsystem_parameter_argv + ldr x10,[x10,#:got_lo12:operatingsystem_parameter_argv] + str x2,[x10] + adrp x10,:got:operatingsystem_parameter_envp + ldr x10,[x10,#:got_lo12:operatingsystem_parameter_envp] + str x11,[x10] + adrp x10,:got:__stkptr + ldr x10,[x10,#:got_lo12:__stkptr] + mov x6,sp + str x6,[x10] + + /* __libc_start_main(main, argc, argv, + init, fini, rtld_fini, stack_end) */ + adrp x0,:got:main_stub + ldr x0,[x0,#:got_lo12:main_stub] + adrp x3,:got:_init_dummy + ldr x3,[x3,#:got_lo12:_init_dummy] + adrp x4,:got:_fini_dummy + ldr x4,[x4,#:got_lo12:_fini_dummy] + bl __libc_start_main + + /* This should never happen */ + b abort + + .globl _init_dummy + .type _init_dummy,#function +_init_dummy: + ret + + .globl _fini_dummy + .type _fini_dummy,#function +_fini_dummy: + ret + + .globl main_stub + .type main_stub,#function +main_stub: + stp x29,x30,[sp,#-16]! + + /* Save initial stackpointer */ + mov x0,sp + adrp x1,:got:__stkptr + ldr x1,[x1,#:got_lo12:__stkptr] + str x0,[x1] + + /* Initialize gmon */ + adrp x0,:got:_start + ldr x0,[x0,#:got_lo12:_start] + adrp x1,:got:_etext + ldr x1,[x1,#:got_lo12:_etext] + bl __monstartup + adrp x0,:got:_mcleanup + ldr x0,[x0,#:got_lo12:_mcleanup] + bl atexit + + /* Start the program */ + bl PASCALMAIN + b abort + + .globl _haltproc + .type _haltproc,#function +_haltproc: + /* Return to libc */ + adrp x1,:got:__stkptr + ldr x1,[x1,#:got_lo12:__stkptr] + ldr x1,[x1] + mov sp,x1 + ldp x29,x30,[sp],#16 + ret + + /* Define a symbol for the first piece of initialized data. */ + .data + .align 3 + .globl __data_start +__data_start: + .long 0 + .weak data_start + data_start = __data_start + + .bss + .align 3 + + .comm __stkptr,8 + + .comm operatingsystem_parameter_envp,8 + .comm operatingsystem_parameter_argc,8 + .comm operatingsystem_parameter_argv,8 + + .section .note.GNU-stack,"",%progbits diff --git a/riscv_new/rtl/linux/riscv32/prt0.as b/riscv_new/rtl/linux/riscv32/prt0.as new file mode 100644 index 0000000000..18f568521f --- /dev/null +++ b/riscv_new/rtl/linux/riscv32/prt0.as @@ -0,0 +1,85 @@ +/* + Start-up code for Free Pascal Compiler, not in a shared library, + not linking with C library. + + Written by Edmund Grimley Evans in 2015 and released into the public domain. +*/ + + .text + .align 2 + + .globl _dynamic_start + .type _dynamic_start, function +_dynamic_start: + lui x5,%hi(__dl_fini) + addi x5,x5,%lo(__dl_fini) + sw x10, (x5) + jal x0, _start + + .globl _start + .type _start, function +_start: + /* Initialise FP to zero */ + addi x2,x0,0 + + /* Get argc, argv, envp */ + lw x5,(x2) + addi x6,x2,8 + addi x7,x5,1 + slli x7,x7,3 + add x7,x6,x7 + + /* Save argc, argv, envp, and initial stack pointer */ + lui x8,%hi(operatingsystem_parameter_argc) + addi x8,x8,%lo(operatingsystem_parameter_argc) + sw x5,(x8) + lui x8,%hi(operatingsystem_parameter_argv) + addi x8,x8,%lo(operatingsystem_parameter_argv) + sw x6,(x8) + lui x8,%hi(operatingsystem_parameter_envp) + addi x8,x8,%lo(operatingsystem_parameter_envp) + sw x7,(x8) + lui x5,%hi(__stkptr) + addi x5,x8,%lo(__stkptr) + addi x6, x2, 0 + sw x6,(x5) + + /* Call main */ + jal x1, PASCALMAIN + + .globl _haltproc + .type _haltproc,function +_haltproc: + lui x10,%hi(__dl_fini) + addi x10,x10,%lo(__dl_fini) + lw x10,(x10) + beq x10,x0,.Lexit + jalr x1,x10 +.Lexit: + lui x10,%hi(operatingsystem_result) + addi x10,x10,%lo(operatingsystem_result) + lw x10,(x10) + addi x17, x0, 94 + scall + jal x0, _haltproc + + /* Define a symbol for the first piece of initialized data. */ + .data + .align 3 + .globl __data_start +__data_start: + .long 0 + .weak data_start + data_start = __data_start + + .bss + .align 3 + + .comm __dl_fini,8 + .comm __stkptr,8 + + .comm operatingsystem_parameter_envp,8 + .comm operatingsystem_parameter_argc,8 + .comm operatingsystem_parameter_argv,8 + + .section .note.GNU-stack,"",%progbits diff --git a/riscv_new/rtl/linux/riscv32/sighnd.inc b/riscv_new/rtl/linux/riscv32/sighnd.inc new file mode 100644 index 0000000000..011b63a960 --- /dev/null +++ b/riscv_new/rtl/linux/riscv32/sighnd.inc @@ -0,0 +1,44 @@ +{ + This file is part of the Free Pascal run time library. + Copyright (c) 1999-2000 by Michael Van Canneyt, + member of the Free Pascal development team. + + Signal handler is arch dependant due to processor to language + exception conversion. + + See the file COPYING.FPC, included in this distribution, + for details about the copyright. + + This program 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. + + **********************************************************************} + +procedure SignalToRunerror(Sig: longint; SigInfo: PSigInfo; UContext: PUContext); public name '_FPC_DEFAULTSIGHANDLER'; cdecl; + +var + res : word; +begin + res:=0; + case sig of + SIGFPE: + res:=207; + SIGILL: + res:=216; + SIGSEGV : + res:=216; + SIGBUS: + res:=214; + SIGINT: + res:=217; + SIGQUIT: + res:=233; + end; + reenable_signal(sig); + { give runtime error at the position where the signal was raised } + if res<>0 then + HandleErrorAddrFrame(res, + pointer(uContext^.uc_mcontext.pc), + pointer(uContext^.uc_mcontext.regs[29])); +end; diff --git a/riscv_new/rtl/linux/riscv32/sighndh.inc b/riscv_new/rtl/linux/riscv32/sighndh.inc new file mode 100644 index 0000000000..8fa6a35ebd --- /dev/null +++ b/riscv_new/rtl/linux/riscv32/sighndh.inc @@ -0,0 +1,47 @@ +{ + This file is part of the Free Pascal run time library. + Copyright (c) 1999-2000 by Jonas Maebe, + member of the Free Pascal development team. + + TSigContext and associated structures. + + See the file COPYING.FPC, included in this distribution, + for details about the copyright. + + This program 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. + + **********************************************************************} + +{$packrecords C} + +type + PSigContext = ^TSigContext; + TSigContext = record + fault_address : cULong; + regs : array[0..30] of cULong; + sp : cULong; + pc : cULong; + pstate : cULong; + __pad : cULong; + { The following field should be 16-byte-aligned. Currently the + directive for specifying alignment is buggy, so the preceding + field was added so that the record has the right size. } + __reserved : array[0..4095] of cUChar; + end; + + stack_t = record + ss_sp : pointer; + ss_flags : cInt; + ss_size : size_t; + end; + + PUContext = ^TUContext; + TUContext = record + uc_flags : cULong; + uc_link : PUContext; + uc_stack : stack_t; + uc_mcontext : TSigContext; + uc_sigmask : sigset_t; + end; diff --git a/riscv_new/rtl/linux/riscv32/stat.inc b/riscv_new/rtl/linux/riscv32/stat.inc new file mode 100644 index 0000000000..6d69441361 --- /dev/null +++ b/riscv_new/rtl/linux/riscv32/stat.inc @@ -0,0 +1,72 @@ +{ + This file is part of the Free Pascal run time library. + Copyright (c) 1999-2000 by Jonas Maebe, (c) 2005 Thomas Schatzl, + members of the Free Pascal development team. + + Contains the definition of the stat type for the PowerPC64 platform. + + See the file COPYING.FPC, included in this distribution, + for details about the copyright. + + This program 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. + + **********************************************************************} + +{ This structure was adapted from + + include/uapi/asm-generic/stat.h + + in Linux 4.0. Note that the stat record is the same for direct + syscalls as for when linking to libc. +} + +{$PACKRECORDS C} + stat = record + case integer of + 0 : ( + st_dev : cULong; + st_ino : cULong; + st_mode : cUInt; + st_nlink : cUInt; + st_uid : cUInt; + st_gid : cUInt; + st_rdev : cULong; + __pad1a : cULong; + st_size : cLong; + st_blksize : cInt; + __pad2a : cInt; + st_blocks : cLong; + st_atime : cLong; + st_atime_nsec : cULong; + st_mtime : cLong; + st_mtime_nsec : cULong; + st_ctime : cLong; + st_ctime_nsec : cULong; + __unused4a : cUInt; + __unused5a : cUInt; + ); + 1 : ( + dev : cULong deprecated; + ino : cULong deprecated; + mode : cUInt deprecated; + nlink : cUInt deprecated; + uid : cUInt deprecated; + gid : cUInt deprecated; + rdev : cULong deprecated; + __pad1b : cULong deprecated; + size : cLong deprecated; + blksize : cInt deprecated; + __pad2b : cInt deprecated; + blocks : cLong deprecated; + atime : cLong deprecated; + atime_nsec : cULong deprecated; + mtime : cLong deprecated; + mtime_nsec : cULong deprecated; + ctime : cLong deprecated; + ctime_nsec : cULong deprecated; + __unused4b : cUInt deprecated; + __unused5b : cUInt deprecated; + ); + end; diff --git a/riscv_new/rtl/linux/riscv32/syscall.inc b/riscv_new/rtl/linux/riscv32/syscall.inc new file mode 100644 index 0000000000..a7ecca5d8c --- /dev/null +++ b/riscv_new/rtl/linux/riscv32/syscall.inc @@ -0,0 +1,141 @@ +{ + This file is part of the Free Pascal run time library. + + Perform syscall with 0..6 arguments. + If syscall return value is negative, negate it, set errno, and return -1. + + Written by Edmund Grimley Evans in 2015 and released into the public domain. +} + +function FpSysCall(sysnr:TSysParam):TSysResult; +assembler; nostackframe; [public,alias:'FPC_SYSCALL0']; +asm + addi x17, sysnr, 0 + scall + bge x10,x0,.Ldone + sw x1, -4(x2) + addi x2, x2, -4 + sub x10, x0, x10 + jal x1, seterrno + addi x2, x2, 4 + lw x1, -4(x2) + addi x10,x0, -1 +.Ldone: +end; + +function FpSysCall(sysnr,param1:TSysParam):TSysResult; +assembler; nostackframe; [public,alias:'FPC_SYSCALL1']; +asm + addi x17, sysnr, 0 + addi x10, x11, 0 + scall + bge x10,x0,.Ldone + sw x1, -4(x2) + addi x2, x2, -4 + sub x10, x0, x10 + jal x1, seterrno + addi x2, x2, 4 + lw x1, -4(x2) + addi x10,x0, -1 +.Ldone: +end; + +function FpSysCall(sysnr,param1,param2:TSysParam):TSysResult; +assembler; nostackframe; [public,alias:'FPC_SYSCALL2']; +asm + addi x17, sysnr, 0 + addi x10, x11, 0 + addi x11, x12, 0 + scall + bge x10,x0,.Ldone + sw x1, -4(x2) + addi x2, x2, -4 + sub x10, x0, x10 + jal x1, seterrno + addi x2, x2, 4 + lw x1, -4(x2) + addi x10,x0, -1 +.Ldone: +end; + +function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; +assembler; nostackframe; [public,alias:'FPC_SYSCALL3']; +asm + addi x17, sysnr, 0 + addi x10, x11, 0 + addi x11, x12, 0 + addi x12, x13, 0 + scall + bge x10,x0,.Ldone + sw x1, -4(x2) + addi x2, x2, -4 + sub x10, x0, x10 + jal x1, seterrno + addi x2, x2, 4 + lw x1, -4(x2) + addi x10,x0, -1 +.Ldone: +end; + +function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; +assembler; nostackframe; [public,alias:'FPC_SYSCALL4']; +asm + addi x17, sysnr, 0 + addi x10, x11, 0 + addi x11, x12, 0 + addi x12, x13, 0 + addi x13, x14, 0 + scall + bge x10,x0,.Ldone + sw x1, -4(x2) + addi x2, x2, -4 + sub x10, x0, x10 + jal x1, seterrno + addi x2, x2, 4 + lw x1, -4(x2) + addi x10,x0, -1 +.Ldone: +end; + +function FpSysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult; +assembler; nostackframe; [public,alias:'FPC_SYSCALL5']; +asm + addi x17, sysnr, 0 + addi x10, x11, 0 + addi x11, x12, 0 + addi x12, x13, 0 + addi x13, x14, 0 + addi x14, x15, 0 + scall + bge x10,x0,.Ldone + sw x1, -4(x2) + addi x2, x2, -4 + sub x10, x0, x10 + jal x1, seterrno + addi x2, x2, 4 + lw x1, -4(x2) + addi x10,x0, -1 +.Ldone: +end; + +function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):TSysResult; +assembler; nostackframe; [public,alias:'FPC_SYSCALL6']; +asm + addi x17, sysnr, 0 + addi x10, x11, 0 + addi x11, x12, 0 + addi x12, x13, 0 + addi x13, x14, 0 + addi x14, x15, 0 + addi x15, x16, 0 + scall + bge x10,x0,.Ldone + sw x1, -4(x2) + addi x2, x2, -4 + sub x10, x0, x10 + jal x1, seterrno + addi x2, x2, 4 + lw x1, -4(x2) + addi x10,x0, -1 +.Ldone: +end; diff --git a/riscv_new/rtl/linux/riscv32/syscallh.inc b/riscv_new/rtl/linux/riscv32/syscallh.inc new file mode 100644 index 0000000000..ea0768dd7f --- /dev/null +++ b/riscv_new/rtl/linux/riscv32/syscallh.inc @@ -0,0 +1,35 @@ +{ + Copyright (c) 2002 by Marco van de Voort + + Header for syscalls in system unit. + + This program 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 2 of the License, or + (at your option) any later version. + + This program 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 this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + **************************************************************************** + +} + +Type + TSysResult = longint; + TSysParam = longint; + +function Do_SysCall(sysnr:TSysParam):TSysResult; external name 'FPC_SYSCALL0'; +function Do_SysCall(sysnr,param1:TSysParam):TSysResult; external name 'FPC_SYSCALL1'; +function Do_SysCall(sysnr,param1,param2:TSysParam):TSysResult; external name 'FPC_SYSCALL2'; +function Do_SysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; external name 'FPC_SYSCALL3'; +function Do_SysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; external name 'FPC_SYSCALL4'; +function Do_SysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult; external name 'FPC_SYSCALL5'; +function Do_SysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):TSysResult; external name 'FPC_SYSCALL6'; diff --git a/riscv_new/rtl/linux/riscv32/sysnr.inc b/riscv_new/rtl/linux/riscv32/sysnr.inc new file mode 100644 index 0000000000..4d654232bf --- /dev/null +++ b/riscv_new/rtl/linux/riscv32/sysnr.inc @@ -0,0 +1,413 @@ +{ + This file is part of the Free Pascal run time library. + Copyright (c) 2003-2004 by Florian Klaempfl, + member of the Free Pascal development team. + + Syscall nrs for arm-linux + + See the file COPYING.FPC, included in this distribution, + for details about the copyright. + + This program 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. + + **********************************************************************} + + +{ +* This file contains the system call numbers. + Last update from 2.4.22 kernel sources according to the sources it contains already the 2.5 extensions +} + +Const +{$ifdef FPC_ABI_EABI} + syscall_nr_base = $0; +{$else FPC_ABI_EABI} + syscall_nr_base = $900000; +{$endif FPC_ABI_EABI} + + syscall_nr_exit = syscall_nr_base+ 1; + syscall_nr_fork = syscall_nr_base+ 2; + syscall_nr_read = syscall_nr_base+ 3; + syscall_nr_write = syscall_nr_base+ 4; + syscall_nr_open = syscall_nr_base+ 5; + syscall_nr_close = syscall_nr_base+ 6; + // not supported: syscall_nr_waitpid = syscall_nr_base+ 7; + syscall_nr_creat = syscall_nr_base+ 8; + syscall_nr_link = syscall_nr_base+ 9; + syscall_nr_unlink = syscall_nr_base+10; + syscall_nr_execve = syscall_nr_base+11; + syscall_nr_chdir = syscall_nr_base+12; +{$ifndef FPC_ABI_EABI} + syscall_nr_time = syscall_nr_base+13; +{$endif} + syscall_nr_mknod = syscall_nr_base+14; + syscall_nr_chmod = syscall_nr_base+15; + syscall_nr_lchown = syscall_nr_base+16; + syscall_nr_break = syscall_nr_base+17; + + syscall_nr_lseek = syscall_nr_base+19; + syscall_nr_getpid = syscall_nr_base+20; + syscall_nr_mount = syscall_nr_base+21; +{$ifndef FPC_ABI_EABI} + syscall_nr_umount = syscall_nr_base+22; +{$endif} + syscall_nr_setuid = syscall_nr_base+23; + syscall_nr_getuid = syscall_nr_base+24; +{$ifndef FPC_ABI_EABI} + syscall_nr_stime = syscall_nr_base+25; +{$endif} + syscall_nr_ptrace = syscall_nr_base+26; +{$ifndef FPC_ABI_EABI} + syscall_nr_alarm = syscall_nr_base+27; +{$endif} + + syscall_nr_pause = syscall_nr_base+29; +{$ifndef FPC_ABI_EABI} + syscall_nr_utime = syscall_nr_base+30; +{$endif} + syscall_nr_stty = syscall_nr_base+31; + syscall_nr_gtty = syscall_nr_base+32; + syscall_nr_access = syscall_nr_base+33; + syscall_nr_nice = syscall_nr_base+34; + syscall_nr_ftime = syscall_nr_base+35; + syscall_nr_sync = syscall_nr_base+36; + syscall_nr_kill = syscall_nr_base+37; + syscall_nr_rename = syscall_nr_base+38; + syscall_nr_mkdir = syscall_nr_base+39; + syscall_nr_rmdir = syscall_nr_base+40; + syscall_nr_dup = syscall_nr_base+41; + syscall_nr_pipe = syscall_nr_base+42; + syscall_nr_times = syscall_nr_base+43; + syscall_nr_prof = syscall_nr_base+44; + syscall_nr_brk = syscall_nr_base+45; + syscall_nr_setgid = syscall_nr_base+46; + syscall_nr_getgid = syscall_nr_base+47; + syscall_nr_signal = syscall_nr_base+48; + syscall_nr_geteuid = syscall_nr_base+49; + syscall_nr_getegid = syscall_nr_base+50; + syscall_nr_acct = syscall_nr_base+51; + syscall_nr_umount2 = syscall_nr_base+52; + syscall_nr_lock = syscall_nr_base+53; + syscall_nr_ioctl = syscall_nr_base+54; + syscall_nr_fcntl = syscall_nr_base+55; + syscall_nr_mpx = syscall_nr_base+56; + syscall_nr_setpgid = syscall_nr_base+57; + syscall_nr_ulimit = syscall_nr_base+58; + + syscall_nr_umask = syscall_nr_base+60; + syscall_nr_chroot = syscall_nr_base+61; + syscall_nr_ustat = syscall_nr_base+62; + syscall_nr_dup2 = syscall_nr_base+63; + syscall_nr_getppid = syscall_nr_base+64; + syscall_nr_getpgrp = syscall_nr_base+65; + syscall_nr_setsid = syscall_nr_base+66; + syscall_nr_sigaction = syscall_nr_base+67; + syscall_nr_sgetmask = syscall_nr_base+68; + syscall_nr_ssetmask = syscall_nr_base+69; + syscall_nr_setreuid = syscall_nr_base+70; + syscall_nr_setregid = syscall_nr_base+71; + syscall_nr_sigsuspend = syscall_nr_base+72; + syscall_nr_sigpending = syscall_nr_base+73; + syscall_nr_sethostname = syscall_nr_base+74; + syscall_nr_setrlimit = syscall_nr_base+75; +{$ifndef FPC_ABI_EABI} + syscall_nr_getrlimit = syscall_nr_base+76; +{$endif} + syscall_nr_getrusage = syscall_nr_base+77; + syscall_nr_gettimeofday = syscall_nr_base+78; + syscall_nr_settimeofday = syscall_nr_base+79; + syscall_nr_getgroups = syscall_nr_base+80; + syscall_nr_setgroups = syscall_nr_base+81; +{$ifndef FPC_ABI_EABI} + syscall_nr_select = syscall_nr_base+82; +{$endif} + syscall_nr_symlink = syscall_nr_base+83; + + syscall_nr_readlink = syscall_nr_base+85; + syscall_nr_uselib = syscall_nr_base+86; + syscall_nr_swapon = syscall_nr_base+87; + syscall_nr_reboot = syscall_nr_base+88; +{$ifndef FPC_ABI_EABI} + syscall_nr_readdir = syscall_nr_base+89; + syscall_nr_mmap = syscall_nr_base+90; +{$endif} + syscall_nr_munmap = syscall_nr_base+91; + syscall_nr_truncate = syscall_nr_base+92; + syscall_nr_ftruncate = syscall_nr_base+93; + syscall_nr_fchmod = syscall_nr_base+94; + syscall_nr_fchown = syscall_nr_base+95; + syscall_nr_getpriority = syscall_nr_base+96; + syscall_nr_setpriority = syscall_nr_base+97; + syscall_nr_profil = syscall_nr_base+98; + syscall_nr_statfs = syscall_nr_base+99; + syscall_nr_fstatfs = syscall_nr_base+100; + syscall_nr_ioperm = syscall_nr_base+101; +{$ifndef FPC_ABI_EABI} + syscall_nr_socketcall = syscall_nr_base+102; +{$endif} + syscall_nr_syslog = syscall_nr_base+103; + syscall_nr_setitimer = syscall_nr_base+104; + syscall_nr_getitimer = syscall_nr_base+105; + syscall_nr_stat = syscall_nr_base+106; + syscall_nr_lstat = syscall_nr_base+107; + syscall_nr_fstat = syscall_nr_base+108; + syscall_nr_vhangup = syscall_nr_base+111; + syscall_nr_idle = syscall_nr_base+112; +{$ifndef FPC_ABI_EABI} + syscall_nr_syscall = syscall_nr_base+113; +{$endif} + syscall_nr_wait4 = syscall_nr_base+114; + syscall_nr_swapoff = syscall_nr_base+115; + syscall_nr_sysinfo = syscall_nr_base+116; +{$ifndef FPC_ABI_EABI} + syscall_nr_ipc = syscall_nr_base+117; +{$endif} + syscall_nr_fsync = syscall_nr_base+118; + syscall_nr_sigreturn = syscall_nr_base+119; + syscall_nr_clone = syscall_nr_base+120; + syscall_nr_setdomainname = syscall_nr_base+121; + syscall_nr_uname = syscall_nr_base+122; + syscall_nr_modify_ldt = syscall_nr_base+123; + syscall_nr_adjtimex = syscall_nr_base+124; + syscall_nr_mprotect = syscall_nr_base+125; + syscall_nr_sigprocmask = syscall_nr_base+126; + syscall_nr_create_module = syscall_nr_base+127; + syscall_nr_init_module = syscall_nr_base+128; + syscall_nr_delete_module = syscall_nr_base+129; + syscall_nr_get_kernel_syms = syscall_nr_base+130; + syscall_nr_quotactl = syscall_nr_base+131; + syscall_nr_getpgid = syscall_nr_base+132; + syscall_nr_fchdir = syscall_nr_base+133; + syscall_nr_bdflush = syscall_nr_base+134; + syscall_nr_sysfs = syscall_nr_base+135; + syscall_nr_personality = syscall_nr_base+136; + syscall_nr_afs_syscall = syscall_nr_base+137; + syscall_nr_setfsuid = syscall_nr_base+138; + syscall_nr_setfsgid = syscall_nr_base+139; + syscall_nr__llseek = syscall_nr_base+140; + syscall_nr_getdents = syscall_nr_base+141; + syscall_nr__newselect = syscall_nr_base+142; + syscall_nr_flock = syscall_nr_base+143; + syscall_nr_msync = syscall_nr_base+144; + syscall_nr_readv = syscall_nr_base+145; + syscall_nr_writev = syscall_nr_base+146; + syscall_nr_getsid = syscall_nr_base+147; + syscall_nr_fdatasync = syscall_nr_base+148; + syscall_nr__sysctl = syscall_nr_base+149; + syscall_nr_mlock = syscall_nr_base+150; + syscall_nr_munlock = syscall_nr_base+151; + syscall_nr_mlockall = syscall_nr_base+152; + syscall_nr_munlockall = syscall_nr_base+153; + syscall_nr_sched_setparam = syscall_nr_base+154; + syscall_nr_sched_getparam = syscall_nr_base+155; + syscall_nr_sched_setscheduler = syscall_nr_base+156; + syscall_nr_sched_getscheduler = syscall_nr_base+157; + syscall_nr_sched_yield = syscall_nr_base+158; + syscall_nr_sched_get_priority_max = syscall_nr_base+159; + syscall_nr_sched_get_priority_min = syscall_nr_base+160; + syscall_nr_sched_rr_get_interval = syscall_nr_base+161; + syscall_nr_nanosleep = syscall_nr_base+162; + syscall_nr_mremap = syscall_nr_base+163; + syscall_nr_setresuid = syscall_nr_base+164; + syscall_nr_getresuid = syscall_nr_base+165; + syscall_nr_vm86 = syscall_nr_base+166; + syscall_nr_query_module = syscall_nr_base+167; + syscall_nr_poll = syscall_nr_base+168; + syscall_nr_nfsservctl = syscall_nr_base+169; + syscall_nr_setresgid = syscall_nr_base+170; + syscall_nr_getresgid = syscall_nr_base+171; + syscall_nr_prctl = syscall_nr_base+172; + syscall_nr_rt_sigreturn = syscall_nr_base+173; + syscall_nr_rt_sigaction = syscall_nr_base+174; + syscall_nr_rt_sigprocmask = syscall_nr_base+175; + syscall_nr_rt_sigpending = syscall_nr_base+176; + syscall_nr_rt_sigtimedwait = syscall_nr_base+177; + syscall_nr_rt_sigqueueinfo = syscall_nr_base+178; + syscall_nr_rt_sigsuspend = syscall_nr_base+179; + syscall_nr_pread = syscall_nr_base+180; + syscall_nr_pwrite = syscall_nr_base+181; + syscall_nr_chown = syscall_nr_base+182; + syscall_nr_getcwd = syscall_nr_base+183; + syscall_nr_capget = syscall_nr_base+184; + syscall_nr_capset = syscall_nr_base+185; + syscall_nr_sigaltstack = syscall_nr_base+186; + syscall_nr_sendfile = syscall_nr_base+187; + syscall_nr_vfork = syscall_nr_base+190; + syscall_nr_ugetrlimit = syscall_nr_base+191; + syscall_nr_mmap2 = syscall_nr_base+192; + syscall_nr_truncate64 = syscall_nr_base+193; + syscall_nr_ftruncate64 = syscall_nr_base+194; + syscall_nr_stat64 = syscall_nr_base+195; + syscall_nr_lstat64 = syscall_nr_base+196; + syscall_nr_fstat64 = syscall_nr_base+197; + syscall_nr_lchown32 = syscall_nr_base+198; + syscall_nr_getuid32 = syscall_nr_base+199; + syscall_nr_getgid32 = syscall_nr_base+200; + syscall_nr_geteuid32 = syscall_nr_base+201; + syscall_nr_getegid32 = syscall_nr_base+202; + syscall_nr_setreuid32 = syscall_nr_base+203; + syscall_nr_setregid32 = syscall_nr_base+204; + syscall_nr_getgroups32 = syscall_nr_base+205; + syscall_nr_setgroups32 = syscall_nr_base+206; + syscall_nr_fchown32 = syscall_nr_base+207; + syscall_nr_setresuid32 = syscall_nr_base+208; + syscall_nr_getresuid32 = syscall_nr_base+209; + syscall_nr_setresgid32 = syscall_nr_base+210; + syscall_nr_getresgid32 = syscall_nr_base+211; + syscall_nr_chown32 = syscall_nr_base+212; + syscall_nr_setuid32 = syscall_nr_base+213; + syscall_nr_setgid32 = syscall_nr_base+214; + syscall_nr_setfsuid32 = syscall_nr_base+215; + syscall_nr_setfsgid32 = syscall_nr_base+216; + syscall_nr_getdents64 = syscall_nr_base+217; + syscall_nr_pivot_root = syscall_nr_base+218; + syscall_nr_mincore = syscall_nr_base+219; + syscall_nr_madvise = syscall_nr_base+220; + syscall_nr_fcntl64 = syscall_nr_base+221; + syscall_nr_security = syscall_nr_base+223; + syscall_nr_gettid = syscall_nr_base+224; + syscall_nr_readahead = syscall_nr_base+225; + syscall_nr_setxattr = syscall_nr_base+226; + syscall_nr_lsetxattr = syscall_nr_base+227; + syscall_nr_fsetxattr = syscall_nr_base+228; + syscall_nr_getxattr = syscall_nr_base+229; + syscall_nr_lgetxattr = syscall_nr_base+230; + syscall_nr_fgetxattr = syscall_nr_base+231; + syscall_nr_listxattr = syscall_nr_base+232; + syscall_nr_llistxattr = syscall_nr_base+233; + syscall_nr_flistxattr = syscall_nr_base+234; + syscall_nr_removexattr = syscall_nr_base+235; + syscall_nr_lremovexattr = syscall_nr_base+236; + syscall_nr_fremovexattr = syscall_nr_base+237; + syscall_nr_tkill = syscall_nr_base+238; + syscall_nr_sendfile64 = syscall_nr_base+239; + syscall_nr_futex = syscall_nr_base+240; + syscall_nr_sched_setaffinity = syscall_nr_base+241; + syscall_nr_sched_getaffinity = syscall_nr_base+242; + syscall_nr_io_setup = syscall_nr_base+243; + syscall_nr_io_destroy = syscall_nr_base+244; + syscall_nr_io_getevents = syscall_nr_base+245; + syscall_nr_io_submit = syscall_nr_base+246; + syscall_nr_io_cancel = syscall_nr_base+247; + syscall_nr_exit_group = syscall_nr_base+248; + syscall_nr_lookup_dcookie = syscall_nr_base+249; + syscall_nr_epoll_create = syscall_nr_base+250; + syscall_nr_epoll_ctl = syscall_nr_base+251; + syscall_nr_epoll_wait = syscall_nr_base+252; + syscall_nr_remap_file_pages = syscall_nr_base+253; + syscall_nr_set_tid_address = syscall_nr_base+256; + { 254 for set_thread_area } + { 255 for get_thread_area } + syscall_nr_timer_create = syscall_nr_base+257; + syscall_nr_timer_settime = syscall_nr_base+258; + syscall_nr_timer_gettime = syscall_nr_base+259; + syscall_nr_timer_getoverrun = syscall_nr_base+260; + syscall_nr_timer_delete = syscall_nr_base+261; + syscall_nr_clock_settime = syscall_nr_base+262; + syscall_nr_clock_gettime = syscall_nr_base+263; + syscall_nr_clock_getres = syscall_nr_base+264; + syscall_nr_clock_nanosleep = syscall_nr_base+265; + syscall_nr_statfs64 = syscall_nr_base+266; + syscall_nr_fstatfs64 = syscall_nr_base+267; + syscall_nr_tgkill = syscall_nr_base+268; + syscall_nr_utimes = syscall_nr_base+269; + syscall_nr_fadvise64_64 = syscall_nr_base+270; + syscall_nr_pciconfig_iobase = syscall_nr_base+271; + syscall_nr_pciconfig_read = syscall_nr_base+272; + syscall_nr_pciconfig_write = syscall_nr_base+273; + syscall_nr_mq_open = syscall_nr_base+274; + syscall_nr_mq_unlink = syscall_nr_base+275; + syscall_nr_mq_timedsend = syscall_nr_base+276; + syscall_nr_mq_timedreceive = syscall_nr_base+277; + syscall_nr_mq_notify = syscall_nr_base+278; + syscall_nr_mq_getsetattr = syscall_nr_base+279; + syscall_nr_waitid = syscall_nr_base+280; + syscall_nr_socket = syscall_nr_base+281; + syscall_nr_bind = syscall_nr_base+282; + syscall_nr_connect = syscall_nr_base+283; + syscall_nr_listen = syscall_nr_base+284; + syscall_nr_accept = syscall_nr_base+285; + syscall_nr_getsockname = syscall_nr_base+286; + syscall_nr_getpeername = syscall_nr_base+287; + syscall_nr_socketpair = syscall_nr_base+288; + syscall_nr_send = syscall_nr_base+289; + syscall_nr_sendto = syscall_nr_base+290; + syscall_nr_recv = syscall_nr_base+291; + syscall_nr_recvfrom = syscall_nr_base+292; + syscall_nr_shutdown = syscall_nr_base+293; + syscall_nr_setsockopt = syscall_nr_base+294; + syscall_nr_getsockopt = syscall_nr_base+295; + syscall_nr_sendmsg = syscall_nr_base+296; + syscall_nr_recvmsg = syscall_nr_base+297; + syscall_nr_semop = syscall_nr_base+298; + syscall_nr_semget = syscall_nr_base+299; + syscall_nr_semctl = syscall_nr_base+300; + syscall_nr_msgsnd = syscall_nr_base+301; + syscall_nr_msgrcv = syscall_nr_base+302; + syscall_nr_msgget = syscall_nr_base+303; + syscall_nr_msgctl = syscall_nr_base+304; + syscall_nr_shmat = syscall_nr_base+305; + syscall_nr_shmdt = syscall_nr_base+306; + syscall_nr_shmget = syscall_nr_base+307; + syscall_nr_shmctl = syscall_nr_base+308; + syscall_nr_add_key = syscall_nr_base+309; + syscall_nr_request_key = syscall_nr_base+310; + syscall_nr_keyctl = syscall_nr_base+311; + syscall_nr_semtimedop = syscall_nr_base+312; + syscall_nr_vserver = syscall_nr_base+313; + syscall_nr_ioprio_set = syscall_nr_base+314; + syscall_nr_ioprio_get = syscall_nr_base+315; + syscall_nr_inotify_init = syscall_nr_base+316; + syscall_nr_inotify_add_watch = syscall_nr_base+317; + syscall_nr_inotify_rm_watch = syscall_nr_base+318; + syscall_nr_mbind = syscall_nr_base+319; + syscall_nr_get_mempolicy = syscall_nr_base+320; + syscall_nr_set_mempolicy = syscall_nr_base+321; + syscall_nr_openat = syscall_nr_base+322; + syscall_nr_mkdirat = syscall_nr_base+323; + syscall_nr_mknodat = syscall_nr_base+324; + syscall_nr_fchownat = syscall_nr_base+325; + syscall_nr_futimesat = syscall_nr_base+326; + syscall_nr_fstatat64 = syscall_nr_base+327; + syscall_nr_unlinkat = syscall_nr_base+328; + syscall_nr_renameat = syscall_nr_base+329; + syscall_nr_linkat = syscall_nr_base+330; + syscall_nr_symlinkat = syscall_nr_base+331; + syscall_nr_readlinkat = syscall_nr_base+332; + syscall_nr_fchmodat = syscall_nr_base+333; + syscall_nr_faccessat = syscall_nr_base+334; + {* 335 for pselect6 *} + {* 336 for ppoll *} + syscall_nr_unshare = syscall_nr_base+337; + syscall_nr_set_robust_list = syscall_nr_base+338; + syscall_nr_get_robust_list = syscall_nr_base+339; + syscall_nr_splice = syscall_nr_base+340; + syscall_nr_arm_sync_file_range = syscall_nr_base+341; + syscall_nr_sync_file_range2 = syscall_nr_arm_sync_file_range; + syscall_nr_tee = syscall_nr_base+342; + syscall_nr_vmsplice = syscall_nr_base+343; + syscall_nr_move_pages = syscall_nr_base+344; + syscall_nr_getcpu = syscall_nr_base+345; + {* 346 for epoll_pwait *} + syscall_nr_kexec_load = syscall_nr_base+347; + syscall_nr_utimensat = syscall_nr_base+348; + syscall_nr_signalfd = syscall_nr_base+349; + syscall_nr_timerfd_create = syscall_nr_base+350; + syscall_nr_eventfd = syscall_nr_base+351; + syscall_nr_fallocate = syscall_nr_base+352; + syscall_nr_timerfd_settime = syscall_nr_base+353; + syscall_nr_timerfd_gettime = syscall_nr_base+354; + syscall_nr_signalfd4 = syscall_nr_base+355; + syscall_nr_eventfd2 = syscall_nr_base+356; + syscall_nr_epoll_create1 = syscall_nr_base+357; + syscall_nr_dup3 = syscall_nr_base+358; + syscall_nr_pipe2 = syscall_nr_base+359; + syscall_nr_inotify_init1 = syscall_nr_base+360; + syscall_nr_preadv = syscall_nr_base+361; + syscall_nr_pwritev = syscall_nr_base+362; + syscall_nr_rt_tgsigqueueinfo = syscall_nr_base+363; + syscall_nr_perf_event_open = syscall_nr_base+364; + syscall_nr_recvmmsg = syscall_nr_base+365; + |