PatchworkOS
Loading...
Searching...
No Matches
kernel.c File Reference
#include "kernel.h"
#include <boot/boot_info.h>
#include <stdint.h>
#include <sys/elf.h>
#include <sys/math.h>
#include <sys/proc.h>

Go to the source code of this file.

Functions

static BOOLEAN is_valid_phdr (const elf_phdr_t *phdr, uint64_t fileSize)
 
static BOOLEAN is_valid_shdr (const elf_shdr_t *shdr, uint64_t fileSize)
 
static EFI_STATUS determine_kernel_bounds (const elf_phdr_t *phdrs, const elf_hdr_t *header, uint64_t phdrTableSize, uintptr_t *virtStart, uintptr_t *virtEnd)
 
static EFI_STATUS load_section_headers (EFI_FILE *file, boot_kernel_t *kernel, uint64_t fileSize)
 
static elf_shdr_tfind_section_by_type (boot_kernel_t *kernel, elf_shdr_type_t sectionType)
 
static EFI_STATUS load_symbol_table (EFI_FILE *file, boot_kernel_t *kernel, uint64_t fileSize)
 
static EFI_STATUS load_kernel_segments (EFI_FILE *file, uintptr_t physStart, uintptr_t virtStart, uint64_t kernelPageAmount, const elf_phdr_t *phdrs, const elf_hdr_t *header, uint64_t fileSize)
 
EFI_STATUS kernel_load (boot_kernel_t *kernel, EFI_FILE *rootHandle)
 

Function Documentation

◆ determine_kernel_bounds()

static EFI_STATUS determine_kernel_bounds ( const elf_phdr_t phdrs,
const elf_hdr_t header,
uint64_t  phdrTableSize,
uintptr_t virtStart,
uintptr_t virtEnd 
)
static

◆ find_section_by_type()

static elf_shdr_t * find_section_by_type ( boot_kernel_t kernel,
elf_shdr_type_t  sectionType 
)
static

◆ is_valid_phdr()

static BOOLEAN is_valid_phdr ( const elf_phdr_t phdr,
uint64_t  fileSize 
)
static

Definition at line 9 of file kernel.c.

References elf_phdr_t::fileSize, NULL, and elf_phdr_t::offset.

Referenced by load_kernel_segments().

◆ is_valid_shdr()

static BOOLEAN is_valid_shdr ( const elf_shdr_t shdr,
uint64_t  fileSize 
)
static

Definition at line 24 of file kernel.c.

References ELF_SHDR_TYPE_NOBITS, NULL, elf_shdr_t::offset, elf_shdr_t::size, and elf_shdr_t::type.

Referenced by load_symbol_table().

◆ kernel_load()

◆ load_kernel_segments()

static EFI_STATUS load_kernel_segments ( EFI_FILE *  file,
uintptr_t  physStart,
uintptr_t  virtStart,
uint64_t  kernelPageAmount,
const elf_phdr_t phdrs,
const elf_hdr_t header,
uint64_t  fileSize 
)
static

◆ load_section_headers()

static EFI_STATUS load_section_headers ( EFI_FILE *  file,
boot_kernel_t kernel,
uint64_t  fileSize 
)
static

◆ load_symbol_table()