]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
plat/kvm: Move `ukplat_memregion` API's to platform common location
authorSergiu Moga <sergiu.moga@protonmail.com>
Thu, 6 Apr 2023 15:07:34 +0000 (18:07 +0300)
committerUnikraft <monkey@unikraft.io>
Fri, 11 Aug 2023 10:18:44 +0000 (10:18 +0000)
Since these API's can be used on any platform and any architecture
subsystem that integrates `struct ukplat_bootinfo` structure, move
their definitions to a platform common place in the tree.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #848

plat/common/memory.c
plat/kvm/Makefile.uk
plat/kvm/memory.c [new file with mode: 0644]
plat/kvm/x86/memory.c [deleted file]

index 4faa39ed3c5ab76574a1923e2e3c5158641bea88..0b8e933883b2998d8c0c6b1055bbab6a3b12b781 100644 (file)
@@ -326,3 +326,26 @@ int ukplat_memregion_list_coalesce(struct ukplat_memregion_list *list)
 
        return 0;
 }
+
+int ukplat_memregion_count(void)
+{
+       struct ukplat_bootinfo *bi = ukplat_bootinfo_get();
+
+       UK_ASSERT(bi);
+
+       return (int)bi->mrds.count;
+}
+
+int ukplat_memregion_get(int i, struct ukplat_memregion_desc **mrd)
+{
+       struct ukplat_bootinfo *bi = ukplat_bootinfo_get();
+
+       UK_ASSERT(bi);
+       UK_ASSERT(i >= 0);
+
+       if (unlikely((__u32)i >= bi->mrds.count))
+               return -1;
+
+       *mrd = &bi->mrds.mrds[i];
+       return 0;
+}
index 786a7e3f76dcb9f6a5ee0c21e633a7f79d9b41f3..dc357a0634fa377f5e1bb1682945460686fa201e 100644 (file)
@@ -77,7 +77,6 @@ LIBKVMPLAT_SRCS-$(CONFIG_ARCH_X86_64) += $(LIBKVMPLAT_BASE)/x86/lcpu_start.S
 LIBKVMPLAT_SRCS-$(CONFIG_ARCH_X86_64) += $(LIBKVMPLAT_BASE)/x86/intctrl.c
 LIBKVMPLAT_SRCS-$(CONFIG_ARCH_X86_64) += $(LIBKVMPLAT_BASE)/x86/tscclock.c
 LIBKVMPLAT_SRCS-$(CONFIG_ARCH_X86_64) += $(LIBKVMPLAT_BASE)/x86/time.c
-LIBKVMPLAT_SRCS-$(CONFIG_ARCH_X86_64) += $(LIBKVMPLAT_BASE)/x86/memory.c
 ifeq ($(findstring y,$(CONFIG_KVM_KERNEL_VGA_CONSOLE) $(CONFIG_KVM_DEBUG_VGA_CONSOLE)),y)
 LIBKVMPLAT_SRCS-$(CONFIG_ARCH_X86_64) += $(LIBKVMPLAT_BASE)/x86/vga_console.c
 endif
@@ -124,12 +123,13 @@ LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) += $(LIBKVMPLAT_BASE)/arm/lcpu.c
 LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) += $(LIBKVMPLAT_BASE)/arm/intctrl.c
 LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) += $(LIBKVMPLAT_BASE)/arm/memory.c
 
-LIBKVMPLAT_SRCS-y              += $(LIBKVMPLAT_BASE)/shutdown.c
-LIBKVMPLAT_SRCS-y              += $(LIBKVMPLAT_BASE)/irq.c
-LIBKVMPLAT_SRCS-y              += $(LIBKVMPLAT_BASE)/io.c
-LIBKVMPLAT_SRCS-y              += $(UK_PLAT_COMMON_BASE)/lcpu.c|common
-LIBKVMPLAT_SRCS-y              += $(UK_PLAT_COMMON_BASE)/memory.c|common
-LIBKVMPLAT_SRCS-y              += $(UK_PLAT_KVM_DEF_LDS)
+LIBKVMPLAT_SRCS-y                          += $(LIBKVMPLAT_BASE)/shutdown.c
+LIBKVMPLAT_SRCS-$(CONFIG_ARCH_X86_64)      += $(LIBKVMPLAT_BASE)/memory.c
+LIBKVMPLAT_SRCS-y                          += $(LIBKVMPLAT_BASE)/irq.c
+LIBKVMPLAT_SRCS-y                          += $(LIBKVMPLAT_BASE)/io.c
+LIBKVMPLAT_SRCS-y                          += $(UK_PLAT_COMMON_BASE)/lcpu.c|common
+LIBKVMPLAT_SRCS-y                          += $(UK_PLAT_COMMON_BASE)/memory.c|common
+LIBKVMPLAT_SRCS-y                          += $(UK_PLAT_KVM_DEF_LDS)
 
 ##
 ## PCI library definitions
diff --git a/plat/kvm/memory.c b/plat/kvm/memory.c
new file mode 100644 (file)
index 0000000..df0c91f
--- /dev/null
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/* Copyright (c) 2022, Unikraft GmbH and The Unikraft Authors.
+ * Licensed under the BSD-3-Clause License (the "License").
+ * You may not use this file except in compliance with the License.
+ */
+
+int _ukplat_mem_mappings_init(void)
+{
+       return 0;
+}
diff --git a/plat/kvm/x86/memory.c b/plat/kvm/x86/memory.c
deleted file mode 100644 (file)
index 794fc89..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause */
-/* Copyright (c) 2022, Unikraft GmbH and The Unikraft Authors.
- * Licensed under the BSD-3-Clause License (the "License").
- * You may not use this file except in compliance with the License.
- */
-
-#include <uk/plat/common/memory.h>
-#include <uk/plat/common/bootinfo.h>
-
-int ukplat_memregion_count(void)
-{
-       struct ukplat_bootinfo *bi = ukplat_bootinfo_get();
-
-       UK_ASSERT(bi);
-
-       return (int)bi->mrds.count;
-}
-
-int ukplat_memregion_get(int i, struct ukplat_memregion_desc **mrd)
-{
-       struct ukplat_bootinfo *bi = ukplat_bootinfo_get();
-
-       UK_ASSERT(bi);
-       UK_ASSERT(i >= 0);
-
-       if (unlikely((__u32)i >= bi->mrds.count))
-               return -1;
-
-       *mrd = &bi->mrds.mrds[i];
-       return 0;
-}
-
-int _ukplat_mem_mappings_init(void)
-{
-       return 0;
-}