From 4acbdade6848b309c265645437e0aafadf4cdfd7 Mon Sep 17 00:00:00 2001 From: d0p1 Date: Tue, 26 Mar 2024 08:39:40 +0100 Subject: [PATCH] build: docs + website --- .gitignore | 1 + Makefile | 8 ++- boot/bootsect/floppy.asm | 1 + boot/efi/bootia32.asm | 1 + boot/loader/loader.asm | 1 + docs/config/Languages.txt | 13 +--- docs/config/Menu.txt | 129 +++++++++---------------------------- kernel/kernel.asm | 9 +-- lib/crypto/sha2/sha256.asm | 53 +++++++-------- lib/lzp/lzp.asm | 90 ++++++++++++++++---------- 10 files changed, 125 insertions(+), 181 deletions(-) diff --git a/.gitignore b/.gitignore index 4df2081..f471c44 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ bochsrc.bxrc *.sys *.obj *.efi +*.EFI diff --git a/Makefile b/Makefile index 0b855de..82b9b7a 100644 --- a/Makefile +++ b/Makefile @@ -69,7 +69,7 @@ run: all -device ide-hd,drive=hdd \ -global isa-fdc.bootindexA=0 \ -serial mon:stdio - + .PHONY: run-efi run-efi: all OVMF32.fd qemu-system-i386 \ @@ -79,6 +79,12 @@ run-efi: all OVMF32.fd -device ide-hd,drive=hdd \ -serial stdio +.PHONY: docs +docs: + @mkdir -p docs/html + naturaldocs -p docs/config -img docs/img -xi sysroot -i . -ro -o HTML docs/html + cp docs/img/favicon.ico docs/html/ + .PHONY: clean clean: $(SUBDIRS) $(RM) $(TARGET) diff --git a/boot/bootsect/floppy.asm b/boot/bootsect/floppy.asm index b6418fc..0b3e15f 100644 --- a/boot/bootsect/floppy.asm +++ b/boot/bootsect/floppy.asm @@ -1,3 +1,4 @@ + ;; File: floppy.asm format binary use16 diff --git a/boot/efi/bootia32.asm b/boot/efi/bootia32.asm index a31a3a3..cdd050a 100644 --- a/boot/efi/bootia32.asm +++ b/boot/efi/bootia32.asm @@ -1,3 +1,4 @@ + ; File: bootia32.asm format PE DLL EFI at 10000000h entry efimain diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index ee94e7e..21e3504 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -1,3 +1,4 @@ + ;; File: loader.asm format binary include '../common/const.inc' diff --git a/docs/config/Languages.txt b/docs/config/Languages.txt index 2581e6e..8d5bc0f 100644 --- a/docs/config/Languages.txt +++ b/docs/config/Languages.txt @@ -115,14 +115,5 @@ Format: 1.51 Alter Language: Assembly - Add Extensions: s inc - Struct Prototype Ender: endstruc - - -Language: PL/S - - Extension: pls - Line Comment: // - Block Comment: /* */ - Function Prototype Ender: ; - Variable Prototype Enders: ; = + Add Extensions: asm s inc + Struct Prototype Ender: } diff --git a/docs/config/Menu.txt b/docs/config/Menu.txt index d05a502..db58369 100644 --- a/docs/config/Menu.txt +++ b/docs/config/Menu.txt @@ -2,9 +2,9 @@ Format: 1.51 Title: StupidOS -SubTitle: Tiny *NIX-like Operating System +SubTitle: 32-bit Operating System written in x86 assembly. -Footer: Copyright (C) 2023 d0p1 +Footer: Copyright (C) 2024 d0p1 Timestamp: Updated yyyy/mm/dd # m - One or two digit month. January is "1" # mm - Always two digit month. January is "01" @@ -39,128 +39,57 @@ Timestamp: Updated yyyy/mm/dd File: Introduction (docs/intro.txt) -Link: Source Code (https://github.com/d0p1s4m4/StupidOS) +Link: Source Code (https://git.cute.engineering/d0p1/StupidOS) File: Coding Style (docs/coding-style.txt) -File: Building (building.txt) File: FAQ (docs/faq.txt) +Group: BootLoader { + + Group: BootSector { + + File: floppy.asm (boot/bootsect/floppy.asm) + } # Group: BootSector + + Group: Loader { + + File: loader.asm (boot/loader/loader.asm) + } # Group: Loader + + Group: EFI { + + File: bootia32.asm (boot/efi/bootia32.asm) + } # Group: EFI + + } # Group: BootLoader + Group: Kernel { - File: Introduction (kernel/intro.txt) - - Group: boot { - - File: gdt.s (kernel/boot/gdt.s) - File: head.s (kernel/boot/head.s) - File: idt.s (kernel/boot/idt.s) - } # Group: boot - - File: kernel.s (kernel/kernel.s) - File: pic.s (kernel/pic.s) - - Group: dev { - - Group: AT { - - File: IBM PC/AT (kernel/dev/at/intro.txt) - File: cmos.s (kernel/dev/at/cmos.s) - File: pit.s (kernel/dev/at/pit.s) - File: serial.s (kernel/dev/at/serial.s) - } # Group: AT - - } # Group: dev - - Group: i18n { - - File: msg_en.s (kernel/i18n/msg_en.s) - } # Group: i18n - - File: pmm.s (kernel/pmm.s) - - Group: sys { - - File: multiboot.inc (kernel/sys/multiboot.inc) - - Group: i386 { - - File: cpu.inc (kernel/sys/i386/cpu.inc) - File: cpuid.inc (kernel/sys/i386/cpuid.inc) - File: mmu.inc (kernel/sys/i386/mmu.inc) - File: registers.inc (kernel/sys/i386/registers.inc) - } # Group: i386 - - } # Group: sys - - File: vm.inc (kernel/vm/vm.inc) - File: pmap.s (kernel/vm/pmap.s) + File: kernel.asm (kernel/kernel.asm) } # Group: Kernel Group: Lib { - Group: Base { + Group: LZP { - File: base.inc (lib/base/base.inc) - File: log.s (lib/base/log.s) - } # Group: Base + File: lzp.asm (lib/lzp/lzp.asm) + } # Group: LZP Group: Crypto { - Group: Hash { + Group: SHA2 { - File: sha256.s (lib/crypto/hash/sha256.s) - File: keccak.s (lib/crypto/hash/keccak.s) - } # Group: Hash - - Group: Sign { - - File: ecdsa.s (lib/crypto/sign/ecdsa.s) - } # Group: Sign + File: sha256.asm (lib/crypto/sha2/sha256.asm) + } # Group: SHA2 } # Group: Crypto - Group: PL/Stupid { - - Group: Runtime { - - File: crt0.s (lib/pls/runtime/crt0.s) - } # Group: Runtime - - } # Group: PL/Stupid - } # Group: Lib -Group: Bin { - - Group: motd { - - File: main.pls (bin/motd/main.pls) - } # Group: motd - - } # Group: Bin - -Group: Share { - - Group: Mk { - - File: stupid.clean.mk (share/mk/stupid.clean.mk) - File: stupid.kernel.mk (share/mk/stupid.kernel.mk) - File: stupid.lib.mk (share/mk/stupid.lib.mk) - File: stupid.own.mk (share/mk/stupid.own.mk) - File: stupid.prog.mk (share/mk/stupid.prog.mk) - File: stupid.subdir.mk (share/mk/stupid.subdir.mk) - File: stupid.sys.mk (share/mk/stupid.sys.mk) - } # Group: Mk - - } # Group: Share - Group: Index { Index: Everything Constant Index: Constants File Index: Files Function Index: Functions - Macro Index: Macros - Variable Index: Variables - Class Index: Classes } # Group: Index diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 6888e1f..b10955b 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -1,11 +1,12 @@ - INCLUDE 'const.inc' + ;; File: kernel.asm + include 'const.inc' - ORG KBASE - USE32 + org KBASE + use32 jmp kmain - INCLUDE 'mm/mm.inc' + include 'mm/mm.inc' kmain: nop diff --git a/lib/crypto/sha2/sha256.asm b/lib/crypto/sha2/sha256.asm index c0a3b5c..cd3670b 100644 --- a/lib/crypto/sha2/sha256.asm +++ b/lib/crypto/sha2/sha256.asm @@ -1,16 +1,13 @@ -; file: sha256.s -; SHA-256 cryptographic hash -; -; Implementation is based on -; -; About: CPU compatibility -; /!\ Only work on *486+* due to bswap for now. + ;; File: sha256.asm + ;; SHA-256 cryptographic hash + + ; Implementation is based on format COFF use32 section '.data' data -; Constant: K -; SHA-256 round constants + ; Constant: K + ; SHA-256 round constants K: dd 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5 dd 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174 @@ -23,7 +20,7 @@ K: section '.text' code - ; Function: sha256_compute_block + ;; Function: sha256_compute_block sha256_compute_block: push ebp mov ebp, esp @@ -31,16 +28,14 @@ sha256_compute_block: leave ret - ; Function: sha256_internal - ; - ; in: - ; - state - ; - Input buffer - ; - Input buffer size - ; - ; out: - ; none - ; + ;; Function: sha256_internal + ;; + ;; Parameters: + ;; + ;; [esp+8] - state + ;; [esp+12] - input buffer + ;; [esp+16] - size of the input buffer + ;; sha256_internal: push ebp push edi @@ -80,16 +75,14 @@ sha256_internal: leave ret - ; Function: sha256 - ; - ; in: - ; - Output buffer - ; - Input buffer - ; - Input buffer size - ; - ; out: - ; none - ; + ;; Function: sha256 + ;; + ;; Parameters: + ;; + ;; [esp+8] - output buffer + ;; [esp+12] - input buffer + ;; [esp+16] - size of the input buffer + ;; public sha256 sha256: push ebp diff --git a/lib/lzp/lzp.asm b/lib/lzp/lzp.asm index a4f9361..4254334 100644 --- a/lib/lzp/lzp.asm +++ b/lib/lzp/lzp.asm @@ -1,6 +1,9 @@ - ;; Lempel-Ziv + Prediction (a fast, efficient, and memory-use - ;; conservative compression algorithm) - ;; (paper: https://ieeexplore.ieee.org/document/488353) + ;; File: lzp.asm + + + ; Lempel-Ziv + Prediction (a fast, efficient, and memory-use + ; conservative compression algorithm) + ; (paper: https://ieeexplore.ieee.org/document/488353) format COFF use32 @@ -15,39 +18,44 @@ section '.code' code - ;; xor hash, hash - ;; xor mask, mask - ;; j = 1 - ;; while (insz > 0) - ;; { - ;; if (ecx == 8) - ;; { - ;; mov [out], mask - ;; xor ecx, ecx - ;; xor mask, mask - ;; j = 1; - ;; } - ;; c = in[inpos++] - ;; if (c == table[hash]) - ;; { - ;; mask |= 1 << ecx - ;; } - ;; else - ;; { - ;; table[hash] = c - ;; out[j] = c; - ;; } - ;; HASH(hash, c) - ;; ecx++; - ;; } + ; xor hash, hash + ; xor mask, mask + ; j = 1 + ; while (insz > 0) + ; { + ; if (ecx == 8) + ; { + ; mov [out], mask + ; xor ecx, ecx + ; xor mask, mask + ; j = 1; + ; } + ; c = in[inpos++] + ; if (c == table[hash]) + ; { + ; mask |= 1 << ecx + ; } + ; else + ; { + ; table[hash] = c + ; out[j] = c; + ; } + ; HASH(hash, c) + ; ecx++; + ; } - ;; Function: lzp_compress(void *out, const void *in, int size) - ;; In: - ;; - [esp+8]: out buffer address (can be null) - ;; - [esp+12]: input buffer address - ;; - [esp+16]: size of the input buffer - ;; Out: - ;; - eax: size of compressed data + ;; Function: lzp_compress + ;; + ;; Parameters: + ;; + ;; [esp+8] - output buffer (can be NULL) + ;; [esp+12] - input buffer + ;; [esp+16] - size of the input buffer + ;; + ;; Returns: + ;; + ;; eax - size of compressed data + ;; param_out equ [ebp+8] param_in equ [ebp+12] param_insz equ [ebp+16] @@ -105,6 +113,18 @@ lzp_compress: leave ret + ;; Function: lzp_decompress + ;; + ;; Parameters: + ;; + ;; [esp+8] - output buffer (can be null) + ;; [esp+12] - input buffer + ;; [esp+16] - size of the input buffer + ;; + ;; Returns: + ;; + ;; eax - size of uncompressed data + ;; lzp_decompress: push ebp mov ebp, esp