bootloader: Align boot volume structure to 8 bytes instead of 4.

This alignment is preferred e.g. on ARM when using 64-bit values.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
This commit is contained in:
Jaroslaw Pelczar 2018-03-09 21:47:54 +01:00 committed by Augustin Cavalier
parent fb4cc98472
commit 5effe7f3ec

View File

@ -132,15 +132,15 @@ main(stage2_args *args)
gKernelArgs.version = CURRENT_KERNEL_ARGS_VERSION;
// clone the boot_volume KMessage into kernel accessible memory
// note, that we need to 4 byte align the buffer and thus allocate
// 3 more bytes
void* buffer = kernel_args_malloc(gBootVolume.ContentSize() + 3);
// note, that we need to 8-byte align the buffer and thus allocate
// 7 more bytes
void* buffer = kernel_args_malloc(gBootVolume.ContentSize() + 7);
if (!buffer) {
panic("Could not allocate memory for the boot volume kernel "
"arguments");
}
buffer = (void*)(((addr_t)buffer + 3) & ~(addr_t)0x3);
buffer = (void*)(((addr_t)buffer + 7) & ~(addr_t)0x7);
memcpy(buffer, gBootVolume.Buffer(), gBootVolume.ContentSize());
gKernelArgs.boot_volume = buffer;
gKernelArgs.boot_volume_size = gBootVolume.ContentSize();