NeKernel Handover Stub

NeKernel's Handover Stub

Brief:

Handover is a boot protocol used to deliver information between the bootloder and operating system kernel. It uses a packed bootloader header in order to do that.

Why?

The handover stub is a simple assembly code that defines the handover header structure. It is used by the bootloader to pass information to the kernel, such as the kernel's entry point, the memory map, and other information that the kernel needs to start up.

Example:

The bootloader 'boot.elf' gives control to a kernel 'kernel.elf':

  • The handover must be dynamic memory too.
  • The bootloader fills the handover header.
  • The bootloader passes the header to the kernel when it's about time to run it.
  • The kernel has to validate it, and then continue or refuse the handover header.

Snippet:


;; /*
;; *	========================================================
;; *
;; *	NeKernel
;; * 	Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
;; *
;; * 	========================================================
;; */

[bits 64]

%define kTypeKernel 100
%define kArchAmd64 122
%define kHandoverMagic 0xBADCC

global _HandoverMagic
global _HandoverType
global _HandoverPad
global _HandoverArch

section .ldr

_HandoverMagic:
    dq kHandoverMagic
_HandoverType:
    dw kTypeKernel
_HandoverPad:
    dw 0
_HandoverArch:
    dw kArchAmd64