mirror of https://github.com/tailix/libkernaux.git
Compare commits
No commits in common. "4e0c0a62e9cc7a9b7d5f3325d5f0b0226418dac6" and "4a44d0f20af0a8bf6beb706dd322ee621a38d7d2" have entirely different histories.
4e0c0a62e9
...
4a44d0f20a
|
@ -57,15 +57,6 @@
|
|||
/libtool
|
||||
/stamp-h1
|
||||
|
||||
# Temporary
|
||||
/confcache
|
||||
/confdefs.h
|
||||
/confinc.mk
|
||||
/confmf.BSD
|
||||
/confmf.GNU
|
||||
/conftest.c
|
||||
/conftest.err
|
||||
|
||||
/examples/test-suite.log
|
||||
/examples/*.log
|
||||
/examples/*.trs
|
||||
|
@ -106,10 +97,8 @@
|
|||
/examples/printf_str_va
|
||||
/examples/units_human
|
||||
|
||||
/tests/multiboot2_header_print0
|
||||
/tests/multiboot2_header_print1
|
||||
/tests/multiboot2_header_print2
|
||||
/tests/multiboot2_info_print0
|
||||
/tests/multiboot2_info_print1
|
||||
/tests/multiboot2_info_print2
|
||||
/tests/test_arch_i386
|
||||
|
|
|
@ -1,12 +1,3 @@
|
|||
2022-12-17 Alex Kotov <kotovalexarian@gmail.com>
|
||||
|
||||
* src/multiboot2/*_print.c: Print some values in hex
|
||||
|
||||
2022-12-16 Alex Kotov <kotovalexarian@gmail.com>
|
||||
|
||||
* configure.ac: Feature "--with[out]-multiboot2" has been added
|
||||
* include/kernaux/multiboot2.h: Has been made stable
|
||||
|
||||
2022-12-14 Alex Kotov <kotovalexarian@gmail.com>
|
||||
|
||||
* configure.ac: Enable shared library
|
||||
|
|
|
@ -89,11 +89,11 @@ libkernaux_la_SOURCES += src/memmap.c
|
|||
endif
|
||||
if WITH_MULTIBOOT2
|
||||
libkernaux_la_SOURCES += \
|
||||
src/multiboot2/header_enums.c \
|
||||
src/multiboot2/enums_to_str.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_convert.c \
|
||||
src/multiboot2/info_helpers.c \
|
||||
src/multiboot2/info_is_valid.c \
|
||||
src/multiboot2/info_print.c
|
||||
|
|
|
@ -66,7 +66,7 @@ zero). Work-in-progress APIs can change at any time.
|
|||
* Data formats
|
||||
* [ELF](/include/kernaux/elf.h) (*work in progress*)
|
||||
* [MBR](/include/kernaux/mbr.h) (*work in progress*)
|
||||
* [Multiboot 2 (GRUB 2)](/include/kernaux/multiboot2.h.in) (*non-breaking since* **?.?.?**)
|
||||
* [Multiboot 2 (GRUB 2)](/include/kernaux/multiboot2.h.in) (*work in progress*)
|
||||
* [Example: header macros](/examples/multiboot2_header_macro.c)
|
||||
* Utilities
|
||||
* [Measurement units utils](/include/kernaux/units.h) (*work in progress*)
|
||||
|
@ -169,7 +169,6 @@ explicitly included, use `--without-all`.
|
|||
* `--with[out]-cmdline` - command line parser
|
||||
* `--with[out]-free-list` - free list memory allocator
|
||||
* `--with[out]-memmap` - memory map
|
||||
* `--with[out]-multiboot2` - Multiboot 2 utils
|
||||
* `--with[out]-ntoa` - itoa/ftoa
|
||||
* `--with[out]-printf` - printf
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ AC_ARG_WITH( [elf], AS_HELP_STRING([--without-elf], [wit
|
|||
AC_ARG_WITH( [free-list], AS_HELP_STRING([--without-free-list], [without free list memory allocator]))
|
||||
AC_ARG_WITH( [mbr], AS_HELP_STRING([--without-mbr], [without MBR utils]))
|
||||
AC_ARG_WITH( [memmap], AS_HELP_STRING([--without-memmap], [without memory map]))
|
||||
AC_ARG_WITH( [multiboot2], AS_HELP_STRING([--without-multiboot2], [without Multiboot 2 utils]))
|
||||
AC_ARG_WITH( [multiboot2], AS_HELP_STRING([--without-multiboot2], [without Multiboot 2 information parser]))
|
||||
AC_ARG_WITH( [ntoa], AS_HELP_STRING([--without-ntoa], [without itoa/ftoa]))
|
||||
AC_ARG_WITH( [pfa], AS_HELP_STRING([--without-pfa], [without Page Frame Allocator]))
|
||||
AC_ARG_WITH( [printf], AS_HELP_STRING([--without-printf], [without printf]))
|
||||
|
@ -265,7 +265,7 @@ AS_IF([test "$with_elf" = yes], [AC_DEFINE([WITH_ELF],
|
|||
AS_IF([test "$with_free_list" = yes], [AC_DEFINE([WITH_FREE_LIST], [1], [with free list memory allocator])])
|
||||
AS_IF([test "$with_mbr" = yes], [AC_DEFINE([WITH_MBR], [1], [with MBR utils])])
|
||||
AS_IF([test "$with_memmap" = yes], [AC_DEFINE([WITH_MEMMAP], [1], [with memory map])])
|
||||
AS_IF([test "$with_multiboot2" = yes], [AC_DEFINE([WITH_MULTIBOOT2], [1], [with Multiboot 2 utils])])
|
||||
AS_IF([test "$with_multiboot2" = yes], [AC_DEFINE([WITH_MULTIBOOT2], [1], [with Multiboot 2 information parser])])
|
||||
AS_IF([test "$with_ntoa" = yes], [AC_DEFINE([WITH_NTOA], [1], [with ntoa])])
|
||||
AS_IF([test "$with_pfa" = yes], [AC_DEFINE([WITH_PFA], [1], [with Page Frame Allocator])])
|
||||
AS_IF([test "$with_printf" = yes], [AC_DEFINE([WITH_PRINTF], [1], [with printf])])
|
||||
|
|
|
@ -54,7 +54,6 @@ multiboot2_header = {
|
|||
.magic = KERNAUX_MULTIBOOT2_HEADER_MAGIC,
|
||||
.arch = KERNAUX_MULTIBOOT2_HEADER_ARCH_I386,
|
||||
.total_size = sizeof(multiboot2_header),
|
||||
// This macro helps to calculate the checksum.
|
||||
.checksum = KERNAUX_MULTIBOOT2_HEADER_CHECKSUM(
|
||||
KERNAUX_MULTIBOOT2_HEADER_ARCH_I386,
|
||||
sizeof(multiboot2_header)
|
||||
|
|
|
@ -23,15 +23,7 @@ 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 \
|
||||
kernaux/ntoa.h \
|
||||
kernaux/pfa.h \
|
||||
kernaux/printf.h \
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <kernaux/mbr.h>
|
||||
#include <kernaux/memmap.h>
|
||||
#include <kernaux/multiboot2.h>
|
||||
#include <kernaux/multiboot2/header_macro.h>
|
||||
#include <kernaux/ntoa.h>
|
||||
#include <kernaux/pfa.h>
|
||||
#include <kernaux/printf.h>
|
||||
|
|
|
@ -7,6 +7,7 @@ extern "C" {
|
|||
|
||||
#include <kernaux/macro.h>
|
||||
#include <kernaux/generic/display.h>
|
||||
#include <kernaux/memmap.h>
|
||||
#include <kernaux/multiboot2/header_macro.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
@ -23,6 +24,13 @@ extern "C" {
|
|||
// @see https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html#Basic-tags-structure
|
||||
#define KERNAUX_MULTIBOOT2_TAG_ALIGN 8
|
||||
|
||||
#define KERNAUX_MULTIBOOT2_HEADER_CHECKSUM(arch, total_size) \
|
||||
((uint32_t)(-( \
|
||||
((uint32_t)KERNAUX_MULTIBOOT2_HEADER_MAGIC) + \
|
||||
((uint32_t)(arch)) + \
|
||||
((uint32_t)(total_size)) \
|
||||
)))
|
||||
|
||||
#define KERNAUX_MULTIBOOT2_DATA(ptr) (((uint8_t*)(ptr)) + sizeof(*(ptr)))
|
||||
|
||||
#define KERNAUX_MULTIBOOT2_HTAG_NEXT(tag_base) \
|
||||
|
@ -41,13 +49,18 @@ extern "C" {
|
|||
|
||||
#include <kernaux/macro/packing_start.run>
|
||||
|
||||
/**********************
|
||||
* Header basic types *
|
||||
**********************/
|
||||
/***********************
|
||||
* Header common types *
|
||||
***********************/
|
||||
|
||||
enum KernAux_Multiboot2_Header_Arch {
|
||||
KERNAUX_MULTIBOOT2_HEADER_ARCH_I386 = 0,
|
||||
KERNAUX_MULTIBOOT2_HEADER_ARCH_MIPS32 = 4,
|
||||
};
|
||||
|
||||
struct KernAux_Multiboot2_Header {
|
||||
uint32_t magic;
|
||||
uint32_t arch;
|
||||
enum KernAux_Multiboot2_Header_Arch arch : 32;
|
||||
uint32_t total_size;
|
||||
uint32_t checksum;
|
||||
}
|
||||
|
@ -55,8 +68,22 @@ 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 {
|
||||
uint16_t type;
|
||||
enum KernAux_Multiboot2_HTag type : 16;
|
||||
uint16_t flags;
|
||||
uint32_t size;
|
||||
}
|
||||
|
@ -64,26 +91,61 @@ KERNAUX_PACKED;
|
|||
|
||||
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_HTagBase, 8);
|
||||
|
||||
/***************************
|
||||
* Information basic types *
|
||||
***************************/
|
||||
/****************************
|
||||
* Information common types *
|
||||
****************************/
|
||||
|
||||
struct KernAux_Multiboot2_Info {
|
||||
uint32_t total_size;
|
||||
uint32_t reserved;
|
||||
uint32_t reserved1;
|
||||
}
|
||||
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 {
|
||||
uint32_t type;
|
||||
enum KernAux_Multiboot2_ITag type : 32;
|
||||
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 *
|
||||
********************************/
|
||||
|
@ -92,7 +154,7 @@ struct KernAux_Multiboot2_ITag_MemoryMap_EntryBase {
|
|||
uint64_t base_addr;
|
||||
uint64_t length;
|
||||
uint32_t type;
|
||||
uint32_t reserved;
|
||||
uint32_t reserved1;
|
||||
}
|
||||
KERNAUX_PACKED;
|
||||
|
||||
|
@ -115,8 +177,6 @@ struct KernAux_Multiboot2_HTag_InfoReq {
|
|||
// type = 1
|
||||
// size > 8
|
||||
struct KernAux_Multiboot2_HTagBase base;
|
||||
|
||||
// DATA: uint32_t mbi_tag_types[]
|
||||
}
|
||||
KERNAUX_PACKED;
|
||||
|
||||
|
@ -219,7 +279,7 @@ struct KernAux_Multiboot2_HTag_RelocatableHeader {
|
|||
uint32_t min_addr;
|
||||
uint32_t max_addr;
|
||||
uint32_t align;
|
||||
uint32_t preference;
|
||||
enum KernAux_Multiboot2_HTag_RelocatableHeader_Preference preferences : 32;
|
||||
}
|
||||
KERNAUX_PACKED;
|
||||
|
||||
|
@ -242,8 +302,6 @@ struct KernAux_Multiboot2_ITag_BootCmdLine {
|
|||
// type = 1
|
||||
// size > 8
|
||||
struct KernAux_Multiboot2_ITagBase base;
|
||||
|
||||
// DATA: char cmdline[]
|
||||
}
|
||||
KERNAUX_PACKED;
|
||||
|
||||
|
@ -253,8 +311,6 @@ struct KernAux_Multiboot2_ITag_BootLoaderName {
|
|||
// type = 2
|
||||
// size > 8
|
||||
struct KernAux_Multiboot2_ITagBase base;
|
||||
|
||||
// DATA: char name[]
|
||||
}
|
||||
KERNAUX_PACKED;
|
||||
|
||||
|
@ -267,8 +323,6 @@ struct KernAux_Multiboot2_ITag_Module {
|
|||
|
||||
uint32_t mod_start;
|
||||
uint32_t mod_end;
|
||||
|
||||
// DATA: char cmdline[]
|
||||
}
|
||||
KERNAUX_PACKED;
|
||||
|
||||
|
@ -291,7 +345,7 @@ struct KernAux_Multiboot2_ITag_BIOSBootDevice {
|
|||
// size = 20
|
||||
struct KernAux_Multiboot2_ITagBase base;
|
||||
|
||||
uint32_t biosdev;
|
||||
uint32_t bios_dev;
|
||||
uint32_t partition;
|
||||
uint32_t sub_partition;
|
||||
}
|
||||
|
@ -306,8 +360,6 @@ struct KernAux_Multiboot2_ITag_MemoryMap {
|
|||
|
||||
uint32_t entry_size;
|
||||
uint32_t entry_version;
|
||||
|
||||
// DATA: varies(entry_size) KernAux_Multiboot2_ITag_MemoryMap_EntryBase entries[]
|
||||
}
|
||||
KERNAUX_PACKED;
|
||||
|
||||
|
@ -331,7 +383,7 @@ KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_VBEInfo, 784);
|
|||
|
||||
struct KernAux_Multiboot2_ITag_FramebufferInfo {
|
||||
// type = 8
|
||||
// size > 32
|
||||
// size > 31
|
||||
struct KernAux_Multiboot2_ITagBase base;
|
||||
|
||||
uint64_t framebuffer_addr;
|
||||
|
@ -340,37 +392,25 @@ struct KernAux_Multiboot2_ITag_FramebufferInfo {
|
|||
uint32_t framebuffer_height;
|
||||
uint8_t framebuffer_bpp;
|
||||
uint8_t framebuffer_type;
|
||||
|
||||
// WARNING: GRUB 2 and Limine don't follow the spec, so we do not too!
|
||||
// Multiboot 2: https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html#Framebuffer-info
|
||||
// GRUB 2: https://github.com/rhboot/grub2/blob/7259d55ffcf124e32eafb61aa381f9856e98a708/include/multiboot2.h#L288
|
||||
// Limine: https://github.com/limine-bootloader/limine/blob/1aba6b3aeb72ac55b177132ca75ea8adfbcb78aa/common/protos/multiboot2.h#L292
|
||||
uint16_t reserved;
|
||||
|
||||
// DATA: varies color_info[]
|
||||
uint8_t reserved1;
|
||||
}
|
||||
KERNAUX_PACKED;
|
||||
|
||||
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_FramebufferInfo, 32);
|
||||
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_FramebufferInfo, 31);
|
||||
|
||||
// WARNING: GRUB 2 and Limine don't follow the spec, so we do not too!
|
||||
// Multiboot 2: https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html#ELF_002dSymbols
|
||||
// GRUB 2: https://github.com/rhboot/grub2/blob/7259d55ffcf124e32eafb61aa381f9856e98a708/include/multiboot2.h#L314-L322
|
||||
// Limine: https://github.com/limine-bootloader/limine/blob/1aba6b3aeb72ac55b177132ca75ea8adfbcb78aa/common/protos/multiboot2.h#L318-L326
|
||||
struct KernAux_Multiboot2_ITag_ELFSymbols {
|
||||
// type = 9
|
||||
// size > 20
|
||||
// size > 16
|
||||
struct KernAux_Multiboot2_ITagBase base;
|
||||
|
||||
uint32_t num;
|
||||
uint32_t entsize;
|
||||
uint32_t shndx;
|
||||
|
||||
// DATA: varies section_headers[]
|
||||
uint16_t num;
|
||||
uint16_t ent_size;
|
||||
uint16_t shndx;
|
||||
uint16_t reserved1;
|
||||
}
|
||||
KERNAUX_PACKED;
|
||||
|
||||
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_ELFSymbols, 20);
|
||||
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_ELFSymbols, 16);
|
||||
|
||||
struct KernAux_Multiboot2_ITag_APMTable {
|
||||
// type = 10
|
||||
|
@ -420,9 +460,7 @@ struct KernAux_Multiboot2_ITag_SMBIOSTables {
|
|||
|
||||
uint8_t major;
|
||||
uint8_t minor;
|
||||
uint8_t reserved[6];
|
||||
|
||||
// TODO: DATA?
|
||||
uint8_t reserved1[6];
|
||||
}
|
||||
KERNAUX_PACKED;
|
||||
|
||||
|
@ -432,8 +470,6 @@ struct KernAux_Multiboot2_ITag_ACPIOldRSDP {
|
|||
// type = 14
|
||||
// size > 8
|
||||
struct KernAux_Multiboot2_ITagBase base;
|
||||
|
||||
// TODO: DATA?
|
||||
}
|
||||
KERNAUX_PACKED;
|
||||
|
||||
|
@ -443,8 +479,6 @@ struct KernAux_Multiboot2_ITag_ACPINewRSDP {
|
|||
// type = 15
|
||||
// size > 8
|
||||
struct KernAux_Multiboot2_ITagBase base;
|
||||
|
||||
// TODO: DATA?
|
||||
}
|
||||
KERNAUX_PACKED;
|
||||
|
||||
|
@ -454,8 +488,6 @@ struct KernAux_Multiboot2_ITag_NetworkingInfo {
|
|||
// type = 16
|
||||
// size > 8
|
||||
struct KernAux_Multiboot2_ITagBase base;
|
||||
|
||||
// TODO: DATA?
|
||||
}
|
||||
KERNAUX_PACKED;
|
||||
|
||||
|
@ -468,8 +500,6 @@ struct KernAux_Multiboot2_ITag_EFIMemoryMap {
|
|||
|
||||
uint32_t descriptor_size;
|
||||
uint32_t descriptor_version;
|
||||
|
||||
// TODO: DATA?
|
||||
}
|
||||
KERNAUX_PACKED;
|
||||
|
||||
|
@ -531,33 +561,276 @@ KERNAUX_STATIC_TEST_STRUCT_SIZE(
|
|||
|
||||
#include <kernaux/macro/packing_end.run>
|
||||
|
||||
/*********
|
||||
* Enums *
|
||||
*********/
|
||||
|
||||
#include <kernaux/multiboot2/header_enums.h>
|
||||
#include <kernaux/multiboot2/info_enums.h>
|
||||
|
||||
/********************
|
||||
* Helper functions *
|
||||
* String functions *
|
||||
********************/
|
||||
|
||||
#include <kernaux/multiboot2/header_helpers.h>
|
||||
#include <kernaux/multiboot2/info_helpers.h>
|
||||
const char *KernAux_Multiboot2_Header_Arch_to_str(
|
||||
enum KernAux_Multiboot2_Header_Arch arch
|
||||
);
|
||||
|
||||
/************************
|
||||
* Validation functions *
|
||||
************************/
|
||||
const char *KernAux_Multiboot2_HTag_to_str(
|
||||
enum KernAux_Multiboot2_HTag tag_type
|
||||
);
|
||||
|
||||
#include <kernaux/multiboot2/header_is_valid.h>
|
||||
#include <kernaux/multiboot2/info_is_valid.h>
|
||||
const char *KernAux_Multiboot2_ITag_to_str(
|
||||
enum KernAux_Multiboot2_ITag tag_type
|
||||
);
|
||||
|
||||
/*******************
|
||||
* Print functions *
|
||||
*******************/
|
||||
const char *KernAux_Multiboot2_HTag_RelocatableHeader_Preference_to_str(
|
||||
enum KernAux_Multiboot2_HTag_RelocatableHeader_Preference pref
|
||||
);
|
||||
|
||||
#include <kernaux/multiboot2/header_print.h>
|
||||
#include <kernaux/multiboot2/info_print.h>
|
||||
/************************************
|
||||
* Information conversion functions *
|
||||
************************************/
|
||||
|
||||
bool KernAux_Multiboot2_Info_to_memmap(
|
||||
const struct KernAux_Multiboot2_Info *multiboot2_info,
|
||||
KernAux_MemMap memmap
|
||||
);
|
||||
|
||||
/***************************
|
||||
* Header helper functions *
|
||||
***************************/
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
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,
|
||||
const struct KernAux_Multiboot2_HTagBase *after_tag
|
||||
);
|
||||
|
||||
/********************************
|
||||
* Information helper functions *
|
||||
********************************/
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
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,
|
||||
const struct KernAux_Multiboot2_ITagBase *after_tag
|
||||
);
|
||||
|
||||
const char *KernAux_Multiboot2_Info_boot_cmd_line(
|
||||
const struct KernAux_Multiboot2_Info *multiboot2_info
|
||||
);
|
||||
|
||||
/*******************************
|
||||
* Header validation functions *
|
||||
*******************************/
|
||||
|
||||
bool KernAux_Multiboot2_Header_is_valid(
|
||||
const struct KernAux_Multiboot2_Header *multiboot2_header
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTagBase_is_valid(
|
||||
const struct KernAux_Multiboot2_HTagBase *tag_base
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_None_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_None *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_InfoReq_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_InfoReq *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_Addr_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_Addr *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_EntryAddr_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_EntryAddr *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_Flags_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_Flags *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_Framebuffer_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_Framebuffer *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_ModuleAlign_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_ModuleAlign *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_EFIBootServices_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_EFIBootServices *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_EFII386EntryAddr_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_EFII386EntryAddr *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_EFIAmd64EntryAddr_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_EFIAmd64EntryAddr *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_RelocatableHeader_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_RelocatableHeader *tag
|
||||
);
|
||||
|
||||
/************************************
|
||||
* Information validation functions *
|
||||
************************************/
|
||||
|
||||
bool KernAux_Multiboot2_Info_is_valid(
|
||||
const struct KernAux_Multiboot2_Info *multiboot2_info
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITagBase_is_valid(
|
||||
const struct KernAux_Multiboot2_ITagBase *tag_base
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_None_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_None *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_BootCmdLine_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_BootCmdLine *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_BootLoaderName_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_BootLoaderName *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_Module_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_Module *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_BasicMemoryInfo_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_BasicMemoryInfo *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_BIOSBootDevice_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_BIOSBootDevice *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_MemoryMap_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_MemoryMap *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_VBEInfo_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_VBEInfo *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_FramebufferInfo_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_FramebufferInfo *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_ELFSymbols_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_ELFSymbols *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_APMTable_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_APMTable *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_EFI32bitSystemTablePtr_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_EFI32bitSystemTablePtr *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_EFI64bitSystemTablePtr_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_EFI64bitSystemTablePtr *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_SMBIOSTables_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_SMBIOSTables *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_ACPIOldRSDP_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_ACPIOldRSDP *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_ACPINewRSDP_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_ACPINewRSDP *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_NetworkingInfo_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_NetworkingInfo *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_EFIMemoryMap_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_EFIMemoryMap *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_EFIBootServicesNotTerminated_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_EFIBootServicesNotTerminated *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_EFI32bitImageHandlePtr_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_EFI32bitImageHandlePtr *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_EFI64bitImageHandlePtr_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_EFI64bitImageHandlePtr *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_ImageLoadBasePhysAddr_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_ImageLoadBasePhysAddr *tag
|
||||
);
|
||||
|
||||
/**************************
|
||||
* Header print functions *
|
||||
**************************/
|
||||
|
||||
void KernAux_Multiboot2_Header_print(
|
||||
const struct KernAux_Multiboot2_Header *multiboot2_header,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_HTagBase_print(
|
||||
const struct KernAux_Multiboot2_HTagBase *tag_base,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
/*******************************
|
||||
* Information print functions *
|
||||
*******************************/
|
||||
|
||||
void KernAux_Multiboot2_Info_print(
|
||||
const struct KernAux_Multiboot2_Info *multiboot2_info,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITagBase_print(
|
||||
const struct KernAux_Multiboot2_ITagBase *tag_base,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_BootCmdLine_print(
|
||||
const struct KernAux_Multiboot2_ITag_BootCmdLine *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_BootLoaderName_print(
|
||||
const struct KernAux_Multiboot2_ITag_BootLoaderName *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_MemoryMap_print(
|
||||
const struct KernAux_Multiboot2_ITag_MemoryMap *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_ELFSymbols_print(
|
||||
const struct KernAux_Multiboot2_ITag_ELFSymbols *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
#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
|
|
@ -1,27 +0,0 @@
|
|||
#ifndef KERNAUX_INCLUDED_MULTIBOOT2_HEADER_HELPERS
|
||||
#define KERNAUX_INCLUDED_MULTIBOOT2_HEADER_HELPERS
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
const struct KernAux_Multiboot2_HTagBase
|
||||
*KernAux_Multiboot2_Header_first_tag_with_type(
|
||||
const struct KernAux_Multiboot2_Header *multiboot2_header,
|
||||
uint16_t tag_type
|
||||
);
|
||||
|
||||
const struct KernAux_Multiboot2_HTagBase
|
||||
*KernAux_Multiboot2_Header_tag_with_type_after(
|
||||
const struct KernAux_Multiboot2_Header *multiboot2_header,
|
||||
uint16_t tag_type,
|
||||
const struct KernAux_Multiboot2_HTagBase *after_tag
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,66 +0,0 @@
|
|||
#ifndef KERNAUX_INCLUDED_MULTIBOOT2_HEADER_IS_VALID
|
||||
#define KERNAUX_INCLUDED_MULTIBOOT2_HEADER_IS_VALID
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
bool KernAux_Multiboot2_Header_is_valid(
|
||||
const struct KernAux_Multiboot2_Header *multiboot2_header
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTagBase_is_valid(
|
||||
const struct KernAux_Multiboot2_HTagBase *tag_base
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_None_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_None *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_InfoReq_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_InfoReq *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_Addr_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_Addr *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_EntryAddr_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_EntryAddr *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_Flags_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_Flags *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_Framebuffer_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_Framebuffer *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_ModuleAlign_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_ModuleAlign *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_EFIBootServices_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_EFIBootServices *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_EFII386EntryAddr_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_EFII386EntryAddr *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_EFIAmd64EntryAddr_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_EFIAmd64EntryAddr *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_HTag_RelocatableHeader_is_valid(
|
||||
const struct KernAux_Multiboot2_HTag_RelocatableHeader *tag
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -10,13 +10,6 @@ extern "C" {
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#define KERNAUX_MULTIBOOT2_HEADER_CHECKSUM(arch, total_size) \
|
||||
((uint32_t)(-( \
|
||||
((uint32_t)KERNAUX_MULTIBOOT2_HEADER_MAGIC) + \
|
||||
((uint32_t)(arch)) + \
|
||||
((uint32_t)(total_size)) \
|
||||
)))
|
||||
|
||||
#define KERNAUX_MULTIBOOT2_HFIELDS_COMMON(name, type) \
|
||||
struct { \
|
||||
struct KernAux_Multiboot2_HTag_##type tag; \
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
#ifndef KERNAUX_INCLUDED_MULTIBOOT2_HEADER_PRINT
|
||||
#define KERNAUX_INCLUDED_MULTIBOOT2_HEADER_PRINT
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
void KernAux_Multiboot2_Header_print(
|
||||
const struct KernAux_Multiboot2_Header *multiboot2_header,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_HTagBase_print(
|
||||
const struct KernAux_Multiboot2_HTagBase *tag_base,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_HTag_None_print(
|
||||
const struct KernAux_Multiboot2_HTag_None *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_HTag_InfoReq_print(
|
||||
const struct KernAux_Multiboot2_HTag_InfoReq *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_HTag_Addr_print(
|
||||
const struct KernAux_Multiboot2_HTag_Addr *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_HTag_EntryAddr_print(
|
||||
const struct KernAux_Multiboot2_HTag_EntryAddr *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_HTag_Flags_print(
|
||||
const struct KernAux_Multiboot2_HTag_Flags *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_HTag_Framebuffer_print(
|
||||
const struct KernAux_Multiboot2_HTag_Framebuffer *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_HTag_ModuleAlign_print(
|
||||
const struct KernAux_Multiboot2_HTag_ModuleAlign *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_HTag_EFIBootServices_print(
|
||||
const struct KernAux_Multiboot2_HTag_EFIBootServices *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_HTag_EFII386EntryAddr_print(
|
||||
const struct KernAux_Multiboot2_HTag_EFII386EntryAddr *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_HTag_EFIAmd64EntryAddr_print(
|
||||
const struct KernAux_Multiboot2_HTag_EFIAmd64EntryAddr *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_HTag_RelocatableHeader_print(
|
||||
const struct KernAux_Multiboot2_HTag_RelocatableHeader *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,41 +0,0 @@
|
|||
#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
|
|
@ -1,31 +0,0 @@
|
|||
#ifndef KERNAUX_INCLUDED_MULTIBOOT2_INFO_HELPERS
|
||||
#define KERNAUX_INCLUDED_MULTIBOOT2_INFO_HELPERS
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
const struct KernAux_Multiboot2_ITagBase
|
||||
*KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
const struct KernAux_Multiboot2_Info *multiboot2_info,
|
||||
uint32_t tag_type
|
||||
);
|
||||
|
||||
const struct KernAux_Multiboot2_ITagBase
|
||||
*KernAux_Multiboot2_Info_tag_with_type_after(
|
||||
const struct KernAux_Multiboot2_Info *multiboot2_info,
|
||||
uint32_t tag_type,
|
||||
const struct KernAux_Multiboot2_ITagBase *after_tag
|
||||
);
|
||||
|
||||
const char *KernAux_Multiboot2_Info_boot_cmd_line(
|
||||
const struct KernAux_Multiboot2_Info *multiboot2_info
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,110 +0,0 @@
|
|||
#ifndef KERNAUX_INCLUDED_MULTIBOOT2_INFO_IS_VALID
|
||||
#define KERNAUX_INCLUDED_MULTIBOOT2_INFO_IS_VALID
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
bool KernAux_Multiboot2_Info_is_valid(
|
||||
const struct KernAux_Multiboot2_Info *multiboot2_info
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITagBase_is_valid(
|
||||
const struct KernAux_Multiboot2_ITagBase *tag_base
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_None_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_None *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_BootCmdLine_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_BootCmdLine *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_BootLoaderName_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_BootLoaderName *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_Module_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_Module *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_BasicMemoryInfo_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_BasicMemoryInfo *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_BIOSBootDevice_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_BIOSBootDevice *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_MemoryMap_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_MemoryMap *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_VBEInfo_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_VBEInfo *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_FramebufferInfo_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_FramebufferInfo *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_ELFSymbols_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_ELFSymbols *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_APMTable_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_APMTable *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_EFI32bitSystemTablePtr_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_EFI32bitSystemTablePtr *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_EFI64bitSystemTablePtr_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_EFI64bitSystemTablePtr *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_SMBIOSTables_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_SMBIOSTables *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_ACPIOldRSDP_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_ACPIOldRSDP *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_ACPINewRSDP_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_ACPINewRSDP *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_NetworkingInfo_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_NetworkingInfo *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_EFIMemoryMap_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_EFIMemoryMap *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_EFIBootServicesNotTerminated_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_EFIBootServicesNotTerminated *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_EFI32bitImageHandlePtr_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_EFI32bitImageHandlePtr *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_EFI64bitImageHandlePtr_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_EFI64bitImageHandlePtr *tag
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITag_ImageLoadBasePhysAddr_is_valid(
|
||||
const struct KernAux_Multiboot2_ITag_ImageLoadBasePhysAddr *tag
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,134 +0,0 @@
|
|||
#ifndef KERNAUX_INCLUDED_MULTIBOOT2_INFO_PRINT
|
||||
#define KERNAUX_INCLUDED_MULTIBOOT2_INFO_PRINT
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
void KernAux_Multiboot2_Info_print(
|
||||
const struct KernAux_Multiboot2_Info *multiboot2_info,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITagBase_print(
|
||||
const struct KernAux_Multiboot2_ITagBase *tag_base,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_None_print(
|
||||
const struct KernAux_Multiboot2_ITag_None *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_BootCmdLine_print(
|
||||
const struct KernAux_Multiboot2_ITag_BootCmdLine *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_BootLoaderName_print(
|
||||
const struct KernAux_Multiboot2_ITag_BootLoaderName *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_Module_print(
|
||||
const struct KernAux_Multiboot2_ITag_Module *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_BasicMemoryInfo_print(
|
||||
const struct KernAux_Multiboot2_ITag_BasicMemoryInfo *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_BIOSBootDevice_print(
|
||||
const struct KernAux_Multiboot2_ITag_BIOSBootDevice *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_MemoryMap_print(
|
||||
const struct KernAux_Multiboot2_ITag_MemoryMap *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_VBEInfo_print(
|
||||
const struct KernAux_Multiboot2_ITag_VBEInfo *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_FramebufferInfo_print(
|
||||
const struct KernAux_Multiboot2_ITag_FramebufferInfo *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_ELFSymbols_print(
|
||||
const struct KernAux_Multiboot2_ITag_ELFSymbols *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_APMTable_print(
|
||||
const struct KernAux_Multiboot2_ITag_APMTable *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_EFI32bitSystemTablePtr_print(
|
||||
const struct KernAux_Multiboot2_ITag_EFI32bitSystemTablePtr *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_EFI64bitSystemTablePtr_print(
|
||||
const struct KernAux_Multiboot2_ITag_EFI64bitSystemTablePtr *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_SMBIOSTables_print(
|
||||
const struct KernAux_Multiboot2_ITag_SMBIOSTables *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_ACPIOldRSDP_print(
|
||||
const struct KernAux_Multiboot2_ITag_ACPIOldRSDP *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_ACPINewRSDP_print(
|
||||
const struct KernAux_Multiboot2_ITag_ACPINewRSDP *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_NetworkingInfo_print(
|
||||
const struct KernAux_Multiboot2_ITag_NetworkingInfo *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_EFIMemoryMap_print(
|
||||
const struct KernAux_Multiboot2_ITag_EFIMemoryMap *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_EFIBootServicesNotTerminated_print(
|
||||
const struct KernAux_Multiboot2_ITag_EFIBootServicesNotTerminated *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_EFI32bitImageHandlePtr_print(
|
||||
const struct KernAux_Multiboot2_ITag_EFI32bitImageHandlePtr *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_EFI64bitImageHandlePtr_print(
|
||||
const struct KernAux_Multiboot2_ITag_EFI64bitImageHandlePtr *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
void KernAux_Multiboot2_ITag_ImageLoadBasePhysAddr_print(
|
||||
const struct KernAux_Multiboot2_ITag_ImageLoadBasePhysAddr *tag,
|
||||
KernAux_Display display
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -5,10 +5,54 @@
|
|||
#include <kernaux/multiboot2.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
const char *KernAux_Multiboot2_ITag_to_str(const uint32_t tag_type)
|
||||
{
|
||||
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"; // TODO: specify this architecture in README
|
||||
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) {
|
||||
case KERNAUX_MULTIBOOT2_ITAG_NONE:
|
||||
return "none";
|
||||
|
@ -58,3 +102,18 @@ const char *KernAux_Multiboot2_ITag_to_str(const uint32_t tag_type)
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
#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 uint16_t tag_type
|
||||
const enum KernAux_Multiboot2_HTag 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 uint16_t tag_type,
|
||||
const enum KernAux_Multiboot2_HTag tag_type,
|
||||
const struct KernAux_Multiboot2_HTagBase *const after_tag
|
||||
) {
|
||||
KERNAUX_ASSERT(multiboot2_header);
|
||||
|
|
|
@ -248,11 +248,12 @@ bool KernAux_Multiboot2_HTag_RelocatableHeader_is_valid(
|
|||
tag->base.type == KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER &&
|
||||
tag->base.size == 24 &&
|
||||
tag->min_addr <= tag->max_addr
|
||||
// TODO: additional requirements?
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (tag->preference) {
|
||||
switch (tag->preferences) {
|
||||
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;
|
||||
|
|
|
@ -7,94 +7,12 @@
|
|||
#include <kernaux/macro.h>
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define PRINT(s) do { KernAux_Display_print (display, s); } while (0)
|
||||
#define PRINTLN(s) do { KernAux_Display_println(display, s); } while (0)
|
||||
|
||||
#define PRINTF(format, ...) \
|
||||
do { KernAux_Display_printf (display, format, __VA_ARGS__); } while (0)
|
||||
#define PRINTLN(s) KernAux_Display_println(display, s)
|
||||
#define PRINTLNF(format, ...) \
|
||||
do { KernAux_Display_printlnf(display, format, __VA_ARGS__); } while (0)
|
||||
|
||||
#define HEADER(Type) do { \
|
||||
KERNAUX_ASSERT(tag); \
|
||||
KERNAUX_ASSERT(display); \
|
||||
\
|
||||
if (!KernAux_Multiboot2_HTag_##Type##_is_valid(tag)) { \
|
||||
PRINTLN("Multiboot 2 header tag // invalid!"); \
|
||||
} \
|
||||
\
|
||||
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: %lu (%s)", \
|
||||
type, \
|
||||
KernAux_Multiboot2_HTag_to_str(tag->base.type) \
|
||||
); \
|
||||
PRINT (" u16 flags: "); \
|
||||
KernAux_Multiboot2_HTagBase_Flags_print( \
|
||||
tag->base.flags, \
|
||||
display, \
|
||||
2, \
|
||||
2, \
|
||||
false \
|
||||
); \
|
||||
PRINTLNF(" u32 size: %lu", size); \
|
||||
} while (0)
|
||||
|
||||
#define FOOTER do { PRINTLN("}"); } while (0)
|
||||
|
||||
#define INDENT do { \
|
||||
for (unsigned index = 0; index < basic_indentation; ++index) PRINT(" "); \
|
||||
} while (0)
|
||||
|
||||
#define INDENT_MORE do { \
|
||||
for (unsigned index = 0; index < indentation_delta; ++index) PRINT(" "); \
|
||||
} while (0)
|
||||
|
||||
static const struct {
|
||||
uint32_t number;
|
||||
const char *name;
|
||||
} base_flag_names[] = {
|
||||
{
|
||||
.number = KERNAUX_MULTIBOOT2_HTAG_BASE_FLAG_OPTIONAL,
|
||||
.name = "OPTIONAL",
|
||||
},
|
||||
};
|
||||
|
||||
static const struct {
|
||||
uint32_t number;
|
||||
const char *name;
|
||||
} console_flag_names[] = {
|
||||
{
|
||||
.number = KERNAUX_MULTIBOOT2_HTAG_FLAGS_REQUIRE_CONSOLE,
|
||||
.name = "REQUIRE_CONSOLE",
|
||||
},
|
||||
{
|
||||
.number = KERNAUX_MULTIBOOT2_HTAG_FLAGS_EGA_SUPPORT,
|
||||
.name = "EGA_SUPPORT",
|
||||
}
|
||||
};
|
||||
|
||||
static void KernAux_Multiboot2_HTagBase_Flags_print(
|
||||
uint16_t flags,
|
||||
KernAux_Display display,
|
||||
unsigned basic_indentation,
|
||||
unsigned indentation_delta,
|
||||
bool indent_first
|
||||
);
|
||||
|
||||
static void KernAux_Multiboot2_HTag_Flags_ConsoleFlags_print(
|
||||
uint32_t console_flags,
|
||||
KernAux_Display display,
|
||||
unsigned basic_indentation,
|
||||
unsigned indentation_delta,
|
||||
bool indent_first
|
||||
);
|
||||
KernAux_Display_printlnf(display, format, __VA_ARGS__)
|
||||
|
||||
void KernAux_Multiboot2_Header_print(
|
||||
const struct KernAux_Multiboot2_Header *const multiboot2_header,
|
||||
|
@ -104,19 +22,17 @@ 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: %lu (%s)",
|
||||
arch,
|
||||
PRINTLN("Multiboot 2 header");
|
||||
PRINTLNF(" magic: %lu", magic);
|
||||
PRINTLNF(" arch: %u (%s)",
|
||||
multiboot2_header->arch,
|
||||
KernAux_Multiboot2_Header_Arch_to_str(multiboot2_header->arch)
|
||||
);
|
||||
PRINTLNF(" u32 size: %lu", total_size);
|
||||
PRINTLNF(" u32 checksum: 0x%lx", checksum);
|
||||
PRINTLN("}");
|
||||
PRINTLNF(" size: %lu", total_size);
|
||||
PRINTLNF(" checksum: %lu", checksum);
|
||||
|
||||
const struct KernAux_Multiboot2_HTagBase *tag_base =
|
||||
(struct KernAux_Multiboot2_HTagBase*)
|
||||
|
@ -127,7 +43,9 @@ void KernAux_Multiboot2_Header_print(
|
|||
((uint8_t*)multiboot2_header + multiboot2_header->total_size))
|
||||
{
|
||||
if (!KernAux_Multiboot2_HTagBase_is_valid(tag_base)) return;
|
||||
|
||||
KernAux_Multiboot2_HTagBase_print(tag_base, display);
|
||||
|
||||
tag_base = KERNAUX_MULTIBOOT2_HTAG_NEXT(tag_base);
|
||||
}
|
||||
}
|
||||
|
@ -139,330 +57,71 @@ void KernAux_Multiboot2_HTagBase_print(
|
|||
KERNAUX_ASSERT(tag_base);
|
||||
KERNAUX_ASSERT(display);
|
||||
|
||||
if (!KernAux_Multiboot2_HTagBase_is_valid(tag_base)) return;
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, flags, tag_base->flags);
|
||||
KERNAUX_CAST_CONST(unsigned long, size, tag_base->size);
|
||||
|
||||
PRINTLN("Multiboot 2 header tag");
|
||||
PRINTLNF(" type: %u (%s)",
|
||||
tag_base->type,
|
||||
KernAux_Multiboot2_HTag_to_str(tag_base->type)
|
||||
);
|
||||
PRINTLNF(" flags: %lu", flags);
|
||||
PRINTLNF(" size: %lu", size);
|
||||
|
||||
switch (tag_base->type) {
|
||||
case KERNAUX_MULTIBOOT2_HTAG_NONE:
|
||||
KernAux_Multiboot2_HTag_None_print(
|
||||
(struct KernAux_Multiboot2_HTag_None*)tag_base,
|
||||
display
|
||||
);
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_HTAG_INFO_REQ:
|
||||
KernAux_Multiboot2_HTag_InfoReq_print(
|
||||
(struct KernAux_Multiboot2_HTag_InfoReq*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
// TODO: print
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_HTAG_ADDR:
|
||||
KernAux_Multiboot2_HTag_Addr_print(
|
||||
(struct KernAux_Multiboot2_HTag_Addr*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
// TODO: print
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_HTAG_ENTRY_ADDR:
|
||||
KernAux_Multiboot2_HTag_EntryAddr_print(
|
||||
(struct KernAux_Multiboot2_HTag_EntryAddr*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
// TODO: print
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_HTAG_FLAGS:
|
||||
KernAux_Multiboot2_HTag_Flags_print(
|
||||
(struct KernAux_Multiboot2_HTag_Flags*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
// TODO: print
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_HTAG_FRAMEBUFFER:
|
||||
KernAux_Multiboot2_HTag_Framebuffer_print(
|
||||
(struct KernAux_Multiboot2_HTag_Framebuffer*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
// TODO: print
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_HTAG_MODULE_ALIGN:
|
||||
KernAux_Multiboot2_HTag_ModuleAlign_print(
|
||||
(struct KernAux_Multiboot2_HTag_ModuleAlign*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
// TODO: print
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_HTAG_EFI_BOOT_SERVICES:
|
||||
KernAux_Multiboot2_HTag_EFIBootServices_print(
|
||||
(struct KernAux_Multiboot2_HTag_EFIBootServices*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
// TODO: print
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_HTAG_EFI_I386_ENTRY_ADDR:
|
||||
KernAux_Multiboot2_HTag_EFII386EntryAddr_print(
|
||||
(struct KernAux_Multiboot2_HTag_EFII386EntryAddr*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
// TODO: print
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_HTAG_EFI_AMD64_ENTRY_ADDR:
|
||||
KernAux_Multiboot2_HTag_EFIAmd64EntryAddr_print(
|
||||
(struct KernAux_Multiboot2_HTag_EFIAmd64EntryAddr*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
// TODO: print
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER:
|
||||
KernAux_Multiboot2_HTag_RelocatableHeader_print(
|
||||
(struct KernAux_Multiboot2_HTag_RelocatableHeader*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
// TODO: print
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_HTag_None_print(
|
||||
const struct KernAux_Multiboot2_HTag_None *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(None);
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_HTag_InfoReq_print(
|
||||
const struct KernAux_Multiboot2_HTag_InfoReq *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(InfoReq);
|
||||
|
||||
// Print data:
|
||||
|
||||
PRINTLN(" u32 mbi_tag_types[]: [");
|
||||
|
||||
const uint32_t *const mbi_tag_types =
|
||||
(const uint32_t*)KERNAUX_MULTIBOOT2_DATA(tag);
|
||||
|
||||
for (
|
||||
size_t index = 0;
|
||||
index < (tag->base.size - sizeof(*tag)) / sizeof(uint32_t);
|
||||
++index
|
||||
) {
|
||||
KERNAUX_CAST_CONST(unsigned long, type, mbi_tag_types[index]);
|
||||
|
||||
PRINTLNF(" %lu (%s)",
|
||||
type,
|
||||
KernAux_Multiboot2_ITag_to_str(type)
|
||||
);
|
||||
}
|
||||
|
||||
PRINTLN(" ]");
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_HTag_Addr_print(
|
||||
const struct KernAux_Multiboot2_HTag_Addr *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(Addr);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, header_addr, tag->header_addr);
|
||||
KERNAUX_CAST_CONST(unsigned long, load_addr, tag->load_addr);
|
||||
KERNAUX_CAST_CONST(unsigned long, load_end_addr, tag->load_end_addr);
|
||||
KERNAUX_CAST_CONST(unsigned long, bss_end_addr, tag->bss_end_addr);
|
||||
|
||||
PRINTLNF(" u32 header_addr: 0x%lx", header_addr);
|
||||
PRINTLNF(" u32 load_addr: 0x%lx", load_addr);
|
||||
PRINTLNF(" u32 load_end_addr: 0x%lx", load_end_addr);
|
||||
PRINTLNF(" u32 bss_end_addr: 0x%lx", bss_end_addr);
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_HTag_EntryAddr_print(
|
||||
const struct KernAux_Multiboot2_HTag_EntryAddr *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(EntryAddr);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, entry_addr, tag->entry_addr);
|
||||
|
||||
PRINTLNF(" u32 entry_addr: 0x%lx", entry_addr);
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_HTag_Flags_print(
|
||||
const struct KernAux_Multiboot2_HTag_Flags *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(Flags);
|
||||
|
||||
PRINT(" u32 console_flags: ");
|
||||
KernAux_Multiboot2_HTag_Flags_ConsoleFlags_print(
|
||||
tag->console_flags,
|
||||
display,
|
||||
2,
|
||||
2,
|
||||
false
|
||||
);
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_HTag_Framebuffer_print(
|
||||
const struct KernAux_Multiboot2_HTag_Framebuffer *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(Framebuffer);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, width, tag->width);
|
||||
KERNAUX_CAST_CONST(unsigned long, height, tag->height);
|
||||
KERNAUX_CAST_CONST(unsigned long, depth, tag->depth);
|
||||
|
||||
PRINTLNF(" u32 width: %lu", width);
|
||||
PRINTLNF(" u32 height: %lu", height);
|
||||
PRINTLNF(" u32 depth: %lu", depth);
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_HTag_ModuleAlign_print(
|
||||
const struct KernAux_Multiboot2_HTag_ModuleAlign *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(ModuleAlign);
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_HTag_EFIBootServices_print(
|
||||
const struct KernAux_Multiboot2_HTag_EFIBootServices *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(EFIBootServices);
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_HTag_EFII386EntryAddr_print(
|
||||
const struct KernAux_Multiboot2_HTag_EFII386EntryAddr *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(EFII386EntryAddr);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, entry_addr, tag->entry_addr);
|
||||
|
||||
PRINTLNF(" u32 entry_addr: 0x%lx", entry_addr);
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_HTag_EFIAmd64EntryAddr_print(
|
||||
const struct KernAux_Multiboot2_HTag_EFIAmd64EntryAddr *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(EFIAmd64EntryAddr);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, entry_addr, tag->entry_addr);
|
||||
|
||||
PRINTLNF(" u32 entry_addr: 0x%lx", entry_addr);
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_HTag_RelocatableHeader_print(
|
||||
const struct KernAux_Multiboot2_HTag_RelocatableHeader *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
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, 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;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_HTagBase_Flags_print(
|
||||
const uint16_t flags,
|
||||
const KernAux_Display display,
|
||||
const unsigned basic_indentation,
|
||||
const unsigned indentation_delta,
|
||||
const bool indent_first
|
||||
) {
|
||||
KERNAUX_CAST_CONST(unsigned long, flags_ul, flags);
|
||||
|
||||
if (indent_first) INDENT;
|
||||
PRINTF("0x%lx (", flags_ul);
|
||||
|
||||
bool is_first = true;
|
||||
|
||||
for (
|
||||
size_t index = 0;
|
||||
index < sizeof(base_flag_names) / sizeof(base_flag_names[0]);
|
||||
++index
|
||||
) {
|
||||
if (flags & base_flag_names[index].number) {
|
||||
if (is_first) {
|
||||
PRINTLN("");
|
||||
} else {
|
||||
PRINTLN(" |");
|
||||
}
|
||||
|
||||
INDENT;
|
||||
INDENT_MORE;
|
||||
PRINTF("%s", base_flag_names[index].name);
|
||||
is_first = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_first) {
|
||||
PRINTLN(")");
|
||||
} else {
|
||||
PRINTLN("");
|
||||
INDENT;
|
||||
PRINTLN(")");
|
||||
}
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_HTag_Flags_ConsoleFlags_print(
|
||||
const uint32_t console_flags,
|
||||
const KernAux_Display display,
|
||||
const unsigned basic_indentation,
|
||||
const unsigned indentation_delta,
|
||||
const bool indent_first
|
||||
) {
|
||||
KERNAUX_CAST_CONST(unsigned long, console_flags_ul, console_flags);
|
||||
|
||||
if (indent_first) INDENT;
|
||||
PRINTF("0x%lx (", console_flags_ul);
|
||||
|
||||
bool is_first = true;
|
||||
|
||||
for (
|
||||
size_t index = 0;
|
||||
index < sizeof(console_flag_names) / sizeof(console_flag_names[0]);
|
||||
++index
|
||||
) {
|
||||
if (console_flags & console_flag_names[index].number) {
|
||||
if (is_first) {
|
||||
PRINTLN("");
|
||||
} else {
|
||||
PRINTLN(" |");
|
||||
}
|
||||
|
||||
INDENT;
|
||||
INDENT_MORE;
|
||||
PRINTF("%s", console_flag_names[index].name);
|
||||
is_first = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_first) {
|
||||
PRINTLN(")");
|
||||
} else {
|
||||
PRINTLN("");
|
||||
INDENT;
|
||||
PRINTLN(")");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <kernaux/assert.h>
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
#ifdef WITH_MEMMAP
|
||||
#include <kernaux/memmap.h>
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef WITH_MEMMAP
|
||||
// TODO: implement this
|
||||
bool KernAux_Multiboot2_Info_to_memmap(
|
||||
const struct KernAux_Multiboot2_Info *multiboot2_info,
|
||||
KernAux_MemMap memmap
|
||||
) {
|
||||
KERNAUX_ASSERT(multiboot2_info);
|
||||
|
||||
KernAux_MemMap_init(memmap, 0);
|
||||
if (!KernAux_Multiboot2_Info_is_valid(multiboot2_info)) return false;
|
||||
|
||||
const struct KernAux_Multiboot2_ITagBase *const basic_memory_info_tag_base =
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_BASIC_MEMORY_INFO
|
||||
);
|
||||
const struct KernAux_Multiboot2_ITagBase *const memory_map_tag_base =
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_MEMORY_MAP
|
||||
);
|
||||
|
||||
// FIXME: Basic memory info tag may not be provided by some boot loaders on
|
||||
// EFI platforms if EFI boot services are enabled and available for the
|
||||
// loaded image (EFI boot services not terminated tag exists in Multiboot2
|
||||
// information structure).
|
||||
if (basic_memory_info_tag_base == NULL || memory_map_tag_base == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const struct KernAux_Multiboot2_ITag_BasicMemoryInfo *const
|
||||
basic_memory_info_tag =
|
||||
(const struct KernAux_Multiboot2_ITag_BasicMemoryInfo*)
|
||||
basic_memory_info_tag_base;
|
||||
const struct KernAux_Multiboot2_ITag_MemoryMap *const
|
||||
memory_map_tag =
|
||||
(const struct KernAux_Multiboot2_ITag_MemoryMap*)
|
||||
memory_map_tag_base;
|
||||
|
||||
// FIXME: The value returned for upper memory is maximally the address of
|
||||
// the first upper memory hole minus 1 megabyte. It is not guaranteed to be
|
||||
// this value.
|
||||
const size_t memory_size = (size_t)basic_memory_info_tag->mem_upper * 1024;
|
||||
KernAux_MemMap_init(memmap, memory_size);
|
||||
|
||||
(void)memory_map_tag;
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
|
@ -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 uint32_t tag_type
|
||||
const enum KernAux_Multiboot2_ITag 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 uint32_t tag_type,
|
||||
const enum KernAux_Multiboot2_ITag tag_type,
|
||||
const struct KernAux_Multiboot2_ITagBase *const after_tag
|
||||
) {
|
||||
KERNAUX_ASSERT(multiboot2_info);
|
||||
|
|
|
@ -287,7 +287,7 @@ bool KernAux_Multiboot2_ITag_FramebufferInfo_is_valid(
|
|||
KERNAUX_ASSERT(tag);
|
||||
return (
|
||||
tag->base.type == KERNAUX_MULTIBOOT2_ITAG_FRAMEBUFFER_INFO &&
|
||||
tag->base.size >= 32
|
||||
tag->base.size >= 31
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -297,10 +297,10 @@ bool KernAux_Multiboot2_ITag_ELFSymbols_is_valid(
|
|||
KERNAUX_ASSERT(tag);
|
||||
return (
|
||||
tag->base.type == KERNAUX_MULTIBOOT2_ITAG_ELF_SYMBOLS &&
|
||||
tag->base.size >= 20 &&
|
||||
tag->base.size >= 16 &&
|
||||
(
|
||||
tag->entsize == 0 ||
|
||||
(tag->base.size - 20) % tag->entsize == 0
|
||||
tag->ent_size == 0 ||
|
||||
(tag->base.size - 16) % tag->ent_size == 0
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -3,41 +3,18 @@
|
|||
#endif
|
||||
|
||||
#include <kernaux/assert.h>
|
||||
#include <kernaux/generic/display.h>
|
||||
#include <kernaux/macro.h>
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define PRINT(s) do { KernAux_Display_print (display, s); } while (0)
|
||||
#define PRINTLN(s) do { KernAux_Display_println(display, s); } while (0)
|
||||
// TODO: create macro for this
|
||||
#define INT_IF(a, b) (sizeof(int) == sizeof(long) ? (a) : (b))
|
||||
|
||||
#define PRINTF(format, ...) \
|
||||
do { KernAux_Display_printf (display, format, __VA_ARGS__); } while (0)
|
||||
#define PRINTLN(s) KernAux_Display_println(display, s)
|
||||
#define PRINTLNF(format, ...) \
|
||||
do { KernAux_Display_printlnf(display, format, __VA_ARGS__); } while (0)
|
||||
|
||||
#define HEADER(Type) do { \
|
||||
KERNAUX_ASSERT(tag); \
|
||||
KERNAUX_ASSERT(display); \
|
||||
\
|
||||
if (!KernAux_Multiboot2_ITag_##Type##_is_valid(tag)) { \
|
||||
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: %lu (%s)", \
|
||||
type, \
|
||||
KernAux_Multiboot2_ITag_to_str(tag->base.type) \
|
||||
); \
|
||||
PRINTLNF(" u32 size: %lu", size); \
|
||||
} while (0)
|
||||
|
||||
#define FOOTER do { PRINTLN("}"); } while (0)
|
||||
KernAux_Display_printlnf(display, format, __VA_ARGS__)
|
||||
|
||||
void KernAux_Multiboot2_Info_print(
|
||||
const struct KernAux_Multiboot2_Info *const multiboot2_info,
|
||||
|
@ -47,12 +24,11 @@ void KernAux_Multiboot2_Info_print(
|
|||
KERNAUX_ASSERT(display);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, total_size, multiboot2_info->total_size);
|
||||
KERNAUX_CAST_CONST(unsigned long, reserved, multiboot2_info->reserved);
|
||||
KERNAUX_CAST_CONST(unsigned long, reserved1, multiboot2_info->reserved1);
|
||||
|
||||
PRINTLN("Multiboot 2 info {");
|
||||
PRINTLNF(" u32 size: %lu", total_size);
|
||||
PRINTLNF(" u32 reserved: 0x%lx", reserved);
|
||||
PRINTLN("}");
|
||||
PRINTLN("Multiboot 2 info");
|
||||
PRINTLNF(" size: %lu", total_size);
|
||||
PRINTLNF(" reserved1: %lu", reserved1);
|
||||
|
||||
const struct KernAux_Multiboot2_ITagBase *tag_base =
|
||||
(struct KernAux_Multiboot2_ITagBase*)
|
||||
|
@ -63,7 +39,9 @@ void KernAux_Multiboot2_Info_print(
|
|||
((uint8_t*)multiboot2_info + multiboot2_info->total_size))
|
||||
{
|
||||
if (!KernAux_Multiboot2_ITagBase_is_valid(tag_base)) return;
|
||||
|
||||
KernAux_Multiboot2_ITagBase_print(tag_base, display);
|
||||
|
||||
tag_base = KERNAUX_MULTIBOOT2_ITAG_NEXT(tag_base);
|
||||
}
|
||||
}
|
||||
|
@ -75,12 +53,20 @@ void KernAux_Multiboot2_ITagBase_print(
|
|||
KERNAUX_ASSERT(tag_base);
|
||||
KERNAUX_ASSERT(display);
|
||||
|
||||
if (!KernAux_Multiboot2_ITagBase_is_valid(tag_base)) return;
|
||||
|
||||
PRINTLN("Multiboot 2 info tag");
|
||||
|
||||
PRINTLNF(" type: %u (%s)",
|
||||
tag_base->type,
|
||||
KernAux_Multiboot2_ITag_to_str(tag_base->type)
|
||||
);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, size, tag_base->size);
|
||||
PRINTLNF(" size: %lu", size);
|
||||
|
||||
switch (tag_base->type) {
|
||||
case KERNAUX_MULTIBOOT2_ITAG_NONE:
|
||||
KernAux_Multiboot2_ITag_None_print(
|
||||
(struct KernAux_Multiboot2_ITag_None*)tag_base,
|
||||
display
|
||||
);
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_ITAG_BOOT_CMD_LINE:
|
||||
KernAux_Multiboot2_ITag_BootCmdLine_print(
|
||||
|
@ -95,22 +81,43 @@ void KernAux_Multiboot2_ITagBase_print(
|
|||
);
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_ITAG_MODULE:
|
||||
KernAux_Multiboot2_ITag_Module_print(
|
||||
(struct KernAux_Multiboot2_ITag_Module*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
const struct KernAux_Multiboot2_ITag_Module *const tag_module =
|
||||
(struct KernAux_Multiboot2_ITag_Module*)tag_base;
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, mod_start, tag_module->mod_start);
|
||||
KERNAUX_CAST_CONST(unsigned long, mod_end, tag_module->mod_end);
|
||||
|
||||
PRINTLNF(" start: %lu", mod_start);
|
||||
PRINTLNF(" end: %lu", mod_end);
|
||||
PRINTLNF(" cmdline: %s", KERNAUX_MULTIBOOT2_DATA(tag_module));
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_ITAG_BASIC_MEMORY_INFO:
|
||||
KernAux_Multiboot2_ITag_BasicMemoryInfo_print(
|
||||
(struct KernAux_Multiboot2_ITag_BasicMemoryInfo*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
const struct KernAux_Multiboot2_ITag_BasicMemoryInfo *const tag_bmi =
|
||||
(struct KernAux_Multiboot2_ITag_BasicMemoryInfo*)tag_base;
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, mem_lower, tag_bmi->mem_lower);
|
||||
KERNAUX_CAST_CONST(unsigned long, mem_upper, tag_bmi->mem_upper);
|
||||
|
||||
PRINTLNF(" mem lower: %lu", mem_lower);
|
||||
PRINTLNF(" mem upper: %lu", mem_upper);
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_ITAG_BIOS_BOOT_DEVICE:
|
||||
KernAux_Multiboot2_ITag_BIOSBootDevice_print(
|
||||
(struct KernAux_Multiboot2_ITag_BIOSBootDevice*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
const struct KernAux_Multiboot2_ITag_BIOSBootDevice *const tag_bbd =
|
||||
(struct KernAux_Multiboot2_ITag_BIOSBootDevice*)tag_base;
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, bios_dev, tag_bbd->bios_dev);
|
||||
KERNAUX_CAST_CONST(unsigned long, partition, tag_bbd->partition);
|
||||
KERNAUX_CAST_CONST(unsigned long, sub_partition, tag_bbd->sub_partition);
|
||||
|
||||
PRINTLNF(" bios dev: %lu", bios_dev);
|
||||
PRINTLNF(" partition: %lu", partition);
|
||||
PRINTLNF(" sub_partition: %lu", sub_partition);
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_ITAG_MEMORY_MAP:
|
||||
KernAux_Multiboot2_ITag_MemoryMap_print(
|
||||
|
@ -119,16 +126,42 @@ void KernAux_Multiboot2_ITagBase_print(
|
|||
);
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_ITAG_VBE_INFO:
|
||||
KernAux_Multiboot2_ITag_VBEInfo_print(
|
||||
(struct KernAux_Multiboot2_ITag_VBEInfo*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
const struct KernAux_Multiboot2_ITag_VBEInfo *const tag_vbe =
|
||||
(struct KernAux_Multiboot2_ITag_VBEInfo*)tag_base;
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, vbe_mode, tag_vbe->vbe_mode);
|
||||
KERNAUX_CAST_CONST(unsigned long, vbe_interface_seg, tag_vbe->vbe_interface_seg);
|
||||
KERNAUX_CAST_CONST(unsigned long, vbe_interface_off, tag_vbe->vbe_interface_off);
|
||||
KERNAUX_CAST_CONST(unsigned long, vbe_interface_len, tag_vbe->vbe_interface_len);
|
||||
|
||||
PRINTLNF(" VBE mode: %lu", vbe_mode);
|
||||
PRINTLNF(" VBE interface seg: %lu", vbe_interface_seg);
|
||||
PRINTLNF(" VBE interface off: %lu", vbe_interface_off);
|
||||
PRINTLNF(" VBE interface len: %lu", vbe_interface_len);
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_ITAG_FRAMEBUFFER_INFO:
|
||||
KernAux_Multiboot2_ITag_FramebufferInfo_print(
|
||||
(struct KernAux_Multiboot2_ITag_FramebufferInfo*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
const struct KernAux_Multiboot2_ITag_FramebufferInfo *const tag_fb =
|
||||
(struct KernAux_Multiboot2_ITag_FramebufferInfo*)tag_base;
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long long, framebuffer_addr, tag_fb->framebuffer_addr);
|
||||
KERNAUX_CAST_CONST(unsigned long, framebuffer_pitch, tag_fb->framebuffer_pitch);
|
||||
KERNAUX_CAST_CONST(unsigned long, framebuffer_width, tag_fb->framebuffer_width);
|
||||
KERNAUX_CAST_CONST(unsigned long, framebuffer_height, tag_fb->framebuffer_height);
|
||||
KERNAUX_CAST_CONST(unsigned long, framebuffer_bpp, tag_fb->framebuffer_bpp);
|
||||
KERNAUX_CAST_CONST(unsigned long, framebuffer_type, tag_fb->framebuffer_type);
|
||||
KERNAUX_CAST_CONST(unsigned long, reserved1, tag_fb->reserved1);
|
||||
|
||||
PRINTLNF(" framebuffer addr: %llu", framebuffer_addr);
|
||||
PRINTLNF(" framebuffer pitch: %lu", framebuffer_pitch);
|
||||
PRINTLNF(" framebuffer width: %lu", framebuffer_width);
|
||||
PRINTLNF(" framebuffer height: %lu", framebuffer_height);
|
||||
PRINTLNF(" framebuffer bpp: %lu", framebuffer_bpp);
|
||||
PRINTLNF(" framebuffer type: %lu", framebuffer_type);
|
||||
PRINTLNF(" reserved1: %lu", reserved1);
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_ITAG_ELF_SYMBOLS:
|
||||
KernAux_Multiboot2_ITag_ELFSymbols_print(
|
||||
|
@ -137,178 +170,159 @@ void KernAux_Multiboot2_ITagBase_print(
|
|||
);
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_ITAG_APM_TABLE:
|
||||
KernAux_Multiboot2_ITag_APMTable_print(
|
||||
(struct KernAux_Multiboot2_ITag_APMTable*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
const struct KernAux_Multiboot2_ITag_APMTable *const tag_apm =
|
||||
(struct KernAux_Multiboot2_ITag_APMTable*)tag_base;
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, version, tag_apm->version);
|
||||
KERNAUX_CAST_CONST(unsigned long, cseg, tag_apm->cseg);
|
||||
KERNAUX_CAST_CONST(unsigned long, offset, tag_apm->offset);
|
||||
KERNAUX_CAST_CONST(unsigned long, cseg_16, tag_apm->cseg_16);
|
||||
KERNAUX_CAST_CONST(unsigned long, dseg, tag_apm->dseg);
|
||||
KERNAUX_CAST_CONST(unsigned long, flags, tag_apm->flags);
|
||||
KERNAUX_CAST_CONST(unsigned long, cseg_len, tag_apm->cseg_len);
|
||||
KERNAUX_CAST_CONST(unsigned long, cseg_16_len, tag_apm->cseg_16_len);
|
||||
KERNAUX_CAST_CONST(unsigned long, dseg_len, tag_apm->dseg_len);
|
||||
|
||||
PRINTLNF(" version: %lu", version);
|
||||
PRINTLNF(" cseg: %lu", cseg);
|
||||
PRINTLNF(" offset: %lu", offset);
|
||||
PRINTLNF(" cseg 16: %lu", cseg_16);
|
||||
PRINTLNF(" dseg: %lu", dseg);
|
||||
PRINTLNF(" flags: %lu", flags);
|
||||
PRINTLNF(" cseg len: %lu", cseg_len);
|
||||
PRINTLNF(" cseg 16 len: %lu", cseg_16_len);
|
||||
PRINTLNF(" dseg len: %lu", dseg_len);
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_SYSTEM_TABLE_PTR:
|
||||
KernAux_Multiboot2_ITag_EFI32bitSystemTablePtr_print(
|
||||
(struct KernAux_Multiboot2_ITag_EFI32bitSystemTablePtr*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
// TODO: print
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_SYSTEM_TABLE_PTR:
|
||||
KernAux_Multiboot2_ITag_EFI64bitSystemTablePtr_print(
|
||||
(struct KernAux_Multiboot2_ITag_EFI64bitSystemTablePtr*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
// TODO: print
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_ITAG_SMBIOS_TABLES:
|
||||
KernAux_Multiboot2_ITag_SMBIOSTables_print(
|
||||
(struct KernAux_Multiboot2_ITag_SMBIOSTables*)tag_base,
|
||||
display
|
||||
{
|
||||
const struct KernAux_Multiboot2_ITag_SMBIOSTables *const tag_smbios =
|
||||
(struct KernAux_Multiboot2_ITag_SMBIOSTables*)tag_base;
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, major, tag_smbios->major);
|
||||
KERNAUX_CAST_CONST(unsigned long, minor, tag_smbios->minor);
|
||||
KERNAUX_CAST_CONST(unsigned long, reserved0, tag_smbios->reserved1[0]);
|
||||
KERNAUX_CAST_CONST(unsigned long, reserved1, tag_smbios->reserved1[1]);
|
||||
KERNAUX_CAST_CONST(unsigned long, reserved2, tag_smbios->reserved1[2]);
|
||||
KERNAUX_CAST_CONST(unsigned long, reserved3, tag_smbios->reserved1[3]);
|
||||
KERNAUX_CAST_CONST(unsigned long, reserved4, tag_smbios->reserved1[4]);
|
||||
KERNAUX_CAST_CONST(unsigned long, reserved5, tag_smbios->reserved1[5]);
|
||||
|
||||
PRINTLNF(" major: %lu", major);
|
||||
PRINTLNF(" minor: %lu", minor);
|
||||
|
||||
PRINTLNF(
|
||||
" reserved1: {%lu, %lu, %lu, %lu, %lu, %lu}",
|
||||
reserved0, reserved1, reserved2,
|
||||
reserved3, reserved4, reserved5
|
||||
);
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_ITAG_ACPI_OLD_RSDP:
|
||||
KernAux_Multiboot2_ITag_ACPIOldRSDP_print(
|
||||
(struct KernAux_Multiboot2_ITag_ACPIOldRSDP*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
// TODO: print
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_ITAG_ACPI_NEW_RSDP:
|
||||
KernAux_Multiboot2_ITag_ACPINewRSDP_print(
|
||||
(struct KernAux_Multiboot2_ITag_ACPINewRSDP*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
// TODO: print
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_ITAG_NETWORKING_INFO:
|
||||
KernAux_Multiboot2_ITag_NetworkingInfo_print(
|
||||
(struct KernAux_Multiboot2_ITag_NetworkingInfo*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
// TODO: print
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_ITAG_EFI_MEMORY_MAP:
|
||||
KernAux_Multiboot2_ITag_EFIMemoryMap_print(
|
||||
(struct KernAux_Multiboot2_ITag_EFIMemoryMap*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
// TODO: print
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_ITAG_EFI_BOOT_SERVICES_NOT_TERMINATED:
|
||||
KernAux_Multiboot2_ITag_EFIBootServicesNotTerminated_print(
|
||||
(struct KernAux_Multiboot2_ITag_EFIBootServicesNotTerminated*)
|
||||
tag_base,
|
||||
display
|
||||
);
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_IMAGE_HANDLE_PTR:
|
||||
KernAux_Multiboot2_ITag_EFI32bitImageHandlePtr_print(
|
||||
(struct KernAux_Multiboot2_ITag_EFI32bitImageHandlePtr*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
// TODO: print
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_IMAGE_HANDLE_PTR:
|
||||
KernAux_Multiboot2_ITag_EFI64bitImageHandlePtr_print(
|
||||
(struct KernAux_Multiboot2_ITag_EFI64bitImageHandlePtr*)tag_base,
|
||||
display
|
||||
);
|
||||
{
|
||||
// TODO: print
|
||||
}
|
||||
break;
|
||||
case KERNAUX_MULTIBOOT2_ITAG_IMAGE_LOAD_BASE_PHYS_ADDR:
|
||||
KernAux_Multiboot2_ITag_ImageLoadBasePhysAddr_print(
|
||||
(struct KernAux_Multiboot2_ITag_ImageLoadBasePhysAddr*)tag_base,
|
||||
display
|
||||
{
|
||||
KERNAUX_CAST_CONST(
|
||||
unsigned long,
|
||||
load_base_addr,
|
||||
((struct KernAux_Multiboot2_ITag_ImageLoadBasePhysAddr*)
|
||||
tag_base)->load_base_addr
|
||||
);
|
||||
PRINTLNF(" load base addr: %lu", load_base_addr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_None_print(
|
||||
const struct KernAux_Multiboot2_ITag_None *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(None);
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_BootCmdLine_print(
|
||||
const struct KernAux_Multiboot2_ITag_BootCmdLine *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(BootCmdLine);
|
||||
KERNAUX_ASSERT(tag);
|
||||
KERNAUX_ASSERT(display);
|
||||
|
||||
// Print data:
|
||||
PRINTLNF(" char cmdline[]: \"%s\"", KERNAUX_MULTIBOOT2_DATA(tag));
|
||||
if (!KernAux_Multiboot2_ITag_BootCmdLine_is_valid(tag)) {
|
||||
PRINTLN(" invalid!");
|
||||
return;
|
||||
}
|
||||
|
||||
FOOTER;
|
||||
PRINTLNF(" cmdline: %s", KERNAUX_MULTIBOOT2_DATA(tag));
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_BootLoaderName_print(
|
||||
const struct KernAux_Multiboot2_ITag_BootLoaderName *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(BootLoaderName);
|
||||
KERNAUX_ASSERT(tag);
|
||||
KERNAUX_ASSERT(display);
|
||||
|
||||
// Print data:
|
||||
PRINTLNF(" char name[]: \"%s\"", KERNAUX_MULTIBOOT2_DATA(tag));
|
||||
if (!KernAux_Multiboot2_ITag_BootLoaderName_is_valid(tag)) {
|
||||
PRINTLN(" invalid!");
|
||||
return;
|
||||
}
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_Module_print(
|
||||
const struct KernAux_Multiboot2_ITag_Module *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(Module);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, mod_start, tag->mod_start);
|
||||
KERNAUX_CAST_CONST(unsigned long, mod_end, tag->mod_end);
|
||||
|
||||
PRINTLNF(" u32 mod_start: 0x%lx", mod_start);
|
||||
PRINTLNF(" u32 mod_end: 0x%lx", mod_end);
|
||||
|
||||
// Print data:
|
||||
PRINTLNF(" char cmdline[]: \"%s\"", KERNAUX_MULTIBOOT2_DATA(tag));
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_BasicMemoryInfo_print(
|
||||
const struct KernAux_Multiboot2_ITag_BasicMemoryInfo *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(BasicMemoryInfo);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, mem_lower, tag->mem_lower);
|
||||
KERNAUX_CAST_CONST(unsigned long, mem_upper, tag->mem_upper);
|
||||
|
||||
PRINTLNF(" u32 mem_lower: %lu", mem_lower);
|
||||
PRINTLNF(" u32 mem_upper: %lu", mem_upper);
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_BIOSBootDevice_print(
|
||||
const struct KernAux_Multiboot2_ITag_BIOSBootDevice *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(BIOSBootDevice);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, biosdev, tag->biosdev);
|
||||
KERNAUX_CAST_CONST(unsigned long, partition, tag->partition);
|
||||
KERNAUX_CAST_CONST(unsigned long, sub_partition, tag->sub_partition);
|
||||
|
||||
PRINTLNF(" u32 biosdev: %lu", biosdev);
|
||||
PRINTLNF(" u32 partition: %lu", partition);
|
||||
PRINTLNF(" u32 sub_partition: %lu", sub_partition);
|
||||
|
||||
FOOTER;
|
||||
PRINTLNF(" name: %s", KERNAUX_MULTIBOOT2_DATA(tag));
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_MemoryMap_print(
|
||||
const struct KernAux_Multiboot2_ITag_MemoryMap *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(MemoryMap);
|
||||
KERNAUX_ASSERT(tag);
|
||||
KERNAUX_ASSERT(display);
|
||||
|
||||
if (!KernAux_Multiboot2_ITag_MemoryMap_is_valid(tag)) {
|
||||
PRINTLN(" invalid!");
|
||||
return;
|
||||
}
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, entry_size, tag->entry_size);
|
||||
KERNAUX_CAST_CONST(unsigned long, entry_version, tag->entry_version);
|
||||
|
||||
PRINTLNF(" u32 entry_size: %lu", entry_size);
|
||||
PRINTLNF(" u32 entry_version: %lu", entry_version);
|
||||
|
||||
// Print data:
|
||||
|
||||
PRINTLN (" varies(entry_size) entries[]: [");
|
||||
PRINTLNF(" entry size: %lu", entry_size);
|
||||
PRINTLNF(" entry version: %lu", entry_version);
|
||||
PRINTLN(" entries:");
|
||||
|
||||
const struct KernAux_Multiboot2_ITag_MemoryMap_EntryBase *const entries =
|
||||
(struct KernAux_Multiboot2_ITag_MemoryMap_EntryBase*)
|
||||
|
@ -322,291 +336,37 @@ void KernAux_Multiboot2_ITag_MemoryMap_print(
|
|||
KERNAUX_CAST_CONST(unsigned long long, base_addr, entries[index].base_addr);
|
||||
KERNAUX_CAST_CONST(unsigned long long, length, entries[index].length);
|
||||
KERNAUX_CAST_CONST(unsigned long, type, entries[index].type);
|
||||
KERNAUX_CAST_CONST(unsigned long, reserved, entries[index].reserved);
|
||||
KERNAUX_CAST_CONST(unsigned long, reserved1, entries[index].reserved1);
|
||||
|
||||
PRINTLNF(" [%zu] entry: {", index);
|
||||
PRINTLNF(" u64 base_addr: 0x%llx", base_addr);
|
||||
PRINTLNF(" u64 length: %llu", length);
|
||||
PRINTLNF(" u32 type: %lu", type);
|
||||
PRINTLNF(" u32 reserved: 0x%lx", reserved);
|
||||
PRINTLN (" }");
|
||||
PRINTLNF(" entry %zu", index);
|
||||
PRINTLNF(" base addr: %llu", base_addr);
|
||||
PRINTLNF(" length: %llu", length);
|
||||
PRINTLNF(" type: %lu", type);
|
||||
PRINTLNF(" reserved1: %lu", reserved1);
|
||||
}
|
||||
|
||||
PRINTLN(" ]");
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_VBEInfo_print(
|
||||
const struct KernAux_Multiboot2_ITag_VBEInfo *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(VBEInfo);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, mode, tag->vbe_mode);
|
||||
KERNAUX_CAST_CONST(unsigned long, interface_seg, tag->vbe_interface_seg);
|
||||
KERNAUX_CAST_CONST(unsigned long, interface_off, tag->vbe_interface_off);
|
||||
KERNAUX_CAST_CONST(unsigned long, interface_len, tag->vbe_interface_len);
|
||||
|
||||
PRINTLNF(" u16 vbe_mode: %lu", mode);
|
||||
PRINTLNF(" u16 vbe_interface_seg: %lu", interface_seg);
|
||||
PRINTLNF(" u16 vbe_interface_off: %lu", interface_off);
|
||||
PRINTLNF(" u16 vbe_interface_len: %lu", interface_len);
|
||||
|
||||
const size_t cols = 16;
|
||||
|
||||
PRINTLN (" u8 vbe_control_info[]: [");
|
||||
for (
|
||||
size_t index = 0;
|
||||
index < sizeof(tag->vbe_control_info) / sizeof(tag->vbe_control_info[0]);
|
||||
index += cols
|
||||
) {
|
||||
PRINTF(" %-3u", tag->vbe_control_info[index]);
|
||||
for (size_t col = 1; col < cols; ++col) {
|
||||
PRINTF(" %-3u", tag->vbe_control_info[index + col]);
|
||||
}
|
||||
PRINTLN("");
|
||||
}
|
||||
PRINTLN (" ]");
|
||||
|
||||
PRINTLN (" u8 vbe_mode_info[]: [");
|
||||
for (
|
||||
size_t index = 0;
|
||||
index < sizeof(tag->vbe_mode_info) / sizeof(tag->vbe_mode_info[0]);
|
||||
index += cols
|
||||
) {
|
||||
PRINTF(" %-3u", tag->vbe_mode_info[index]);
|
||||
for (size_t col = 1; col < cols; ++col) {
|
||||
PRINTF(" %-3u", tag->vbe_mode_info[index + col]);
|
||||
}
|
||||
PRINTLN("");
|
||||
}
|
||||
PRINTLN (" ]");
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_FramebufferInfo_print(
|
||||
const struct KernAux_Multiboot2_ITag_FramebufferInfo *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(FramebufferInfo);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long long, addr, tag->framebuffer_addr);
|
||||
KERNAUX_CAST_CONST(unsigned long, pitch, tag->framebuffer_pitch);
|
||||
KERNAUX_CAST_CONST(unsigned long, width, tag->framebuffer_width);
|
||||
KERNAUX_CAST_CONST(unsigned long, height, tag->framebuffer_height);
|
||||
KERNAUX_CAST_CONST(unsigned long, bpp, tag->framebuffer_bpp);
|
||||
KERNAUX_CAST_CONST(unsigned long, type, tag->framebuffer_type);
|
||||
KERNAUX_CAST_CONST(unsigned long, reserved, tag->reserved);
|
||||
|
||||
PRINTLNF(" u64 framebuffer_addr: 0x%llx", addr);
|
||||
PRINTLNF(" u32 framebuffer_pitch: %lu", pitch);
|
||||
PRINTLNF(" u32 framebuffer_width: %lu", width);
|
||||
PRINTLNF(" u32 framebuffer_height: %lu", height);
|
||||
PRINTLNF(" u8 framebuffer_bpp: %lu", bpp);
|
||||
PRINTLNF(" u8 framebuffer_type: %lu", type);
|
||||
PRINTLNF(" u16 reserved: 0x%lx", reserved);
|
||||
|
||||
// TODO: Print data?
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_ELFSymbols_print(
|
||||
const struct KernAux_Multiboot2_ITag_ELFSymbols *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(ELFSymbols);
|
||||
KERNAUX_ASSERT(tag);
|
||||
KERNAUX_ASSERT(display);
|
||||
|
||||
if (!KernAux_Multiboot2_ITag_ELFSymbols_is_valid(tag)) {
|
||||
PRINTLN(" invalid!");
|
||||
return;
|
||||
}
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, num, tag->num);
|
||||
KERNAUX_CAST_CONST(unsigned long, entsize, tag->entsize);
|
||||
KERNAUX_CAST_CONST(unsigned long, ent_size, tag->ent_size);
|
||||
KERNAUX_CAST_CONST(unsigned long, shndx, tag->shndx);
|
||||
KERNAUX_CAST_CONST(unsigned long, reserved1, tag->reserved1);
|
||||
|
||||
PRINTLNF(" u32 num: %lu", num);
|
||||
PRINTLNF(" u32 entsize: %lu", entsize);
|
||||
PRINTLNF(" u32 shndx: %lu", shndx);
|
||||
PRINTLNF(" num: %lu", num);
|
||||
PRINTLNF(" entsize: %lu", ent_size);
|
||||
PRINTLNF(" shndx: %lu", shndx);
|
||||
PRINTLNF(" reserved1: %lu", reserved1);
|
||||
|
||||
// TODO: Print data?
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_APMTable_print(
|
||||
const struct KernAux_Multiboot2_ITag_APMTable *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(APMTable);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, version, tag->version);
|
||||
KERNAUX_CAST_CONST(unsigned long, cseg, tag->cseg);
|
||||
KERNAUX_CAST_CONST(unsigned long, offset, tag->offset);
|
||||
KERNAUX_CAST_CONST(unsigned long, cseg_16, tag->cseg_16);
|
||||
KERNAUX_CAST_CONST(unsigned long, dseg, tag->dseg);
|
||||
KERNAUX_CAST_CONST(unsigned long, flags, tag->flags);
|
||||
KERNAUX_CAST_CONST(unsigned long, cseg_len, tag->cseg_len);
|
||||
KERNAUX_CAST_CONST(unsigned long, cseg_16_len, tag->cseg_16_len);
|
||||
KERNAUX_CAST_CONST(unsigned long, dseg_len, tag->dseg_len);
|
||||
|
||||
PRINTLNF(" u16 version: %lu", version);
|
||||
PRINTLNF(" u16 cseg: %lu", cseg);
|
||||
PRINTLNF(" u32 offset: %lu", offset);
|
||||
PRINTLNF(" u16 cseg_16: %lu", cseg_16);
|
||||
PRINTLNF(" u16 dseg: %lu", dseg);
|
||||
PRINTLNF(" u16 flags: %lu", flags);
|
||||
PRINTLNF(" u16 cseg_len: %lu", cseg_len);
|
||||
PRINTLNF(" u16 cseg_16_len: %lu", cseg_16_len);
|
||||
PRINTLNF(" u16 dseg_len: %lu", dseg_len);
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_EFI32bitSystemTablePtr_print(
|
||||
const struct KernAux_Multiboot2_ITag_EFI32bitSystemTablePtr *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(EFI32bitSystemTablePtr);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, pointer, tag->pointer);
|
||||
|
||||
PRINTLNF(" u32 pointer: %lu", pointer);
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_EFI64bitSystemTablePtr_print(
|
||||
const struct KernAux_Multiboot2_ITag_EFI64bitSystemTablePtr *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(EFI64bitSystemTablePtr);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long long, pointer, tag->pointer);
|
||||
|
||||
PRINTLNF(" u64 pointer: %llu", pointer);
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_SMBIOSTables_print(
|
||||
const struct KernAux_Multiboot2_ITag_SMBIOSTables *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(SMBIOSTables);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, major, tag->major);
|
||||
KERNAUX_CAST_CONST(unsigned long, minor, tag->minor);
|
||||
KERNAUX_CAST_CONST(unsigned long, reserved0, tag->reserved[0]);
|
||||
KERNAUX_CAST_CONST(unsigned long, reserved1, tag->reserved[1]);
|
||||
KERNAUX_CAST_CONST(unsigned long, reserved2, tag->reserved[2]);
|
||||
KERNAUX_CAST_CONST(unsigned long, reserved3, tag->reserved[3]);
|
||||
KERNAUX_CAST_CONST(unsigned long, reserved4, tag->reserved[4]);
|
||||
KERNAUX_CAST_CONST(unsigned long, reserved5, tag->reserved[5]);
|
||||
|
||||
PRINTLNF(" u8 major: %lu", major);
|
||||
PRINTLNF(" u8 minor: %lu", minor);
|
||||
PRINTLNF(" u8 reserved[6]: [0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%lx]",
|
||||
reserved0, reserved1, reserved2,
|
||||
reserved3, reserved4, reserved5
|
||||
);
|
||||
|
||||
// TODO: Print data?
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_ACPIOldRSDP_print(
|
||||
const struct KernAux_Multiboot2_ITag_ACPIOldRSDP *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(ACPIOldRSDP);
|
||||
|
||||
// TODO: Print data?
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_ACPINewRSDP_print(
|
||||
const struct KernAux_Multiboot2_ITag_ACPINewRSDP *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(ACPINewRSDP);
|
||||
|
||||
// TODO: Print data?
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_NetworkingInfo_print(
|
||||
const struct KernAux_Multiboot2_ITag_NetworkingInfo *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(NetworkingInfo);
|
||||
|
||||
// TODO: Print data?
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_EFIMemoryMap_print(
|
||||
const struct KernAux_Multiboot2_ITag_EFIMemoryMap *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(EFIMemoryMap);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, descr_size, tag->descriptor_size);
|
||||
KERNAUX_CAST_CONST(unsigned long, descr_version, tag->descriptor_version);
|
||||
|
||||
PRINTLNF(" u32 descriptor_size: %lu", descr_size);
|
||||
PRINTLNF(" u32 descriptor_version: %lu", descr_version);
|
||||
|
||||
// TODO: Print data?
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_EFIBootServicesNotTerminated_print(
|
||||
const struct KernAux_Multiboot2_ITag_EFIBootServicesNotTerminated *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(EFIBootServicesNotTerminated);
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_EFI32bitImageHandlePtr_print(
|
||||
const struct KernAux_Multiboot2_ITag_EFI32bitImageHandlePtr *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(EFI32bitImageHandlePtr);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, pointer, tag->pointer);
|
||||
|
||||
PRINTLNF(" u32 pointer: %lu", pointer);
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_EFI64bitImageHandlePtr_print(
|
||||
const struct KernAux_Multiboot2_ITag_EFI64bitImageHandlePtr *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(EFI64bitImageHandlePtr);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long long, pointer, tag->pointer);
|
||||
|
||||
PRINTLNF(" u64 pointer: %llu", pointer);
|
||||
|
||||
FOOTER;
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_ITag_ImageLoadBasePhysAddr_print(
|
||||
const struct KernAux_Multiboot2_ITag_ImageLoadBasePhysAddr *const tag,
|
||||
const KernAux_Display display
|
||||
) {
|
||||
HEADER(ImageLoadBasePhysAddr);
|
||||
|
||||
KERNAUX_CAST_CONST(unsigned long, load_base_addr, tag->load_base_addr);
|
||||
|
||||
PRINTLNF(" u32 load_base_addr: 0x%lx", load_base_addr);
|
||||
|
||||
FOOTER;
|
||||
// TODO: implement this
|
||||
}
|
||||
|
|
|
@ -4,19 +4,6 @@ CLEANFILES =
|
|||
TESTS =
|
||||
noinst_PROGRAMS = $(TESTS)
|
||||
|
||||
############################
|
||||
# multiboot2_header_print0 #
|
||||
############################
|
||||
|
||||
if WITH_MULTIBOOT2
|
||||
noinst_PROGRAMS += multiboot2_header_print0
|
||||
multiboot2_header_print0_LDADD = $(top_builddir)/libkernaux.la
|
||||
multiboot2_header_print0_SOURCES = \
|
||||
main.c \
|
||||
multiboot2_header_print0.c \
|
||||
multiboot2_header_example0.h
|
||||
endif
|
||||
|
||||
############################
|
||||
# multiboot2_header_print1 #
|
||||
############################
|
||||
|
@ -43,19 +30,6 @@ multiboot2_header_print2_SOURCES = \
|
|||
multiboot2_header_example2.h
|
||||
endif
|
||||
|
||||
##########################
|
||||
# multiboot2_info_print0 #
|
||||
##########################
|
||||
|
||||
if WITH_MULTIBOOT2
|
||||
noinst_PROGRAMS += multiboot2_info_print0
|
||||
multiboot2_info_print0_LDADD = $(top_builddir)/libkernaux.la
|
||||
multiboot2_info_print0_SOURCES = \
|
||||
main.c \
|
||||
multiboot2_info_print0.c \
|
||||
multiboot2_info_example0.h
|
||||
endif
|
||||
|
||||
##########################
|
||||
# multiboot2_info_print1 #
|
||||
##########################
|
||||
|
@ -215,7 +189,6 @@ endif
|
|||
if WITH_MULTIBOOT2
|
||||
TESTS += test_multiboot2_header_print
|
||||
test_multiboot2_header_print_DEPENDENCIES = \
|
||||
multiboot2_header_print0 \
|
||||
multiboot2_header_print1 \
|
||||
multiboot2_header_print2
|
||||
test_multiboot2_header_print_LDADD = $(top_builddir)/libkernaux.la
|
||||
|
@ -259,7 +232,6 @@ endif
|
|||
if WITH_MULTIBOOT2
|
||||
TESTS += test_multiboot2_info_print
|
||||
test_multiboot2_info_print_DEPENDENCIES = \
|
||||
multiboot2_info_print0 \
|
||||
multiboot2_info_print1 \
|
||||
multiboot2_info_print2
|
||||
test_multiboot2_info_print_LDADD = $(top_builddir)/libkernaux.la
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
#include <kernaux/macro.h>
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
#include <kernaux/macro/packing_start.run>
|
||||
|
||||
// Minimal example
|
||||
KERNAUX_ALIGNED(KERNAUX_MULTIBOOT2_HEADER_ALIGN)
|
||||
static const struct {
|
||||
struct KernAux_Multiboot2_Header multiboot2_header;
|
||||
struct KernAux_Multiboot2_HTag_None tag_none;
|
||||
}
|
||||
KERNAUX_PACKED
|
||||
multiboot2_header_example0 = {
|
||||
.multiboot2_header = {
|
||||
.magic = KERNAUX_MULTIBOOT2_HEADER_MAGIC,
|
||||
.arch = KERNAUX_MULTIBOOT2_HEADER_ARCH_I386,
|
||||
.total_size = sizeof(multiboot2_header_example0),
|
||||
.checksum = KERNAUX_MULTIBOOT2_HEADER_CHECKSUM(
|
||||
KERNAUX_MULTIBOOT2_HEADER_ARCH_I386,
|
||||
sizeof(multiboot2_header_example0)
|
||||
),
|
||||
},
|
||||
.tag_none = {
|
||||
.base = {
|
||||
.type = KERNAUX_MULTIBOOT2_HTAG_NONE,
|
||||
.flags = 0,
|
||||
.size = sizeof(multiboot2_header_example0.tag_none),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
#include <kernaux/macro/packing_end.run>
|
|
@ -1,30 +1,7 @@
|
|||
#include <kernaux/macro.h>
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
#include <kernaux/macro/packing_start.run>
|
||||
|
||||
KERNAUX_ALIGNED(KERNAUX_MULTIBOOT2_HEADER_ALIGN)
|
||||
static const struct {
|
||||
struct KernAux_Multiboot2_Header multiboot2_header;
|
||||
|
||||
struct KernAux_Multiboot2_HTag_Flags tag_flags1;
|
||||
uint8_t _align1[4];
|
||||
|
||||
struct KernAux_Multiboot2_HTag_Flags tag_flags2;
|
||||
uint8_t _align2[4];
|
||||
|
||||
struct KernAux_Multiboot2_HTag_Flags tag_flags3;
|
||||
uint8_t _align3[4];
|
||||
|
||||
struct KernAux_Multiboot2_HTag_Flags tag_flags4;
|
||||
uint8_t _align4[4];
|
||||
|
||||
struct {
|
||||
struct KernAux_Multiboot2_HTag_InfoReq tag;
|
||||
uint32_t mbi_tag_types[1];
|
||||
} tag_info_req;
|
||||
uint8_t _align5[4];
|
||||
|
||||
struct KernAux_Multiboot2_HTag_None tag_none;
|
||||
}
|
||||
KERNAUX_PACKED
|
||||
|
@ -38,52 +15,6 @@ multiboot2_header_example1 = {
|
|||
sizeof(multiboot2_header_example1)
|
||||
),
|
||||
},
|
||||
.tag_flags1 = {
|
||||
.base = {
|
||||
.type = KERNAUX_MULTIBOOT2_HTAG_FLAGS,
|
||||
.flags = 0,
|
||||
.size = sizeof(multiboot2_header_example1.tag_flags1),
|
||||
},
|
||||
.console_flags = 0,
|
||||
},
|
||||
.tag_flags2 = {
|
||||
.base = {
|
||||
.type = KERNAUX_MULTIBOOT2_HTAG_FLAGS,
|
||||
.flags = 0,
|
||||
.size = sizeof(multiboot2_header_example1.tag_flags2),
|
||||
},
|
||||
.console_flags = KERNAUX_MULTIBOOT2_HTAG_FLAGS_REQUIRE_CONSOLE,
|
||||
},
|
||||
.tag_flags3 = {
|
||||
.base = {
|
||||
.type = KERNAUX_MULTIBOOT2_HTAG_FLAGS,
|
||||
.flags = 0,
|
||||
.size = sizeof(multiboot2_header_example1.tag_flags3),
|
||||
},
|
||||
.console_flags = KERNAUX_MULTIBOOT2_HTAG_FLAGS_EGA_SUPPORT,
|
||||
},
|
||||
.tag_flags4 = {
|
||||
.base = {
|
||||
.type = KERNAUX_MULTIBOOT2_HTAG_FLAGS,
|
||||
.flags = 0,
|
||||
.size = sizeof(multiboot2_header_example1.tag_flags4),
|
||||
},
|
||||
.console_flags =
|
||||
KERNAUX_MULTIBOOT2_HTAG_FLAGS_REQUIRE_CONSOLE |
|
||||
KERNAUX_MULTIBOOT2_HTAG_FLAGS_EGA_SUPPORT,
|
||||
},
|
||||
.tag_info_req = {
|
||||
.tag = {
|
||||
.base = {
|
||||
.type = KERNAUX_MULTIBOOT2_HTAG_INFO_REQ,
|
||||
.flags = KERNAUX_MULTIBOOT2_HTAG_BASE_FLAG_OPTIONAL,
|
||||
.size = sizeof(multiboot2_header_example1.tag_info_req),
|
||||
},
|
||||
},
|
||||
.mbi_tag_types = {
|
||||
KERNAUX_MULTIBOOT2_ITAG_NONE,
|
||||
},
|
||||
},
|
||||
.tag_none = {
|
||||
.base = {
|
||||
.type = KERNAUX_MULTIBOOT2_HTAG_NONE,
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
#include <kernaux/macro.h>
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
#include <kernaux/macro/packing_start.run>
|
||||
|
||||
KERNAUX_ALIGNED(KERNAUX_MULTIBOOT2_HEADER_ALIGN)
|
||||
static const struct {
|
||||
struct KernAux_Multiboot2_Header multiboot2_header;
|
||||
|
||||
|
@ -87,10 +85,10 @@ multiboot2_header_example2 = {
|
|||
.flags = 0,
|
||||
.size = sizeof(multiboot2_header_example2.tag_addr),
|
||||
},
|
||||
.header_addr = 0xcafebabe,
|
||||
.load_addr = 0xdeadbeaf,
|
||||
.load_end_addr = 0xdeadbabe,
|
||||
.bss_end_addr = 0xcafebeaf,
|
||||
.header_addr = 0,
|
||||
.load_addr = 0,
|
||||
.load_end_addr = 0,
|
||||
.bss_end_addr = 0,
|
||||
},
|
||||
.tag_entry_addr = {
|
||||
.base = {
|
||||
|
@ -98,7 +96,7 @@ multiboot2_header_example2 = {
|
|||
.flags = 0,
|
||||
.size = sizeof(multiboot2_header_example2.tag_entry_addr),
|
||||
},
|
||||
.entry_addr = 0xcafebabe,
|
||||
.entry_addr = 0,
|
||||
},
|
||||
.tag_flags = {
|
||||
.base = {
|
||||
|
@ -106,7 +104,10 @@ multiboot2_header_example2 = {
|
|||
.flags = 0,
|
||||
.size = sizeof(multiboot2_header_example2.tag_flags),
|
||||
},
|
||||
.console_flags = 0,
|
||||
.console_flags = (
|
||||
KERNAUX_MULTIBOOT2_HTAG_FLAGS_REQUIRE_CONSOLE |
|
||||
KERNAUX_MULTIBOOT2_HTAG_FLAGS_EGA_SUPPORT
|
||||
),
|
||||
},
|
||||
.tag_framebuffer = {
|
||||
.base = {
|
||||
|
@ -114,9 +115,9 @@ multiboot2_header_example2 = {
|
|||
.flags = 0,
|
||||
.size = sizeof(multiboot2_header_example2.tag_framebuffer),
|
||||
},
|
||||
.width = 80,
|
||||
.height = 25,
|
||||
.depth = 8,
|
||||
.width = 0,
|
||||
.height = 0,
|
||||
.depth = 0,
|
||||
},
|
||||
.tag_module_align = {
|
||||
.base = {
|
||||
|
@ -138,7 +139,7 @@ multiboot2_header_example2 = {
|
|||
.flags = 0,
|
||||
.size = sizeof(multiboot2_header_example2.tag_efi_i386_entry_addr),
|
||||
},
|
||||
.entry_addr = 0xcafebabe,
|
||||
.entry_addr = 0,
|
||||
},
|
||||
.tag_efi_amd64_entry_addr = {
|
||||
.base = {
|
||||
|
@ -146,7 +147,7 @@ multiboot2_header_example2 = {
|
|||
.flags = 0,
|
||||
.size = sizeof(multiboot2_header_example2.tag_efi_amd64_entry_addr),
|
||||
},
|
||||
.entry_addr = 0xdeadbeaf,
|
||||
.entry_addr = 0,
|
||||
},
|
||||
.tag_relocatable_header = {
|
||||
.base = {
|
||||
|
@ -154,10 +155,10 @@ multiboot2_header_example2 = {
|
|||
.flags = 0,
|
||||
.size = sizeof(multiboot2_header_example2.tag_relocatable_header),
|
||||
},
|
||||
.min_addr = 0xcafebabe,
|
||||
.max_addr = 0xdeadbeaf,
|
||||
.align = 8,
|
||||
.preference =
|
||||
.min_addr = 0,
|
||||
.max_addr = 0,
|
||||
.align = 0,
|
||||
.preferences =
|
||||
KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_LOWEST,
|
||||
},
|
||||
.tag_none = {
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#define KERNAUX_ACCESS_PROTECTED
|
||||
|
||||
#include <kernaux/generic/display.h>
|
||||
#include <kernaux/macro.h>
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "multiboot2_header_example0.h"
|
||||
|
||||
static void my_putc(void *display KERNAUX_UNUSED, char c)
|
||||
{
|
||||
putchar(c);
|
||||
}
|
||||
|
||||
static
|
||||
void my_vprintf(void *display KERNAUX_UNUSED, const char *format, va_list va)
|
||||
{
|
||||
vprintf(format, va);
|
||||
}
|
||||
|
||||
static const struct KernAux_Display display = {
|
||||
.putc = my_putc,
|
||||
.vprintf = my_vprintf,
|
||||
};
|
||||
|
||||
void test_main()
|
||||
{
|
||||
assert(KernAux_Multiboot2_Header_is_valid(
|
||||
(struct KernAux_Multiboot2_Header*)&multiboot2_header_example0
|
||||
));
|
||||
|
||||
KernAux_Multiboot2_Header_print(
|
||||
(struct KernAux_Multiboot2_Header*)&multiboot2_header_example0,
|
||||
&display
|
||||
);
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
#include <kernaux/macro.h>
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
#include <kernaux/macro/packing_start.run>
|
||||
|
||||
// Minimal example
|
||||
KERNAUX_ALIGNED(KERNAUX_MULTIBOOT2_INFO_ALIGN)
|
||||
static const struct {
|
||||
struct KernAux_Multiboot2_Info multiboot2_info;
|
||||
struct KernAux_Multiboot2_ITag_None tag_none;
|
||||
}
|
||||
KERNAUX_PACKED
|
||||
multiboot2_info_example0 = {
|
||||
.multiboot2_info = {
|
||||
.total_size = sizeof(multiboot2_info_example0),
|
||||
.reserved = 0,
|
||||
},
|
||||
.tag_none = {
|
||||
.base = {
|
||||
.type = KERNAUX_MULTIBOOT2_ITAG_NONE,
|
||||
.size = sizeof(multiboot2_info_example0.tag_none),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
#include <kernaux/macro/packing_end.run>
|
|
@ -1,7 +1,3 @@
|
|||
#include <kernaux/macro.h>
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
KERNAUX_ALIGNED(KERNAUX_MULTIBOOT2_INFO_ALIGN)
|
||||
static const uint8_t multiboot2_info_example1[864] = {
|
||||
96, 3, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 12, 0, 0, 0,
|
||||
0, 0, 64, 0, 0, 0, 232, 133, 1, 0, 0, 0, 21, 0, 0, 0,
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
#include <kernaux/macro.h>
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
#include <kernaux/macro/packing_start.run>
|
||||
|
||||
KERNAUX_ALIGNED(KERNAUX_MULTIBOOT2_INFO_ALIGN)
|
||||
static const struct {
|
||||
struct KernAux_Multiboot2_Info multiboot2_info;
|
||||
|
||||
|
@ -48,6 +46,7 @@ static const struct {
|
|||
struct KernAux_Multiboot2_ITag_FramebufferInfo tag;
|
||||
uint8_t data[8];
|
||||
} tag_framebuffer_info;
|
||||
uint8_t _align6[1];
|
||||
|
||||
struct {
|
||||
struct KernAux_Multiboot2_ITag_ELFSymbols tag;
|
||||
|
@ -111,7 +110,7 @@ KERNAUX_PACKED
|
|||
multiboot2_info_example2 = {
|
||||
.multiboot2_info = {
|
||||
.total_size = sizeof(multiboot2_info_example2),
|
||||
.reserved = 0,
|
||||
.reserved1 = 0,
|
||||
},
|
||||
.tag_boot_cmd_line = {
|
||||
.tag = {
|
||||
|
@ -166,7 +165,7 @@ multiboot2_info_example2 = {
|
|||
.type = KERNAUX_MULTIBOOT2_ITAG_BIOS_BOOT_DEVICE,
|
||||
.size = sizeof(multiboot2_info_example2.tag_bios_boot_device),
|
||||
},
|
||||
.biosdev = 0,
|
||||
.bios_dev = 0,
|
||||
.partition = 1,
|
||||
.sub_partition = 2,
|
||||
},
|
||||
|
@ -201,24 +200,6 @@ multiboot2_info_example2 = {
|
|||
.vbe_interface_seg = 123,
|
||||
.vbe_interface_off = 456,
|
||||
.vbe_interface_len = 789,
|
||||
.vbe_control_info = {
|
||||
[0] = 0,
|
||||
[16] = 1,
|
||||
[32] = 12,
|
||||
[48] = 123,
|
||||
[79] = 1,
|
||||
[95] = 12,
|
||||
[111] = 123,
|
||||
},
|
||||
.vbe_mode_info = {
|
||||
[0] = 0,
|
||||
[16] = 3,
|
||||
[32] = 32,
|
||||
[48] = 255,
|
||||
[79] = 3,
|
||||
[95] = 32,
|
||||
[111] = 255,
|
||||
},
|
||||
},
|
||||
.tag_framebuffer_info = {
|
||||
.tag = {
|
||||
|
@ -242,11 +223,12 @@ multiboot2_info_example2 = {
|
|||
.size = sizeof(multiboot2_info_example2.tag_elf_symbols),
|
||||
},
|
||||
.num = 10,
|
||||
.entsize = 40,
|
||||
.shndx = 9,
|
||||
.ent_size = 0,
|
||||
.shndx = 40,
|
||||
.reserved1 = 0,
|
||||
},
|
||||
.data = {
|
||||
0, 0, 0, 0,
|
||||
9, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 27, 0, 0, 0, 1, 0, 0, 0, 6, 0, 0, 0,
|
||||
|
@ -311,7 +293,7 @@ multiboot2_info_example2 = {
|
|||
},
|
||||
.major = 1,
|
||||
.minor = 2,
|
||||
.reserved = {0, 0, 0, 0, 0, 0},
|
||||
.reserved1 = {0, 0, 0, 0, 0, 0},
|
||||
},
|
||||
.data = {0, 0, 0, 0, 0, 0, 0, 0},
|
||||
},
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#define KERNAUX_ACCESS_PROTECTED
|
||||
|
||||
#include <kernaux/generic/display.h>
|
||||
#include <kernaux/macro.h>
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "multiboot2_info_example0.h"
|
||||
|
||||
static void my_putc(void *display KERNAUX_UNUSED, char c)
|
||||
{
|
||||
putchar(c);
|
||||
}
|
||||
|
||||
static
|
||||
void my_vprintf(void *display KERNAUX_UNUSED, const char *format, va_list va)
|
||||
{
|
||||
vprintf(format, va);
|
||||
}
|
||||
|
||||
static const struct KernAux_Display display = {
|
||||
.putc = my_putc,
|
||||
.vprintf = my_vprintf,
|
||||
};
|
||||
|
||||
void test_main()
|
||||
{
|
||||
assert(KernAux_Multiboot2_Info_is_valid(
|
||||
&multiboot2_info_example0.multiboot2_info
|
||||
));
|
||||
|
||||
KernAux_Multiboot2_Info_print(
|
||||
&multiboot2_info_example0.multiboot2_info,
|
||||
&display
|
||||
);
|
||||
}
|
|
@ -106,8 +106,8 @@ void test_main()
|
|||
INFO_SIZEOF1(BIOSBootDevice, bios_boot_device, 20 );
|
||||
INFO_SIZEOF2(MemoryMap, memory_map, 16, 160 - 16);
|
||||
INFO_SIZEOF1(VBEInfo, vbe_info, 784 );
|
||||
INFO_SIZEOF2(FramebufferInfo, framebuffer_info, 32, 8 );
|
||||
INFO_SIZEOF2(ELFSymbols, elf_symbols, 20, 420 - 20);
|
||||
INFO_SIZEOF2(FramebufferInfo, framebuffer_info, 31, 8 );
|
||||
INFO_SIZEOF2(ELFSymbols, elf_symbols, 16, 420 - 16);
|
||||
INFO_SIZEOF1(APMTable, apm_table, 28 );
|
||||
INFO_SIZEOF1(EFI32bitSystemTablePtr, efi_32bit_system_table_ptr, 12 );
|
||||
INFO_SIZEOF1(EFI64bitSystemTablePtr, efi_64bit_system_table_ptr, 16 );
|
||||
|
|
|
@ -9,189 +9,70 @@
|
|||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
static const char output0[] =
|
||||
"Multiboot 2 header {\n"
|
||||
" u32 magic: 0xe85250d6\n"
|
||||
" u32 arch: 0 (i386)\n"
|
||||
" u32 size: 24\n"
|
||||
" u32 checksum: 0x17adaf12\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 0 (none)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 8\n"
|
||||
"}\n";
|
||||
|
||||
static const char output1[] =
|
||||
"Multiboot 2 header {\n"
|
||||
" u32 magic: 0xe85250d6\n"
|
||||
" u32 arch: 4 (MIPS32)\n"
|
||||
" u32 size: 104\n"
|
||||
" u32 checksum: 0x17adaebe\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 4 (flags)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 console_flags: 0x0 ()\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 4 (flags)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 console_flags: 0x1 (\n"
|
||||
" REQUIRE_CONSOLE\n"
|
||||
" )\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 4 (flags)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 console_flags: 0x2 (\n"
|
||||
" EGA_SUPPORT\n"
|
||||
" )\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 4 (flags)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 console_flags: 0x3 (\n"
|
||||
" REQUIRE_CONSOLE |\n"
|
||||
" EGA_SUPPORT\n"
|
||||
" )\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 1 (information request)\n"
|
||||
" u16 flags: 0x1 (\n"
|
||||
" OPTIONAL\n"
|
||||
" )\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 mbi_tag_types[]: [\n"
|
||||
" 0 (none)\n"
|
||||
" ]\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 0 (none)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 8\n"
|
||||
"}\n";
|
||||
"Multiboot 2 header\n"
|
||||
" magic: 3897708758\n"
|
||||
" arch: 4 (MIPS32)\n"
|
||||
" size: 24\n"
|
||||
" checksum: 397258510\n"
|
||||
"Multiboot 2 header tag\n"
|
||||
" type: 0 (none)\n"
|
||||
" flags: 0\n"
|
||||
" size: 8\n";
|
||||
|
||||
static const char output2[] =
|
||||
"Multiboot 2 header {\n"
|
||||
" u32 magic: 0xe85250d6\n"
|
||||
" u32 arch: 0 (i386)\n"
|
||||
" u32 size: 272\n"
|
||||
" u32 checksum: 0x17adae1a\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 1 (information request)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 96\n"
|
||||
" u32 mbi_tag_types[]: [\n"
|
||||
" 0 (none)\n"
|
||||
" 1 (boot cmd line)\n"
|
||||
" 2 (boot loader name)\n"
|
||||
" 3 (module)\n"
|
||||
" 4 (basic memory info)\n"
|
||||
" 5 (BIOS boot device)\n"
|
||||
" 6 (memory map)\n"
|
||||
" 7 (VBE info)\n"
|
||||
" 8 (framebuffer info)\n"
|
||||
" 9 (ELF symbols)\n"
|
||||
" 10 (APM table)\n"
|
||||
" 11 (EFI 32bit system table ptr)\n"
|
||||
" 12 (EFI 64bit system table ptr)\n"
|
||||
" 13 (SMBIOS tables)\n"
|
||||
" 14 (ACPI old RSDP)\n"
|
||||
" 15 (ACPI new RSDP)\n"
|
||||
" 16 (networking info)\n"
|
||||
" 17 (EFI memory map)\n"
|
||||
" 18 (EFI boot services not terminated)\n"
|
||||
" 19 (EFI 32bit image handle ptr)\n"
|
||||
" 20 (EFI 64bit image handle ptr)\n"
|
||||
" 21 (image load base phys addr)\n"
|
||||
" ]\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 2 (address)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 24\n"
|
||||
" u32 header_addr: 0xcafebabe\n"
|
||||
" u32 load_addr: 0xdeadbeaf\n"
|
||||
" u32 load_end_addr: 0xdeadbabe\n"
|
||||
" u32 bss_end_addr: 0xcafebeaf\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 3 (entry address)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 entry_addr: 0xcafebabe\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 4 (flags)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 console_flags: 0x0 ()\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 5 (framebuffer)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 20\n"
|
||||
" u32 width: 80\n"
|
||||
" u32 height: 25\n"
|
||||
" u32 depth: 8\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 6 (module alignment)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 8\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 7 (EFI boot services)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 8\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 8 (EFI i386 entry address)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 entry_addr: 0xcafebabe\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 9 (EFI amd64 entry address)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 entry_addr: 0xdeadbeaf\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 10 (relocatable header)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 24\n"
|
||||
" 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"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 8\n"
|
||||
"}\n";
|
||||
"Multiboot 2 header\n"
|
||||
" magic: 3897708758\n"
|
||||
" arch: 0 (i386)\n"
|
||||
" size: 272\n"
|
||||
" checksum: 397258266\n"
|
||||
"Multiboot 2 header tag\n"
|
||||
" type: 1 (information request)\n"
|
||||
" flags: 0\n"
|
||||
" size: 96\n"
|
||||
"Multiboot 2 header tag\n"
|
||||
" type: 2 (address)\n"
|
||||
" flags: 0\n"
|
||||
" size: 24\n"
|
||||
"Multiboot 2 header tag\n"
|
||||
" type: 3 (entry address)\n"
|
||||
" flags: 0\n"
|
||||
" size: 12\n"
|
||||
"Multiboot 2 header tag\n"
|
||||
" type: 4 (flags)\n"
|
||||
" flags: 0\n"
|
||||
" size: 12\n"
|
||||
"Multiboot 2 header tag\n"
|
||||
" type: 5 (framebuffer)\n"
|
||||
" flags: 0\n"
|
||||
" size: 20\n"
|
||||
"Multiboot 2 header tag\n"
|
||||
" type: 6 (module alignment)\n"
|
||||
" flags: 0\n"
|
||||
" size: 8\n"
|
||||
"Multiboot 2 header tag\n"
|
||||
" type: 7 (EFI boot services)\n"
|
||||
" flags: 0\n"
|
||||
" size: 8\n"
|
||||
"Multiboot 2 header tag\n"
|
||||
" type: 8 (EFI i386 entry address)\n"
|
||||
" flags: 0\n"
|
||||
" size: 12\n"
|
||||
"Multiboot 2 header tag\n"
|
||||
" type: 9 (EFI amd64 entry address)\n"
|
||||
" flags: 0\n"
|
||||
" size: 12\n"
|
||||
"Multiboot 2 header tag\n"
|
||||
" type: 10 (relocatable header)\n"
|
||||
" flags: 0\n"
|
||||
" size: 24\n"
|
||||
"Multiboot 2 header tag\n"
|
||||
" type: 0 (none)\n"
|
||||
" flags: 0\n"
|
||||
" size: 8\n";
|
||||
|
||||
void test_main()
|
||||
{
|
||||
{
|
||||
FILE *const fd = popen("./multiboot2_header_print0", "r");
|
||||
assert(fd != NULL);
|
||||
|
||||
for (const char *ch = output0; *ch; ++ch) {
|
||||
assert(fgetc(fd) == *ch);
|
||||
}
|
||||
|
||||
const int status = pclose(fd);
|
||||
assert(status == 0);
|
||||
}
|
||||
|
||||
{
|
||||
FILE *const fd = popen("./multiboot2_header_print1", "r");
|
||||
assert(fd != NULL);
|
||||
|
|
|
@ -18,7 +18,7 @@ static const struct {
|
|||
} KERNAUX_PACKED multiboot2_without_boot_cmd_line = {
|
||||
.multiboot2_info = {
|
||||
.total_size = sizeof(multiboot2_without_boot_cmd_line),
|
||||
.reserved = 0,
|
||||
.reserved1 = 0,
|
||||
},
|
||||
.tag_none = {
|
||||
.base = {
|
||||
|
@ -42,7 +42,7 @@ static const struct {
|
|||
} KERNAUX_PACKED multiboot2_with_some_boot_cmd_line = {
|
||||
.multiboot2_info = {
|
||||
.total_size = sizeof(multiboot2_with_some_boot_cmd_line),
|
||||
.reserved = 0,
|
||||
.reserved1 = 0,
|
||||
},
|
||||
.tag_boot_cmd_line = {
|
||||
.tag = {
|
||||
|
@ -84,7 +84,7 @@ static const struct {
|
|||
} KERNAUX_PACKED multiboot2_with_two_boot_cmd_lines = {
|
||||
.multiboot2_info = {
|
||||
.total_size = sizeof(multiboot2_with_two_boot_cmd_lines),
|
||||
.reserved = 0,
|
||||
.reserved1 = 0,
|
||||
},
|
||||
.tag_boot_cmd_line1 = {
|
||||
.tag = {
|
||||
|
|
|
@ -3,409 +3,273 @@
|
|||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef __USE_POSIX2
|
||||
#define __USE_POSIX2
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
static const char output0[] =
|
||||
"Multiboot 2 info {\n"
|
||||
" u32 size: 16\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 0 (none)\n"
|
||||
" u32 size: 8\n"
|
||||
"}\n";
|
||||
|
||||
static const char output1[] =
|
||||
"Multiboot 2 info {\n"
|
||||
" u32 size: 864\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 21 (image load base phys addr)\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 load_base_addr: 0x400000\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 1 (boot cmd line)\n"
|
||||
" u32 size: 21\n"
|
||||
" char cmdline[]: \"hello kernel\"\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 2 (boot loader name)\n"
|
||||
" u32 size: 30\n"
|
||||
" char name[]: \"GRUB 2.02-2ubuntu8.20\"\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 10 (APM table)\n"
|
||||
" u32 size: 28\n"
|
||||
" u16 version: 258\n"
|
||||
" u16 cseg: 61440\n"
|
||||
" u32 offset: 54479\n"
|
||||
" u16 cseg_16: 61440\n"
|
||||
" u16 dseg: 61440\n"
|
||||
" u16 flags: 3\n"
|
||||
" u16 cseg_len: 65520\n"
|
||||
" u16 cseg_16_len: 65520\n"
|
||||
" u16 dseg_len: 65520\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 3 (module)\n"
|
||||
" u32 size: 29\n"
|
||||
" u32 mod_start: 0x102000\n"
|
||||
" u32 mod_end: 0x10329c\n"
|
||||
" char cmdline[]: \"hello module\"\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 3 (module)\n"
|
||||
" u32 size: 17\n"
|
||||
" u32 mod_start: 0x104000\n"
|
||||
" u32 mod_end: 0x105254\n"
|
||||
" char cmdline[]: \"\"\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 6 (memory map)\n"
|
||||
" u32 size: 160\n"
|
||||
" u32 entry_size: 24\n"
|
||||
" u32 entry_version: 0\n"
|
||||
" varies(entry_size) entries[]: [\n"
|
||||
" [0] entry: {\n"
|
||||
" u64 base_addr: 0x0\n"
|
||||
" u64 length: 654336\n"
|
||||
" u32 type: 1\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" [1] entry: {\n"
|
||||
" u64 base_addr: 0x9fc00\n"
|
||||
" u64 length: 1024\n"
|
||||
" u32 type: 2\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" [2] entry: {\n"
|
||||
" u64 base_addr: 0xf0000\n"
|
||||
" u64 length: 65536\n"
|
||||
" u32 type: 2\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" [3] entry: {\n"
|
||||
" u64 base_addr: 0x100000\n"
|
||||
" u64 length: 133038080\n"
|
||||
" u32 type: 1\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" [4] entry: {\n"
|
||||
" u64 base_addr: 0x7fe0000\n"
|
||||
" u64 length: 131072\n"
|
||||
" u32 type: 2\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" [5] entry: {\n"
|
||||
" u64 base_addr: 0xfffc0000\n"
|
||||
" u64 length: 262144\n"
|
||||
" u32 type: 2\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" ]\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 9 (ELF symbols)\n"
|
||||
" u32 size: 420\n"
|
||||
" u32 num: 10\n"
|
||||
" u32 entsize: 40\n"
|
||||
" u32 shndx: 9\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 4 (basic memory info)\n"
|
||||
" u32 size: 16\n"
|
||||
" u32 mem_lower: 639\n"
|
||||
" u32 mem_upper: 129920\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 5 (BIOS boot device)\n"
|
||||
" u32 size: 20\n"
|
||||
" u32 biosdev: 224\n"
|
||||
" u32 partition: 4294967295\n"
|
||||
" u32 sub_partition: 4294967295\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 8 (framebuffer info)\n"
|
||||
" u32 size: 32\n"
|
||||
" u64 framebuffer_addr: 0xb8000\n"
|
||||
" u32 framebuffer_pitch: 160\n"
|
||||
" u32 framebuffer_width: 80\n"
|
||||
" u32 framebuffer_height: 25\n"
|
||||
" u8 framebuffer_bpp: 16\n"
|
||||
" u8 framebuffer_type: 2\n"
|
||||
" u16 reserved: 0x0\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 14 (ACPI old RSDP)\n"
|
||||
" u32 size: 28\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 0 (none)\n"
|
||||
" u32 size: 8\n"
|
||||
"}\n";
|
||||
"Multiboot 2 info\n"
|
||||
" size: 864\n"
|
||||
" reserved1: 0\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 21 (image load base phys addr)\n"
|
||||
" size: 12\n"
|
||||
" load base addr: 4194304\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 1 (boot cmd line)\n"
|
||||
" size: 21\n"
|
||||
" cmdline: hello kernel\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 2 (boot loader name)\n"
|
||||
" size: 30\n"
|
||||
" name: GRUB 2.02-2ubuntu8.20\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 10 (APM table)\n"
|
||||
" size: 28\n"
|
||||
" version: 258\n"
|
||||
" cseg: 61440\n"
|
||||
" offset: 54479\n"
|
||||
" cseg 16: 61440\n"
|
||||
" dseg: 61440\n"
|
||||
" flags: 3\n"
|
||||
" cseg len: 65520\n"
|
||||
" cseg 16 len: 65520\n"
|
||||
" dseg len: 65520\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 3 (module)\n"
|
||||
" size: 29\n"
|
||||
" start: 1056768\n"
|
||||
" end: 1061532\n"
|
||||
" cmdline: hello module\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 3 (module)\n"
|
||||
" size: 17\n"
|
||||
" start: 1064960\n"
|
||||
" end: 1069652\n"
|
||||
" cmdline: \n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 6 (memory map)\n"
|
||||
" size: 160\n"
|
||||
" entry size: 24\n"
|
||||
" entry version: 0\n"
|
||||
" entries:\n"
|
||||
" entry 0\n"
|
||||
" base addr: 0\n"
|
||||
" length: 654336\n"
|
||||
" type: 1\n"
|
||||
" reserved1: 0\n"
|
||||
" entry 1\n"
|
||||
" base addr: 654336\n"
|
||||
" length: 1024\n"
|
||||
" type: 2\n"
|
||||
" reserved1: 0\n"
|
||||
" entry 2\n"
|
||||
" base addr: 983040\n"
|
||||
" length: 65536\n"
|
||||
" type: 2\n"
|
||||
" reserved1: 0\n"
|
||||
" entry 3\n"
|
||||
" base addr: 1048576\n"
|
||||
" length: 133038080\n"
|
||||
" type: 1\n"
|
||||
" reserved1: 0\n"
|
||||
" entry 4\n"
|
||||
" base addr: 134086656\n"
|
||||
" length: 131072\n"
|
||||
" type: 2\n"
|
||||
" reserved1: 0\n"
|
||||
" entry 5\n"
|
||||
" base addr: 4294705152\n"
|
||||
" length: 262144\n"
|
||||
" type: 2\n"
|
||||
" reserved1: 0\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 9 (ELF symbols)\n"
|
||||
" size: 420\n"
|
||||
" num: 10\n"
|
||||
" entsize: 0\n"
|
||||
" shndx: 40\n"
|
||||
" reserved1: 0\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 4 (basic memory info)\n"
|
||||
" size: 16\n"
|
||||
" mem lower: 639\n"
|
||||
" mem upper: 129920\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 5 (BIOS boot device)\n"
|
||||
" size: 20\n"
|
||||
" bios dev: 224\n"
|
||||
" partition: 4294967295\n"
|
||||
" sub_partition: 4294967295\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 8 (framebuffer info)\n"
|
||||
" size: 32\n"
|
||||
" framebuffer addr: 753664\n"
|
||||
" framebuffer pitch: 160\n"
|
||||
" framebuffer width: 80\n"
|
||||
" framebuffer height: 25\n"
|
||||
" framebuffer bpp: 16\n"
|
||||
" framebuffer type: 2\n"
|
||||
" reserved1: 0\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 14 (ACPI old RSDP)\n"
|
||||
" size: 28\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 0 (none)\n"
|
||||
" size: 8\n";
|
||||
|
||||
static const char output2_part1[] =
|
||||
"Multiboot 2 info {\n"
|
||||
" u32 size: 1816\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 1 (boot cmd line)\n"
|
||||
" u32 size: 23\n"
|
||||
" char cmdline[]: \"Hello, Kernel!\"\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 2 (boot loader name)\n"
|
||||
" u32 size: 30\n"
|
||||
" char name[]: \"GRUB 2.02-2ubuntu8.20\"\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 3 (module)\n"
|
||||
" u32 size: 33\n"
|
||||
" u32 mod_start: 0x7b\n"
|
||||
" u32 mod_end: 0x1c8\n"
|
||||
" char cmdline[]: \"Hello, Module 1!\"\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 3 (module)\n"
|
||||
" u32 size: 33\n"
|
||||
" u32 mod_start: 0x7b\n"
|
||||
" u32 mod_end: 0x1c8\n"
|
||||
" char cmdline[]: \"Hello, Module 2!\"\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 4 (basic memory info)\n"
|
||||
" u32 size: 16\n"
|
||||
" u32 mem_lower: 123\n"
|
||||
" u32 mem_upper: 456\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 5 (BIOS boot device)\n"
|
||||
" u32 size: 20\n"
|
||||
" u32 biosdev: 0\n"
|
||||
" u32 partition: 1\n"
|
||||
" u32 sub_partition: 2\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 6 (memory map)\n"
|
||||
" u32 size: 160\n"
|
||||
" u32 entry_size: 24\n"
|
||||
" u32 entry_version: 0\n"
|
||||
" varies(entry_size) entries[]: [\n"
|
||||
" [0] entry: {\n"
|
||||
" u64 base_addr: 0x0\n"
|
||||
" u64 length: 654336\n"
|
||||
" u32 type: 1\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" [1] entry: {\n"
|
||||
" u64 base_addr: 0x9fc00\n"
|
||||
" u64 length: 1024\n"
|
||||
" u32 type: 2\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" [2] entry: {\n"
|
||||
" u64 base_addr: 0xf0000\n"
|
||||
" u64 length: 65536\n"
|
||||
" u32 type: 2\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" [3] entry: {\n"
|
||||
" u64 base_addr: 0x100000\n"
|
||||
" u64 length: 133038080\n"
|
||||
" u32 type: 1\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" [4] entry: {\n"
|
||||
" u64 base_addr: 0x7fe0000\n"
|
||||
" u64 length: 131072\n"
|
||||
" u32 type: 2\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" [5] entry: {\n"
|
||||
" u64 base_addr: 0xfffc0000\n"
|
||||
" u64 length: 262144\n"
|
||||
" u32 type: 2\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" ]\n"
|
||||
"}\n";
|
||||
|
||||
static const char output2_part2[] =
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 7 (VBE info)\n"
|
||||
" u32 size: 784\n"
|
||||
" u16 vbe_mode: 0\n"
|
||||
" u16 vbe_interface_seg: 123\n"
|
||||
" u16 vbe_interface_off: 456\n"
|
||||
" u16 vbe_interface_len: 789\n"
|
||||
" u8 vbe_control_info[]: [\n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 123 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 123\n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" ]\n"
|
||||
" u8 vbe_mode_info[]: [\n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255\n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" ]\n"
|
||||
"}\n";
|
||||
|
||||
static const char output2_part3[] =
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 8 (framebuffer info)\n"
|
||||
" u32 size: 40\n"
|
||||
" u64 framebuffer_addr: 0x7b\n"
|
||||
" u32 framebuffer_pitch: 456\n"
|
||||
" u32 framebuffer_width: 123\n"
|
||||
" u32 framebuffer_height: 456\n"
|
||||
" u8 framebuffer_bpp: 8\n"
|
||||
" u8 framebuffer_type: 1\n"
|
||||
" u16 reserved: 0x0\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 9 (ELF symbols)\n"
|
||||
" u32 size: 420\n"
|
||||
" u32 num: 10\n"
|
||||
" u32 entsize: 40\n"
|
||||
" u32 shndx: 9\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 10 (APM table)\n"
|
||||
" u32 size: 28\n"
|
||||
" u16 version: 0\n"
|
||||
" u16 cseg: 123\n"
|
||||
" u32 offset: 456\n"
|
||||
" u16 cseg_16: 789\n"
|
||||
" u16 dseg: 123\n"
|
||||
" u16 flags: 1\n"
|
||||
" u16 cseg_len: 456\n"
|
||||
" u16 cseg_16_len: 789\n"
|
||||
" u16 dseg_len: 123\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 11 (EFI 32bit system table ptr)\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 pointer: 0\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 12 (EFI 64bit system table ptr)\n"
|
||||
" u32 size: 16\n"
|
||||
" u64 pointer: 0\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 13 (SMBIOS tables)\n"
|
||||
" u32 size: 24\n"
|
||||
" u8 major: 1\n"
|
||||
" u8 minor: 2\n"
|
||||
" u8 reserved[6]: [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 14 (ACPI old RSDP)\n"
|
||||
" u32 size: 16\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 15 (ACPI new RSDP)\n"
|
||||
" u32 size: 16\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 16 (networking info)\n"
|
||||
" u32 size: 16\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 17 (EFI memory map)\n"
|
||||
" u32 size: 24\n"
|
||||
" u32 descriptor_size: 123\n"
|
||||
" u32 descriptor_version: 1\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 18 (EFI boot services not terminated)\n"
|
||||
" u32 size: 8\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 19 (EFI 32bit image handle ptr)\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 pointer: 0\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 20 (EFI 64bit image handle ptr)\n"
|
||||
" u32 size: 16\n"
|
||||
" u64 pointer: 0\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 21 (image load base phys addr)\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 load_base_addr: 0x7b\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 0 (none)\n"
|
||||
" u32 size: 8\n"
|
||||
"}\n";
|
||||
static const char output2[] =
|
||||
"Multiboot 2 info\n"
|
||||
" size: 1816\n"
|
||||
" reserved1: 0\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 1 (boot cmd line)\n"
|
||||
" size: 23\n"
|
||||
" cmdline: Hello, Kernel!\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 2 (boot loader name)\n"
|
||||
" size: 30\n"
|
||||
" name: GRUB 2.02-2ubuntu8.20\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 3 (module)\n"
|
||||
" size: 33\n"
|
||||
" start: 123\n"
|
||||
" end: 456\n"
|
||||
" cmdline: Hello, Module 1!\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 3 (module)\n"
|
||||
" size: 33\n"
|
||||
" start: 123\n"
|
||||
" end: 456\n"
|
||||
" cmdline: Hello, Module 2!\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 4 (basic memory info)\n"
|
||||
" size: 16\n"
|
||||
" mem lower: 123\n"
|
||||
" mem upper: 456\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 5 (BIOS boot device)\n"
|
||||
" size: 20\n"
|
||||
" bios dev: 0\n"
|
||||
" partition: 1\n"
|
||||
" sub_partition: 2\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 6 (memory map)\n"
|
||||
" size: 160\n"
|
||||
" entry size: 24\n"
|
||||
" entry version: 0\n"
|
||||
" entries:\n"
|
||||
" entry 0\n"
|
||||
" base addr: 0\n"
|
||||
" length: 654336\n"
|
||||
" type: 1\n"
|
||||
" reserved1: 0\n"
|
||||
" entry 1\n"
|
||||
" base addr: 654336\n"
|
||||
" length: 1024\n"
|
||||
" type: 2\n"
|
||||
" reserved1: 0\n"
|
||||
" entry 2\n"
|
||||
" base addr: 983040\n"
|
||||
" length: 65536\n"
|
||||
" type: 2\n"
|
||||
" reserved1: 0\n"
|
||||
" entry 3\n"
|
||||
" base addr: 1048576\n"
|
||||
" length: 133038080\n"
|
||||
" type: 1\n"
|
||||
" reserved1: 0\n"
|
||||
" entry 4\n"
|
||||
" base addr: 134086656\n"
|
||||
" length: 131072\n"
|
||||
" type: 2\n"
|
||||
" reserved1: 0\n"
|
||||
" entry 5\n"
|
||||
" base addr: 4294705152\n"
|
||||
" length: 262144\n"
|
||||
" type: 2\n"
|
||||
" reserved1: 0\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 7 (VBE info)\n"
|
||||
" size: 784\n"
|
||||
" VBE mode: 0\n"
|
||||
" VBE interface seg: 123\n"
|
||||
" VBE interface off: 456\n"
|
||||
" VBE interface len: 789\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 8 (framebuffer info)\n"
|
||||
" size: 39\n"
|
||||
" framebuffer addr: 123\n"
|
||||
" framebuffer pitch: 456\n"
|
||||
" framebuffer width: 123\n"
|
||||
" framebuffer height: 456\n"
|
||||
" framebuffer bpp: 8\n"
|
||||
" framebuffer type: 1\n"
|
||||
" reserved1: 0\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 9 (ELF symbols)\n"
|
||||
" size: 420\n"
|
||||
" num: 10\n"
|
||||
" entsize: 0\n"
|
||||
" shndx: 40\n"
|
||||
" reserved1: 0\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 10 (APM table)\n"
|
||||
" size: 28\n"
|
||||
" version: 0\n"
|
||||
" cseg: 123\n"
|
||||
" offset: 456\n"
|
||||
" cseg 16: 789\n"
|
||||
" dseg: 123\n"
|
||||
" flags: 1\n"
|
||||
" cseg len: 456\n"
|
||||
" cseg 16 len: 789\n"
|
||||
" dseg len: 123\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 11 (EFI 32bit system table ptr)\n"
|
||||
" size: 12\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 12 (EFI 64bit system table ptr)\n"
|
||||
" size: 16\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 13 (SMBIOS tables)\n"
|
||||
" size: 24\n"
|
||||
" major: 1\n"
|
||||
" minor: 2\n"
|
||||
" reserved1: {0, 0, 0, 0, 0, 0}\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 14 (ACPI old RSDP)\n"
|
||||
" size: 16\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 15 (ACPI new RSDP)\n"
|
||||
" size: 16\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 16 (networking info)\n"
|
||||
" size: 16\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 17 (EFI memory map)\n"
|
||||
" size: 24\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 18 (EFI boot services not terminated)\n"
|
||||
" size: 8\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 19 (EFI 32bit image handle ptr)\n"
|
||||
" size: 12\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 20 (EFI 64bit image handle ptr)\n"
|
||||
" size: 16\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 21 (image load base phys addr)\n"
|
||||
" size: 12\n"
|
||||
" load base addr: 123\n"
|
||||
"Multiboot 2 info tag\n"
|
||||
" type: 0 (none)\n"
|
||||
" size: 8\n";
|
||||
|
||||
void test_main()
|
||||
{
|
||||
{
|
||||
FILE *const fd = popen("./multiboot2_info_print0", "r");
|
||||
assert(fd != NULL);
|
||||
|
||||
for (const char *ch = output0; *ch; ++ch) {
|
||||
assert(fgetc(fd) == *ch);
|
||||
}
|
||||
|
||||
const int status = pclose(fd);
|
||||
assert(status == 0);
|
||||
}
|
||||
|
||||
{
|
||||
FILE *const fd = popen("./multiboot2_info_print1", "r");
|
||||
assert(fd != NULL);
|
||||
|
@ -419,15 +283,6 @@ void test_main()
|
|||
}
|
||||
|
||||
{
|
||||
const size_t part1_len = strlen(output2_part1);
|
||||
const size_t part2_len = strlen(output2_part2);
|
||||
const size_t part3_len = strlen(output2_part3);
|
||||
char *const output2 = malloc(1 + part1_len + part2_len + part3_len);
|
||||
assert(output2);
|
||||
strcpy(output2, output2_part1);
|
||||
strcat(output2, output2_part2);
|
||||
strcat(output2, output2_part3);
|
||||
|
||||
FILE *const fd = popen("./multiboot2_info_print2", "r");
|
||||
assert(fd != NULL);
|
||||
|
||||
|
|
|
@ -328,7 +328,7 @@ tag_bios_boot_device_valid = {
|
|||
.type = KERNAUX_MULTIBOOT2_ITAG_BIOS_BOOT_DEVICE,
|
||||
.size = 20,
|
||||
},
|
||||
.biosdev = 123,
|
||||
.bios_dev = 123,
|
||||
.partition = 456,
|
||||
.sub_partition = 789,
|
||||
};
|
||||
|
@ -339,7 +339,7 @@ tag_bios_boot_device_invalid_type = {
|
|||
.type = KERNAUX_MULTIBOOT2_ITAG_NONE,
|
||||
.size = 20,
|
||||
},
|
||||
.biosdev = 123,
|
||||
.bios_dev = 123,
|
||||
.partition = 456,
|
||||
.sub_partition = 789,
|
||||
};
|
||||
|
@ -350,7 +350,7 @@ tag_bios_boot_device_invalid_size = {
|
|||
.type = KERNAUX_MULTIBOOT2_ITAG_BIOS_BOOT_DEVICE,
|
||||
.size = 21,
|
||||
},
|
||||
.biosdev = 123,
|
||||
.bios_dev = 123,
|
||||
.partition = 456,
|
||||
.sub_partition = 789,
|
||||
};
|
||||
|
@ -530,14 +530,15 @@ tag_vbe_info_invalid_size = {
|
|||
******************/
|
||||
|
||||
static const struct KernAux_Multiboot2_ITag_ELFSymbols
|
||||
tag_elf_symbols_with_zero_entsize_valid = {
|
||||
tag_elf_symbols_with_zero_ent_size_valid = {
|
||||
.base = {
|
||||
.type = KERNAUX_MULTIBOOT2_ITAG_ELF_SYMBOLS,
|
||||
.size = 20,
|
||||
.size = 16,
|
||||
},
|
||||
.num = 0,
|
||||
.entsize = 0,
|
||||
.ent_size = 0,
|
||||
.shndx = 0,
|
||||
.reserved1 = 0,
|
||||
};
|
||||
|
||||
/**************
|
||||
|
@ -550,7 +551,7 @@ static const struct {
|
|||
} KERNAUX_PACKED multiboot2_empty_valid = {
|
||||
.multiboot2_info = {
|
||||
.total_size = 8 + 8,
|
||||
.reserved = 0,
|
||||
.reserved1 = 0,
|
||||
},
|
||||
.tag_none = {
|
||||
.base = {
|
||||
|
@ -567,7 +568,7 @@ static const struct {
|
|||
} KERNAUX_PACKED multiboot2_with_some_additional_tag_valid = {
|
||||
.multiboot2_info = {
|
||||
.total_size = 8 + 16 + 8,
|
||||
.reserved = 0,
|
||||
.reserved1 = 0,
|
||||
},
|
||||
.tag_basic_memory_info = {
|
||||
.base = {
|
||||
|
@ -594,7 +595,7 @@ static const struct {
|
|||
} KERNAUX_PACKED multiboot2_with_more_additional_tags_valid = {
|
||||
.multiboot2_info = {
|
||||
.total_size = 8 + 16 + (20 + 4) + 8,
|
||||
.reserved = 0,
|
||||
.reserved1 = 0,
|
||||
},
|
||||
.tag_basic_memory_info = {
|
||||
.base = {
|
||||
|
@ -609,7 +610,7 @@ static const struct {
|
|||
.type = KERNAUX_MULTIBOOT2_ITAG_BIOS_BOOT_DEVICE,
|
||||
.size = 20,
|
||||
},
|
||||
.biosdev = 123,
|
||||
.bios_dev = 123,
|
||||
.partition = 456,
|
||||
.sub_partition = 789,
|
||||
},
|
||||
|
@ -627,7 +628,7 @@ static const struct {
|
|||
} KERNAUX_PACKED multiboot2_empty_invalid_size = {
|
||||
.multiboot2_info = {
|
||||
.total_size = 8,
|
||||
.reserved = 0,
|
||||
.reserved1 = 0,
|
||||
},
|
||||
.tag_none = {
|
||||
.base = {
|
||||
|
@ -640,7 +641,7 @@ static const struct {
|
|||
static const struct KernAux_Multiboot2_Info
|
||||
multiboot2_without_none_tag_invalid = {
|
||||
.total_size = 8,
|
||||
.reserved = 0,
|
||||
.reserved1 = 0,
|
||||
};
|
||||
|
||||
static const struct {
|
||||
|
@ -649,7 +650,7 @@ static const struct {
|
|||
} KERNAUX_PACKED multiboot2_with_invalid_last_tag_invalid = {
|
||||
.multiboot2_info = {
|
||||
.total_size = 8 + 16,
|
||||
.reserved = 0,
|
||||
.reserved1 = 0,
|
||||
},
|
||||
.tag_basic_memory_info = {
|
||||
.base = {
|
||||
|
@ -671,7 +672,7 @@ static const struct {
|
|||
} KERNAUX_PACKED multiboot2_with_early_none_tag_invalid = {
|
||||
.multiboot2_info = {
|
||||
.total_size = 8 + 16 + 8 + (20 + 4) + 8,
|
||||
.reserved = 0,
|
||||
.reserved1 = 0,
|
||||
},
|
||||
.tag_basic_memory_info = {
|
||||
.base = {
|
||||
|
@ -692,7 +693,7 @@ static const struct {
|
|||
.type = KERNAUX_MULTIBOOT2_ITAG_BIOS_BOOT_DEVICE,
|
||||
.size = 20,
|
||||
},
|
||||
.biosdev = 123,
|
||||
.bios_dev = 123,
|
||||
.partition = 456,
|
||||
.sub_partition = 789,
|
||||
},
|
||||
|
@ -713,7 +714,7 @@ static const struct {
|
|||
} KERNAUX_PACKED multiboot2_with_more_additional_tags_invalid_size_too_big = {
|
||||
.multiboot2_info = {
|
||||
.total_size = 8 + 16 + (20 + 4) + 8 + 1,
|
||||
.reserved = 0,
|
||||
.reserved1 = 0,
|
||||
},
|
||||
.tag_basic_memory_info = {
|
||||
.base = {
|
||||
|
@ -728,7 +729,7 @@ static const struct {
|
|||
.type = KERNAUX_MULTIBOOT2_ITAG_BIOS_BOOT_DEVICE,
|
||||
.size = 20,
|
||||
},
|
||||
.biosdev = 123,
|
||||
.bios_dev = 123,
|
||||
.partition = 456,
|
||||
.sub_partition = 789,
|
||||
},
|
||||
|
@ -749,7 +750,7 @@ static const struct {
|
|||
} KERNAUX_PACKED multiboot2_with_more_additional_tags_invalid_size_too_small = {
|
||||
.multiboot2_info = {
|
||||
.total_size = 8 + 16 + (20 + 4) + 8 - 1,
|
||||
.reserved = 0,
|
||||
.reserved1 = 0,
|
||||
},
|
||||
.tag_basic_memory_info = {
|
||||
.base = {
|
||||
|
@ -764,7 +765,7 @@ static const struct {
|
|||
.type = KERNAUX_MULTIBOOT2_ITAG_BIOS_BOOT_DEVICE,
|
||||
.size = 20,
|
||||
},
|
||||
.biosdev = 123,
|
||||
.bios_dev = 123,
|
||||
.partition = 456,
|
||||
.sub_partition = 789,
|
||||
},
|
||||
|
@ -954,7 +955,7 @@ void test_main()
|
|||
));
|
||||
|
||||
assert(KernAux_Multiboot2_ITagBase_is_valid(
|
||||
&tag_elf_symbols_with_zero_entsize_valid.base
|
||||
&tag_elf_symbols_with_zero_ent_size_valid.base
|
||||
));
|
||||
|
||||
// Tag_None
|
||||
|
@ -1123,6 +1124,6 @@ void test_main()
|
|||
|
||||
|
||||
assert(KernAux_Multiboot2_ITag_ELFSymbols_is_valid(
|
||||
&tag_elf_symbols_with_zero_entsize_valid
|
||||
&tag_elf_symbols_with_zero_ent_size_valid
|
||||
));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue