2022-01-13 12:44:22 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <kernaux/multiboot2.h>
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
const struct KernAux_Multiboot2_HTagBase
|
|
|
|
*KernAux_Multiboot2_Header_first_tag_with_type(
|
|
|
|
const struct KernAux_Multiboot2_Header *const multiboot2_header,
|
|
|
|
const enum KernAux_Multiboot2_HTag tag_type
|
|
|
|
) {
|
|
|
|
const struct KernAux_Multiboot2_HTagBase *tag_base =
|
|
|
|
(struct KernAux_Multiboot2_HTagBase*)
|
|
|
|
KERNAUX_MULTIBOOT2_DATA(multiboot2_header);
|
|
|
|
|
|
|
|
while (tag_base <
|
|
|
|
(struct KernAux_Multiboot2_HTagBase*)
|
|
|
|
((uint8_t*)multiboot2_header + multiboot2_header->total_size))
|
|
|
|
{
|
2022-01-14 06:42:36 +00:00
|
|
|
if (!KernAux_Multiboot2_HTagBase_is_valid(tag_base)) return NULL;
|
2022-01-13 12:44:22 +00:00
|
|
|
if (tag_base->type == tag_type) return tag_base;
|
|
|
|
|
2022-01-13 12:55:59 +00:00
|
|
|
tag_base = KERNAUX_MULTIBOOT2_HTAG_NEXT(tag_base);
|
2022-01-13 12:44:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct KernAux_Multiboot2_HTagBase
|
|
|
|
*KernAux_Multiboot2_Header_tag_with_type_after(
|
|
|
|
const struct KernAux_Multiboot2_Header *const multiboot2_header,
|
|
|
|
const enum KernAux_Multiboot2_HTag tag_type,
|
|
|
|
const struct KernAux_Multiboot2_HTagBase *const after_tag
|
|
|
|
) {
|
|
|
|
const struct KernAux_Multiboot2_HTagBase *tag_base =
|
|
|
|
(struct KernAux_Multiboot2_HTagBase*)
|
|
|
|
KERNAUX_MULTIBOOT2_DATA(multiboot2_header);
|
|
|
|
|
|
|
|
while (tag_base <
|
|
|
|
(struct KernAux_Multiboot2_HTagBase*)
|
|
|
|
((uint8_t*)multiboot2_header + multiboot2_header->total_size))
|
|
|
|
{
|
2022-01-14 06:42:36 +00:00
|
|
|
if (!KernAux_Multiboot2_HTagBase_is_valid(tag_base)) return NULL;
|
2022-01-13 12:44:22 +00:00
|
|
|
if (tag_base->type == tag_type && tag_base > after_tag) return tag_base;
|
|
|
|
|
2022-01-13 12:55:59 +00:00
|
|
|
tag_base = KERNAUX_MULTIBOOT2_HTAG_NEXT(tag_base);
|
2022-01-13 12:44:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|