Files
LithosAnanake/kernel/include/starkernel/uefi.h
T
rajamesandClaude Opus 5.5 1b45f5f85f feat(boot): the loader tells the kernel its boot disk; system=v3 is refused on a stick
uefi.h: the UEFI device path and Block I/O protocols, a typed LocateDevicePath, and BootDisk
{gpt, is_stick, disk_guid[16]} appended to BootInfo after args (boot_info_offsets.h unchanged).
The loader, before ExitBootServices, cuts its image's device path at the partition's HardDrive
node, locates the whole disk's Block I/O (whole path consumed, not a logical partition, 512-byte
blocks), reads it as 1 KiB blocks through a loader-side blkio adapter, and runs the kernel's own
gpt_read: is it a StarshipOS stick (identity and Artemis partitions), and its DiskGUID
(gpt_disk_guid, new). No HardDrive node (an ISO/CD boot), no GPT, or any failure: not a stick.
Monolithic builds only (the non-monolithic loader does not link gpt.c, and does not build today:
kernel/src/vm/vm_core.c -- reported, not fixed).

The kernel prints 'Boot disk: a StarshipOS stick' or '... not a StarshipOS stick', and on a stick
system=v3 gives 'System: v3 is not on this stick -- StarForth v4' and boots v4.

Tests: stick_v3 (new), stick_boot and zuse x3 failed on the new lines before, pass after; v3_keys
still boots v3 off a stick. Acceptance: amd64, aarch64, riscv64 to [zuse@Hera] ok>, POST 538/538,
dict_hash 0xfec8c47cfc6f437f; v4 suite and test-32 0 failures.

Plan: docs/v4.0.0/plans/2026-10-27-stick-4-one-disk.md, Task 3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 12:08:48 -04:00

734 lines
20 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
StarForth — Steady-State Virtual Machine Runtime
Copyright (c) 2023–2025 Robert A. James
All rights reserved.
This file is part of the StarForth project.
Licensed under the StarForth License, Version 1.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at:
https://github.com/star.4th@proton.me/StarForth/LICENSE.txt
This software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND,
express or implied, including but not limited to the warranties of
merchantability, fitness for a particular purpose, and noninfringement.
See the License for the specific language governing permissions and
limitations under the License.
StarForth — Steady-State Virtual Machine Runtime
Copyright (c) 2023–2025 Robert A. James
All rights reserved.
This file is part of the StarForth project.
Licensed under the StarForth License, Version 1.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at:
https://github.com/star.4th@proton.me/StarForth/LICENSE.txt
This software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND,
express or implied, including but not limited to the warranties of
merchantability, fitness for a particular purpose, and noninfringement.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* uefi.h - UEFI definitions for StarKernel
* Minimal UEFI interface for bare-metal boot
*/
#ifndef STARKERNEL_UEFI_H
#define STARKERNEL_UEFI_H
#include <stdint.h>
#include <stddef.h>
/* UEFI Basic Types */
typedef uint64_t UINTN;
typedef int64_t INTN;
typedef uint8_t UINT8;
typedef uint16_t UINT16;
typedef uint32_t UINT32;
typedef uint64_t UINT64;
typedef int8_t INT8;
typedef int16_t INT16;
typedef int32_t INT32;
typedef int64_t INT64;
typedef uint8_t BOOLEAN;
typedef void VOID;
typedef uint16_t CHAR16;
typedef UINTN EFI_TPL;
#define TRUE ((BOOLEAN)1)
#define FALSE ((BOOLEAN)0)
#define TPL_APPLICATION 4
#define TPL_CALLBACK 8
#define TPL_NOTIFY 16
#define TPL_HIGH_LEVEL 31
/* Calling convention */
#if defined(__x86_64__) || defined(__i386__)
#define EFIAPI __attribute__((ms_abi))
#else
#define EFIAPI
#endif
/* EFI Status Codes */
typedef UINTN EFI_STATUS;
#define EFI_SUCCESS 0
#define EFI_LOAD_ERROR (1 | (1ULL << 63))
#define EFI_INVALID_PARAMETER (2 | (1ULL << 63))
#define EFI_UNSUPPORTED (3 | (1ULL << 63))
#define EFI_BAD_BUFFER_SIZE (4 | (1ULL << 63))
#define EFI_BUFFER_TOO_SMALL (5 | (1ULL << 63))
#define EFI_NOT_READY (6 | (1ULL << 63))
#define EFI_DEVICE_ERROR (7 | (1ULL << 63))
#define EFI_WRITE_PROTECTED (8 | (1ULL << 63))
#define EFI_OUT_OF_RESOURCES (9 | (1ULL << 63))
#define EFI_NOT_FOUND (14 | (1ULL << 63))
#define EFI_ABORTED (21 | (1ULL << 63))
/* EFI Handle */
typedef void* EFI_HANDLE;
/* EFI Physical Address */
typedef UINT64 EFI_PHYSICAL_ADDRESS;
/* Allocation types for AllocatePages */
typedef enum {
AllocateAnyPages,
AllocateMaxAddress,
AllocateAddress,
MaxAllocateType
} EFI_ALLOCATE_TYPE;
/* EFI GUID */
typedef struct {
UINT32 Data1;
UINT16 Data2;
UINT16 Data3;
UINT8 Data4[8];
} EFI_GUID;
/* EFI Memory Types */
typedef enum {
EfiReservedMemoryType,
EfiLoaderCode,
EfiLoaderData,
EfiBootServicesCode,
EfiBootServicesData,
EfiRuntimeServicesCode,
EfiRuntimeServicesData,
EfiConventionalMemory,
EfiUnusableMemory,
EfiACPIReclaimMemory,
EfiACPIMemoryNVS,
EfiMemoryMappedIO,
EfiMemoryMappedIOPortSpace,
EfiPalCode,
EfiPersistentMemory,
EfiMaxMemoryType
} EFI_MEMORY_TYPE;
/* EFI Memory Descriptor */
typedef struct {
UINT32 Type;
UINT64 PhysicalStart;
UINT64 VirtualStart;
UINT64 NumberOfPages;
UINT64 Attribute;
} EFI_MEMORY_DESCRIPTOR;
/* Memory Attributes */
#define EFI_MEMORY_UC 0x0000000000000001ULL
#define EFI_MEMORY_WC 0x0000000000000002ULL
#define EFI_MEMORY_WT 0x0000000000000004ULL
#define EFI_MEMORY_WB 0x0000000000000008ULL
#define EFI_MEMORY_UCE 0x0000000000000010ULL
#define EFI_MEMORY_WP 0x0000000000001000ULL
#define EFI_MEMORY_RP 0x0000000000002000ULL
#define EFI_MEMORY_XP 0x0000000000004000ULL
#define EFI_MEMORY_RUNTIME 0x8000000000000000ULL
/* EFI Table Header */
typedef struct {
UINT64 Signature;
UINT32 Revision;
UINT32 HeaderSize;
UINT32 CRC32;
UINT32 Reserved;
} EFI_TABLE_HEADER;
/* Forward declarations */
struct _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;
struct _EFI_BOOT_SERVICES;
struct _EFI_RUNTIME_SERVICES;
/* Simple Text Output Protocol */
typedef EFI_STATUS (EFIAPI *EFI_TEXT_STRING)(
struct _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
CHAR16 *String
);
typedef EFI_STATUS (EFIAPI *EFI_TEXT_RESET)(
struct _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
BOOLEAN ExtendedVerification
);
typedef struct _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL {
EFI_TEXT_RESET Reset;
EFI_TEXT_STRING OutputString;
void *TestString;
void *QueryMode;
void *SetMode;
void *SetAttribute;
void *ClearScreen;
void *SetCursorPosition;
void *EnableCursor;
void *Mode;
} EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;
/* Boot Services */
typedef EFI_STATUS (EFIAPI *EFI_GET_MEMORY_MAP)(
UINTN *MemoryMapSize,
EFI_MEMORY_DESCRIPTOR *MemoryMap,
UINTN *MapKey,
UINTN *DescriptorSize,
UINT32 *DescriptorVersion
);
typedef EFI_STATUS (EFIAPI *EFI_EXIT_BOOT_SERVICES)(
EFI_HANDLE ImageHandle,
UINTN MapKey
);
typedef EFI_STATUS (EFIAPI *EFI_ALLOCATE_POOL)(
EFI_MEMORY_TYPE PoolType,
UINTN Size,
void **Buffer
);
typedef EFI_STATUS (EFIAPI *EFI_FREE_POOL)(
void *Buffer
);
typedef EFI_STATUS (EFIAPI *EFI_ALLOCATE_PAGES)(
EFI_ALLOCATE_TYPE Type,
EFI_MEMORY_TYPE MemoryType,
UINTN Pages,
EFI_PHYSICAL_ADDRESS *Memory
);
typedef EFI_STATUS (EFIAPI *EFI_FREE_PAGES)(
EFI_PHYSICAL_ADDRESS Memory,
UINTN Pages
);
typedef EFI_STATUS (EFIAPI *EFI_HANDLE_PROTOCOL)(
EFI_HANDLE Handle,
EFI_GUID *Protocol,
void **Interface
);
typedef EFI_STATUS (EFIAPI *EFI_STALL)(
UINTN Microseconds
);
/* Search types for LocateHandle */
typedef enum {
AllHandles,
ByRegisterNotify,
ByProtocol
} EFI_LOCATE_SEARCH_TYPE;
typedef EFI_STATUS (EFIAPI *EFI_LOCATE_HANDLE)(
EFI_LOCATE_SEARCH_TYPE SearchType,
EFI_GUID *Protocol,
void *SearchKey,
UINTN *BufferSize,
EFI_HANDLE *Buffer
);
typedef EFI_STATUS (EFIAPI *EFI_LOCATE_PROTOCOL)(
EFI_GUID *Protocol,
void *Registration,
void **Interface
);
/* Device path (UEFI 2.x 10.2): a list of nodes, each a 4-byte header
* (Type, SubType, Length little-endian) followed by its data, ending in an
* End node (Type 0x7F, SubType 0xFF). */
typedef struct {
UINT8 Type;
UINT8 SubType;
UINT8 Length[2];
} EFI_DEVICE_PATH_PROTOCOL;
#define EFI_DEVICE_PATH_TYPE_MEDIA 0x04
#define EFI_DEVICE_PATH_SUBTYPE_HARDDRIVE 0x01
#define EFI_DEVICE_PATH_TYPE_END 0x7F
#define EFI_DEVICE_PATH_SUBTYPE_END_ENTIRE 0xFF
typedef EFI_STATUS (EFIAPI *EFI_LOCATE_DEVICE_PATH)(
EFI_GUID *Protocol,
EFI_DEVICE_PATH_PROTOCOL **DevicePath,
EFI_HANDLE *Device
);
typedef EFI_TPL (EFIAPI *EFI_RAISE_TPL)(
EFI_TPL NewTpl
);
typedef void (EFIAPI *EFI_RESTORE_TPL)(
EFI_TPL OldTpl
);
typedef struct _EFI_BOOT_SERVICES {
EFI_TABLE_HEADER Hdr;
/* Task Priority Services */
EFI_RAISE_TPL RaiseTPL;
EFI_RESTORE_TPL RestoreTPL;
/* Memory Services */
EFI_ALLOCATE_PAGES AllocatePages;
EFI_FREE_PAGES FreePages;
EFI_GET_MEMORY_MAP GetMemoryMap;
EFI_ALLOCATE_POOL AllocatePool;
EFI_FREE_POOL FreePool;
/* Event & Timer Services */
void *CreateEvent;
void *SetTimer;
void *WaitForEvent;
void *SignalEvent;
void *CloseEvent;
void *CheckEvent;
/* Protocol Handler Services */
void *InstallProtocolInterface;
void *ReinstallProtocolInterface;
void *UninstallProtocolInterface;
EFI_HANDLE_PROTOCOL HandleProtocol;
void *Reserved;
void *RegisterProtocolNotify;
EFI_LOCATE_HANDLE LocateHandle;
EFI_LOCATE_DEVICE_PATH LocateDevicePath;
void *InstallConfigurationTable;
/* Image Services */
void *LoadImage;
void *StartImage;
void *Exit;
void *UnloadImage;
EFI_EXIT_BOOT_SERVICES ExitBootServices;
/* Misc Services */
void *GetNextMonotonicCount;
EFI_STALL Stall;
void *SetWatchdogTimer;
/* Driver Support Services */
void *ConnectController;
void *DisconnectController;
/* Open/Close Protocol Services */
void *OpenProtocol;
void *CloseProtocol;
void *OpenProtocolInformation;
/* Library Services */
void *ProtocolsPerHandle;
void *LocateHandleBuffer;
EFI_LOCATE_PROTOCOL LocateProtocol;
} EFI_BOOT_SERVICES;
/* Runtime Services */
typedef struct _EFI_RUNTIME_SERVICES {
EFI_TABLE_HEADER Hdr;
/* Time Services */
void *GetTime;
void *SetTime;
void *GetWakeupTime;
void *SetWakeupTime;
/* Virtual Memory Services */
void *SetVirtualAddressMap;
void *ConvertPointer;
/* Variable Services */
void *GetVariable;
void *GetNextVariableName;
void *SetVariable;
/* Misc Services */
void *GetNextHighMonotonicCount;
void *ResetSystem;
} EFI_RUNTIME_SERVICES;
/* System Table */
typedef struct _EFI_SYSTEM_TABLE {
EFI_TABLE_HEADER Hdr;
CHAR16 *FirmwareVendor;
UINT32 FirmwareRevision;
EFI_HANDLE ConsoleInHandle;
void *ConIn;
EFI_HANDLE ConsoleOutHandle;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;
EFI_HANDLE StandardErrorHandle;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *StdErr;
EFI_RUNTIME_SERVICES *RuntimeServices;
EFI_BOOT_SERVICES *BootServices;
UINTN NumberOfTableEntries;
void *ConfigurationTable;
} EFI_SYSTEM_TABLE;
/* Configuration Table */
typedef struct {
EFI_GUID VendorGuid;
void *VendorTable;
} EFI_CONFIGURATION_TABLE;
/* ACPI GUIDs */
static const EFI_GUID EFI_ACPI_20_TABLE_GUID = {0x8868e871,0xe4f1,0x11d3,{0xbc,0x22,0x00,0x80,0xc7,0x3c,0x88,0x81}};
static const EFI_GUID EFI_ACPI_TABLE_GUID = {0xeb9d2d30,0x2d88,0x11d3,{0x9a,0x16,0x00,0x90,0x27,0x3f,0xc1,0x4d}};
/* Devicetree Blob GUID (UEFI 2.10 §4.6, "Devicetree Tables").
* On QEMU virt for riscv64 and aarch64 the firmware publishes the FDT here;
* it is the only route to timebase-frequency (riscv64, item 0.3) and to the
* GIC base addresses and timer PPI (aarch64, item 0.6). */
static const EFI_GUID EFI_DTB_TABLE_GUID = {
0xb1b621d5, 0xf19c, 0x41a5, {0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0}
};
/* Graphics Output Protocol */
typedef enum {
PixelRedGreenBlueReserved8BitPerColor,
PixelBlueGreenRedReserved8BitPerColor,
PixelBitMask,
PixelBltOnly,
PixelFormatMax
} EFI_GRAPHICS_PIXEL_FORMAT;
typedef struct {
UINT32 RedMask;
UINT32 GreenMask;
UINT32 BlueMask;
UINT32 ReservedMask;
} EFI_PIXEL_BITMASK;
typedef struct {
UINT32 Version;
UINT32 HorizontalResolution;
UINT32 VerticalResolution;
EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
EFI_PIXEL_BITMASK PixelInformation;
UINT32 PixelsPerScanLine;
} EFI_GRAPHICS_OUTPUT_MODE_INFORMATION;
typedef struct {
UINT32 MaxMode;
UINT32 Mode;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
UINTN SizeOfInfo;
EFI_PHYSICAL_ADDRESS FrameBufferBase;
UINTN FrameBufferSize;
} EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE;
struct _EFI_GRAPHICS_OUTPUT_PROTOCOL;
typedef EFI_STATUS (EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE)(
struct _EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
UINT32 ModeNumber,
UINTN *SizeOfInfo,
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info
);
typedef EFI_STATUS (EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE)(
struct _EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
UINT32 ModeNumber
);
typedef struct _EFI_GRAPHICS_OUTPUT_PROTOCOL {
EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE QueryMode;
EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE SetMode;
void *Blt;
EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode;
} EFI_GRAPHICS_OUTPUT_PROTOCOL;
static const EFI_GUID EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID =
{0x9042a9de, 0x23dc, 0x4a38, {0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a}};
/* Framebuffer info (from GOP, passed to kernel) */
typedef struct {
void *base;
UINTN size;
UINT32 width;
UINT32 height;
UINT32 pixels_per_scanline;
UINT32 pixel_format; /* EFI_GRAPHICS_PIXEL_FORMAT value */
} FramebufferInfo;
/* File System Protocols (needed for loader) */
static const EFI_GUID EFI_LOADED_IMAGE_PROTOCOL_GUID =
{0x5B1B31A1,0x9562,0x11d2, {0x8E,0x3F,0x00,0xA0,0xC9,0x69,0x72,0x3B}};
static const EFI_GUID EFI_DEVICE_PATH_PROTOCOL_GUID =
{0x09576e91,0x6d3f,0x11d2, {0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b}};
/* Block I/O (UEFI 2.x 13.9): the boot disk read whole, before ExitBootServices
* (docs/v4.0.0/plans/2026-10-27-stick-4-one-disk.md, Task 3). */
static const EFI_GUID EFI_BLOCK_IO_PROTOCOL_GUID =
{0x964e5b21,0x6459,0x11d2, {0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b}};
typedef struct {
UINT32 MediaId;
BOOLEAN RemovableMedia;
BOOLEAN MediaPresent;
BOOLEAN LogicalPartition;
BOOLEAN ReadOnly;
BOOLEAN WriteCaching;
UINT32 BlockSize;
UINT32 IoAlign;
UINT64 LastBlock;
} EFI_BLOCK_IO_MEDIA;
struct _EFI_BLOCK_IO_PROTOCOL;
typedef EFI_STATUS (EFIAPI *EFI_BLOCK_READ)(
struct _EFI_BLOCK_IO_PROTOCOL *This,
UINT32 MediaId,
UINT64 Lba,
UINTN BufferSize,
void *Buffer
);
typedef struct _EFI_BLOCK_IO_PROTOCOL {
UINT64 Revision;
EFI_BLOCK_IO_MEDIA *Media;
void *Reset;
EFI_BLOCK_READ ReadBlocks;
void *WriteBlocks;
void *FlushBlocks;
} EFI_BLOCK_IO_PROTOCOL;
static const EFI_GUID EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID =
{0x0964e5b22,0x6459,0x11d2, {0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b}};
static const EFI_GUID EFI_FILE_INFO_GUID =
{0x09576e92,0x6d3f,0x11d2, {0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b}};
#define EFI_FILE_MODE_READ 0x0000000000000001ULL
struct _EFI_FILE_PROTOCOL;
struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL;
typedef EFI_STATUS (EFIAPI *EFI_FILE_OPEN)(
struct _EFI_FILE_PROTOCOL *This,
struct _EFI_FILE_PROTOCOL **NewHandle,
CHAR16 *FileName,
UINT64 OpenMode,
UINT64 Attributes
);
typedef EFI_STATUS (EFIAPI *EFI_FILE_CLOSE)(
struct _EFI_FILE_PROTOCOL *This
);
typedef EFI_STATUS (EFIAPI *EFI_FILE_READ)(
struct _EFI_FILE_PROTOCOL *This,
UINTN *BufferSize,
VOID *Buffer
);
typedef EFI_STATUS (EFIAPI *EFI_FILE_GET_INFO)(
struct _EFI_FILE_PROTOCOL *This,
EFI_GUID *InformationType,
UINTN *BufferSize,
VOID *Buffer
);
typedef struct _EFI_FILE_PROTOCOL {
UINT64 Revision;
EFI_FILE_OPEN Open;
EFI_FILE_CLOSE Close;
VOID *Delete;
EFI_FILE_READ Read;
VOID *Write;
VOID *GetPosition;
VOID *SetPosition;
EFI_FILE_GET_INFO GetInfo;
VOID *SetInfo;
VOID *Flush;
} EFI_FILE_PROTOCOL;
typedef EFI_STATUS (EFIAPI *EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME)(
struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
EFI_FILE_PROTOCOL **Root
);
typedef struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL {
UINT64 Revision;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME OpenVolume;
} EFI_SIMPLE_FILE_SYSTEM_PROTOCOL;
typedef struct {
UINT16 Year;
UINT8 Month;
UINT8 Day;
UINT8 Hour;
UINT8 Minute;
UINT8 Second;
UINT8 Pad1;
UINT32 Nanosecond;
INT16 TimeZone;
UINT8 Daylight;
UINT8 Pad2;
} EFI_TIME;
typedef struct {
UINT64 Size;
UINT64 FileSize;
UINT64 PhysicalSize;
EFI_TIME CreateTime;
EFI_TIME LastAccessTime;
EFI_TIME ModificationTime;
UINT64 Attribute;
CHAR16 FileName[256];
} EFI_FILE_INFO;
/* EFI_LOADED_IMAGE_PROTOCOL — spec-compliant layout (UEFI 2.x §8.1)
* Offsets (64-bit):
* 0: Revision (4) + 4 pad
* 8: ParentHandle (8)
* 16: SystemTable (8)
* 24: DeviceHandle (8)
* 32: FilePath (8)
* 40: Reserved (8)
* 48: LoadOptionsSize (4) + 4 pad
* 56: LoadOptions (8)
* 64: ImageBase (8)
* 72: ImageSize (8)
* 80: ImageCodeType (4)
* 84: ImageDataType (4)
* 88: Unload (8)
*/
typedef struct {
UINT32 Revision;
EFI_HANDLE ParentHandle;
void *SystemTable;
EFI_HANDLE DeviceHandle;
VOID *FilePath;
VOID *Reserved;
UINT32 LoadOptionsSize;
VOID *LoadOptions;
VOID *ImageBase;
UINT64 ImageSize;
EFI_MEMORY_TYPE ImageCodeType;
EFI_MEMORY_TYPE ImageDataType;
VOID *Unload;
} EFI_LOADED_IMAGE_PROTOCOL;
/* ---- UEFI Variable Services typedefs ----------------------------------- */
#define EFI_VARIABLE_NON_VOLATILE 0x00000001U
#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002U
#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004U
typedef EFI_STATUS (EFIAPI *EFI_GET_VARIABLE)(
CHAR16 *VariableName,
EFI_GUID *VendorGuid,
UINT32 *Attributes,
UINTN *DataSize,
void *Data
);
typedef EFI_STATUS (EFIAPI *EFI_SET_VARIABLE)(
CHAR16 *VariableName,
EFI_GUID *VendorGuid,
UINT32 Attributes,
UINTN DataSize,
void *Data
);
typedef enum {
EfiResetCold,
EfiResetWarm,
EfiResetShutdown
} EFI_RESET_TYPE;
typedef void (EFIAPI *EFI_RESET_SYSTEM)(
EFI_RESET_TYPE ResetType,
EFI_STATUS ResetStatus,
UINTN DataSize,
void *ResetData
);
/* ---- StarForth vendor GUID (for NVRAM variables) ----------------------- */
/* {b7e42c1a-4f3d-4e8b-9c5a-1d2f6a8b3e70} */
#define STARFORTH_VENDOR_GUID \
{0xb7e42c1aU, 0x4f3dU, 0x4e8bU, \
{0x9cU, 0x5aU, 0x1dU, 0x2fU, 0x6aU, 0x8bU, 0x3eU, 0x70U}}
/* NVRAM variable names (UCS-2 string literals) */
#define SF_VAR_BOOT_ARGS L"StarForthBootArgs"
#define SF_VAR_REBOOT_TRIES L"StarForthRebootTries"
#define SF_VAR_ZUSE_CERT L"StarForthZuseCert" /* 64 bytes: 32-byte Ed25519
* seed || 32-byte pubkey.
* Written exactly once
* (Phase 8 first-boot mint,
* see FABRIC-2.md) --
* presence means the fuse
* is already blown. */
/* ---- BootInfo extension ------------------------------------------------ */
#include "kernel_args.h"
/* The boot disk, as the loader found it. All zero when the firmware gave
* no whole-disk Block I/O for it (an ISO or CD boot) or it has no GPT. */
typedef struct {
uint8_t gpt; /* its GPT read GPT_OK */
uint8_t is_stick; /* it has a StarshipOS identity and a StarshipOS Artemis partition */
uint8_t disk_guid[16]; /* the GPT header's DiskGUID, as on disk */
} BootDisk;
/* Boot Info Structure (passed to kernel) */
typedef struct {
EFI_MEMORY_DESCRIPTOR *memory_map;
UINTN memory_map_size;
UINTN memory_map_descriptor_size;
EFI_RUNTIME_SERVICES *runtime_services;
void *acpi_table;
/* Devicetree blob, located by EFI_DTB_TABLE_GUID in the configuration
* table; NULL when the firmware publishes none (amd64 typically, and any
* platform that is ACPI-only). Consumers must handle NULL rather than
* assume presence. */
void* dtb;
FramebufferInfo framebuffer;
UINT8 uefi_boot_services_exited;
/* Loader-allocated kernel stack (zero = fall back to 2 MiB BSS stack) */
void *kernel_stack_base;
uint64_t kernel_stack_size;
/* Parsed boot command-line arguments */
KernelArgs args;
/* The disk the loader was booted from (appended after args, so
* boot_info_offsets.h is unchanged): filled before ExitBootServices
* from the boot disk's GPT, read with the kernel's own gpt.c
* (docs/v4.0.0/plans/2026-10-27-stick-4-one-disk.md, Task 3). */
BootDisk boot_disk;
} BootInfo;
#endif /* STARKERNEL_UEFI_H */