harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 1a8d90e7250d44be627358cf524a69daf18d2238
parent 5c3500d282d81b52b2170bd9129d3207fc38cba1
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sun, 15 Aug 2021 11:36:48 +0200

rt: initial riscv64 support

This does not work pending completed qbe support, but it is a start.

Diffstat:
Art/+linux/start+riscv64.s | 6++++++
Art/+linux/syscall+riscv64.s | 146+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Art/+linux/syscallno+riscv64.ha | 299+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 451 insertions(+), 0 deletions(-)

diff --git a/rt/+linux/start+riscv64.s b/rt/+linux/start+riscv64.s @@ -0,0 +1,6 @@ +.text +.global _start +_start: + mv a0, sp + andi sp, sp, -16 + tail rt.start_ha diff --git a/rt/+linux/syscall+riscv64.s b/rt/+linux/syscall+riscv64.s @@ -0,0 +1,146 @@ +.section .text.rt.syscall0 +.global rt.syscall0 +rt.syscall0: + addi sp, sp, -32 + sd s0, 24(sp) + addi s0, sp, 32 + sd a0, -24(s0) + ld a7, -24(s0) + ecall + mv a5, a0 + mv a0, a5 + ld s0, 24(sp) + addi sp, sp, 32 + jr ra + +.section .text.rt.syscall1 +.global rt.syscall1 +rt.syscall1: + addi sp, sp, -32 + sd s0, 24(sp) + addi s0, sp, 32 + sd a0, -24(s0) + sd a1, -32(s0) + ld a7, -24(s0) + ld a0, -32(s0) + ecall + mv a5, a0 + mv a0, a5 + ld s0, 24(sp) + addi sp, sp, 32 + jr ra + +.section .text.rt.syscall2 +.global rt.syscall2 +rt.syscall2: + addi sp, sp, -48 + sd s0, 40(sp) + addi s0, sp, 48 + sd a0, -24(s0) + sd a1, -32(s0) + sd a2, -40(s0) + ld a7, -24(s0) + ld a0, -32(s0) + ld a1, -40(s0) + ecall + mv a5, a0 + mv a0, a5 + ld s0, 40(sp) + addi sp, sp, 48 + jr ra + +.section .text.rt.syscall3 +.global rt.syscall3 +rt.syscall3: + addi sp, sp, -48 + sd s0, 40(sp) + addi s0, sp, 48 + sd a0, -24(s0) + sd a1, -32(s0) + sd a2, -40(s0) + sd a3, -48(s0) + ld a7, -24(s0) + ld a0, -32(s0) + ld a1, -40(s0) + ld a2, -48(s0) + ecall + mv a5, a0 + mv a0, a5 + ld s0, 40(sp) + addi sp, sp, 48 + jr ra + +.section .text.rt.syscall4 +.global rt.syscall4 +rt.syscall4: + addi sp, sp, -64 + sd s0, 56(sp) + addi s0, sp, 64 + sd a0, -24(s0) + sd a1, -32(s0) + sd a2, -40(s0) + sd a3, -48(s0) + sd a4, -56(s0) + ld a7, -24(s0) + ld a0, -32(s0) + ld a1, -40(s0) + ld a2, -48(s0) + ld a3, -56(s0) + ecall + mv a5, a0 + mv a0, a5 + ld s0, 56(sp) + addi sp, sp, 64 + jr ra + +.section .text.rt.syscall5 +.global rt.syscall5 +rt.syscall5: + addi sp, sp, -64 + sd s0, 56(sp) + addi s0, sp, 64 + sd a0, -24(s0) + sd a1, -32(s0) + sd a2, -40(s0) + sd a3, -48(s0) + sd a4, -56(s0) + sd a5, -64(s0) + ld a7, -24(s0) + ld a0, -32(s0) + ld a1, -40(s0) + ld a2, -48(s0) + ld a3, -56(s0) + ld a4, -64(s0) + ecall + mv a5, a0 + mv a0, a5 + ld s0, 56(sp) + addi sp, sp, 64 + jr ra + +.section .text.rt.syscall6 +.global rt.syscall6 +rt.syscall6: + addi sp, sp, -80 + sd s0, 72(sp) + addi s0, sp, 80 + sd a0, -24(s0) + sd a1, -32(s0) + sd a2, -40(s0) + sd a3, -48(s0) + sd a4, -56(s0) + sd a5, -64(s0) + sd a6, -72(s0) + ld a7, -24(s0) + ld a0, -32(s0) + ld a1, -40(s0) + ld a2, -48(s0) + ld a3, -56(s0) + ld a4, -64(s0) + ld a5, -72(s0) + ecall + mv a5, a0 + mv a0, a5 + ld s0, 72(sp) + addi sp, sp, 80 + jr ra diff --git a/rt/+linux/syscallno+riscv64.ha b/rt/+linux/syscallno+riscv64.ha @@ -0,0 +1,299 @@ +export def SYS_io_setup: u64 = 0; +export def SYS_io_destroy: u64 = 1; +export def SYS_io_submit: u64 = 2; +export def SYS_io_cancel: u64 = 3; +export def SYS_io_getevents: u64 = 4; +export def SYS_setxattr: u64 = 5; +export def SYS_lsetxattr: u64 = 6; +export def SYS_fsetxattr: u64 = 7; +export def SYS_getxattr: u64 = 8; +export def SYS_lgetxattr: u64 = 9; +export def SYS_fgetxattr: u64 = 10; +export def SYS_listxattr: u64 = 11; +export def SYS_llistxattr: u64 = 12; +export def SYS_flistxattr: u64 = 13; +export def SYS_removexattr: u64 = 14; +export def SYS_lremovexattr: u64 = 15; +export def SYS_fremovexattr: u64 = 16; +export def SYS_getcwd: u64 = 17; +export def SYS_lookup_dcookie: u64 = 18; +export def SYS_eventfd2: u64 = 19; +export def SYS_epoll_create1: u64 = 20; +export def SYS_epoll_ctl: u64 = 21; +export def SYS_epoll_pwait: u64 = 22; +export def SYS_dup: u64 = 23; +export def SYS_dup3: u64 = 24; +export def SYS_fcntl: u64 = 25; +export def SYS_inotify_init1: u64 = 26; +export def SYS_inotify_add_watch: u64 = 27; +export def SYS_inotify_rm_watch: u64 = 28; +export def SYS_ioctl: u64 = 29; +export def SYS_ioprio_set: u64 = 30; +export def SYS_ioprio_get: u64 = 31; +export def SYS_flock: u64 = 32; +export def SYS_mknodat: u64 = 33; +export def SYS_mkdirat: u64 = 34; +export def SYS_unlinkat: u64 = 35; +export def SYS_symlinkat: u64 = 36; +export def SYS_linkat: u64 = 37; +export def SYS_umount2: u64 = 39; +export def SYS_mount: u64 = 40; +export def SYS_pivot_root: u64 = 41; +export def SYS_nfsservctl: u64 = 42; +export def SYS_statfs: u64 = 43; +export def SYS_fstatfs: u64 = 44; +export def SYS_truncate: u64 = 45; +export def SYS_ftruncate: u64 = 46; +export def SYS_fallocate: u64 = 47; +export def SYS_faccessat: u64 = 48; +export def SYS_chdir: u64 = 49; +export def SYS_fchdir: u64 = 50; +export def SYS_chroot: u64 = 51; +export def SYS_fchmod: u64 = 52; +export def SYS_fchmodat: u64 = 53; +export def SYS_fchownat: u64 = 54; +export def SYS_fchown: u64 = 55; +export def SYS_openat: u64 = 56; +export def SYS_close: u64 = 57; +export def SYS_vhangup: u64 = 58; +export def SYS_pipe2: u64 = 59; +export def SYS_quotactl: u64 = 60; +export def SYS_getdents64: u64 = 61; +export def SYS_lseek: u64 = 62; +export def SYS_read: u64 = 63; +export def SYS_write: u64 = 64; +export def SYS_readv: u64 = 65; +export def SYS_writev: u64 = 66; +export def SYS_pread64: u64 = 67; +export def SYS_pwrite64: u64 = 68; +export def SYS_preadv: u64 = 69; +export def SYS_pwritev: u64 = 70; +export def SYS_sendfile: u64 = 71; +export def SYS_pselect6: u64 = 72; +export def SYS_ppoll: u64 = 73; +export def SYS_signalfd4: u64 = 74; +export def SYS_vmsplice: u64 = 75; +export def SYS_splice: u64 = 76; +export def SYS_tee: u64 = 77; +export def SYS_readlinkat: u64 = 78; +export def SYS_fstatat: u64 = 79; +export def SYS_fstat: u64 = 80; +export def SYS_sync: u64 = 81; +export def SYS_fsync: u64 = 82; +export def SYS_fdatasync: u64 = 83; +export def SYS_sync_file_range: u64 = 84; +export def SYS_timerfd_create: u64 = 85; +export def SYS_timerfd_settime: u64 = 86; +export def SYS_timerfd_gettime: u64 = 87; +export def SYS_utimensat: u64 = 88; +export def SYS_acct: u64 = 89; +export def SYS_capget: u64 = 90; +export def SYS_capset: u64 = 91; +export def SYS_personality: u64 = 92; +export def SYS_exit: u64 = 93; +export def SYS_exit_group: u64 = 94; +export def SYS_waitid: u64 = 95; +export def SYS_set_tid_address: u64 = 96; +export def SYS_unshare: u64 = 97; +export def SYS_futex: u64 = 98; +export def SYS_set_robust_list: u64 = 99; +export def SYS_get_robust_list: u64 = 100; +export def SYS_nanosleep: u64 = 101; +export def SYS_getitimer: u64 = 102; +export def SYS_setitimer: u64 = 103; +export def SYS_kexec_load: u64 = 104; +export def SYS_init_module: u64 = 105; +export def SYS_delete_module: u64 = 106; +export def SYS_timer_create: u64 = 107; +export def SYS_timer_gettime: u64 = 108; +export def SYS_timer_getoverrun: u64 = 109; +export def SYS_timer_settime: u64 = 110; +export def SYS_timer_delete: u64 = 111; +export def SYS_clock_settime: u64 = 112; +export def SYS_clock_gettime: u64 = 113; +export def SYS_clock_getres: u64 = 114; +export def SYS_clock_nanosleep: u64 = 115; +export def SYS_syslog: u64 = 116; +export def SYS_ptrace: u64 = 117; +export def SYS_sched_setparam: u64 = 118; +export def SYS_sched_setscheduler: u64 = 119; +export def SYS_sched_getscheduler: u64 = 120; +export def SYS_sched_getparam: u64 = 121; +export def SYS_sched_setaffinity: u64 = 122; +export def SYS_sched_getaffinity: u64 = 123; +export def SYS_sched_yield: u64 = 124; +export def SYS_sched_get_priority_max: u64 = 125; +export def SYS_sched_get_priority_min: u64 = 126; +export def SYS_sched_rr_get_interval: u64 = 127; +export def SYS_restart_syscall: u64 = 128; +export def SYS_kill: u64 = 129; +export def SYS_tkill: u64 = 130; +export def SYS_tgkill: u64 = 131; +export def SYS_sigaltstack: u64 = 132; +export def SYS_rt_sigsuspend: u64 = 133; +export def SYS_rt_sigaction: u64 = 134; +export def SYS_rt_sigprocmask: u64 = 135; +export def SYS_rt_sigpending: u64 = 136; +export def SYS_rt_sigtimedwait: u64 = 137; +export def SYS_rt_sigqueueinfo: u64 = 138; +export def SYS_rt_sigreturn: u64 = 139; +export def SYS_setpriority: u64 = 140; +export def SYS_getpriority: u64 = 141; +export def SYS_reboot: u64 = 142; +export def SYS_setregid: u64 = 143; +export def SYS_setgid: u64 = 144; +export def SYS_setreuid: u64 = 145; +export def SYS_setuid: u64 = 146; +export def SYS_setresuid: u64 = 147; +export def SYS_getresuid: u64 = 148; +export def SYS_setresgid: u64 = 149; +export def SYS_getresgid: u64 = 150; +export def SYS_setfsuid: u64 = 151; +export def SYS_setfsgid: u64 = 152; +export def SYS_times: u64 = 153; +export def SYS_setpgid: u64 = 154; +export def SYS_getpgid: u64 = 155; +export def SYS_getsid: u64 = 156; +export def SYS_setsid: u64 = 157; +export def SYS_getgroups: u64 = 158; +export def SYS_setgroups: u64 = 159; +export def SYS_uname: u64 = 160; +export def SYS_sethostname: u64 = 161; +export def SYS_setdomainname: u64 = 162; +export def SYS_getrlimit: u64 = 163; +export def SYS_setrlimit: u64 = 164; +export def SYS_getrusage: u64 = 165; +export def SYS_umask: u64 = 166; +export def SYS_prctl: u64 = 167; +export def SYS_getcpu: u64 = 168; +export def SYS_gettimeofday: u64 = 169; +export def SYS_settimeofday: u64 = 170; +export def SYS_adjtimex: u64 = 171; +export def SYS_getpid: u64 = 172; +export def SYS_getppid: u64 = 173; +export def SYS_getuid: u64 = 174; +export def SYS_geteuid: u64 = 175; +export def SYS_getgid: u64 = 176; +export def SYS_getegid: u64 = 177; +export def SYS_gettid: u64 = 178; +export def SYS_sysinfo: u64 = 179; +export def SYS_mq_open: u64 = 180; +export def SYS_mq_unlink: u64 = 181; +export def SYS_mq_timedsend: u64 = 182; +export def SYS_mq_timedreceive: u64 = 183; +export def SYS_mq_notify: u64 = 184; +export def SYS_mq_getsetattr: u64 = 185; +export def SYS_msgget: u64 = 186; +export def SYS_msgctl: u64 = 187; +export def SYS_msgrcv: u64 = 188; +export def SYS_msgsnd: u64 = 189; +export def SYS_semget: u64 = 190; +export def SYS_semctl: u64 = 191; +export def SYS_semtimedop: u64 = 192; +export def SYS_semop: u64 = 193; +export def SYS_shmget: u64 = 194; +export def SYS_shmctl: u64 = 195; +export def SYS_shmat: u64 = 196; +export def SYS_shmdt: u64 = 197; +export def SYS_socket: u64 = 198; +export def SYS_socketpair: u64 = 199; +export def SYS_bind: u64 = 200; +export def SYS_listen: u64 = 201; +export def SYS_accept: u64 = 202; +export def SYS_connect: u64 = 203; +export def SYS_getsockname: u64 = 204; +export def SYS_getpeername: u64 = 205; +export def SYS_sendto: u64 = 206; +export def SYS_recvfrom: u64 = 207; +export def SYS_setsockopt: u64 = 208; +export def SYS_getsockopt: u64 = 209; +export def SYS_shutdown: u64 = 210; +export def SYS_sendmsg: u64 = 211; +export def SYS_recvmsg: u64 = 212; +export def SYS_readahead: u64 = 213; +export def SYS_brk: u64 = 214; +export def SYS_munmap: u64 = 215; +export def SYS_mremap: u64 = 216; +export def SYS_add_key: u64 = 217; +export def SYS_request_key: u64 = 218; +export def SYS_keyctl: u64 = 219; +export def SYS_clone: u64 = 220; +export def SYS_execve: u64 = 221; +export def SYS_mmap: u64 = 222; +export def SYS_fadvise64: u64 = 223; +export def SYS_swapon: u64 = 224; +export def SYS_swapoff: u64 = 225; +export def SYS_mprotect: u64 = 226; +export def SYS_msync: u64 = 227; +export def SYS_mlock: u64 = 228; +export def SYS_munlock: u64 = 229; +export def SYS_mlockall: u64 = 230; +export def SYS_munlockall: u64 = 231; +export def SYS_mincore: u64 = 232; +export def SYS_madvise: u64 = 233; +export def SYS_remap_file_pages: u64 = 234; +export def SYS_mbind: u64 = 235; +export def SYS_get_mempolicy: u64 = 236; +export def SYS_set_mempolicy: u64 = 237; +export def SYS_migrate_pages: u64 = 238; +export def SYS_move_pages: u64 = 239; +export def SYS_rt_tgsigqueueinfo: u64 = 240; +export def SYS_perf_event_open: u64 = 241; +export def SYS_accept4: u64 = 242; +export def SYS_recvmmsg: u64 = 243; +export def SYS_arch_specific_syscall: u64 = 244; +export def SYS_wait4: u64 = 260; +export def SYS_prlimit64: u64 = 261; +export def SYS_fanotify_init: u64 = 262; +export def SYS_fanotify_mark: u64 = 263; +export def SYS_name_to_handle_at: u64 = 264; +export def SYS_open_by_handle_at: u64 = 265; +export def SYS_clock_adjtime: u64 = 266; +export def SYS_syncfs: u64 = 267; +export def SYS_setns: u64 = 268; +export def SYS_sendmmsg: u64 = 269; +export def SYS_process_vm_readv: u64 = 270; +export def SYS_process_vm_writev: u64 = 271; +export def SYS_kcmp: u64 = 272; +export def SYS_finit_module: u64 = 273; +export def SYS_sched_setattr: u64 = 274; +export def SYS_sched_getattr: u64 = 275; +export def SYS_renameat2: u64 = 276; +export def SYS_seccomp: u64 = 277; +export def SYS_getrandom: u64 = 278; +export def SYS_memfd_create: u64 = 279; +export def SYS_bpf: u64 = 280; +export def SYS_execveat: u64 = 281; +export def SYS_userfaultfd: u64 = 282; +export def SYS_membarrier: u64 = 283; +export def SYS_mlock2: u64 = 284; +export def SYS_copy_file_range: u64 = 285; +export def SYS_preadv2: u64 = 286; +export def SYS_pwritev2: u64 = 287; +export def SYS_pkey_mprotect: u64 = 288; +export def SYS_pkey_alloc: u64 = 289; +export def SYS_pkey_free: u64 = 290; +export def SYS_statx: u64 = 291; +export def SYS_io_pgetevents: u64 = 292; +export def SYS_rseq: u64 = 293; +export def SYS_kexec_file_load: u64 = 294; +export def SYS_pidfd_send_signal: u64 = 424; +export def SYS_io_uring_setup: u64 = 425; +export def SYS_io_uring_enter: u64 = 426; +export def SYS_io_uring_register: u64 = 427; +export def SYS_open_tree: u64 = 428; +export def SYS_move_mount: u64 = 429; +export def SYS_fsopen: u64 = 430; +export def SYS_fsconfig: u64 = 431; +export def SYS_fsmount: u64 = 432; +export def SYS_fspick: u64 = 433; +export def SYS_pidfd_open: u64 = 434; +export def SYS_clone3: u64 = 435; +export def SYS_close_range: u64 = 436; +export def SYS_openat2: u64 = 437; +export def SYS_pidfd_getfd: u64 = 438; +export def SYS_faccessat2: u64 = 439; + +// RISC-V specific +export def SYS_sysriscv: u64 = SYS_arch_specific_syscall; +export def SYS_riscv_flush_icache: u64 = SYS_sysriscv + 15;