os

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

commit 88ed74024c05650adefa7cef20a66ae775ee3348
parent 7e296da8cf87f35649541c339348a6638f207767
Author: erai <erai@omiltem.net>
Date:   Sat, 25 May 2024 20:15:09 -0400

remove qemu scripts

Diffstat:
M.gitignore | 11+++++++++++
Mbootstrap.sh | 46+++++++++++++++++++++++++++++++++-------------
Acmp.c | 2++
Acpio.c | 2++
Aecho.c | 2++
Dkernel.sh | 3---
Als.c | 2++
Mpxe.sh | 12+++++++++++-
Arm.c | 2++
Dserial.sh | 2--
Ash.c | 2++
Asshd.c | 105+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Avi.c | 2++
13 files changed, 174 insertions(+), 19 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -9,3 +9,14 @@ gencc lex3.c parse3.c pxe +cmp +cpio +echo +find +ls +rm +sh +sshd +vi +as +initramfs diff --git a/bootstrap.sh b/bootstrap.sh @@ -2,24 +2,44 @@ set -ue -# Environmental variables used to compile the bootstrap -: ${CC:=gcc} -: ${CFLAGS:=-Wall -Wextra -Wno-unused -pedantic -std=c99} LIBS="bufio.c lib.c alloc.c syscall.c" SOURCES="cc1.c type.c parse1.c lex1.c as.c ${LIBS}" GENLEX_SOURCES="genlex.c ${LIBS}" -# First compile the bootstrap -${CC} ${CFLAGS} ./cc0.c -o cc0 || { rm -f cc0; echo "bootstrap failed" >&2; exit 1; } +if [ -e cc1 ]; then + ./cc1 ${SOURCES} -o cc0 +else + gcc -Wall -Wextra -Wno-unused -pedantic -std=c99 ./cc0.c -o cc0 || { rm -f cc0; echo bootstrap failed; exit 1; } +fi -# Then use the bootstrap to compile the compiler -./cc0 ${SOURCES} -o cc1 || { rm -f cc1; echo "cc0 failed" >&2; exit 1; } +./cc0 ${SOURCES} -o cc1 || { rm -f cc1; echo cc0 failed; exit 1; } -# Then compile the compiler with itself -./cc1 ${SOURCES} -o cc2 || { rm -f cc2; echo "cc1 failed" >&2; exit 1; } +./cc1 ${SOURCES} -o cc2 || { rm -f cc2; echo cc1 failed; exit 1; } -# And check our work -cmp cc1 cc2 || { echo "output mismatch"; exit 1; } +cmp cc1 cc2 || { echo output mismatch; 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; } +./cc1 ${GENLEX_SOURCES} -o genlex || { rm -f genlex; echo cc1 failed; exit 1; } +./genlex < cc3.l > lex3.c || { rm -f lex3.c; echo genlex failed; exit 1; } + +./cc1 ${LIBS} echo.c -o echo || { rm -f echo; echo echo failed; exit 1; } +./cc1 ${LIBS} cmp.c -o cmp || { rm -f cmp; echo cmp failed; exit 1; } +./cc1 ${LIBS} rm.c -o rm || { rm -f rm; echo rm failed; exit 1; } +./cc1 ${LIBS} ls.c -o ls || { rm -f ls; echo ls failed; exit 1; } +./cc1 ${LIBS} cpio.c -o cpio || { rm -f cpio; echo cpio failed; exit 1; } +./cc1 ${LIBS} sh.c -o sh || { rm -f sh; echo sh failed; exit 1; } +./cc1 ${LIBS} sshd.c -o sshd || { rm -f sshd; echo sshd failed; exit 1; } +./cc1 ${LIBS} vi.c -o vi || { rm -f vi; echo vi failed; exit 1; } + +{ + echo echo + echo cmp + echo rm + echo ls + echo cpio + echo sh + echo sshd + echo vi + echo cc1 +} | ./cpio > initramfs || { rm -f initramfs; echo initramfs failed; exit 1; } + +./cc1 kernel.c -o kernel diff --git a/cmp.c b/cmp.c @@ -0,0 +1,2 @@ +main(argc: int, argv: **byte, envp: **byte) { +} diff --git a/cpio.c b/cpio.c @@ -0,0 +1,2 @@ +main(argc: int, argv: **byte, envp: **byte) { +} diff --git a/echo.c b/echo.c @@ -0,0 +1,2 @@ +main(argc: int, argv: **byte, envp: **byte) { +} diff --git a/kernel.sh b/kernel.sh @@ -1,3 +0,0 @@ -#!/bin/bash -truncate --size 4096 disk -./bootstrap.sh && ./cc2 kernel.c -o kernel && qemu-system-x86_64 -kernel kernel -M q35 -m 1g -nographic -monitor stdio -serial chardev:sock -chardev socket,id=sock,path=/tmp/s -drive file=disk,if=none,id=disk,format=raw -device nvme,serial=12345678,drive=disk -device e1000,netdev=net -netdev tap,id=net,ifname=tap0,script=no,downscript=no diff --git a/ls.c b/ls.c @@ -0,0 +1,2 @@ +main(argc: int, argv: **byte, envp: **byte) { +} diff --git a/pxe.sh b/pxe.sh @@ -1,3 +1,13 @@ #!/bin/bash + +set -ue + exec 3<>/dev/ttyACM0 -./bootstrap.sh && ./cc2 kernel.c -o kernel && nasm -f bin pxe.asm && cp kernel pxe /srv/tftp/ && printf r >&3 + +./bootstrap.sh + +nasm -f bin pxe.asm + +cp kernel pxe /srv/tftp/ + +printf r >&3 diff --git a/rm.c b/rm.c @@ -0,0 +1,2 @@ +main(argc: int, argv: **byte, envp: **byte) { +} diff --git a/serial.sh b/serial.sh @@ -1,2 +0,0 @@ -#!/bin/bash -nc -l -k -U /tmp/s diff --git a/sh.c b/sh.c @@ -0,0 +1,2 @@ +main(argc: int, argv: **byte, envp: **byte) { +} diff --git a/sshd.c b/sshd.c @@ -0,0 +1,105 @@ +// authentication -> ssh-ed25519 +// key exchange -> curve25519-sha256 +// cipher -> chacha20-poly1305@openssh.com +// mac -> none + +//<- +//SSH-2.0-omiltem<CR><LF> + +//-> +//SSH-2.0-VERSION<CR><LF> + +//-> +//byte SSH_MSG_KEXINIT +//byte[16] cookie (random bytes) +//name-list kex_algorithms +//name-list server_host_key_algorithms +//name-list encryption_algorithms_client_to_server +//name-list encryption_algorithms_server_to_client +//name-list mac_algorithms_client_to_server +//name-list mac_algorithms_server_to_client +//name-list compression_algorithms_client_to_server +//name-list compression_algorithms_server_to_client +//name-list languages_client_to_server +//name-list languages_server_to_client +//boolean first_kex_packet_follows +//uint32 0 (reserved for future extension) + +//<- +//byte SSH_MSG_KEXINIT +//byte[16] cookie (random bytes) +//name-list kex_algorithms +//name-list server_host_key_algorithms +//name-list encryption_algorithms_client_to_server +//name-list encryption_algorithms_server_to_client +//name-list mac_algorithms_client_to_server +//name-list mac_algorithms_server_to_client +//name-list compression_algorithms_client_to_server +//name-list compression_algorithms_server_to_client +//name-list languages_client_to_server +//name-list languages_server_to_client +//boolean first_kex_packet_follows +//uint32 0 (reserved for future extension) + +//-> +//byte SSH_MSG_KEX_ECDH_INIT +//string Q_C, client's ephemeral public key octet string + +//<- +//byte SSH_MSG_KEX_ECDH_REPLY +//string K_S, server's public host key +//string Q_S, server's ephemeral public key octet string +//string the signature on the exchange hash + +//signature of +//string V_C, client's identification string (CR and LF excluded) +//string V_S, server's identification string (CR and LF excluded) +//string I_C, payload of the client's SSH_MSG_KEXINIT +//string I_S, payload of the server's SSH_MSG_KEXINIT +//string K_S, server's public host key +//string Q_C, client's ephemeral public key octet string +//string Q_S, server's ephemeral public key octet string +//mpint K, shared secret + +//-> +//byte SSH_MSG_USERAUTH_REQUEST +//string user name in ISO-10646 UTF-8 encoding [RFC3629] +//string service name in US-ASCII +//string "publickey" +//boolean FALSE +//string public key algorithm name +//string public key blob + +//<- +//byte SSH_MSG_USERAUTH_PK_OK +//string public key algorithm name from the request +//string public key blob from the request + +//-> +//byte SSH_MSG_USERAUTH_REQUEST +//string user name +//string service name +//string "publickey" +//boolean TRUE +//string public key algorithm name +//string public key to be used for authentication +//string signature + +//signature of +//string session identifier +//byte SSH_MSG_USERAUTH_REQUEST +//string user name +//string service name +//string "publickey" +//boolean TRUE +//string public key algorithm name +//string public key to be used for authentication + +//<- +//SSH_MSG_USERAUTH_PK_OK + + +_rdrand(): int; +main(argc: int, argv: **byte, envp: **byte) { + exit(_rdrand()); +} diff --git a/vi.c b/vi.c @@ -0,0 +1,2 @@ +main(argc: int, argv: **byte, envp: **byte) { +}