summaryrefslogtreecommitdiffstats
path: root/bsps/x86_64/amd64/start/start.S
diff options
context:
space:
mode:
authorKarel Gardas <karel@functional.vision>2023-04-16 23:01:58 +0200
committerKarel Gardas <karel@functional.vision>2023-04-29 20:41:23 +0200
commitbf53ff2de2c2dab5b3e2186eac5310e78b38e413 (patch)
tree2655fff7f0369e59e0474b155de28f647b0b5c56 /bsps/x86_64/amd64/start/start.S
parentbsps/amd64: increase CPU alignment to 16 (diff)
downloadrtems-bf53ff2de2c2dab5b3e2186eac5310e78b38e413.tar.bz2
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
Diffstat (limited to '')
-rw-r--r--bsps/x86_64/amd64/start/start.S72
1 files changed, 72 insertions, 0 deletions
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 <bspopts.h>
+
+#ifdef BSP_MULTIBOOT_SUPPORT
+#include <multiboot2.h>
+#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