Use new drivers

This commit is contained in:
Alex Kotov 2022-12-03 22:48:32 +04:00
parent 42c7bbbbcf
commit ec3e68b9b4
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
6 changed files with 23 additions and 23 deletions

View File

@ -3,7 +3,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <kernaux/drivers/shutdown.h> #include <drivers/shutdown.h>
#include <kernaux/generic/malloc.h> #include <kernaux/generic/malloc.h>
#include <kernaux/free_list.h> #include <kernaux/free_list.h>
#include <kernaux/libc.h> #include <kernaux/libc.h>
@ -43,7 +43,7 @@ void my_abort()
void my_exit(const int status) void my_exit(const int status)
{ {
logger_exit(status); logger_exit(status);
kernaux_drivers_shutdown_poweroff(); drivers_shutdown_poweroff();
// TODO: libkernaux shutdown poweroff noreturn // TODO: libkernaux shutdown poweroff noreturn
volatile int x = 0; volatile int x = 0;

View File

@ -1,16 +1,16 @@
#include "logger.h" #include "logger.h"
#include <kernaux/drivers/console.h> #include <drivers/console.h>
void logger_assert( void logger_assert(
const char *const file, const char *const file,
const int line, const int line,
const char *const str const char *const str
) { ) {
kernaux_drivers_console_printf("panic: %s:%u: \"%s\"\n", file, line, str); drivers_console_printf("panic: %s:%u: \"%s\"\n", file, line, str);
} }
void logger_exit(const int status) void logger_exit(const int status)
{ {
kernaux_drivers_console_printf("exit: %d\n", status); drivers_console_printf("exit: %d\n", status);
} }

View File

@ -7,9 +7,10 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <kernaux/drivers/console.h>
#include <kernaux/multiboot2.h> #include <kernaux/multiboot2.h>
#include <drivers/console.h>
#include <mruby.h> #include <mruby.h>
#include <mruby/compile.h> #include <mruby/compile.h>
#include <mruby/proc.h> #include <mruby/proc.h>
@ -93,6 +94,6 @@ mrb_value ruby_console_puts(
) { ) {
const char *str = NULL; const char *str = NULL;
mrb_get_args(mrb, "z", &str); mrb_get_args(mrb, "z", &str);
kernaux_drivers_console_puts(str); drivers_console_puts(str);
return mrb_nil_value(); return mrb_nil_value();
} }

View File

@ -1,8 +1,8 @@
#include "logger.h" #include "logger.h"
#include "panic.h" #include "panic.h"
#include <drivers/shutdown.h>
#include <kernaux/assert.h> #include <kernaux/assert.h>
#include <kernaux/drivers/shutdown.h>
void panic_init() void panic_init()
{ {
@ -12,5 +12,5 @@ void panic_init()
void assert(const char *const file, const int line, const char *const str) void assert(const char *const file, const int line, const char *const str)
{ {
logger_assert(file, line, str); logger_assert(file, line, str);
kernaux_drivers_shutdown_poweroff(); drivers_shutdown_poweroff();
} }

View File

@ -2,7 +2,7 @@
#include <string.h> #include <string.h>
#include <kernaux/drivers/console.h> #include <drivers/console.h>
#include <kernaux/multiboot2.h> #include <kernaux/multiboot2.h>
#include <kernaux/macro/packing_start.run> #include <kernaux/macro/packing_start.run>
@ -34,7 +34,7 @@ void stack_trace_init(
); );
if (!elf_symbols_tag) { if (!elf_symbols_tag) {
kernaux_drivers_console_puts("ELF symbols tag not found"); drivers_console_puts("ELF symbols tag not found");
return; return;
} }
@ -44,13 +44,13 @@ void stack_trace_init(
// (const struct SectionEntry*)KERNAUX_MULTIBOOT2_DATA(elf_symbols_tag); // (const struct SectionEntry*)KERNAUX_MULTIBOOT2_DATA(elf_symbols_tag);
(const struct SectionEntry*)(&((uint8_t*)elf_symbols_tag)[20]); (const struct SectionEntry*)(&((uint8_t*)elf_symbols_tag)[20]);
kernaux_drivers_console_puts("ELF symbols tag:"); drivers_console_puts("ELF symbols tag:");
KernAux_Multiboot2_ITag_ELFSymbols_print( KernAux_Multiboot2_ITag_ELFSymbols_print(
elf_symbols_tag, elf_symbols_tag,
kernaux_drivers_console_printf drivers_console_printf
); );
kernaux_drivers_console_printf(" data: 0x%p\n", (void*)section_headers); drivers_console_printf(" data: 0x%p\n", (void*)section_headers);
kernaux_drivers_console_putc('\n'); drivers_console_putc('\n');
const struct SectionEntry *const shstrtab = const struct SectionEntry *const shstrtab =
// FIXME: GRUB 2 doesn't conform the spec! // FIXME: GRUB 2 doesn't conform the spec!
@ -71,8 +71,7 @@ void stack_trace_init(
const char *const section_name = const char *const section_name =
&((const char*)shstrtab->vaddr)[section_header->name]; &((const char*)shstrtab->vaddr)[section_header->name];
kernaux_drivers_console_printf("section %lu: %s\n", drivers_console_printf("section %lu: %s\n", index, section_name);
index, section_name);
if (strcmp(section_name, ".debug_info") == 0) { if (strcmp(section_name, ".debug_info") == 0) {
debug_info_index = index; debug_info_index = index;
@ -83,12 +82,12 @@ void stack_trace_init(
} }
} }
kernaux_drivers_console_putc('\n'); drivers_console_putc('\n');
kernaux_drivers_console_printf(".debug_info: %lu\n", debug_info_index); drivers_console_printf(".debug_info: %lu\n", debug_info_index);
kernaux_drivers_console_printf(".debug_abbrev: %lu\n", debug_abbrev_index); drivers_console_printf(".debug_abbrev: %lu\n", debug_abbrev_index);
kernaux_drivers_console_printf(".debug_str: %lu\n", debug_str_index); drivers_console_printf(".debug_str: %lu\n", debug_str_index);
kernaux_drivers_console_putc('\n'); drivers_console_putc('\n');
if (!debug_info_index || !debug_abbrev_index || !debug_str_index) return; if (!debug_info_index || !debug_abbrev_index || !debug_str_index) return;
/* /*

View File

@ -22,6 +22,6 @@ _start:
push %ebx // Multiboot information pointer push %ebx // Multiboot information pointer
push %eax // Multiboot magic number push %eax // Multiboot magic number
call main call main
call kernaux_drivers_shutdown_poweroff call drivers_shutdown_poweroff
.size _start, . - _start .size _start, . - _start