diff --git a/.gdbinit b/.gdbinit new file mode 100644 index 0000000..965c5d9 --- /dev/null +++ b/.gdbinit @@ -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 diff --git a/.gitignore b/.gitignore index 1643365..bc5be10 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/LICENSE b/LICENSE index af789a0..bb40d15 100644 --- a/LICENSE +++ b/LICENSE @@ -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 diff --git a/Makefile b/Makefile index fc15aea..f8b4ff1 100644 --- a/Makefile +++ b/Makefile @@ -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 # +------------------------------------------------------------------+ diff --git a/boot/bootsect/Makefile b/boot/bootsect/Makefile index adbc33e..e593073 100644 --- a/boot/bootsect/Makefile +++ b/boot/bootsect/Makefile @@ -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 diff --git a/boot/bootsect/floppy.asm b/boot/bootsect/floppy.asm index 55ac782..2248a04 100644 --- a/boot/bootsect/floppy.asm +++ b/boot/bootsect/floppy.asm @@ -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 diff --git a/boot/bootsect/mbr.asm b/boot/bootsect/mbr.asm index 35c8593..9143c7f 100644 --- a/boot/bootsect/mbr.asm +++ b/boot/bootsect/mbr.asm @@ -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 diff --git a/boot/common/cfg.inc b/boot/common/cfg.inc new file mode 100644 index 0000000..e9bdfcd --- /dev/null +++ b/boot/common/cfg.inc @@ -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 diff --git a/boot/common/const.inc.in b/boot/common/const.inc similarity index 67% rename from boot/common/const.inc.in rename to boot/common/const.inc index 64a71d7..7365616 100644 --- a/boot/common/const.inc.in +++ b/boot/common/const.inc @@ -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@" diff --git a/boot/common/fat12.inc b/boot/common/fat12.inc index 48db169..e0eb2e9 100644 --- a/boot/common/fat12.inc +++ b/boot/common/fat12.inc @@ -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 diff --git a/boot/efi/Makefile b/boot/efi/Makefile index 88e41e8..4c07e74 100644 --- a/boot/efi/Makefile +++ b/boot/efi/Makefile @@ -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 diff --git a/boot/efi/bootia32.asm b/boot/efi/bootia32.asm index 88a59ed..6b4e508 100644 --- a/boot/efi/bootia32.asm +++ b/boot/efi/bootia32.asm @@ -33,7 +33,6 @@ efimain: LOG szHelloMsg - call efi_fs_init ; #=======================# diff --git a/boot/efi/logger.inc b/boot/efi/logger.inc index dd6fcae..b1db6b2 100644 --- a/boot/efi/logger.inc +++ b/boot/efi/logger.inc @@ -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 diff --git a/boot/efi/uefi.inc b/boot/efi/uefi.inc index 614ed22..7951603 100644 --- a/boot/efi/uefi.inc +++ b/boot/efi/uefi.inc @@ -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 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 diff --git a/boot/loader/Makefile b/boot/loader/Makefile index 76a4ea4..be6a66c 100644 --- a/boot/loader/Makefile +++ b/boot/loader/Makefile @@ -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 diff --git a/boot/loader/boot.cfg b/boot/loader/boot.cfg new file mode 100644 index 0000000..743660f --- /dev/null +++ b/boot/loader/boot.cfg @@ -0,0 +1,10 @@ +; Boot configuration + +;kernel=vmstupid.sys + +;cmdline= + +textmode=no + +; resolution=*width*x*height*[x*bpp*] +resolution=1024x768x32 diff --git a/boot/loader/disk.inc b/boot/loader/disk.inc index c8f8e8b..cfb98b6 100644 --- a/boot/loader/disk.inc +++ b/boot/loader/disk.inc @@ -37,7 +37,7 @@ disk_read_sectors: ret @@: mov si, szMsgErrorSector - call bios_print + call bios_log_error ret .lba_read: push si diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index b59d456..49119bc 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -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 diff --git a/boot/loader/logger.inc b/boot/loader/logger.inc index faf5870..2544fb3 100644 --- a/boot/loader/logger.inc +++ b/boot/loader/logger.inc @@ -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 diff --git a/boot/loader/memory.inc b/boot/loader/memory.inc index 7e37180..bcc2fc2 100644 --- a/boot/loader/memory.inc +++ b/boot/loader/memory.inc @@ -1,39 +1,39 @@ ;; File: memory.inc - ;; Detect available memory - ;; - - ;; Constants: Address type + ;; Detect available memory ;; - ;; See - ;; - ;; 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 +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.
.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 diff --git a/boot/loader/multiboot.inc b/boot/loader/multiboot.inc index f4db7e2..2996222 100644 --- a/boot/loader/multiboot.inc +++ b/boot/loader/multiboot.inc @@ -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 ? diff --git a/docs/config/Languages.txt b/docs/config/Languages.txt index 4c2030b..7530287 100644 --- a/docs/config/Languages.txt +++ b/docs/config/Languages.txt @@ -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 diff --git a/docs/config/Topics.txt b/docs/config/Topics.txt index 10ff754..f3a7fe0 100644 --- a/docs/config/Topics.txt +++ b/docs/config/Topics.txt @@ -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: diff --git a/docs/devsewebring.py b/docs/devsewebring.py index 92cd63a..ec544e1 100644 --- a/docs/devsewebring.py +++ b/docs/devsewebring.py @@ -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) diff --git a/kernel/Makefile b/kernel/Makefile index fdc2819..bf45b9f 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -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 diff --git a/kernel/const.inc.in b/kernel/const.inc similarity index 63% rename from kernel/const.inc.in rename to kernel/const.inc index e10b32c..ee5752d 100644 --- a/kernel/const.inc.in +++ b/kernel/const.inc @@ -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 diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 7e64132..75ffcfe 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -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 diff --git a/kernel/mm/svm/object.inc b/kernel/mm/svm/object.inc index 1d9985b..0516f50 100644 --- a/kernel/mm/svm/object.inc +++ b/kernel/mm/svm/object.inc @@ -1,4 +1,8 @@ ;; File: object.inc +SVM_OBJ_ANON = 1 +SVM_OBJ_FILE = 2 +SVM_OBJ_DEVICE = 3 + struc SvmObject { .refcount dd ? diff --git a/kernel/sys/bootinfo.inc b/kernel/sys/bootinfo.inc index 6582cf5..75be3d8 100644 --- a/kernel/sys/bootinfo.inc +++ b/kernel/sys/bootinfo.inc @@ -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 ;; .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 diff --git a/kernel/sys/version.inc.in b/kernel/sys/version.inc.in new file mode 100644 index 0000000..4cad9c4 --- /dev/null +++ b/kernel/sys/version.inc.in @@ -0,0 +1,5 @@ +VERSION_MAJOR = @MAJOR@ +VERSION_MINOR = @MINOR@ +VERSION_COMMIT equ "@COMMIT@" +VERSION_FULL equ "@FULLVERSION@" +BUILD_DATE equ "@DATE@" diff --git a/sbin/parted/Makefile b/sbin/fdisk/Makefile similarity index 100% rename from sbin/parted/Makefile rename to sbin/fdisk/Makefile diff --git a/sbin/parted/cmd.c b/sbin/fdisk/cmd.c similarity index 100% rename from sbin/parted/cmd.c rename to sbin/fdisk/cmd.c diff --git a/sbin/parted/disk.c b/sbin/fdisk/disk.c similarity index 69% rename from sbin/parted/disk.c rename to sbin/fdisk/disk.c index a226ef3..a42b159 100644 --- a/sbin/parted/disk.c +++ b/sbin/fdisk/disk.c @@ -1,5 +1,8 @@ +#include +#include #include +/* 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); } +*/ diff --git a/sbin/parted/disk.h b/sbin/fdisk/disk.h similarity index 100% rename from sbin/parted/disk.h rename to sbin/fdisk/disk.h diff --git a/sbin/parted/parted.8 b/sbin/fdisk/fdisk.8 similarity index 78% rename from sbin/parted/parted.8 rename to sbin/fdisk/fdisk.8 index 135fb44..da9fcd9 100644 --- a/sbin/parted/parted.8 +++ b/sbin/fdisk/fdisk.8 @@ -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 diff --git a/sbin/parted/fdisk/cmd.h b/sbin/fdisk/fdisk/cmd.h similarity index 100% rename from sbin/parted/fdisk/cmd.h rename to sbin/fdisk/fdisk/cmd.h diff --git a/sbin/parted/fdisk/device.h b/sbin/fdisk/fdisk/device.h similarity index 100% rename from sbin/parted/fdisk/device.h rename to sbin/fdisk/fdisk/device.h diff --git a/sbin/parted/fdisk/disk.h b/sbin/fdisk/fdisk/disk.h similarity index 100% rename from sbin/parted/fdisk/disk.h rename to sbin/fdisk/fdisk/disk.h diff --git a/sbin/parted/fdisk/partition.h b/sbin/fdisk/fdisk/partition.h similarity index 100% rename from sbin/parted/fdisk/partition.h rename to sbin/fdisk/fdisk/partition.h diff --git a/sbin/parted/fdisk/version.h b/sbin/fdisk/fdisk/version.h similarity index 100% rename from sbin/parted/fdisk/version.h rename to sbin/fdisk/fdisk/version.h diff --git a/sbin/parted/fildev.c b/sbin/fdisk/fildev.c similarity index 100% rename from sbin/parted/fildev.c rename to sbin/fdisk/fildev.c diff --git a/sbin/parted/gpt.h b/sbin/fdisk/gpt.h similarity index 100% rename from sbin/parted/gpt.h rename to sbin/fdisk/gpt.h diff --git a/sbin/parted/guid.h b/sbin/fdisk/guid.h similarity index 100% rename from sbin/parted/guid.h rename to sbin/fdisk/guid.h diff --git a/sbin/parted/label/msdos.c b/sbin/fdisk/label/msdos.c similarity index 100% rename from sbin/parted/label/msdos.c rename to sbin/fdisk/label/msdos.c diff --git a/sbin/parted/main.c b/sbin/fdisk/main.c similarity index 100% rename from sbin/parted/main.c rename to sbin/fdisk/main.c diff --git a/sbin/parted/mbr.h b/sbin/fdisk/mbr.h similarity index 100% rename from sbin/parted/mbr.h rename to sbin/fdisk/mbr.h diff --git a/sbin/parted/parted.h b/sbin/fdisk/parted.h similarity index 100% rename from sbin/parted/parted.h rename to sbin/fdisk/parted.h diff --git a/sbin/parted/repl.c b/sbin/fdisk/repl.c similarity index 93% rename from sbin/parted/repl.c rename to sbin/fdisk/repl.c index 74230de..9031ec8 100644 --- a/sbin/parted/repl.c +++ b/sbin/fdisk/repl.c @@ -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'; diff --git a/sbin/parted/version.c b/sbin/fdisk/version.c similarity index 100% rename from sbin/parted/version.c rename to sbin/fdisk/version.c diff --git a/share/Makefile b/share/Makefile new file mode 100644 index 0000000..842162a --- /dev/null +++ b/share/Makefile @@ -0,0 +1,3 @@ +SUBDIRS = doc mk + +include stpd.subdirs.mk diff --git a/share/doc/Makefile b/share/doc/Makefile new file mode 100644 index 0000000..a5c2619 --- /dev/null +++ b/share/doc/Makefile @@ -0,0 +1,4 @@ +FILESDIR = /usr/share/doc +FILES = manifesto.texi + +include stpd.files.mk diff --git a/share/docs/manifesto.texi b/share/doc/manifesto.texi similarity index 100% rename from share/docs/manifesto.texi rename to share/doc/manifesto.texi diff --git a/share/man/boot.cfg.5 b/share/man/boot.cfg.5 new file mode 100644 index 0000000..ad86af5 --- /dev/null +++ b/share/man/boot.cfg.5 @@ -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 diff --git a/share/mk/Makefile b/share/mk/Makefile new file mode 100644 index 0000000..c6254c6 --- /dev/null +++ b/share/mk/Makefile @@ -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 diff --git a/share/mk/stpd.files.mk b/share/mk/stpd.files.mk new file mode 100644 index 0000000..38c8b12 --- /dev/null +++ b/share/mk/stpd.files.mk @@ -0,0 +1,13 @@ +include stpd.base.mk + +FILESDIR?= $(BINDIR) + +ifdef FILES + +$(DESTDIR)$(FILESDIR)/%: % + $(MSG_INSTALL) + @install -D $< $@ + +install: $(addprefix $(DESTDIR)$(FILESDIR)/, $(FILES)) + +endif diff --git a/share/mk/stpd.kernel.mk b/share/mk/stpd.kernel.mk index 1bd2db9..22db3d1 100644 --- a/share/mk/stpd.kernel.mk +++ b/share/mk/stpd.kernel.mk @@ -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 diff --git a/tools/fdisk/Makefile b/tools/fdisk/Makefile index 8f5bdb4..a5f97a6 100644 --- a/tools/fdisk/Makefile +++ b/tools/fdisk/Makefile @@ -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