Code: Select all
menuentry "*****" {
set root='(hd96)'
set gfxpayload=1024x768x32
multiboot /boot/kernel.bin
}
Code: Select all
menuentry "*****" {
set root='(hd96)'
set gfxpayload=1024x768x32
multiboot /boot/kernel.bin
}
Code: Select all
+-------------------+
0 | flags | (required)
+-------------------+
4 | mem_lower | (present if flags[0] is set)
8 | mem_upper | (present if flags[0] is set)
+-------------------+
12 | boot_device | (present if flags[1] is set)
+-------------------+
16 | cmdline | (present if flags[2] is set)
+-------------------+
20 | mods_count | (present if flags[3] is set)
24 | mods_addr | (present if flags[3] is set)
+-------------------+
28 - 40 | syms | (present if flags[4] or
| | flags[5] is set)
+-------------------+
44 | mmap_length | (present if flags[6] is set)
48 | mmap_addr | (present if flags[6] is set)
+-------------------+
52 | drives_length | (present if flags[7] is set)
56 | drives_addr | (present if flags[7] is set)
+-------------------+
60 | config_table | (present if flags[8] is set)
+-------------------+
64 | boot_loader_name | (present if flags[9] is set)
+-------------------+
68 | apm_table | (present if flags[10] is set)
+-------------------+
72 | vbe_control_info | (present if flags[11] is set)
76 | vbe_mode_info |
80 | vbe_mode |
82 | vbe_interface_seg |
84 | vbe_interface_off |
86 | vbe_interface_len |
+-------------------+
88 | framebuffer_addr | (present if flags[12] is set)
96 | framebuffer_pitch |
100 | framebuffer_width |
104 | framebuffer_height|
108 | framebuffer_bpp |
109 | framebuffer_type |
110-115 | color_info |
+-------------------+
Code: Select all
kmain()
{
}
Code: Select all
bits 32
section .text
align 4
dd 0x1BADB002
dd 0x04
dd -(0x1BADB002 + 0x04)
dd 0 ; skip some flags
dd 0
dd 0
dd 0
dd 0
dd 0 ; sets it to graphical mode
dd 800 ; sets the width
dd 600 ; sets the height
dd 32 ; sets the bits per pixel
push ebx
global start
extern kmain
start:
cli
call kmain
hlt
Code: Select all
bits 32
section .text
align 4
dd 0x1BADB002
dd 0x04
dd -(0x1BADB002 + 0x04)
dd 0 ; skip some flags
dd 0
dd 0
dd 0
dd 0
dd 0 ; sets it to graphical mode
dd 800 ; sets the width
dd 600 ; sets the height
dd 32 ; sets the bits per pixel
global start
extern kmain
start:
mov edi, dword [ebx + 88] ; edi <- framebuffer_addr
mov dword [edi], 0x00FFFFFF ; white pixel should appear in top left corner
mov esp, stack.end
push ebx
call kmain
pop ebx
cli
hlt
stack: resb 4096
.end:
Code: Select all
vesa_clear();
Code: Select all
vesa_drawpixel(x,y,colour)
Code: Select all
typedef struct
{
char skip[88]; // there are some interesting fields here but
// we skip them for simplicity
unsigned framebuffer_addr_lo; // separated these fields to avoid 64 bit
unsigned framebuffer_addr_hi; // arithmetic (which may need some extra code)
unsigned framebuffer_pitch; // this is basically bytes per line
unsigned framebuffer_width;
unsigned framebuffer_height;
unsigned char framebuffer_bpp;
} multiboot_info_t;
multiboot_info_t *mbinfo;
void vesa_drawpixel(unsigned x, unsigned y, unsigned color)
{ // assuming 32bpp
unsigned *line = (unsigned *)(mbinfo->framebuffer_addr_lo + y * mbinfo->framebuffer_pitch);
line[x] = color;
}
void vesa_clear(unsigned color)
{ // slow but simple
for(unsigned y = 0; y < mbinfo->framebuffer_height; ++y)
{
for(unsigned x = 0; x < mbinfo->framebuffer_width; ++x)
vesa_drawpixel(x, y, color);
}
}
void kmain(multiboot_info_t *mboot_info)
{
mbinfo = mboot_info;
vesa_clear(0x00203040);
vesa_drawpixel(400, 300, 0x00FFFFFF);
}