machdep.c (31174518d2db4950b8bc8ab02e64cdb5e00d34c9) | machdep.c (5641eda2f3f9658de93ad3eefd27880778d49d65) |
---|---|
1/*- 2 * Copyright (c) 2014 Andrew Turner 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 950 unchanged lines hidden (view full) --- 959 960#ifdef FDT 961static void 962try_load_dtb(caddr_t kmdp) 963{ 964 vm_offset_t dtbp; 965 966 dtbp = MD_FETCH(kmdp, MODINFOMD_DTBP, vm_offset_t); | 1/*- 2 * Copyright (c) 2014 Andrew Turner 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 950 unchanged lines hidden (view full) --- 959 960#ifdef FDT 961static void 962try_load_dtb(caddr_t kmdp) 963{ 964 vm_offset_t dtbp; 965 966 dtbp = MD_FETCH(kmdp, MODINFOMD_DTBP, vm_offset_t); |
967#if defined(FDT_DTB_STATIC) 968 /* 969 * In case the device tree blob was not retrieved (from metadata) try 970 * to use the statically embedded one. 971 */ 972 if (dtbp == 0) 973 dtbp = (vm_offset_t)&fdt_static_dtb; 974#endif 975 |
|
967 if (dtbp == (vm_offset_t)NULL) { 968 printf("ERROR loading DTB\n"); 969 return; 970 } 971 972 if (OF_install(OFW_FDT, 0) == FALSE) 973 panic("Cannot install FDT"); 974 975 if (OF_init((void *)dtbp) != 0) 976 panic("OF_init failed with the found device tree"); | 976 if (dtbp == (vm_offset_t)NULL) { 977 printf("ERROR loading DTB\n"); 978 return; 979 } 980 981 if (OF_install(OFW_FDT, 0) == FALSE) 982 panic("Cannot install FDT"); 983 984 if (OF_init((void *)dtbp) != 0) 985 panic("OF_init failed with the found device tree"); |
986 987 parse_fdt_bootargs(); |
|
977} 978#endif 979 980static bool 981bus_probe(void) 982{ 983 bool has_acpi, has_fdt; 984 char *order, *env; --- 92 unchanged lines hidden (view full) --- 1077#ifdef FDT 1078 struct mem_region mem_regions[FDT_MEM_REGIONS]; 1079 int mem_regions_sz; 1080#endif 1081 vm_offset_t lastaddr; 1082 caddr_t kmdp; 1083 bool valid; 1084 | 988} 989#endif 990 991static bool 992bus_probe(void) 993{ 994 bool has_acpi, has_fdt; 995 char *order, *env; --- 92 unchanged lines hidden (view full) --- 1088#ifdef FDT 1089 struct mem_region mem_regions[FDT_MEM_REGIONS]; 1090 int mem_regions_sz; 1091#endif 1092 vm_offset_t lastaddr; 1093 caddr_t kmdp; 1094 bool valid; 1095 |
1085 /* Set the module data location */ 1086 preload_metadata = (caddr_t)(uintptr_t)(abp->modulep); | 1096 /* Parse loader or FDT boot parametes. Determine last used address. */ 1097 lastaddr = parse_boot_param(abp); |
1087 1088 /* Find the kernel address */ 1089 kmdp = preload_search_by_type("elf kernel"); 1090 if (kmdp == NULL) 1091 kmdp = preload_search_by_type("elf64 kernel"); 1092 | 1098 1099 /* Find the kernel address */ 1100 kmdp = preload_search_by_type("elf kernel"); 1101 if (kmdp == NULL) 1102 kmdp = preload_search_by_type("elf64 kernel"); 1103 |
1093 boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int); 1094 init_static_kenv(MD_FETCH(kmdp, MODINFOMD_ENVP, char *), 0); | |
1095 link_elf_ireloc(kmdp); | 1104 link_elf_ireloc(kmdp); |
1096 1097#ifdef FDT | |
1098 try_load_dtb(kmdp); | 1105 try_load_dtb(kmdp); |
1099#endif | |
1100 1101 efi_systbl_phys = MD_FETCH(kmdp, MODINFOMD_FW_HANDLE, vm_paddr_t); 1102 | 1106 1107 efi_systbl_phys = MD_FETCH(kmdp, MODINFOMD_FW_HANDLE, vm_paddr_t); 1108 |
1103 /* Find the address to start allocating from */ 1104 lastaddr = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t); 1105 | |
1106 /* Load the physical memory ranges */ 1107 efihdr = (struct efi_map_header *)preload_search_info(kmdp, 1108 MODINFO_METADATA | MODINFOMD_EFI_MAP); 1109 if (efihdr != NULL) 1110 add_efi_map_entries(efihdr); 1111#ifdef FDT 1112 else { 1113 /* Grab physical memory regions information from device tree. */ --- 186 unchanged lines hidden --- | 1109 /* Load the physical memory ranges */ 1110 efihdr = (struct efi_map_header *)preload_search_info(kmdp, 1111 MODINFO_METADATA | MODINFOMD_EFI_MAP); 1112 if (efihdr != NULL) 1113 add_efi_map_entries(efihdr); 1114#ifdef FDT 1115 else { 1116 /* Grab physical memory regions information from device tree. */ --- 186 unchanged lines hidden --- |