mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-03 18:22:22 +00:00
Added setup screen on bootup. Also added src/config.asm, where you can configure some stuff
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 8.9 KiB |
@@ -0,0 +1,7 @@
|
|||||||
|
;;;
|
||||||
|
;;; Kern build configuration
|
||||||
|
;;;
|
||||||
|
|
||||||
|
;; Force 1920x1080 32bpp resolution (will skip prompt on boot)
|
||||||
|
; %define FORCE_RESOLUTION
|
||||||
|
|
||||||
+96
-4
@@ -1,6 +1,8 @@
|
|||||||
[bits 16]
|
[bits 16]
|
||||||
[org 0x7e00]
|
[org 0x7e00]
|
||||||
|
|
||||||
|
%include "src/config.asm"
|
||||||
|
|
||||||
%define KERNEL_LOC 0x1000
|
%define KERNEL_LOC 0x1000
|
||||||
%define VIDMEM 0xb800
|
%define VIDMEM 0xb800
|
||||||
|
|
||||||
@@ -29,10 +31,8 @@ getMemoryMap:
|
|||||||
jnz .start
|
jnz .start
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
mov si, acpiFuncErr
|
stc
|
||||||
call print
|
jmp inputGfx
|
||||||
cli
|
|
||||||
hlt
|
|
||||||
|
|
||||||
.nextEntry:
|
.nextEntry:
|
||||||
mov edx, "PAMS" ; In case BIOS messes with edx
|
mov edx, "PAMS" ; In case BIOS messes with edx
|
||||||
@@ -59,8 +59,30 @@ getMemoryMap:
|
|||||||
mov [memMapEntries], bp
|
mov [memMapEntries], bp
|
||||||
clc
|
clc
|
||||||
|
|
||||||
|
;; Get graphics values from user (resolution etc.)
|
||||||
|
inputGfx:
|
||||||
|
xor ecx, ecx
|
||||||
|
cmp word [width], 0 ; Values already set
|
||||||
|
jne vbeSetup
|
||||||
|
mov si, gfxChooseMsg
|
||||||
|
call print
|
||||||
|
call getNumber ; Stores input value in bx
|
||||||
|
mov [width], bx
|
||||||
|
|
||||||
|
mov si, gfxHeightMsg
|
||||||
|
call print
|
||||||
|
call getNumber
|
||||||
|
mov [height], bx
|
||||||
|
|
||||||
|
mov si, gfxBppMsg
|
||||||
|
call print
|
||||||
|
call getNumber
|
||||||
|
mov [bpp], bx
|
||||||
|
|
||||||
vbeSetup:
|
vbeSetup:
|
||||||
; Setup VBE info
|
; Setup VBE info
|
||||||
|
xor ax, ax
|
||||||
|
mov es, ax
|
||||||
mov ax, 0x4f00
|
mov ax, 0x4f00
|
||||||
mov di, vbeInfoBlock
|
mov di, vbeInfoBlock
|
||||||
int 0x10
|
int 0x10
|
||||||
@@ -233,6 +255,64 @@ print:
|
|||||||
pop ax
|
pop ax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
;;
|
||||||
|
;; Reads a base 10 number as input from user
|
||||||
|
;; Returns:
|
||||||
|
;; bx - number read
|
||||||
|
;;
|
||||||
|
getNumber: ; TODO: if user enters a number that overflows (n > 0xffff) shit breaks
|
||||||
|
push cx
|
||||||
|
push ax
|
||||||
|
push dx
|
||||||
|
xor bx, bx
|
||||||
|
mov cx, 10
|
||||||
|
.nextDigit:
|
||||||
|
xor ah, ah
|
||||||
|
int 0x16
|
||||||
|
mov ah, 0x0e
|
||||||
|
|
||||||
|
cmp al, 0x08 ; Backspace
|
||||||
|
je .backspace
|
||||||
|
cmp al, 0x0d ; Enter
|
||||||
|
je .enter
|
||||||
|
|
||||||
|
cmp al, '0' ; Make sure user entered a number
|
||||||
|
jl .nextDigit
|
||||||
|
cmp al, '9'
|
||||||
|
jg .nextDigit
|
||||||
|
|
||||||
|
int 0x10 ; Print the digit
|
||||||
|
|
||||||
|
sub al, '0' ; Convert to integer
|
||||||
|
mov ah, 0
|
||||||
|
imul bx, bx, 10 ; bx *= 10
|
||||||
|
add bx, ax ; bx += ax
|
||||||
|
jmp .nextDigit
|
||||||
|
|
||||||
|
.backspace:
|
||||||
|
cmp bx, 0 ; Check if we can backspace
|
||||||
|
je .nextDigit
|
||||||
|
int 0x10 ; go back one space
|
||||||
|
|
||||||
|
mov ax, bx
|
||||||
|
xor dx, dx
|
||||||
|
div cx ; dx:ax / cx -> ax = result, dx = remainder
|
||||||
|
mov bx, ax
|
||||||
|
|
||||||
|
mov ah, 0x0e
|
||||||
|
mov al, ' '
|
||||||
|
int 0x10
|
||||||
|
mov al, 0x08
|
||||||
|
int 0x10
|
||||||
|
|
||||||
|
jmp .nextDigit
|
||||||
|
|
||||||
|
.enter:
|
||||||
|
pop dx
|
||||||
|
pop ax
|
||||||
|
pop cx
|
||||||
|
ret
|
||||||
|
|
||||||
;; 32 Bit entry code
|
;; 32 Bit entry code
|
||||||
[bits 32]
|
[bits 32]
|
||||||
protected_start:
|
protected_start:
|
||||||
@@ -267,6 +347,11 @@ vbeErr: db "VBE Error!", 0
|
|||||||
modeNotFoundErr: db "VBE Mode not found!", 0
|
modeNotFoundErr: db "VBE Mode not found!", 0
|
||||||
acpiFuncErr: db "ACPI Function not supported!", 0
|
acpiFuncErr: db "ACPI Function not supported!", 0
|
||||||
|
|
||||||
|
gfxChooseMsg: db "Please enter desired values" ; No NULL terminator, we want to print gfxWidthMsg right after anyway
|
||||||
|
gfxWidthMsg: db 0x0a, 0x0d, "Width: ", 0
|
||||||
|
gfxHeightMsg: db 0x0a, 0x0d, "Height: ", 0
|
||||||
|
gfxBppMsg: db 0x0a, 0x0d, "Bits Per Pixel: ", 0
|
||||||
|
|
||||||
;; GDT
|
;; GDT
|
||||||
GDT:
|
GDT:
|
||||||
.start:
|
.start:
|
||||||
@@ -297,9 +382,16 @@ CODE_SEG equ GDT.codeDescriptor - GDT.start
|
|||||||
DATA_SEG equ GDT.dataDescriptor - GDT.start
|
DATA_SEG equ GDT.dataDescriptor - GDT.start
|
||||||
|
|
||||||
;; VBE Stuff
|
;; VBE Stuff
|
||||||
|
%ifdef FORCE_RESOLUTION
|
||||||
width: dw 1920
|
width: dw 1920
|
||||||
height: dw 1080
|
height: dw 1080
|
||||||
bpp: db 32
|
bpp: db 32
|
||||||
|
%else
|
||||||
|
width: dw 0
|
||||||
|
height: dw 0
|
||||||
|
bpp: db 0
|
||||||
|
%endif
|
||||||
|
|
||||||
offset: dw 0
|
offset: dw 0
|
||||||
_segment: dw 0 ; segment is a keyword
|
_segment: dw 0 ; segment is a keyword
|
||||||
mode: dw 0
|
mode: dw 0
|
||||||
|
|||||||
Reference in New Issue
Block a user