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