Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146516808
D49700.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D49700.diff
View Options
diff --git a/sys/arm/arm/machdep.c b/sys/arm/arm/machdep.c
--- a/sys/arm/arm/machdep.c
+++ b/sys/arm/arm/machdep.c
@@ -415,14 +415,26 @@
}
#ifdef FDT
+static void
+fdt_physmem_hardware_region_cb(const struct mem_region *mr, void *arg __unused)
+{
+ physmem_hardware_region(mr->mr_start, mr->mr_size);
+}
+
+static void
+fdt_physmem_exclude_region_cb(const struct mem_region *mr, void *arg __unused)
+{
+ physmem_exclude_region(mr->mr_start, mr->mr_size,
+ EXFLAG_NODUMP | EXFLAG_NOALLOC);
+}
+
void *
initarm(struct arm_boot_params *abp)
{
- struct mem_region mem_regions[FDT_MEM_REGIONS];
vm_paddr_t lastaddr;
vm_offset_t dtbp, kernelstack, dpcpu;
char *env;
- int err_devmap, mem_regions_sz;
+ int err_devmap;
phandle_t root;
char dts_version[255];
#ifdef EFI
@@ -469,15 +481,13 @@
#endif
{
/* Grab physical memory regions information from device tree. */
- if (fdt_get_mem_regions(mem_regions, &mem_regions_sz,NULL) != 0)
+ if (fdt_foreach_mem_region(fdt_physmem_hardware_region_cb,
+ NULL) != 0)
panic("Cannot get physical memory regions");
- physmem_hardware_regions(mem_regions, mem_regions_sz);
-
/* Grab reserved memory regions information from device tree. */
- if (fdt_get_reserved_regions(mem_regions, &mem_regions_sz) == 0)
- physmem_exclude_regions(mem_regions, mem_regions_sz,
- EXFLAG_NODUMP | EXFLAG_NOALLOC);
+ fdt_foreach_reserved_region(fdt_physmem_exclude_region_cb,
+ NULL);
}
/*
diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -722,6 +722,21 @@
return (VM_MEMATTR_DEVICE);
}
+#ifdef FDT
+static void
+fdt_physmem_hardware_region_cb(const struct mem_region *mr, void *arg __unused)
+{
+ physmem_hardware_region(mr->mr_start, mr->mr_size);
+}
+
+static void
+fdt_physmem_exclude_region_cb(const struct mem_region *mr, void *arg __unused)
+{
+ physmem_exclude_region(mr->mr_start, mr->mr_size,
+ EXFLAG_NODUMP | EXFLAG_NOALLOC);
+}
+#endif
+
void
initarm(struct arm64_bootparams *abp)
{
@@ -729,8 +744,6 @@
struct pcpu *pcpup;
char *env;
#ifdef FDT
- struct mem_region mem_regions[FDT_MEM_REGIONS];
- int mem_regions_sz;
phandle_t root;
char dts_version[255];
#endif
@@ -781,14 +794,11 @@
#ifdef FDT
else {
/* Grab physical memory regions information from device tree. */
- if (fdt_get_mem_regions(mem_regions, &mem_regions_sz,
+ if (fdt_foreach_mem_region(fdt_physmem_hardware_region_cb,
NULL) != 0)
panic("Cannot get physical memory regions");
- physmem_hardware_regions(mem_regions, mem_regions_sz);
}
- if (fdt_get_reserved_mem(mem_regions, &mem_regions_sz) == 0)
- physmem_exclude_regions(mem_regions, mem_regions_sz,
- EXFLAG_NODUMP | EXFLAG_NOALLOC);
+ fdt_foreach_reserved_mem(fdt_physmem_exclude_region_cb, NULL);
#endif
/* Exclude the EFI framebuffer from our view of physical memory. */
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
@@ -506,13 +506,46 @@
return (lastaddr);
}
+#ifdef FDT
+static void
+fdt_physmem_hardware_region_cb(const struct mem_region *mr, void *arg)
+{
+ bool *first = arg;
+
+ physmem_hardware_region(mr->mr_start, mr->mr_size);
+
+ if (*first) {
+ /*
+ * 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(mr->mr_start, L2_SIZE,
+ EXFLAG_NODUMP | EXFLAG_NOALLOC);
+ *first = false;
+ }
+}
+
+static void
+fdt_physmem_exclude_region_cb(const struct mem_region *mr, void *arg __unused)
+{
+ physmem_exclude_region(mr->mr_start, mr->mr_size,
+ EXFLAG_NODUMP | EXFLAG_NOALLOC);
+}
+#endif
+
void
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;
vm_size_t kernlen;
char *env;
@@ -547,31 +580,17 @@
}
#ifdef FDT
else {
+ bool first;
+
/* 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);
- }
+ fdt_foreach_reserved_mem(fdt_physmem_exclude_region_cb, NULL);
/* Grab physical memory regions information from device tree. */
- if (fdt_get_mem_regions(mem_regions, &mem_regions_sz, NULL) != 0)
+ first = true;
+ if (fdt_foreach_mem_region(fdt_physmem_hardware_region_cb,
+ &first) != 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);
}
#endif
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 4, 7:46 AM (2 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29233765
Default Alt Text
D49700.diff (5 KB)
Attached To
Mode
D49700: sys: Use fdt_foreach on arm, arm64, and riscv
Attached
Detach File
Event Timeline
Log In to Comment