+
+ /*
+ * Display header info
+ */
+ } else if (argv[1][0] == 'h') {
+ u32 version = fdt_version(working_fdt);
+ printf("magic:\t\t\t0x%x\n", fdt_magic(working_fdt));
+ printf("totalsize:\t\t0x%x (%d)\n", fdt_totalsize(working_fdt),
+ fdt_totalsize(working_fdt));
+ printf("off_dt_struct:\t\t0x%x\n",
+ fdt_off_dt_struct(working_fdt));
+ printf("off_dt_strings:\t\t0x%x\n",
+ fdt_off_dt_strings(working_fdt));
+ printf("off_mem_rsvmap:\t\t0x%x\n",
+ fdt_off_mem_rsvmap(working_fdt));
+ printf("version:\t\t%d\n", version);
+ printf("last_comp_version:\t%d\n",
+ fdt_last_comp_version(working_fdt));
+ if (version >= 2)
+ printf("boot_cpuid_phys:\t0x%x\n",
+ fdt_boot_cpuid_phys(working_fdt));
+ if (version >= 3)
+ printf("size_dt_strings:\t0x%x\n",
+ fdt_size_dt_strings(working_fdt));
+ if (version >= 17)
+ printf("size_dt_struct:\t\t0x%x\n",
+ fdt_size_dt_struct(working_fdt));
+ printf("number mem_rsv:\t\t0x%x\n",
+ fdt_num_mem_rsv(working_fdt));
+ printf("\n");
+
+ /*
+ * Set boot cpu id
+ */
+ } else if (strncmp(argv[1], "boo", 3) == 0) {
+ unsigned long tmp = simple_strtoul(argv[2], NULL, 16);
+ fdt_set_boot_cpuid_phys(working_fdt, tmp);
+
+ /*
+ * memory command
+ */
+ } else if (strncmp(argv[1], "me", 2) == 0) {
+ uint64_t addr, size;
+ int err;
+ addr = simple_strtoull(argv[2], NULL, 16);
+ size = simple_strtoull(argv[3], NULL, 16);
+ err = fdt_fixup_memory(working_fdt, addr, size);
+ if (err < 0)
+ return err;
+
+ /*
+ * mem reserve commands
+ */
+ } else if (strncmp(argv[1], "rs", 2) == 0) {
+ if (argv[2][0] == 'p') {
+ uint64_t addr, size;
+ int total = fdt_num_mem_rsv(working_fdt);
+ int j, err;
+ printf("index\t\t start\t\t size\n");
+ printf("-------------------------------"
+ "-----------------\n");
+ for (j = 0; j < total; j++) {
+ err = fdt_get_mem_rsv(working_fdt, j, &addr, &size);
+ if (err < 0) {
+ printf("libfdt fdt_get_mem_rsv(): %s\n",
+ fdt_strerror(err));
+ return err;
+ }
+ printf(" %x\t%08x%08x\t%08x%08x\n", j,
+ (u32)(addr >> 32),
+ (u32)(addr & 0xffffffff),
+ (u32)(size >> 32),
+ (u32)(size & 0xffffffff));
+ }
+ } else if (argv[2][0] == 'a') {
+ uint64_t addr, size;
+ int err;
+ addr = simple_strtoull(argv[3], NULL, 16);
+ size = simple_strtoull(argv[4], NULL, 16);
+ err = fdt_add_mem_rsv(working_fdt, addr, size);
+
+ if (err < 0) {
+ printf("libfdt fdt_add_mem_rsv(): %s\n",
+ fdt_strerror(err));
+ return err;
+ }
+ } else if (argv[2][0] == 'd') {
+ unsigned long idx = simple_strtoul(argv[3], NULL, 16);
+ int err = fdt_del_mem_rsv(working_fdt, idx);
+
+ if (err < 0) {
+ printf("libfdt fdt_del_mem_rsv(): %s\n",
+ fdt_strerror(err));
+ return err;
+ }
+ } else {
+ /* Unrecognized command */
+ return CMD_RET_USAGE;
+ }