Pixel not being outputted to screen - Multiboot2

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
itsaxg
Posts: 3
Joined: Tue Sep 30, 2025 11:51 am
Libera.chat IRC: alex

Pixel not being outputted to screen - Multiboot2

Post by itsaxg »

Hey there everyone! I am making a simple kernel for other people to use with very simple functions and there is an issue: pixels are not being outputted.

https://github.com/axgam190/zxOS/tree/main

I have a suspicion that in multiboot.h, fb_color_info isn't that structure, but the other structure

https://www.gnu.org/software/grub/manua ... uffer-info

I don't really have an idea on how I would make this dynamic tho.
What would a fair approach be?
The function calls are in kernel.c
Any help is appreciated!
MichaelPetch
Member
Member
Posts: 857
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: Pixel not being outputted to screen - Multiboot2

Post by MichaelPetch »

I recommend building with debug info and launching GDB to connect to QEMU. The first thing I notice though is that in `start` you don't set up a stack nor do you pass the magic number and mbi address to `kernel_main`. As a result I believe your framebuffer code is never called because the magic number is wrong and it fails that check and exits `kernel_main`.

You can change your boot.asm to use this setup code instead:

Code: Select all

; boot.asm
global start
extern kernel_main

section .text
bits 32
align 4
start:
    mov esp, stack_top-8 ; Subtract 8 so the 8 bytes pushed below keep stack 16 byte aligned before calling kernel_main
    cld
    push ebx
    push eax
    call kernel_main
end:
    hlt
    jmp end

section .bss
align 16
stack_bottom: resb 4096
stack_top:
I recommend building with debug info so add `-gdwarf` to each NASM assemble command in your makefile and the `-g` option to the `gcc` compile commands. You can then create a shell script to launch QEMU in the background and connect GDB to it. Something like:

Code: Select all

#!/bin/sh

qemu-system-i386 -cdrom os.iso  -s -S -d int -M smm=off -no-shutdown -no-reboot &
QEMU_PID=$!

gdb iso/boot/kernel.bin \
        -ex 'target remote localhost:1234' \
        -ex 'set disassembly-flavor intel' \
        -ex 'break kernel_main' \
        -ex 'continue'
        
stty sane
if ps -p $QEMU_PID >/dev/null
then
    kill -9 $QEMU_PID >/dev/null
fi
You still have problems but this should allow you to get further in your debugging experience.
Post Reply