mirror of
https://github.com/tailix/libkernaux.git
synced 2025-04-07 17:32:45 -04:00
Add function "KernAux_Multiboot2_tag_with_type_after"
This commit is contained in:
parent
e7a0f05c5d
commit
388095b2be
3 changed files with 73 additions and 0 deletions
|
@ -314,6 +314,13 @@ const struct KernAux_Multiboot2_TagBase *KernAux_Multiboot2_first_tag_with_type(
|
|||
)
|
||||
__attribute__((nonnull));
|
||||
|
||||
const struct KernAux_Multiboot2_TagBase *KernAux_Multiboot2_tag_with_type_after(
|
||||
const struct KernAux_Multiboot2 *multiboot2,
|
||||
enum KernAux_Multiboot2_TagType tag_type,
|
||||
const struct KernAux_Multiboot2_TagBase *after_tag
|
||||
)
|
||||
__attribute__((nonnull));
|
||||
|
||||
const char *KernAux_Multiboot2_boot_cmd_line(
|
||||
const struct KernAux_Multiboot2 *multiboot2
|
||||
)
|
||||
|
|
|
@ -24,6 +24,31 @@ const struct KernAux_Multiboot2_TagBase *KernAux_Multiboot2_first_tag_with_type(
|
|||
return 0;
|
||||
}
|
||||
|
||||
const struct KernAux_Multiboot2_TagBase *KernAux_Multiboot2_tag_with_type_after(
|
||||
const struct KernAux_Multiboot2 *const multiboot2,
|
||||
const enum KernAux_Multiboot2_TagType tag_type,
|
||||
const struct KernAux_Multiboot2_TagBase *const after_tag
|
||||
) {
|
||||
const struct KernAux_Multiboot2_TagBase *tag_base =
|
||||
(struct KernAux_Multiboot2_TagBase*)multiboot2->data;
|
||||
|
||||
while ((void*)tag_base < (void*)multiboot2 + multiboot2->total_size) {
|
||||
if (!KernAux_Multiboot2_TagBase_is_valid(tag_base)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tag_base->type == tag_type && tag_base > after_tag) {
|
||||
return tag_base;
|
||||
}
|
||||
|
||||
tag_base = (struct KernAux_Multiboot2_TagBase*)(
|
||||
(void*)tag_base + ((tag_base->size + 7) & ~7)
|
||||
);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *KernAux_Multiboot2_boot_cmd_line(
|
||||
const struct KernAux_Multiboot2 *const multiboot2
|
||||
) {
|
||||
|
|
|
@ -335,6 +335,47 @@ int main()
|
|||
) == &multiboot2_example2.tag_image_load_base_phys_addr.base
|
||||
);
|
||||
|
||||
// KernAux_Multiboot2_tag_with_type_after
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_tag_with_type_after(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KERNAUX_MULTIBOOT2_TAGTYPE_MODULE,
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KERNAUX_MULTIBOOT2_TAGTYPE_MODULE
|
||||
) - 1
|
||||
) == (struct KernAux_Multiboot2_TagBase*)
|
||||
&multiboot2_example2.tag_module1
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_tag_with_type_after(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KERNAUX_MULTIBOOT2_TAGTYPE_MODULE,
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KERNAUX_MULTIBOOT2_TAGTYPE_MODULE
|
||||
)
|
||||
) == (struct KernAux_Multiboot2_TagBase*)
|
||||
&multiboot2_example2.tag_module2
|
||||
);
|
||||
|
||||
assert(
|
||||
KernAux_Multiboot2_tag_with_type_after(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KERNAUX_MULTIBOOT2_TAGTYPE_MODULE,
|
||||
KernAux_Multiboot2_tag_with_type_after(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KERNAUX_MULTIBOOT2_TAGTYPE_MODULE,
|
||||
KernAux_Multiboot2_first_tag_with_type(
|
||||
&multiboot2_example2.multiboot2,
|
||||
KERNAUX_MULTIBOOT2_TAGTYPE_MODULE
|
||||
)
|
||||
)
|
||||
) == 0
|
||||
);
|
||||
|
||||
// KernAux_Multiboot2_boot_cmd_line
|
||||
|
||||
assert(
|
||||
|
|
Loading…
Add table
Reference in a new issue