From bf53ff2de2c2dab5b3e2186eac5310e78b38e413 Mon Sep 17 00:00:00 2001 From: Karel Gardas Date: Sun, 16 Apr 2023 23:01:58 +0200 Subject: bsps/amd64: add a new EFI-based variant of AMD64 BSP The new amd64efi BSP supports: - multiboot2 boot format. Runs well with GRUB. - console based on either EFI simple text output or GOP-based framebuffer - clock based on EFI event/timer API - early console using either hard-wired PC-AT serial or just memory buffer - with EFI support disabled the BSP is more or less equivalent to amd64 BSP with multiboot2 support --- bsps/x86_64/amd64/start/start.S | 72 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) (limited to 'bsps/x86_64/amd64/start/start.S') diff --git a/bsps/x86_64/amd64/start/start.S b/bsps/x86_64/amd64/start/start.S index e1a50e05db..e1812e5410 100644 --- a/bsps/x86_64/amd64/start/start.S +++ b/bsps/x86_64/amd64/start/start.S @@ -1,6 +1,7 @@ /* * SPDX-License-Identifier: BSD-2-Clause * + * Copyright (C) 2023 Karel Gardas * Copyright (C) 2018 embedded brains GmbH * * Redistribution and use in source and binary forms, with or without @@ -25,6 +26,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include + +#ifdef BSP_MULTIBOOT_SUPPORT +#include +#endif + .text .section .text._start,"ax",@progbits .p2align 4,,15 @@ -36,6 +43,71 @@ _start: subq $8, %rsp .cfi_def_cfa_offset 16 xorl %edi, %edi +#ifdef BSP_MULTIBOOT_SUPPORT + mov %eax, _multiboot2_magic + mov %rbx, _multiboot2_info_ptr +#endif movabsq $boot_card, %rax call *%rax .cfi_endproc + +#ifdef BSP_MULTIBOOT_SUPPORT + +multiboot2: + ret + +_multiboot2_start: + jmp _start + + .text + .section .multiboot2_header + .p2align 4,,15 +multiboot2_header_start: + .long MULTIBOOT2_HEADER_MAGIC + .long MULTIBOOT_ARCHITECTURE_I386 + .long multiboot2_header_end - multiboot2_header_start + .long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_I386 + (multiboot2_header_end - multiboot2_header_start)) +efi_bootservices_start: + .short MULTIBOOT_HEADER_TAG_EFI_BS + .short 0 + .long efi_bootservices_end - efi_bootservices_start +efi_bootservices_end: +efi64_entry_start: + .short MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 + .short 0 + .long efi64_entry_end - efi64_entry_start + .long _start /* directly copied from resulting ELF */ + /* padding to 8 byte tags allignment */ + .long 0 +efi64_entry_end: +info_requests_start: + .short MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST + .short 0 + .long info_requests_end - info_requests_start + .long MULTIBOOT_TAG_TYPE_EFI64 + .long MULTIBOOT_TAG_TYPE_CMDLINE +#ifdef BSP_USE_EFI_BOOT_SERVICES + .long MULTIBOOT_TAG_TYPE_EFI_BS +#else + .long 0 +#endif + /* padding to 8 byte tags allignment */ + .long 0 +info_requests_end: + /* header end*/ + .short MULTIBOOT_HEADER_TAG_END + .short 0 + .long 8 +multiboot2_header_end: + + .data + .global _multiboot2_magic +_multiboot2_magic: + .long 0 + + .data + .global _multiboot2_info_ptr +_multiboot2_info_ptr: + .quad 0 + +#endif -- cgit v1.2.3