con: Add early vesa fbcon
This commit is contained in:
parent
7438ee768f
commit
bb5ff71a79
@ -15,8 +15,7 @@ struct display *vesa_get_display(void) {
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize early (pre-PCI) framebuffer
|
||||
void vesa_init(struct boot_video_info *info) {
|
||||
void vesa_early_init(struct boot_video_info *info) {
|
||||
if (info->width && info->height) {
|
||||
// If these fields are set, framebuffer is available
|
||||
display_vesa_fb.flags = DISP_GRAPHIC | DISP_LFB;
|
||||
@ -27,7 +26,10 @@ void vesa_init(struct boot_video_info *info) {
|
||||
display_vesa_fb.framebuffer = MM_VIRTUALIZE(info->framebuffer_phys);
|
||||
|
||||
list_head_init(&display_vesa_fb.list);
|
||||
|
||||
display_add(&display_vesa_fb);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize early (pre-PCI) framebuffer
|
||||
void vesa_add_display(void) {
|
||||
display_add(&display_vesa_fb);
|
||||
}
|
||||
|
@ -188,6 +188,12 @@ void kernel_early_init(uint64_t entry_method) {
|
||||
panic("Unknown boot method: something's broken\n");
|
||||
break;
|
||||
}
|
||||
vesa_early_init(&boot_video_info);
|
||||
struct display *disp = vesa_get_display();
|
||||
if (disp) {
|
||||
kdebug("Initialize early console!\n");
|
||||
console_init_early(disp);
|
||||
}
|
||||
|
||||
cpuid_init();
|
||||
|
||||
@ -207,13 +213,14 @@ void kernel_early_init(uint64_t entry_method) {
|
||||
}
|
||||
|
||||
amd64_phys_memory_map(&phys_memory_map);
|
||||
while (1);
|
||||
|
||||
amd64_gdt_init();
|
||||
amd64_idt_init(0);
|
||||
|
||||
amd64_mm_init();
|
||||
|
||||
vesa_init(&boot_video_info);
|
||||
vesa_add_display();
|
||||
|
||||
//if (multiboot_tag_sections) {
|
||||
// ksym_set_multiboot2(multiboot_tag_sections);
|
||||
|
@ -12,6 +12,7 @@ struct boot_video_info {
|
||||
};
|
||||
|
||||
struct display *vesa_get_display(void);
|
||||
void vesa_init(struct boot_video_info *info);
|
||||
void vesa_early_init(struct boot_video_info *info);
|
||||
void vesa_add_display(void);
|
||||
void vesa_put(uint32_t x, uint32_t y, uint32_t v);
|
||||
void vesa_clear(uint32_t color);
|
||||
|
@ -35,4 +35,5 @@ void console_default_putc(int c);
|
||||
|
||||
struct console *console_get_default(void);
|
||||
|
||||
void console_init_early(struct display *output);
|
||||
void console_init_default(void);
|
||||
|
@ -27,10 +27,11 @@ uintptr_t kernel_config[__CFG_SIZE] = {
|
||||
[CFG_INIT] = (uintptr_t) "/init",
|
||||
[CFG_CONSOLE] = (uintptr_t) "tty0",
|
||||
[CFG_DEBUG] = DEBUG_ALL_SERIAL |
|
||||
DEBUG_DISP(DEBUG_INFO) |
|
||||
DEBUG_DISP(DEBUG_WARN) |
|
||||
DEBUG_DISP(DEBUG_ERROR) |
|
||||
DEBUG_DISP(DEBUG_FATAL),
|
||||
DEBUG_ALL_DISP,
|
||||
//DEBUG_DISP(DEBUG_INFO) |
|
||||
//DEBUG_DISP(DEBUG_WARN) |
|
||||
//DEBUG_DISP(DEBUG_ERROR) |
|
||||
//DEBUG_DISP(DEBUG_FATAL),
|
||||
};
|
||||
|
||||
static int parse_number(const char *s, intptr_t *res) {
|
||||
|
@ -37,6 +37,14 @@ struct console_buffer {
|
||||
uint16_t data[0];
|
||||
};
|
||||
|
||||
#define ECON_BUFSIZ 32768
|
||||
static int have_early;
|
||||
static union {
|
||||
struct console_buffer buf;
|
||||
char _buf[sizeof(struct console_buffer) + ECON_BUFSIZ];
|
||||
} early_buffer;
|
||||
static struct console early;
|
||||
|
||||
static struct console_buffer *console_buffer_create(uint16_t rows, uint16_t cols) {
|
||||
struct console_buffer *buf = kmalloc(sizeof(struct console_buffer) + rows * cols * sizeof(uint16_t));
|
||||
_assert(buf);
|
||||
@ -370,6 +378,11 @@ void console_type(struct console *con, int c) {
|
||||
|
||||
void console_default_putc(int c) {
|
||||
if (list_empty(&g_consoles)) {
|
||||
if (have_early) {
|
||||
struct console *con = &early;
|
||||
_assert(con->buf_active);
|
||||
_console_putc(con, con->buf_active, c);
|
||||
}
|
||||
return;
|
||||
}
|
||||
struct console *con = list_entry(g_consoles.next, struct console, list);
|
||||
@ -378,6 +391,34 @@ void console_default_putc(int c) {
|
||||
}
|
||||
}
|
||||
|
||||
void console_init_early(struct display *output) {
|
||||
// TODO: allow selecting fonts per console/display
|
||||
early.tty_active = NULL;
|
||||
early.buf_active = &early_buffer.buf;
|
||||
early.display = output;
|
||||
early.width_chars = output->width_pixels / 8;
|
||||
early.height_chars = output->height_pixels / 16;
|
||||
|
||||
if (early.width_chars * early.height_chars * 2 > ECON_BUFSIZ) {
|
||||
panic("Failed to fit early console\n");
|
||||
}
|
||||
|
||||
struct console_buffer *buf = &early_buffer.buf;
|
||||
memsetw(buf->data, ATTR_DEFAULT, early.width_chars * early.height_chars);
|
||||
buf->y = 0;
|
||||
buf->x = 0;
|
||||
buf->saved_y = 0;
|
||||
buf->saved_x = 0;
|
||||
buf->last_blink_x = 0;
|
||||
buf->last_blink_y = 0;
|
||||
buf->attr = ATTR_DEFAULT;
|
||||
buf->xattrs = 0;
|
||||
buf->esc_mode = 0;
|
||||
|
||||
have_early = 1;
|
||||
console_flush(&early, buf);
|
||||
}
|
||||
|
||||
void console_init_default(void) {
|
||||
// Initialize default display+keyboard pair
|
||||
struct console *con = kmalloc(sizeof(struct console));
|
||||
|
Loading…
x
Reference in New Issue
Block a user