You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
141 lines
3.2 KiB
141 lines
3.2 KiB
#! /bin/bash
|
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
# minal Build and start Minal OS.
|
|
|
|
#----------------------------------------------------------------------------
|
|
# assist
|
|
|
|
headline () { echo "------- "$1; }
|
|
|
|
error () { echo "####### " $1 ; exit 1; }
|
|
|
|
|
|
#----------------------------------------------------------------------------
|
|
# build
|
|
|
|
copy () {
|
|
headline "copy"
|
|
rm work/*
|
|
cp fasm/* work
|
|
|
|
}
|
|
|
|
|
|
assemble () {
|
|
headline "assemble"
|
|
cd work
|
|
fasm -m 131072 minal.fasm kernel.o
|
|
cd ..
|
|
}
|
|
|
|
|
|
|
|
|
|
linking () {
|
|
headline "linking"
|
|
LDFLAGS=' -z max-page-size=0x1000 --warn-common --strip-all '
|
|
cd work
|
|
ld $LDFLAGS -T ../further/linker.ld -o kernel.elf kernel.o
|
|
cd ..
|
|
}
|
|
|
|
|
|
iso () {
|
|
headline "iso"
|
|
cd iso
|
|
test -e minal.iso && rm minal.iso
|
|
grub-mkrescue -o minal.iso .
|
|
cd ..
|
|
}
|
|
|
|
|
|
build-iso () {
|
|
copy
|
|
echo "Minal-OS 2022-September fasm for x86_64 compiled at `date +'%F %X'`" >work/version.txt
|
|
assemble
|
|
linking
|
|
test -e work/kernel.elf || error "No kernel found."
|
|
mv work/kernel.elf iso/boot
|
|
iso
|
|
}
|
|
|
|
#----------------------------------------------------------------------------
|
|
# start
|
|
|
|
start-qemu () {
|
|
qemu-system-x86_64 -m 64 -cdrom iso/minal.iso
|
|
}
|
|
|
|
|
|
start-vbox () {
|
|
VBoxManage startvm Minal
|
|
}
|
|
|
|
|
|
restart-vbox () {
|
|
VBoxManage controlvm Minal poweroff
|
|
sleep 1
|
|
VBoxManage startvm Minal
|
|
}
|
|
#----------------------------------------------------------------------------
|
|
# help
|
|
|
|
list-macros () { grep -n '^macro ' fasm/* |grep $1 ; }
|
|
list-funcs () { grep -n '^func ' fasm/* |grep $1 ; }
|
|
list-mess () { grep -n ' says ' fasm/* |grep $1 ; }
|
|
|
|
count_lines () { wc -l fasm/* ; wc -l inc/*; }
|
|
|
|
print-help () {
|
|
cat <<EOF
|
|
======= minal-go
|
|
options:
|
|
EOF
|
|
PAREN=') '
|
|
grep ' -.*'$PAREN minal
|
|
|
|
}
|
|
|
|
|
|
#----------------------------------------------------------------------------
|
|
# commands
|
|
|
|
command=$1
|
|
case $command in
|
|
|
|
-mm) build-iso # Build new iso.
|
|
;;
|
|
-sq) start-qemu # Start iso with qemu.
|
|
;;
|
|
-svb) start-vbox # Start iso with VirtualBox.
|
|
;;
|
|
-iter) build-iso; restart-vbox # Stop running, start new VM.
|
|
;;
|
|
-lm) list-macros $2 # ./minal -lm *|<str>
|
|
;;
|
|
-lf) list-funcs $2 # ./minal -lf *|<str>
|
|
;;
|
|
-lmess) list-mess $2 # ./minal -lmess *|<str>
|
|
;;
|
|
-wc) count_lines
|
|
;;
|
|
-asm)
|
|
cd further
|
|
nasm -f elf64 -l asm.txt asm.asm
|
|
;;
|
|
-run-file-server)
|
|
LOG="mlog.txt"
|
|
tail -f $LOG | sbcl --script further/file-server.lisp
|
|
;;
|
|
*) print-help # Print this text.
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
#----------------------------------------------------------------------------
|
|
# end
|
|
|