struct machine_desc * __init setup_machine_tags(phys_addr_t __atags_pointer, unsigned int machine_nr) { struct tag *tags = (struct tag *)&default_tags; struct machine_desc *mdesc = NULL, *p; char *from = default_command_line; default_tags.mem.start = PHYS_OFFSET; /* * locate machine in the list of supported machines. */ for_each_machine_desc(p) if (machine_nr == p->nr) { printk("Machine: %s\n", p->name); mdesc = p; break; } if (!mdesc) { early_print("\nError: unrecognized/unsupported machine ID" " (r1 = 0x%08x).\n\n", machine_nr); dump_machine_table(); /* does not return */ } if (__atags_pointer) tags = phys_to_virt(__atags_pointer); else if (mdesc->atag_offset) tags = (void *)(PAGE_OFFSET + mdesc->atag_offset); #if defined(CONFIG_DEPRECATED_PARAM_STRUCT) /* * If we have the old style parameters, convert them to * a tag list. */ if (tags->hdr.tag != ATAG_CORE) convert_to_tag_list(tags); #endif if (tags->hdr.tag != ATAG_CORE) { early_print("Warning: Neither atags nor dtb found\n"); tags = (struct tag *)&default_tags; } if (mdesc->fixup) mdesc->fixup(tags, &from, &meminfo); if (tags->hdr.tag == ATAG_CORE) { if (meminfo.nr_banks != 0) squash_mem_tags(tags); save_atags(tags); parse_tags(tags); } /* parse_early_param needs a boot_command_line */ strlcpy(boot_command_line, from, COMMAND_LINE_SIZE); return mdesc; }
/** * setup_machine_fdt - Machine setup when an dtb was passed to the kernel * @dt_phys: physical address of dt blob * * If a dtb was passed to the kernel in r2, then use it to choose the * correct machine_desc and to setup the system. */ struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) { struct boot_param_header *devtree; struct machine_desc *mdesc, *mdesc_best = NULL; unsigned int score, mdesc_score = ~1; unsigned long dt_root; const char *model; devtree = phys_to_virt(dt_phys); /* check device tree validity */ if (be32_to_cpu(devtree->magic) != OF_DT_HEADER) return NULL; /* Search the mdescs for the 'best' compatible value match */ initial_boot_params = devtree; dt_root = of_get_flat_dt_root(); for_each_machine_desc(mdesc) { score = of_flat_dt_match(dt_root, mdesc->dt_compat); if (score > 0 && score < mdesc_score) { mdesc_best = mdesc; mdesc_score = score; } } if (!mdesc_best) { const char *prop; long size; early_print("\nError: unrecognized/unsupported " "device tree compatible list:\n[ "); prop = of_get_flat_dt_prop(dt_root, "compatible", &size); while (size > 0) { early_print("'%s' ", prop); size -= strlen(prop) + 1; prop += strlen(prop) + 1; } early_print("]\n\n"); dump_machine_table(); /* does not return */ } model = of_get_flat_dt_prop(dt_root, "model", NULL); if (!model) model = of_get_flat_dt_prop(dt_root, "compatible", NULL); if (!model) model = "<unknown>"; pr_info("Machine: %s, model: %s\n", mdesc_best->name, model); /* Retrieve various information from the /chosen node */ of_scan_flat_dt(early_init_dt_scan_chosen, NULL); /* Initialize {size,address}-cells info */ of_scan_flat_dt(early_init_dt_scan_root, NULL); /* Setup memory, calling early_init_dt_add_memory_arch */ of_scan_flat_dt(early_init_dt_scan_memory, NULL); /* Save command line for /proc/cmdline */ strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE); /* Change machine number to match the mdesc we're using */ __machine_arch_type = mdesc_best->nr; return mdesc_best; }
struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) { struct boot_param_header *devtree; struct machine_desc *mdesc, *mdesc_best = NULL; unsigned int score, mdesc_score = ~1; unsigned long dt_root; const char *model; printk("kinson:[%s]-[%d] dt_phys:0x%08x\n",__FUNCTION__,__LINE__,dt_phys); if (!dt_phys) return NULL; debug_step_dt=1; devtree = phys_to_virt(dt_phys); printk("kinson:[%s]-[%d] devtree:0x%08x devtree->magic:0x%x 0x%x 0x%x 0x%x\n",__FUNCTION__,__LINE__,devtree,be32_to_cpu(devtree->magic),devtree->totalsize, devtree->off_dt_struct,devtree->off_dt_strings); /* check device tree validity */ if (be32_to_cpu(devtree->magic) != OF_DT_HEADER) { printk("kinson:[%s]-[%d] devtree->magic error!\n",__FUNCTION__,__LINE__); return NULL; } /* Search the mdescs for the 'best' compatible value match */ initial_boot_params = devtree; dt_root = of_get_flat_dt_root(); for_each_machine_desc(mdesc) { #if 0 score = of_flat_dt_match(dt_root, mdesc->dt_compat); if (score > 0 && score < mdesc_score) { mdesc_best = mdesc; mdesc_score = score; } #else //kinson mdesc_best = mdesc; #endif } debug_step_dt=2; if (!mdesc_best) { const char *prop; long size; early_print("\nError: unrecognized/unsupported " "device tree compatible list:\n[ "); debug_step_dt=3; prop = of_get_flat_dt_prop(dt_root, "compatible", &size); while (size > 0) { early_print("'%s' ", prop); size -= strlen(prop) + 1; prop += strlen(prop) + 1; } early_print("]\n\n"); debug_step_dt=4; dump_machine_table(); /* does not return */ } debug_step_dt=7; model = of_get_flat_dt_prop(dt_root, "model", NULL); if (!model) model = of_get_flat_dt_prop(dt_root, "compatible", NULL); if (!model) model = "<unknown>"; pr_info("Machine: %s, model: %s\n", mdesc_best->name, model); debug_step_dt=8; /* Retrieve various information from the /chosen node */ of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line); /* Initialize {size,address}-cells info */ debug_step_dt=9; of_scan_flat_dt(early_init_dt_scan_root, NULL); debug_step_dt=10; /* Setup memory, calling early_init_dt_add_memory_arch */ of_scan_flat_dt(early_init_dt_scan_memory, NULL); debug_step_dt=11; /* Change machine number to match the mdesc we're using */ __machine_arch_type = mdesc_best->nr; return mdesc_best; }