dev: boot framebuffer support
This commit is contained in:
@@ -16,6 +16,9 @@ extern "C" {
|
||||
|
||||
extern int ml_init(uintptr_t arg);
|
||||
|
||||
extern const struct framebuffer_varinfo *bootfb_varinfo(void);
|
||||
extern const struct framebuffer_fixedinfo *bootfb_fixedinfo(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#define PTR32(x) ((void *)((uintptr_t)(x)))
|
||||
|
||||
static ml_cpu_block g_bootstrap_cpu = {0};
|
||||
static struct framebuffer_varinfo __bootfb_varinfo;
|
||||
static struct framebuffer_fixedinfo __bootfb_fixedinfo;
|
||||
|
||||
/* start and end of kernel image (physical addresses) */
|
||||
extern char __pstart[], __pend[];
|
||||
@@ -44,10 +46,51 @@ static void early_vm_init(void)
|
||||
printk("memblock: reserved bios+kernel at [0x%016llx-0x%016llx]", 0, (uintptr_t)__pend);
|
||||
}
|
||||
|
||||
static void init_bootfb(multiboot_info_t *mb)
|
||||
{
|
||||
__bootfb_varinfo.fb_xres = mb->framebuffer_width;
|
||||
__bootfb_varinfo.fb_yres = mb->framebuffer_height;
|
||||
__bootfb_varinfo.fb_bpp = mb->framebuffer_bpp;
|
||||
__bootfb_varinfo.fb_stride = mb->framebuffer_pitch;
|
||||
|
||||
switch (mb->framebuffer_type) {
|
||||
case MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED:
|
||||
__bootfb_varinfo.fb_flags = FB_MODE_PALETTE;
|
||||
__bootfb_varinfo.fb_palette_addr = mb->framebuffer_palette_addr;
|
||||
__bootfb_varinfo.fb_palette_nr_colours = mb->framebuffer_palette_num_colors;
|
||||
break;
|
||||
case MULTIBOOT_FRAMEBUFFER_TYPE_RGB:
|
||||
__bootfb_varinfo.fb_flags = FB_MODE_RGB;
|
||||
__bootfb_varinfo.fb_red.b_length = mb->framebuffer_red_mask_size;
|
||||
__bootfb_varinfo.fb_red.b_offset = mb->framebuffer_red_field_position;
|
||||
|
||||
__bootfb_varinfo.fb_green.b_length = mb->framebuffer_green_mask_size;
|
||||
__bootfb_varinfo.fb_green.b_offset = mb->framebuffer_green_field_position;
|
||||
|
||||
__bootfb_varinfo.fb_blue.b_length = mb->framebuffer_blue_mask_size;
|
||||
__bootfb_varinfo.fb_blue.b_offset = mb->framebuffer_blue_field_position;
|
||||
|
||||
__bootfb_varinfo.fb_alpha.b_length = 0;
|
||||
__bootfb_varinfo.fb_alpha.b_offset = 0;
|
||||
break;
|
||||
case MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT:
|
||||
__bootfb_varinfo.fb_flags = FB_MODE_VGATEXT;
|
||||
__bootfb_varinfo.fb_xcells = 80;
|
||||
__bootfb_varinfo.fb_ycells = 25;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
__bootfb_fixedinfo.fb_baseptr = mb->framebuffer_addr;
|
||||
}
|
||||
|
||||
int ml_init(uintptr_t arg)
|
||||
{
|
||||
multiboot_info_t *mb = (multiboot_info_t *)arg;
|
||||
|
||||
init_bootfb(mb);
|
||||
|
||||
bootstrap_cpu_init();
|
||||
vgacon_init();
|
||||
serialcon_init(115200);
|
||||
@@ -56,6 +99,7 @@ int ml_init(uintptr_t arg)
|
||||
print_kernel_banner();
|
||||
|
||||
early_vm_init();
|
||||
printk("video mode: %ux%u", mb->framebuffer_width, mb->framebuffer_height);
|
||||
|
||||
e820_scan(PTR32(mb->mmap_addr), mb->mmap_length);
|
||||
|
||||
@@ -91,3 +135,13 @@ int ml_init(uintptr_t arg)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct framebuffer_varinfo *bootfb_varinfo(void)
|
||||
{
|
||||
return &__bootfb_varinfo;
|
||||
}
|
||||
|
||||
const struct framebuffer_fixedinfo *bootfb_fixedinfo(void)
|
||||
{
|
||||
return &__bootfb_fixedinfo;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user