dtb.c 720 B

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