- 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
- 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)
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)
;----------------------------------------------------------;
;---------------------------------------------;
- ; main FAT12 info structure ;
+ ; FAT12 main info structure ;
;---------------------------------------------;
struc fat12
{
.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 ;
;---------------------------------------------;
.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
.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
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
;------------------------------------------;
-fd0: fat12 ; define fd0 data.. tmp example.
+fd0 fat12 ; define fd0 data.. tmp example.
; TODO, alloc memory for struct and keep pointer only.
; ---------------
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
;----------------------------------------------------------;\r
-; BOS 0.04 Christoffer Bubach, 2004-2005. ;\r
+; BOS 0.05 Christoffer Bubach, 2004-2015. ;\r
;----------------------------------------------------------;\r
; ;\r
-; System interrupts.. ;\r
+; Service handler for components such as VFS & STDIO. ;\r
; ;\r
;----------------------------------------------------------;\r
\r
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
; 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