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/cga.inc \
dev/at/kbd.inc \ dev/at/kbd.inc \
dev/at/floppy.inc \ dev/at/floppy.inc \
dev/dev.inc \
fs/fat.inc \ fs/fat.inc \
fs/stpdfs.inc \ fs/stpdfs.inc \
fs/xv6fs.inc \ fs/xv6fs.inc \

View file

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

View file

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

View file

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

View file

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

View file

@ -1,10 +1,27 @@
;; File: dev.inc ;; File: dev.inc
struc Device { struc Device {
.probe dd ?
.write dd ? .write dd ?
.read dd ? .read dd ?
.probe dd ?
} }
DEFN Device
aDevices:
dd console_device
dd floppy_device
.end:
dev_init: 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 ret

View file

@ -71,3 +71,27 @@ fatfs_init:
mov eax, vfs_fatfs mov eax, vfs_fatfs
call vfs_register call vfs_register
ret 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 pit_init
call dev_init
call vfs_init call vfs_init
mov eax, SYSCALL_EXIT mov eax, SYSCALL_EXIT
@ -73,8 +75,6 @@ kmain:
;mov al, 'X' ;mov al, 'X'
;call cga_putc ;call cga_putc
call floppy_probe
.halt: .halt:
hlt hlt
jmp $ jmp $
@ -91,6 +91,7 @@ kmain:
include 'dev/at/floppy.inc' include 'dev/at/floppy.inc'
include 'klog.inc' include 'klog.inc'
include 'dev/console.inc' include 'dev/console.inc'
include 'dev/dev.inc'
include 'mm/mm.inc' include 'mm/mm.inc'
include 'lock.inc' include 'lock.inc'
include 'gdt.inc' include 'gdt.inc'

View file

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