mirror of
https://github.com/tailix/libkernaux.git
synced 2025-02-17 15:45:32 -05:00
Main: include/kernaux/multiboot2.h.in: Add func "KernAux_Multiboot2_Info_to_memmap"
This commit is contained in:
parent
0c09da19f8
commit
edf6d1b36d
6 changed files with 69 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -102,6 +102,7 @@
|
||||||
|
|
||||||
/include/kernaux.h
|
/include/kernaux.h
|
||||||
/include/kernaux/console.h
|
/include/kernaux/console.h
|
||||||
|
/include/kernaux/multiboot2.h
|
||||||
/include/kernaux/printf.h
|
/include/kernaux/printf.h
|
||||||
/include/kernaux/version.h
|
/include/kernaux/version.h
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ libkernaux_la_SOURCES += \
|
||||||
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 \
|
||||||
|
src/multiboot2/info_convert.c \
|
||||||
src/multiboot2/info_helpers.c \
|
src/multiboot2/info_helpers.c \
|
||||||
src/multiboot2/info_is_valid.c \
|
src/multiboot2/info_is_valid.c \
|
||||||
src/multiboot2/info_print.c
|
src/multiboot2/info_print.c
|
||||||
|
|
|
@ -63,7 +63,7 @@ zero). Work-in-progress APIs can change at any time.
|
||||||
* Utilities
|
* Utilities
|
||||||
* [Measurement units utils](/include/kernaux/units.h) (*work in progress*)
|
* [Measurement units utils](/include/kernaux/units.h) (*work in progress*)
|
||||||
* [To human](/examples/units_human.c)
|
* [To human](/examples/units_human.c)
|
||||||
* [Memory map](/include/kernaux/memmap.h) (*work in progress*)
|
* [Memory map](/include/kernaux/memmap.h.in) (*work in progress*)
|
||||||
* [Example](/examples/memmap.c)
|
* [Example](/examples/memmap.c)
|
||||||
* [printf format parser](/include/kernaux/printf_fmt.h) (*work in progress*)
|
* [printf format parser](/include/kernaux/printf_fmt.h) (*work in progress*)
|
||||||
* Code from [https://github.com/mpaland/printf](https://github.com/mpaland/printf). Thank you!
|
* Code from [https://github.com/mpaland/printf](https://github.com/mpaland/printf). Thank you!
|
||||||
|
|
|
@ -31,6 +31,7 @@ AC_CONFIG_FILES([
|
||||||
libc/include/Makefile
|
libc/include/Makefile
|
||||||
include/kernaux.h
|
include/kernaux.h
|
||||||
include/kernaux/console.h
|
include/kernaux/console.h
|
||||||
|
include/kernaux/multiboot2.h
|
||||||
include/kernaux/printf.h
|
include/kernaux/printf.h
|
||||||
include/kernaux/version.h
|
include/kernaux/version.h
|
||||||
tests/Makefile
|
tests/Makefile
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@comment_line_memmap@#include <kernaux/memmap.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
@ -488,6 +490,15 @@ const char *KernAux_Multiboot2_HTag_RelocatableHeader_Preference_to_str(
|
||||||
enum KernAux_Multiboot2_HTag_RelocatableHeader_Preference pref
|
enum KernAux_Multiboot2_HTag_RelocatableHeader_Preference pref
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/************************************
|
||||||
|
* Information conversion functions *
|
||||||
|
************************************/
|
||||||
|
|
||||||
|
@comment_line_memmap@bool KernAux_Multiboot2_Info_to_memmap(
|
||||||
|
@comment_line_memmap@ const struct KernAux_Multiboot2_Info *multiboot2_info,
|
||||||
|
@comment_line_memmap@ KernAux_MemMap memmap
|
||||||
|
@comment_line_memmap@);
|
||||||
|
|
||||||
/***************************
|
/***************************
|
||||||
* Header helper functions *
|
* Header helper functions *
|
||||||
***************************/
|
***************************/
|
54
src/multiboot2/info_convert.c
Normal file
54
src/multiboot2/info_convert.c
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
#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
|
||||||
|
);
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
(void)basic_memory_info_tag;
|
||||||
|
(void)memory_map_tag;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
Loading…
Add table
Reference in a new issue