[fb] Output klog to fb if video exists

If there's no video, do as we did before, otherwise route logs to the fb
driver instead. (Need to clean this up to just have a log consumer
general interface?) Also added a "scrollback" class to fb driver and
updated the system_get_log syscall.
This commit is contained in:
Justin C. Miller
2021-01-03 18:13:41 -08:00
parent dccb136c99
commit e477dea5c7
12 changed files with 181 additions and 29 deletions

View File

@@ -10,7 +10,7 @@ static uint8_t log_buffer[0x10000];
// so that we can start log output immediately. Keep its constructor
// from being called here so as to not overwrite the previous initialization.
static kutil::no_construct<log::logger> __g_logger_storage;
static log::logger &g_logger = __g_logger_storage.value;
log::logger &g_logger = __g_logger_storage.value;
static const uint8_t level_colors[] = {0x07, 0x07, 0x0f, 0x0b, 0x09};
@@ -57,3 +57,8 @@ void logger_init()
{
new (&g_logger) log::logger(log_buffer, sizeof(log_buffer), output_log);
}
void logger_clear_immediate()
{
g_logger.set_immediate(nullptr);
}

View File

@@ -6,4 +6,5 @@ namespace log = kutil::log;
namespace logs = kutil::logs;
void logger_init();
void logger_clear_immediate();
void logger_task();

View File

@@ -64,7 +64,6 @@ init_console()
cons->puts("jsix OS ");
cons->set_color(0x08, 0x00);
cons->puts(GIT_VERSION " booting...\n");
logger_init();
}
channel *std_out = nullptr;
@@ -112,6 +111,7 @@ kernel_main(args::header *header)
{
kutil::assert_set_callback(__kernel_assert);
init_console();
logger_init();
gdt_init();
interrupts_init();
@@ -135,8 +135,11 @@ kernel_main(args::header *header)
}
}
bool has_video = false;
if (header->video.size > 0) {
fb = memory::to_virtual<args::framebuffer>(reinterpret_cast<uintptr_t>(&header->video));
has_video = true;
logger_clear_immediate();
}
log::debug(logs::boot, " jsix header is at: %016lx", header);
@@ -186,11 +189,12 @@ kernel_main(args::header *header)
args::program &prog = header->programs[i];
thread *th = sched->load_process(prog.phys_addr, prog.virt_addr, prog.size, prog.entrypoint);
if (i == 2) {
th->set_state(thread::state::constant);
//th->set_state(thread::state::constant);
}
}
sched->create_kernel_task(logger_task, scheduler::max_priority-1, true);
if (!has_video)
sched->create_kernel_task(logger_task, scheduler::max_priority-1, true);
sched->create_kernel_task(stdout_task, scheduler::max_priority-1, true);
const char stdout_message[] = "Hello on the fake stdout channel\n";

View File

@@ -19,13 +19,15 @@
#include "objects/vm_area.h"
#include "scheduler.h"
// here for the framebuffer hack
#include "kernel_args.h"
#include "kutil/assert.h"
scheduler *scheduler::s_instance = nullptr;
extern uintptr_t fb_loc;
extern size_t fb_size;
extern kernel::args::framebuffer *fb;
const uint64_t rflags_noint = 0x002;
const uint64_t rflags_int = 0x202;
@@ -98,8 +100,15 @@ load_process_image(uintptr_t phys, uintptr_t virt, size_t bytes, TCB *tcb)
kutil::memcpy(message_arg, message, sizeof(message));
j6_init_framebuffer *fb_desc = push<j6_init_framebuffer>(tcb->rsp3);
fb_desc->addr = reinterpret_cast<void*>(0x100000000);
fb_desc->size = fb_size;
fb_desc->addr = fb ? reinterpret_cast<void*>(0x100000000) : nullptr;
fb_desc->size = fb ? fb->size : 0;
fb_desc->vertical = fb ? fb->vertical : 0;
fb_desc->horizontal = fb ? fb->horizontal : 0;
fb_desc->scanline = fb ? fb->scanline : 0;
fb_desc->flags = 0;
if (fb && fb->type == kernel::args::fb_type::bgr8)
fb_desc->flags |= 1;
j6_init_value *initv = push<j6_init_value>(tcb->rsp3);
initv->type = j6_init_handle_system;
@@ -131,9 +140,11 @@ load_process_image(uintptr_t phys, uintptr_t virt, size_t bytes, TCB *tcb)
*argc = 1;
// Crazypants framebuffer part
vma = new vm_area_open(fb_size, space, vm_flags::write|vm_flags::mmio);
space.add(0x100000000, vma);
vma->commit(fb_loc, 0, memory::page_count(fb_size));
if (fb) {
vma = new vm_area_open(fb->size, space, vm_flags::write|vm_flags::mmio);
space.add(0x100000000, vma);
vma->commit(fb->phys_addr, 0, memory::page_count(fb->size));
}
th.clear_state(thread::state::loading);
return tcb->rsp3;

View File

@@ -7,6 +7,8 @@
#include "objects/thread.h"
#include "syscalls/helpers.h"
extern log::logger &g_logger;
namespace syscalls {
j6_status_t
@@ -29,9 +31,10 @@ system_noop()
}
j6_status_t
system_get_log(j6_handle_t sys, j6_handle_t *log)
system_get_log(j6_handle_t sys, char *buffer, size_t *size)
{
return j6_err_nyi;
*size = g_logger.get_entry(buffer, *size);
return j6_status_ok;
}
j6_status_t