syscall.riscv64.om (4016B)
1 enum { 2 O_RDONLY = 0, 3 O_WRONLY = 1, 4 O_RDWR = 2, 5 O_CREAT = 64, 6 O_TRUNC = 512, 7 O_APPEND = 1024, 8 O_DIRECTORY = 0x1000, 9 10 EINTR = 4, 11 EPIPE = 32, 12 13 AF_INET = 2, 14 SOCK_STREAM = 1, 15 16 POLLIN = 0x01, 17 POLLPRI = 0x02, 18 POLLOUT = 0x04, 19 POLLERR = 0x08, 20 POLLHUP = 0x10, 21 POLLNVAL = 0x20, 22 23 PROT_NONE = 0, 24 PROT_READ = 1, 25 PROT_WRITE = 2, 26 PROT_EXEC = 4, 27 28 MAP_PRIVATE = 2, 29 MAP_ANON = 32, 30 31 WNOHANG = 1, 32 33 SIG_DFL = 0, 34 SIG_IGN = 1, 35 36 SIGINT = 2, 37 SIGPIPE = 13, 38 SIGALRM = 14, 39 SIGCHLD = 17, 40 SIGWINCH = 28, 41 } 42 43 struct stat_riscv64 { 44 dev: int; 45 ino: int; 46 nlink_mode: int; 47 gid_uid: int; 48 rdev: int; 49 pad0: int; 50 size: int; 51 blksize: int; 52 blocks: int; 53 atime: int; 54 atime_nsec: int; 55 mtime: int; 56 mtime_nsec: int; 57 ctime: int; 58 ctime_nsec: int; 59 pad1: int; 60 } 61 62 func get_machine(): int { 63 return 0xf3; 64 } 65 66 func read(fd: int, buf: *byte, n: int): int { 67 return syscall(63, fd, buf as int, n, 0, 0, 0); 68 } 69 70 func write(fd: int, buf: *byte, n: int): int { 71 return syscall(64, fd, buf as int, n, 0, 0, 0); 72 } 73 74 func open(name: *byte, flags: int, mode: int): int { 75 return syscall(56, -100, name as int, flags, mode, 0, 0); 76 } 77 78 func close(fd: int): int { 79 return syscall(57, fd, 0, 0, 0, 0, 0); 80 } 81 82 func fstat(fd: int, sb: *stat): int { 83 var s: stat_riscv64; 84 var ret: int; 85 ret = syscall(80, fd, (&s) as int, 0, 0, 0, 0); 86 if ret == 0 { 87 sb.dev = s.dev; 88 sb.ino = s.ino; 89 sb.mode = s.nlink_mode & (-1 >> 32); 90 sb.nlink = s.nlink_mode >> 32; 91 sb.uid = s.gid_uid & (-1 >> 32); 92 sb.gid = s.gid_uid >> 32; 93 sb.rdev = s.rdev; 94 sb.size = s.size; 95 sb.blksize = s.blksize; 96 sb.blocks = s.blocks; 97 sb.atime = s.atime; 98 sb.atime_nsec = s.atime_nsec; 99 sb.mtime = s.mtime; 100 sb.mtime_nsec = s.mtime_nsec; 101 sb.ctime = s.ctime; 102 sb.ctime_nsec = s.ctime_nsec; 103 sb.pad1 = 0; 104 sb.pad2 = 0; 105 } 106 return ret; 107 } 108 109 func getrandom(buf: *byte, len: int, flags: int): int { 110 return syscall(278, buf as int, len, flags, 0, 0, 0); 111 } 112 113 func poll(pfd: *int, nfd: int, timeout: int): int { 114 return syscall(73, pfd as int, nfd, 0, 0, 0, 0); 115 } 116 117 func lseek(fd: int, off: int, whence: int): int { 118 return syscall(62, fd, off, whence, 0, 0, 0); 119 } 120 121 func mmap(addr: int, len: int, prot: int, flags: int, fd: int, off: int): int { 122 return syscall(222, addr, len, prot, flags, fd, off); 123 } 124 125 func munmap(addr: int, len: int): int { 126 return syscall(215, addr, len, 0, 0, 0, 0); 127 } 128 129 func sigaction(sig: int, act: *sigaction, oact: *sigaction): int { 130 return syscall(134, sig, act as int, oact as int, 8, 0, 0); 131 } 132 133 func pipe(rfd: *int, wfd: *int): int { 134 var buf: int; 135 var ret: int; 136 ret = syscall(59, (&buf) as int, 0, 0, 0, 0, 0); 137 if ret == 0 { 138 *rfd = buf & (-1 >> 32); 139 *wfd = buf >> 32; 140 } 141 return ret; 142 } 143 144 func dup2(old: int, new: int): int { 145 return syscall(24, old, new, 0, 0, 0, 0); 146 } 147 148 func socket(pf: int, ty: int, pc: int): int { 149 return syscall(198, pf, ty, pc, 0, 0, 0); 150 } 151 152 func accept(fd: int, addr: *byte, len: *int): int { 153 return syscall(202, fd, addr as int, len as int, 0, 0, 0); 154 } 155 156 func bind(fd: int, addr: *byte, len: int): int { 157 return syscall(200, fd, addr as int, len as int, 0, 0, 0); 158 } 159 160 func listen(fd: int, backlog: int): int { 161 return syscall(201, fd, backlog, 0, 0, 0, 0); 162 } 163 164 func fork(): int { 165 return syscall(220, 0, 0, 0, 0, 0, 0); 166 } 167 168 func exec(cmd: *byte, argv: **byte, envp: **byte): int { 169 return syscall(221, cmd as int, argv as int, envp as int, 0, 0, 0); 170 } 171 172 func exit(n: int) { 173 syscall(93, n, 0, 0, 0, 0, 0); 174 } 175 176 func wait(pid: int, status: *int, flags: int): int { 177 var s: int; 178 var ret: int; 179 s = 0; 180 ret = syscall(260, pid, s as int, flags, 0, 0, 0); 181 if status { 182 *status = s & (-1 >> 32); 183 } 184 return ret; 185 } 186 187 func rename(oldname: *byte, newname: *byte): int { 188 return syscall(276, -100, oldname as int, -100, newname as int, 0, 0); 189 } 190 191 func mkdir(name: *byte): int { 192 return syscall(34, -100, name as int, 0, 0, 0, 0); 193 } 194 195 func unlink(name: *byte): int { 196 return syscall(35, -100, name as int, 0, 0, 0, 0); 197 } 198 199 func getdirents(fd: int, buf: *byte, len: int): int { 200 return syscall(61, fd, buf as int, len, 0, 0, 0); 201 }