From 1dd914ffc8989cafc9415682a178a900249ca091 Mon Sep 17 00:00:00 2001 From: florian Date: Tue, 7 Apr 2020 21:01:07 +0000 Subject: [PATCH] + initial xtensa-linux rtl git-svn-id: trunk@44636 - --- .gitattributes | 7 + compiler/systems.pas | 1 + rtl/linux/bunxsysc.inc | 6 +- rtl/linux/linux.pp | 2 +- rtl/linux/osdefs.inc | 8 + rtl/linux/ossysc.inc | 4 +- rtl/linux/ostypes.inc | 2 +- rtl/linux/system.pp | 4 +- rtl/linux/termios.inc | 241 ++++++++++++++++++++ rtl/linux/xtensa/bsyscall.inc | 1 + rtl/linux/xtensa/si_c.inc | 69 ++++++ rtl/linux/xtensa/si_dll.inc | 39 ++++ rtl/linux/xtensa/si_prc.inc | 70 ++++++ rtl/linux/xtensa/sighnd.inc | 61 +++++ rtl/linux/xtensa/syscall.inc | 150 +++++++++++++ rtl/linux/xtensa/sysnr.inc | 405 ++++++++++++++++++++++++++++++++++ 16 files changed, 1061 insertions(+), 9 deletions(-) create mode 100644 rtl/linux/xtensa/bsyscall.inc create mode 100644 rtl/linux/xtensa/si_c.inc create mode 100644 rtl/linux/xtensa/si_dll.inc create mode 100644 rtl/linux/xtensa/si_prc.inc create mode 100644 rtl/linux/xtensa/sighnd.inc create mode 100644 rtl/linux/xtensa/syscall.inc create mode 100644 rtl/linux/xtensa/sysnr.inc diff --git a/.gitattributes b/.gitattributes index ae2ad05aaf..440239575f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11180,9 +11180,16 @@ rtl/linux/x86_64/stat.inc svneol=native#text/plain rtl/linux/x86_64/syscall.inc svneol=native#text/plain rtl/linux/x86_64/syscallh.inc svneol=native#text/plain rtl/linux/x86_64/sysnr.inc svneol=native#text/plain +rtl/linux/xtensa/bsyscall.inc svneol=native#text/plain +rtl/linux/xtensa/si_c.inc svneol=native#text/plain +rtl/linux/xtensa/si_dll.inc svneol=native#text/plain +rtl/linux/xtensa/si_prc.inc svneol=native#text/plain +rtl/linux/xtensa/sighnd.inc svneol=native#text/plain rtl/linux/xtensa/sighndh.inc svneol=native#text/plain rtl/linux/xtensa/stat.inc svneol=native#text/plain +rtl/linux/xtensa/syscall.inc svneol=native#text/plain rtl/linux/xtensa/syscallh.inc svneol=native#text/plain +rtl/linux/xtensa/sysnr.inc svneol=native#text/plain rtl/m68k/cpuh.inc svneol=native#text/plain rtl/m68k/int64p.inc svneol=native#text/plain rtl/m68k/lowmath.inc svneol=native#text/plain diff --git a/compiler/systems.pas b/compiler/systems.pas index 26dd2e8b2b..c2369a337c 100644 --- a/compiler/systems.pas +++ b/compiler/systems.pas @@ -367,6 +367,7 @@ interface systems_internal_sysinit = [system_i386_win32,system_x86_64_win64, system_i386_linux,system_powerpc64_linux,system_sparc64_linux,system_x86_64_linux, + system_xtensa_linux, system_m68k_atari,system_m68k_palmos, system_i386_haiku,system_x86_64_haiku, system_i386_openbsd,system_x86_64_openbsd, diff --git a/rtl/linux/bunxsysc.inc b/rtl/linux/bunxsysc.inc index be03c5c41a..a6a3e82732 100644 --- a/rtl/linux/bunxsysc.inc +++ b/rtl/linux/bunxsysc.inc @@ -460,7 +460,7 @@ Function fpSelect(N:cint;readfds,writefds,exceptfds:pfdSet;TimeOut:PTimeVal):cin Select checks whether the file descriptor sets in readfs/writefs/exceptfs have changed. } -{$if defined(generic_linux_syscalls) and not defined(NO_SYSCALL_PSELECT6)} +{$if (defined(generic_linux_syscalls) and not defined(NO_SYSCALL_PSELECT6)) or defined(CPUXTENSA)} var ts : timespec; pts : PTimeSpec; @@ -542,12 +542,12 @@ function fpNice(N:cint):cint; Doesn't exist in BSD. Linux emu uses setpriority in a construct as below: } -{$if defined(generic_linux_syscalls) or defined(cpux86_64)} +{$if defined(generic_linux_syscalls) or defined(cpux86_64) or defined(cpuxtensa)} var oldprio : cint; {$endif} begin -{$if defined(generic_linux_syscalls) or defined(cpux86_64)} +{$if defined(generic_linux_syscalls) or defined(cpux86_64) or defined(cpuxtensa)} oldprio:=fpGetPriority(Prio_Process,0); fpNice:=fpSetPriority(Prio_Process,0,oldprio+N); if fpNice=0 then diff --git a/rtl/linux/linux.pp b/rtl/linux/linux.pp index 793bdc1fd9..418d42d1b4 100644 --- a/rtl/linux/linux.pp +++ b/rtl/linux/linux.pp @@ -668,7 +668,7 @@ end; function sync_file_range(fd: cInt; offset: off64_t; nbytes: off64_t; flags: cuInt): cInt; begin -{$if defined(cpupowerpc) or defined(cpuarm)} +{$if defined(cpupowerpc) or defined(cpuarm) or defined(cpuxtensa)} sync_file_range := do_syscall(syscall_nr_sync_file_range2, TSysParam(fd), TSysParam(flags), TSysParam(hi(offset)), TSysParam(lo(offset)), TSysParam(hi(nbytes)), TSysParam(lo(nbytes))); {$else} diff --git a/rtl/linux/osdefs.inc b/rtl/linux/osdefs.inc index e3aa84d000..1e114a948e 100644 --- a/rtl/linux/osdefs.inc +++ b/rtl/linux/osdefs.inc @@ -99,6 +99,14 @@ {$undef usestime} {$endif cpuriscv64} +{$ifdef cpuxtensa} + {$define FPC_USEGETTIMEOFDAY} + {$define MMAP2} + {$define WAIT4} + {$undef usestime} +{$endif cpuxtensa} + + {$ifdef android} {$define generic_linux_syscalls} {$ifdef cpuarm} diff --git a/rtl/linux/ossysc.inc b/rtl/linux/ossysc.inc index 299b89f853..074ad4b9a8 100644 --- a/rtl/linux/ossysc.inc +++ b/rtl/linux/ossysc.inc @@ -428,12 +428,12 @@ function Fpfork : pid_t; [public, alias : 'FPC_SYSC_FORK']; A negative value indicates that an error has occurred, the error is returned in LinuxError. } -{$if defined(generic_linux_syscalls)} +{$if defined(generic_linux_syscalls) or defined(cpuxtensa)} var pid : Int64; {$endif} Begin -{$if defined(generic_linux_syscalls)} +{$if defined(generic_linux_syscalls) or defined(cpuxtensa)} Fpfork:=Do_syscall(syscall_nr_clone,clone_flags_fork,0,0,0,TSysParam(@pid)); {$else} Fpfork:=Do_syscall(SysCall_nr_fork); diff --git a/rtl/linux/ostypes.inc b/rtl/linux/ostypes.inc index b2b21a1e55..3ba93786df 100644 --- a/rtl/linux/ostypes.inc +++ b/rtl/linux/ostypes.inc @@ -315,7 +315,7 @@ CONST {$if defined(cpupowerpc)} O_LARGEFILE = $10000; {$endif} -{$if defined(cpui386) or defined(cpux86_64) or defined(cpuia64)} +{$if defined(cpui386) or defined(cpux86_64) or defined(cpuia64) or defined(cpuxtensa)} O_LARGEFILE = $8000; {$endif} {$if defined(cpumips) or defined(cpumipsel)} diff --git a/rtl/linux/system.pp b/rtl/linux/system.pp index 61b5e9b740..e6cb6246f2 100644 --- a/rtl/linux/system.pp +++ b/rtl/linux/system.pp @@ -48,9 +48,9 @@ const function get_cmdline:Pchar; deprecated 'use paramstr' ; property cmdline:Pchar read get_cmdline; -{$if defined(CPURISCV32) or defined(CPURISCV64) or defined(CPUARM) or defined(CPUM68K) or (defined(CPUSPARC) and defined(VER2_6))} +{$if defined(CPURISCV32) or defined(CPURISCV64) or defined(CPUARM) or defined(CPUM68K) or (defined(CPUSPARC) and defined(VER2_6)) or defined(CPUXTENSA)} {$define FPC_LOAD_SOFTFPU} -{$endif defined(CPURISCV32) or defined(CPURISCV64) or defined(CPUARM) or defined(CPUM68K) or (defined(CPUSPARC) and defined(VER2_6))} +{$endif defined(CPURISCV32) or defined(CPURISCV64) or defined(CPUARM) or defined(CPUM68K) or (defined(CPUSPARC) and defined(VER2_6)) or defined(CPUXTENSA)} {$ifdef FPC_SOFT_FPUX80} {$define FPC_SOFTFLOAT_FLOATX80} diff --git a/rtl/linux/termios.inc b/rtl/linux/termios.inc index 0e0d5abbc4..2c6810884c 100644 --- a/rtl/linux/termios.inc +++ b/rtl/linux/termios.inc @@ -2507,6 +2507,247 @@ const {$endif CPUM68K} + +{$ifdef cpuxtensa} + { For Terminal handling } + TCGETS = $5401; + TCSETS = $5402; + TCSETSW = $5403; + TCSETSF = $5404; + TCGETA = $5405; + TCSETA = $5406; + TCSETAW = $5407; + TCSETAF = $5408; + TCSBRK = $5409; + TCXONC = $540A; + TCFLSH = $540B; + TIOCEXCL = $540C; + TIOCNXCL = $540D; + TIOCSCTTY = $540E; + TIOCGPGRP = $540F; + TIOCSPGRP = $5410; + TIOCOUTQ = $5411; + TIOCSTI = $5412; + TIOCGWINSZ = $5413; + TIOCSWINSZ = $5414; + TIOCMGET = $5415; + TIOCMBIS = $5416; + TIOCMBIC = $5417; + TIOCMSET = $5418; + TIOCGSOFTCAR = $5419; + TIOCSSOFTCAR = $541A; + FIONREAD = $541B; + TIOCINQ = FIONREAD; + TIOCLINUX = $541C; + TIOCCONS = $541D; + TIOCGSERIAL = $541E; + TIOCSSERIAL = $541F; + TIOCPKT = $5420; + FIONBIO = $5421; + TIOCNOTTY = $5422; + TIOCSETD = $5423; + TIOCGETD = $5424; + TCSBRKP = $5425; + TIOCTTYGSTRUCT = $5426; + FIONCLEX = $5450; + FIOCLEX = $5451; + FIOASYNC = $5452; + TIOCSERCONFIG = $5453; + TIOCSERGWILD = $5454; + TIOCSERSWILD = $5455; + TIOCGLCKTRMIOS = $5456; + TIOCSLCKTRMIOS = $5457; + TIOCSERGSTRUCT = $5458; + TIOCSERGETLSR = $5459; + TIOCSERGETMULTI = $545A; + TIOCSERSETMULTI = $545B; + + TIOCMIWAIT = $545C; + TIOCGICOUNT = $545D; + TIOCGHAYESESP = $545E; + TIOCSHAYESESP = $545F; + FIOQSIZE = $5460; + + + TIOCPKT_DATA = 0; + TIOCPKT_FLUSHREAD = 1; + TIOCPKT_FLUSHWRITE = 2; + TIOCPKT_STOP = 4; + TIOCPKT_START = 8; + TIOCPKT_NOSTOP = 16; + TIOCPKT_DOSTOP = 32; + +{c_cc characters} + VINTR = 0; + VQUIT = 1; + VERASE = 2; + VKILL = 3; + VEOF = 4; + VTIME = 5; + VMIN = 6; + VSWTC = 7; + VSTART = 8; + VSTOP = 9; + VSUSP = 10; + VEOL = 11; + VREPRINT = 12; + VDISCARD = 13; + VWERASE = 14; + VLNEXT = 15; + VEOL2 = 16; + +{c_iflag bits} + IGNBRK = $0000001; + BRKINT = $0000002; + IGNPAR = $0000004; + PARMRK = $0000008; + INPCK = $0000010; + ISTRIP = $0000020; + INLCR = $0000040; + IGNCR = $0000080; + ICRNL = $0000100; + IUCLC = $0000200; + IXON = $0000400; + IXANY = $0000800; + IXOFF = $0001000; + IMAXBEL = $0002000; + IUTF8 = $0004000; + +{c_oflag bits} + OPOST = $0000001; + OLCUC = $0000002; + ONLCR = $0000004; + OCRNL = $0000008; + ONOCR = $0000010; + ONLRET = $0000020; + OFILL = $0000040; + OFDEL = $0000080; + NLDLY = $0000100; + NL0 = $0000000; + NL1 = $0000100; + CRDLY = $0000600; + CR0 = $0000000; + CR1 = $0000200; + CR2 = $0000400; + CR3 = $0000600; + TABDLY = $0001800; + TAB0 = $0000000; + TAB1 = $0000800; + TAB2 = $0001000; + TAB3 = $0001800; + XTABS = $0001800; + BSDLY = $0002000; + BS0 = $0000000; + BS1 = $0002000; + VTDLY = $0004000; + VT0 = $0000000; + VT1 = $0004000; + FFDLY = $0008000; + FF0 = $0000000; + FF1 = $0008000; + +{c_cflag bits} + CBAUD = $000100F; + B0 = $0000000; + B50 = $0000001; + B75 = $0000002; + B110 = $0000003; + B134 = $0000004; + B150 = $0000005; + B200 = $0000006; + B300 = $0000007; + B600 = $0000008; + B1200 = $0000009; + B1800 = $000000A; + B2400 = $000000B; + B4800 = $000000C; + B9600 = $000000D; + B19200 = $000000E; + B38400 = $000000F; + EXTA = B19200; + EXTB = B38400; + CSIZE = $0000030; + CS5 = $0000000; + CS6 = $0000010; + CS7 = $0000020; + CS8 = $0000030; + CSTOPB = $0000040; + CREAD = $0000080; + PARENB = $0000100; + PARODD = $0000200; + HUPCL = $0000400; + CLOCAL = $0000800; + CBAUDEX = $0001000; + B57600 = $0001001; + B115200 = $0001002; + B230400 = $0001003; + B460800 = $0001004; + B500000 = $0001005; + B576000 = $0001006; + B921600 = $0001007; + B1000000= $0001008; + B1152000= $0001009; + B1500000= $000100A; + B2000000= $000100B; + B2500000= $000100C; + B3000000= $000100D; + B3500000= $000100E; + B4000000= $000100F; + + CIBAUD = $100F0000; + CMSPAR = $40000000; + CRTSCTS = $80000000; + +{c_lflag bits} + ISIG = $0000001; + ICANON = $0000002; + XCASE = $0000004; + ECHO = $0000008; + ECHOE = $0000010; + ECHOK = $0000020; + ECHONL = $0000040; + NOFLSH = $0000080; + TOSTOP = $0000100; + ECHOCTL = $0000200; + ECHOPRT = $0000400; + ECHOKE = $0000800; + FLUSHO = $0001000; + PENDIN = $0004000; + IEXTEN = $0008000; + +{c_line bits} + TIOCM_LE = $001; + TIOCM_DTR = $002; + TIOCM_RTS = $004; + TIOCM_ST = $008; + TIOCM_SR = $010; + TIOCM_CTS = $020; + TIOCM_CAR = $040; + TIOCM_RNG = $080; + TIOCM_DSR = $100; + TIOCM_CD = TIOCM_CAR; + TIOCM_RI = TIOCM_RNG; + TIOCM_OUT1 = $2000; + TIOCM_OUT2 = $4000; + +{TCSetAttr} + TCSANOW = 0; + TCSADRAIN = 1; + TCSAFLUSH = 2; + +{TCFlow} + TCOOFF = 0; + TCOON = 1; + TCIOFF = 2; + TCION = 3; + +{TCFlush} + TCIFLUSH = 0; + TCOFLUSH = 1; + TCIOFLUSH = 2; + +{$endif cpuxtensa} + Type winsize = record ws_row, diff --git a/rtl/linux/xtensa/bsyscall.inc b/rtl/linux/xtensa/bsyscall.inc new file mode 100644 index 0000000000..c690ebeb2c --- /dev/null +++ b/rtl/linux/xtensa/bsyscall.inc @@ -0,0 +1 @@ +{ nothing } diff --git a/rtl/linux/xtensa/si_c.inc b/rtl/linux/xtensa/si_c.inc new file mode 100644 index 0000000000..1f6b5eb252 --- /dev/null +++ b/rtl/linux/xtensa/si_c.inc @@ -0,0 +1,69 @@ +{ + This file is part of the Free Pascal run time library. + Copyright (c) 2019 by Jeppe Johansen. + + 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. + + **********************************************************************} + +{****************************************************************************** + Process start/halt + ******************************************************************************} + +var + dlexitproc : pointer; + +var + BSS_START: record end; external name '__bss_start'; + STACK_PTR: record end; external name '__stkptr'; + + libc_init_proc: TProcedure; weakexternal name '_init'; + libc_fini_proc: TProcedure; weakexternal name '_fini'; + +procedure libc_start_main(main: TProcedure; argc: ptruint; argv: ppchar; init, fini, rtld_fini: TProcedure; stack_end: pointer); cdecl; external name '__libc_start_main'; +procedure libc_exit(code: ptruint); cdecl; external name 'exit'; + +procedure _FPC_xtensa_enter(at_exit: TProcedure; sp: pptruint); + var + argc: ptruint; + argv: ppchar; + begin + argc:=sp[0]; + argv:=@sp[1]; + + initialstkptr:=sp; + operatingsystem_parameter_argc:=argc; + operatingsystem_parameter_argv:=argv; + operatingsystem_parameter_envp:=@sp[1+argc]; + + libc_start_main(@PascalMain, argc, argv, libc_init_proc, libc_fini_proc, at_exit, sp); + end; + + +procedure _FPC_proc_start; assembler; public name '_start'; + asm + ill + end; + + +procedure _FPC_xtensa_exit(e:longint); assembler; + asm + mov a6,a3 + movi a2,119 + syscall + end; + + +procedure _FPC_proc_haltproc(e:longint); cdecl; public name '_haltproc'; + begin + while true do + begin + libc_exit(e); + _FPC_xtensa_exit(e); + end; + end; diff --git a/rtl/linux/xtensa/si_dll.inc b/rtl/linux/xtensa/si_dll.inc new file mode 100644 index 0000000000..cedcccc59f --- /dev/null +++ b/rtl/linux/xtensa/si_dll.inc @@ -0,0 +1,39 @@ +{ + This file is part of the Free Pascal run time library. + Copyright (c) 2019 by Jeppe Johansen. + + 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. + + **********************************************************************} + + +{****************************************************************************** + Shared library start/halt + ******************************************************************************} + +procedure _FPC_shared_lib_start(argc : dword;argv,envp : pointer); cdecl; public name 'FPC_SHARED_LIB_START'; public name '_start'; + begin + + operatingsystem_parameter_argc:=argc; { Copy the argument count } + operatingsystem_parameter_argv:=argv; { Copy the argument pointer } + operatingsystem_parameter_envp:=envp; { Copy the environment pointer } + initialstkptr:=get_frame; + + PASCALMAIN; + end; + +{ this routine is only called when the halt() routine of the RTL embedded in + the shared library is called } +procedure _FPC_shared_lib_haltproc(e:longint); cdecl; assembler; public name '_haltproc'; + asm + .L1: + mov a6,a3 + movi a2,119 + syscall + j .L1 + end; diff --git a/rtl/linux/xtensa/si_prc.inc b/rtl/linux/xtensa/si_prc.inc new file mode 100644 index 0000000000..d4ca463b88 --- /dev/null +++ b/rtl/linux/xtensa/si_prc.inc @@ -0,0 +1,70 @@ +{ + This file is part of the Free Pascal run time library. + Copyright (c) 2019 by Jeppe Johansen. + + 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. + + **********************************************************************} + +{****************************************************************************** + Process start/halt + ******************************************************************************} + +var + dlexitproc : pointer; + +var + BSS_START: record end; external name '__bss_start'; + STACK_PTR: record end; external name '__stkptr'; + +procedure _FPC_xtensa_enter(sp: pptruint); + var + argc: ptruint; + begin + argc:=sp[0]; + + initialstkptr:=sp; + operatingsystem_parameter_argc:=argc; + operatingsystem_parameter_argv:=@sp[1]; + operatingsystem_parameter_envp:=@sp[1+argc]; + + PascalMain; + end; + +procedure _FPC_proc_start; assembler; public name '_start'; + asm + { outermost stack frame } + movi a0,0 + { pass stack pointer } + mov a6,a1 + call4 _FPC_xtensa_enter + end; + + +procedure _FPC_dynamic_proc_start; assembler; public name '_dynamic_start'; + asm + ill + end; + + +procedure _FPC_xtensa_exit(e:longint); assembler; + asm + .L1: + mov a6,a3 + movi a2,119 + syscall + j .L1 + end; + + +procedure _FPC_proc_haltproc(e:longint); cdecl; public name '_haltproc'; + begin + if assigned(dlexitproc) then + TProcedure(dlexitproc); + _FPC_xtensa_exit(e); + end; diff --git a/rtl/linux/xtensa/sighnd.inc b/rtl/linux/xtensa/sighnd.inc new file mode 100644 index 0000000000..af0730f159 --- /dev/null +++ b/rtl/linux/xtensa/sighnd.inc @@ -0,0 +1,61 @@ +{ + 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. + + **********************************************************************} + +function GetHandleErrorAddrFrameAddr: pointer; +begin + result:=@HandleErrorAddrFrame; +end; + + +Procedure SignalToHandleErrorAddrFrame(Errno : longint;addr : CodePointer; frame : Pointer); nostackframe; assembler; +asm +end; + + +procedure SignalToRunerror(Sig: longint; { _a2,_a3,_a4 : dword; } SigContext: PSigInfo; uContext : PuContext); public name '_FPC_DEFAULTSIGHANDLER'; cdecl; +var + res : word; +begin + res:=0; + case sig of + SIGFPE : + begin + res := 207; + SysResetFPU; + end; + SIGILL: + res:=216; + SIGSEGV : + res:=216; + SIGBUS: + res:=214; + SIGINT: + res:=217; + SIGQUIT: + res:=233; + end; + { give runtime error at the position where the signal was raised } + if res<>0 then + begin +{!!! ucontext^.uc_mcontext.arm_r0:=res; + ucontext^.uc_mcontext.arm_r1:=uContext^.uc_mcontext.arm_pc; + ucontext^.uc_mcontext.arm_r2:=uContext^.uc_mcontext.arm_fp; + ucontext^.uc_mcontext.arm_pc:=ptruint(@SignalToHandleErrorAddrFrame); } + end; +end; + + diff --git a/rtl/linux/xtensa/syscall.inc b/rtl/linux/xtensa/syscall.inc new file mode 100644 index 0000000000..6fd6732ff1 --- /dev/null +++ b/rtl/linux/xtensa/syscall.inc @@ -0,0 +1,150 @@ +{ + This file is part of the Free Pascal run time library. + Copyright (c) 2020 by Florian Klaempfl, + member of the Free Pascal development team. + + 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. + + **********************************************************************} + +{No debugging for syslinux include !} +{$IFDEF SYS_LINUX} + {$UNDEF SYSCALL_DEBUG} +{$ENDIF SYS_LINUX} + + +{***************************************************************************** + --- Main:The System Call Self --- +*****************************************************************************} + +function FpSysCall(sysnr:TSysParam):TSysResult; assembler; [public,alias:'FPC_SYSCALL0']; +{ + Perform syscall and set errno variable if needed. +} +asm + syscall + movi a4,-4095 + bgeu a2,a4,.Lnoexit + retw +.Lnoexit: + neg a2,a2 + call4 seterrno +end; + + +function FpSysCall(sysnr,param1:TSysParam):TSysResult; assembler; [public,alias:'FPC_SYSCALL1']; +{ + Perform syscall and set errno variable if needed. +} +asm + mov a6,param1 + syscall + movi a4,-4095 + bgeu a2,a4,.Lnoexit + retw +.Lnoexit: + neg a2,a2 + call4 seterrno +end; + + +function FpSysCall(sysnr,param1,param2:TSysParam):TSysResult; assembler; [public,alias:'FPC_SYSCALL2']; +{ + Perform syscall and set errno variable if needed. +} +asm + mov a6,param1 + mov a3,param2 + syscall + movi a4,-4095 + bgeu a2,a4,.Lnoexit + retw +.Lnoexit: + neg a2,a2 + call4 seterrno +end; + + +function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler; [public,alias:'FPC_SYSCALL3']; +{ + Perform syscall and set errno variable if needed. +} +asm + mov a6,param1 + mov a3,param2 + mov a4,param3 + syscall + movi a4,-4095 + bgeu a2,a4,.Lnoexit + retw +.Lnoexit: + neg a2,a2 + call4 seterrno +end; + + +function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler; [public,alias:'FPC_SYSCALL4']; +{ + Perform syscall and set errno variable if needed. +} +asm + mov a9,param1 + mov a3,param2 + mov a4,param3 + mov a5,param4 + mov a6,a9 + syscall + movi a4,-4095 + bgeu a2,a4,.Lnoexit + retw +.Lnoexit: + neg a2,a2 + call4 seterrno +end; + +function FpSysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult; assembler; [public,alias:'FPC_SYSCALL5']; +{ + Perform syscall and set errno variable if needed. +} +asm + mov a9,param1 + mov a3,param2 + mov a4,param3 + mov a5,param4 + mov a8,param5 + mov a6,a9 + syscall + movi a4,-4095 + bgeu a2,a4,.Lnoexit + retw +.Lnoexit: + neg a2,a2 + call4 seterrno +end; + + +function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):TSysResult; assembler; [public,alias:'FPC_SYSCALL6']; +{ + Perform syscall and set errno variable if needed. +} +asm + mov a9,param1 + mov a3,param2 + mov a4,param3 + mov a5,param4 + mov a8,param5 + mov a6,a9 + l32i a9,param6 + syscall + movi a4,-4095 + bgeu a2,a4,.Lnoexit + retw +.Lnoexit: + neg a2,a2 + call4 seterrno +end; diff --git a/rtl/linux/xtensa/sysnr.inc b/rtl/linux/xtensa/sysnr.inc new file mode 100644 index 0000000000..a7c660a09b --- /dev/null +++ b/rtl/linux/xtensa/sysnr.inc @@ -0,0 +1,405 @@ +{ + This file is part of the Free Pascal run time library. + Copyright (c) 2003-2020 by Florian Klaempfl and David Zhang + + Syscall nrs for Xtensa + + 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. +} + +Const + syscall_nr_spill = 0; + syscall_nr_xtensa = 1; + syscall_nr_available4 = 2; + syscall_nr_available5 = 3; + syscall_nr_available6 = 4; + syscall_nr_available7 = 5; + syscall_nr_available8 = 6; + syscall_nr_available9 = 7; + syscall_nr_open = 8; + syscall_nr_close = 9; + syscall_nr_dup = 10; + syscall_nr_dup2 = 11; + syscall_nr_read = 12; + syscall_nr_write = 13; + syscall_nr_select = 14; + syscall_nr_lseek = 15; + syscall_nr_poll = 16; + syscall_nr__llseek = 17; + syscall_nr_epoll_wait = 18; + syscall_nr_epoll_ctl = 19; + syscall_nr_epoll_create = 20; + syscall_nr_creat = 21; + syscall_nr_truncate = 22; + syscall_nr_ftruncate = 23; + syscall_nr_readv = 24; + syscall_nr_writev = 25; + syscall_nr_fsync = 26; + syscall_nr_fdatasync = 27; + syscall_nr_truncate64 = 28; + syscall_nr_ftruncate64 = 29; + syscall_nr_pread64 = 30; + syscall_nr_pwrite64 = 31; + syscall_nr_link = 32; + syscall_nr_rename = 33; + syscall_nr_symlink = 34; + syscall_nr_readlink = 35; + syscall_nr_mknod = 36; + syscall_nr_pipe = 37; + syscall_nr_unlink = 38; + syscall_nr_rmdir = 39; + syscall_nr_mkdir = 40; + syscall_nr_chdir = 41; + syscall_nr_fchdir = 42; + syscall_nr_getcwd = 43; + syscall_nr_chmod = 44; + syscall_nr_chown = 45; + syscall_nr_stat = 46; + syscall_nr_stat64 = 47; + syscall_nr_lchown = 48; + syscall_nr_lstat = 49; + syscall_nr_lstat64 = 50; + syscall_nr_available51 = 51; + syscall_nr_fchmod = 52; + syscall_nr_fchown = 53; + syscall_nr_fstat = 54; + syscall_nr_fstat64 = 55; + syscall_nr_flock = 56; + syscall_nr_access = 57; + syscall_nr_umask = 58; + syscall_nr_getdents = 59; + syscall_nr_getdents64 = 60; + syscall_nr_fcntl64 = 61; + syscall_nr_fallocate = 62; + syscall_nr_fadvise64_64 = 63; + syscall_nr_utime = 64; + syscall_nr_utimes = 65; + syscall_nr_ioctl = 66; + syscall_nr_fcntl = 67; + syscall_nr_setxattr = 68; + syscall_nr_getxattr = 69; + syscall_nr_listxattr = 70; + syscall_nr_removexattr = 71; + syscall_nr_lsetxattr = 72; + syscall_nr_lgetxattr = 73; + syscall_nr_llistxattr = 74; + syscall_nr_lremovexattr = 75; + syscall_nr_fsetxattr = 76; + syscall_nr_fgetxattr = 77; + syscall_nr_flistxattr = 78; + syscall_nr_fremovexattr = 79; + syscall_nr_mmap2 = 80; + syscall_nr_munmap = 81; + syscall_nr_mprotect = 82; + syscall_nr_brk = 83; + syscall_nr_mlock = 84; + syscall_nr_munlock = 85; + syscall_nr_mlockall = 86; + syscall_nr_munlockall = 87; + syscall_nr_mremap = 88; + syscall_nr_msync = 89; + syscall_nr_mincore = 90; + syscall_nr_madvise = 91; + syscall_nr_shmget = 92; + syscall_nr_shmat = 93; + syscall_nr_shmctl = 94; + syscall_nr_shmdt = 95; + syscall_nr_socket = 96; + syscall_nr_setsockopt = 97; + syscall_nr_getsockopt = 98; + syscall_nr_shutdown = 99; + syscall_nr_bind = 100; + syscall_nr_connect = 101; + syscall_nr_listen = 102; + syscall_nr_accept = 103; + syscall_nr_getsockname = 104; + syscall_nr_getpeername = 105; + syscall_nr_sendmsg = 106; + syscall_nr_recvmsg = 107; + syscall_nr_send = 108; + syscall_nr_recv = 109; + syscall_nr_sendto = 110; + syscall_nr_recvfrom = 111; + syscall_nr_socketpair = 112; + syscall_nr_sendfile = 113; + syscall_nr_sendfile64 = 114; + syscall_nr_sendmmsg = 115; + syscall_nr_clone = 116; + syscall_nr_execve = 117; + syscall_nr_exit = 118; + syscall_nr_exit_group = 119; + syscall_nr_getpid = 120; + syscall_nr_wait4 = 121; + syscall_nr_waitid = 122; + syscall_nr_kill = 123; + syscall_nr_tkill = 124; + syscall_nr_tgkill = 125; + syscall_nr_set_tid_address = 126; + syscall_nr_gettid = 127; + syscall_nr_setsid = 128; + syscall_nr_getsid = 129; + syscall_nr_prctl = 130; + syscall_nr_personality = 131; + syscall_nr_getpriority = 132; + syscall_nr_setpriority = 133; + syscall_nr_setitimer = 134; + syscall_nr_getitimer = 135; + syscall_nr_setuid = 136; + syscall_nr_getuid = 137; + syscall_nr_setgid = 138; + syscall_nr_getgid = 139; + syscall_nr_geteuid = 140; + syscall_nr_getegid = 141; + syscall_nr_setreuid = 142; + syscall_nr_setregid = 143; + syscall_nr_setresuid = 144; + syscall_nr_getresuid = 145; + syscall_nr_setresgid = 146; + syscall_nr_getresgid = 147; + syscall_nr_setpgid = 148; + syscall_nr_getpgid = 149; + syscall_nr_getppid = 150; + syscall_nr_getpgrp = 151; + syscall_nr_reserved152 = 152; + syscall_nr_reserved153 = 153; + syscall_nr_times = 154; + syscall_nr_acct = 155; + syscall_nr_sched_setaffinity = 156; + syscall_nr_sched_getaffinity = 157; + syscall_nr_capget = 158; + syscall_nr_capset = 159; + syscall_nr_ptrace = 160; + syscall_nr_semtimedop = 161; + syscall_nr_semget = 162; + syscall_nr_semop = 163; + syscall_nr_semctl = 164; + syscall_nr_available165 = 165; + syscall_nr_msgget = 166; + syscall_nr_msgsnd = 167; + syscall_nr_msgrcv = 168; + syscall_nr_msgctl = 169; + syscall_nr_available170 = 170; + syscall_nr_umount2 = 171; + syscall_nr_mount = 172; + syscall_nr_swapon = 173; + syscall_nr_chroot = 174; + syscall_nr_pivot_root = 175; + syscall_nr_umount = 176; + syscall_nr_swapoff = 177; + syscall_nr_sync = 178; + syscall_nr_syncfs = 179; + syscall_nr_setfsuid = 180; + syscall_nr_setfsgid = 181; + syscall_nr_sysfs = 182; + syscall_nr_ustat = 183; + syscall_nr_statfs = 184; + syscall_nr_fstatfs = 185; + syscall_nr_statfs64 = 186; + syscall_nr_fstatfs64 = 187; + syscall_nr_setrlimit = 188; + syscall_nr_getrlimit = 189; + syscall_nr_getrusage = 190; + syscall_nr_futex = 191; + syscall_nr_gettimeofday = 192; + syscall_nr_settimeofday = 193; + syscall_nr_adjtimex = 194; + syscall_nr_nanosleep = 195; + syscall_nr_getgroups = 196; + syscall_nr_setgroups = 197; + syscall_nr_sethostname = 198; + syscall_nr_setdomainname = 199; + syscall_nr_syslog = 200; + syscall_nr_vhangup = 201; + syscall_nr_uselib = 202; + syscall_nr_reboot = 203; + syscall_nr_quotactl = 204; + syscall_nr_nfsservctl = 205; + syscall_nr__sysctl = 206; + syscall_nr_bdflush = 207; + syscall_nr_uname = 208; + syscall_nr_sysinfo = 209; + syscall_nr_init_module = 210; + syscall_nr_delete_module = 211; + syscall_nr_sched_setparam = 212; + syscall_nr_sched_getparam = 213; + syscall_nr_sched_setscheduler = 214; + syscall_nr_sched_getscheduler = 215; + syscall_nr_sched_get_priority_max = 216; + syscall_nr_sched_get_priority_min = 217; + syscall_nr_sched_rr_get_interval = 218; + syscall_nr_sched_yield = 219; + syscall_nr_available222 = 222; + syscall_nr_restart_syscall = 223; + syscall_nr_sigaltstack = 224; + syscall_nr_rt_sigreturn = 225; + syscall_nr_rt_sigaction = 226; + syscall_nr_rt_sigprocmask = 227; + syscall_nr_rt_sigpending = 228; + syscall_nr_rt_sigtimedwait = 229; + syscall_nr_rt_sigqueueinfo = 230; + syscall_nr_rt_sigsuspend = 231; + syscall_nr_mq_open = 232; + syscall_nr_mq_unlink = 233; + syscall_nr_mq_timedsend = 234; + syscall_nr_mq_timedreceive = 235; + syscall_nr_mq_notify = 236; + syscall_nr_mq_getsetattr = 237; + syscall_nr_available238 = 238; + syscall_nr_io_setup = 239; + syscall_nr_io_destroy = 240; + syscall_nr_io_submit = 241; + syscall_nr_io_getevents = 242; + syscall_nr_io_cancel = 243; + syscall_nr_clock_settime = 244; + syscall_nr_clock_gettime = 245; + syscall_nr_clock_getres = 246; + syscall_nr_clock_nanosleep = 247; + syscall_nr_timer_create = 248; + syscall_nr_timer_delete = 249; + syscall_nr_timer_settime = 250; + syscall_nr_timer_gettime = 251; + syscall_nr_timer_getoverrun = 252; + syscall_nr_reserved253 = 253; + syscall_nr_lookup_dcookie = 254; + syscall_nr_available255 = 255; + syscall_nr_add_key = 256; + syscall_nr_request_key = 257; + syscall_nr_keyctl = 258; + syscall_nr_available259 = 259; + syscall_nr_readahead = 260; + syscall_nr_remap_file_pages = 261; + syscall_nr_migrate_pages = 262; + syscall_nr_mbind = 263; + syscall_nr_get_mempolicy = 264; + syscall_nr_set_mempolicy = 265; + syscall_nr_unshare = 266; + syscall_nr_move_pages = 267; + syscall_nr_splice = 268; + syscall_nr_tee = 269; + syscall_nr_vmsplice = 270; + syscall_nr_available271 = 271; + syscall_nr_pselect6 = 272; + syscall_nr_ppoll = 273; + syscall_nr_epoll_pwait = 274; + syscall_nr_epoll_create1 = 275; + syscall_nr_inotify_init = 276; + syscall_nr_inotify_add_watch = 277; + syscall_nr_inotify_rm_watch = 278; + syscall_nr_inotify_init1 = 279; + syscall_nr_getcpu = 280; + syscall_nr_kexec_load = 281; + syscall_nr_ioprio_set = 282; + syscall_nr_ioprio_get = 283; + syscall_nr_set_robust_list = 284; + syscall_nr_get_robust_list = 285; + syscall_nr_available286 = 286; + syscall_nr_available287 = 287; + syscall_nr_openat = 288; + syscall_nr_mkdirat = 289; + syscall_nr_mknodat = 290; + syscall_nr_unlinkat = 291; + syscall_nr_renameat = 292; + syscall_nr_linkat = 293; + syscall_nr_symlinkat = 294; + syscall_nr_readlinkat = 295; + syscall_nr_utimensat = 296; + syscall_nr_fchownat = 297; + syscall_nr_futimesat = 298; + syscall_nr_fstatat64 = 299; + syscall_nr_fchmodat = 300; + syscall_nr_faccessat = 301; + syscall_nr_available302 = 302; + syscall_nr_available303 = 303; + syscall_nr_signalfd = 304; + syscall_nr_eventfd = 306; + syscall_nr_recvmmsg = 307; + syscall_nr_setns = 308; + syscall_nr_signalfd4 = 309; + syscall_nr_dup3 = 310; + syscall_nr_pipe2 = 311; + syscall_nr_timerfd_create = 312; + syscall_nr_timerfd_settime = 313; + syscall_nr_timerfd_gettime = 314; + syscall_nr_available315 = 315; + syscall_nr_eventfd2 = 316; + syscall_nr_preadv = 317; + syscall_nr_pwritev = 318; + syscall_nr_available319 = 319; + syscall_nr_fanotify_init = 320; + syscall_nr_fanotify_mark = 321; + syscall_nr_process_vm_readv = 322; + syscall_nr_process_vm_writev = 323; + syscall_nr_name_to_handle_at = 324; + syscall_nr_open_by_handle_at = 325; + syscall_nr_sync_file_range2 = 326; + syscall_nr_perf_event_open = 327; + syscall_nr_rt_tgsigqueueinfo = 328; + syscall_nr_clock_adjtime = 329; + syscall_nr_prlimit64 = 330; + syscall_nr_kcmp = 331; + syscall_nr_finit_module = 332; + syscall_nr_accept4 = 333; + syscall_nr_sched_setattr = 334; + syscall_nr_sched_getattr = 335; + syscall_nr_renameat2 = 336; + syscall_nr_seccomp = 337; + syscall_nr_getrandom = 338; + syscall_nr_memfd_create = 339; + syscall_nr_bpf = 340; + syscall_nr_execveat = 341; + syscall_nr_userfaultfd = 342; + syscall_nr_membarrier = 343; + syscall_nr_mlock2 = 344; + syscall_nr_copy_file_range = 345; + syscall_nr_preadv2 = 346; + syscall_nr_pwritev2 = 347; + syscall_nr_pkey_mprotect = 348; + syscall_nr_pkey_alloc = 349; + syscall_nr_pkey_free = 350; + syscall_nr_statx = 351; + syscall_nr_rseq = 352; + syscall_nr_clock_gettime64 = 403; + syscall_nr_clock_settime64 = 404; + syscall_nr_clock_adjtime64 = 405; + syscall_nr_clock_getres_time64 = 406; + syscall_nr_clock_nanosleep_time64 = 407; + syscall_nr_timer_gettime64 = 408; + syscall_nr_timer_settime64 = 409; + syscall_nr_timerfd_gettime64 = 410; + syscall_nr_timerfd_settime64 = 411; + syscall_nr_utimensat_time64 = 412; + syscall_nr_pselect6_time64 = 413; + syscall_nr_ppoll_time64 = 414; + syscall_nr_io_pgetevents_time64 = 416; + syscall_nr_recvmmsg_time64 = 417; + syscall_nr_mq_timedsend_time64 = 418; + syscall_nr_mq_timedreceive_time64 = 419; + syscall_nr_semtimedop_time64 = 420; + syscall_nr_rt_sigtimedwait_time64 = 421; + syscall_nr_futex_time64 = 422; + syscall_nr_sched_rr_get_interval_time64 = 423; + syscall_nr_pidfd_send_signal = 424; + syscall_nr_io_uring_setup = 425; + syscall_nr_io_uring_enter = 426; + syscall_nr_io_uring_register = 427; + syscall_nr_open_tree = 428; + syscall_nr_move_mount = 429; + syscall_nr_fsopen = 430; + syscall_nr_fsconfig = 431; + syscall_nr_fsmount = 432; + syscall_nr_fspick = 433; + syscall_nr_pidfd_open = 434; + syscall_nr_clone3 = 435; + syscall_nr_openat2 = 437; + syscall_nr_pidfd_getfd = 438;