2024-04-11 22:53:15 +08:00
|
|
|
#include "../include/graphics.h"
|
2024-05-19 18:05:00 +08:00
|
|
|
#include "../include/memory.h"
|
2024-05-02 11:06:52 +08:00
|
|
|
#include "../include/io.h"
|
2024-04-11 22:53:15 +08:00
|
|
|
|
2024-05-19 18:05:00 +08:00
|
|
|
extern page_directory_t *kernel_directory;
|
|
|
|
uint32_t video_base, video_size;
|
|
|
|
|
|
|
|
svga_mode_info_t* svga_mode_get_info(multiboot_t *sys_multiboot_info,uint16_t mode) {
|
|
|
|
return (svga_mode_info_t *) sys_multiboot_info->vbe_mode_info;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
uint32_t svga_map_fb(uint32_t real_addr, uint32_t fb_length) {
|
|
|
|
int i = 0;
|
|
|
|
uint32_t fb_addr;
|
|
|
|
|
|
|
|
// Align framebuffer length to page boundaries
|
|
|
|
fb_length += 0x1000;
|
|
|
|
fb_length &= 0x0FFFF000;
|
|
|
|
|
|
|
|
// Map enough framebuffer
|
|
|
|
for(i = 0xD0000000; i < 0xD0000000 + fb_length; i += 0x1000) {
|
|
|
|
page_t* page = paging_get_page(i, true, kernel_directory);
|
|
|
|
|
|
|
|
fb_addr = (i & 0x0FFFF000) + real_addr;
|
|
|
|
|
|
|
|
page->present = 1;
|
|
|
|
page->rw = 1;
|
|
|
|
page->user = 1;
|
|
|
|
page->frame = fb_addr >> 12;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert the kernel directory addresses to physical if needed
|
|
|
|
for(i = 0x340; i < 0x340 + (fb_length / 0x400000); i++) {
|
|
|
|
uint32_t physAddr = kernel_directory->tablesPhysical[i];
|
|
|
|
|
|
|
|
if((physAddr & 0xC0000000) == 0xC0000000) {
|
|
|
|
physAddr &= 0x0FFFFFFF; // get rid of high nybble
|
|
|
|
|
|
|
|
kernel_directory->tablesPhysical[i] = physAddr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0xD0000000;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2024-05-03 20:32:10 +08:00
|
|
|
int isVBEDisplayMode(uint16_t vbe_mode_info) {
|
|
|
|
if (vbe_mode_info & (1 << 12)) {
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
2024-04-12 22:03:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void initVBE(multiboot_t *mboot) {
|
2024-05-19 18:05:00 +08:00
|
|
|
svga_mode_info_t *vbe_info = svga_mode_get_info(mboot,SVGA_DEFAULT_MODE);
|
|
|
|
if(vbe_info->bpp == 32 || vbe_info->bpp == 16){
|
|
|
|
printf("VBE LOAD SUCCESS!");
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("[VBE]: Bass: %08x | PITCH: %d | HEIGHT: %d\n",vbe_info->physbase,
|
|
|
|
vbe_info->pitch,
|
|
|
|
vbe_info->screen_height);
|
|
|
|
|
|
|
|
//video_base = svga_map_fb(svga_mode_info->physbase, svga_mode_info->pitch * svga_mode_info->screen_height);
|
2024-04-11 22:53:15 +08:00
|
|
|
|
2024-05-19 18:05:00 +08:00
|
|
|
while (1) io_hlt();
|
2024-04-11 22:53:15 +08:00
|
|
|
}
|