chore: remove build.sh

This commit is contained in:
d0p1 🏳️‍⚧️ 2024-07-18 12:36:43 +02:00
parent dc252706cd
commit 0ce1e73a09
6 changed files with 47 additions and 204 deletions

200
build.sh
View file

@ -1,200 +0,0 @@
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# log reporting
# -----------------------------------------------------------------------------
plain() {
local mesg=$1; shift
# shellcheck disable=SC2059
printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@"
}
msg() {
local mesg=$1; shift
# shellcheck disable=SC2059
printf "${MAGENTA}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@"
}
msg2() {
local mesg=$1; shift
# shellcheck disable=SC2059
printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@"
}
error() {
local mesg=$1; shift
# shellcheck disable=SC2059
printf "${RED}==> ERROR:${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@"
exit 1
}
warning() {
local mesg=$1; shift
# shellcheck disable=SC2059
printf "${YELLOW}==> WARNING:${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@"
}
success() {
local mesg=$1; shift
# shellcheck disable=SC2059
printf "${GREEN}==> SUCCESS:${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@"
}
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# build
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# tools
# -----------------------------------------------------------------------------
build_tools() {
msg "Builing tools"
plain "tools dir: %s" "${TOOLS_DIR}"
make tools
}
# -----------------------------------------------------------------------------
# doctor - check os dependancies
# -----------------------------------------------------------------------------
check_tool() {
local tool=$1; shift
printf "checking for %s " "${tool}"
tool_path="$(which "${tool}" 2> /dev/null)"
if [ -z "${tool_path}" ]; then
# shellcheck disable=SC2059
printf "${BOLD}${RED}NO${ALL_OFF}\n"
false;
else
# shellcheck disable=SC2059
printf "${GREEN}${tool_path}${ALL_OFF}\n"
true;
fi
}
doctor() {
local err=0
check_tool fasm || ((err++))
check_tool gcc || ((err++))
check_tool bmake || ((err++))
check_tool sha256sum || ((err++))
check_tool python3 || ((err++))
if [ $err -gt 0 ]; then error "Some tools are missing"; fi
}
# -----------------------------------------------------------------------------
# usage & version
# -----------------------------------------------------------------------------
usage() {
local status=$1
if [ ${status} -eq 0 ]; then
cat <<EOF
Usage: $prgname [-hV] [COMMANDS]
Flags:
-h display this menu.
-V display version information.
Options:
Commands:
doctor
tools
build
EOF
else
printf "Try '%s -h' for more information.\n" "${prgname}" >&2
fi
exit ${status}
}
version() {
VERSION_MAJOR="$(grep VERSION_MAJOR kernel/const.inc | cut -d' ' -f 3)"
VERSION_MINOR="$(grep VERSION_MINOR kernel/const.inc | cut -d' ' -f 3)"
printf "%s (StupidOS) %d.%d\n" "${prgname}" ${VERSION_MAJOR} ${VERSION_MINOR}
exit 0
}
# -----------------------------------------------------------------------------
# entry
# -----------------------------------------------------------------------------
LC_ALL=C
export LC_ALL
unset INFODIR
unset LESSCHARSET
unset MAKEFLAGS
unset TERMINFO
unset ALL_OFF BOLD RED GREEN BLUE MAGENTA YELLOW
if [ ! -v NO_COLOR ]; then
ALL_OFF="\e[1;0m"
BOLD="\e[1;1m"
BLUE="${BOLD}\e[1;34m"
GREEN="${BOLD}\e[1;32m"
RED="${BOLD}\e[1;31m"
MAGENTA="${BOLD}\e[1;35m"
YELLOW="${BOLD}\e[1;33m"
fi
readonly ALL_OFF BOLD RED GREEN BLUE MAGENTA YELLOW
unset topdir prgname build_start
prgname="$(basename $0)"
topdir="$(realpath "$0")"
topdir="$(dirname "${topdir}")"
#build_start="$(date)"
readonly topdir prgname
#build_start
SRC_DIR="${topdir}"
BUILD_DIR="${topdir}/.build"
TOOLS_DIR="${topdir}/.tools"
TOOLS_PREFIX="stpd-"
export PATH="$PATH:$TOOLS_DIR"
if [ ! -f Makefile ] || [ ! -f LICENSE ]; then
error "Run this script at StupidOS root"
fi
if [ $# -eq 0 ]; then
usage 1
fi
while [ $# -gt 0 ]; do
op=$1; shift
case "${op}" in
help | --help | -h)
usage 0
;;
--version | -V)
version
;;
doctor)
doctor
;;
tools)
build_tools
;;
*)
usage 1
;;
esac
done

View file

@ -1,6 +1,28 @@
;; File: com.inc
;;
;; Usefull links:
;; - <PC16550D datasheet at https://www.scs.stanford.edu/10wi-cs140/pintos/specs/pc16550d.pdf>
COM_MAJOR = 1
COM1 = 0x3F8
COM2 = 0x2F8
COM3 = 0x3E8
COM4 = 0x2E8
UART8250_RBR = 0x0
UART8250_THR = 0x0
UART8250_IER = 0x1
UART8250_IIR = 0x2
UART8250_FCR = 0x2
UART8250_LCR = 0x3
UART8250_MCR = 0x4
UART8250_LSR = 0x5
UART8250_MSR = 0x6
UART8250_SCR = 0x7
; DLAB = 1
UART8250_DLL = 0x0
UART8250_DLH = 0x1
com_init:
ret
@ -8,9 +30,13 @@ com_init:
com_probe:
ret
com_irq:
com_irq1:
pusha
popa
iret
com_irq2:
pusha
popa
iret

View file

@ -74,7 +74,6 @@ ne2k_init:
ne2k_probe:
ret
ne2k_irq:

View file

@ -66,3 +66,8 @@ gdt_flush:
mov gs, ax
mov ss, ax
ret
tss_flush:
mov ax, 0x2B
ltr ax
ret

View file

@ -33,14 +33,22 @@ idt_setup:
cmp ecx, 0x30
jb @b
mov ecx, 35
mov eax, com_irq2
call idt_set_gate
mov ecx, 36
mov eax, com_irq
mov eax, com_irq1
call idt_set_gate
mov ecx, 38
mov eax, floppy_irq
call idt_set_gate
mov ecx, 41
mov eax, ne2k_irq
call idt_set_gate
mov ecx, 0x42
mov eax, isr_syscall
call idt_set_gate

View file

@ -71,6 +71,7 @@ kmain:
call gdt_set_tss
call gdt_flush
call tss_flush
call idt_setup
@ -86,6 +87,8 @@ kmain:
;mov al, 'X'
;call cga_putc
.halt:
hlt
jmp $
@ -96,6 +99,8 @@ kmain:
jmp .halt
include 'dev/at/cmos.inc'
include 'dev/at/com.inc'
include 'dev/at/ne2k.inc'
include 'dev/at/pit.inc'
include 'dev/at/kbd.inc'
include 'dev/at/cga.inc'