From c9b3f899133a4c45bc23ed2b118f656d34d94724 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Fri, 23 Dec 2022 15:46:30 +0400 Subject: [PATCH] Use new Multiboot 2 header builder from libkernaux --- src/Makefile | 1 + src/linker.ld | 2 +- src/multiboot2.c | 36 ++++++++++++++++++++++++++++++++++++ src/start.s | 18 ------------------ 4 files changed, 38 insertions(+), 19 deletions(-) create mode 100644 src/multiboot2.c diff --git a/src/Makefile b/src/Makefile index 5287f2d..791fc22 100644 --- a/src/Makefile +++ b/src/Makefile @@ -33,6 +33,7 @@ OBJS += paging.c.o # Architecture-independent OBJS += info.c.o +OBJS += multiboot2.c.o OBJS += protected.c.o OBJS += interrupts.c.o interrupts.asm.cpp.o OBJS += heap.c.o diff --git a/src/linker.ld b/src/linker.ld index 699fefd..2cedcf0 100644 --- a/src/linker.ld +++ b/src/linker.ld @@ -14,7 +14,7 @@ SECTIONS .text BLOCK(4K) : ALIGN(4K) { - *(.multiboot) + *(.multiboot2) *(.text) } diff --git a/src/multiboot2.c b/src/multiboot2.c new file mode 100644 index 0000000..a06952e --- /dev/null +++ b/src/multiboot2.c @@ -0,0 +1,36 @@ +#include + +#include + +__attribute__(( + section(".multiboot2"), + aligned(KERNAUX_MULTIBOOT2_HEADER_ALIGN), + used +)) +const struct { + struct KernAux_Multiboot2_Header header; + KERNAUX_MULTIBOOT2_HFIELDS_COMMON(tag_none, None) +} +KERNAUX_PACKED +multiboot2_header = { + .header = { + .magic = KERNAUX_MULTIBOOT2_HEADER_MAGIC, + .arch = KERNAUX_MULTIBOOT2_HEADER_ARCH_I386, + .total_size = sizeof(multiboot2_header), + .checksum = KERNAUX_MULTIBOOT2_HEADER_CHECKSUM( + KERNAUX_MULTIBOOT2_HEADER_ARCH_I386, + sizeof(multiboot2_header) + ), + }, + .tag_none = { + .tag = { + .base = { + .type = KERNAUX_MULTIBOOT2_HTAG_NONE, + .flags = 0, + .size = sizeof(multiboot2_header.tag_none), + }, + }, + }, +}; + +#include diff --git a/src/start.s b/src/start.s index eafa898..f705620 100644 --- a/src/start.s +++ b/src/start.s @@ -1,21 +1,3 @@ -.set MULTIBOOT_MAGIC, 0xE85250D6 -.set MULTIBOOT_ARCH, 0 -.set MULTIBOOT_LENGTH, 16 + 8 -.set MULTIBOOT_CHECKSUM, -(MULTIBOOT_MAGIC + MULTIBOOT_ARCH + MULTIBOOT_LENGTH) - - - -.section .multiboot -.align 4 -.long MULTIBOOT_MAGIC -.long MULTIBOOT_ARCH -.long MULTIBOOT_LENGTH -.long MULTIBOOT_CHECKSUM -.long 0 -.long 8 - - - .section .bss .global _kernel_stack_start