2022-01-08 22:30:36 -05:00
|
|
|
#include <stdarg.h>
|
2022-01-08 22:06:03 -05:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include <kernaux/asm/i386.h>
|
2022-01-09 23:45:02 -05:00
|
|
|
#include <kernaux/console.h>
|
2022-01-08 22:06:03 -05:00
|
|
|
#include <kernaux/multiboot2.h>
|
|
|
|
|
2022-01-12 04:40:35 -05:00
|
|
|
void poweroff();
|
2022-01-08 22:06:03 -05:00
|
|
|
|
2022-01-14 00:40:51 -05:00
|
|
|
extern const struct KernAux_Multiboot2_Header multiboot2_header;
|
|
|
|
|
2022-01-08 22:06:03 -05:00
|
|
|
static void panic(const char *str);
|
|
|
|
|
|
|
|
void main(
|
|
|
|
const uint32_t multiboot2_magic,
|
2022-01-12 23:11:27 -05:00
|
|
|
const struct KernAux_Multiboot2_Info *const multiboot2_info
|
2022-01-08 22:06:03 -05:00
|
|
|
) {
|
2022-01-14 00:40:51 -05:00
|
|
|
if (!KernAux_Multiboot2_Header_is_valid(&multiboot2_header)) {
|
|
|
|
panic("Multiboot 2 header is invalid");
|
|
|
|
} else {
|
|
|
|
kernaux_console_printf("Multiboot 2 header is valid\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
KernAux_Multiboot2_Header_print(&multiboot2_header, kernaux_console_printf);
|
|
|
|
|
|
|
|
if (multiboot2_magic != KERNAUX_MULTIBOOT2_INFO_MAGIC) {
|
2022-01-08 22:06:03 -05:00
|
|
|
panic("Multiboot 2 magic number is invalid");
|
2022-01-09 21:24:49 -05:00
|
|
|
} else {
|
|
|
|
kernaux_console_printf("Multiboot 2 magic number is valid\n");
|
2022-01-08 22:06:03 -05:00
|
|
|
}
|
|
|
|
|
2022-01-12 23:11:27 -05:00
|
|
|
if (!KernAux_Multiboot2_Info_is_valid(multiboot2_info)) {
|
2022-01-08 22:06:03 -05:00
|
|
|
panic("Multiboot 2 info is invalid");
|
2022-01-09 21:24:49 -05:00
|
|
|
} else {
|
|
|
|
kernaux_console_printf("Multiboot 2 info is valid\n");
|
2022-01-08 22:06:03 -05:00
|
|
|
}
|
2022-01-08 22:40:55 -05:00
|
|
|
|
2022-01-12 23:11:27 -05:00
|
|
|
KernAux_Multiboot2_Info_print(multiboot2_info, kernaux_console_printf);
|
2022-01-08 22:06:03 -05:00
|
|
|
}
|
|
|
|
|
2022-01-12 04:40:35 -05:00
|
|
|
void poweroff()
|
2022-01-08 22:06:03 -05:00
|
|
|
{
|
2022-01-12 04:40:35 -05:00
|
|
|
kernaux_asm_i386_outportw(0x604, 0x2000);
|
2022-01-08 22:06:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void panic(const char *const str)
|
|
|
|
{
|
2022-01-09 20:30:40 -05:00
|
|
|
kernaux_console_printf("panic: %s\n", str);
|
2022-01-15 05:42:13 -05:00
|
|
|
poweroff();
|
2022-01-08 22:06:03 -05:00
|
|
|
}
|