chore: sync repo

- add various comments
- add stpd.file.mk
- etc
This commit is contained in:
d0p1 🏳️‍⚧️ 2025-10-30 16:36:18 +01:00
parent 62127fc4fd
commit 5c2c3bb348
57 changed files with 322 additions and 142 deletions

6
.gdbinit Normal file
View file

@ -0,0 +1,6 @@
set disassembly-flavor intel
add-symbol-file .build/syms/stpdldr.sym
add-symbol-file .build/syms/vmstupid.sym
target remote localhost:1234

4
.gitignore vendored
View file

@ -3,6 +3,7 @@
*.img
*.bin
*.iso
*.hdd
*.exe
*~
\#*\#
@ -39,6 +40,5 @@ bochsrc.bxrc
*.dbg
webring.json
webring.txt
kernel/const.inc
boot/common/const.inc
kernel/sys/version.inc
.build

View file

@ -1,6 +1,6 @@
BSD 3-Clause License
Copyright (c) 2024, d0p1
Copyright (c) 2025, d0p1
All rights reserved.
Redistribution and use in source and binary forms, with or without

View file

@ -21,7 +21,7 @@ SUBDIRS := external tools include lib bin sbin boot kernel modules tests
BUILD_RULES := build-tools .WAIT
BUILD_RULES += includes-kernel includes-include includes-lib .WAIT
BUILD_RULES += build-user build-kernel
BUILD_RULES += build-user build-kernel install-share
USER_RULES := install-lib .WAIT install-bin install-sbin
KERNEL_RULES := install-boot install-kernel install-modules
@ -58,6 +58,7 @@ build-kernel: $(KERNEL_RULES)
$(eval $(foreach X,kernel include lib,$(call subdir-rule,includes,$X)))
$(eval $(foreach X,lib bin sbin,$(call subdir-rule,install,$X)))
$(eval $(foreach X,boot kernel modules,$(call subdir-rule,install,$X)))
$(eval $(foreach X,share,$(call subdir-rule,install,$X)))
.PHONY: stupid.tar.gz
stupid.tar.gz: $(BUILD_RULES)
@ -69,7 +70,7 @@ stupid.tar.gz: $(BUILD_RULES)
.PHONY: stupid.iso
stupid.iso: $(BUILD_RULES)
@echo "TODO"
@printf "%s: TODO\n" "$@"
.PHONY: stupid.hdd
stupid.hdd: $(BUILD_RULES)
@ -105,10 +106,13 @@ OVMF32.fd:
run: floppy1440.img
$(QEMU) $(QEMU_COMMON) \
-drive file=floppy1440.img,if=none,format=raw,id=boot \
-drive file=flat:rw:$(SYSROOTDIR),if=none,id=hdd \
-drive file=fat:rw:.build/sysroot,if=none,id=hdd \
-device floppy,drive=boot \
-global isa-fdc.bootindexA=0
debug: QEMU_COMMON += -s -S
debug: run
.PHONY: run-iso
run-iso: $(BUILD_RULES)
$(QEMU) $(QEMU_COMMON) \
@ -117,7 +121,7 @@ run-iso: $(BUILD_RULES)
.PHONY: run-efi
run-efi: OVMF32.fd $(BUILD_RULES)
$(QEMU) -bios OVMF32.fd \
-drive file=fat:rw:$(SYSROOTDIR),if=none,id=hdd \
-drive file=fat:rw:.build/sysroot,if=none,id=hdd \
-device ide-hd,drive=hdd
.PHONY: bochs
@ -131,9 +135,8 @@ bochs: $(BUILD_RULES)
.PHONY: docs
docs:
@mkdir -p docs/html
wget -O docs/webring.json "https://webring.devse.wiki/webring.json"
python3 docs/devsewebring.py docs/webring.json docs/webring.txt
naturaldocs -p docs/config -img docs/img -xi .build -i . -ro -o HTML docs/html
python3 docs/devsewebring.py -u "https://webring.devse.wiki" -o docs/webring.txt
naturaldocs -p docs/config -img docs/img -xi .build -xi sysroot -i . -ro -o HTML docs/html
cp docs/img/favicon.ico docs/html
# +------------------------------------------------------------------+

View file

@ -22,9 +22,6 @@ MBR_SRCS = mbr.asm \
.PHONY: all
all: $(BINS)
%.inc: %.inc.in
@$(VERSION_SH)
boot_floppy1440.bin: $(FLOPPY_SRCS)
$(MSG_BUILD)
@$(FASM) floppy.asm $@ >/dev/null
@ -44,6 +41,6 @@ boot_hdd.bin: $(HDD_SRCS)
.PHONY: install
install: $(BINS)
CLEANFILES = $(BINS) $(COMMON_DIR)/const.inc
CLEANFILES = $(BINS)
include stpd.clean.mk

View file

@ -44,7 +44,8 @@ volume_id dd 0xB00B135 ; hope mine will grow :'(
volume_label db 'Stupid Boot'
system_id db 'FAT12 '
;; Function: _start
;; Boot Sector entry point
_start:
cli
cld

View file

@ -12,7 +12,7 @@
mov ds, ax
mov es, ax
mov ss, ax
mov sp, ax
mov sp, 0x7c00
cld
; relocate from 0x7C00 to 0x0600
mov cx, 0x0100

62
boot/common/cfg.inc Normal file
View file

@ -0,0 +1,62 @@
;; File: cfg.inc
;;
;; Basic boot.cfg file
;; >
;; > textmode=no
;; > resolution=1024x768x32
;; >
;; Define: CFG_COMMENT
CFG_COMMENT = 0x3B ; ';'
;; Define: CFG_ENTRY_SEP
CFG_ENTRY_SEP = 0x3D ; '='
;; Define: CFG_RESOLUTION_SEP
CFG_RESOLUTION_SEP = 0x78 ; 'x'
;; Function: boot_cfg_parse
;;
boot_cfg_parse:
ret
;; Function: cfg_textmode_handler
cfg_textmode_handler:
ret
;; Function: cfg_resolution_handler
cfg_resolution_handler:
ret
;; Function: cfg_cmdline_handler
cfg_cmdline_handler:
ret
;; Function: cfg_kernel_handler
cfg_kernel_handler:
ret
;; Variable: bCfgTextMode
bCfgTextMode db TRUE
;; Variable: uCfgVideoWidth
uCfgVideoWidth dw 1024
;; Variable: uCfgVideoHeight
uCfgVideoHeight dw 768
;; Variable: uCfgVideoDepth
uCfgVideoDepth db 32
;; Constant: szCfgFile
szCfgFile db "BOOT CFG", 0
;; Constant: szErrorCfgNotFound
szErrorCfgNotFound db "boot.cfg not found", CR, LF, 0
;; Constant: szCfgYes
szCfgYes db "yes", 0
;; Constant: szCfgNo
szCfgNo db "no", 0
CfgTable:
db 8, "textmode"
dw cfg_textmode_handler
db 10, "resolution"
dw cfg_resolution_handler
db 7, "cmdline"
dw cfg_cmdline_handler
db 6, "kernel"
dw cfg_kernel_handler

View file

@ -15,17 +15,9 @@ KERNEL_PRELOAD = 0xF000
STACK_TOP = 0x7000
; ---------- Magic ------------
STPDBOOT_MAGIC = 0x53545044
STPDFS_MAGIC = 0x44505453
; ---------- Video ------------
VIDEO_WIDTH = 1024
VIDEO_HEIGHT = 768
VIDEO_DEPTH = 32
; --------- Version -----------
VERSION_MAJOR = @MAJOR@
VERSION_MINOR = @MINOR@
VERSION_COMMIT equ "@COMMIT@"
VERSION_FULL equ "@FULLVERSION@"
BUILD_DATE equ "@DATE@"

View file

@ -1,5 +1,6 @@
;; File: fat12.inc
;; Struc: fat_pbp
struc fat_bpb
{
.jump db 3 dup(?)
@ -17,7 +18,7 @@ struc fat_bpb
}
DEFN fat_bpb
;; Struct: fat_entry
;; Struc: fat_entry
struc fat_entry
{
.name db 8 dup ?
@ -49,8 +50,6 @@ DEFN fat_entry
ATTR_DIRECTORY = 0x10
ATTR_ARCHIVE = 0x20
;; Section: Globals
;; Function: fat_load_root
fat_load_root:
mov ax, DISK_BUFFER/0x10

View file

@ -14,9 +14,6 @@ BOOTIA32_EFI_SRCS = bootia32.asm \
.PHONY: all
all: BOOTIA32.EFI
%.inc: %.inc.in
@$(VERSION_SH)
BOOTIA32.EFI: $(BOOTIA32_EFI_SRCS)
$(MSG_BUILD)
@$(FASM) bootia32.asm $@ >/dev/null
@ -28,6 +25,6 @@ $(DESTDIR)/EFI/BOOT/BOOTIA32.EFI: BOOTIA32.EFI
$(MSG_INSTALL)
@install -D $< $@
CLEANFILES = BOOTIA32.EFI $(COMMON_DIR)/const.inc
CLEANFILES = BOOTIA32.EFI
include stpd.clean.mk

View file

@ -33,7 +33,6 @@ efimain:
LOG szHelloMsg
call efi_fs_init
; #=======================#

View file

@ -1,5 +1,6 @@
;; File: logger.inc
;; Macro: LOG
macro LOG msg, [arg] {
common
_ARGS = 0
@ -116,7 +117,7 @@ efi_log_time:
; GetTime(EFI_TIME *time, EFI_TIME_CAPS *cap)
EFI_CALL [fnGetTime], stEfiTime, 0
; Hours
; Hours
mov al, [stEfiTime + EFI_TIME.Hour]
xor ah, ah
mov cl, 10
@ -142,11 +143,11 @@ efi_log_time:
movzx cx, al
mov [szTime + 8], cx
movzx cx, ah
mov [szTime + 10], cx
; Secondes
; Secondes
mov al, [stEfiTime + EFI_TIME.Second]
xor ah, ah
mov cl, 10
@ -157,7 +158,7 @@ efi_log_time:
movzx cx, al
mov [szTime + 14], cx
movzx cx, ah
mov [szTime + 16], cx
@ -175,7 +176,7 @@ efi_log:
push esi
push edi
push ebx
push ebx
mov esi, eax
mov edi, eax

View file

@ -1,5 +1,6 @@
;; File: uefi.inc
;; Macro: EFI_CALL
macro EFI_CALL fn, [arg] {
common
_ARGS = 0
@ -15,6 +16,7 @@ macro EFI_CALL fn, [arg] {
end if
}
;; Macro: EFI_GET_INTERFACE
macro EFI_GET_INTERFACE reg, interface {
if interface in <ConsoleInHandle,ConIn,ConsOutHandle,ConOut,StandardErrorHandle,StdErr>
mov reg, [pEfiSystemTable]
@ -22,6 +24,7 @@ macro EFI_GET_INTERFACE reg, interface {
end if
}
;; Macro: EFI_INIT
macro EFI_INIT handle, table {
local efi_init_bad
local efi_init_end
@ -196,7 +199,7 @@ struc EFI_SYSTEM_TABLE
.FirmwareVendor UINTPTR
.FirmwareRevision UINT32
.ConsoleInHandle EFI_HANDLE
.ConIn UINTPTR
.ConIn UINTPTR
.ConsoleOutHandle EFI_HANDLE
.ConOut UINTPTR
.StandardErrorHandle EFI_HANDLE
@ -339,7 +342,7 @@ EFI_MEMORY_MORE_RELIABLE = 0x0000000000010000
EFI_MEMORY_RO = 0x0000000000020000
EFI_MEMORY_SP = 0x0000000000040000
EFI_MEMORY_CPU_CRYPTO = 0x0000000000080000
EFI_MEMORY_RUNTIME = 0x8000000000000000
EFI_MEMORY_RUNTIME = 0x8000000000000000
;; ========================================================================
;; EFI_RUNTIMES_SERVICES
;; ========================================================================
@ -544,7 +547,7 @@ EFI_FILE_SYSTEM = 0x0000000000000004
EFI_FILE_RESERVED = 0x0000000000000008
EFI_FILE_DIRECTORY = 0x0000000000000010
EFI_FILE_ARCHIVE = 0x0000000000000020
EFI_FILE_VALID_ATTR = 0x0000000000000037
EFI_FILE_VALID_ATTR = 0x0000000000000037
section '.data' data readable writeable

View file

@ -4,10 +4,13 @@ SYS_DIR = ../../kernel/sys
KERNEL = stpdldr
COMMON_SRCS = const.inc \
bootinfo.inc
bootinfo.inc \
cfg.inc \
bios.inc
SYS_SRCS = bootinfo.inc \
register.inc
register.inc \
mmu.inc
SRCS = loader.asm \
$(addprefix $(COMMON_DIR)/, $(COMMON_SRCS)) \
@ -21,10 +24,6 @@ SRCS = loader.asm \
stpdfs.inc \
disk.inc
.PHONY: $(COMMON_DIR)/const.inc
$(COMMON_DIR)/const.inc: $(COMMON_DIR)/const.inc.in
@$(VERSION_SH)
CLEANFILES = $(COMMON_DIR)/const.inc
FAS2SYMFLAGS = -t _start,_end
include stpd.kernel.mk

10
boot/loader/boot.cfg Normal file
View file

@ -0,0 +1,10 @@
; Boot configuration
;kernel=vmstupid.sys
;cmdline=
textmode=no
; resolution=*width*x*height*[x*bpp*]
resolution=1024x768x32

View file

@ -37,7 +37,7 @@ disk_read_sectors:
ret
@@:
mov si, szMsgErrorSector
call bios_print
call bios_log_error
ret
.lba_read:
push si

View file

@ -3,6 +3,8 @@
include '../common/const.inc'
include 'sys/macro.inc'
include 'sys/register.inc'
include 'sys/mmu.inc'
include 'multiboot.inc'
org LOADER_BASE
@ -174,7 +176,7 @@ _start:
.error_a20:
mov si, szMsgErrorA20
.error:
call bios_log
call bios_log_error
@@:
hlt
@ -190,8 +192,7 @@ _start:
include 'video.inc'
include 'gdt.inc'
include '../common/bootinfo.inc'
include '../../kernel/sys/register.inc'
include '../../kernel/sys/mmu.inc'
include '../common/cfg.inc'
uDrive rb 1
bDriveLBA db FALSE
@ -205,10 +206,10 @@ szKernelStpdfsFile db "vmstupid.sys", 0
szMsgStpdFSFound db "StupidFS found", 0
szMsgFatFallback db "Fallback to FATFS", 0
szMsgKernelFound db "Kernel found, size: %x", 0
szMsgErrorA20 db "ERROR: can't enable a20 line", 0
szMsgErrorMemory db "ERROR: can't detect available memory", 0
szMsgErrorSector db "ERROR: reading sector", CR, LF, 0
szMsgErrorNotFound db "ERROR: kernel not found", 0
szMsgErrorA20 db "can't enable a20 line", 0
szMsgErrorMemory db "can't detect available memory", 0
szMsgErrorSector db "reading sector", CR, LF, 0
szMsgErrorNotFound db "kernel not found", 0
use32
; =========================================================================
@ -282,7 +283,7 @@ common32:
cli ; ensure interrupt are disabled
mov eax, STPDBOOT_MAGIC
mov eax, BOOT_BOOTLOADER_MAGIC
mov ebx, boot_structure
mov ecx, 0xC0000000 + KERNEL_BASE

View file

@ -72,7 +72,7 @@ bios_log_number:
or cl, cl
jnz .loop_print
pop bx
pop dx
ret
@ -80,7 +80,7 @@ bios_log_number:
;; Function: bios_log_hex
;;
;; Parameters:
;; EDI - number
;; EDI - number
bios_log_hex:
push si
mov si, szHexPrefix
@ -116,6 +116,23 @@ bios_log_hex:
.end:
ret
bios_log_warn:
call bios_log_time
push si
mov si, szLogWarn
jmp bios_log_error.common
;; Function: bios_log_error
;;
bios_log_error:
call bios_log_time
push si
mov si, szLogError
.common:
call bios_print
pop si
jmp bios_log.loop
;; Function: bios_log
;;
;; Parameters:
@ -157,7 +174,7 @@ bios_log:
jne .unknown_format
pop ax
pop word di
push ax
push ax
call bios_log_number
jmp .next
.unknown_format:
@ -174,9 +191,10 @@ bios_log:
ret
szTime db '[00:00:00] ', 0
szHexPrefix db '0x', 0
sDigits db '0123456789ABCDEF'
szEndLine db CR, LF, 0
szBuffer db '00000000', 0
szLogError db 'ERROR: ', 0
szLogWarn db 'WARN: ', 0

View file

@ -1,39 +1,39 @@
;; File: memory.inc
;; Detect available memory
;;
;; Constants: Address type
;; Detect available memory
;;
;; See <AddressRange.Type>
;;
;; ADDRESS_RANGE_MEMORY - Available and usable RAM.
;; ADDRESS_RANGE_RESERVED - Reserved or in use.
ADDRESS_RANGE_MEMORY = 1
ADDRESS_RANGE_RESERVED = 2
;; Struct: AddressRange
struc E820AddressRange
{
;; Variable: BaseAddrLow
;; Low 32 Bits of Base Address
;; Constants: Memory type
;;
;; E820_MEMORY_USABLE - Normal RAM
;; E820_MEMORY_RESERVED - xxx
;; E820_MEMORY_ACPI_RECLAIMABLE - XXXX
;; E820_MEMORY_NVS - xxx
;; E820_MEMORY_BAD - Bad region
E820_MEMORY_USABLE = 1
E820_MEMORY_RESERVED = 2
E820_MEMORY_ACPI_RECLAIMABLE = 3
E820_MEMORY_NVS = 4
E820_MEMORY_BAD = 5
;; Struc: E820AddressRange
;;
;; .BaseAddrLow - Low 32 bits of Base Address
;; .BaseAddrHigh - High 32 Bits of Base Address
;; .LengthLow - Low 32 Bits of Length in Bytes
;; .LengthHigh - High 32 Bits of Length in Bytes
;; .Type - Address type of this range. See <Memory type>
struc E820AddressRange {
.BaseAddrLow dd ?
;; Variable: BaseAddrHigh
;; High 32 Bits of Base Address
.BaseAddrHigh dd ?
;; Variable: LengthLow
;; Low 32 Bits of Length in Bytes
.LengthLow dd ?
;; Variable: LengthHigh
;; High 32 Bits of Length in Bytes
.LengthHigh dd ?
;; Variable: Type
;; Address type of this range. <Address type>
.Type dd ?
}
;; Function: memory_e820_get_mmap_entry
;;
;; Function: memory_e820_get_map
;;
;; In:
;; EAX - Function code
;; EBX - Continuation
@ -49,7 +49,7 @@ struc E820AddressRange
;; EBX - Continuation
memory_e820_get_map:
xor ebx, ebx
@@:
@@:
clc
xor eax, eax
mov es, ax
@ -64,7 +64,7 @@ memory_e820_get_map:
or ebx, ebx
jz .end
cmp [pE280AddrRange.Type], 0x1
cmp [pE280AddrRange.Type], E820_MEMORY_USABLE
jne @b
mov ecx, [pE280AddrRange.BaseAddrHigh]
@ -113,11 +113,11 @@ memory_get_for_large_conf:
@@:
ret
;; Function: memory_get_extended_memory_size
;; Function: memory_get_map
;;
;; In:
;; AH - Function code 88h
;;
;;
;; Out:
;; CF - Non-Carry - indicates no error
;; AX - Number of contiguous KB above 1MB

View file

@ -1,4 +1,8 @@
;; File: multiboot.inc
;; Define: MULTIBOOT_HDR_MAGIC
MULTIBOOT_HDR_MAGIC = 0x1BADB002
;; Define: MULTIBOOT_MAGIC
MULTIBOOT_MAGIC = 0x2BADB002
MULTIBOOT_HDR_ALIGN = 0x1
@ -7,6 +11,7 @@ MULTIBOOT_HDR_VIDEO = 0x4
MULTIBOOT_HDR_AOUT_KLUDGE = 0x10000
MULTIBOOT_FLAGS = MULTIBOOT_HDR_ALIGN or MULTIBOOT_HDR_MEMINFO or MULTIBOOT_HDR_VIDEO or MULTIBOOT_HDR_AOUT_KLUDGE
;; Struc: MultibootHeader
struc MultibootHeader addr
{
.magic dd MULTIBOOT_HDR_MAGIC
@ -27,6 +32,7 @@ struc MultibootHeader addr
.depth dd VIDEO_DEPTH
}
;; Struc: MultibootData
struc MultibootData
{
.flags dd ?
@ -94,6 +100,7 @@ MULTIBOOT_DATA_BOOTLOADER_NAME = 0x0200
MULTIBOOT_DATA_VBE = 0x0800
MULTIBOOT_DATA_FB = 0x1000
;; Struc: MultibootMMap
struc MultibootMMap
{
.size dd ?
@ -109,6 +116,7 @@ MULTIBOOT_MEMORY_ACPI = 0x3
MULTIBOOT_MEMORY_NVS = 0x4
MULTIBOOT_MEMORY_BADPARAM = 0x5
;; Struc: MultibootModule
struc MultibootModule
{
.mod_start dd ?

View file

@ -116,6 +116,8 @@ Format: 1.52
Alter Language: Assembly
Add Extensions: asm s inc
Class Prototype Ender: {
Function Prototype Ender: :
Macro Prototype Ender: {
Struct Prototype Ender: }
Constant Prototype Ender: \n
Struct Prototype Ender: {
Macro Prototype Enders: { \n

View file

@ -81,12 +81,6 @@ Format: 1.52
# topics [at] naturaldocs [dot] org.
Alter Topic Type: Macro
Add Keywords:
equ
Alter Topic Type: Section
Add Keywords:

View file

@ -1,14 +1,31 @@
import sys
import json
import requests
import argparse
from urllib.parse import urljoin
WEBRING_DEFURL = "https://webring.devse.wiki"
def get_webring_entries(url):
json_url = urljoin(url, "/webring.json")
req = requests.get(json_url)
if req.status_code != requests.codes.ok:
return []
return req.json()
def main(args):
entries = get_webring_entries(args.url)
with open(args.output, "w") as f:
f.write("File: Webring\n\n")
for entry in entries:
f.write(f"- <{entry['name']} at {entry['protocols']['http']['clearnet']}> : {entry['description']}\n\n")
if __name__ == '__main__':
source = sys.argv[1]
dest = sys.argv[2]
parser = argparse.ArgumentParser(prog='devsewebring.py')
parser.add_argument('-u', '--url',
type=str, help='set webring url',
default=WEBRING_DEFURL)
parser.add_argument('-o', '--output', type=str, help='output file')
data = None
with open(source, "r") as f:
data = json.load(f)
with open(dest, "w") as f:
f.write("File: Webring\n\n")
for entry in data:
f.write(f"- <{entry['name']} at {entry['protocols']['http']['clearnet']}> : {entry['description']}\n\n")
args = parser.parse_args()
main(args)

View file

@ -5,7 +5,8 @@ ASMINCS = sys/bootinfo.inc \
sys/macro.inc \
sys/mmu.inc \
sys/process.inc \
sys/register.inc
sys/register.inc \
sys/version.inc
KERNEL = vmstupid
@ -44,10 +45,10 @@ SRCS = kernel.asm \
FAS2SYMFLAGS = -t kmain,kend
.PHONY: const.inc
const.inc: const.inc.in
.PHONY: sys/version.inc
sys/version.inc: sys/version.inc.in
@$(VERSION_SH)
CLEANFILES = const.inc
CLEANFILES = sys/version.inc
include stpd.kernel.mk

View file

@ -7,15 +7,6 @@ KERNEL_HEAP_SIZE = 260046848
PSIZE = 0x1000
STPDBOOT_MAGIC = 0x53545044
; --------- VERSION -------------
VERSION_MAJOR = @MAJOR@
VERSION_MINOR = @MINOR@
VERSION_COMMIT equ "@COMMIT@"
VERSION_FULL equ "@FULLVERSION@"
BUILD_DATE equ "@DATE@"
; ------------- OTHER -----------
CR = 0x0D
LF = 0x0A

View file

@ -2,6 +2,7 @@
format binary
include 'const.inc'
include 'sys/version.inc'
include 'sys/macro.inc'
include 'sys/bootinfo.inc'
include 'sys/cpu.inc'
@ -26,7 +27,7 @@
kmain:
mov esp, stack_top
cmp eax, STPDBOOT_MAGIC
cmp eax, BOOT_BOOTLOADER_MAGIC
jne .error_magic
; Copy boot structure

View file

@ -1,4 +1,8 @@
;; File: object.inc
SVM_OBJ_ANON = 1
SVM_OBJ_FILE = 2
SVM_OBJ_DEVICE = 3
struc SvmObject {
.refcount dd ?

View file

@ -1,12 +1,12 @@
;; File: bootinfo.inc
;; StupidOS Boot protocol constants and structs
;; Constant: BOOT_HEADER_MAGIC
;; Define: BOOT_HEADER_MAGIC
BOOT_HEADER_MAGIC = 0x44505453
;; Constant: BOOT_BOOTLOADER_MAGIC
;; Define: BOOT_BOOTLOADER_MAGIC
BOOT_BOOTLOADER_MAGIC = 0x53545044
;; Struct: BootHeader
;; Struc: BootHeader
;;
;; .magic - Must be <BOOT_HEADER_MAGIC>
;; .load_end_addr - TODO
@ -14,12 +14,12 @@ BOOT_BOOTLOADER_MAGIC = 0x53545044
;; .entry_addr - Kernel entry point
struc BootHeader {
.magic dd ?
.entry_addr dd ?
.load_end_addr dd ?
.bss_end_addr dd ?
.entry_addr dd ?
}
;; Struct: BootMMapEntry
;; Struc: BootMMapEntry
;; Memory map entry
;;
;; .base - TODO
@ -28,14 +28,18 @@ struc BootMMapEntry {
.base dq ?
.length dq ?
}
DEFN BootMMapEntry
;; Struct: BootInfoRange
;; Define: BOOT_MAX_MMAP_ENTRY
BOOT_MAX_MMAP_ENTRY = 16
;; Struc: BootInfoRange
struc BootInfoRange {
.base dd ?
.length dd ?
}
;; Struct: BootInfo
;; Struc: BootInfo
;; StupidOS boot protocol structure
;;
;; .mmap - Free memory map
@ -50,7 +54,4 @@ struc BootInfo {
.high_mem dd ?
.low_mem dd ?
}
virtual at 0
BootInfo BootInfo
sizeof.BootInfo:
end virtual
DEFN BootInfo

View file

@ -0,0 +1,5 @@
VERSION_MAJOR = @MAJOR@
VERSION_MINOR = @MINOR@
VERSION_COMMIT equ "@COMMIT@"
VERSION_FULL equ "@FULLVERSION@"
BUILD_DATE equ "@DATE@"

View file

@ -1,5 +1,8 @@
#include <stdlib.h>
#include <string.h>
#include <fdisk/disk.h>
/*
int
disk_init(struct disk *dsk, struct device *dev)
{
@ -9,5 +12,8 @@ disk_init(struct disk *dsk, struct device *dev)
}
memset(dsk, 0, sizeof(struct disk));
disk->dev = dev;
dsk->dev = dev;
return (0);
}
*/

View file

@ -1,11 +1,11 @@
.Dd $Mdocdate$
.Dt PARTED 8
.Dt FDISK 8
.Os
.Sh NAME
.Nm parted
.Nm fdisk
.Nd a partition utility
.Sh SYNOPSIS
.Nm parted
.Nm fdisk
.Op Fl d
.Op Fl p Ar 0-3
.Op Fl o Ar file

View file

@ -12,6 +12,7 @@ readline(const char *prompt)
size_t linsz = 0;
size_t buffsz;
char *line = NULL;
char *tmp = NULL;
char buffer[BUFFSZ];
printf(prompt);
@ -19,12 +20,15 @@ readline(const char *prompt)
{
buffsz = strlen(buffer);
line = realloc(line, linsz + buffsz + 1);
if (line == NULL)
tmp = realloc(line, linsz + buffsz + 1);
if (tmp == NULL)
{
free(line);
return (NULL);
}
line = tmp;
memcpy(line + linsz, buffer, buffsz);
linsz += buffsz;
line[linsz] = '\0';

3
share/Makefile Normal file
View file

@ -0,0 +1,3 @@
SUBDIRS = doc mk
include stpd.subdirs.mk

4
share/doc/Makefile Normal file
View file

@ -0,0 +1,4 @@
FILESDIR = /usr/share/doc
FILES = manifesto.texi
include stpd.files.mk

32
share/man/boot.cfg.5 Normal file
View file

@ -0,0 +1,32 @@
.Dd October 27, 2025
.Dt BOOT.CFG 5
.Os
.Sh NAME
.Nm boot.cfg
.Nd configuration file for StupidBoot
.Sh DESCRIPTION
The file
.Pa /boot.cfg
XXXX
.Ss FILE FORMAT
.Pq Sq = .
Lines begining with a semi-colon
.Pq Sq \;
are comments and are ignored.
.Bl -tag -width resolution
.It Sy textmode
XXX
.It Sy resolution
XXX
.It Sy kernel
XXX
.It Sy cmdline
xxxx
.El
.Sh EXAMPLES
.Bd -literal -offset indent
textmode=no
resolution=1024x768x32
.Ed
.Sh SEE ALSO
.Xr stpdldr.sys 8

6
share/mk/Makefile Normal file
View file

@ -0,0 +1,6 @@
FILESDIR = /usr/share/mk
FILES = stpd.base.mk stpd.clean.mk stpd.files.mk stpd.hostlib.mk
FILES += stpd.hostprog.mk stpd.inc.mk stpd.kernel.mk stpd.lib.mk
FILES += stpd.man.mk stpd.module.mk stpd.subdirs.mk
include stpd.files.mk

13
share/mk/stpd.files.mk Normal file
View file

@ -0,0 +1,13 @@
include stpd.base.mk
FILESDIR?= $(BINDIR)
ifdef FILES
$(DESTDIR)$(FILESDIR)/%: %
$(MSG_INSTALL)
@install -D $< $@
install: $(addprefix $(DESTDIR)$(FILESDIR)/, $(FILES))
endif

View file

@ -24,7 +24,7 @@ $(SYMSDIR)/$(KERNEL).sym: $(KERNEL).sym
$(MSG_INSTALL)
@install -D $< $@
CLEANFILES += $(KERNEL).sys $(KERNEL).fas $(KERNEL).sys
CLEANFILES += $(KERNEL).sys $(KERNEL).fas $(KERNEL).sym
include stpd.inc.mk
include stpd.clean.mk

View file

@ -1,6 +1,6 @@
VPATH = $(TOPDIR)/sbin/parted
VPATH = $(TOPDIR)/sbin/fdisk
HOSTPROG = fdisk
HOST_CPPFLAGS += -I$(TOPDIR)/sbin/parted
HOST_CPPFLAGS += -I$(TOPDIR)/sbin/fdisk
SRCS = main.c repl.c cmd.c version.c fildev.c
include stpd.hostprog.mk