fat32_sys_rewrite as of 22/8/2025 #5

Closed
nivirx wants to merge 0 commits from fat32_sys_rewrite into trunk
Owner

Key changes

** Stevia is now GPLv3 again, I'm the only contributor so the board said it was ok to re-license 🤣 **

  • .gitignore – ignores developer environment artifacts.
  • include/cdecl16.inc – expanded macro set for function prolog/epilog and fastcall variants.
  • include/BIOS/func/ext_read.nasm – revised extended‑read wrapper; now uses a macro for easy invocation and clears the LBA packet with kmemset.
  • include/error_codes.inc – new codes for FAT32 and stage‑2 errors.
  • include/util/kmem_func.nasm – streamlined kmemset/kmemcpy.
  • Major FAT32 subsystem refactor:
    • include/fat32/fat32_structures.inc – field names normalized to spec and structured for relative addressing.
    • include/fat32/FAT32_SYS.inc – InitFATDriver rewritten with error‑flag checks, state struct handled via di; new FSInfoPrinter stub and rewritten SearchFATDIR.
  • src/stage2/stage2.nasm – updated to use new info strings and macro names; hooks into refactored FAT32 routines.
  • src/vbr/vbr.nasm – minor adjustments for the revised includes.
  • scripts/create-disk.sh – small cleanup in disk-image creation.

These changes collectively modernize calling conventions, improve FAT32 handling, and streamline build scripts compared to the trunk branch.

# Key changes ** Stevia is now GPLv3 again, I'm the only contributor so the board said it was ok to re-license 🤣 ** - .gitignore – ignores developer environment artifacts. - include/cdecl16.inc – expanded macro set for function prolog/epilog and fastcall variants. - include/BIOS/func/ext_read.nasm – revised extended‑read wrapper; now uses a macro for easy invocation and clears the LBA packet with kmemset. - include/error_codes.inc – new codes for FAT32 and stage‑2 errors. - include/util/kmem_func.nasm – streamlined kmemset/kmemcpy. - Major FAT32 subsystem refactor: - include/fat32/fat32_structures.inc – field names normalized to spec and structured for relative addressing. - include/fat32/FAT32_SYS.inc – InitFATDriver rewritten with error‑flag checks, state struct handled via di; new FSInfoPrinter stub and rewritten SearchFATDIR. - src/stage2/stage2.nasm – updated to use new info strings and macro names; hooks into refactored FAT32 routines. - src/vbr/vbr.nasm – minor adjustments for the revised includes. - scripts/create-disk.sh – small cleanup in disk-image creation. These changes collectively modernize calling conventions, improve FAT32 handling, and streamline build scripts compared to the trunk branch.
nivirx added 180 commits 2025-08-22 11:51:17 -04:00
Create LICENSE.md
Removing GPL-3.0 license.
🏳️‍⚧️
updated description to more accurately reflect project status
also reenable interupts in the init block
this fixes an issue that appeared on WSL2 recently(ish)
also there is special handling for them in error.inc
saves us 5 bytes of code (15 overall)
moved top of stack marker to init
SetTextMode and Cursor done before hello msg
corrected CC/Stack usage to conform with cdecl16 for PrintString
corrected CC/Stack usage to conform with cdecl16 for PrintChar
corrected stack usage to conform with cdecl16 for SetTextMode
corrected stack usage to conform with cdecl16 for disable_cursor
also InitFATDriver should be ok to add to the start process again.
also included a work around for a WSL bug in create-disk.sh
switch to cdecl kmem* functions
refactored read_disk_raw to read_vbr_raw
fixed a small issue where the mbr wasn't checking its signature
refactored read_disk_raw to read_stage2_raw
switched to new kmem functions
also pointed up a bug in memory.inc
also back to putting the test 32bit mode code on the root of the volume
boot_drive and partition_offset are global pointers now
removed an extra error from mbr disk read
and some general formating and cleanup 😅
Full refactor for modularization
this file has always just been a place holder to get some code to load from the disk
I wanted to cut out all the extra stuff in it just to simplify things down.
files that actually include code should be in .nasm files
defines/macros/non-code should be in .inc files
optimized the early error printer a bit to save some bytes
removed DEBUG_HCF macro
surpress reloc abs warnings
corrected include paths/filenames
ss, and e/f/g segments are loaded to the same flat 4gb segment
moved gdt notes to documentation
will need ported to macOS sometime
copy our VBR code to backup VBR
K.I.S.S.
removed caller save kludge for now
init first_root_dir_sector from ebpb data
aligned all the entry points for proceedures to 4 bytes
added a PrintString wraper macro
fix a few mistakes in macro defs
also preparing to move memory globals to bss section.
we are going to use 0x07E0 as our base segment so we have a bit
more memory to work with until we are fully in 32bit protected mode.

this commit is broken but is just one step towards a working release.
huge unreal mode is 4GiB code in 16bit mode + 4GiB data
we will just use the regular big flat model instead (64KiB code/4GiB data)
also the partition table and fat32_bpb and passed/copied from the mbr/vbr now
convert MBR, VBR, & Stage2 to use a BSS section.
makes it easier to get a good state to do some investigating before reseting.
removed some unused data in bss
reordered how/when in init we set sp/bp and zero bss
we now push the top of the stack pointer/bp at the top of the stack, which makes the stack frame more 'normal'
also use movsb instead of movsw
removed redzone label
reordered sp/bp setup and bss zeroing in init:
fixed kmemcpy call stack usage
reworked init: process
512 byte stack...should be more than enough for the vbr
added some magic debug points for stuff that isn't working as well.
also correct total size output as combined .data + .text
use xchg to swap si/di instead of the stack
uninline ClusterToLBA call
also use the pointers we have in bss to our saved data
also added prototype for FS info printer that will print some basic santity check type info.
disable bad cluster jmp for now
only does a stack frame setup with no locals space
cleanup of NextCluster
this is to work around having to save them without .bss ready
also cleanup comment from previous bug
fixed a bug where fat32_state wasn't being updated...
Author
Owner

merged with 8129a71fdd

merged with 8129a71fdd9b532b9da24fb4f9cd53d128d458e7
nivirx closed this pull request 2025-08-22 12:01:43 -04:00

Pull request closed

Sign in to join this conversation.