feature (kernel): added format strings to log function
This commit is contained in:
parent
74d3e98772
commit
858bcfaebb
|
@ -30,6 +30,6 @@ typedef enum {
|
||||||
} log_level_E;
|
} log_level_E;
|
||||||
|
|
||||||
// logs a string to qemu's serial port
|
// logs a string to qemu's serial port
|
||||||
void log(log_level_E log_level, string_t string);
|
void log(log_level_E log_level, string_t string, ...);
|
||||||
|
|
||||||
#endif //NOX_LOGGER_H
|
#endif //NOX_LOGGER_H
|
||||||
|
|
|
@ -41,17 +41,5 @@ void kmain(boot_info_T boot_info) {
|
||||||
|
|
||||||
kernel_init(&boot_info);
|
kernel_init(&boot_info);
|
||||||
|
|
||||||
uint64_t size = format_size("Test: %d", 1312);
|
|
||||||
|
|
||||||
char string[size];
|
|
||||||
format(string, "Test: %d", 1312);
|
|
||||||
|
|
||||||
char buf[16];
|
|
||||||
format(buf, "size: %d", size);
|
|
||||||
|
|
||||||
log(LOG_DEBUG, string);
|
|
||||||
log(LOG_DEBUG, buf);
|
|
||||||
|
|
||||||
|
|
||||||
CORE_HALT_FOREVER
|
CORE_HALT_FOREVER
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
uint64_t memory_map_get_total_memory_size(boot_info_T* boot_info) {
|
uint64_t memory_map_get_total_memory_size(boot_info_T* boot_info) {
|
||||||
static uint64_t size = 0;
|
static uint64_t size = 0;
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
log(LOG_INFO, "Memory size is already calculated, returning known value");
|
log(LOG_INFO, "Memory size is already calculated: %d", size);
|
||||||
return size;
|
return size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ void pframe_manager_init(boot_info_T* boot_info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t total_memory = memory_map_get_total_memory_size(boot_info);
|
uint64_t total_memory = memory_map_get_total_memory_size(boot_info);
|
||||||
log(LOG_INFO, " * Total Memory size: 'size'"); // TODO: replace with format string
|
log(LOG_INFO, " * Total Memory size: %d B", total_memory); // TODO: replace with format string
|
||||||
|
|
||||||
g_page_frame_manager.page_bitmap = bitmap_init_from_buffer((void*)largest_usable_entry->base, total_memory / PFRAME_SIZE / 8 + 1);
|
g_page_frame_manager.page_bitmap = bitmap_init_from_buffer((void*)largest_usable_entry->base, total_memory / PFRAME_SIZE / 8 + 1);
|
||||||
g_page_frame_manager.page_bitmap_index = 0;
|
g_page_frame_manager.page_bitmap_index = 0;
|
||||||
|
|
|
@ -124,7 +124,7 @@ cpu_state_T* interrupts_handle(cpu_state_T* state) {
|
||||||
return exception_handle(state);
|
return exception_handle(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
log(LOG_WARNING, "Non exception interrupt detected");
|
log(LOG_WARNING, "Non exception interrupt detected ID: 0x%xb", state->interrupt_id);
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,19 @@ void log_send_string_to_port(string_t str) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(log_level_E log_level, string_t str) {
|
void log(log_level_E log_level, string_t str, ...) {
|
||||||
|
va_list args;
|
||||||
|
va_start(args, str);
|
||||||
|
|
||||||
|
uint64_t size = variadic_format_size(str, args);
|
||||||
|
char formatted_string[size];
|
||||||
|
|
||||||
|
va_start(args, str);
|
||||||
|
variadic_format(formatted_string, str, args);
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
log_send_string_to_port(log_prefixes[log_level]);
|
log_send_string_to_port(log_prefixes[log_level]);
|
||||||
log_send_string_to_port(str);
|
log_send_string_to_port(formatted_string);
|
||||||
log_send_string_to_port("\n");
|
log_send_string_to_port("\n");
|
||||||
}
|
}
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
void panic(cpu_state_T* state, string_t message) {
|
void panic(cpu_state_T* state, string_t message) {
|
||||||
log(LOG_ERROR, "!=====[ KERNEL PANIC ]=====!");
|
log(LOG_ERROR, "!=====[ KERNEL PANIC ]=====!");
|
||||||
log(LOG_ERROR, message);
|
log(LOG_ERROR, "Error Message:", message);
|
||||||
|
|
||||||
CORE_HALT_FOREVER
|
CORE_HALT_FOREVER
|
||||||
}
|
}
|
Loading…
Reference in New Issue