fix(kernel): cga scrolling

This commit is contained in:
d0p1 🏳️‍⚧️ 2024-07-16 09:52:08 +02:00
parent cac86dd43f
commit 140a204ebf
9 changed files with 65 additions and 14 deletions

View file

@ -18,6 +18,7 @@ SRCS = kernel.asm \
dev/at/cga.inc \
dev/at/kbd.inc \
dev/at/floppy.inc \
dev/dev.inc \
fs/fat.inc \
fs/stpdfs.inc \
fs/xv6fs.inc \

View file

@ -87,7 +87,7 @@ cga_putc:
xor ah, ah
mov cx, [ebp-0x2]
add cx, ax
jmp .end
jmp .next
@@:
mov edx, CGA_MEMORY
xor ecx, ecx
@ -99,6 +99,7 @@ cga_putc:
mov cx, [ebp-0x2]
inc cx
.next:
mov ax, cx
mov dl, CGA_COLUMNS
div dl
@ -110,20 +111,20 @@ cga_putc:
; scroll up
push esi
push edi
mov ecx, CGA_COLUMNS*(CGA_LINES-1)
mov ecx, CGA_COLUMNS*(CGA_LINES)*2
mov edi, CGA_MEMORY
mov esi, CGA_MEMORY+80*2
rep movsw
mov ecx, CGA_COLUMNS
xor ax, ax
mov edi, CGA_MEMORY+(CGA_COLUMNS*(CGA_LINES-1)*2)
mov edi, CGA_MEMORY+(CGA_COLUMNS*(CGA_LINES)*2)
rep stosw
pop esi
pop edi
mov cx, CGA_COLUMNS*(CGA_LINES-1)
mov cx, CGA_COLUMNS*(CGA_LINES)
.end:
mov ax, cx
call cga_setpos

View file

@ -57,4 +57,8 @@
CMOS_COMMAND = 0x70
CMOS_DATA = 0x71
CMOS_REG_SECOND = 0x00
CMOS_REG_MINUTE = 0x02
CMOS_REG_HOUR = 0x04
CMOS_FLOPPY_TYPE = 0x10

View file

@ -37,5 +37,10 @@ floppy_probe:
floppy_irq:
iret
floppy_device:
dd floppy_probe
dd 0
dd 0
szMsgFloppy0Found db "floppy0: Found", 0
szMsgFloppy1Found db "floppy1: Found", 0

View file

@ -21,4 +21,9 @@ console_read:
console_init:
ret
console_device:
dd console_probe
dd console_write
dd console_write
uConsoleLock dd 0

View file

@ -1,10 +1,27 @@
;; File: dev.inc
struc Device {
.probe dd ?
.write dd ?
.read dd ?
.probe dd ?
}
DEFN Device
aDevices:
dd console_device
dd floppy_device
.end:
dev_init:
mov ecx, aDevices
@@:
mov eax, [ecx]
mov eax, [eax + Device.probe]
push ecx
call eax
pop ecx
add ecx, 4
cmp ecx, aDevices.end
jb @b
ret

View file

@ -71,3 +71,27 @@ fatfs_init:
mov eax, vfs_fatfs
call vfs_register
ret
fatfs_mount:
ret
fatfs_start:
ret
fatfs_unmount:
ret
fatfs_root:
ret
fatfs_statvfs:
ret
fatfs_loadvnode:
ret
fatfs_newvnode:
ret
fatfs_mountroot:
ret

View file

@ -65,6 +65,8 @@ kmain:
call pit_init
call dev_init
call vfs_init
mov eax, SYSCALL_EXIT
@ -73,8 +75,6 @@ kmain:
;mov al, 'X'
;call cga_putc
call floppy_probe
.halt:
hlt
jmp $
@ -91,6 +91,7 @@ kmain:
include 'dev/at/floppy.inc'
include 'klog.inc'
include 'dev/console.inc'
include 'dev/dev.inc'
include 'mm/mm.inc'
include 'lock.inc'
include 'gdt.inc'

View file

@ -1,13 +1,6 @@
;; File: klog.inc
;; Kernel logging utilities
CMOS_COMMAND = 0x70
CMOS_DATA = 0x71
CMOS_REG_SECOND = 0x00
CMOS_REG_MINUTE = 0x02
CMOS_REG_HOUR = 0x04
COM1 = 0x3F8
klog_kputc: