mirror of
https://github.com/ivoszbg/uniLoader.git
synced 2026-08-15 05:18:32 +00:00
- Move main headers from include/ to include/main/
- Split booting logic to boot.c and boot-fdt.c to avoid cluttering main()
- Conditionally compile boot-fdt only if libfdt is used
- Add some better logging
Change was tested on qemu-virt, which succesfully booted a kernel:
$ qemu-system-aarch64 -machine virt -cpu cortex-a72 -nographic -m 512m -kernel uniLoader.o
[INFO] .__.____ .___
[INFO] __ __ ____ |__| | _________ __| _/___________
[INFO] | | \/ \| | | / _ \__ \ / __ |/ __ \_ __\
[INFO] | | / | \ | |__( <_> ) __ \_/ /_/ \ ___/| |\/
[INFO] |____/|___| /__|_______ \____(____ /\____ |\___ >__|
[INFO] \/ \/ \/ \/ \/
[INFO] passed board initialization
[INFO] welcome to uniLoader (e69eba1) - date 2026-02-21 14:01:34 on qemu-virt
[INFO] Booting kernel...
[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd083]
[ 0.000000] Linux version 6.12.73+deb13-arm64 (debian-kernel@lists.debian.org) (aarch64-linux-gnu-gcc-14 (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44) #1 SMP Debian 6.12.73-1 (2026-02-17)
[ 0.000000] KASLR enabled
[ 0.000000] random: crng init done
[...]
Signed-off-by: Igor Belwon <igor.belwon@mentallysanemainliners.org>
28 lines
849 B
C
28 lines
849 B
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (c) 2022, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
|
|
* Copyright (c) 2026, Igor Belwon <igor.belwon@mentallysanemainliners.org>
|
|
*/
|
|
|
|
#include <lib/debug.h>
|
|
#include <main/boot.h>
|
|
#include <main/boot-fdt.h>
|
|
#include <string.h>
|
|
|
|
void boot_kernel(void* dt, void* kernel, void* ramdisk)
|
|
{
|
|
#ifdef CONFIG_LIBFDT
|
|
patch_dtb(dt);
|
|
#endif
|
|
|
|
#if !defined(CONFIG_RAMDISK_NO_COPY) && !defined(__arm__)
|
|
__optimized_memcpy((void*)CONFIG_RAMDISK_ENTRY, ramdisk, (unsigned long) &ramdisk_size);
|
|
#elif !defined(CONFIG_RAMDISK_NO_COPY)
|
|
memcpy((void*)CONFIG_RAMDISK_ENTRY, ramdisk, (unsigned long) &ramdisk_size);
|
|
#endif
|
|
memcpy((void*)CONFIG_PAYLOAD_ENTRY, kernel, (unsigned long) &kernel_size);
|
|
|
|
printk(KERN_INFO, "Booting kernel...\n");
|
|
load_kernel_and_jump(dt, 0, 0, 0, (void*)CONFIG_PAYLOAD_ENTRY);
|
|
}
|