mirror of
https://github.com/tailix/libkernaux.git
synced 2024-11-13 11:04:27 -05:00
Merge branch 'master' into paging
This commit is contained in:
commit
4e0c0a62e9
16 changed files with 199 additions and 165 deletions
|
@ -89,10 +89,11 @@ libkernaux_la_SOURCES += src/memmap.c
|
|||
endif
|
||||
if WITH_MULTIBOOT2
|
||||
libkernaux_la_SOURCES += \
|
||||
src/multiboot2/enums_to_str.c \
|
||||
src/multiboot2/header_enums.c \
|
||||
src/multiboot2/header_helpers.c \
|
||||
src/multiboot2/header_is_valid.c \
|
||||
src/multiboot2/header_print.c \
|
||||
src/multiboot2/info_enums.c \
|
||||
src/multiboot2/info_helpers.c \
|
||||
src/multiboot2/info_is_valid.c \
|
||||
src/multiboot2/info_print.c
|
||||
|
|
|
@ -23,10 +23,12 @@ nobase_include_HEADERS = \
|
|||
kernaux/mbr.h \
|
||||
kernaux/memmap.h \
|
||||
kernaux/multiboot2.h \
|
||||
kernaux/multiboot2/header_enums.h \
|
||||
kernaux/multiboot2/header_helpers.h \
|
||||
kernaux/multiboot2/header_is_valid.h \
|
||||
kernaux/multiboot2/header_macro.h \
|
||||
kernaux/multiboot2/header_print.h \
|
||||
kernaux/multiboot2/info_enums.h \
|
||||
kernaux/multiboot2/info_helpers.h \
|
||||
kernaux/multiboot2/info_is_valid.h \
|
||||
kernaux/multiboot2/info_print.h \
|
||||
|
|
|
@ -41,18 +41,13 @@ extern "C" {
|
|||
|
||||
#include <kernaux/macro/packing_start.run>
|
||||
|
||||
/***********************
|
||||
* Header common types *
|
||||
***********************/
|
||||
|
||||
enum KernAux_Multiboot2_Header_Arch {
|
||||
KERNAUX_MULTIBOOT2_HEADER_ARCH_I386 = 0,
|
||||
KERNAUX_MULTIBOOT2_HEADER_ARCH_MIPS32 = 4,
|
||||
};
|
||||
/**********************
|
||||
* Header basic types *
|
||||
**********************/
|
||||
|
||||
struct KernAux_Multiboot2_Header {
|
||||
uint32_t magic;
|
||||
enum KernAux_Multiboot2_Header_Arch arch : 32;
|
||||
uint32_t arch;
|
||||
uint32_t total_size;
|
||||
uint32_t checksum;
|
||||
}
|
||||
|
@ -60,22 +55,8 @@ KERNAUX_PACKED;
|
|||
|
||||
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_Header, 16);
|
||||
|
||||
enum KernAux_Multiboot2_HTag {
|
||||
KERNAUX_MULTIBOOT2_HTAG_NONE = 0,
|
||||
KERNAUX_MULTIBOOT2_HTAG_INFO_REQ = 1,
|
||||
KERNAUX_MULTIBOOT2_HTAG_ADDR = 2,
|
||||
KERNAUX_MULTIBOOT2_HTAG_ENTRY_ADDR = 3,
|
||||
KERNAUX_MULTIBOOT2_HTAG_FLAGS = 4,
|
||||
KERNAUX_MULTIBOOT2_HTAG_FRAMEBUFFER = 5,
|
||||
KERNAUX_MULTIBOOT2_HTAG_MODULE_ALIGN = 6,
|
||||
KERNAUX_MULTIBOOT2_HTAG_EFI_BOOT_SERVICES = 7,
|
||||
KERNAUX_MULTIBOOT2_HTAG_EFI_I386_ENTRY_ADDR = 8,
|
||||
KERNAUX_MULTIBOOT2_HTAG_EFI_AMD64_ENTRY_ADDR = 9,
|
||||
KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER = 10,
|
||||
};
|
||||
|
||||
struct KernAux_Multiboot2_HTagBase {
|
||||
enum KernAux_Multiboot2_HTag type : 16;
|
||||
uint16_t type;
|
||||
uint16_t flags;
|
||||
uint32_t size;
|
||||
}
|
||||
|
@ -83,9 +64,9 @@ KERNAUX_PACKED;
|
|||
|
||||
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_HTagBase, 8);
|
||||
|
||||
/****************************
|
||||
* Information common types *
|
||||
****************************/
|
||||
/***************************
|
||||
* Information basic types *
|
||||
***************************/
|
||||
|
||||
struct KernAux_Multiboot2_Info {
|
||||
uint32_t total_size;
|
||||
|
@ -95,49 +76,14 @@ KERNAUX_PACKED;
|
|||
|
||||
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_Info, 8);
|
||||
|
||||
enum KernAux_Multiboot2_ITag {
|
||||
KERNAUX_MULTIBOOT2_ITAG_NONE = 0,
|
||||
KERNAUX_MULTIBOOT2_ITAG_BOOT_CMD_LINE = 1,
|
||||
KERNAUX_MULTIBOOT2_ITAG_BOOT_LOADER_NAME = 2,
|
||||
KERNAUX_MULTIBOOT2_ITAG_MODULE = 3,
|
||||
KERNAUX_MULTIBOOT2_ITAG_BASIC_MEMORY_INFO = 4,
|
||||
KERNAUX_MULTIBOOT2_ITAG_BIOS_BOOT_DEVICE = 5,
|
||||
KERNAUX_MULTIBOOT2_ITAG_MEMORY_MAP = 6,
|
||||
KERNAUX_MULTIBOOT2_ITAG_VBE_INFO = 7,
|
||||
KERNAUX_MULTIBOOT2_ITAG_FRAMEBUFFER_INFO = 8,
|
||||
KERNAUX_MULTIBOOT2_ITAG_ELF_SYMBOLS = 9,
|
||||
KERNAUX_MULTIBOOT2_ITAG_APM_TABLE = 10,
|
||||
KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_SYSTEM_TABLE_PTR = 11,
|
||||
KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_SYSTEM_TABLE_PTR = 12,
|
||||
KERNAUX_MULTIBOOT2_ITAG_SMBIOS_TABLES = 13,
|
||||
KERNAUX_MULTIBOOT2_ITAG_ACPI_OLD_RSDP = 14,
|
||||
KERNAUX_MULTIBOOT2_ITAG_ACPI_NEW_RSDP = 15,
|
||||
KERNAUX_MULTIBOOT2_ITAG_NETWORKING_INFO = 16,
|
||||
KERNAUX_MULTIBOOT2_ITAG_EFI_MEMORY_MAP = 17,
|
||||
KERNAUX_MULTIBOOT2_ITAG_EFI_BOOT_SERVICES_NOT_TERMINATED = 18,
|
||||
KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_IMAGE_HANDLE_PTR = 19,
|
||||
KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_IMAGE_HANDLE_PTR = 20,
|
||||
KERNAUX_MULTIBOOT2_ITAG_IMAGE_LOAD_BASE_PHYS_ADDR = 21,
|
||||
};
|
||||
|
||||
struct KernAux_Multiboot2_ITagBase {
|
||||
enum KernAux_Multiboot2_ITag type : 32;
|
||||
uint32_t type;
|
||||
uint32_t size;
|
||||
}
|
||||
KERNAUX_PACKED;
|
||||
|
||||
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITagBase, 8);
|
||||
|
||||
/***************************
|
||||
* Header additional types *
|
||||
***************************/
|
||||
|
||||
enum KernAux_Multiboot2_HTag_RelocatableHeader_Preference {
|
||||
KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_NONE = 0,
|
||||
KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_LOWEST = 1,
|
||||
KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_HIGHEST = 2,
|
||||
};
|
||||
|
||||
/********************************
|
||||
* Information additional types *
|
||||
********************************/
|
||||
|
@ -273,7 +219,7 @@ struct KernAux_Multiboot2_HTag_RelocatableHeader {
|
|||
uint32_t min_addr;
|
||||
uint32_t max_addr;
|
||||
uint32_t align;
|
||||
enum KernAux_Multiboot2_HTag_RelocatableHeader_Preference preferences : 32;
|
||||
uint32_t preference;
|
||||
}
|
||||
KERNAUX_PACKED;
|
||||
|
||||
|
@ -585,25 +531,12 @@ KERNAUX_STATIC_TEST_STRUCT_SIZE(
|
|||
|
||||
#include <kernaux/macro/packing_end.run>
|
||||
|
||||
/********************
|
||||
* String functions *
|
||||
********************/
|
||||
/*********
|
||||
* Enums *
|
||||
*********/
|
||||
|
||||
const char *KernAux_Multiboot2_Header_Arch_to_str(
|
||||
enum KernAux_Multiboot2_Header_Arch arch
|
||||
);
|
||||
|
||||
const char *KernAux_Multiboot2_HTag_to_str(
|
||||
enum KernAux_Multiboot2_HTag tag_type
|
||||
);
|
||||
|
||||
const char *KernAux_Multiboot2_ITag_to_str(
|
||||
enum KernAux_Multiboot2_ITag tag_type
|
||||
);
|
||||
|
||||
const char *KernAux_Multiboot2_HTag_RelocatableHeader_Preference_to_str(
|
||||
enum KernAux_Multiboot2_HTag_RelocatableHeader_Preference pref
|
||||
);
|
||||
#include <kernaux/multiboot2/header_enums.h>
|
||||
#include <kernaux/multiboot2/info_enums.h>
|
||||
|
||||
/********************
|
||||
* Helper functions *
|
||||
|
|
40
include/kernaux/multiboot2/header_enums.h
Normal file
40
include/kernaux/multiboot2/header_enums.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
#ifndef KERNAUX_INCLUDED_MULTIBOOT2_HEADER_ENUMS
|
||||
#define KERNAUX_INCLUDED_MULTIBOOT2_HEADER_ENUMS
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define KERNAUX_MULTIBOOT2_HEADER_ARCH_I386 0
|
||||
#define KERNAUX_MULTIBOOT2_HEADER_ARCH_MIPS32 4
|
||||
|
||||
#define KERNAUX_MULTIBOOT2_HTAG_NONE 0
|
||||
#define KERNAUX_MULTIBOOT2_HTAG_INFO_REQ 1
|
||||
#define KERNAUX_MULTIBOOT2_HTAG_ADDR 2
|
||||
#define KERNAUX_MULTIBOOT2_HTAG_ENTRY_ADDR 3
|
||||
#define KERNAUX_MULTIBOOT2_HTAG_FLAGS 4
|
||||
#define KERNAUX_MULTIBOOT2_HTAG_FRAMEBUFFER 5
|
||||
#define KERNAUX_MULTIBOOT2_HTAG_MODULE_ALIGN 6
|
||||
#define KERNAUX_MULTIBOOT2_HTAG_EFI_BOOT_SERVICES 7
|
||||
#define KERNAUX_MULTIBOOT2_HTAG_EFI_I386_ENTRY_ADDR 8
|
||||
#define KERNAUX_MULTIBOOT2_HTAG_EFI_AMD64_ENTRY_ADDR 9
|
||||
#define KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER 10
|
||||
|
||||
#define KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_NONE 0
|
||||
#define KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_LOWEST 1
|
||||
#define KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_HIGHEST 2
|
||||
|
||||
const char *KernAux_Multiboot2_Header_Arch_to_str(uint32_t arch);
|
||||
const char *KernAux_Multiboot2_HTag_to_str(uint16_t tag_type);
|
||||
const char*
|
||||
KernAux_Multiboot2_HTag_RelocatableHeader_Preference_to_str(uint32_t pref);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -10,13 +10,13 @@ extern "C" {
|
|||
const struct KernAux_Multiboot2_HTagBase
|
||||
*KernAux_Multiboot2_Header_first_tag_with_type(
|
||||
const struct KernAux_Multiboot2_Header *multiboot2_header,
|
||||
enum KernAux_Multiboot2_HTag tag_type
|
||||
uint16_t tag_type
|
||||
);
|
||||
|
||||
const struct KernAux_Multiboot2_HTagBase
|
||||
*KernAux_Multiboot2_Header_tag_with_type_after(
|
||||
const struct KernAux_Multiboot2_Header *multiboot2_header,
|
||||
enum KernAux_Multiboot2_HTag tag_type,
|
||||
uint16_t tag_type,
|
||||
const struct KernAux_Multiboot2_HTagBase *after_tag
|
||||
);
|
||||
|
||||
|
|
41
include/kernaux/multiboot2/info_enums.h
Normal file
41
include/kernaux/multiboot2/info_enums.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
#ifndef KERNAUX_INCLUDED_MULTIBOOT2_INFO_ENUMS
|
||||
#define KERNAUX_INCLUDED_MULTIBOOT2_INFO_ENUMS
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_NONE 0
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_BOOT_CMD_LINE 1
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_BOOT_LOADER_NAME 2
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_MODULE 3
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_BASIC_MEMORY_INFO 4
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_BIOS_BOOT_DEVICE 5
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_MEMORY_MAP 6
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_VBE_INFO 7
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_FRAMEBUFFER_INFO 8
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_ELF_SYMBOLS 9
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_APM_TABLE 10
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_SYSTEM_TABLE_PTR 11
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_SYSTEM_TABLE_PTR 12
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_SMBIOS_TABLES 13
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_ACPI_OLD_RSDP 14
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_ACPI_NEW_RSDP 15
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_NETWORKING_INFO 16
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_EFI_MEMORY_MAP 17
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_EFI_BOOT_SERVICES_NOT_TERMINATED 18
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_IMAGE_HANDLE_PTR 19
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_IMAGE_HANDLE_PTR 20
|
||||
#define KERNAUX_MULTIBOOT2_ITAG_IMAGE_LOAD_BASE_PHYS_ADDR 21
|
||||
|
||||
const char *KernAux_Multiboot2_ITag_to_str(uint32_t tag_type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -10,13 +10,13 @@ extern "C" {
|
|||
const struct KernAux_Multiboot2_ITagBase
|
||||
*KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
const struct KernAux_Multiboot2_Info *multiboot2_info,
|
||||
enum KernAux_Multiboot2_ITag tag_type
|
||||
uint32_t tag_type
|
||||
);
|
||||
|
||||
const struct KernAux_Multiboot2_ITagBase
|
||||
*KernAux_Multiboot2_Info_tag_with_type_after(
|
||||
const struct KernAux_Multiboot2_Info *multiboot2_info,
|
||||
enum KernAux_Multiboot2_ITag tag_type,
|
||||
uint32_t tag_type,
|
||||
const struct KernAux_Multiboot2_ITagBase *after_tag
|
||||
);
|
||||
|
||||
|
|
65
src/multiboot2/header_enums.c
Normal file
65
src/multiboot2/header_enums.c
Normal file
|
@ -0,0 +1,65 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
const char *KernAux_Multiboot2_Header_Arch_to_str(const uint32_t arch)
|
||||
{
|
||||
switch (arch) {
|
||||
case KERNAUX_MULTIBOOT2_HEADER_ARCH_I386:
|
||||
return "i386";
|
||||
case KERNAUX_MULTIBOOT2_HEADER_ARCH_MIPS32:
|
||||
return "MIPS32";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const char *KernAux_Multiboot2_HTag_to_str(const uint16_t tag_type)
|
||||
{
|
||||
switch (tag_type) {
|
||||
case KERNAUX_MULTIBOOT2_HTAG_NONE:
|
||||
return "none";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_INFO_REQ:
|
||||
return "information request";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_ADDR:
|
||||
return "address";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_ENTRY_ADDR:
|
||||
return "entry address";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_FLAGS:
|
||||
return "flags";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_FRAMEBUFFER:
|
||||
return "framebuffer";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_MODULE_ALIGN:
|
||||
return "module alignment";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_EFI_BOOT_SERVICES:
|
||||
return "EFI boot services";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_EFI_I386_ENTRY_ADDR:
|
||||
return "EFI i386 entry address";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_EFI_AMD64_ENTRY_ADDR:
|
||||
return "EFI amd64 entry address";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER:
|
||||
return "relocatable header";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const char*
|
||||
KernAux_Multiboot2_HTag_RelocatableHeader_Preference_to_str(uint32_t pref)
|
||||
{
|
||||
switch (pref) {
|
||||
case KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_NONE:
|
||||
return "none";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_LOWEST:
|
||||
return "lowest";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_HIGHEST:
|
||||
return "highest";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
const struct KernAux_Multiboot2_HTagBase
|
||||
*KernAux_Multiboot2_Header_first_tag_with_type(
|
||||
const struct KernAux_Multiboot2_Header *const multiboot2_header,
|
||||
const enum KernAux_Multiboot2_HTag tag_type
|
||||
const uint16_t tag_type
|
||||
) {
|
||||
KERNAUX_ASSERT(multiboot2_header);
|
||||
|
||||
|
@ -35,7 +35,7 @@ const struct KernAux_Multiboot2_HTagBase
|
|||
const struct KernAux_Multiboot2_HTagBase
|
||||
*KernAux_Multiboot2_Header_tag_with_type_after(
|
||||
const struct KernAux_Multiboot2_Header *const multiboot2_header,
|
||||
const enum KernAux_Multiboot2_HTag tag_type,
|
||||
const uint16_t tag_type,
|
||||
const struct KernAux_Multiboot2_HTagBase *const after_tag
|
||||
) {
|
||||
KERNAUX_ASSERT(multiboot2_header);
|
||||
|
|
|
@ -252,7 +252,7 @@ bool KernAux_Multiboot2_HTag_RelocatableHeader_is_valid(
|
|||
return false;
|
||||
}
|
||||
|
||||
switch (tag->preferences) {
|
||||
switch (tag->preference) {
|
||||
case KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_NONE: break;
|
||||
case KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_LOWEST: break;
|
||||
case KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_HIGHEST: break;
|
||||
|
|
|
@ -27,11 +27,12 @@
|
|||
PRINTLN("Multiboot 2 header tag // invalid!"); \
|
||||
} \
|
||||
\
|
||||
KERNAUX_CAST_CONST(unsigned long, size, tag->base.size); \
|
||||
KERNAUX_CAST_CONST(unsigned long, type, tag->base.type); \
|
||||
KERNAUX_CAST_CONST(unsigned long, size, tag->base.size); \
|
||||
\
|
||||
PRINTLN ("Multiboot 2 header tag {"); \
|
||||
PRINTLNF(" u16 type: %u (%s)", \
|
||||
tag->base.type, \
|
||||
PRINTLNF(" u16 type: %lu (%s)", \
|
||||
type, \
|
||||
KernAux_Multiboot2_HTag_to_str(tag->base.type) \
|
||||
); \
|
||||
PRINT (" u16 flags: "); \
|
||||
|
@ -103,13 +104,14 @@ void KernAux_Multiboot2_Header_print(
|
|||
KERNAUX_ASSERT(display);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, magic, multiboot2_header->magic);
|
||||
KERNAUX_CAST_CONST(unsigned long, arch, multiboot2_header->arch);
|
||||
KERNAUX_CAST_CONST(unsigned long, total_size, multiboot2_header->total_size);
|
||||
KERNAUX_CAST_CONST(unsigned long, checksum, multiboot2_header->checksum);
|
||||
|
||||
PRINTLN("Multiboot 2 header {");
|
||||
PRINTLNF(" u32 magic: 0x%lx", magic);
|
||||
PRINTLNF(" u32 arch: %u (%s)",
|
||||
multiboot2_header->arch,
|
||||
PRINTLNF(" u32 arch: %lu (%s)",
|
||||
arch,
|
||||
KernAux_Multiboot2_Header_Arch_to_str(multiboot2_header->arch)
|
||||
);
|
||||
PRINTLNF(" u32 size: %lu", total_size);
|
||||
|
@ -363,13 +365,20 @@ void KernAux_Multiboot2_HTag_RelocatableHeader_print(
|
|||
) {
|
||||
HEADER(RelocatableHeader);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, min_addr, tag->min_addr);
|
||||
KERNAUX_CAST_CONST(unsigned long, max_addr, tag->max_addr);
|
||||
KERNAUX_CAST_CONST(unsigned long, align, tag->align);
|
||||
KERNAUX_CAST_CONST(unsigned long, min_addr, tag->min_addr);
|
||||
KERNAUX_CAST_CONST(unsigned long, max_addr, tag->max_addr);
|
||||
KERNAUX_CAST_CONST(unsigned long, align, tag->align);
|
||||
KERNAUX_CAST_CONST(unsigned long, preference, tag->preference);
|
||||
|
||||
PRINTLNF(" u32 min_addr: 0x%lx", min_addr);
|
||||
PRINTLNF(" u32 max_addr: 0x%lx", max_addr);
|
||||
PRINTLNF(" u32 align: %lu", align);
|
||||
PRINTLNF(" u32 preference: %lu (%s)",
|
||||
preference,
|
||||
KernAux_Multiboot2_HTag_RelocatableHeader_Preference_to_str(
|
||||
tag->preference
|
||||
)
|
||||
);
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
|
|
@ -5,54 +5,10 @@
|
|||
#include <kernaux/multiboot2.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
const char *KernAux_Multiboot2_Header_Arch_to_str(
|
||||
const enum KernAux_Multiboot2_Header_Arch arch
|
||||
) {
|
||||
switch (arch) {
|
||||
case KERNAUX_MULTIBOOT2_HEADER_ARCH_I386:
|
||||
return "i386";
|
||||
case KERNAUX_MULTIBOOT2_HEADER_ARCH_MIPS32:
|
||||
return "MIPS32";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const char *KernAux_Multiboot2_HTag_to_str(
|
||||
const enum KernAux_Multiboot2_HTag tag_type
|
||||
) {
|
||||
switch (tag_type) {
|
||||
case KERNAUX_MULTIBOOT2_HTAG_NONE:
|
||||
return "none";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_INFO_REQ:
|
||||
return "information request";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_ADDR:
|
||||
return "address";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_ENTRY_ADDR:
|
||||
return "entry address";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_FLAGS:
|
||||
return "flags";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_FRAMEBUFFER:
|
||||
return "framebuffer";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_MODULE_ALIGN:
|
||||
return "module alignment";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_EFI_BOOT_SERVICES:
|
||||
return "EFI boot services";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_EFI_I386_ENTRY_ADDR:
|
||||
return "EFI i386 entry address";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_EFI_AMD64_ENTRY_ADDR:
|
||||
return "EFI amd64 entry address";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER:
|
||||
return "relocatable header";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const char *KernAux_Multiboot2_ITag_to_str(
|
||||
const enum KernAux_Multiboot2_ITag tag_type
|
||||
) {
|
||||
const char *KernAux_Multiboot2_ITag_to_str(const uint32_t tag_type)
|
||||
{
|
||||
switch (tag_type) {
|
||||
case KERNAUX_MULTIBOOT2_ITAG_NONE:
|
||||
return "none";
|
||||
|
@ -102,18 +58,3 @@ const char *KernAux_Multiboot2_ITag_to_str(
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const char *KernAux_Multiboot2_HTag_RelocatableHeader_Preference_to_str(
|
||||
const enum KernAux_Multiboot2_HTag_RelocatableHeader_Preference pref
|
||||
) {
|
||||
switch (pref) {
|
||||
case KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_NONE:
|
||||
return "none";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_LOWEST:
|
||||
return "lowest";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_HIGHEST:
|
||||
return "highest";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
const struct KernAux_Multiboot2_ITagBase
|
||||
*KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
const struct KernAux_Multiboot2_Info *const multiboot2_info,
|
||||
const enum KernAux_Multiboot2_ITag tag_type
|
||||
const uint32_t tag_type
|
||||
) {
|
||||
KERNAUX_ASSERT(multiboot2_info);
|
||||
|
||||
|
@ -35,7 +35,7 @@ const struct KernAux_Multiboot2_ITagBase
|
|||
const struct KernAux_Multiboot2_ITagBase
|
||||
*KernAux_Multiboot2_Info_tag_with_type_after(
|
||||
const struct KernAux_Multiboot2_Info *const multiboot2_info,
|
||||
const enum KernAux_Multiboot2_ITag tag_type,
|
||||
const uint32_t tag_type,
|
||||
const struct KernAux_Multiboot2_ITagBase *const after_tag
|
||||
) {
|
||||
KERNAUX_ASSERT(multiboot2_info);
|
||||
|
|
|
@ -26,11 +26,12 @@
|
|||
PRINTLN("Multiboot 2 info tag // invalid!"); \
|
||||
} \
|
||||
\
|
||||
KERNAUX_CAST_CONST(unsigned long, type, tag->base.type); \
|
||||
KERNAUX_CAST_CONST(unsigned long, size, tag->base.size); \
|
||||
\
|
||||
PRINTLN("Multiboot 2 info tag {"); \
|
||||
PRINTLNF(" u32 type: %u (%s)", \
|
||||
tag->base.type, \
|
||||
PRINTLNF(" u32 type: %lu (%s)", \
|
||||
type, \
|
||||
KernAux_Multiboot2_ITag_to_str(tag->base.type) \
|
||||
); \
|
||||
PRINTLNF(" u32 size: %lu", size); \
|
||||
|
|
|
@ -157,7 +157,7 @@ multiboot2_header_example2 = {
|
|||
.min_addr = 0xcafebabe,
|
||||
.max_addr = 0xdeadbeaf,
|
||||
.align = 8,
|
||||
.preferences =
|
||||
.preference =
|
||||
KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_LOWEST,
|
||||
},
|
||||
.tag_none = {
|
||||
|
|
|
@ -170,6 +170,7 @@ static const char output2[] =
|
|||
" u32 min_addr: 0xcafebabe\n"
|
||||
" u32 max_addr: 0xdeadbeaf\n"
|
||||
" u32 align: 8\n"
|
||||
" u32 preference: 1 (lowest)\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 0 (none)\n"
|
||||
|
|
Loading…
Reference in a new issue