Lean Sheng Tan has submitted this change. ( https://review.coreboot.org/c/coreboot/+/77970?usp=email )
(
10 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: treewide: Move device_tree to commonlib ......................................................................
treewide: Move device_tree to commonlib
Signed-off-by: Maximilian Brune maximilian.brune@9elements.com Change-Id: I990d74d9fff06b17ec8a6ee962955e4b0df8b907 Reviewed-on: https://review.coreboot.org/c/coreboot/+/77970 Reviewed-by: Julius Werner jwerner@chromium.org Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M payloads/libpayload/libc/Makefile.mk M src/commonlib/Makefile.mk R src/commonlib/device_tree.c R src/commonlib/include/commonlib/device_tree.h M src/include/fit.h M src/lib/Makefile.mk M src/mainboard/emulation/qemu-sbsa/cbmem.c M src/mainboard/emulation/qemu-sbsa/mainboard.c M src/mainboard/sifive/hifive-unleashed/fixup_fdt.c M src/mainboard/sifive/hifive-unmatched/fixup_fdt.c M tests/commonlib/Makefile.mk R tests/commonlib/device_tree-test.c M tests/lib/Makefile.mk 13 files changed, 26 insertions(+), 20 deletions(-)
Approvals: Julius Werner: Looks good to me, approved build bot (Jenkins): Verified
diff --git a/payloads/libpayload/libc/Makefile.mk b/payloads/libpayload/libc/Makefile.mk index 5a65565..3d070eb 100644 --- a/payloads/libpayload/libc/Makefile.mk +++ b/payloads/libpayload/libc/Makefile.mk @@ -49,6 +49,7 @@ libc-srcs += $(coreboottop)/src/commonlib/bsd/ipchksum.c libc-srcs += $(coreboottop)/src/commonlib/bsd/string.c ifeq ($(CONFIG_LP_GPL),y) +libc-srcs += $(coreboottop)/src/commonlib/device_tree.c libc-srcs += $(coreboottop)/src/commonlib/list.c endif endif diff --git a/src/commonlib/Makefile.mk b/src/commonlib/Makefile.mk index 00f3629..a274d5f 100644 --- a/src/commonlib/Makefile.mk +++ b/src/commonlib/Makefile.mk @@ -32,6 +32,9 @@ endif ramstage-$(CONFIG_PLATFORM_USES_FSP2_0) += fsp_relocate.c
+romstage-$(CONFIG_FLATTENED_DEVICE_TREE) += device_tree.c +ramstage-$(CONFIG_FLATTENED_DEVICE_TREE) += device_tree.c + bootblock-y += bsd/cbfs_private.c verstage-y += bsd/cbfs_private.c romstage-y += bsd/cbfs_private.c diff --git a/src/lib/device_tree.c b/src/commonlib/device_tree.c similarity index 99% rename from src/lib/device_tree.c rename to src/commonlib/device_tree.c index 5087d39..f70aaf7 100644 --- a/src/lib/device_tree.c +++ b/src/commonlib/device_tree.c @@ -2,12 +2,17 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */
#include <assert.h> -#include <console/console.h> +#include <commonlib/device_tree.h> #include <ctype.h> -#include <device_tree.h> #include <endian.h> #include <stdbool.h> #include <stdint.h> +#ifdef __COREBOOT__ +#include <console/console.h> +#else +#include <stdio.h> +#define printk(level, ...) printf(__VA_ARGS__) +#endif #include <stdio.h> #include <string.h> #include <stddef.h> diff --git a/src/include/device_tree.h b/src/commonlib/include/commonlib/device_tree.h similarity index 98% rename from src/include/device_tree.h rename to src/commonlib/include/commonlib/device_tree.h index bb522bf..be73357 100644 --- a/src/include/device_tree.h +++ b/src/commonlib/include/commonlib/device_tree.h @@ -1,8 +1,8 @@ /* Taken from depthcharge: src/base/device_tree.h */ /* SPDX-License-Identifier: GPL-2.0-or-later */
-#ifndef __DEVICE_TREE_H__ -#define __DEVICE_TREE_H__ +#ifndef __COMMONLIB_DEVICE_TREE_H__ +#define __COMMONLIB_DEVICE_TREE_H__
#include <stdbool.h> #include <stddef.h> @@ -229,4 +229,4 @@ */ struct device_tree_node *dt_init_reserved_memory_node(struct device_tree *tree);
-#endif /* __DEVICE_TREE_H__ */ +#endif /* __COMMONLIB_DEVICE_TREE_H__ */ diff --git a/src/include/fit.h b/src/include/fit.h index d587750..25f85ab 100644 --- a/src/include/fit.h +++ b/src/include/fit.h @@ -4,8 +4,8 @@ #ifndef __LIB_FIT_H__ #define __LIB_FIT_H__
+#include <commonlib/device_tree.h> #include <commonlib/list.h> -#include <device_tree.h> #include <program_loading.h> #include <stddef.h> #include <stdint.h> diff --git a/src/lib/Makefile.mk b/src/lib/Makefile.mk index 59e2116..56d8b1a 100644 --- a/src/lib/Makefile.mk +++ b/src/lib/Makefile.mk @@ -163,9 +163,6 @@ ramstage-$(CONFIG_PAYLOAD_FIT_SUPPORT) += fit.c ramstage-$(CONFIG_PAYLOAD_FIT_SUPPORT) += fit_payload.c
-romstage-$(CONFIG_FLATTENED_DEVICE_TREE) += device_tree.c -ramstage-$(CONFIG_FLATTENED_DEVICE_TREE) += device_tree.c - romstage-$(CONFIG_TIMER_QUEUE) += timer_queue.c ramstage-$(CONFIG_TIMER_QUEUE) += timer_queue.c
diff --git a/src/mainboard/emulation/qemu-sbsa/cbmem.c b/src/mainboard/emulation/qemu-sbsa/cbmem.c index ebc8a78..d6d5861 100644 --- a/src/mainboard/emulation/qemu-sbsa/cbmem.c +++ b/src/mainboard/emulation/qemu-sbsa/cbmem.c @@ -2,7 +2,7 @@
#include <cbmem.h> #include <symbols.h> -#include <device_tree.h> +#include <commonlib/device_tree.h> #include <console/console.h>
DECLARE_REGION(fdt_pointer) diff --git a/src/mainboard/emulation/qemu-sbsa/mainboard.c b/src/mainboard/emulation/qemu-sbsa/mainboard.c index 112e118..9d64b73 100644 --- a/src/mainboard/emulation/qemu-sbsa/mainboard.c +++ b/src/mainboard/emulation/qemu-sbsa/mainboard.c @@ -6,7 +6,7 @@ #include <bootmem.h> #include <cbfs.h> #include <device/device.h> -#include <device_tree.h> +#include <commonlib/device_tree.h> #include <bootmem.h> #include <arch/mmu.h> #include <mainboard/addressmap.h> diff --git a/src/mainboard/sifive/hifive-unleashed/fixup_fdt.c b/src/mainboard/sifive/hifive-unleashed/fixup_fdt.c index dda71b6..c4999a5 100644 --- a/src/mainboard/sifive/hifive-unleashed/fixup_fdt.c +++ b/src/mainboard/sifive/hifive-unleashed/fixup_fdt.c @@ -7,7 +7,7 @@ #include <soc/otp.h> #include <soc/sdram.h> #include <cbfs.h> -#include <device_tree.h> +#include <commonlib/device_tree.h> #include <bootstate.h> #include <mcall.h>
diff --git a/src/mainboard/sifive/hifive-unmatched/fixup_fdt.c b/src/mainboard/sifive/hifive-unmatched/fixup_fdt.c index ed24ee3..766258a 100644 --- a/src/mainboard/sifive/hifive-unmatched/fixup_fdt.c +++ b/src/mainboard/sifive/hifive-unmatched/fixup_fdt.c @@ -7,7 +7,7 @@ #include <soc/otp.h> #include <soc/sdram.h> #include <cbfs.h> -#include <device_tree.h> +#include <commonlib/device_tree.h> #include <bootstate.h> #include <mcall.h>
diff --git a/tests/commonlib/Makefile.mk b/tests/commonlib/Makefile.mk index 55c3ddd..e593b14 100644 --- a/tests/commonlib/Makefile.mk +++ b/tests/commonlib/Makefile.mk @@ -5,6 +5,12 @@ tests-y += list-test tests-y += rational-test tests-y += region-test +tests-y += device_tree-test + +device_tree-test-srcs += tests/commonlib/device_tree-test.c +device_tree-test-srcs += tests/stubs/console.c +device_tree-test-srcs += src/commonlib/device_tree.c +device_tree-test-syssrcs += tests/helpers/file.c
list-test-srcs += tests/commonlib/list-test.c list-test-srcs += src/commonlib/list.c diff --git a/tests/lib/device_tree-test.c b/tests/commonlib/device_tree-test.c similarity index 98% rename from tests/lib/device_tree-test.c rename to tests/commonlib/device_tree-test.c index 21f81c6..0c1e2dd 100644 --- a/tests/lib/device_tree-test.c +++ b/tests/commonlib/device_tree-test.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */
+#include <commonlib/device_tree.h> #include <console/console.h> -#include <device_tree.h> #include <helpers/file.h> #include <stddef.h> #include <stdint.h> diff --git a/tests/lib/Makefile.mk b/tests/lib/Makefile.mk index 2090ef8..7fc5471 100644 --- a/tests/lib/Makefile.mk +++ b/tests/lib/Makefile.mk @@ -39,15 +39,9 @@ tests-y += cbfs-lookup-has-mcache-test tests-y += lzma-test tests-y += ux_locales-test -tests-y += device_tree-test
lib-test-srcs += tests/lib/lib-test.c
-device_tree-test-srcs += tests/lib/device_tree-test.c -device_tree-test-srcs += tests/stubs/console.c -device_tree-test-srcs += src/lib/device_tree.c -device_tree-test-syssrcs += tests/helpers/file.c - string-test-srcs += tests/lib/string-test.c string-test-srcs += src/lib/string.c