xref: /linux/arch/um/kernel/dtb.c (revision 221a819a)
1b31297f0SVincent Whitchurch // SPDX-License-Identifier: GPL-2.0-only
2b31297f0SVincent Whitchurch 
3b31297f0SVincent Whitchurch #include <linux/init.h>
4b31297f0SVincent Whitchurch #include <linux/of_fdt.h>
5b31297f0SVincent Whitchurch #include <linux/printk.h>
6b31297f0SVincent Whitchurch #include <linux/memblock.h>
7b31297f0SVincent Whitchurch #include <init.h>
8b31297f0SVincent Whitchurch 
9b31297f0SVincent Whitchurch #include "um_arch.h"
10b31297f0SVincent Whitchurch 
11b31297f0SVincent Whitchurch static char *dtb __initdata;
12b31297f0SVincent Whitchurch 
uml_dtb_init(void)13b31297f0SVincent Whitchurch void uml_dtb_init(void)
14b31297f0SVincent Whitchurch {
15b31297f0SVincent Whitchurch 	long long size;
16b31297f0SVincent Whitchurch 	void *area;
17b31297f0SVincent Whitchurch 
18b31297f0SVincent Whitchurch 	area = uml_load_file(dtb, &size);
19*221a819aSStephen Boyd 	if (area) {
20b31297f0SVincent Whitchurch 		if (!early_init_dt_scan(area)) {
21b31297f0SVincent Whitchurch 			pr_err("invalid DTB %s\n", dtb);
22b31297f0SVincent Whitchurch 			memblock_free(area, size);
23b31297f0SVincent Whitchurch 			return;
24b31297f0SVincent Whitchurch 		}
25b31297f0SVincent Whitchurch 
26b31297f0SVincent Whitchurch 		early_init_fdt_scan_reserved_mem();
27*221a819aSStephen Boyd 	}
28*221a819aSStephen Boyd 
2939508aabSVincent Whitchurch 	unflatten_device_tree();
30b31297f0SVincent Whitchurch }
31b31297f0SVincent Whitchurch 
uml_dtb_setup(char * line,int * add)32b31297f0SVincent Whitchurch static int __init uml_dtb_setup(char *line, int *add)
33b31297f0SVincent Whitchurch {
34b31297f0SVincent Whitchurch 	dtb = line;
35b31297f0SVincent Whitchurch 	return 0;
36b31297f0SVincent Whitchurch }
37b31297f0SVincent Whitchurch 
38b31297f0SVincent Whitchurch __uml_setup("dtb=", uml_dtb_setup,
39b31297f0SVincent Whitchurch "dtb=<file>\n"
40b31297f0SVincent Whitchurch "    Boot the kernel with the devicetree blob from the specified file.\n"
41b31297f0SVincent Whitchurch );
42