1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2024-11-13 11:04:27 -05:00

Move Multiboot 2 string functions to separate module

This commit is contained in:
Alex Kotov 2022-01-13 19:07:13 +05:00
parent 55e5c6800b
commit 172dff9f48
5 changed files with 104 additions and 92 deletions

View file

@ -56,6 +56,7 @@ endif
if WITH_MULTIBOOT2 if WITH_MULTIBOOT2
libkernaux_a_SOURCES += \ libkernaux_a_SOURCES += \
src/multiboot2/enums_to_str.c \
src/multiboot2/header_helpers.c \ src/multiboot2/header_helpers.c \
src/multiboot2/header_is_valid.c \ src/multiboot2/header_is_valid.c \
src/multiboot2/header_print.c \ src/multiboot2/header_print.c \

View file

@ -444,6 +444,18 @@ struct KernAux_Multiboot2_ITag_MemoryMap_EntryBase {
} }
__attribute__((packed)); __attribute__((packed));
/********************
* String functions *
********************/
const char *KernAux_Multiboot2_HTag_to_str(
enum KernAux_Multiboot2_HTag tag_type
);
const char *KernAux_Multiboot2_ITag_to_str(
enum KernAux_Multiboot2_ITag tag_type
);
/*************************** /***************************
* Header helper functions * * Header helper functions *
***************************/ ***************************/

View file

@ -0,0 +1,91 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <kernaux/multiboot2.h>
#include <stddef.h>
const char *KernAux_Multiboot2_HTag_to_str(
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(
enum KernAux_Multiboot2_ITag tag_type
) {
switch (tag_type) {
case KERNAUX_MULTIBOOT2_ITAG_NONE:
return "none";
case KERNAUX_MULTIBOOT2_ITAG_BOOT_CMD_LINE:
return "boot cmd line";
case KERNAUX_MULTIBOOT2_ITAG_BOOT_LOADER_NAME:
return "boot loader name";
case KERNAUX_MULTIBOOT2_ITAG_MODULE:
return "module";
case KERNAUX_MULTIBOOT2_ITAG_BASIC_MEMORY_INFO:
return "basic memory info";
case KERNAUX_MULTIBOOT2_ITAG_BIOS_BOOT_DEVICE:
return "BIOS boot device";
case KERNAUX_MULTIBOOT2_ITAG_MEMORY_MAP:
return "memory map";
case KERNAUX_MULTIBOOT2_ITAG_VBE_INFO:
return "VBE info";
case KERNAUX_MULTIBOOT2_ITAG_FRAMEBUFFER_INFO:
return "framebuffer info";
case KERNAUX_MULTIBOOT2_ITAG_ELF_SYMBOLS:
return "ELF symbols";
case KERNAUX_MULTIBOOT2_ITAG_APM_TABLE:
return "APM table";
case KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_SYSTEM_TABLE_PTR:
return "EFI 32bit system table ptr";
case KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_SYSTEM_TABLE_PTR:
return "EFI 64bit system table ptr";
case KERNAUX_MULTIBOOT2_ITAG_SMBIOS_TABLES:
return "SMBIOS tables";
case KERNAUX_MULTIBOOT2_ITAG_ACPI_OLD_RSDP:
return "ACPI old RSDP";
case KERNAUX_MULTIBOOT2_ITAG_ACPI_NEW_RSDP:
return "ACPI new RSDP";
case KERNAUX_MULTIBOOT2_ITAG_NETWORKING_INFO:
return "networking info";
case KERNAUX_MULTIBOOT2_ITAG_EFI_MEMORY_MAP:
return "EFI memory map";
case KERNAUX_MULTIBOOT2_ITAG_EFI_BOOT_SERVICES_NOT_TERMINATED:
return "EFI boot services not terminated";
case KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_IMAGE_HANDLE_PTR:
return "EFI 32bit image handle ptr";
case KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_IMAGE_HANDLE_PTR:
return "EFI 64bit image handle ptr";
case KERNAUX_MULTIBOOT2_ITAG_IMAGE_LOAD_BASE_PHYS_ADDR:
return "image load base phys addr";
default:
return NULL;
}
}

View file

@ -6,41 +6,6 @@
#include <stddef.h> #include <stddef.h>
static const char *KernAux_Multiboot2_HTag_to_str(
enum KernAux_Multiboot2_HTag tag_type
);
const char *KernAux_Multiboot2_HTag_to_str(
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;
}
}
void KernAux_Multiboot2_Header_print( void KernAux_Multiboot2_Header_print(
const struct KernAux_Multiboot2_Header *const multiboot2_header, const struct KernAux_Multiboot2_Header *const multiboot2_header,
void (*const printf)(const char *format, ...) __attribute__((format(printf, 1, 2))) void (*const printf)(const char *format, ...) __attribute__((format(printf, 1, 2)))

View file

@ -6,10 +6,6 @@
#include <stddef.h> #include <stddef.h>
static const char *KernAux_Multiboot2_ITag_to_str(
enum KernAux_Multiboot2_ITag tag_type
);
static void KernAux_Multiboot2_ITag_MemoryMap_print( static void KernAux_Multiboot2_ITag_MemoryMap_print(
const struct KernAux_Multiboot2_ITag_MemoryMap *tag, const struct KernAux_Multiboot2_ITag_MemoryMap *tag,
void (*printf)(const char *format, ...) __attribute__((format(printf, 1, 2))) void (*printf)(const char *format, ...) __attribute__((format(printf, 1, 2)))
@ -20,59 +16,6 @@ static void KernAux_Multiboot2_ITag_ELFSymbols_print(
void (*printf)(const char *format, ...) __attribute__((format(printf, 1, 2))) void (*printf)(const char *format, ...) __attribute__((format(printf, 1, 2)))
); );
const char *KernAux_Multiboot2_ITag_to_str(
enum KernAux_Multiboot2_ITag tag_type
) {
switch (tag_type) {
case KERNAUX_MULTIBOOT2_ITAG_NONE:
return "none";
case KERNAUX_MULTIBOOT2_ITAG_BOOT_CMD_LINE:
return "boot cmd line";
case KERNAUX_MULTIBOOT2_ITAG_BOOT_LOADER_NAME:
return "boot loader name";
case KERNAUX_MULTIBOOT2_ITAG_MODULE:
return "module";
case KERNAUX_MULTIBOOT2_ITAG_BASIC_MEMORY_INFO:
return "basic memory info";
case KERNAUX_MULTIBOOT2_ITAG_BIOS_BOOT_DEVICE:
return "BIOS boot device";
case KERNAUX_MULTIBOOT2_ITAG_MEMORY_MAP:
return "memory map";
case KERNAUX_MULTIBOOT2_ITAG_VBE_INFO:
return "VBE info";
case KERNAUX_MULTIBOOT2_ITAG_FRAMEBUFFER_INFO:
return "framebuffer info";
case KERNAUX_MULTIBOOT2_ITAG_ELF_SYMBOLS:
return "ELF symbols";
case KERNAUX_MULTIBOOT2_ITAG_APM_TABLE:
return "APM table";
case KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_SYSTEM_TABLE_PTR:
return "EFI 32bit system table ptr";
case KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_SYSTEM_TABLE_PTR:
return "EFI 64bit system table ptr";
case KERNAUX_MULTIBOOT2_ITAG_SMBIOS_TABLES:
return "SMBIOS tables";
case KERNAUX_MULTIBOOT2_ITAG_ACPI_OLD_RSDP:
return "ACPI old RSDP";
case KERNAUX_MULTIBOOT2_ITAG_ACPI_NEW_RSDP:
return "ACPI new RSDP";
case KERNAUX_MULTIBOOT2_ITAG_NETWORKING_INFO:
return "networking info";
case KERNAUX_MULTIBOOT2_ITAG_EFI_MEMORY_MAP:
return "EFI memory map";
case KERNAUX_MULTIBOOT2_ITAG_EFI_BOOT_SERVICES_NOT_TERMINATED:
return "EFI boot services not terminated";
case KERNAUX_MULTIBOOT2_ITAG_EFI_32BIT_IMAGE_HANDLE_PTR:
return "EFI 32bit image handle ptr";
case KERNAUX_MULTIBOOT2_ITAG_EFI_64BIT_IMAGE_HANDLE_PTR:
return "EFI 64bit image handle ptr";
case KERNAUX_MULTIBOOT2_ITAG_IMAGE_LOAD_BASE_PHYS_ADDR:
return "image load base phys addr";
default:
return NULL;
}
}
void KernAux_Multiboot2_Info_print( void KernAux_Multiboot2_Info_print(
const struct KernAux_Multiboot2_Info *const multiboot2_info, 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)))