Sixty-five headers sat side by side in include/, so `#include "irq.h"` said nothing about where irq.h was or what it belonged to, and errno.h, stat.h and fcntl.h at the top shadowed the system's for any host tool built with -I./include. They are in folders now -- arch/ core/ fs/ dev/ gfx/ net/ uapi/ (and ldls/ for the Linux driver layer) -- and every include names the folder, as Linux's do: "core/proc.h". Done mechanically and checked the hard way: the kernel built from this tree disassembles identically to the one built from the tree before it. The full image boots, and userland is the same set of programs. Paths in docs and comments follow; docs/guides/layout.md has a table of what is where, and tools/fix-includes.py rewrites old-style includes from the folders in the tree, for code written before this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S1giNvrHTrPMPw7V6x1kQ4
137 lines
2.5 KiB
ArmAsm
137 lines
2.5 KiB
ArmAsm
#include "core/syscall.h"
|
|
#include "arch/traps.h"
|
|
|
|
#define SYSCALL(name) \
|
|
.global name; \
|
|
name: \
|
|
mov $SYS_ ## name, %rax; \
|
|
mov %rcx, %r10 ;\
|
|
syscall ;\
|
|
ret
|
|
|
|
SYSCALL(fork)
|
|
.global _xv6_exit
|
|
_xv6_exit:
|
|
mov $SYS_exit, %rax
|
|
mov %rcx, %r10
|
|
syscall
|
|
ret
|
|
SYSCALL(wait)
|
|
SYSCALL(pipe)
|
|
SYSCALL(read)
|
|
SYSCALL(write)
|
|
SYSCALL(close)
|
|
SYSCALL(kill)
|
|
/* The raw stub is execve: three arguments, the Linux shape. exec() is a C
|
|
wrapper in glue.c that passes a null environment, so the 2-argument callers
|
|
in cmd/ cannot leave %rdx holding whatever happened to be there. */
|
|
.global execve
|
|
execve:
|
|
mov $SYS_exec, %rax
|
|
mov %rcx, %r10
|
|
syscall
|
|
ret
|
|
SYSCALL(open)
|
|
SYSCALL(mknod)
|
|
SYSCALL(unlink)
|
|
SYSCALL(fstat)
|
|
SYSCALL(link)
|
|
SYSCALL(mkdir)
|
|
SYSCALL(chdir)
|
|
SYSCALL(dup)
|
|
SYSCALL(dup2)
|
|
SYSCALL(fcntl)
|
|
SYSCALL(getpid)
|
|
SYSCALL(sbrk)
|
|
SYSCALL(sleep)
|
|
SYSCALL(uptime)
|
|
SYSCALL(vga_sync)
|
|
SYSCALL(getmouse)
|
|
SYSCALL(lseek)
|
|
SYSCALL(reboot)
|
|
SYSCALL(shutdown)
|
|
SYSCALL(sigfillset)
|
|
SYSCALL(sigprocmask)
|
|
SYSCALL(sigwait)
|
|
SYSCALL(alarm)
|
|
SYSCALL(waitpid)
|
|
SYSCALL(poll)
|
|
SYSCALL(setsid)
|
|
SYSCALL(mmap)
|
|
SYSCALL(munmap)
|
|
SYSCALL(delete)
|
|
SYSCALL(show)
|
|
SYSCALL(showstat)
|
|
SYSCALL(ftruncate)
|
|
SYSCALL(truncate)
|
|
SYSCALL(rename)
|
|
SYSCALL(symlink)
|
|
SYSCALL(readlink)
|
|
SYSCALL(getuid)
|
|
SYSCALL(geteuid)
|
|
SYSCALL(nanosleep)
|
|
SYSCALL(mprotect)
|
|
SYSCALL(ioctl)
|
|
SYSCALL(getcwd)
|
|
SYSCALL(arch_prctl)
|
|
SYSCALL(set_tid_address)
|
|
SYSCALL(set_robust_list)
|
|
SYSCALL(futex)
|
|
SYSCALL(clone)
|
|
SYSCALL(exit_group)
|
|
SYSCALL(wait4)
|
|
SYSCALL(getgid)
|
|
SYSCALL(getegid)
|
|
SYSCALL(umask)
|
|
SYSCALL(writev)
|
|
SYSCALL(readv)
|
|
SYSCALL(brk)
|
|
SYSCALL(prlimit)
|
|
SYSCALL(stat)
|
|
SYSCALL(lstat)
|
|
SYSCALL(access)
|
|
SYSCALL(openat)
|
|
SYSCALL(fchdir)
|
|
SYSCALL(enable_linux_abi)
|
|
SYSCALL(getrlimit)
|
|
SYSCALL(setuid)
|
|
SYSCALL(setgid)
|
|
SYSCALL(getsid)
|
|
SYSCALL(dup3)
|
|
SYSCALL(pipe2)
|
|
SYSCALL(clock_gettime)
|
|
SYSCALL(getppid)
|
|
SYSCALL(rt_sigaction)
|
|
SYSCALL(rt_sigsuspend)
|
|
SYSCALL(memfd_create)
|
|
SYSCALL(shmget)
|
|
SYSCALL(shmat)
|
|
SYSCALL(shmdt)
|
|
SYSCALL(socket)
|
|
SYSCALL(bind)
|
|
SYSCALL(listen)
|
|
SYSCALL(accept)
|
|
SYSCALL(accept4)
|
|
SYSCALL(connect)
|
|
SYSCALL(sendto)
|
|
SYSCALL(recvfrom)
|
|
SYSCALL(sockshutdown)
|
|
SYSCALL(socketpair)
|
|
SYSCALL(setsockopt)
|
|
SYSCALL(getsockopt)
|
|
SYSCALL(sendmsg)
|
|
SYSCALL(recvmsg)
|
|
SYSCALL(mount)
|
|
SYSCALL(umount2)
|
|
SYSCALL(sync)
|
|
SYSCALL(fsync)
|
|
SYSCALL(getdents64)
|
|
|
|
// Attributes and the index over them (SchFS phase 5). setxattr/getxattr/
|
|
// removexattr are Linux's; schfs_index and schfs_query are native, because
|
|
// asking a filesystem a question has no Linux equivalent.
|
|
SYSCALL(setxattr)
|
|
SYSCALL(getxattr)
|
|
SYSCALL(removexattr)
|
|
SYSCALL(schfs_index)
|
|
SYSCALL(schfs_query)
|