of.c 765 B

12345678910111213141516171819202122232425262728293031323334
  1. #include <linux/bootmem.h>
  2. #include <linux/init.h>
  3. #include <linux/io.h>
  4. #include <linux/of_fdt.h>
  5. #include <asm/byteorder.h>
  6. static int __init reserve_mem_mach(unsigned long addr, unsigned long size)
  7. {
  8. return reserve_bootmem(addr, size, BOOTMEM_DEFAULT);
  9. }
  10. void __init free_mem_mach(unsigned long addr, unsigned long size)
  11. {
  12. return free_bootmem(addr, size);
  13. }
  14. void __init device_tree_init(void)
  15. {
  16. unsigned long base, size;
  17. if (!initial_boot_params)
  18. return;
  19. base = virt_to_phys((void *)initial_boot_params);
  20. size = be32_to_cpu(initial_boot_params->totalsize);
  21. /* Before we do anything, lets reserve the dt blob */
  22. reserve_mem_mach(base, size);
  23. unflatten_device_tree();
  24. /* free the space reserved for the dt blob */
  25. free_mem_mach(base, size);
  26. }