diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/gbos.inc | 52 |
1 files changed, 41 insertions, 11 deletions
diff --git a/include/gbos.inc b/include/gbos.inc index 3b96f56..770bd55 100644 --- a/include/gbos.inc +++ b/include/gbos.inc @@ -124,21 +124,51 @@ DEF SYS_MAX EQU 25 ; (SYS_OPEN=4 / SYS_CLOSE=5 are now implemented by the filesystem) ; ----------------------------------------------------------------------------- -; RAM filesystem (lives in WRAMX $D000-$DFFF, 4 KiB; fixed in DMG mode). -; 8 files x 512 bytes: name[8] (first byte 0 = free) + len[2] + data[502]. +; Block-based filesystem (on the persistent block device; see fs.asm). +; block 0 superblock (magic + version) +; block 1 bitmaps: block bitmap @0 (16 B), inode bitmap @16 (4 B) +; blocks 2-3 inode table (32 inodes x 16 B) +; blocks 4.. data blocks +; Metadata (bitmaps + inode table) is cached in WRAMX; data/dir blocks stream +; through fs_datbuf / fs_dirbuf. ; ----------------------------------------------------------------------------- -DEF FS_BASE EQU $D000 -DEF FS_MAX_FILES EQU 8 -DEF FS_FILE_SIZE EQU 512 -DEF FS_NAME EQU 0 -DEF FS_LEN EQU 8 -DEF FS_DATA EQU 10 -DEF FS_MAX_DATA EQU 502 +DEF BLK_SUPER EQU 0 +DEF BLK_BITMAP EQU 1 +DEF BLK_INODE0 EQU 2 ; inode table = blocks 2,3 +DEF BLK_DATA0 EQU 4 ; first data block +DEF FS_VERSION EQU 2 +DEF NINODES EQU 32 +DEF ROOT_INO EQU 1 +DEF NDIRECT EQU 8 ; direct block pointers per inode -> files <= 2 KiB +DEF DIRENTS EQU 16 ; directory entries per block (256/16) -; open-file table (kernel WRAM0): inuse, slot, mode, pos(2) +; inode fields (16 bytes) +DEF I_TYPE EQU 0 ; 0=free 1=file 2=dir +DEF I_NLINK EQU 1 +DEF I_SIZE EQU 2 ; 16-bit +DEF I_BLOCKS EQU 4 ; 8 direct block pointers (1 byte each; 0=none) +DEF IT_FREE EQU 0 +DEF IT_FILE EQU 1 +DEF IT_DIR EQU 2 + +; directory entry (16 bytes): inode(1, 0=free) + name(15, NUL-term) +DEF DE_INO EQU 0 +DEF DE_NAME EQU 1 + +; bitmap offsets within block 1 +DEF BM_BLOCKS EQU 0 +DEF BM_INODES EQU 16 + +; WRAMX working buffers (freed by removing the old 8-slot FS) +DEF fs_bmbuf EQU $D000 ; 256 B: bitmap block cache (block 1) +DEF fs_inobuf EQU $D100 ; 512 B: inode table cache (blocks 2-3) +DEF fs_dirbuf EQU $D300 ; 256 B: directory block scratch +DEF fs_datbuf EQU $D400 ; 256 B: data block cache + +; open-file table (kernel WRAM0): inuse, inode, mode, pos(2) DEF OF_MAX EQU 4 DEF OF_INUSE EQU 0 -DEF OF_SLOT EQU 1 +DEF OF_INODE EQU 1 DEF OF_MODE EQU 2 DEF OF_POS EQU 3 DEF OF_SIZE EQU 5 |
