universalisos/kernel/test_boot.S
Fábio Coutada 62e8454f91 build: add UEFI ISO builder, test boot scripts, EIM config
- make-uefi-iso.sh: UEFI ISO image builder
- test_boot.S, test_boot.ld: test boot assembly and linker script
- eim_config.toml: EIM (External Interface Module) configuration
- edk2-ovmf RPM for UEFI firmware
- GAP_ANALYSIS_PIKEOS_PARITY.md: PikeOS parity gap analysis
2026-07-15 15:33:07 +01:00

87 lines
1.7 KiB
ArmAsm

/*
* Minimal Multiboot2 boot test proves QEMU x86_64 can boot our kernel.
*
* SPDX-License-Identifier: MIT
*/
.section .multiboot, "ax"
.align 8
#define MULTIBOOT2_MAGIC 0x36d76289
#define MULTIBOOT2_ARCH 0
#define MULTIBOOT2_HDR_LEN 24
mb2_header:
.long MULTIBOOT2_MAGIC
.long MULTIBOOT2_ARCH
.long -(MULTIBOOT2_MAGIC + MULTIBOOT2_ARCH)
.word MULTIBOOT2_HDR_LEN
.word 0
.section .text, "ax"
.code32
.global _start
_start:
/* Set up stack */
movl $(_stack_top), %esp
/* Save Multiboot2 info */
pushl $0
pushl %eax /* magic */
pushl %ebx /* mboot info addr */
/* Jump to 64-bit code */
ljmp $0x08, $start64
.section .text64, "ax"
.code64
start64:
/* Set up 64-bit segments */
movw $0x10, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %ss
xorw %ax, %ax
movw %ax, %fs
movw %ax, %gs
/* Restore Multiboot2 info */
popq %rdi /* magic */
popq %rsi /* info addr */
addq $8, %rsp /* skip padding */
/* Write 'UOS' to VGA text buffer (0xb8000) to prove we're alive */
movq $0x204F5355204F5355, %rax /* "UOS UOS" */
movq %rax, (%rax)
/* Write to serial port COM1 (0x3F8) */
movw $0x3F8, %dx
movb $'U', %al
outb %al, (%dx)
movb $'O', %al
outb %al, (%dx)
movb $'S', %al
outb %al, (%dx)
movb $' ', %al
outb %al, (%dx)
movb $'O', %al
outb %al, (%dx)
movb $'K', %al
outb %al, (%dx)
movb $0x0A, %al /* newline */
outb %al, (%dx)
movb $0x0D, %al /* carriage return */
outb %al, (%dx)
/* Halt */
cli
.Lhalt:
hlt
jmp .Lhalt
.section .bss, "aw"
.align 16
_stack_bottom:
.space 4096
_stack_top: