feat(kernel): detect floppy

This commit is contained in:
d0p1 🏳️‍⚧️ 2024-07-14 18:48:36 +02:00
parent 7fcb200475
commit a3e4aabe92
12 changed files with 173 additions and 35 deletions

View file

@ -6,7 +6,6 @@ KERNEL = vmstupid.sys
SRCS = kernel.asm \ SRCS = kernel.asm \
const.inc \ const.inc \
klog.inc \ klog.inc \
dev/vga_console.inc \
mm/mm.inc \ mm/mm.inc \
mm/pmm.inc \ mm/pmm.inc \
lock.inc \ lock.inc \
@ -14,9 +13,11 @@ SRCS = kernel.asm \
isr.inc \ isr.inc \
pic.inc \ pic.inc \
idt.inc \ idt.inc \
dev/console.inc \
dev/at/pit.inc \ dev/at/pit.inc \
dev/at/cga.inc \ dev/at/cga.inc \
dev/at/kbd.inc dev/at/kbd.inc \
dev/at/floppy.inc
.PHONY: all .PHONY: all
all: $(KERNEL) all: $(KERNEL)

15
kernel/dev/at/cmos.inc Normal file
View file

@ -0,0 +1,15 @@
;; File: cmos.inc
;;
;; > +--------------------------------
;; > | 0x00 | RTC seconds
;; > +---------------
;; > | 0x01 | RTC seconds alarm
;; > +--------------------
;; > | 0x02 | RTC minutes
;; > +------------------------
CMOS_COMMAND = 0x70
CMOS_DATA = 0x71
CMOS_FLOPPY_TYPE = 0x10

4
kernel/dev/at/com.inc Normal file
View file

@ -0,0 +1,4 @@
;; File: com.inc
com_probe:
ret

35
kernel/dev/at/floppy.inc Normal file
View file

@ -0,0 +1,35 @@
;; File: floppy.inc
CMOS_FLOPPY_TYPE = 0x10
FLOPPY_NONE = 0x0
FLOPPY_360KB = 0x1
FLOPPY_1_2MB = 0x2
FLOPPY_720KB = 0x3
FLOPPY_1_44MB = 0x4
FLOPPY_2_88MB = 0x5
floppy_probe:
mov al, CMOS_FLOPPY_TYPE
out CMOS_COMMAND, al
in al, CMOS_DATA
mov ah, al
and al, 0x0F
and ah, 0xF0
or al, al
jz @f
push ax
mov esi, szMsgFloppy1Found
call klog
pop ax
@@:
or ah, ah
jz @f
mov esi, szMsgFloppy0Found
call klog
@@:
ret
szMsgFloppy0Found db "floppy0: Found", 0
szMsgFloppy1Found db "floppy1: Found", 0

4
kernel/dev/at/ide.inc Normal file
View file

@ -0,0 +1,4 @@
;; File: ide.inc
ide_probe:
ret

9
kernel/dev/at/ne2k.inc Normal file
View file

@ -0,0 +1,9 @@
;; File: ne2k.inc
;;
;; Usefull links:
;; - <datasheet at https://bitsavers.org/components/national/_dataBooks/1988_National_Data_Communications_Local_Area_Networks_UARTs_Handbook.pdf>
NE2K_IOBASE = 0x300
ne2k_probe:
ret

View file

@ -1,2 +1,21 @@
;; File: console.inc ;; File: console.inc
console_probe:
ret
console_write:
mov eax, uConsoleLock
call lock_acquire
mov eax, uConsoleLock
call lock_release
ret
console_read:
mov eax, uConsoleLock
call lock_acquire
mov eax, uConsoleLock
call lock_release
ret
uConsoleLock dd 0

View file

@ -1,9 +1,8 @@
;; File: dev.inc ;; File: dev.inc
struc Device { struc Device {
.write dd ? .write dd ?
.read dd ? .read dd ?
.probe dd ?
} }

View file

@ -1,25 +0,0 @@
;; File: vga_console.inc
VGA_COLUMNS = 80
VGA_LINES = 25
VGA_BASE = 0xC00B8000
vga_lineno db 0
vga_colno db 0
;; Function: vga_console_clear
vga_console_clear:
mov ecx, VGA_COLUMNS*VGA_LINES
xor al, al
mov edi, VGA_BASE
rep stosb
ret
;; Function: vga_console_putc
;;
;; In:
;; AL - charactere to print
vga_console_putc:
ret

View file

@ -70,6 +70,8 @@ kmain:
mov al, 'X' mov al, 'X'
call cga_putc call cga_putc
call floppy_probe
.halt: .halt:
hlt hlt
jmp $ jmp $
@ -80,7 +82,7 @@ kmain:
jmp .halt jmp .halt
include 'klog.inc' include 'klog.inc'
include 'dev/vga_console.inc' include 'dev/console.inc'
include 'mm/mm.inc' include 'mm/mm.inc'
include 'lock.inc' include 'lock.inc'
include 'gdt.inc' include 'gdt.inc'
@ -91,6 +93,7 @@ kmain:
include 'dev/at/pit.inc' include 'dev/at/pit.inc'
include 'dev/at/kbd.inc' include 'dev/at/kbd.inc'
include 'dev/at/cga.inc' include 'dev/at/cga.inc'
include 'dev/at/floppy.inc'
szMsgKernelAlive db "Kernel (", VERSION_FULL , ") is alive", 0 szMsgKernelAlive db "Kernel (", VERSION_FULL , ") is alive", 0

View file

@ -1,7 +1,7 @@
;; File: klog.inc ;; File: klog.inc
;; Kernel logging utilities ;; Kernel logging utilities
CMOS_ADDRESS = 0x70 CMOS_COMMAND = 0x70
CMOS_DATA = 0x71 CMOS_DATA = 0x71
CMOS_REG_SECOND = 0x00 CMOS_REG_SECOND = 0x00
@ -44,13 +44,13 @@ klog_print:
klog_print_time: klog_print_time:
@@: @@:
mov al, 0x0A mov al, 0x0A
out CMOS_ADDRESS, al out CMOS_COMMAND, al
in al, CMOS_DATA in al, CMOS_DATA
and al, 0x80 and al, 0x80
jnz @b jnz @b
mov al, CMOS_REG_HOUR mov al, CMOS_REG_HOUR
out CMOS_ADDRESS, al out CMOS_COMMAND, al
in al, CMOS_DATA in al, CMOS_DATA
mov ah, al mov ah, al
@ -64,7 +64,7 @@ klog_print_time:
mov [szTime + 2], al mov [szTime + 2], al
mov al, CMOS_REG_MINUTE mov al, CMOS_REG_MINUTE
out CMOS_ADDRESS, al out CMOS_COMMAND, al
in al, CMOS_DATA in al, CMOS_DATA
mov ah, al mov ah, al
@ -78,7 +78,7 @@ klog_print_time:
mov [szTime + 5], al mov [szTime + 5], al
mov al, CMOS_REG_SECOND mov al, CMOS_REG_SECOND
out CMOS_ADDRESS, al out CMOS_COMMAND, al
in al, CMOS_DATA in al, CMOS_DATA
mov ah, al mov ah, al

View file

@ -1,3 +1,77 @@
;; File: vfs.inc
;;
;; Usefull links:
;; - <https://www.cs.fsu.edu/~awang/courses/cop5611_s2024/vnode.pdf>
;;
struc VFS {
.next dd ?
.op dd ?
.vnodes dd ?
.flag dd ?
.bsize dd ?
.data dd ?
}
struc VFSOps {
.mount dd ?
.umount dd ?
.root dd ?
.statfs dd ?
.sync dd ?
.fid dd ?
.vget dd ?
}
VNODE_TYPE_NON = 0x0
VNODE_TYPE_REG = 0x1
VNODE_TYPE_DIR = 0x2
VNODE_TYPE_BLK = 0x3
VNODE_TYPE_CHR = 0x4
VNODE_TYPE_LNK = 0x5
VNODE_TYPE_SOCK = 0x6
VNODE_TYPE_BAD = 0x7
struc VNode {
.flag dw ?
.refcount dw ?
.shlockc dw ?
.exlockc dw ?
.vfs dd ?
.op dd ?
.sock dd ?
.vfsp dd ?
.type db ?
.data dd ?
}
struc VNodeOps {
.open dd ?
.close dd ?
.rdwr dd ?
.ioctl dd ?
.select dd ?
.getattr dd ?
.setattr dd ?
.access dd ?
.lookup dd ?
.create dd ?
.remove dd ?
.link dd ?
.rename dd ?
.mkdir dd ?
.rmdir dd ?
.readdir dd ?
.symlink dd ?
.readlink dd ?
.fsync dd ?
.inactive dd ?
.bmap dd ?
.strategy dd ?
.bread dd ?
.brelse dd ?
}
vfs_init: vfs_init:
ret ret