StupidOS/kernel/dev/at/floppy.inc

104 lines
1.4 KiB
PHP
Raw Normal View History

2024-07-14 16:48:36 +00:00
;; File: floppy.inc
2024-07-14 20:39:48 +00:00
;;
;; Usefull links:
;; - <https://wiki.osdev.org/Floppy_Disk_Controller>
;; - <datasheet at http://www.osdever.net/documents/82077AA_FloppyControllerDatasheet.pdf>
2024-07-14 16:48:36 +00:00
2024-07-17 07:41:36 +00:00
FLOPPY_BDEV_MAJOR = 0
FLOPPY_CDEV_MAJOR = 9
2024-07-14 16:48:36 +00:00
FLOPPY_NONE = 0x0
FLOPPY_360KB = 0x1
FLOPPY_1_2MB = 0x2
FLOPPY_720KB = 0x3
FLOPPY_1_44MB = 0x4
FLOPPY_2_88MB = 0x5
2024-07-17 07:41:36 +00:00
FLOPPY_MAX = 2
struc Floppy {
.active db ?
}
2024-07-14 16:48:36 +00:00
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
2024-07-17 07:41:36 +00:00
floppy_init:
call floppy_probe
ret
floppy_strategy:
ret
floppy_open:
2024-07-18 09:28:07 +00:00
push ebp
mov ebp, esp
2024-07-17 07:41:36 +00:00
2024-07-18 09:28:07 +00:00
mov eax, [ebp+4]
cmp al, FLOPPY_MAX
jb @f
mov eax, ENXIO
jmp .end
@@:
2024-07-17 07:41:36 +00:00
xor eax, eax
2024-07-18 09:28:07 +00:00
.end:
pop ebp
2024-07-17 07:41:36 +00:00
ret
floppy_close:
2024-07-18 09:28:07 +00:00
xor eax, eax
2024-07-17 07:41:36 +00:00
ret
floppy_ioctl:
mov eax, ENODEV
ret
2024-07-18 09:28:07 +00:00
floppy_dump:
ret
floppy_psize:
ret
2024-07-14 20:39:48 +00:00
floppy_irq:
2024-07-18 09:48:35 +00:00
pusha
mov esi, szMsgFloppyIRQ
popa
2024-07-14 20:39:48 +00:00
iret
2024-07-14 16:48:36 +00:00
2024-07-18 09:48:35 +00:00
szMsgFloppyIRQ db 'Floppy: IRQ', 0
2024-07-16 07:52:08 +00:00
floppy_device:
2024-07-17 07:41:36 +00:00
db 'floppy', 0, 0
dd floppy_init
2024-07-18 09:28:07 +00:00
db FLOPPY_BDEV_MAJOR
db FLOPPY_CDEV_MAJOR
2024-07-21 16:14:38 +00:00
floppy_bdevsw:
2024-07-18 09:28:07 +00:00
dd floppy_open
dd floppy_strategy
dd floppy_ioctl
dd floppy_close
dd floppy_dump
dd floppy_psize
2024-07-16 07:52:08 +00:00
2024-07-18 09:28:07 +00:00
szMsgFloppy0Found db "floppy: fd0 found", 0
szMsgFloppy1Found db "floppy: fd1 found", 0