[log] Fix logging, and log some init functions
This commit is contained in:
parent
748a8e8d28
commit
3b6512a6ae
@ -8,6 +8,7 @@
|
||||
* can be considered copyrightable in your jurisdiction.
|
||||
*/
|
||||
#include <system.h>
|
||||
#include <logging.h>
|
||||
|
||||
/**
|
||||
* Set the FPU control word
|
||||
@ -28,6 +29,7 @@ set_fpu_cw(const uint16_t cw) {
|
||||
*/
|
||||
void
|
||||
enable_fpu() {
|
||||
LOG(INFO, "Enabling floating-point arithmetic unit");
|
||||
size_t cr4;
|
||||
asm volatile ("mov %%cr4, %0" : "=r"(cr4));
|
||||
cr4 |= 0x200;
|
||||
|
@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
#include <system.h>
|
||||
#include <logging.h>
|
||||
|
||||
#define KEY_UP_MASK 0x80
|
||||
#define KEY_CODE_MASK 0x7F
|
||||
@ -253,6 +254,7 @@ keyboard_handler(
|
||||
|
||||
void
|
||||
keyboard_install() {
|
||||
LOG(INFO, "Initializing PS/2 keyboard driver");
|
||||
/* IRQ installer */
|
||||
keyboard_buffer_handler = NULL;
|
||||
keyboard_direct_handler = NULL;
|
||||
|
@ -9,16 +9,15 @@
|
||||
#include <process.h>
|
||||
#include <va_list.h>
|
||||
|
||||
static char buf[1024] = {-1};
|
||||
static int ptr = -1;
|
||||
|
||||
/*
|
||||
* Integer to string
|
||||
*/
|
||||
static void
|
||||
parse_num(
|
||||
unsigned int value,
|
||||
unsigned int base
|
||||
unsigned int base,
|
||||
char * buf,
|
||||
int * ptr
|
||||
) {
|
||||
unsigned int n = value / base;
|
||||
int r = value % base;
|
||||
@ -27,9 +26,10 @@ parse_num(
|
||||
--n;
|
||||
}
|
||||
if (value >= base) {
|
||||
parse_num(n, base);
|
||||
parse_num(n, base, buf, ptr);
|
||||
}
|
||||
buf[ptr++] = (r+'0');
|
||||
buf[*ptr] = (r+'0');
|
||||
*ptr = *ptr + 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -37,11 +37,14 @@ parse_num(
|
||||
*/
|
||||
static void
|
||||
parse_hex(
|
||||
unsigned int value
|
||||
unsigned int value,
|
||||
char * buf,
|
||||
int * ptr
|
||||
) {
|
||||
int i = 8;
|
||||
while (i-- > 0) {
|
||||
buf[ptr++] = "0123456789abcdef"[(value>>(i*4))&0xF];
|
||||
buf[*ptr] = "0123456789abcdef"[(value>>(i*4))&0xF];
|
||||
*ptr = *ptr + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,6 +60,8 @@ kprintf(
|
||||
const char *fmt,
|
||||
...
|
||||
) {
|
||||
char buf[1024] = {-1};
|
||||
int ptr = -1;
|
||||
int i = 0;
|
||||
char *s;
|
||||
va_list args;
|
||||
@ -79,10 +84,10 @@ kprintf(
|
||||
buf[ptr++] = (char)va_arg(args, int);
|
||||
break;
|
||||
case 'x': /* Hexadecimal number */
|
||||
parse_hex((unsigned long)va_arg(args, unsigned long));
|
||||
parse_hex((unsigned long)va_arg(args, unsigned long), buf, &ptr);
|
||||
break;
|
||||
case 'd': /* Decimal number */
|
||||
parse_num((unsigned long)va_arg(args, unsigned long), 10);
|
||||
parse_num((unsigned long)va_arg(args, unsigned long), 10, buf, &ptr);
|
||||
break;
|
||||
case '%': /* Escape */
|
||||
buf[ptr++] = '%';
|
||||
@ -114,7 +119,7 @@ sprintf(
|
||||
char *s;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
ptr = 0;
|
||||
int ptr = 0;
|
||||
for ( ; fmt[i]; ++i) {
|
||||
if (fmt[i] != '%') {
|
||||
buf[ptr++] = fmt[i];
|
||||
@ -132,10 +137,10 @@ sprintf(
|
||||
buf[ptr++] = (char)va_arg(args, int);
|
||||
break;
|
||||
case 'x': /* Hexadecimal number */
|
||||
parse_hex((unsigned long)va_arg(args, unsigned long));
|
||||
parse_hex((unsigned long)va_arg(args, unsigned long), buf, &ptr);
|
||||
break;
|
||||
case 'd': /* Decimal number */
|
||||
parse_num((unsigned long)va_arg(args, unsigned long), 10);
|
||||
parse_num((unsigned long)va_arg(args, unsigned long), 10, buf, &ptr);
|
||||
break;
|
||||
case '%': /* Escape */
|
||||
buf[ptr++] = '%';
|
||||
|
@ -22,6 +22,7 @@ static char * messages[] = {
|
||||
|
||||
void logging_install() {
|
||||
log_buffer = list_create();
|
||||
LOG(INFO, "Kernel log initialized");
|
||||
}
|
||||
|
||||
void debug_print_log_entry(log_entry_t * l) {
|
||||
|
@ -3,6 +3,7 @@
|
||||
* Serial Port Driver
|
||||
*/
|
||||
#include <system.h>
|
||||
#include <logging.h>
|
||||
|
||||
#define SERIAL_PORT_A 0x3F8
|
||||
#define SERIAL_PORT_B 0x2F8
|
||||
@ -34,6 +35,7 @@ serial_handler(
|
||||
|
||||
void
|
||||
serial_install() {
|
||||
LOG(INFO, "Installing serial communication driver");
|
||||
/* We will initialize the first serial port */
|
||||
outportb(SERIAL_PORT_A + 1, 0x00);
|
||||
outportb(SERIAL_PORT_A + 3, 0x80); /* Enable divisor mode */
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <system.h>
|
||||
#include <syscall.h>
|
||||
#include <process.h>
|
||||
#include <logging.h>
|
||||
|
||||
#define SPECIAL_CASE_STDIO
|
||||
|
||||
@ -234,6 +235,7 @@ uint32_t num_syscalls = 18;
|
||||
|
||||
void
|
||||
syscalls_install() {
|
||||
LOG(INFO, "Initializing syscall table with %d functions", num_syscalls);
|
||||
isrs_install_handler(0x7F, &syscall_handler);
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
#include <system.h>
|
||||
#include <process.h>
|
||||
#include <logging.h>
|
||||
|
||||
uint32_t next_pid = 0;
|
||||
|
||||
@ -90,6 +91,8 @@ void
|
||||
tasking_install() {
|
||||
IRQ_OFF; /* Disable interrupts */
|
||||
|
||||
LOG(NOTICE, "Initializing multitasking");
|
||||
|
||||
/* Initialize the process tree */
|
||||
initialize_process_tree();
|
||||
/* Spawn the initial process */
|
||||
|
@ -3,6 +3,7 @@
|
||||
* Programmable Interrupt Timer
|
||||
*/
|
||||
#include <system.h>
|
||||
#include <logging.h>
|
||||
|
||||
#define PIT_A 0x40
|
||||
#define PIT_B 0x41
|
||||
@ -48,6 +49,7 @@ timer_handler(
|
||||
* Device installer for the PIT
|
||||
*/
|
||||
void timer_install() {
|
||||
LOG(INFO,"Initializing interval timer");
|
||||
irq_install_handler(0, timer_handler);
|
||||
timer_phase(100); /* 100Hz */
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user