// SPDX-License-Identifier: Apache-2.0 #pragma once #ifndef SCHBOOT_H #define SCHBOOT_H // The loader/kernel hand-off, in one place. // // Included by kernel/arch/x86_64/entry.S and by boot/uefi/main.c, so the two // cannot disagree about the magic or the layout. Defining it twice is exactly // how a loader ends up scanning for bytes the kernel never wrote — the first // attempt here searched for "SCH6" while the assembler had stored 0x53434836, // which lands in the file as "6HCS". // // Keep this header assembler-safe: no typedefs, no structs outside the C // guard, nothing entry.S cannot preprocess. // Scanned for in the first 16 KB of the kernel image, 8-byte aligned, exactly // as the BIOS loader scans for the multiboot magic. Followed by a little-endian // 64-bit physical address: the kernel's 64-bit entry point. // // The values spell "SCH6" "4BOO" when stored little-endian, which is what // makes them findable by eye in a hex dump of the image. #define SCH64_MAGIC0 0x36484353 /* "SCH6" */ #define SCH64_MAGIC1 0x4f4f4234 /* "4BOO" */ // Where the loader leaves the ACPI RSDP, as a little-endian 64-bit physical // address. Zero means "not provided, go and look for it yourself". // // The kernel's own search scans the EBDA and 0xE0000-0x100000, which is a BIOS // convention. UEFI publishes the RSDP in its configuration table instead and is // under no obligation to leave a copy anywhere in particular; OVMF does not. // Without it the kernel finds no MADT, so no IOAPIC, so no interrupt routing -- // the machine boots to a prompt on polled serial output and then ignores every // key, which looks like a broken console rather than a missing table. // // 0x30000 is the same low-memory hand-off block the BIOS loader uses: // +0x100 verbose flag, +0x200 e820 count, +0x208 the e820 map (32 entries of // 24 bytes, ending at 0x508). 0x600 is clear of all of it. #define SCHBOOT_RSDP_ADDR (0x30000 + 0x600) #ifndef __ASSEMBLER__ struct sch64_header { unsigned int magic0; // SCH64_MAGIC0 unsigned int magic1; // SCH64_MAGIC1 unsigned long long entry; // physical address, entered in long mode }; #endif /* !__ASSEMBLER__ */ #endif /* SCHBOOT_H */