[misc] Boot logging to screen
This commit is contained in:
parent
3023d58a7f
commit
edebb12573
6
Makefile
6
Makefile
@ -252,10 +252,14 @@ clean: clean-soft clean-boot clean-core
|
||||
clean-hard: clean clean-bin clean-aux clean-docs
|
||||
@${INFO} "--" "Finished hard cleaning"
|
||||
|
||||
clean-disk:
|
||||
@${BEGRM} "RM" "Deleting hard disk image..."
|
||||
@-rm -f toaruos-disk.img
|
||||
@${ENDRM} "RM" "Deleted hard disk image"
|
||||
|
||||
clean-once:
|
||||
@${BEGRM} "RM" "Cleaning one-time files..."
|
||||
@-rm -f .passed
|
||||
@-rm -f toaruos-disk.img
|
||||
@${ENDRM} "RM" "Cleaned one-time files"
|
||||
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
* (C) 2011 Kevin Lange
|
||||
*/
|
||||
#include <system.h>
|
||||
#include <logging.h>
|
||||
|
||||
static void write_tss(int32_t, uint16_t, uint32_t);
|
||||
tss_entry_t tss_entry;
|
||||
@ -78,6 +79,7 @@ gdt_set_gate(
|
||||
*/
|
||||
void
|
||||
gdt_install() {
|
||||
blog("Setting up Global Descriptor Tables...");
|
||||
/* GDT pointer and limits */
|
||||
gp.limit = (sizeof(struct gdt_entry) * 6) - 1;
|
||||
gp.base = (unsigned int)&gdt;
|
||||
@ -95,6 +97,7 @@ gdt_install() {
|
||||
/* Go go go */
|
||||
gdt_flush();
|
||||
tss_flush();
|
||||
bfinish(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
#include <system.h>
|
||||
#include <logging.h>
|
||||
|
||||
/*
|
||||
* IDT Entry
|
||||
@ -53,9 +54,11 @@ idt_set_gate(
|
||||
*/
|
||||
void
|
||||
idt_install() {
|
||||
blog("Setting up Interrupt Descriptor Tables...");
|
||||
idtp.limit = (sizeof(struct idt_entry) * 256) - 1;
|
||||
idtp.base = (uintptr_t)&idt;
|
||||
memset(&idt, 0, sizeof(struct idt_entry) * 256);
|
||||
|
||||
idt_load();
|
||||
bfinish(0);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
#include <system.h>
|
||||
#include <logging.h>
|
||||
|
||||
extern void _irq0();
|
||||
extern void _irq1();
|
||||
@ -87,9 +88,11 @@ irq_gates() {
|
||||
*/
|
||||
void
|
||||
irq_install() {
|
||||
blog("Setting up and enabling hardware interrupts...");
|
||||
irq_remap();
|
||||
irq_gates();
|
||||
IRQ_ON;
|
||||
bfinish(0);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3,6 +3,7 @@
|
||||
* Interrupt Services Requests
|
||||
*/
|
||||
#include <system.h>
|
||||
#include <logging.h>
|
||||
|
||||
/*
|
||||
* Exception Handlers
|
||||
@ -61,6 +62,7 @@ isrs_uninstall_handler(
|
||||
|
||||
void
|
||||
isrs_install() {
|
||||
blog("Setting up Interrupt Service Routines...");
|
||||
/* Exception Handlers */
|
||||
idt_set_gate(0, (unsigned)_isr0, 0x08, 0x8E);
|
||||
idt_set_gate(1, (unsigned)_isr1, 0x08, 0x8E);
|
||||
@ -95,6 +97,7 @@ isrs_install() {
|
||||
idt_set_gate(30, (unsigned)_isr30, 0x08, 0x8E);
|
||||
idt_set_gate(31, (unsigned)_isr31, 0x08, 0x8E);
|
||||
idt_set_gate(SYSCALL_VECTOR, (unsigned)_isr127, 0x08, 0x8E);
|
||||
bfinish(0);
|
||||
}
|
||||
|
||||
char *exception_messages[] = {
|
||||
|
@ -29,11 +29,13 @@ set_fpu_cw(const uint16_t cw) {
|
||||
*/
|
||||
void
|
||||
enable_fpu() {
|
||||
blog("Enabling floating-point arithmetic unit...");
|
||||
LOG(INFO, "Enabling floating-point arithmetic unit");
|
||||
size_t cr4;
|
||||
asm volatile ("mov %%cr4, %0" : "=r"(cr4));
|
||||
cr4 |= 0x200;
|
||||
asm volatile ("mov %0, %%cr4" :: "r"(cr4));
|
||||
set_fpu_cw(0x37F);
|
||||
bfinish(0);
|
||||
}
|
||||
|
||||
|
@ -254,11 +254,13 @@ keyboard_handler(
|
||||
|
||||
void
|
||||
keyboard_install() {
|
||||
blog("Initializing PS/2 keyboard driver...");
|
||||
LOG(INFO, "Initializing PS/2 keyboard driver");
|
||||
/* IRQ installer */
|
||||
keyboard_buffer_handler = NULL;
|
||||
keyboard_direct_handler = NULL;
|
||||
irq_install_handler(1, keyboard_handler);
|
||||
bfinish(0);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -35,6 +35,7 @@ serial_handler(
|
||||
|
||||
void
|
||||
serial_install() {
|
||||
blog("Installing serial communication driver...");
|
||||
LOG(INFO, "Installing serial communication driver");
|
||||
/* We will initialize the first serial port */
|
||||
outportb(SERIAL_PORT_A + 1, 0x00);
|
||||
@ -46,6 +47,7 @@ serial_install() {
|
||||
outportb(SERIAL_PORT_A + 4, 0x0B);
|
||||
irq_install_handler(4, serial_handler); /* Install the serial input handler */
|
||||
outportb(SERIAL_PORT_A + 1, 0x01); /* Enable interrupts on receive */
|
||||
bfinish(0);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -49,9 +49,11 @@ timer_handler(
|
||||
* Device installer for the PIT
|
||||
*/
|
||||
void timer_install() {
|
||||
blog("Installing Programmable Interval Timer...");
|
||||
LOG(INFO,"Initializing interval timer");
|
||||
irq_install_handler(0, timer_handler);
|
||||
timer_phase(100); /* 100Hz */
|
||||
bfinish(0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
||||
*/
|
||||
#include <system.h>
|
||||
#include <ext2.h>
|
||||
#include <fs.h>
|
||||
@ -372,6 +374,7 @@ initrd_mount(
|
||||
uint32_t mem_head,
|
||||
uint32_t mem_top
|
||||
) {
|
||||
blog("Mounting EXT2 ramdisk...");
|
||||
initrd_start = (void *)mem_head;
|
||||
initrd_superblock = (ext2_superblock_t *)((uintptr_t)initrd_start + 1024);
|
||||
assert(initrd_superblock->magic == EXT2_SUPER_MAGIC);
|
||||
@ -389,4 +392,5 @@ initrd_mount(
|
||||
assert(initrd_node_root(root_inode, initrd_root));
|
||||
fs_root = initrd_root;
|
||||
LOG(INFO, "Mounted EXT2 ramdisk at 0x%x-0x%x, root VFS node is 0x%x", mem_head, mem_top, initrd_root);
|
||||
bfinish(0);
|
||||
}
|
||||
|
@ -23,4 +23,7 @@ void klog(log_type_t type, char *module, unsigned int line, const char *fmt, ...
|
||||
void debug_print_log();
|
||||
void logging_install();
|
||||
|
||||
void blog(char * string);
|
||||
void bfinish(int status);
|
||||
|
||||
#endif
|
||||
|
@ -35,6 +35,7 @@ extern void spin_unlock(uint8_t volatile * lock);
|
||||
|
||||
/* Kernel Main */
|
||||
extern int max(int,int);
|
||||
extern int min(int,int);
|
||||
extern int abs(int);
|
||||
extern void swap(int *, int *);
|
||||
extern void *memcpy(void *restrict dest, const void *restrict src, size_t count);
|
||||
|
@ -68,6 +68,7 @@ int main(struct multiboot *mboot, uint32_t mboot_mag, uintptr_t esp)
|
||||
initial_esp = esp;
|
||||
enum BOOTMODE boot_mode = unknown; /* Boot Mode */
|
||||
char * cmdline = NULL;
|
||||
uintptr_t ramdisk_top = 0;
|
||||
|
||||
/* Immediately initialize the video service so we can spew usable error messages */
|
||||
init_video();
|
||||
@ -76,6 +77,7 @@ int main(struct multiboot *mboot, uint32_t mboot_mag, uintptr_t esp)
|
||||
/*
|
||||
* Multiboot (GRUB, native QEMU, PXE)
|
||||
*/
|
||||
blog("Relocating Multiboot structures...");
|
||||
boot_mode = multiboot;
|
||||
mboot_ptr = mboot;
|
||||
|
||||
@ -93,9 +95,11 @@ int main(struct multiboot *mboot, uint32_t mboot_mag, uintptr_t esp)
|
||||
uint32_t module_start = *((uint32_t *) mboot_ptr->mods_addr); /* Start address */
|
||||
uint32_t module_end = *(uint32_t *) (mboot_ptr->mods_addr + 4); /* End address */
|
||||
ramdisk = (char *)kmalloc(module_end - module_start);
|
||||
ramdisk_top = (uintptr_t)ramdisk + (module_end - module_start);
|
||||
memmove(ramdisk, (char *)module_start, module_end - module_start); /* Copy it over. */
|
||||
}
|
||||
}
|
||||
bfinish(0);
|
||||
} else {
|
||||
/*
|
||||
* This isn't a multiboot attempt. We were probably loaded by
|
||||
@ -127,7 +131,7 @@ int main(struct multiboot *mboot, uint32_t mboot_mag, uintptr_t esp)
|
||||
syscalls_install(); /* Install the system calls */
|
||||
|
||||
if (ramdisk) {
|
||||
initrd_mount((uintptr_t)ramdisk, 0);
|
||||
initrd_mount((uintptr_t)ramdisk, ramdisk_top);
|
||||
}
|
||||
|
||||
mouse_install(); /* Mouse driver */
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include <system.h>
|
||||
#include <process.h>
|
||||
#include <logging.h>
|
||||
|
||||
extern uintptr_t end;
|
||||
uintptr_t placement_pointer = (uintptr_t)&end;
|
||||
@ -218,6 +219,7 @@ memory_total(){
|
||||
|
||||
void
|
||||
paging_install(uint32_t memsize) {
|
||||
blog("Setting up memory paging...");
|
||||
nframes = memsize / 4;
|
||||
frames = (uint32_t *)kmalloc(INDEX_FROM_BIT(nframes));
|
||||
memset(frames, 0, INDEX_FROM_BIT(nframes));
|
||||
@ -242,6 +244,7 @@ paging_install(uint32_t memsize) {
|
||||
|
||||
current_directory = clone_directory(kernel_directory);
|
||||
switch_page_directory(kernel_directory);
|
||||
bfinish(0);
|
||||
}
|
||||
|
||||
void
|
||||
@ -324,7 +327,9 @@ page_fault(
|
||||
|
||||
void
|
||||
heap_install() {
|
||||
blog("Initializing block allocator...");
|
||||
heap_end = (placement_pointer + 0x1000) & ~0xFFF;
|
||||
bfinish(0);
|
||||
}
|
||||
|
||||
void *
|
||||
|
@ -22,8 +22,10 @@ static char * messages[] = {
|
||||
};
|
||||
|
||||
void logging_install() {
|
||||
blog("Installing stored logging...");
|
||||
log_buffer = list_create();
|
||||
LOG(INFO, "Kernel log initialized");
|
||||
bfinish(0);
|
||||
}
|
||||
|
||||
void debug_print_log_entry(log_entry_t * l) {
|
||||
@ -62,3 +64,24 @@ void klog(log_type_t type, char *module, unsigned int line, const char *fmt, ...
|
||||
va_end(args);
|
||||
list_insert(log_buffer, l);
|
||||
}
|
||||
|
||||
/*
|
||||
* Messsage... <--- ---> [ OK ]
|
||||
*/
|
||||
|
||||
static char * boot_messages[] = {
|
||||
"\033[1;32m OK ",
|
||||
"\033[1;33m WARN ",
|
||||
"\033[1;31mERROR!"
|
||||
};
|
||||
|
||||
char * last_message = NULL;
|
||||
|
||||
void blog(char * string) {
|
||||
last_message = string;
|
||||
kprintf("\033[0m%s\033[1000C\033[8D[ \033[1;34m....\033[0m ]", string);
|
||||
}
|
||||
void bfinish(int status) {
|
||||
if (!last_message) { return; }
|
||||
kprintf("\033[1000D\033[0m%s\033[1000C\033[8D[%s\033[0m]\n", last_message, boot_messages[status]);
|
||||
}
|
||||
|
@ -256,8 +256,10 @@ uint32_t num_syscalls = 21;
|
||||
|
||||
void
|
||||
syscalls_install() {
|
||||
blog("Initializing syscall table...");
|
||||
LOG(INFO, "Initializing syscall table with %d functions", num_syscalls);
|
||||
isrs_install_handler(0x7F, &syscall_handler);
|
||||
bfinish(0);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -40,6 +40,11 @@ max(int a, int b) {
|
||||
return (a > b) ? a : b;
|
||||
}
|
||||
|
||||
int
|
||||
min(int a, int b) {
|
||||
return (a > b) ? b : a;
|
||||
}
|
||||
|
||||
int
|
||||
abs(int a) {
|
||||
return (a >= 0) ? a : -a;
|
||||
|
@ -116,6 +116,7 @@ clone_table(
|
||||
*/
|
||||
void
|
||||
tasking_install() {
|
||||
blog("Initializing multitasking...");
|
||||
IRQ_OFF; /* Disable interrupts */
|
||||
|
||||
LOG(NOTICE, "Initializing multitasking");
|
||||
@ -131,6 +132,7 @@ tasking_install() {
|
||||
|
||||
/* Reenable interrupts */
|
||||
IRQ_ON;
|
||||
bfinish(0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -56,7 +56,7 @@ static struct _ansi_state {
|
||||
uint8_t flags ; /* Bright, etc. */
|
||||
uint8_t escape; /* Escape status */
|
||||
uint8_t buflen; /* Buffer Length */
|
||||
char * buffer; /* Previous buffer */
|
||||
char buffer[100]; /* Previous buffer */
|
||||
} state;
|
||||
|
||||
void (*ansi_writer)(char) = NULL;
|
||||
@ -98,7 +98,6 @@ ansi_put(
|
||||
* fill the buffer, get out of here.
|
||||
*/
|
||||
state.escape = 1;
|
||||
state.buffer = malloc(sizeof(char) * 100);
|
||||
state.buflen = 0;
|
||||
ansi_buf_add(c);
|
||||
return;
|
||||
@ -117,8 +116,6 @@ ansi_put(
|
||||
ansi_dump_buffer();
|
||||
ansi_writer(c);
|
||||
state.escape = 0;
|
||||
free(state.buffer);
|
||||
state.buffer = NULL;
|
||||
state.buflen = 0;
|
||||
return;
|
||||
}
|
||||
@ -222,7 +219,7 @@ ansi_put(
|
||||
if (argc) {
|
||||
i = atoi(argv[0]);
|
||||
}
|
||||
ansi_set_csr(ansi_get_csr_x() + i, ansi_get_csr_y());
|
||||
ansi_set_csr(min(ansi_get_csr_x() + i, state.width - 1), ansi_get_csr_y());
|
||||
}
|
||||
break;
|
||||
case ANSI_CUU:
|
||||
@ -231,7 +228,7 @@ ansi_put(
|
||||
if (argc) {
|
||||
i = atoi(argv[0]);
|
||||
}
|
||||
ansi_set_csr(ansi_get_csr_x(), ansi_get_csr_y() - i);
|
||||
ansi_set_csr(ansi_get_csr_x(), max(ansi_get_csr_y() - i, 0));
|
||||
}
|
||||
break;
|
||||
case ANSI_CUD:
|
||||
@ -240,7 +237,7 @@ ansi_put(
|
||||
if (argc) {
|
||||
i = atoi(argv[0]);
|
||||
}
|
||||
ansi_set_csr(ansi_get_csr_x(), ansi_get_csr_y() + i);
|
||||
ansi_set_csr(ansi_get_csr_x(), min(ansi_get_csr_y() + i, state.height - 1));
|
||||
}
|
||||
break;
|
||||
case ANSI_CUB:
|
||||
@ -249,7 +246,7 @@ ansi_put(
|
||||
if (argc) {
|
||||
i = atoi(argv[0]);
|
||||
}
|
||||
ansi_set_csr(ansi_get_csr_x() - i, ansi_get_csr_y());
|
||||
ansi_set_csr(max(ansi_get_csr_x() - i,0), ansi_get_csr_y());
|
||||
}
|
||||
break;
|
||||
case ANSI_CUP:
|
||||
@ -312,8 +309,6 @@ ansi_put(
|
||||
ansi_set_color(state.fg, state.bg);
|
||||
}
|
||||
/* Clear out the buffer */
|
||||
free(state.buffer);
|
||||
state.buffer = NULL;
|
||||
state.buflen = 0;
|
||||
state.escape = 0;
|
||||
return;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <fs.h>
|
||||
#include <types.h>
|
||||
#include <vesa.h>
|
||||
#include <logging.h>
|
||||
|
||||
#define PROMPT_FOR_MODE 0
|
||||
|
||||
@ -101,9 +102,10 @@ bochs_screenshot(char * filename) {
|
||||
|
||||
void
|
||||
bochs_install_wallpaper(char * filename) {
|
||||
kprintf("Starting up...\n");
|
||||
blog("Loading wallpaper...");
|
||||
fs_node_t * image = kopen(filename, 0);
|
||||
if (!image) {
|
||||
bfinish(2);
|
||||
kprintf("[NOTICE] Failed to load wallpaper `%s`.\n", filename);
|
||||
return;
|
||||
}
|
||||
@ -153,6 +155,7 @@ bochs_install_wallpaper(char * filename) {
|
||||
}
|
||||
|
||||
free(bufferb);
|
||||
bfinish(0);
|
||||
}
|
||||
|
||||
static void finalize_graphics(uint16_t x, uint16_t y, uint16_t b) {
|
||||
@ -170,6 +173,7 @@ static void finalize_graphics(uint16_t x, uint16_t y, uint16_t b) {
|
||||
|
||||
void
|
||||
graphics_install_bochs(uint16_t resolution_x, uint16_t resolution_y) {
|
||||
blog("Setting up BOCHS/QEMU graphics controller...");
|
||||
outports(0x1CE, 0x00);
|
||||
uint16_t i = inports(0x1CF);
|
||||
if (i < 0xB0C0 || i > 0xB0C6) {
|
||||
@ -224,12 +228,15 @@ graphics_install_bochs(uint16_t resolution_x, uint16_t resolution_y) {
|
||||
|
||||
mem_found:
|
||||
finalize_graphics(resolution_x, resolution_y, PREFERRED_B);
|
||||
bfinish(0);
|
||||
}
|
||||
|
||||
#include "../v8086/rme.h"
|
||||
|
||||
void
|
||||
graphics_install_vesa(uint16_t x, uint16_t y) {
|
||||
blog("Setting up VESA video controller...");
|
||||
|
||||
/* VESA Structs */
|
||||
struct VesaControllerInfo *info = (void*)0x10000;
|
||||
struct VesaModeInfo *modeinfo = (void*)0x9000;
|
||||
@ -254,6 +261,7 @@ graphics_install_vesa(uint16_t x, uint16_t y) {
|
||||
emu->DI.W = 0;
|
||||
ret = RME_CallInt(emu, 0x10);
|
||||
if (info->Version < 0x200 || info->Version > 0x300) {
|
||||
bfinish(2);
|
||||
kprintf("\033[JYou have attempted to use the VESA/VBE2 driver\nwith a card that does not support VBE2.\n");
|
||||
kprintf("\nSystem responded to VBE request with version: 0x%x\n", info->Version);
|
||||
|
||||
@ -344,6 +352,7 @@ graphics_install_vesa(uint16_t x, uint16_t y) {
|
||||
dma_frame(get_page(i, 1, kernel_directory), 0, 1, i);
|
||||
}
|
||||
|
||||
|
||||
/* Go find it */
|
||||
for (uintptr_t x = 0xE0000000; x < 0xE0FF0000; x += 0x1000) {
|
||||
if (((uintptr_t *)x)[0] == 0xA5ADFACE) {
|
||||
@ -364,6 +373,7 @@ mem_found:
|
||||
* Finalize the graphics setup with the actual selected resolution.
|
||||
*/
|
||||
finalize_graphics(actual_x, actual_y, actual_b);
|
||||
bfinish(0);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -6,6 +6,7 @@
|
||||
*
|
||||
*/
|
||||
#include <system.h>
|
||||
#include <logging.h>
|
||||
|
||||
/*
|
||||
* Text pointer, background, foreground
|
||||
@ -275,4 +276,6 @@ void init_video() {
|
||||
move_csr();
|
||||
|
||||
ansi_init(&writech, 80, 25, &vga_set_color, &vga_set_csr, &vga_get_csr_x, &vga_get_csr_y, &vga_set_cell, &cls, &redraw_csr);
|
||||
blog("Initializing video services...");
|
||||
bfinish(0);
|
||||
}
|
||||
|
@ -8,14 +8,24 @@
|
||||
DEFN_SYSCALL1(wait, 17, unsigned int);
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
int quiet = 0;
|
||||
if (argc > 1) {
|
||||
if (!strcmp(argv[1],"-q")) {
|
||||
printf("I'll be quiet...\n");
|
||||
quiet = 1;
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < 1024; ++j) {
|
||||
volatile int k = fork();
|
||||
printf("I am %d, I got %d\n", getpid(), k);
|
||||
if (!quiet)
|
||||
printf("I am %d, I got %d\n", getpid(), k);
|
||||
if (k == 0) {
|
||||
printf("I am %d\n", getpid());
|
||||
if (!quiet || !(j % 10))
|
||||
printf("I am %d\n", getpid());
|
||||
return 0;
|
||||
} else {
|
||||
printf("Waiting on %d\n", k);
|
||||
if (!quiet)
|
||||
printf("Waiting on %d\n", k);
|
||||
syscall_wait(k);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user