wip: vbe still not working but let us cook

This commit is contained in:
0x35c 2024-12-06 14:25:03 +01:00
parent 2a281522cf
commit daf510687a
5 changed files with 15 additions and 11 deletions

View File

@ -6,6 +6,7 @@ struct vbe_interface {
uint32_t *buff; uint32_t *buff;
uint16_t height; uint16_t height;
uint16_t width; uint16_t width;
uint32_t pitch;
uint8_t bpp; uint8_t bpp;
}; };

View File

@ -40,6 +40,6 @@ void kernel_main(multiboot_info_t *mbd, uint32_t magic)
/* "complex 8*unknown quantity -byte descriptor table. -- Troy " /* "complex 8*unknown quantity -byte descriptor table. -- Troy "
*/ */
/* "Martin 03:50, 22 March 2009 (UTC)\n"); */ /* "Martin 03:50, 22 March 2009 (UTC)\n"); */
display.buff[1024] = 255; memset(display.buff, 255, 1024 * 1024);
shell_init(); /* shell_init(); */
} }

View File

@ -46,9 +46,8 @@ static void add_frame_node(multiboot_memory_map_t *mmmt)
* this situation: * this situation:
* --------############### * --------###############
*/ */
if (KERNEL_START > start_addr && KERNEL_START <= end_addr) { if (KERNEL_START > start_addr && KERNEL_START <= end_addr)
len = ROUND_FLOOR(KERNEL_START - start_addr, PAGE_SIZE); len = ROUND_FLOOR(KERNEL_START - start_addr, PAGE_SIZE);
}
/** Kernel code end on the block /** Kernel code end on the block
* this situation: * this situation:
* ###############-------- * ###############--------

View File

@ -9,6 +9,7 @@
#include "vbe.h" #include "vbe.h"
uint32_t multiboot_page_table[1024] __attribute__((aligned(PAGE_SIZE))); uint32_t multiboot_page_table[1024] __attribute__((aligned(PAGE_SIZE)));
uint32_t vbe_page_table[1024] __attribute__((aligned(PAGE_SIZE)));
multiboot_memory_map_t *mmap_addr; multiboot_memory_map_t *mmap_addr;
multiboot_uint32_t mmap_length; multiboot_uint32_t mmap_length;
@ -27,22 +28,25 @@ static void init_mmap(multiboot_info_t *mbd_virt, size_t *pt_index)
*pt_index += i; *pt_index += i;
} }
static void init_vbe(multiboot_info_t *mbd_virt, size_t *pt_index) static void init_vbe(multiboot_info_t *mbd_virt)
{ {
const uint32_t framebuffer_size = mbd_virt->framebuffer_height * const uint32_t framebuffer_size = mbd_virt->framebuffer_height *
mbd_virt->framebuffer_width * mbd_virt->framebuffer_width *
CEIL(mbd_virt->framebuffer_bpp, 4); CEIL(mbd_virt->framebuffer_bpp, 4);
uint32_t i = 0; uint32_t i = 0;
for (; i < CEIL(framebuffer_size, PAGE_SIZE); i++) for (; i < CEIL(framebuffer_size, PAGE_SIZE); i++) {
multiboot_page_table[i + *pt_index] = if (i % 1024 == 0)
page_directory[800 + i / 1024] =
((uint32_t)vbe_page_table - HEAP_END) | 0x03;
vbe_page_table[i % 1024] =
((mbd_virt->framebuffer_addr + i * PAGE_SIZE) & PAGE_MASK) | ((mbd_virt->framebuffer_addr + i * PAGE_SIZE) & PAGE_MASK) |
INIT_FLAGS; INIT_FLAGS;
display.buff = (uint32_t *)GET_PAGE_ADDR(1023, *pt_index) + }
display.buff = (uint32_t *)GET_PAGE_ADDR(800 + i - 1 / 1024, 0) +
(mbd_virt->framebuffer_addr % PAGE_SIZE); (mbd_virt->framebuffer_addr % PAGE_SIZE);
display.height = mbd_virt->framebuffer_height; display.height = mbd_virt->framebuffer_height;
display.width = mbd_virt->framebuffer_width; display.width = mbd_virt->framebuffer_width;
display.bpp = mbd_virt->framebuffer_bpp; display.bpp = mbd_virt->framebuffer_bpp;
*pt_index += i;
} }
void init_multiboot(multiboot_info_t *mbd, uint32_t magic) void init_multiboot(multiboot_info_t *mbd, uint32_t magic)
@ -64,5 +68,5 @@ void init_multiboot(multiboot_info_t *mbd, uint32_t magic)
(multiboot_info_t *)(GET_PAGE_ADDR(1023, 0) + (multiboot_info_t *)(GET_PAGE_ADDR(1023, 0) +
(uint32_t)mbd % PAGE_SIZE); (uint32_t)mbd % PAGE_SIZE);
init_mmap(mbd_virt, &pt_index); init_mmap(mbd_virt, &pt_index);
init_vbe(mbd, &pt_index); init_vbe(mbd_virt);
} }

View File

@ -82,7 +82,7 @@ uint8_t terminal_get_default_color(void)
uint8_t terminal_get_char(int column, int row) uint8_t terminal_get_char(int column, int row)
{ {
return screen->buffer[row * VGA_WIDTH + column]; /* return screen->buffer[row * VGA_WIDTH + column]; */
} }
void terminal_putentryat(char c, uint8_t color, size_t x, size_t y) void terminal_putentryat(char c, uint8_t color, size_t x, size_t y)