os

An operating system
git clone https://erai.gay/code/os/
Log | Files | Refs | README | LICENSE

commit 7e296da8cf87f35649541c339348a6638f207767
parent 1d7fc228ae5d6168c0c54f7d6b3ff4af5fc591cb
Author: erai <erai@omiltem.net>
Date:   Sat, 25 May 2024 19:53:36 -0400

always compile all

Diffstat:
Mbootstrap.sh | 28+++++-----------------------
Mkernel.c | 46++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 49 insertions(+), 25 deletions(-)

diff --git a/bootstrap.sh b/bootstrap.sh @@ -2,23 +2,6 @@ set -ue -uptodate() { - target=$1 - shift - if ! [ -f "${target}" ]; then - echo "[B] ${target}" >&2 - return 1 - fi - while [ $# -gt 0 ]; do - if ! [ -f "$1" ] || [ "$1" -nt "${target}" ]; then - echo "[B] ${target}" >&2 - return 1 - fi - shift - done - return 0 -} - # Environmental variables used to compile the bootstrap : ${CC:=gcc} : ${CFLAGS:=-Wall -Wextra -Wno-unused -pedantic -std=c99} @@ -27,17 +10,16 @@ SOURCES="cc1.c type.c parse1.c lex1.c as.c ${LIBS}" GENLEX_SOURCES="genlex.c ${LIBS}" # First compile the bootstrap -uptodate cc0 cc0.c || ${CC} ${CFLAGS} ./cc0.c -o cc0 || { rm -f cc0; echo "bootstrap failed" >&2; exit 1; } +${CC} ${CFLAGS} ./cc0.c -o cc0 || { rm -f cc0; echo "bootstrap failed" >&2; exit 1; } # Then use the bootstrap to compile the compiler -uptodate cc1 cc0 ${SOURCES} || ./cc0 ${SOURCES} -o cc1 || { rm -f cc1; echo "cc0 failed" >&2; exit 1; } +./cc0 ${SOURCES} -o cc1 || { rm -f cc1; echo "cc0 failed" >&2; exit 1; } # Then compile the compiler with itself -uptodate cc2 cc1 ${SOURCES} || ./cc1 ${SOURCES} -o cc2 || { rm -f cc2; echo "cc1 failed" >&2; exit 1; } +./cc1 ${SOURCES} -o cc2 || { rm -f cc2; echo "cc1 failed" >&2; exit 1; } # And check our work -diff <(xxd cc1) <(xxd cc2) || : cmp cc1 cc2 || { echo "output mismatch"; exit 1; } -uptodate genlex cc1 ${GENLEX_SOURCES} || ./cc1 ${GENLEX_SOURCES} -o genlex || { rm -f genlex; echo "cc1 failed" >&2; exit 1; } -uptodate lex3.c genlex cc3.l || ./genlex < cc3.l > lex3.c || { rm -f lex3.c; echo "genlex failed" >&2; exit 1; } +./cc1 ${GENLEX_SOURCES} -o genlex || { rm -f genlex; echo "cc1 failed" >&2; exit 1; } +./genlex < cc3.l > lex3.c || { rm -f lex3.c; echo "genlex failed" >&2; exit 1; } diff --git a/kernel.c b/kernel.c @@ -3528,16 +3528,58 @@ spawn(f: (func(t: *task)), name: *byte, a: *void): *task { } _ssr(r: *regs) { - if r.rax == 60 { + if r.rax == 0 { + kputs("read\n"); + r.rax = -1; + } else if r.rax == 1 { + kputs("write\n"); + r.rax = -1; + } else if r.rax == 2 { + kputs("open\n"); + r.rax = -1; + } else if r.rax == 3 { + kputs("close\n"); + r.rax = -1; + } else if r.rax == 9 { + kputs("mmap\n"); + r.rax = -1; + } else if r.rax == 33 { + kputs("dup2\n"); + r.rax = -1; + } else if r.rax == 41 { + kputs("socket\n"); + r.rax = -1; + } else if r.rax == 43 { + kputs("accept\n"); + r.rax = -1; + } else if r.rax == 49 { + kputs("bind\n"); + r.rax = -1; + } else if r.rax == 50 { + kputs("listen\n"); + r.rax = -1; + } else if r.rax == 57 { + kputs("fork\n"); + r.rax = -1; + } else if r.rax == 59 { + kputs("exec\n"); + r.rax = -1; + } else if r.rax == 60 { kputs("exit\n"); task_exit(); + } else if r.rax == 61 { + kputs("wait\n"); + r.rax = -1; + } else if r.rax == 87 { + kputs("unlink\n"); + r.rax = -1; } else { r.rax = -1; } } user() { - syscall(1, 2, 3, 4, 5, 6, 7); + syscall(1, 1, "Hello, world!\n":int, 14, 0, 0, 0); } _ustart() {