klange wrote:
QEMU does not use a fixed address for the framebuffer. Grub will pass the framebuffer address to you in the multiboot struct (and you can also locate it through PCI).
I tried to do it, but it didn't work. I used the code for multiboot info from
this site.
Complement of its kernel.asm up to this:
Code:
bits 32
%define MULTIBOOT_MAGIC 0x1BADB002
%define MULTIBOOT_FLAGS (1<<0 | 1<<1 | 1<<2)
%define KERNEL_BASE 0xFFFF800000000000
section .text
align 4
multiboot_header:
dd MULTIBOOT_MAGIC
dd MULTIBOOT_FLAGS
dd -(MULTIBOOT_MAGIC + MULTIBOOT_FLAGS)
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 800 ; width
dd 600 ; height
dd 32 ; bbp
global start
extern kmain
start:
cli
mov esp, stack_space
mov [multiboot_info_ptr - KERNEL_BASE], ebx
call kmain
hlt
section .bss
multiboot_info_ptr
resb 8192
stack_space:
kernel.c looks like this:
Code:
#include "kernel.h"
#define VESA_WIDTH 800
#define VESA_HEIGHT 600
#define VESA_BBP 32
#define VESA_SIZE VESA_WIDTH * VESA_HEIGHT * VESA_BBP / 8
void kmain(unsigned long magic, unsigned long addr)
{
multiboot_info_t *mbi;
mbi = (multiboot_info_t *) addr;
memset((void*)mbi->framebuffer_addr, 0xFF0000, VESA_SIZE);
return;
}
But I see only a black screen again. I suspect grub doesn't give me the address on the multiboot info. But I can't check it.