mirror of https://github.com/tailix/libkernaux.git
Merge branch 'master' into rewrite-assertions-again
This commit is contained in:
commit
63ba6ae4c2
|
@ -89,10 +89,11 @@ libkernaux_la_SOURCES += src/memmap.c
|
||||||
endif
|
endif
|
||||||
if WITH_MULTIBOOT2
|
if WITH_MULTIBOOT2
|
||||||
libkernaux_la_SOURCES += \
|
libkernaux_la_SOURCES += \
|
||||||
src/multiboot2/enums_to_str.c \
|
src/multiboot2/header_enums.c \
|
||||||
src/multiboot2/header_helpers.c \
|
src/multiboot2/header_helpers.c \
|
||||||
src/multiboot2/header_is_valid.c \
|
src/multiboot2/header_is_valid.c \
|
||||||
src/multiboot2/header_print.c \
|
src/multiboot2/header_print.c \
|
||||||
|
src/multiboot2/info_enums.c \
|
||||||
src/multiboot2/info_helpers.c \
|
src/multiboot2/info_helpers.c \
|
||||||
src/multiboot2/info_is_valid.c \
|
src/multiboot2/info_is_valid.c \
|
||||||
src/multiboot2/info_print.c
|
src/multiboot2/info_print.c
|
||||||
|
|
|
@ -22,10 +22,12 @@ nobase_include_HEADERS = \
|
||||||
kernaux/mbr.h \
|
kernaux/mbr.h \
|
||||||
kernaux/memmap.h \
|
kernaux/memmap.h \
|
||||||
kernaux/multiboot2.h \
|
kernaux/multiboot2.h \
|
||||||
|
kernaux/multiboot2/header_enums.h \
|
||||||
kernaux/multiboot2/header_helpers.h \
|
kernaux/multiboot2/header_helpers.h \
|
||||||
kernaux/multiboot2/header_is_valid.h \
|
kernaux/multiboot2/header_is_valid.h \
|
||||||
kernaux/multiboot2/header_macro.h \
|
kernaux/multiboot2/header_macro.h \
|
||||||
kernaux/multiboot2/header_print.h \
|
kernaux/multiboot2/header_print.h \
|
||||||
|
kernaux/multiboot2/info_enums.h \
|
||||||
kernaux/multiboot2/info_helpers.h \
|
kernaux/multiboot2/info_helpers.h \
|
||||||
kernaux/multiboot2/info_is_valid.h \
|
kernaux/multiboot2/info_is_valid.h \
|
||||||
kernaux/multiboot2/info_print.h \
|
kernaux/multiboot2/info_print.h \
|
||||||
|
|
|
@ -41,18 +41,13 @@ extern "C" {
|
||||||
|
|
||||||
#include <kernaux/macro/packing_start.run>
|
#include <kernaux/macro/packing_start.run>
|
||||||
|
|
||||||
/***********************
|
/**********************
|
||||||
* Header common types *
|
* Header basic types *
|
||||||
***********************/
|
**********************/
|
||||||
|
|
||||||
enum KernAux_Multiboot2_Header_Arch {
|
|
||||||
KERNAUX_MULTIBOOT2_HEADER_ARCH_I386 = 0,
|
|
||||||
KERNAUX_MULTIBOOT2_HEADER_ARCH_MIPS32 = 4,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct KernAux_Multiboot2_Header {
|
struct KernAux_Multiboot2_Header {
|
||||||
uint32_t magic;
|
uint32_t magic;
|
||||||
enum KernAux_Multiboot2_Header_Arch arch : 32;
|
uint32_t arch;
|
||||||
uint32_t total_size;
|
uint32_t total_size;
|
||||||
uint32_t checksum;
|
uint32_t checksum;
|
||||||
}
|
}
|
||||||
|
@ -60,22 +55,8 @@ KERNAUX_PACKED;
|
||||||
|
|
||||||
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_Header, 16);
|
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 {
|
struct KernAux_Multiboot2_HTagBase {
|
||||||
enum KernAux_Multiboot2_HTag type : 16;
|
uint16_t type;
|
||||||
uint16_t flags;
|
uint16_t flags;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
}
|
}
|
||||||
|
@ -83,9 +64,9 @@ KERNAUX_PACKED;
|
||||||
|
|
||||||
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_HTagBase, 8);
|
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_HTagBase, 8);
|
||||||
|
|
||||||
/****************************
|
/***************************
|
||||||
* Information common types *
|
* Information basic types *
|
||||||
****************************/
|
***************************/
|
||||||
|
|
||||||
struct KernAux_Multiboot2_Info {
|
struct KernAux_Multiboot2_Info {
|
||||||
uint32_t total_size;
|
uint32_t total_size;
|
||||||
|
@ -95,49 +76,14 @@ KERNAUX_PACKED;
|
||||||
|
|
||||||
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_Info, 8);
|
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 {
|
struct KernAux_Multiboot2_ITagBase {
|
||||||
enum KernAux_Multiboot2_ITag type : 32;
|
uint32_t type;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
}
|
}
|
||||||
KERNAUX_PACKED;
|
KERNAUX_PACKED;
|
||||||
|
|
||||||
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITagBase, 8);
|
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 *
|
* Information additional types *
|
||||||
********************************/
|
********************************/
|
||||||
|
@ -273,7 +219,7 @@ struct KernAux_Multiboot2_HTag_RelocatableHeader {
|
||||||
uint32_t min_addr;
|
uint32_t min_addr;
|
||||||
uint32_t max_addr;
|
uint32_t max_addr;
|
||||||
uint32_t align;
|
uint32_t align;
|
||||||
enum KernAux_Multiboot2_HTag_RelocatableHeader_Preference preferences : 32;
|
uint32_t preference;
|
||||||
}
|
}
|
||||||
KERNAUX_PACKED;
|
KERNAUX_PACKED;
|
||||||
|
|
||||||
|
@ -585,25 +531,12 @@ KERNAUX_STATIC_TEST_STRUCT_SIZE(
|
||||||
|
|
||||||
#include <kernaux/macro/packing_end.run>
|
#include <kernaux/macro/packing_end.run>
|
||||||
|
|
||||||
/********************
|
/*********
|
||||||
* String functions *
|
* Enums *
|
||||||
********************/
|
*********/
|
||||||
|
|
||||||
const char *KernAux_Multiboot2_Header_Arch_to_str(
|
#include <kernaux/multiboot2/header_enums.h>
|
||||||
enum KernAux_Multiboot2_Header_Arch arch
|
#include <kernaux/multiboot2/info_enums.h>
|
||||||
);
|
|
||||||
|
|
||||||
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
|
|
||||||
);
|
|
||||||
|
|
||||||
/********************
|
/********************
|
||||||
* Helper functions *
|
* Helper functions *
|
||||||
|
|
|
@ -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
|
const struct KernAux_Multiboot2_HTagBase
|
||||||
*KernAux_Multiboot2_Header_first_tag_with_type(
|
*KernAux_Multiboot2_Header_first_tag_with_type(
|
||||||
const struct KernAux_Multiboot2_Header *multiboot2_header,
|
const struct KernAux_Multiboot2_Header *multiboot2_header,
|
||||||
enum KernAux_Multiboot2_HTag tag_type
|
uint16_t tag_type
|
||||||
);
|
);
|
||||||
|
|
||||||
const struct KernAux_Multiboot2_HTagBase
|
const struct KernAux_Multiboot2_HTagBase
|
||||||
*KernAux_Multiboot2_Header_tag_with_type_after(
|
*KernAux_Multiboot2_Header_tag_with_type_after(
|
||||||
const struct KernAux_Multiboot2_Header *multiboot2_header,
|
const struct KernAux_Multiboot2_Header *multiboot2_header,
|
||||||
enum KernAux_Multiboot2_HTag tag_type,
|
uint16_t tag_type,
|
||||||
const struct KernAux_Multiboot2_HTagBase *after_tag
|
const struct KernAux_Multiboot2_HTagBase *after_tag
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -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
|
const struct KernAux_Multiboot2_ITagBase
|
||||||
*KernAux_Multiboot2_Info_first_tag_with_type(
|
*KernAux_Multiboot2_Info_first_tag_with_type(
|
||||||
const struct KernAux_Multiboot2_Info *multiboot2_info,
|
const struct KernAux_Multiboot2_Info *multiboot2_info,
|
||||||
enum KernAux_Multiboot2_ITag tag_type
|
uint32_t tag_type
|
||||||
);
|
);
|
||||||
|
|
||||||
const struct KernAux_Multiboot2_ITagBase
|
const struct KernAux_Multiboot2_ITagBase
|
||||||
*KernAux_Multiboot2_Info_tag_with_type_after(
|
*KernAux_Multiboot2_Info_tag_with_type_after(
|
||||||
const struct KernAux_Multiboot2_Info *multiboot2_info,
|
const struct KernAux_Multiboot2_Info *multiboot2_info,
|
||||||
enum KernAux_Multiboot2_ITag tag_type,
|
uint32_t tag_type,
|
||||||
const struct KernAux_Multiboot2_ITagBase *after_tag
|
const struct KernAux_Multiboot2_ITagBase *after_tag
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -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
|
const struct KernAux_Multiboot2_HTagBase
|
||||||
*KernAux_Multiboot2_Header_first_tag_with_type(
|
*KernAux_Multiboot2_Header_first_tag_with_type(
|
||||||
const struct KernAux_Multiboot2_Header *const multiboot2_header,
|
const struct KernAux_Multiboot2_Header *const multiboot2_header,
|
||||||
const enum KernAux_Multiboot2_HTag tag_type
|
const uint16_t tag_type
|
||||||
) {
|
) {
|
||||||
KERNAUX_NOTNULL(multiboot2_header);
|
KERNAUX_NOTNULL(multiboot2_header);
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ const struct KernAux_Multiboot2_HTagBase
|
||||||
const struct KernAux_Multiboot2_HTagBase
|
const struct KernAux_Multiboot2_HTagBase
|
||||||
*KernAux_Multiboot2_Header_tag_with_type_after(
|
*KernAux_Multiboot2_Header_tag_with_type_after(
|
||||||
const struct KernAux_Multiboot2_Header *const multiboot2_header,
|
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
|
const struct KernAux_Multiboot2_HTagBase *const after_tag
|
||||||
) {
|
) {
|
||||||
KERNAUX_NOTNULL(multiboot2_header);
|
KERNAUX_NOTNULL(multiboot2_header);
|
||||||
|
|
|
@ -252,7 +252,7 @@ bool KernAux_Multiboot2_HTag_RelocatableHeader_is_valid(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (tag->preferences) {
|
switch (tag->preference) {
|
||||||
case KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_NONE: break;
|
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_LOWEST: break;
|
||||||
case KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_HIGHEST: break;
|
case KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_HIGHEST: break;
|
||||||
|
|
|
@ -27,11 +27,12 @@
|
||||||
PRINTLN("Multiboot 2 header tag // invalid!"); \
|
PRINTLN("Multiboot 2 header tag // invalid!"); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
KERNAUX_CAST_CONST(unsigned long, type, tag->base.type); \
|
||||||
KERNAUX_CAST_CONST(unsigned long, size, tag->base.size); \
|
KERNAUX_CAST_CONST(unsigned long, size, tag->base.size); \
|
||||||
\
|
\
|
||||||
PRINTLN ("Multiboot 2 header tag {"); \
|
PRINTLN ("Multiboot 2 header tag {"); \
|
||||||
PRINTLNF(" u16 type: %u (%s)", \
|
PRINTLNF(" u16 type: %lu (%s)", \
|
||||||
tag->base.type, \
|
type, \
|
||||||
KernAux_Multiboot2_HTag_to_str(tag->base.type) \
|
KernAux_Multiboot2_HTag_to_str(tag->base.type) \
|
||||||
); \
|
); \
|
||||||
PRINT (" u16 flags: "); \
|
PRINT (" u16 flags: "); \
|
||||||
|
@ -103,13 +104,14 @@ void KernAux_Multiboot2_Header_print(
|
||||||
KERNAUX_NOTNULL(display);
|
KERNAUX_NOTNULL(display);
|
||||||
|
|
||||||
KERNAUX_CAST_CONST(unsigned long, magic, multiboot2_header->magic);
|
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, total_size, multiboot2_header->total_size);
|
||||||
KERNAUX_CAST_CONST(unsigned long, checksum, multiboot2_header->checksum);
|
KERNAUX_CAST_CONST(unsigned long, checksum, multiboot2_header->checksum);
|
||||||
|
|
||||||
PRINTLN("Multiboot 2 header {");
|
PRINTLN("Multiboot 2 header {");
|
||||||
PRINTLNF(" u32 magic: 0x%lx", magic);
|
PRINTLNF(" u32 magic: 0x%lx", magic);
|
||||||
PRINTLNF(" u32 arch: %u (%s)",
|
PRINTLNF(" u32 arch: %lu (%s)",
|
||||||
multiboot2_header->arch,
|
arch,
|
||||||
KernAux_Multiboot2_Header_Arch_to_str(multiboot2_header->arch)
|
KernAux_Multiboot2_Header_Arch_to_str(multiboot2_header->arch)
|
||||||
);
|
);
|
||||||
PRINTLNF(" u32 size: %lu", total_size);
|
PRINTLNF(" u32 size: %lu", total_size);
|
||||||
|
@ -366,10 +368,17 @@ void KernAux_Multiboot2_HTag_RelocatableHeader_print(
|
||||||
KERNAUX_CAST_CONST(unsigned long, min_addr, tag->min_addr);
|
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, max_addr, tag->max_addr);
|
||||||
KERNAUX_CAST_CONST(unsigned long, align, tag->align);
|
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 min_addr: 0x%lx", min_addr);
|
||||||
PRINTLNF(" u32 max_addr: 0x%lx", max_addr);
|
PRINTLNF(" u32 max_addr: 0x%lx", max_addr);
|
||||||
PRINTLNF(" u32 align: %lu", align);
|
PRINTLNF(" u32 align: %lu", align);
|
||||||
|
PRINTLNF(" u32 preference: %lu (%s)",
|
||||||
|
preference,
|
||||||
|
KernAux_Multiboot2_HTag_RelocatableHeader_Preference_to_str(
|
||||||
|
tag->preference
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
FOOTER;
|
FOOTER;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,54 +5,10 @@
|
||||||
#include <kernaux/multiboot2.h>
|
#include <kernaux/multiboot2.h>
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
const char *KernAux_Multiboot2_Header_Arch_to_str(
|
const char *KernAux_Multiboot2_ITag_to_str(const uint32_t tag_type)
|
||||||
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
|
|
||||||
) {
|
|
||||||
switch (tag_type) {
|
switch (tag_type) {
|
||||||
case KERNAUX_MULTIBOOT2_ITAG_NONE:
|
case KERNAUX_MULTIBOOT2_ITAG_NONE:
|
||||||
return "none";
|
return "none";
|
||||||
|
@ -102,18 +58,3 @@ const char *KernAux_Multiboot2_ITag_to_str(
|
||||||
return NULL;
|
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
|
const struct KernAux_Multiboot2_ITagBase
|
||||||
*KernAux_Multiboot2_Info_first_tag_with_type(
|
*KernAux_Multiboot2_Info_first_tag_with_type(
|
||||||
const struct KernAux_Multiboot2_Info *const multiboot2_info,
|
const struct KernAux_Multiboot2_Info *const multiboot2_info,
|
||||||
const enum KernAux_Multiboot2_ITag tag_type
|
const uint32_t tag_type
|
||||||
) {
|
) {
|
||||||
KERNAUX_NOTNULL(multiboot2_info);
|
KERNAUX_NOTNULL(multiboot2_info);
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ const struct KernAux_Multiboot2_ITagBase
|
||||||
const struct KernAux_Multiboot2_ITagBase
|
const struct KernAux_Multiboot2_ITagBase
|
||||||
*KernAux_Multiboot2_Info_tag_with_type_after(
|
*KernAux_Multiboot2_Info_tag_with_type_after(
|
||||||
const struct KernAux_Multiboot2_Info *const multiboot2_info,
|
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
|
const struct KernAux_Multiboot2_ITagBase *const after_tag
|
||||||
) {
|
) {
|
||||||
KERNAUX_NOTNULL(multiboot2_info);
|
KERNAUX_NOTNULL(multiboot2_info);
|
||||||
|
|
|
@ -26,11 +26,12 @@
|
||||||
PRINTLN("Multiboot 2 info tag // invalid!"); \
|
PRINTLN("Multiboot 2 info tag // invalid!"); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
KERNAUX_CAST_CONST(unsigned long, type, tag->base.type); \
|
||||||
KERNAUX_CAST_CONST(unsigned long, size, tag->base.size); \
|
KERNAUX_CAST_CONST(unsigned long, size, tag->base.size); \
|
||||||
\
|
\
|
||||||
PRINTLN("Multiboot 2 info tag {"); \
|
PRINTLN("Multiboot 2 info tag {"); \
|
||||||
PRINTLNF(" u32 type: %u (%s)", \
|
PRINTLNF(" u32 type: %lu (%s)", \
|
||||||
tag->base.type, \
|
type, \
|
||||||
KernAux_Multiboot2_ITag_to_str(tag->base.type) \
|
KernAux_Multiboot2_ITag_to_str(tag->base.type) \
|
||||||
); \
|
); \
|
||||||
PRINTLNF(" u32 size: %lu", size); \
|
PRINTLNF(" u32 size: %lu", size); \
|
||||||
|
|
|
@ -157,7 +157,7 @@ multiboot2_header_example2 = {
|
||||||
.min_addr = 0xcafebabe,
|
.min_addr = 0xcafebabe,
|
||||||
.max_addr = 0xdeadbeaf,
|
.max_addr = 0xdeadbeaf,
|
||||||
.align = 8,
|
.align = 8,
|
||||||
.preferences =
|
.preference =
|
||||||
KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_LOWEST,
|
KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_LOWEST,
|
||||||
},
|
},
|
||||||
.tag_none = {
|
.tag_none = {
|
||||||
|
|
|
@ -170,6 +170,7 @@ static const char output2[] =
|
||||||
" u32 min_addr: 0xcafebabe\n"
|
" u32 min_addr: 0xcafebabe\n"
|
||||||
" u32 max_addr: 0xdeadbeaf\n"
|
" u32 max_addr: 0xdeadbeaf\n"
|
||||||
" u32 align: 8\n"
|
" u32 align: 8\n"
|
||||||
|
" u32 preference: 1 (lowest)\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"Multiboot 2 header tag {\n"
|
"Multiboot 2 header tag {\n"
|
||||||
" u16 type: 0 (none)\n"
|
" u16 type: 0 (none)\n"
|
||||||
|
|
Loading…
Reference in New Issue