xref: /linux/arch/um/kernel/dtb.c (revision 831c1926ee728c3e747255f7c0f434762e8e863d)
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 
uml_dtb_init(void)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 		if (!early_init_dt_scan(area, __pa(area))) {
21 			pr_err("invalid DTB %s\n", dtb);
22 			memblock_free(area, size);
23 			return;
24 		}
25 
26 		early_init_fdt_scan_reserved_mem();
27 	}
28 
29 	unflatten_device_tree();
30 }
31 
uml_dtb_setup(char * line,int * add)32 static int __init uml_dtb_setup(char *line, int *add)
33 {
34 	*add = 0;
35 	dtb = line;
36 	return 0;
37 }
38 
39 __uml_setup("dtb=", uml_dtb_setup,
40 "dtb=<file>\n"
41 "    Boot the kernel with the devicetree blob from the specified file.\n"
42 );
43