From d89a1c40715f6378f05ffc057833b8e8a6277b53 Mon Sep 17 00:00:00 2001 From: xamidev <121681048+xamidev@users.noreply.github.com> Date: Sat, 14 Sep 2024 20:08:30 +0200 Subject: [PATCH] Fix: compatibility, kernel stack, + docs --- docs/DEVELOPERS.md | 17 +++++++++++++++++ grub.cfg | 1 - link.ld | 2 +- makefile | 2 +- src/kernel/loader.s | 5 +++-- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/docs/DEVELOPERS.md b/docs/DEVELOPERS.md index 4128319..045ccdc 100644 --- a/docs/DEVELOPERS.md +++ b/docs/DEVELOPERS.md @@ -8,6 +8,7 @@ - Writing programs for BlankOS - Changing the TTY font - Changing the initial ramdisk content +- Changing the framebuffer resolution ## Getting Started @@ -120,3 +121,19 @@ The system loads an initial ramdisk as a simple TAR file located in `iso/boot/in You can add, delete, or modify this file's contents by doing that in the `src/initrd` folder. Anything in that folder will be added to the initial ramdisk and will therefore be loaded into the system. The ramdisk gets loaded as a GRUB2 module. + +## Changing the framebuffer resolution + +Locate the framebuffer request tag from the Multiboot2 header in `src/kernel/loader.s`. It should look like this: + +``` + align 8 + dw 5 ; 2 + dw 0 ; 2 + dd 20 ; 4 + dd 1920 ; 4 + dd 1080 ; 4 + dd 32 ; 4 +``` + +Change the `1920` and `1080` values with the resolution you want, according to your screen. Be aware that this might break some programs that rely on the hardcoded Full HD framebuffer value (1920x1080x32). You can also try switching the value under that,`32`, but it will break the display because the kernel is made for 32bpp. diff --git a/grub.cfg b/grub.cfg index a42e11b..050a8c1 100644 --- a/grub.cfg +++ b/grub.cfg @@ -1,6 +1,5 @@ menuentry "Blank OS" { insmod all_video - set gfxpayload=1024x768x32 multiboot2 /boot/kernel.elf module2 /boot/initrd.tar boot diff --git a/link.ld b/link.ld index f697fc2..1f9e748 100644 --- a/link.ld +++ b/link.ld @@ -3,7 +3,7 @@ ENTRY(loader) SECTIONS { /* Address to load at; 2MB */ - /*. = 2M;*/ + . = 2M; .multiboot_header ALIGN(4K) : { *(.multiboot_header) diff --git a/makefile b/makefile index d1580ae..c6eb216 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,5 @@ CC = i386-elf-7.5.0-Linux-x86_64/bin/i386-elf-gcc -CFLAGS = -ffreestanding -g -Wall -Wextra -Wno-builtin-declaration-mismatch -c -I src/ +CFLAGS = -ffreestanding -g -Wall -Wextra -Wno-builtin-declaration-mismatch -mno-sse -mno-mmx -mno-avx -march=i386 -c -I src/ LDFLAGS = -T link.ld -melf_i386 AS = nasm ASFLAGS = -f elf diff --git a/src/kernel/loader.s b/src/kernel/loader.s index 55c97d1..11d8aeb 100644 --- a/src/kernel/loader.s +++ b/src/kernel/loader.s @@ -51,6 +51,7 @@ KERNEL_STACK_SIZE equ 4096 extern kmain loader: + mov esp, kernel_stack + KERNEL_STACK_SIZE cli push ebx call kmain @@ -211,6 +212,6 @@ irq_common_stub: section .bss align 4 + +resb KERNEL_STACK_SIZE kernel_stack: - resb KERNEL_STACK_SIZE - mov esp, kernel_stack + KERNEL_STACK_SIZE -- 2.49.1