Add macro KERNAUX_MULTIBOOT2_TAG_SIZE_ALIGN

This commit is contained in:
Alex Kotov 2022-01-13 17:46:05 +05:00
parent 34f1936af8
commit 0a309ec182
5 changed files with 10 additions and 6 deletions

View File

@ -11,6 +11,8 @@ extern "C" {
#define KERNAUX_MULTIBOOT2_MAGIC 0x36d76289
#define KERNAUX_MULTIBOOT2_DATA(ptr) (((uint8_t*)(ptr)) + sizeof(*(ptr)))
#define KERNAUX_MULTIBOOT2_TAG_SIZE_ALIGN(tag_base) \
(((tag_base)->size + 7) & ~7)
/***********************
* Header common types *

View File

@ -25,7 +25,7 @@ const struct KernAux_Multiboot2_HTagBase
if (tag_base->type == tag_type) return tag_base;
tag_base = (struct KernAux_Multiboot2_HTagBase*)(
(uint8_t*)tag_base + ((tag_base->size + 7) & ~7)
(uint8_t*)tag_base + KERNAUX_MULTIBOOT2_TAG_SIZE_ALIGN(tag_base)
);
}
@ -51,7 +51,7 @@ const struct KernAux_Multiboot2_HTagBase
if (tag_base->type == tag_type && tag_base > after_tag) return tag_base;
tag_base = (struct KernAux_Multiboot2_HTagBase*)(
(uint8_t*)tag_base + ((tag_base->size + 7) & ~7)
(uint8_t*)tag_base + KERNAUX_MULTIBOOT2_TAG_SIZE_ALIGN(tag_base)
);
}

View File

@ -24,7 +24,7 @@ const struct KernAux_Multiboot2_ITagBase
if (tag_base->type == tag_type) return tag_base;
tag_base = (struct KernAux_Multiboot2_ITagBase*)(
(uint8_t*)tag_base + ((tag_base->size + 7) & ~7)
(uint8_t*)tag_base + KERNAUX_MULTIBOOT2_TAG_SIZE_ALIGN(tag_base)
);
}
@ -49,7 +49,7 @@ const struct KernAux_Multiboot2_ITagBase
if (tag_base->type == tag_type && tag_base > after_tag) return tag_base;
tag_base = (struct KernAux_Multiboot2_ITagBase*)(
(uint8_t*)tag_base + ((tag_base->size + 7) & ~7)
(uint8_t*)tag_base + KERNAUX_MULTIBOOT2_TAG_SIZE_ALIGN(tag_base)
);
}

View File

@ -30,7 +30,8 @@ bool KernAux_Multiboot2_Info_is_valid(
}
tag_base = (struct KernAux_Multiboot2_ITagBase*)(
(unsigned char*)tag_base + ((tag_base->size + 7) & ~7)
(unsigned char*)tag_base +
KERNAUX_MULTIBOOT2_TAG_SIZE_ALIGN(tag_base)
);
}

View File

@ -94,7 +94,8 @@ void KernAux_Multiboot2_Info_print(
KernAux_Multiboot2_ITagBase_print(tag_base, printf);
tag_base = (struct KernAux_Multiboot2_ITagBase*)(
(unsigned char*)tag_base + ((tag_base->size + 7) & ~7)
(unsigned char*)tag_base +
KERNAUX_MULTIBOOT2_TAG_SIZE_ALIGN(tag_base)
);
}
}