1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2024-10-30 11:54:01 -04:00
libkernaux/examples/bootloader-multiboot2-limine/main.c

51 lines
1.3 KiB
C
Raw Normal View History

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(
2022-01-15 06:17:06 -05:00
const uint32_t multiboot2_info_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);
2022-01-15 06:17:06 -05:00
if (multiboot2_info_magic != KERNAUX_MULTIBOOT2_INFO_MAGIC) {
panic("Multiboot 2 info magic number is invalid");
2022-01-09 21:24:49 -05:00
} else {
2022-01-15 06:17:06 -05:00
kernaux_console_printf("Multiboot 2 info 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
}