My Project
Loading...
Searching...
No Matches
efi.h
Go to the documentation of this file.
1#ifndef X86_UEFI_MEMORY_H
2#define X86_UEFI_MEMORY_H
3
4/*++
5
6Module Name:
7
8 efi.h
9
10Purpose:
11
12 This module contains the header files & prototypes required for interacting with UEFI properties
13
14Author:
15
16 slep (Matanel) 2025.
17
18Revision History:
19
20--*/
21
22// Standard headers, required.
23#include <stddef.h>
24#include <stdbool.h>
25#include <stdint.h>
26
27// global
28typedef struct _BLOCK_DEVICE BLOCK_DEVICE;
29
30// Minimal UEFI memory descriptor for kernel use
31// Matches UEFI spec EFI_MEMORY_DESCRIPTOR up to PhysicalStart, NumberOfPages, Type
32
33typedef struct _EFI_MEMORY_DESCRIPTOR {
34 uint32_t Type; // What this memory region is used for
35 uint32_t Pad; // Alignment / padding
36 uint64_t PhysicalStart; // Physical start address of the region
37 uint64_t VirtualStart; // Virtual start (usually 0 during boot)
38 uint64_t NumberOfPages; // Size of the region in pages (usually 4 KB)
39 uint64_t Attribute; // Flags (cacheable, runtime, etc.)
41
42typedef struct _GOP_PARAMS {
45 uint32_t Width; // Visible width in pixels
46 uint32_t Height; // Visible height in pixels
47 uint32_t PixelsPerScanLine; // Actual pixels per row in framebuffer (stride)
49
50#define KERNEL_STACK_SIZE_IN_BYTES (8 * 4096) // 32768 Bytes
51
64
65#ifndef _MSC_VER
66_Static_assert(sizeof(BOOT_INFO) == 352, "Size of BOOT_INFO doesn't equal 344 bytes. Update the struct.");
67_Static_assert(offsetof(BOOT_INFO, KernelStackTop) == 0x148, "KernelStackTop isnt 0x148");
68#endif
69
70/*
71Gop : offset 0x00 (0)
72MemoryMap : offset 0x20 (32)
73MapSize : offset 0x28 (40)
74DescriptorSize : offset 0x30 (48)
75DescriptorVersion : offset 0x38 (56)
76AhciCount : offset 0x40 (64)
77AhciBarBases : offset 0x48 (72)
78KernelStackTop : offset 0x148 (328)
79Pml4Phys : offset 0x150 (336)
80AcpiRsdpPhys : offset 0x158 (352)
81sizeof(BOOT_INFO) : 352 (0x160)
82*/
83
84// Memory types (we only need ConventionalMemory here)
85#define EfiReservedMemoryType 0
86#define EfiLoaderCode 1 // Unusable, marked when we allocated something.
87#define EfiLoaderData 2 // Unusable, marked when we alocated something.
88#define EfiBootServicesCode 3
89#define EfiBootServicesData 4
90#define EfiRuntimeServicesCode 5
91#define EfiRuntimeServicesData 6
92#define EfiConventionalMemory 7
93#define EfiUnusableMemory 8
94#define EfiACPIReclaimMemory 9
95#define EfiACPIMemoryNVS 10
96#define EfiMemoryMappedIO 11
97#define EfiMemoryMappedIOPort 12
98#define EfiPalCode 13
99#define EfiPersistentMemory 14
100
102
103#endif
BOOT_INFO boot_info_local
Definition kernel.c:27
struct _BLOCK_DEVICE BLOCK_DEVICE
struct _BOOT_INFO * PBOOT_INFO
struct _GOP_PARAMS GOP_PARAMS
struct _BOOT_INFO BOOT_INFO
struct _EFI_MEMORY_DESCRIPTOR EFI_MEMORY_DESCRIPTOR
struct _EFI_MEMORY_DESCRIPTOR * PEFI_MEMORY_DESCRIPTOR
uintptr_t Pml4Phys
Definition efi.h:61
size_t AhciCount
Definition efi.h:58
EFI_MEMORY_DESCRIPTOR * MemoryMap
Definition efi.h:54
uint64_t AhciBarBases[32]
Definition efi.h:59
uint64_t KernelStackTop
Definition efi.h:60
uintptr_t AcpiRsdpPhys
Definition efi.h:62
size_t DescriptorSize
Definition efi.h:56
GOP_PARAMS Gop
Definition efi.h:53
uint32_t DescriptorVersion
Definition efi.h:57
size_t MapSize
Definition efi.h:55
uint32_t Type
Definition efi.h:34
uint64_t VirtualStart
Definition efi.h:37
uint64_t NumberOfPages
Definition efi.h:38
uint64_t Attribute
Definition efi.h:39
uint64_t PhysicalStart
Definition efi.h:36
uint64_t FrameBufferBase
Definition efi.h:43
uint32_t Height
Definition efi.h:46
uint64_t FrameBufferSize
Definition efi.h:44
uint32_t Width
Definition efi.h:45
uint32_t PixelsPerScanLine
Definition efi.h:47