1185void __init early_init_dt_scan_nodes(void) 1186{ 1187 int rc = 0; 1188 1189 /* Retrieve various information from the /chosen node */ 1190 rc = of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line); 1191 if (!rc) 1192 pr_warn("No chosen node found, continuing without\n"); 1193 1194 /* Initialize {size,address}-cells info */ 1195 of_scan_flat_dt(early_init_dt_scan_root, NULL); 1196 1197 /* Setup memory, calling early_init_dt_add_memory_arch */ 1198 of_scan_flat_dt(early_init_dt_scan_memory, NULL); 1199}
1039int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, 1040 int depth, void *data) 1041{ 1042 int l; 1043 const char *p; 1044 const void *rng_seed; 1045 1046 pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname); 1047 1048 if (depth != 1 || !data || 1049 (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0)) 1050 return 0; 1051 1052 early_init_dt_check_for_initrd(node); 1053 1054 /* Retrieve command line */ 1055 p = of_get_flat_dt_prop(node, "bootargs", &l); 1056 if (p != NULL && l > 0) 1057 strlcpy(data, p, min(l, COMMAND_LINE_SIZE)); 1058 1059 /* 1060 * CONFIG_CMDLINE is meant to be a default in case nothing else 1061 * managed to set the command line, unless CONFIG_CMDLINE_FORCE 1062 * is set in which case we override whatever was found earlier. 1063 */ 1064#ifdef CONFIG_CMDLINE 1065#if defined(CONFIG_CMDLINE_EXTEND) 1066 strlcat(data, " ", COMMAND_LINE_SIZE); 1067 strlcat(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE); 1068#elif defined(CONFIG_CMDLINE_FORCE) 1069 strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE); 1070#else 1071 /* No arguments from boot loader, use kernel's cmdl*/ 1072 if (!((char *)data)[0]) 1073 strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE); 1074#endif 1075#endif /* CONFIG_CMDLINE */ 1076 1077 pr_debug("Command line is: %s\n", (char *)data); 1078 1079 rng_seed = of_get_flat_dt_prop(node, "rng-seed", &l); 1080 if (rng_seed && l > 0) { 1081 add_bootloader_randomness(rng_seed, l); 1082 1083 /* try to clear seed so it won't be found. */ 1084 fdt_nop_property(initial_boot_params, node, "rng-seed"); 1085 1086 /* update CRC check value */ 1087 of_fdt_crc32 = crc32_be(~0, initial_boot_params, 1088 fdt_totalsize(initial_boot_params)); 1089 } 1090 1091 /* break now */ 1092 return 1; 1093}1048 ~ 1050 如果不是 choose 节点,就 return .