162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci 362306a36Sopenharmony_ci======================= 462306a36Sopenharmony_ciBooting Linux/LoongArch 562306a36Sopenharmony_ci======================= 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci:Author: Yanteng Si <siyanteng@loongson.cn> 862306a36Sopenharmony_ci:Date: 18 Nov 2022 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ciInformation passed from BootLoader to kernel 1162306a36Sopenharmony_ci============================================ 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ciLoongArch supports ACPI and FDT. The information that needs to be passed 1462306a36Sopenharmony_cito the kernel includes the memmap, the initrd, the command line, optionally 1562306a36Sopenharmony_cithe ACPI/FDT tables, and so on. 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ciThe kernel is passed the following arguments on `kernel_entry` : 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci - a0 = efi_boot: `efi_boot` is a flag indicating whether 2062306a36Sopenharmony_ci this boot environment is fully UEFI-compliant. 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci - a1 = cmdline: `cmdline` is a pointer to the kernel command line. 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci - a2 = systemtable: `systemtable` points to the EFI system table. 2562306a36Sopenharmony_ci All pointers involved at this stage are in physical addresses. 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ciHeader of Linux/LoongArch kernel images 2862306a36Sopenharmony_ci======================================= 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ciLinux/LoongArch kernel images are EFI images. Being PE files, they have 3162306a36Sopenharmony_cia 64-byte header structured like:: 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci u32 MZ_MAGIC /* "MZ", MS-DOS header */ 3462306a36Sopenharmony_ci u32 res0 = 0 /* Reserved */ 3562306a36Sopenharmony_ci u64 kernel_entry /* Kernel entry point */ 3662306a36Sopenharmony_ci u64 _end - _text /* Kernel image effective size */ 3762306a36Sopenharmony_ci u64 load_offset /* Kernel image load offset from start of RAM */ 3862306a36Sopenharmony_ci u64 res1 = 0 /* Reserved */ 3962306a36Sopenharmony_ci u64 res2 = 0 /* Reserved */ 4062306a36Sopenharmony_ci u64 res3 = 0 /* Reserved */ 4162306a36Sopenharmony_ci u32 LINUX_PE_MAGIC /* Magic number */ 4262306a36Sopenharmony_ci u32 pe_header - _head /* Offset to the PE header */ 43