mirror of
https://github.com/tailix/libkernaux.git
synced 2025-03-31 17:25:22 -04:00
Rename Multiboot2 info struct
This commit is contained in:
parent
ab84e5892f
commit
9227f70f10
9 changed files with 186 additions and 179 deletions
|
@ -74,7 +74,7 @@ enum KernAux_Multiboot2_ITag {
|
|||
KERNAUX_MULTIBOOT2_ITAG_IMAGE_LOAD_BASE_PHYS_ADDR = 21,
|
||||
};
|
||||
|
||||
struct KernAux_Multiboot2 {
|
||||
struct KernAux_Multiboot2_Info {
|
||||
uint32_t total_size;
|
||||
uint32_t reserved1;
|
||||
}
|
||||
|
@ -321,28 +321,28 @@ __attribute__((packed));
|
|||
********************************/
|
||||
|
||||
const struct KernAux_Multiboot2_ITagBase
|
||||
*KernAux_Multiboot2_first_tag_with_type(
|
||||
const struct KernAux_Multiboot2 *multiboot2,
|
||||
*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_tag_with_type_after(
|
||||
const struct KernAux_Multiboot2 *multiboot2,
|
||||
*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_boot_cmd_line(
|
||||
const struct KernAux_Multiboot2 *multiboot2
|
||||
const char *KernAux_Multiboot2_Info_boot_cmd_line(
|
||||
const struct KernAux_Multiboot2_Info *multiboot2_info
|
||||
);
|
||||
|
||||
/*******************************
|
||||
* Information print functions *
|
||||
*******************************/
|
||||
|
||||
void KernAux_Multiboot2_print(
|
||||
const struct KernAux_Multiboot2 *multiboot2,
|
||||
void KernAux_Multiboot2_Info_print(
|
||||
const struct KernAux_Multiboot2_Info *multiboot2_info,
|
||||
void (*printf)(const char *format, ...)
|
||||
);
|
||||
|
||||
|
@ -355,8 +355,8 @@ void KernAux_Multiboot2_ITagBase_print(
|
|||
* Information validation functions *
|
||||
************************************/
|
||||
|
||||
bool KernAux_Multiboot2_is_valid(
|
||||
const struct KernAux_Multiboot2 *multiboot2
|
||||
bool KernAux_Multiboot2_Info_is_valid(
|
||||
const struct KernAux_Multiboot2_Info *multiboot2_info
|
||||
);
|
||||
|
||||
bool KernAux_Multiboot2_ITagBase_is_valid(
|
||||
|
|
|
@ -7,17 +7,17 @@
|
|||
#include <stddef.h>
|
||||
|
||||
const struct KernAux_Multiboot2_ITagBase
|
||||
*KernAux_Multiboot2_first_tag_with_type(
|
||||
const struct KernAux_Multiboot2 *const multiboot2,
|
||||
*KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
const struct KernAux_Multiboot2_Info *const multiboot2_info,
|
||||
const enum KernAux_Multiboot2_ITag tag_type
|
||||
) {
|
||||
const struct KernAux_Multiboot2_ITagBase *tag_base =
|
||||
(struct KernAux_Multiboot2_ITagBase*)
|
||||
KERNAUX_MULTIBOOT2_DATA(multiboot2);
|
||||
KERNAUX_MULTIBOOT2_DATA(multiboot2_info);
|
||||
|
||||
while (tag_base <
|
||||
(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 (tag_base->type == tag_type) return tag_base;
|
||||
|
@ -31,18 +31,18 @@ const struct KernAux_Multiboot2_ITagBase
|
|||
}
|
||||
|
||||
const struct KernAux_Multiboot2_ITagBase
|
||||
*KernAux_Multiboot2_tag_with_type_after(
|
||||
const struct KernAux_Multiboot2 *const multiboot2,
|
||||
*KernAux_Multiboot2_Info_tag_with_type_after(
|
||||
const struct KernAux_Multiboot2_Info *const multiboot2_info,
|
||||
const enum KernAux_Multiboot2_ITag tag_type,
|
||||
const struct KernAux_Multiboot2_ITagBase *const after_tag
|
||||
) {
|
||||
const struct KernAux_Multiboot2_ITagBase *tag_base =
|
||||
(struct KernAux_Multiboot2_ITagBase*)
|
||||
KERNAUX_MULTIBOOT2_DATA(multiboot2);
|
||||
KERNAUX_MULTIBOOT2_DATA(multiboot2_info);
|
||||
|
||||
while (tag_base <
|
||||
(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 (tag_base->type == tag_type && tag_base > after_tag) return tag_base;
|
||||
|
@ -55,13 +55,13 @@ const struct KernAux_Multiboot2_ITagBase
|
|||
return NULL;
|
||||
}
|
||||
|
||||
const char *KernAux_Multiboot2_boot_cmd_line(
|
||||
const struct KernAux_Multiboot2 *const multiboot2
|
||||
const char *KernAux_Multiboot2_Info_boot_cmd_line(
|
||||
const struct KernAux_Multiboot2_Info *const multiboot2_info
|
||||
) {
|
||||
const struct KernAux_Multiboot2_ITag_BootCmdLine *const tag =
|
||||
(struct KernAux_Multiboot2_ITag_BootCmdLine*)
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_BOOT_CMD_LINE
|
||||
);
|
||||
|
||||
|
|
|
@ -6,20 +6,20 @@
|
|||
|
||||
#include <stddef.h>
|
||||
|
||||
bool KernAux_Multiboot2_is_valid(
|
||||
const struct KernAux_Multiboot2 *const multiboot2
|
||||
bool KernAux_Multiboot2_Info_is_valid(
|
||||
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 =
|
||||
(struct KernAux_Multiboot2_ITagBase*)
|
||||
KERNAUX_MULTIBOOT2_DATA(multiboot2);
|
||||
KERNAUX_MULTIBOOT2_DATA(multiboot2_info);
|
||||
|
||||
const struct KernAux_Multiboot2_ITagBase *none_tag_base = NULL;
|
||||
|
||||
while (tag_base <
|
||||
(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;
|
||||
|
||||
|
@ -36,7 +36,7 @@ bool KernAux_Multiboot2_is_valid(
|
|||
|
||||
if (tag_base !=
|
||||
(struct KernAux_Multiboot2_ITagBase*)
|
||||
((unsigned char*)multiboot2 + multiboot2->total_size))
|
||||
((unsigned char*)multiboot2_info + multiboot2_info->total_size))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -73,21 +73,21 @@ const char *KernAux_Multiboot2_ITag_to_str(
|
|||
}
|
||||
}
|
||||
|
||||
void KernAux_Multiboot2_print(
|
||||
const struct KernAux_Multiboot2 *const multiboot2,
|
||||
void KernAux_Multiboot2_Info_print(
|
||||
const struct KernAux_Multiboot2_Info *const multiboot2_info,
|
||||
void (*const printf)(const char *format, ...) __attribute__((format(printf, 1, 2)))
|
||||
) {
|
||||
printf("Multiboot 2 info\n");
|
||||
printf(" size: %u\n", multiboot2->total_size);
|
||||
printf(" reserved1: %u\n", multiboot2->reserved1);
|
||||
printf(" size: %u\n", multiboot2_info->total_size);
|
||||
printf(" reserved1: %u\n", multiboot2_info->reserved1);
|
||||
|
||||
const struct KernAux_Multiboot2_ITagBase *tag_base =
|
||||
(struct KernAux_Multiboot2_ITagBase*)
|
||||
KERNAUX_MULTIBOOT2_DATA(multiboot2);
|
||||
KERNAUX_MULTIBOOT2_DATA(multiboot2_info);
|
||||
|
||||
while (tag_base <
|
||||
(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;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
static const struct {
|
||||
struct KernAux_Multiboot2 multiboot2;
|
||||
struct KernAux_Multiboot2_Info multiboot2_info;
|
||||
|
||||
struct {
|
||||
struct KernAux_Multiboot2_ITag_BootCmdLine tag;
|
||||
|
@ -113,7 +113,7 @@ static const struct {
|
|||
|
||||
struct KernAux_Multiboot2_ITag_None tag_none;
|
||||
} multiboot2_example2 = {
|
||||
.multiboot2 = {
|
||||
.multiboot2_info = {
|
||||
.total_size = sizeof(multiboot2_example2),
|
||||
.reserved1 = 0,
|
||||
},
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
assert(KernAux_Multiboot2_is_valid(
|
||||
(struct KernAux_Multiboot2*)multiboot2_example1
|
||||
assert(KernAux_Multiboot2_Info_is_valid(
|
||||
(struct KernAux_Multiboot2_Info*)multiboot2_example1
|
||||
));
|
||||
|
||||
KernAux_Multiboot2_print(
|
||||
(struct KernAux_Multiboot2*)multiboot2_example1,
|
||||
KernAux_Multiboot2_Info_print(
|
||||
(struct KernAux_Multiboot2_Info*)multiboot2_example1,
|
||||
(void (*)(const char *format, ...))printf
|
||||
);
|
||||
|
||||
|
|
|
@ -11,10 +11,12 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
assert(KernAux_Multiboot2_is_valid(&multiboot2_example2.multiboot2));
|
||||
assert(KernAux_Multiboot2_Info_is_valid(
|
||||
&multiboot2_example2.multiboot2_info
|
||||
));
|
||||
|
||||
KernAux_Multiboot2_print(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_print(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
(void (*)(const char *format, ...))printf
|
||||
);
|
||||
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
#include "multiboot2_example2.h"
|
||||
|
||||
static const struct {
|
||||
struct KernAux_Multiboot2 multiboot2;
|
||||
struct KernAux_Multiboot2_Info multiboot2_info;
|
||||
struct KernAux_Multiboot2_ITag_None tag_none;
|
||||
} multiboot2_without_boot_cmd_line = {
|
||||
.multiboot2 = {
|
||||
.multiboot2_info = {
|
||||
.total_size = sizeof(multiboot2_without_boot_cmd_line),
|
||||
.reserved1 = 0,
|
||||
},
|
||||
|
@ -26,7 +26,7 @@ static const struct {
|
|||
};
|
||||
|
||||
static const struct {
|
||||
struct KernAux_Multiboot2 multiboot2;
|
||||
struct KernAux_Multiboot2_Info multiboot2_info;
|
||||
|
||||
struct {
|
||||
struct KernAux_Multiboot2_ITag_BootCmdLine tag;
|
||||
|
@ -37,7 +37,7 @@ static const struct {
|
|||
|
||||
struct KernAux_Multiboot2_ITag_None tag_none;
|
||||
} multiboot2_with_some_boot_cmd_line = {
|
||||
.multiboot2 = {
|
||||
.multiboot2_info = {
|
||||
.total_size = sizeof(multiboot2_with_some_boot_cmd_line),
|
||||
.reserved1 = 0,
|
||||
},
|
||||
|
@ -61,7 +61,7 @@ static const struct {
|
|||
};
|
||||
|
||||
static const struct {
|
||||
struct KernAux_Multiboot2 multiboot2;
|
||||
struct KernAux_Multiboot2_Info multiboot2_info;
|
||||
|
||||
struct {
|
||||
struct KernAux_Multiboot2_ITag_BootCmdLine tag;
|
||||
|
@ -79,7 +79,7 @@ static const struct {
|
|||
|
||||
struct KernAux_Multiboot2_ITag_None tag_none;
|
||||
} multiboot2_with_two_boot_cmd_lines = {
|
||||
.multiboot2 = {
|
||||
.multiboot2_info = {
|
||||
.total_size = sizeof(multiboot2_with_two_boot_cmd_lines),
|
||||
.reserved1 = 0,
|
||||
},
|
||||
|
@ -115,238 +115,238 @@ static const struct {
|
|||
|
||||
int main()
|
||||
{
|
||||
assert(KernAux_Multiboot2_is_valid(
|
||||
(struct KernAux_Multiboot2*)multiboot2_example1
|
||||
assert(KernAux_Multiboot2_Info_is_valid(
|
||||
(struct KernAux_Multiboot2_Info*)multiboot2_example1
|
||||
));
|
||||
|
||||
assert(KernAux_Multiboot2_is_valid(
|
||||
&multiboot2_example2.multiboot2
|
||||
assert(KernAux_Multiboot2_Info_is_valid(
|
||||
&multiboot2_example2.multiboot2_info
|
||||
));
|
||||
|
||||
assert(KernAux_Multiboot2_is_valid(
|
||||
&multiboot2_without_boot_cmd_line.multiboot2
|
||||
assert(KernAux_Multiboot2_Info_is_valid(
|
||||
&multiboot2_without_boot_cmd_line.multiboot2_info
|
||||
));
|
||||
|
||||
assert(KernAux_Multiboot2_is_valid(
|
||||
&multiboot2_with_some_boot_cmd_line.multiboot2
|
||||
assert(KernAux_Multiboot2_Info_is_valid(
|
||||
&multiboot2_with_some_boot_cmd_line.multiboot2_info
|
||||
));
|
||||
|
||||
assert(KernAux_Multiboot2_is_valid(
|
||||
&multiboot2_with_two_boot_cmd_lines.multiboot2
|
||||
assert(KernAux_Multiboot2_Info_is_valid(
|
||||
&multiboot2_with_two_boot_cmd_lines.multiboot2_info
|
||||
));
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_boot_cmd_line(
|
||||
&multiboot2_without_boot_cmd_line.multiboot2
|
||||
KernAux_Multiboot2_Info_boot_cmd_line(
|
||||
&multiboot2_without_boot_cmd_line.multiboot2_info
|
||||
) == 0
|
||||
);
|
||||
|
||||
// KernAux_Multiboot2_first_tag_with_type
|
||||
// KernAux_Multiboot2_Info_first_tag_with_type
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
(struct KernAux_Multiboot2*)multiboot2_example1,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
(struct KernAux_Multiboot2_Info*)multiboot2_example1,
|
||||
KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_SYSTEM_TABLE_PTR
|
||||
) == 0
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
(struct KernAux_Multiboot2*)multiboot2_example1,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
(struct KernAux_Multiboot2_Info*)multiboot2_example1,
|
||||
KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_SYSTEM_TABLE_PTR
|
||||
) == 0
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
(struct KernAux_Multiboot2*)multiboot2_example1,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
(struct KernAux_Multiboot2_Info*)multiboot2_example1,
|
||||
KERNAUX_MULTIBOOT2_ITAG_SMBIOS_TABLES
|
||||
) == 0
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
(struct KernAux_Multiboot2*)multiboot2_example1,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
(struct KernAux_Multiboot2_Info*)multiboot2_example1,
|
||||
KERNAUX_MULTIBOOT2_ITAG_ACPI_NEW_RSDP
|
||||
) == 0
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
(struct KernAux_Multiboot2*)multiboot2_example1,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
(struct KernAux_Multiboot2_Info*)multiboot2_example1,
|
||||
KERNAUX_MULTIBOOT2_ITAG_NETWORKING_INFO
|
||||
) == 0
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
(struct KernAux_Multiboot2*)multiboot2_example1,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
(struct KernAux_Multiboot2_Info*)multiboot2_example1,
|
||||
KERNAUX_MULTIBOOT2_ITAG_EFI_MEMORY_MAP
|
||||
) == 0
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
(struct KernAux_Multiboot2*)multiboot2_example1,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
(struct KernAux_Multiboot2_Info*)multiboot2_example1,
|
||||
KERNAUX_MULTIBOOT2_ITAG_EFI_BOOT_SERVICES_NOT_TERMINATED
|
||||
) == 0
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
(struct KernAux_Multiboot2*)multiboot2_example1,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
(struct KernAux_Multiboot2_Info*)multiboot2_example1,
|
||||
KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_IMAGE_HANDLE_PTR
|
||||
) == 0
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
(struct KernAux_Multiboot2*)multiboot2_example1,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
(struct KernAux_Multiboot2_Info*)multiboot2_example1,
|
||||
KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_IMAGE_HANDLE_PTR
|
||||
) == 0
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_NONE
|
||||
) == &multiboot2_example2.tag_none.base
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_BOOT_CMD_LINE
|
||||
) == &multiboot2_example2.tag_boot_cmd_line.tag.base
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_BOOT_LOADER_NAME
|
||||
) == &multiboot2_example2.tag_boot_loader_name.tag.base
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_MODULE
|
||||
) == &multiboot2_example2.tag_module1.tag.base
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_BASIC_MEMORY_INFO
|
||||
) == &multiboot2_example2.tag_basic_memory_info.base
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_FRAMEBUFFER_INFO
|
||||
) == &multiboot2_example2.tag_framebuffer_info.tag.base
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_ELF_SYMBOLS
|
||||
) == &multiboot2_example2.tag_elf_symbols.tag.base
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_APM_TABLE
|
||||
) == &multiboot2_example2.tag_apm_table.base
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_SYSTEM_TABLE_PTR
|
||||
) == &multiboot2_example2.tag_efi_32bit_system_table_ptr.base
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_SYSTEM_TABLE_PTR
|
||||
) == &multiboot2_example2.tag_efi_64bit_system_table_ptr.base
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_SMBIOS_TABLES
|
||||
) == &multiboot2_example2.tag_smbios_tables.tag.base
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_ACPI_OLD_RSDP
|
||||
) == &multiboot2_example2.tag_acpi_old_rsdp.tag.base
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_ACPI_NEW_RSDP
|
||||
) == &multiboot2_example2.tag_acpi_new_rsdp.tag.base
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_NETWORKING_INFO
|
||||
) == &multiboot2_example2.tag_networking_info.tag.base
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_EFI_MEMORY_MAP
|
||||
) == &multiboot2_example2.tag_efi_memory_map.tag.base
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_EFI_BOOT_SERVICES_NOT_TERMINATED
|
||||
) == &multiboot2_example2.tag_efi_boot_services_not_terminated.base
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_IMAGE_HANDLE_PTR
|
||||
) == &multiboot2_example2.tag_efi_32bit_image_handle_ptr.base
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_IMAGE_HANDLE_PTR
|
||||
) == &multiboot2_example2.tag_efi_64bit_image_handle_ptr.base
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_IMAGE_LOAD_BASE_PHYS_ADDR
|
||||
) == &multiboot2_example2.tag_image_load_base_phys_addr.base
|
||||
);
|
||||
|
||||
// KernAux_Multiboot2_tag_with_type_after
|
||||
// KernAux_Multiboot2_Info_tag_with_type_after
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_tag_with_type_after(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_tag_with_type_after(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_MODULE,
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_MODULE
|
||||
) - 1
|
||||
) == (struct KernAux_Multiboot2_ITagBase*)
|
||||
|
@ -354,11 +354,11 @@ int main()
|
|||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_tag_with_type_after(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_tag_with_type_after(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_MODULE,
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_MODULE
|
||||
)
|
||||
) == (struct KernAux_Multiboot2_ITagBase*)
|
||||
|
@ -366,31 +366,31 @@ int main()
|
|||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_tag_with_type_after(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_tag_with_type_after(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_MODULE,
|
||||
KernAux_Multiboot2_tag_with_type_after(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_tag_with_type_after(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_MODULE,
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KernAux_Multiboot2_Info_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2_info,
|
||||
KERNAUX_MULTIBOOT2_ITAG_MODULE
|
||||
)
|
||||
)
|
||||
) == 0
|
||||
);
|
||||
|
||||
// KernAux_Multiboot2_boot_cmd_line
|
||||
// KernAux_Multiboot2_Info_boot_cmd_line
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_boot_cmd_line(
|
||||
&multiboot2_with_some_boot_cmd_line.multiboot2
|
||||
KernAux_Multiboot2_Info_boot_cmd_line(
|
||||
&multiboot2_with_some_boot_cmd_line.multiboot2_info
|
||||
) == multiboot2_with_some_boot_cmd_line.tag_boot_cmd_line.cmdline
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_boot_cmd_line(
|
||||
&multiboot2_with_two_boot_cmd_lines.multiboot2
|
||||
KernAux_Multiboot2_Info_boot_cmd_line(
|
||||
&multiboot2_with_two_boot_cmd_lines.multiboot2_info
|
||||
) == multiboot2_with_two_boot_cmd_lines.tag_boot_cmd_line1.cmdline
|
||||
);
|
||||
|
||||
|
|
|
@ -527,10 +527,10 @@ tag_vbe_info_invalid_size = {
|
|||
**************/
|
||||
|
||||
static const struct {
|
||||
struct KernAux_Multiboot2 multiboot2;
|
||||
struct KernAux_Multiboot2_Info multiboot2_info;
|
||||
struct KernAux_Multiboot2_ITag_None tag_none;
|
||||
} multiboot2_empty_valid = {
|
||||
.multiboot2 = {
|
||||
.multiboot2_info = {
|
||||
.total_size = 8 + 8,
|
||||
.reserved1 = 0,
|
||||
},
|
||||
|
@ -543,11 +543,11 @@ 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_None tag_none;
|
||||
} multiboot2_with_some_additional_tag_valid = {
|
||||
.multiboot2 = {
|
||||
.multiboot2_info = {
|
||||
.total_size = 8 + 16 + 8,
|
||||
.reserved1 = 0,
|
||||
},
|
||||
|
@ -568,13 +568,13 @@ 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_BIOSBootDevice tag_bios_boot_device;
|
||||
unsigned char _align1[4];
|
||||
struct KernAux_Multiboot2_ITag_None tag_none;
|
||||
} multiboot2_with_more_additional_tags_valid = {
|
||||
.multiboot2 = {
|
||||
.multiboot2_info = {
|
||||
.total_size = 8 + 16 + (20 + 4) + 8,
|
||||
.reserved1 = 0,
|
||||
},
|
||||
|
@ -604,10 +604,10 @@ static const struct {
|
|||
};
|
||||
|
||||
static const struct {
|
||||
struct KernAux_Multiboot2 multiboot2;
|
||||
struct KernAux_Multiboot2_Info multiboot2_info;
|
||||
struct KernAux_Multiboot2_ITag_None tag_none;
|
||||
} multiboot2_empty_invalid_size = {
|
||||
.multiboot2 = {
|
||||
.multiboot2_info = {
|
||||
.total_size = 8,
|
||||
.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,
|
||||
.reserved1 = 0,
|
||||
};
|
||||
|
||||
static const struct {
|
||||
struct KernAux_Multiboot2 multiboot2;
|
||||
struct KernAux_Multiboot2_Info multiboot2_info;
|
||||
struct KernAux_Multiboot2_ITag_BasicMemoryInfo tag_basic_memory_info;
|
||||
} multiboot2_with_invalid_last_tag_invalid = {
|
||||
.multiboot2 = {
|
||||
.multiboot2_info = {
|
||||
.total_size = 8 + 16,
|
||||
.reserved1 = 0,
|
||||
},
|
||||
|
@ -643,14 +644,14 @@ 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_None tag_none1;
|
||||
struct KernAux_Multiboot2_ITag_BIOSBootDevice tag_bios_boot_device;
|
||||
unsigned char _align1[4];
|
||||
struct KernAux_Multiboot2_ITag_None tag_none2;
|
||||
} multiboot2_with_early_none_tag_invalid = {
|
||||
.multiboot2 = {
|
||||
.multiboot2_info = {
|
||||
.total_size = 8 + 16 + 8 + (20 + 4) + 8,
|
||||
.reserved1 = 0,
|
||||
},
|
||||
|
@ -686,13 +687,13 @@ 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_BIOSBootDevice tag_bios_boot_device;
|
||||
unsigned char _align1[4];
|
||||
struct KernAux_Multiboot2_ITag_None tag_none;
|
||||
} multiboot2_with_more_additional_tags_invalid_size_too_big = {
|
||||
.multiboot2 = {
|
||||
.multiboot2_info = {
|
||||
.total_size = 8 + 16 + (20 + 4) + 8 + 1,
|
||||
.reserved1 = 0,
|
||||
},
|
||||
|
@ -722,13 +723,13 @@ 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_BIOSBootDevice tag_bios_boot_device;
|
||||
unsigned char _align1[4];
|
||||
struct KernAux_Multiboot2_ITag_None tag_none;
|
||||
} multiboot2_with_more_additional_tags_invalid_size_too_small = {
|
||||
.multiboot2 = {
|
||||
.multiboot2_info = {
|
||||
.total_size = 8 + 16 + (20 + 4) + 8 - 1,
|
||||
.reserved1 = 0,
|
||||
},
|
||||
|
@ -765,45 +766,49 @@ int main()
|
|||
{
|
||||
// Multiboot2
|
||||
|
||||
assert(KernAux_Multiboot2_is_valid(
|
||||
(struct KernAux_Multiboot2*)&multiboot2_example1
|
||||
assert(KernAux_Multiboot2_Info_is_valid(
|
||||
(struct KernAux_Multiboot2_Info*)&multiboot2_example1
|
||||
));
|
||||
|
||||
assert(KernAux_Multiboot2_is_valid(
|
||||
(struct KernAux_Multiboot2*)&multiboot2_example2
|
||||
assert(KernAux_Multiboot2_Info_is_valid(
|
||||
(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(
|
||||
&multiboot2_with_some_additional_tag_valid.multiboot2)
|
||||
assert(KernAux_Multiboot2_Info_is_valid(
|
||||
&multiboot2_with_some_additional_tag_valid.multiboot2_info)
|
||||
);
|
||||
|
||||
assert(KernAux_Multiboot2_is_valid(
|
||||
&multiboot2_with_more_additional_tags_valid.multiboot2)
|
||||
assert(KernAux_Multiboot2_Info_is_valid(
|
||||
&multiboot2_with_more_additional_tags_valid.multiboot2_info)
|
||||
);
|
||||
|
||||
assert(!KernAux_Multiboot2_is_valid(
|
||||
&multiboot2_empty_invalid_size.multiboot2
|
||||
assert(!KernAux_Multiboot2_Info_is_valid(
|
||||
&multiboot2_empty_invalid_size.multiboot2_info
|
||||
));
|
||||
|
||||
assert(!KernAux_Multiboot2_is_valid(&multiboot2_without_none_tag_invalid));
|
||||
|
||||
assert(!KernAux_Multiboot2_is_valid(
|
||||
&multiboot2_with_invalid_last_tag_invalid.multiboot2
|
||||
assert(!KernAux_Multiboot2_Info_is_valid(
|
||||
&multiboot2_without_none_tag_invalid
|
||||
));
|
||||
|
||||
assert(!KernAux_Multiboot2_is_valid(
|
||||
&multiboot2_with_early_none_tag_invalid.multiboot2
|
||||
assert(!KernAux_Multiboot2_Info_is_valid(
|
||||
&multiboot2_with_invalid_last_tag_invalid.multiboot2_info
|
||||
));
|
||||
|
||||
assert(!KernAux_Multiboot2_is_valid(
|
||||
&multiboot2_with_more_additional_tags_invalid_size_too_big.multiboot2)
|
||||
);
|
||||
assert(!KernAux_Multiboot2_Info_is_valid(
|
||||
&multiboot2_with_early_none_tag_invalid.multiboot2_info
|
||||
));
|
||||
|
||||
assert(!KernAux_Multiboot2_is_valid(
|
||||
&multiboot2_with_more_additional_tags_invalid_size_too_small.multiboot2)
|
||||
);
|
||||
assert(!KernAux_Multiboot2_Info_is_valid(
|
||||
&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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue