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
;; Struct: BootInfoRange
struc BootInfoRange {
.base dd ?
.legth dd ?
}
;; Struct: BootInfo
;;
;; StupidOS boot protocol structure
struc BootInfo {
.mmap dd 4*2*40 dup(0)
.kernel_start dd ?
.kernel_size dd ?
}
;; Section: Globals
;; Constant: BOOTINFO_MEMORY_LIMIT
BOOTINFO_MEMORY_LIMIT = 0xFFFFF000

View file

@ -1,12 +1,6 @@
;; File: fat12.inc
ATTR_READ_ONLY = 0x01
ATTR_HIDDEN = 0x02
ATTR_SYSTEM = 0x04
ATTR_VOLUME_ID = 0x08
ATTR_DIRECTORY = 0x10
ATTR_ARCHIVE = 0x20
;; Struct: fat_entry
struc fat_entry
{
.name db 8 dup ?
@ -24,6 +18,22 @@ struc 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
fat_load_root:
mov ax, DISK_BUFFER/0x10

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -10,5 +10,15 @@ fi
. ./releasetools/image.functions
DESTDIR=${BUILDDIR}/floppy
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.functions
DESTDIR=${BUILDDIR}/hd
export DESTDIR
if [ -f "${IMG}" ]
then
rm -f "${IMG}"
fi
mkdir -p "${BUILDDIR}" "${OBJ}"
mkdir -p "${DESTDIR}/boot"
create_stpdboot_ini "${DESTDIR}/boot"
make
echo ""
echo "Disk image at $(pwd)/${IMG}"

View file

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

View file

@ -19,12 +19,18 @@ menuentry "StupidOS" {
EOF
)"
echo "$grub_cfg" > "$target"
echo "$grub_cfg" > "${target}/grub.cfg"
}
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()
@ -32,3 +38,15 @@ create_efi_image()
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"
}