Move some assembly code to C.
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
---
xen/arch/x86/boot/build32.lds.S | 1 +
xen/arch/x86/boot/cmdline.c | 14 ++++++++++++--
xen/arch/x86/boot/head.S | 9 +--------
xen/arch/x86/boot/trampoline.S | 2 +-
xen/arch/x86/include/asm/setup.h | 2 ++
xen/arch/x86/include/boot/xen/cpumask.h | 1 +
xen/arch/x86/include/boot/xen/string.h | 10 ++++++++++
7 files changed, 28 insertions(+), 11 deletions(-)
create mode 100644 xen/arch/x86/include/boot/xen/cpumask.h
create mode 100644 xen/arch/x86/include/boot/xen/string.h
diff --git a/xen/arch/x86/boot/build32.lds.S b/xen/arch/x86/boot/build32.lds.S
index 1726c17c88..652f951e52 100644
--- a/xen/arch/x86/boot/build32.lds.S
+++ b/xen/arch/x86/boot/build32.lds.S
@@ -54,6 +54,7 @@ SECTIONS
DECLARE_IMPORT(multiboot_ptr);
DECLARE_IMPORT(pvh_boot);
DECLARE_IMPORT(pvh_start_info_pa);
+ DECLARE_IMPORT(early_boot_opts);
. = . + GAP;
*(.text)
*(.text.*)
diff --git a/xen/arch/x86/boot/cmdline.c b/xen/arch/x86/boot/cmdline.c
index 196c580e91..7a8a3ed97f 100644
--- a/xen/arch/x86/boot/cmdline.c
+++ b/xen/arch/x86/boot/cmdline.c
@@ -22,6 +22,9 @@
#include <xen/kconfig.h>
#include <xen/macros.h>
#include <xen/types.h>
+#include <xen/multiboot.h>
+
+#include <asm/setup.h>
#include "video.h"
@@ -39,6 +42,8 @@ typedef struct __packed {
#endif
} early_boot_opts_t;
+extern early_boot_opts_t early_boot_opts;
+
/* Avoid pulling in all of ctypes.h for this. */
#define tolower(c) ((c) | 0x20)
@@ -335,10 +340,15 @@ static void vga_parse(const char *cmdline, early_boot_opts_t *ebo)
#endif
/* SAF-1-safe */
-void cmdline_parse_early(const char *cmdline, early_boot_opts_t *ebo)
+void cmdline_parse_early(void)
{
- if ( !cmdline )
+ early_boot_opts_t *ebo = &early_boot_opts;
+ struct multiboot_info *mbi = (void *)multiboot_ptr;
+ const char *cmdline;
+
+ if ( !(mbi->flags & MBI_CMDLINE) || !mbi->cmdline )
return;
+ cmdline = (void *)mbi->cmdline;
ebo->skip_realmode = skip_realmode(cmdline);
ebo->opt_edd = edd_parse(cmdline);
diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
index f86910294f..b79d4884df 100644
--- a/xen/arch/x86/boot/head.S
+++ b/xen/arch/x86/boot/head.S
@@ -690,14 +690,7 @@ trampoline_setup:
cmpb $0, sym_esi(efi_platform)
jnz 1f
- /* Bail if there is no command line to parse. */
- mov sym_esi(multiboot_ptr), %ebx
- testl $MBI_CMDLINE,MB_flags(%ebx)
- jz 1f
-
- lea sym_esi(early_boot_opts), %edx
- mov MB_cmdline(%ebx), %eax
- /* cmdline_parse_early(cmdline/eax, opts/edx) using fastcall. */
+ /* cmdline_parse_early using fastcall. */
call cmdline_parse_early
1:
diff --git a/xen/arch/x86/boot/trampoline.S b/xen/arch/x86/boot/trampoline.S
index b8ab0ffdcb..f2fa7ca07d 100644
--- a/xen/arch/x86/boot/trampoline.S
+++ b/xen/arch/x86/boot/trampoline.S
@@ -258,7 +258,7 @@ trampoline_boot_cpu_entry:
.align 2
/* Keep in sync with cmdline.c:early_boot_opts_t type! */
-early_boot_opts:
+GLOBAL(early_boot_opts)
skip_realmode:
.byte 0
opt_edd:
diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h
index 25c15ef914..a5ca007722 100644
--- a/xen/arch/x86/include/asm/setup.h
+++ b/xen/arch/x86/include/asm/setup.h
@@ -16,6 +16,8 @@ extern uint64_t boot_tsc_stamp;
extern void *stack_start;
extern unsigned int multiboot_ptr;
+struct domain;
+
void early_cpu_init(bool verbose);
void early_time_init(void);
diff --git a/xen/arch/x86/include/boot/xen/cpumask.h b/xen/arch/x86/include/boot/xen/cpumask.h
new file mode 100644
index 0000000000..046b862b78
--- /dev/null
+++ b/xen/arch/x86/include/boot/xen/cpumask.h
@@ -0,0 +1 @@
+/* Empty. */
diff --git a/xen/arch/x86/include/boot/xen/string.h b/xen/arch/x86/include/boot/xen/string.h
new file mode 100644
index 0000000000..6556d3b4af
--- /dev/null
+++ b/xen/arch/x86/include/boot/xen/string.h
@@ -0,0 +1,10 @@
+#ifndef BOOT__XEN__STRING_H
+#define BOOT__XEN__STRING_H
+
+#include <xen/types.h> /* for size_t */
+
+void *memset(void *s, int c, size_t n);
+void *memcpy(void *dest, const void *src, size_t n);
+void *memmove(void *dest, const void *src, size_t n);
+
+#endif /* BOOT__XEN__STRING_H */
--
2.34.1
© 2016 - 2024 Red Hat, Inc.