docs: minor change

This commit is contained in:
d0p1 🏳️‍⚧️ 2024-07-05 08:16:40 +02:00
parent c97a637ecd
commit 2d48606692
11 changed files with 256 additions and 182 deletions

View file

@ -1,16 +1,23 @@
;; File: bootinfo.inc ;; File: bootinfo.inc
;; Struct: BootInfoRange
struc BootInfoRange { struc BootInfoRange {
.base dd ? .base dd ?
.legth dd ? .legth dd ?
} }
;; Struct: BootInfo
;;
;; StupidOS boot protocol structure
struc BootInfo { struc BootInfo {
.mmap dd 4*2*40 dup(0) .mmap dd 4*2*40 dup(0)
.kernel_start dd ? .kernel_start dd ?
.kernel_size dd ? .kernel_size dd ?
} }
;; Section: Globals
;; Constant: BOOTINFO_MEMORY_LIMIT
BOOTINFO_MEMORY_LIMIT = 0xFFFFF000 BOOTINFO_MEMORY_LIMIT = 0xFFFFF000

View file

@ -1,12 +1,6 @@
;; File: fat12.inc ;; File: fat12.inc
ATTR_READ_ONLY = 0x01 ;; Struct: fat_entry
ATTR_HIDDEN = 0x02
ATTR_SYSTEM = 0x04
ATTR_VOLUME_ID = 0x08
ATTR_DIRECTORY = 0x10
ATTR_ARCHIVE = 0x20
struc fat_entry struc fat_entry
{ {
.name db 8 dup ? .name db 8 dup ?
@ -24,6 +18,22 @@ struc fat_entry
} }
defn fat_entry defn fat_entry
;; Constants: Attributes
;; ATTR_READ_ONLY - Read-only
;; ATTR_HIDDEN - Hidden
;; ATTR_SYSTEM - System
;; ATTR_VOLUME_ID - Volume label
;; ATTR_DIRECTORY - Subdirectory
;; ATTR_ARCHIVE - Archive
ATTR_READ_ONLY = 0x01
ATTR_HIDDEN = 0x02
ATTR_SYSTEM = 0x04
ATTR_VOLUME_ID = 0x08
ATTR_DIRECTORY = 0x10
ATTR_ARCHIVE = 0x20
;; Section: Globals
;; Function: fat_load_root ;; Function: fat_load_root
fat_load_root: fat_load_root:
mov ax, DISK_BUFFER/0x10 mov ax, DISK_BUFFER/0x10

View file

@ -1,3 +1,6 @@
;; File: macro.inc
;; Macro: defn name
macro defn name macro defn name
{ {
virtual at 0 virtual at 0

View file

@ -1,171 +1,177 @@
; copy/pasted from https://wiki.osdev.org/A20_Line ;; File: a20.inc
; .... sorry I was lazy :x ;; copy/pasted from https://wiki.osdev.org/A20_Line
;; .... sorry I was lazy :x
a20_get_state:
pushf ;; Function: a20_get_state
push si a20_get_state:
push di pushf
push ds push si
push es push di
push ds
cli push es
xor ax, ax cli
mov ds, ax
mov si, 0x500 xor ax, ax
mov ds, ax
not ax mov si, 0x500
mov es, ax
mov di, 0x0510 not ax
mov es, ax
mov al, [ds:si] ; save old values mov di, 0x0510
mov byte [.BufferBelowMB], al
mov al, [es:di] mov al, [ds:si] ; save old values
mov byte [.BufferOverMB], al mov byte [.BufferBelowMB], al
mov al, [es:di]
mov ah, 1 ; check byte [0x00100500] == byte [0x0500] mov byte [.BufferOverMB], al
mov byte [ds:si], 0
mov byte [es:di], 1 mov ah, 1 ; check byte [0x00100500] == byte [0x0500]
mov al, [ds:si] mov byte [ds:si], 0
cmp al, [es:di] mov byte [es:di], 1
jne .exit mov al, [ds:si]
dec ah cmp al, [es:di]
.exit: jne .exit
mov al, [.BufferBelowMB] dec ah
mov [ds:si], al .exit:
mov al, [.BufferOverMB] mov al, [.BufferBelowMB]
mov [es:di], al mov [ds:si], al
shr ax, 8 mov al, [.BufferOverMB]
sti mov [es:di], al
pop es shr ax, 8
pop ds sti
pop di pop es
pop si pop ds
popf pop di
ret pop si
popf
.BufferBelowMB: db 0 ret
.BufferOverMB db 0
.BufferBelowMB: db 0
.BufferOverMB db 0
a20_query_support:
push bx ;; Function: a20_query_support
clc a20_query_support:
push bx
mov ax, 0x2403 clc
int 0x15
jc .error mov ax, 0x2403
int 0x15
test ah, ah jc .error
jnz .error
test ah, ah
mov ax, bx jnz .error
pop bx
ret mov ax, bx
.error: pop bx
stc ret
pop bx .error:
ret stc
pop bx
a20_enable_keyboard_controller: ret
cli
;; Function: a20_enable_keyboard_controller
call .wait_io1 a20_enable_keyboard_controller:
mov al, 0xad cli
out 0x64, al
call .wait_io1
call .wait_io1 mov al, 0xad
mov al, 0xd0 out 0x64, al
out 0x64, al
call .wait_io1
call .wait_io2 mov al, 0xd0
in al, 0x60 out 0x64, al
push eax
call .wait_io2
call .wait_io1 in al, 0x60
mov al, 0xd1 push eax
out 0x64, al
call .wait_io1
call .wait_io1 mov al, 0xd1
pop eax out 0x64, al
or al, 2
out 0x60, al call .wait_io1
pop eax
call .wait_io1 or al, 2
mov al, 0xae out 0x60, al
out 0x64, al
call .wait_io1
call .wait_io1 mov al, 0xae
sti out 0x64, al
ret
.wait_io1: call .wait_io1
in al, 0x64 sti
test al, 2 ret
jnz .wait_io1 .wait_io1:
ret in al, 0x64
.wait_io2: test al, 2
in al, 0x64 jnz .wait_io1
test al, 1 ret
jz .wait_io2 .wait_io2:
ret in al, 0x64
test al, 1
; out: jz .wait_io2
; cf - set on error ret
a20_enable:
clc ; clear cf ;; Function: a20_enable
pusha ;;
mov bh, 0 ; clear bh ;; Out:
;; CF - set on error
call a20_get_state ;;
jc .fast_gate a20_enable:
clc ; clear cf
test ax, ax pusha
jnz .done mov bh, 0 ; clear bh
call a20_query_support call a20_get_state
mov bl, al jc .fast_gate
test bl, 1 ; enable A20 using keyboard controller
jnz .keybord_controller test ax, ax
jnz .done
test bl, 2 ; enable A20 using fast A20 gate
jnz .fast_gate call a20_query_support
.bios_int: mov bl, al
mov ax, 0x2401 test bl, 1 ; enable A20 using keyboard controller
int 0x15 jnz .keybord_controller
jc .fast_gate
test ah, ah test bl, 2 ; enable A20 using fast A20 gate
jnz .failed jnz .fast_gate
call a20_get_state .bios_int:
test ax, ax mov ax, 0x2401
jnz .done int 0x15
.fast_gate: jc .fast_gate
in al, 0x92 test ah, ah
test al, 2 jnz .failed
jnz .done call a20_get_state
test ax, ax
or al, 2 jnz .done
and al, 0xfe .fast_gate:
out 0x92, al in al, 0x92
test al, 2
call a20_get_state jnz .done
test ax, ax
jnz .done or al, 2
and al, 0xfe
test bh, bh ; test if there was an attempt using the keyboard controller out 0x92, al
jnz .failed
.keybord_controller: call a20_get_state
call a20_enable_keyboard_controller test ax, ax
call a20_get_state jnz .done
test ax, ax
jnz .done test bh, bh ; test if there was an attempt using the keyboard controller
jnz .failed
mov bh, 1 ; flag enable attempt with keyboard controller .keybord_controller:
call a20_enable_keyboard_controller
test bl, 2 call a20_get_state
jnz .fast_gate test ax, ax
jmp .failed jnz .done
.failed:
stc mov bh, 1 ; flag enable attempt with keyboard controller
.done:
popa test bl, 2
ret jnz .fast_gate
jmp .failed
.failed:
stc
.done:
popa
ret

View file

@ -14,6 +14,8 @@
multiboot_header: multiboot_header:
mb_header MultibootHeader multiboot_header mb_header MultibootHeader multiboot_header
;; Function: _start
;; Loader entry point.
_start: _start:
cmp eax, MULTIBOOT_MAGIC cmp eax, MULTIBOOT_MAGIC
je multiboot je multiboot

View file

@ -56,6 +56,7 @@ struc VesaModeInfo
.Reserved2 db 206 dup(?) .Reserved2 db 206 dup(?)
} }
;; Function: video_setup
video_setup: video_setup:
mov si, szMsgDetectVideo mov si, szMsgDetectVideo
call bios_log call bios_log

View file

@ -11,4 +11,9 @@ fi
DESTDIR=${BUILDDIR}/iso DESTDIR=${BUILDDIR}/iso
mkdir -p "${OBJ}"
(cd "${OBJ}"; get_grub)
make make

View file

@ -10,5 +10,15 @@ fi
. ./releasetools/image.functions . ./releasetools/image.functions
DESTDIR=${BUILDDIR}/floppy DESTDIR=${BUILDDIR}/floppy
export DESTDIR export DESTDIR
mkdir -p "${BUILDDIR}" "${OBJ}"
mkdir -p "${DESTDIR}/boot"
create_stpdboot_ini "${DESTDIR}/boot"
make
echo ""
echo "floppy image at $(pwd)/${IMG}"

View file

@ -11,10 +11,21 @@ fi
. ./releasetools/image.defaults . ./releasetools/image.defaults
. ./releasetools/image.functions . ./releasetools/image.functions
DESTDIR=${BUILDDIR}/hd
export DESTDIR
if [ -f "${IMG}" ] if [ -f "${IMG}" ]
then then
rm -f "${IMG}" rm -f "${IMG}"
fi fi
mkdir -p "${BUILDDIR}" "${OBJ}"
mkdir -p "${DESTDIR}/boot"
create_stpdboot_ini "${DESTDIR}/boot"
make
echo "" echo ""
echo "Disk image at $(pwd)/${IMG}" echo "Disk image at $(pwd)/${IMG}"

View file

@ -1,5 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
: "${BUILDDIR=.build}" : "${BUILDDIR=$(pwd)/.build}"
: "${OBJ=${BUILDDIR}/obj}" : "${OBJ=${BUILDDIR}/obj}"
: "${DESTDIR=${BUILDDIR}/dist}" : "${DESTDIR=${BUILDDIR}/dist}"
: "${TOOLSDIR=$(pwd)/.tools}"

View file

@ -19,12 +19,18 @@ menuentry "StupidOS" {
EOF EOF
)" )"
echo "$grub_cfg" > "$target" echo "$grub_cfg" > "${target}/grub.cfg"
} }
get_grub() get_grub()
{ {
echo local version="2.12"
local url="https://ftp.gnu.org/gnu/grub/grub-${version}.tar.gz"
wget "${url}"
tar -xvf "grub-${version}.tar.gz"
(cd "grub-${version}"; ./configure --prefix="${TOOLSDIR}" && make install)
} }
create_efi_image() create_efi_image()
@ -32,3 +38,15 @@ create_efi_image()
echo echo
} }
create_stpdboot_ini()
{
local target="$1"
local stupid_ini="$(cat <<EOF
CMDLINE=consdev=com0
MODULE=dummy.mod
MODULE=dummy2.mod
EOF
)"
echo "$stupid_ini" > "${target}/stupid.ini"
}