From: Christoffer Bubach Date: Fri, 16 Jan 2015 01:16:46 +0000 (+0100) Subject: VFS structures in place, minor typos fixed X-Git-Url: https://git.wirehaze.ovh/BOS.git/commitdiff_plain/0af2320324eedb4577b402e65b1a9df017fac87c?ds=sidebyside;hp=0fc4c7c0416f40e61ca790fb088058b985e6df5c VFS structures in place, minor typos fixed --- diff --git a/doc/services.txt b/doc/services.txt index 58eeecb..4ada963 100644 --- a/doc/services.txt +++ b/doc/services.txt @@ -38,6 +38,7 @@ default include: - general PCI devices - special one for all things USB? - GUI specific functions +- printing services - running stuff in 16 and 64 bit, with extra DOS emulation and/or other services @@ -65,12 +66,9 @@ services.asm (main service 0x00) - get/set interrupts - execute kernel monitor command/script - get time/date - - DMA functions, here or in VFS/floppy/memory drivers? - GDT function, create new segments 'n shit - pc-speaker beep if not even stdio is found - CMOS / PIC functions - - run 16/64 bit code - seperate services for this? (int21h included?) - - get specified... stdio.asm (service number 0x01) @@ -146,6 +144,7 @@ proccess.asm (service number 0x03) more executable formats, possibly other execution modes: realmode, longmode - Remove driver + - run 16/64 bit code - seperate services for this? (int21h included?) memory.asm (service number 0x04) diff --git a/kernel/fat12/fat12.asm b/kernel/fat12/fat12.asm index a961782..416fe43 100644 --- a/kernel/fat12/fat12.asm +++ b/kernel/fat12/fat12.asm @@ -7,7 +7,7 @@ ;----------------------------------------------------------; ;---------------------------------------------; - ; main FAT12 info structure ; + ; FAT12 main info structure ; ;---------------------------------------------; struc fat12 { @@ -21,9 +21,14 @@ .boot bootsector .dir_entries: times 16 * sizeof.dir_entry db 0 ; 512b dir entry buffer - .fat_buffer: times 512 db 0 ; 512b FAT cluster info buffer + .fat_buffer: times 512 db 0 ; 512b FAT cluster info buffer } + virtual at 0 ; could use "at esi" instead + fat12 fat12 + sizeof.fat12 = $-$$ + end virtual + ;---------------------------------------------; ; FAT12 bootsector structure ; ;---------------------------------------------; @@ -53,10 +58,15 @@ .boot_signature db 0,0 ; 0x55,0xAA } + virtual at 0 + bootsector bootsector + sizeof.bootsector = $-$$ + end virtual + ;---------------------------------------------; ; FAT12 directory entry structure ; ;---------------------------------------------; - struct dir_entry + struc dir_entry { .filename db 0,0,0,0,0,0,0,0 .extension db 0,0,0 @@ -68,10 +78,15 @@ .filesize dd 0 } + virtual at 0 + dir_entry dir_entry + sizeof.dir_entry = $-$$ + end virtual + ;---------------------------------------------; ; FAT12 directory entry for LFN ; ;---------------------------------------------; - struct lnf_entry + struc lfn_entry { .order db 0 ; LFN entry in sequence, never 0x00 or 0xE5. .namefirst dw 0,0,0,0,0 ; 5 first unicode (2byte) chars @@ -85,22 +100,7 @@ virtual at 0 lfn_entry lfn_entry - sizeof.lfn_entry = $ - end virtual - - virtual at 0 - dir_entry dir_entry - sizeof.dir_entry = $ - end virtual - - virtual at 0 - bootsector bootsector - sizeof.bootsector = $ - end virtual - - virtual at 0 - disk disk - sizeof.disk = $ + sizeof.lfn_entry = $-$$ end virtual ;------------------------------------------; @@ -138,7 +138,7 @@ -fd0: fat12 ; define fd0 data.. tmp example. +fd0 fat12 ; define fd0 data.. tmp example. ; TODO, alloc memory for struct and keep pointer only. ; --------------- @@ -191,7 +191,10 @@ calc_lfn_chksum: mov cx, 11 xor ax, ax ; return value start with null .l1: - add ax, byte [esi] ; add next char to sum + push cx + movzx cx, byte [esi] ; add next char to sum + add ax, cx + pop cx shr ax, 1 ; shift sum right by 1 inc esi ; prepare for next character loop .l1 diff --git a/kernel/system/services.asm b/kernel/system/services.asm index 3f57ddd..3bd5b98 100755 --- a/kernel/system/services.asm +++ b/kernel/system/services.asm @@ -1,8 +1,8 @@ ;----------------------------------------------------------; -; BOS 0.04 Christoffer Bubach, 2004-2005. ; +; BOS 0.05 Christoffer Bubach, 2004-2015. ; ;----------------------------------------------------------; ; ; -; System interrupts.. ; +; Service handler for components such as VFS & STDIO. ; ; ; ;----------------------------------------------------------; diff --git a/kernel/vfs/parse.asm b/kernel/vfs/parse.asm index a067cce..e3264f2 100644 --- a/kernel/vfs/parse.asm +++ b/kernel/vfs/parse.asm @@ -29,19 +29,19 @@ parse_path: mov bl, 0x00 ; fd base is 0x00 cmp word [esi], 'FD' ; fd check je .drive_found - mov bl, 0x0F ; hd base is 0x0F + mov bl, 0x10 ; hd base is 0x10 cmp word [esi], 'HD' ; hd check je .drive_found - mov bl, 0x5F ; cd base is 0x5F + mov bl, 0x60 ; cd base is 0x60 cmp word [esi], 'CD' ; cd check je .drive_found - mov bl, 0x7F ; rd base is 0x7F - cmp word [esi], 'RD' ; rd (ram drive) check + mov bl, 0x80 ; vd base is 0x80 + cmp word [esi], 'VD' ; vd (virtual ram drive) check je .drive_found - mov bl, 0x8F ; rm base is 0x8F - cmp word [esi], 'RM' ; rm (removable/usb) + mov bl, 0x90 ; rd base is 0x90 + cmp word [esi], 'RD' ; rd (removable/usb) je .drive_found - mov bl, 0xAF ; nd base is 0xAF + mov bl, 0xB0 ; nd base is 0xB0 cmp word [esi], 'ND' ; nd (net) check je .drive_found diff --git a/kernel/vfs/vfs.asm b/kernel/vfs/vfs.asm index ff661fd..ab2f0fa 100644 --- a/kernel/vfs/vfs.asm +++ b/kernel/vfs/vfs.asm @@ -2,10 +2,84 @@ ; BOS kernel Christoffer Bubach, 2012-2015. ; ;----------------------------------------------------------; ; ; -; VFS handling all devices and filesystems. ; +; VFS handling all devices and filesystems. ; ; ; ;----------------------------------------------------------; + ;---------------------------------------------; + ; VFS main structure ; + ;---------------------------------------------; + struc VFS + { + .number: times 255 db 0 ; 00=FD, 0x10=HD, 0x60=CD, 0x80=VD, 90=RD, B0=ND + .storage: + times 255 * sizeof.VFS_storage db 0 ; storage driver structure + .filesystem: + times 255 * sizeof.VFS_filesystem db 0 ; filesystem driver structure + } + + virtual at 0 ; could use "at esi" instead + VFS VFS + sizeof.VFS = $-$$ + end virtual + + ;---------------------------------------------; + ; VFS storage driver structure ; + ;---------------------------------------------; + struc VFS_storage + { + .data_pointer dd 0 ; internal driver data + .init dd 0 ; pointer to init + .deinit dd 0 ; remove driver + .read dd 0 ; read device + .write dd 0 ; write device + .ioctl dd 0 ; handle device specific extras + } + + virtual at 0 + VFS_storage VFS_storage + sizeof.VFS_storage = $-$$ + end virtual + + ;---------------------------------------------; + ; VFS filesystem structure ; + ;---------------------------------------------; + struc VFS_filesystem + { + .data_pointer dd 0 ; internal driver data + .init dd 0 ; pointer to init + .deinit dd 0 ; remove driver + .format dd 0 ; format drive + .mount dd 0 ; mount drive + .unmount dd 0 ; unmount drive + .find dd 0 ; find file + .findnext dd 0 ; get next match + .open dd 0 ; open file, get handle + .read dd 0 ; read file from handle + .write dd 0 ; write file from handle + .seek dd 0 ; seek from handle + .remove dd 0 ; remove file/dir + .create dd 0 ; create file/dir + .ioctl dd 0 ; extra calls if exists + } + + virtual at 0 + VFS_filesystem VFS_filesystem + sizeof.VFS_filesystem = $-$$ + end virtual + + +VFS_structure VFS + +;--------------------------------------------------------------; +; init_vfs - detect connected drives ; +;--------------------------------------------------------------; +; ; +; in: reg = pointer to VFS drive info ; +; ; +; out: reg = pointer to struct(s) if FAT12 found ; +; ; +;--------------------------------------------------------------; init_vfs: push eax ; a bit more code here