Rename Multiboot2 info struct

This commit is contained in:
Alex Kotov 2022-01-13 08:59:52 +05:00
parent ab84e5892f
commit 9227f70f10
9 changed files with 186 additions and 179 deletions

View File

@ -74,7 +74,7 @@ enum KernAux_Multiboot2_ITag {
KERNAUX_MULTIBOOT2_ITAG_IMAGE_LOAD_BASE_PHYS_ADDR = 21, KERNAUX_MULTIBOOT2_ITAG_IMAGE_LOAD_BASE_PHYS_ADDR = 21,
}; };
struct KernAux_Multiboot2 { struct KernAux_Multiboot2_Info {
uint32_t total_size; uint32_t total_size;
uint32_t reserved1; uint32_t reserved1;
} }
@ -321,28 +321,28 @@ __attribute__((packed));
********************************/ ********************************/
const struct KernAux_Multiboot2_ITagBase const struct KernAux_Multiboot2_ITagBase
*KernAux_Multiboot2_first_tag_with_type( *KernAux_Multiboot2_Info_first_tag_with_type(
const struct KernAux_Multiboot2 *multiboot2, const struct KernAux_Multiboot2_Info *multiboot2_info,
enum KernAux_Multiboot2_ITag tag_type enum KernAux_Multiboot2_ITag tag_type
); );
const struct KernAux_Multiboot2_ITagBase const struct KernAux_Multiboot2_ITagBase
*KernAux_Multiboot2_tag_with_type_after( *KernAux_Multiboot2_Info_tag_with_type_after(
const struct KernAux_Multiboot2 *multiboot2, const struct KernAux_Multiboot2_Info *multiboot2_info,
enum KernAux_Multiboot2_ITag tag_type, enum KernAux_Multiboot2_ITag tag_type,
const struct KernAux_Multiboot2_ITagBase *after_tag const struct KernAux_Multiboot2_ITagBase *after_tag
); );
const char *KernAux_Multiboot2_boot_cmd_line( const char *KernAux_Multiboot2_Info_boot_cmd_line(
const struct KernAux_Multiboot2 *multiboot2 const struct KernAux_Multiboot2_Info *multiboot2_info
); );
/******************************* /*******************************
* Information print functions * * Information print functions *
*******************************/ *******************************/
void KernAux_Multiboot2_print( void KernAux_Multiboot2_Info_print(
const struct KernAux_Multiboot2 *multiboot2, const struct KernAux_Multiboot2_Info *multiboot2_info,
void (*printf)(const char *format, ...) void (*printf)(const char *format, ...)
); );
@ -355,8 +355,8 @@ void KernAux_Multiboot2_ITagBase_print(
* Information validation functions * * Information validation functions *
************************************/ ************************************/
bool KernAux_Multiboot2_is_valid( bool KernAux_Multiboot2_Info_is_valid(
const struct KernAux_Multiboot2 *multiboot2 const struct KernAux_Multiboot2_Info *multiboot2_info
); );
bool KernAux_Multiboot2_ITagBase_is_valid( bool KernAux_Multiboot2_ITagBase_is_valid(

View File

@ -7,17 +7,17 @@
#include <stddef.h> #include <stddef.h>
const struct KernAux_Multiboot2_ITagBase const struct KernAux_Multiboot2_ITagBase
*KernAux_Multiboot2_first_tag_with_type( *KernAux_Multiboot2_Info_first_tag_with_type(
const struct KernAux_Multiboot2 *const multiboot2, const struct KernAux_Multiboot2_Info *const multiboot2_info,
const enum KernAux_Multiboot2_ITag tag_type const enum KernAux_Multiboot2_ITag tag_type
) { ) {
const struct KernAux_Multiboot2_ITagBase *tag_base = const struct KernAux_Multiboot2_ITagBase *tag_base =
(struct KernAux_Multiboot2_ITagBase*) (struct KernAux_Multiboot2_ITagBase*)
KERNAUX_MULTIBOOT2_DATA(multiboot2); KERNAUX_MULTIBOOT2_DATA(multiboot2_info);
while (tag_base < while (tag_base <
(struct KernAux_Multiboot2_ITagBase*) (struct KernAux_Multiboot2_ITagBase*)
((unsigned char*)multiboot2 + multiboot2->total_size)) ((unsigned char*)multiboot2_info + multiboot2_info->total_size))
{ {
if (!KernAux_Multiboot2_ITagBase_is_valid(tag_base)) return NULL; if (!KernAux_Multiboot2_ITagBase_is_valid(tag_base)) return NULL;
if (tag_base->type == tag_type) return tag_base; if (tag_base->type == tag_type) return tag_base;
@ -31,18 +31,18 @@ const struct KernAux_Multiboot2_ITagBase
} }
const struct KernAux_Multiboot2_ITagBase const struct KernAux_Multiboot2_ITagBase
*KernAux_Multiboot2_tag_with_type_after( *KernAux_Multiboot2_Info_tag_with_type_after(
const struct KernAux_Multiboot2 *const multiboot2, const struct KernAux_Multiboot2_Info *const multiboot2_info,
const enum KernAux_Multiboot2_ITag tag_type, const enum KernAux_Multiboot2_ITag tag_type,
const struct KernAux_Multiboot2_ITagBase *const after_tag const struct KernAux_Multiboot2_ITagBase *const after_tag
) { ) {
const struct KernAux_Multiboot2_ITagBase *tag_base = const struct KernAux_Multiboot2_ITagBase *tag_base =
(struct KernAux_Multiboot2_ITagBase*) (struct KernAux_Multiboot2_ITagBase*)
KERNAUX_MULTIBOOT2_DATA(multiboot2); KERNAUX_MULTIBOOT2_DATA(multiboot2_info);
while (tag_base < while (tag_base <
(struct KernAux_Multiboot2_ITagBase*) (struct KernAux_Multiboot2_ITagBase*)
(unsigned char*)multiboot2 + multiboot2->total_size) (unsigned char*)multiboot2_info + multiboot2_info->total_size)
{ {
if (!KernAux_Multiboot2_ITagBase_is_valid(tag_base)) return NULL; if (!KernAux_Multiboot2_ITagBase_is_valid(tag_base)) return NULL;
if (tag_base->type == tag_type && tag_base > after_tag) return tag_base; if (tag_base->type == tag_type && tag_base > after_tag) return tag_base;
@ -55,13 +55,13 @@ const struct KernAux_Multiboot2_ITagBase
return NULL; return NULL;
} }
const char *KernAux_Multiboot2_boot_cmd_line( const char *KernAux_Multiboot2_Info_boot_cmd_line(
const struct KernAux_Multiboot2 *const multiboot2 const struct KernAux_Multiboot2_Info *const multiboot2_info
) { ) {
const struct KernAux_Multiboot2_ITag_BootCmdLine *const tag = const struct KernAux_Multiboot2_ITag_BootCmdLine *const tag =
(struct KernAux_Multiboot2_ITag_BootCmdLine*) (struct KernAux_Multiboot2_ITag_BootCmdLine*)
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
multiboot2, multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_BOOT_CMD_LINE KERNAUX_MULTIBOOT2_ITAG_BOOT_CMD_LINE
); );

View File

@ -6,20 +6,20 @@
#include <stddef.h> #include <stddef.h>
bool KernAux_Multiboot2_is_valid( bool KernAux_Multiboot2_Info_is_valid(
const struct KernAux_Multiboot2 *const multiboot2 const struct KernAux_Multiboot2_Info *const multiboot2_info
) { ) {
if (multiboot2->total_size <= 8) return false; if (multiboot2_info->total_size <= 8) return false;
const struct KernAux_Multiboot2_ITagBase *tag_base = const struct KernAux_Multiboot2_ITagBase *tag_base =
(struct KernAux_Multiboot2_ITagBase*) (struct KernAux_Multiboot2_ITagBase*)
KERNAUX_MULTIBOOT2_DATA(multiboot2); KERNAUX_MULTIBOOT2_DATA(multiboot2_info);
const struct KernAux_Multiboot2_ITagBase *none_tag_base = NULL; const struct KernAux_Multiboot2_ITagBase *none_tag_base = NULL;
while (tag_base < while (tag_base <
(struct KernAux_Multiboot2_ITagBase*) (struct KernAux_Multiboot2_ITagBase*)
((unsigned char*)multiboot2 + multiboot2->total_size)) ((unsigned char*)multiboot2_info + multiboot2_info->total_size))
{ {
if (!KernAux_Multiboot2_ITagBase_is_valid(tag_base)) return false; if (!KernAux_Multiboot2_ITagBase_is_valid(tag_base)) return false;
@ -36,7 +36,7 @@ bool KernAux_Multiboot2_is_valid(
if (tag_base != if (tag_base !=
(struct KernAux_Multiboot2_ITagBase*) (struct KernAux_Multiboot2_ITagBase*)
((unsigned char*)multiboot2 + multiboot2->total_size)) ((unsigned char*)multiboot2_info + multiboot2_info->total_size))
{ {
return false; return false;
} }

View File

@ -73,21 +73,21 @@ const char *KernAux_Multiboot2_ITag_to_str(
} }
} }
void KernAux_Multiboot2_print( void KernAux_Multiboot2_Info_print(
const struct KernAux_Multiboot2 *const multiboot2, const struct KernAux_Multiboot2_Info *const multiboot2_info,
void (*const printf)(const char *format, ...) __attribute__((format(printf, 1, 2))) void (*const printf)(const char *format, ...) __attribute__((format(printf, 1, 2)))
) { ) {
printf("Multiboot 2 info\n"); printf("Multiboot 2 info\n");
printf(" size: %u\n", multiboot2->total_size); printf(" size: %u\n", multiboot2_info->total_size);
printf(" reserved1: %u\n", multiboot2->reserved1); printf(" reserved1: %u\n", multiboot2_info->reserved1);
const struct KernAux_Multiboot2_ITagBase *tag_base = const struct KernAux_Multiboot2_ITagBase *tag_base =
(struct KernAux_Multiboot2_ITagBase*) (struct KernAux_Multiboot2_ITagBase*)
KERNAUX_MULTIBOOT2_DATA(multiboot2); KERNAUX_MULTIBOOT2_DATA(multiboot2_info);
while (tag_base < while (tag_base <
(struct KernAux_Multiboot2_ITagBase*) (struct KernAux_Multiboot2_ITagBase*)
((unsigned char*)multiboot2 + multiboot2->total_size)) ((unsigned char*)multiboot2_info + multiboot2_info->total_size))
{ {
if (!KernAux_Multiboot2_ITagBase_is_valid(tag_base)) return; if (!KernAux_Multiboot2_ITagBase_is_valid(tag_base)) return;

View File

@ -1,5 +1,5 @@
static const struct { static const struct {
struct KernAux_Multiboot2 multiboot2; struct KernAux_Multiboot2_Info multiboot2_info;
struct { struct {
struct KernAux_Multiboot2_ITag_BootCmdLine tag; struct KernAux_Multiboot2_ITag_BootCmdLine tag;
@ -113,7 +113,7 @@ static const struct {
struct KernAux_Multiboot2_ITag_None tag_none; struct KernAux_Multiboot2_ITag_None tag_none;
} multiboot2_example2 = { } multiboot2_example2 = {
.multiboot2 = { .multiboot2_info = {
.total_size = sizeof(multiboot2_example2), .total_size = sizeof(multiboot2_example2),
.reserved1 = 0, .reserved1 = 0,
}, },

View File

@ -11,12 +11,12 @@
int main() int main()
{ {
assert(KernAux_Multiboot2_is_valid( assert(KernAux_Multiboot2_Info_is_valid(
(struct KernAux_Multiboot2*)multiboot2_example1 (struct KernAux_Multiboot2_Info*)multiboot2_example1
)); ));
KernAux_Multiboot2_print( KernAux_Multiboot2_Info_print(
(struct KernAux_Multiboot2*)multiboot2_example1, (struct KernAux_Multiboot2_Info*)multiboot2_example1,
(void (*)(const char *format, ...))printf (void (*)(const char *format, ...))printf
); );

View File

@ -11,10 +11,12 @@
int main() int main()
{ {
assert(KernAux_Multiboot2_is_valid(&multiboot2_example2.multiboot2)); assert(KernAux_Multiboot2_Info_is_valid(
&multiboot2_example2.multiboot2_info
));
KernAux_Multiboot2_print( KernAux_Multiboot2_Info_print(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
(void (*)(const char *format, ...))printf (void (*)(const char *format, ...))printf
); );

View File

@ -10,10 +10,10 @@
#include "multiboot2_example2.h" #include "multiboot2_example2.h"
static const struct { static const struct {
struct KernAux_Multiboot2 multiboot2; struct KernAux_Multiboot2_Info multiboot2_info;
struct KernAux_Multiboot2_ITag_None tag_none; struct KernAux_Multiboot2_ITag_None tag_none;
} multiboot2_without_boot_cmd_line = { } multiboot2_without_boot_cmd_line = {
.multiboot2 = { .multiboot2_info = {
.total_size = sizeof(multiboot2_without_boot_cmd_line), .total_size = sizeof(multiboot2_without_boot_cmd_line),
.reserved1 = 0, .reserved1 = 0,
}, },
@ -26,7 +26,7 @@ static const struct {
}; };
static const struct { static const struct {
struct KernAux_Multiboot2 multiboot2; struct KernAux_Multiboot2_Info multiboot2_info;
struct { struct {
struct KernAux_Multiboot2_ITag_BootCmdLine tag; struct KernAux_Multiboot2_ITag_BootCmdLine tag;
@ -37,7 +37,7 @@ static const struct {
struct KernAux_Multiboot2_ITag_None tag_none; struct KernAux_Multiboot2_ITag_None tag_none;
} multiboot2_with_some_boot_cmd_line = { } multiboot2_with_some_boot_cmd_line = {
.multiboot2 = { .multiboot2_info = {
.total_size = sizeof(multiboot2_with_some_boot_cmd_line), .total_size = sizeof(multiboot2_with_some_boot_cmd_line),
.reserved1 = 0, .reserved1 = 0,
}, },
@ -61,7 +61,7 @@ static const struct {
}; };
static const struct { static const struct {
struct KernAux_Multiboot2 multiboot2; struct KernAux_Multiboot2_Info multiboot2_info;
struct { struct {
struct KernAux_Multiboot2_ITag_BootCmdLine tag; struct KernAux_Multiboot2_ITag_BootCmdLine tag;
@ -79,7 +79,7 @@ static const struct {
struct KernAux_Multiboot2_ITag_None tag_none; struct KernAux_Multiboot2_ITag_None tag_none;
} multiboot2_with_two_boot_cmd_lines = { } multiboot2_with_two_boot_cmd_lines = {
.multiboot2 = { .multiboot2_info = {
.total_size = sizeof(multiboot2_with_two_boot_cmd_lines), .total_size = sizeof(multiboot2_with_two_boot_cmd_lines),
.reserved1 = 0, .reserved1 = 0,
}, },
@ -115,238 +115,238 @@ static const struct {
int main() int main()
{ {
assert(KernAux_Multiboot2_is_valid( assert(KernAux_Multiboot2_Info_is_valid(
(struct KernAux_Multiboot2*)multiboot2_example1 (struct KernAux_Multiboot2_Info*)multiboot2_example1
)); ));
assert(KernAux_Multiboot2_is_valid( assert(KernAux_Multiboot2_Info_is_valid(
&multiboot2_example2.multiboot2 &multiboot2_example2.multiboot2_info
)); ));
assert(KernAux_Multiboot2_is_valid( assert(KernAux_Multiboot2_Info_is_valid(
&multiboot2_without_boot_cmd_line.multiboot2 &multiboot2_without_boot_cmd_line.multiboot2_info
)); ));
assert(KernAux_Multiboot2_is_valid( assert(KernAux_Multiboot2_Info_is_valid(
&multiboot2_with_some_boot_cmd_line.multiboot2 &multiboot2_with_some_boot_cmd_line.multiboot2_info
)); ));
assert(KernAux_Multiboot2_is_valid( assert(KernAux_Multiboot2_Info_is_valid(
&multiboot2_with_two_boot_cmd_lines.multiboot2 &multiboot2_with_two_boot_cmd_lines.multiboot2_info
)); ));
assert( assert(
KernAux_Multiboot2_boot_cmd_line( KernAux_Multiboot2_Info_boot_cmd_line(
&multiboot2_without_boot_cmd_line.multiboot2 &multiboot2_without_boot_cmd_line.multiboot2_info
) == 0 ) == 0
); );
// KernAux_Multiboot2_first_tag_with_type // KernAux_Multiboot2_Info_first_tag_with_type
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
(struct KernAux_Multiboot2*)multiboot2_example1, (struct KernAux_Multiboot2_Info*)multiboot2_example1,
KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_SYSTEM_TABLE_PTR KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_SYSTEM_TABLE_PTR
) == 0 ) == 0
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
(struct KernAux_Multiboot2*)multiboot2_example1, (struct KernAux_Multiboot2_Info*)multiboot2_example1,
KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_SYSTEM_TABLE_PTR KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_SYSTEM_TABLE_PTR
) == 0 ) == 0
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
(struct KernAux_Multiboot2*)multiboot2_example1, (struct KernAux_Multiboot2_Info*)multiboot2_example1,
KERNAUX_MULTIBOOT2_ITAG_SMBIOS_TABLES KERNAUX_MULTIBOOT2_ITAG_SMBIOS_TABLES
) == 0 ) == 0
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
(struct KernAux_Multiboot2*)multiboot2_example1, (struct KernAux_Multiboot2_Info*)multiboot2_example1,
KERNAUX_MULTIBOOT2_ITAG_ACPI_NEW_RSDP KERNAUX_MULTIBOOT2_ITAG_ACPI_NEW_RSDP
) == 0 ) == 0
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
(struct KernAux_Multiboot2*)multiboot2_example1, (struct KernAux_Multiboot2_Info*)multiboot2_example1,
KERNAUX_MULTIBOOT2_ITAG_NETWORKING_INFO KERNAUX_MULTIBOOT2_ITAG_NETWORKING_INFO
) == 0 ) == 0
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
(struct KernAux_Multiboot2*)multiboot2_example1, (struct KernAux_Multiboot2_Info*)multiboot2_example1,
KERNAUX_MULTIBOOT2_ITAG_EFI_MEMORY_MAP KERNAUX_MULTIBOOT2_ITAG_EFI_MEMORY_MAP
) == 0 ) == 0
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
(struct KernAux_Multiboot2*)multiboot2_example1, (struct KernAux_Multiboot2_Info*)multiboot2_example1,
KERNAUX_MULTIBOOT2_ITAG_EFI_BOOT_SERVICES_NOT_TERMINATED KERNAUX_MULTIBOOT2_ITAG_EFI_BOOT_SERVICES_NOT_TERMINATED
) == 0 ) == 0
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
(struct KernAux_Multiboot2*)multiboot2_example1, (struct KernAux_Multiboot2_Info*)multiboot2_example1,
KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_IMAGE_HANDLE_PTR KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_IMAGE_HANDLE_PTR
) == 0 ) == 0
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
(struct KernAux_Multiboot2*)multiboot2_example1, (struct KernAux_Multiboot2_Info*)multiboot2_example1,
KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_IMAGE_HANDLE_PTR KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_IMAGE_HANDLE_PTR
) == 0 ) == 0
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_NONE KERNAUX_MULTIBOOT2_ITAG_NONE
) == &multiboot2_example2.tag_none.base ) == &multiboot2_example2.tag_none.base
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_BOOT_CMD_LINE KERNAUX_MULTIBOOT2_ITAG_BOOT_CMD_LINE
) == &multiboot2_example2.tag_boot_cmd_line.tag.base ) == &multiboot2_example2.tag_boot_cmd_line.tag.base
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_BOOT_LOADER_NAME KERNAUX_MULTIBOOT2_ITAG_BOOT_LOADER_NAME
) == &multiboot2_example2.tag_boot_loader_name.tag.base ) == &multiboot2_example2.tag_boot_loader_name.tag.base
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_MODULE KERNAUX_MULTIBOOT2_ITAG_MODULE
) == &multiboot2_example2.tag_module1.tag.base ) == &multiboot2_example2.tag_module1.tag.base
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_BASIC_MEMORY_INFO KERNAUX_MULTIBOOT2_ITAG_BASIC_MEMORY_INFO
) == &multiboot2_example2.tag_basic_memory_info.base ) == &multiboot2_example2.tag_basic_memory_info.base
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_FRAMEBUFFER_INFO KERNAUX_MULTIBOOT2_ITAG_FRAMEBUFFER_INFO
) == &multiboot2_example2.tag_framebuffer_info.tag.base ) == &multiboot2_example2.tag_framebuffer_info.tag.base
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_ELF_SYMBOLS KERNAUX_MULTIBOOT2_ITAG_ELF_SYMBOLS
) == &multiboot2_example2.tag_elf_symbols.tag.base ) == &multiboot2_example2.tag_elf_symbols.tag.base
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_APM_TABLE KERNAUX_MULTIBOOT2_ITAG_APM_TABLE
) == &multiboot2_example2.tag_apm_table.base ) == &multiboot2_example2.tag_apm_table.base
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_SYSTEM_TABLE_PTR KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_SYSTEM_TABLE_PTR
) == &multiboot2_example2.tag_efi_32bit_system_table_ptr.base ) == &multiboot2_example2.tag_efi_32bit_system_table_ptr.base
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_SYSTEM_TABLE_PTR KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_SYSTEM_TABLE_PTR
) == &multiboot2_example2.tag_efi_64bit_system_table_ptr.base ) == &multiboot2_example2.tag_efi_64bit_system_table_ptr.base
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_SMBIOS_TABLES KERNAUX_MULTIBOOT2_ITAG_SMBIOS_TABLES
) == &multiboot2_example2.tag_smbios_tables.tag.base ) == &multiboot2_example2.tag_smbios_tables.tag.base
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_ACPI_OLD_RSDP KERNAUX_MULTIBOOT2_ITAG_ACPI_OLD_RSDP
) == &multiboot2_example2.tag_acpi_old_rsdp.tag.base ) == &multiboot2_example2.tag_acpi_old_rsdp.tag.base
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_ACPI_NEW_RSDP KERNAUX_MULTIBOOT2_ITAG_ACPI_NEW_RSDP
) == &multiboot2_example2.tag_acpi_new_rsdp.tag.base ) == &multiboot2_example2.tag_acpi_new_rsdp.tag.base
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_NETWORKING_INFO KERNAUX_MULTIBOOT2_ITAG_NETWORKING_INFO
) == &multiboot2_example2.tag_networking_info.tag.base ) == &multiboot2_example2.tag_networking_info.tag.base
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_EFI_MEMORY_MAP KERNAUX_MULTIBOOT2_ITAG_EFI_MEMORY_MAP
) == &multiboot2_example2.tag_efi_memory_map.tag.base ) == &multiboot2_example2.tag_efi_memory_map.tag.base
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_EFI_BOOT_SERVICES_NOT_TERMINATED KERNAUX_MULTIBOOT2_ITAG_EFI_BOOT_SERVICES_NOT_TERMINATED
) == &multiboot2_example2.tag_efi_boot_services_not_terminated.base ) == &multiboot2_example2.tag_efi_boot_services_not_terminated.base
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_IMAGE_HANDLE_PTR KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_IMAGE_HANDLE_PTR
) == &multiboot2_example2.tag_efi_32bit_image_handle_ptr.base ) == &multiboot2_example2.tag_efi_32bit_image_handle_ptr.base
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_IMAGE_HANDLE_PTR KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_IMAGE_HANDLE_PTR
) == &multiboot2_example2.tag_efi_64bit_image_handle_ptr.base ) == &multiboot2_example2.tag_efi_64bit_image_handle_ptr.base
); );
assert( assert(
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_IMAGE_LOAD_BASE_PHYS_ADDR KERNAUX_MULTIBOOT2_ITAG_IMAGE_LOAD_BASE_PHYS_ADDR
) == &multiboot2_example2.tag_image_load_base_phys_addr.base ) == &multiboot2_example2.tag_image_load_base_phys_addr.base
); );
// KernAux_Multiboot2_tag_with_type_after // KernAux_Multiboot2_Info_tag_with_type_after
assert( assert(
KernAux_Multiboot2_tag_with_type_after( KernAux_Multiboot2_Info_tag_with_type_after(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_MODULE, KERNAUX_MULTIBOOT2_ITAG_MODULE,
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_MODULE KERNAUX_MULTIBOOT2_ITAG_MODULE
) - 1 ) - 1
) == (struct KernAux_Multiboot2_ITagBase*) ) == (struct KernAux_Multiboot2_ITagBase*)
@ -354,11 +354,11 @@ int main()
); );
assert( assert(
KernAux_Multiboot2_tag_with_type_after( KernAux_Multiboot2_Info_tag_with_type_after(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_MODULE, KERNAUX_MULTIBOOT2_ITAG_MODULE,
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_MODULE KERNAUX_MULTIBOOT2_ITAG_MODULE
) )
) == (struct KernAux_Multiboot2_ITagBase*) ) == (struct KernAux_Multiboot2_ITagBase*)
@ -366,31 +366,31 @@ int main()
); );
assert( assert(
KernAux_Multiboot2_tag_with_type_after( KernAux_Multiboot2_Info_tag_with_type_after(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_MODULE, KERNAUX_MULTIBOOT2_ITAG_MODULE,
KernAux_Multiboot2_tag_with_type_after( KernAux_Multiboot2_Info_tag_with_type_after(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_MODULE, KERNAUX_MULTIBOOT2_ITAG_MODULE,
KernAux_Multiboot2_first_tag_with_type( KernAux_Multiboot2_Info_first_tag_with_type(
&multiboot2_example2.multiboot2, &multiboot2_example2.multiboot2_info,
KERNAUX_MULTIBOOT2_ITAG_MODULE KERNAUX_MULTIBOOT2_ITAG_MODULE
) )
) )
) == 0 ) == 0
); );
// KernAux_Multiboot2_boot_cmd_line // KernAux_Multiboot2_Info_boot_cmd_line
assert( assert(
KernAux_Multiboot2_boot_cmd_line( KernAux_Multiboot2_Info_boot_cmd_line(
&multiboot2_with_some_boot_cmd_line.multiboot2 &multiboot2_with_some_boot_cmd_line.multiboot2_info
) == multiboot2_with_some_boot_cmd_line.tag_boot_cmd_line.cmdline ) == multiboot2_with_some_boot_cmd_line.tag_boot_cmd_line.cmdline
); );
assert( assert(
KernAux_Multiboot2_boot_cmd_line( KernAux_Multiboot2_Info_boot_cmd_line(
&multiboot2_with_two_boot_cmd_lines.multiboot2 &multiboot2_with_two_boot_cmd_lines.multiboot2_info
) == multiboot2_with_two_boot_cmd_lines.tag_boot_cmd_line1.cmdline ) == multiboot2_with_two_boot_cmd_lines.tag_boot_cmd_line1.cmdline
); );

View File

@ -527,10 +527,10 @@ tag_vbe_info_invalid_size = {
**************/ **************/
static const struct { static const struct {
struct KernAux_Multiboot2 multiboot2; struct KernAux_Multiboot2_Info multiboot2_info;
struct KernAux_Multiboot2_ITag_None tag_none; struct KernAux_Multiboot2_ITag_None tag_none;
} multiboot2_empty_valid = { } multiboot2_empty_valid = {
.multiboot2 = { .multiboot2_info = {
.total_size = 8 + 8, .total_size = 8 + 8,
.reserved1 = 0, .reserved1 = 0,
}, },
@ -543,11 +543,11 @@ static const struct {
}; };
static const struct { static const struct {
struct KernAux_Multiboot2 multiboot2; struct KernAux_Multiboot2_Info multiboot2_info;
struct KernAux_Multiboot2_ITag_BasicMemoryInfo tag_basic_memory_info; struct KernAux_Multiboot2_ITag_BasicMemoryInfo tag_basic_memory_info;
struct KernAux_Multiboot2_ITag_None tag_none; struct KernAux_Multiboot2_ITag_None tag_none;
} multiboot2_with_some_additional_tag_valid = { } multiboot2_with_some_additional_tag_valid = {
.multiboot2 = { .multiboot2_info = {
.total_size = 8 + 16 + 8, .total_size = 8 + 16 + 8,
.reserved1 = 0, .reserved1 = 0,
}, },
@ -568,13 +568,13 @@ static const struct {
}; };
static const struct { static const struct {
struct KernAux_Multiboot2 multiboot2; struct KernAux_Multiboot2_Info multiboot2_info;
struct KernAux_Multiboot2_ITag_BasicMemoryInfo tag_basic_memory_info; struct KernAux_Multiboot2_ITag_BasicMemoryInfo tag_basic_memory_info;
struct KernAux_Multiboot2_ITag_BIOSBootDevice tag_bios_boot_device; struct KernAux_Multiboot2_ITag_BIOSBootDevice tag_bios_boot_device;
unsigned char _align1[4]; unsigned char _align1[4];
struct KernAux_Multiboot2_ITag_None tag_none; struct KernAux_Multiboot2_ITag_None tag_none;
} multiboot2_with_more_additional_tags_valid = { } multiboot2_with_more_additional_tags_valid = {
.multiboot2 = { .multiboot2_info = {
.total_size = 8 + 16 + (20 + 4) + 8, .total_size = 8 + 16 + (20 + 4) + 8,
.reserved1 = 0, .reserved1 = 0,
}, },
@ -604,10 +604,10 @@ static const struct {
}; };
static const struct { static const struct {
struct KernAux_Multiboot2 multiboot2; struct KernAux_Multiboot2_Info multiboot2_info;
struct KernAux_Multiboot2_ITag_None tag_none; struct KernAux_Multiboot2_ITag_None tag_none;
} multiboot2_empty_invalid_size = { } multiboot2_empty_invalid_size = {
.multiboot2 = { .multiboot2_info = {
.total_size = 8, .total_size = 8,
.reserved1 = 0, .reserved1 = 0,
}, },
@ -619,16 +619,17 @@ static const struct {
}, },
}; };
static const struct KernAux_Multiboot2 multiboot2_without_none_tag_invalid = { static const struct KernAux_Multiboot2_Info
multiboot2_without_none_tag_invalid = {
.total_size = 8, .total_size = 8,
.reserved1 = 0, .reserved1 = 0,
}; };
static const struct { static const struct {
struct KernAux_Multiboot2 multiboot2; struct KernAux_Multiboot2_Info multiboot2_info;
struct KernAux_Multiboot2_ITag_BasicMemoryInfo tag_basic_memory_info; struct KernAux_Multiboot2_ITag_BasicMemoryInfo tag_basic_memory_info;
} multiboot2_with_invalid_last_tag_invalid = { } multiboot2_with_invalid_last_tag_invalid = {
.multiboot2 = { .multiboot2_info = {
.total_size = 8 + 16, .total_size = 8 + 16,
.reserved1 = 0, .reserved1 = 0,
}, },
@ -643,14 +644,14 @@ static const struct {
}; };
static const struct { static const struct {
struct KernAux_Multiboot2 multiboot2; struct KernAux_Multiboot2_Info multiboot2_info;
struct KernAux_Multiboot2_ITag_BasicMemoryInfo tag_basic_memory_info; struct KernAux_Multiboot2_ITag_BasicMemoryInfo tag_basic_memory_info;
struct KernAux_Multiboot2_ITag_None tag_none1; struct KernAux_Multiboot2_ITag_None tag_none1;
struct KernAux_Multiboot2_ITag_BIOSBootDevice tag_bios_boot_device; struct KernAux_Multiboot2_ITag_BIOSBootDevice tag_bios_boot_device;
unsigned char _align1[4]; unsigned char _align1[4];
struct KernAux_Multiboot2_ITag_None tag_none2; struct KernAux_Multiboot2_ITag_None tag_none2;
} multiboot2_with_early_none_tag_invalid = { } multiboot2_with_early_none_tag_invalid = {
.multiboot2 = { .multiboot2_info = {
.total_size = 8 + 16 + 8 + (20 + 4) + 8, .total_size = 8 + 16 + 8 + (20 + 4) + 8,
.reserved1 = 0, .reserved1 = 0,
}, },
@ -686,13 +687,13 @@ static const struct {
}; };
static const struct { static const struct {
struct KernAux_Multiboot2 multiboot2; struct KernAux_Multiboot2_Info multiboot2_info;
struct KernAux_Multiboot2_ITag_BasicMemoryInfo tag_basic_memory_info; struct KernAux_Multiboot2_ITag_BasicMemoryInfo tag_basic_memory_info;
struct KernAux_Multiboot2_ITag_BIOSBootDevice tag_bios_boot_device; struct KernAux_Multiboot2_ITag_BIOSBootDevice tag_bios_boot_device;
unsigned char _align1[4]; unsigned char _align1[4];
struct KernAux_Multiboot2_ITag_None tag_none; struct KernAux_Multiboot2_ITag_None tag_none;
} multiboot2_with_more_additional_tags_invalid_size_too_big = { } multiboot2_with_more_additional_tags_invalid_size_too_big = {
.multiboot2 = { .multiboot2_info = {
.total_size = 8 + 16 + (20 + 4) + 8 + 1, .total_size = 8 + 16 + (20 + 4) + 8 + 1,
.reserved1 = 0, .reserved1 = 0,
}, },
@ -722,13 +723,13 @@ static const struct {
}; };
static const struct { static const struct {
struct KernAux_Multiboot2 multiboot2; struct KernAux_Multiboot2_Info multiboot2_info;
struct KernAux_Multiboot2_ITag_BasicMemoryInfo tag_basic_memory_info; struct KernAux_Multiboot2_ITag_BasicMemoryInfo tag_basic_memory_info;
struct KernAux_Multiboot2_ITag_BIOSBootDevice tag_bios_boot_device; struct KernAux_Multiboot2_ITag_BIOSBootDevice tag_bios_boot_device;
unsigned char _align1[4]; unsigned char _align1[4];
struct KernAux_Multiboot2_ITag_None tag_none; struct KernAux_Multiboot2_ITag_None tag_none;
} multiboot2_with_more_additional_tags_invalid_size_too_small = { } multiboot2_with_more_additional_tags_invalid_size_too_small = {
.multiboot2 = { .multiboot2_info = {
.total_size = 8 + 16 + (20 + 4) + 8 - 1, .total_size = 8 + 16 + (20 + 4) + 8 - 1,
.reserved1 = 0, .reserved1 = 0,
}, },
@ -765,45 +766,49 @@ int main()
{ {
// Multiboot2 // Multiboot2
assert(KernAux_Multiboot2_is_valid( assert(KernAux_Multiboot2_Info_is_valid(
(struct KernAux_Multiboot2*)&multiboot2_example1 (struct KernAux_Multiboot2_Info*)&multiboot2_example1
)); ));
assert(KernAux_Multiboot2_is_valid( assert(KernAux_Multiboot2_Info_is_valid(
(struct KernAux_Multiboot2*)&multiboot2_example2 (struct KernAux_Multiboot2_Info*)&multiboot2_example2
)); ));
assert(KernAux_Multiboot2_is_valid(&multiboot2_empty_valid.multiboot2)); assert(KernAux_Multiboot2_Info_is_valid(
&multiboot2_empty_valid.multiboot2_info
));
assert(KernAux_Multiboot2_is_valid( assert(KernAux_Multiboot2_Info_is_valid(
&multiboot2_with_some_additional_tag_valid.multiboot2) &multiboot2_with_some_additional_tag_valid.multiboot2_info)
); );
assert(KernAux_Multiboot2_is_valid( assert(KernAux_Multiboot2_Info_is_valid(
&multiboot2_with_more_additional_tags_valid.multiboot2) &multiboot2_with_more_additional_tags_valid.multiboot2_info)
); );
assert(!KernAux_Multiboot2_is_valid( assert(!KernAux_Multiboot2_Info_is_valid(
&multiboot2_empty_invalid_size.multiboot2 &multiboot2_empty_invalid_size.multiboot2_info
)); ));
assert(!KernAux_Multiboot2_is_valid(&multiboot2_without_none_tag_invalid)); assert(!KernAux_Multiboot2_Info_is_valid(
&multiboot2_without_none_tag_invalid
assert(!KernAux_Multiboot2_is_valid(
&multiboot2_with_invalid_last_tag_invalid.multiboot2
)); ));
assert(!KernAux_Multiboot2_is_valid( assert(!KernAux_Multiboot2_Info_is_valid(
&multiboot2_with_early_none_tag_invalid.multiboot2 &multiboot2_with_invalid_last_tag_invalid.multiboot2_info
)); ));
assert(!KernAux_Multiboot2_is_valid( assert(!KernAux_Multiboot2_Info_is_valid(
&multiboot2_with_more_additional_tags_invalid_size_too_big.multiboot2) &multiboot2_with_early_none_tag_invalid.multiboot2_info
); ));
assert(!KernAux_Multiboot2_is_valid( assert(!KernAux_Multiboot2_Info_is_valid(
&multiboot2_with_more_additional_tags_invalid_size_too_small.multiboot2) &multiboot2_with_more_additional_tags_invalid_size_too_big.multiboot2_info
); ));
assert(!KernAux_Multiboot2_Info_is_valid(
&multiboot2_with_more_additional_tags_invalid_size_too_small.multiboot2_info
));
// ITagBase // ITagBase