mirror of
https://github.com/tailix/libkernaux.git
synced 2025-04-07 17:32:45 -04:00
Fix enums
This commit is contained in:
parent
e363c8dbcf
commit
afe3556467
9 changed files with 51 additions and 13 deletions
Binary file not shown.
|
@ -10,10 +10,10 @@ __attribute__((packed))
|
|||
multiboot2_header = {
|
||||
.multiboot2_header = {
|
||||
.magic = KERNAUX_MULTIBOOT2_HEADER_MAGIC,
|
||||
.arch = KERNAUX_MULTIBOOT2_ARCH_NONE,
|
||||
.arch = KERNAUX_MULTIBOOT2_HEADER_ARCH_I386,
|
||||
.total_size = sizeof(multiboot2_header),
|
||||
.checksum = KERNAUX_MULTIBOOT2_HEADER_CHECKSUM(
|
||||
KERNAUX_MULTIBOOT2_ARCH_NONE,
|
||||
KERNAUX_MULTIBOOT2_HEADER_ARCH_I386,
|
||||
sizeof(multiboot2_header)
|
||||
),
|
||||
},
|
||||
|
|
Binary file not shown.
|
@ -10,10 +10,10 @@ __attribute__((packed))
|
|||
multiboot2_header = {
|
||||
.multiboot2_header = {
|
||||
.magic = KERNAUX_MULTIBOOT2_HEADER_MAGIC,
|
||||
.arch = KERNAUX_MULTIBOOT2_ARCH_NONE,
|
||||
.arch = KERNAUX_MULTIBOOT2_HEADER_ARCH_I386,
|
||||
.total_size = sizeof(multiboot2_header),
|
||||
.checksum = KERNAUX_MULTIBOOT2_HEADER_CHECKSUM(
|
||||
KERNAUX_MULTIBOOT2_ARCH_NONE,
|
||||
KERNAUX_MULTIBOOT2_HEADER_ARCH_I386,
|
||||
sizeof(multiboot2_header)
|
||||
),
|
||||
},
|
||||
|
|
|
@ -43,8 +43,7 @@ extern "C" {
|
|||
***********************/
|
||||
|
||||
enum KernAux_Multiboot2_Header_Arch {
|
||||
KERNAUX_MULTIBOOT2_HEADER_ARCH_NONE = 0,
|
||||
KERNAUX_MULTIBOOT2_HEADER_ARCH_I386 = 1,
|
||||
KERNAUX_MULTIBOOT2_HEADER_ARCH_I386 = 0,
|
||||
KERNAUX_MULTIBOOT2_HEADER_ARCH_MIPS32 = 4,
|
||||
};
|
||||
|
||||
|
@ -465,6 +464,10 @@ __attribute__((packed));
|
|||
* String functions *
|
||||
********************/
|
||||
|
||||
const char *KernAux_Multiboot2_Header_Arch_to_str(
|
||||
enum KernAux_Multiboot2_Header_Arch arch
|
||||
);
|
||||
|
||||
const char *KernAux_Multiboot2_HTag_to_str(
|
||||
enum KernAux_Multiboot2_HTag tag_type
|
||||
);
|
||||
|
@ -473,6 +476,10 @@ const char *KernAux_Multiboot2_ITag_to_str(
|
|||
enum KernAux_Multiboot2_ITag tag_type
|
||||
);
|
||||
|
||||
const char *KernAux_Multiboot2_HTag_RelocatableHeader_Preference_to_str(
|
||||
enum KernAux_Multiboot2_HTag_RelocatableHeader_Preference pref
|
||||
);
|
||||
|
||||
/***************************
|
||||
* Header helper functions *
|
||||
***************************/
|
||||
|
|
|
@ -6,8 +6,21 @@
|
|||
|
||||
#include <stddef.h>
|
||||
|
||||
const char *KernAux_Multiboot2_Header_Arch_to_str(
|
||||
const enum KernAux_Multiboot2_Header_Arch arch
|
||||
) {
|
||||
switch (arch) {
|
||||
case KERNAUX_MULTIBOOT2_HEADER_ARCH_I386:
|
||||
return "i386";
|
||||
case KERNAUX_MULTIBOOT2_HEADER_ARCH_MIPS32:
|
||||
return "MIPS32"; // TODO: specify this architecture in README
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const char *KernAux_Multiboot2_HTag_to_str(
|
||||
enum KernAux_Multiboot2_HTag tag_type
|
||||
const enum KernAux_Multiboot2_HTag tag_type
|
||||
) {
|
||||
switch (tag_type) {
|
||||
case KERNAUX_MULTIBOOT2_HTAG_NONE:
|
||||
|
@ -38,7 +51,7 @@ const char *KernAux_Multiboot2_HTag_to_str(
|
|||
}
|
||||
|
||||
const char *KernAux_Multiboot2_ITag_to_str(
|
||||
enum KernAux_Multiboot2_ITag tag_type
|
||||
const enum KernAux_Multiboot2_ITag tag_type
|
||||
) {
|
||||
switch (tag_type) {
|
||||
case KERNAUX_MULTIBOOT2_ITAG_NONE:
|
||||
|
@ -89,3 +102,18 @@ const char *KernAux_Multiboot2_ITag_to_str(
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const char *KernAux_Multiboot2_HTag_RelocatableHeader_Preference_to_str(
|
||||
const enum KernAux_Multiboot2_HTag_RelocatableHeader_Preference pref
|
||||
) {
|
||||
switch (pref) {
|
||||
case KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_NONE:
|
||||
return "none";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_LOWEST:
|
||||
return "lowest";
|
||||
case KERNAUX_MULTIBOOT2_HTAG_RELOCATABLE_HEADER_PREFERENCE_HIGHEST:
|
||||
return "highest";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,7 @@ bool KernAux_Multiboot2_Header_is_valid(
|
|||
return false;
|
||||
}
|
||||
|
||||
if (multiboot2_header->arch != KERNAUX_MULTIBOOT2_HEADER_ARCH_NONE &&
|
||||
multiboot2_header->arch != KERNAUX_MULTIBOOT2_HEADER_ARCH_I386 &&
|
||||
if (multiboot2_header->arch != KERNAUX_MULTIBOOT2_HEADER_ARCH_I386 &&
|
||||
multiboot2_header->arch != KERNAUX_MULTIBOOT2_HEADER_ARCH_MIPS32)
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -13,7 +13,11 @@ void KernAux_Multiboot2_Header_print(
|
|||
) {
|
||||
printf("Multiboot 2 header\n");
|
||||
printf(" magic: %u\n", multiboot2_header->magic);
|
||||
printf(" arch: %u\n", multiboot2_header->arch);
|
||||
printf(
|
||||
" arch: %u (%s)\n",
|
||||
multiboot2_header->arch,
|
||||
KernAux_Multiboot2_Header_Arch_to_str(multiboot2_header->arch)
|
||||
);
|
||||
printf(" size: %u\n", multiboot2_header->total_size);
|
||||
printf(" checksum: %u\n", multiboot2_header->checksum);
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
static const char output2[] =
|
||||
"Multiboot 2 header\n"
|
||||
" magic: 3897708758\n"
|
||||
" arch: 1\n"
|
||||
" arch: 0 (i386)\n"
|
||||
" size: 272\n"
|
||||
" checksum: 397258265\n"
|
||||
" checksum: 397258266\n"
|
||||
"Multiboot 2 header tag\n"
|
||||
" type: 1 (information request)\n"
|
||||
" flags: 0\n"
|
||||
|
|
Loading…
Add table
Reference in a new issue