chore: sync repo

This commit is contained in:
d0p1 🏳️‍⚧️ 2024-07-17 09:41:36 +02:00
parent 4022be6c36
commit 40d3009b1a
13 changed files with 154 additions and 21 deletions

View file

@ -1,4 +1,4 @@
INCS = coff.h
INCS = coff.h elf.h
.PHONY: all
all:

8
include/elf.h Normal file
View file

@ -0,0 +1,8 @@
#ifndef ELF_H
# define ELF_H 1
# include <stdint.h>
/* TODO */
#endif /* !ELF_H */

6
include/sys/errno.h Normal file
View file

@ -0,0 +1,6 @@
#ifndef SYS_ERRNO_H
# define SYS_ERRNO_H 1
# define ENODEV 19
#endif /* !SYS_ERRNO_H */

View file

@ -131,3 +131,6 @@ cga_putc:
leave
ret
cga_device:
db 'video', 0, 0, 0

View file

@ -62,3 +62,5 @@ CMOS_REG_MINUTE = 0x02
CMOS_REG_HOUR = 0x04
CMOS_FLOPPY_TYPE = 0x10
CMOS_INSTALLED_EQUIPMENT = 0x14

View file

@ -1,7 +1,10 @@
;; File: com.inc
COM_MAJOR = 1
com_probe:
ret
com_irq:
iret

View file

@ -4,7 +4,8 @@
;; - <https://wiki.osdev.org/Floppy_Disk_Controller>
;; - <datasheet at http://www.osdever.net/documents/82077AA_FloppyControllerDatasheet.pdf>
CMOS_FLOPPY_TYPE = 0x10
FLOPPY_BDEV_MAJOR = 0
FLOPPY_CDEV_MAJOR = 9
FLOPPY_NONE = 0x0
FLOPPY_360KB = 0x1
@ -13,6 +14,12 @@ FLOPPY_720KB = 0x3
FLOPPY_1_44MB = 0x4
FLOPPY_2_88MB = 0x5
FLOPPY_MAX = 2
struc Floppy {
.active db ?
}
floppy_probe:
mov al, CMOS_FLOPPY_TYPE
out CMOS_COMMAND, al
@ -34,13 +41,33 @@ floppy_probe:
@@:
ret
floppy_init:
call floppy_probe
ret
floppy_strategy:
ret
floppy_open:
xor eax, eax
ret
floppy_close:
ret
floppy_ioctl:
mov eax, ENODEV
ret
floppy_irq:
iret
floppy_device:
dd floppy_probe
dd 0
dd 0
db 'floppy', 0, 0
dd floppy_init
db 0
db 0
szMsgFloppy0Found db "floppy0: Found", 0
szMsgFloppy1Found db "floppy1: Found", 0

View file

@ -7,6 +7,27 @@ KBD_STATP = 0x64
KBD_ATAP = 0x60
KBS_DIB = 0x01
;; function: kbd_probe
;;
;; Out:
;; AL - 0 if not found
kbd_probe:
mov al, CMOS_INSTALLED_EQUIPMENT
out CMOS_COMMAND, al
in al, CMOS_DATA
and al, 0x4
ret
kbd_init:
call kbd_probe
or al, al
jz @f
mov esi, szMsgKbdFound
call klog
@@:
ret
kbd_getc:
in al, KBD_STATP
and al, KBS_DIB
@ -34,7 +55,7 @@ kbd_irq:
popa
iret
szMsgKbdIRQ db "KBD: IRQ", 0
szMsgKbdFound db "KBD: found", 0
aKbdNormalMap:
db 0, 0x1B, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'
@ -44,11 +65,8 @@ aKbdNormalMap:
db 'b', 'n', 'm', ',', '.', '/', 0, '*', 0, ' ', 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7'
db '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.'
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1B, '1', '2'
db '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 0x08, 0x09
db 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']'
db LF, 0, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';'
db "'", '`', 0, '\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ','
db '.', '/', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4'
db '5', '6', '+', '1', '2', '3', '0', '.'
db 0, 0, 0, 0, 0, 0, 0, 0
kbd_device:
db 'kbd', 0, 0, 0, 0, 0
dd kbd_init

View file

@ -22,7 +22,8 @@ console_init:
ret
console_device:
dd console_probe
db 'console', 0
dd console_init
dd console_write
dd console_write

View file

@ -1,22 +1,51 @@
;; File: dev.inc
struc Device {
.probe dd ?
.write dd ?
.read dd ?
.name db 8 dup(?)
.init dd ?
}
DEFN Device
struc BlkDev {
.open dd ?
.close dd ?
.strategy dd ?
.ioctl dd ?
.close dd ?
.dump dd ?
.psize dd ?
}
struc CharDev {
.open dd ?
.close dd ?
.read dd ?
.write dd ?
.ioctl dd ?
.select dd ?
.stop dd ?
.mmap dd ?
.reset dd ?
}
aBlockDevices:
dd 10 dup(0)
.end:
aCharDevices:
dd 10 dup(0)
.end:
aDevices:
dd console_device
dd floppy_device
dd kbd_device
dd console_device
.end:
dev_init:
mov ecx, aDevices
@@:
mov eax, [ecx]
mov eax, [eax + Device.probe]
mov eax, [eax + Device.init]
push ecx
call eax
pop ecx

View file

@ -36,6 +36,7 @@ struc FATFS_BootSector16 {
.code db 448 dup(?)
.signature dw ?
}
DEFN FATFS_BootSector16
struc FATFS_BootSector32 {
.base FATFS_BootSectorBase
@ -56,6 +57,7 @@ struc FATFS_BootSector32 {
.code db 420 dup(?)
.signature dw ?
}
DEFN FATFS_BootSector32
szVfsFatName db 'FATFS', 0
@ -95,3 +97,34 @@ fatfs_newvnode:
fatfs_mountroot:
ret
;; vnode ops
fatfs_open:
ret
fatfs_close:
ret
fatfs_rdwr:
ret
fatfs_ioctl:
ret
fatfs_select:
ret
fatfs_getattr:
ret
fatfs_setattr:
ret
fatfs_access:
ret
fatfs_lookup:
ret
fatfs_create:
ret

View file

@ -5,6 +5,7 @@
include 'sys/macro.inc'
include 'sys/bootinfo.inc'
include 'sys/cpu.inc'
include 'sys/errno.inc'
org KBASE
use32

2
kernel/sys/errno.inc Normal file
View file

@ -0,0 +1,2 @@
ENODEV = 19