Page MenuHomeFreeBSD

D49131.diff
No OneTemporary

D49131.diff

diff --git a/sys/conf/files.riscv b/sys/conf/files.riscv
--- a/sys/conf/files.riscv
+++ b/sys/conf/files.riscv
@@ -30,6 +30,7 @@
kern/pic_if.m standard
kern/subr_devmap.c standard
kern/subr_dummy_vdso_tc.c standard
+kern/subr_efi_map.c standard
kern/subr_intr.c standard
kern/subr_physmem.c standard
libkern/bcopy.c standard
diff --git a/sys/riscv/riscv/machdep.c b/sys/riscv/riscv/machdep.c
--- a/sys/riscv/riscv/machdep.c
+++ b/sys/riscv/riscv/machdep.c
@@ -45,6 +45,7 @@
#include <sys/cons.h>
#include <sys/cpu.h>
#include <sys/devmap.h>
+#include <sys/efi_map.h>
#include <sys/exec.h>
#include <sys/imgact.h>
#include <sys/kdb.h>
@@ -468,6 +469,7 @@
initriscv(struct riscv_bootparams *rvbp)
{
struct mem_region mem_regions[FDT_MEM_REGIONS];
+ struct efi_map_header *efihdr;
struct pcpu *pcpup;
int mem_regions_sz;
vm_offset_t lastaddr;
@@ -516,21 +518,40 @@
}
pcpup->pc_hart = boot_hart;
-#ifdef FDT
- /*
- * Exclude reserved memory specified by the device tree. Typically,
- * this contains an entry for memory used by the runtime SBI firmware.
- */
- if (fdt_get_reserved_mem(mem_regions, &mem_regions_sz) == 0) {
- physmem_exclude_regions(mem_regions, mem_regions_sz,
- EXFLAG_NODUMP | EXFLAG_NOALLOC);
+ efihdr = (struct efi_map_header *)preload_search_info(preload_kmdp,
+ MODINFO_METADATA | MODINFOMD_EFI_MAP);
+ if (efihdr != NULL) {
+ efi_map_add_entries(efihdr);
+ efi_map_exclude_entries(efihdr);
}
+#ifdef FDT
+ else {
+ /* Exclude reserved memory specified by the device tree. */
+ if (fdt_get_reserved_mem(mem_regions, &mem_regions_sz) == 0) {
+ physmem_exclude_regions(mem_regions, mem_regions_sz,
+ EXFLAG_NODUMP | EXFLAG_NOALLOC);
+ }
- /* Grab physical memory regions information from device tree. */
- if (fdt_get_mem_regions(mem_regions, &mem_regions_sz, NULL) != 0) {
- panic("Cannot get physical memory regions");
+ /* Grab physical memory regions information from device tree. */
+ if (fdt_get_mem_regions(mem_regions, &mem_regions_sz, NULL) != 0)
+ panic("Cannot get physical memory regions");
+ physmem_hardware_regions(mem_regions, mem_regions_sz);
+
+ /*
+ * XXX: Unconditionally exclude the lowest 2MB of physical
+ * memory, as this area is assumed to contain the SBI firmware,
+ * and this is not properly reserved in all cases (e.g. in
+ * older firmware like BBL).
+ *
+ * This is a little fragile, but it is consistent with the
+ * platforms we support so far.
+ *
+ * TODO: remove this when the all regular booting methods
+ * properly report their reserved memory in the device tree.
+ */
+ physmem_exclude_region(mem_regions[0].mr_start, L2_SIZE,
+ EXFLAG_NODUMP | EXFLAG_NOALLOC);
}
- physmem_hardware_regions(mem_regions, mem_regions_sz);
#endif
/*
@@ -541,19 +562,6 @@
/* Do basic tuning, hz etc */
init_param1();
-#ifdef FDT
- /*
- * XXX: Unconditionally exclude the lowest 2MB of physical memory, as
- * this area is assumed to contain the SBI firmware. This is a little
- * fragile, but it is consistent with the platforms we support so far.
- *
- * TODO: remove this when the all regular booting methods properly
- * report their reserved memory in the device tree.
- */
- physmem_exclude_region(mem_regions[0].mr_start, L2_SIZE,
- EXFLAG_NODUMP | EXFLAG_NOALLOC);
-#endif
-
/* Bootstrap enough of pmap to enter the kernel proper */
kernlen = (lastaddr - KERNBASE);
pmap_bootstrap(rvbp->kern_phys, kernlen);
@@ -588,8 +596,11 @@
if (env != NULL)
strlcpy(kernelname, env, sizeof(kernelname));
- if (boothowto & RB_VERBOSE)
+ if (boothowto & RB_VERBOSE) {
+ if (efihdr != NULL)
+ efi_map_print_entries(efihdr);
physmem_print_tables();
+ }
early_boot = 0;

File Metadata

Mime Type
text/plain
Expires
Fri, Apr 10, 1:10 AM (9 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31184815
Default Alt Text
D49131.diff (3 KB)

Event Timeline