Commit 1442afc1 authored by Andrew Turner's avatar Andrew Turner
Browse files

Handle reserved memory with the no-map property.

We shouldn't be mapping this memory, so we need to find it so it
can be excluded from the phys_avail map.

Reviewed by:	manu
Obtained from:	ABT Systems Ltd
Sponsored by:	Turing Robotic Industries
Differential Revision:	https://reviews.freebsd.org/D15518
parent 9f78e2b8
...@@ -499,6 +499,47 @@ fdt_get_reserved_regions(struct mem_region *mr, int *mrcnt) ...@@ -499,6 +499,47 @@ fdt_get_reserved_regions(struct mem_region *mr, int *mrcnt)
return (rv); return (rv);
} }
int
fdt_get_reserved_mem(struct mem_region *reserved, int *mreserved)
{
pcell_t reg[FDT_REG_CELLS];
phandle_t child, root;
int addr_cells, size_cells;
int i, rv;
root = OF_finddevice("/reserved-memory");
if (root == -1) {
return (ENXIO);
}
if ((rv = fdt_addrsize_cells(root, &addr_cells, &size_cells)) != 0)
return (rv);
if (addr_cells + size_cells > FDT_REG_CELLS)
panic("Too many address and size cells %d %d", addr_cells,
size_cells);
i = 0;
for (child = OF_child(root); child != 0; child = OF_peer(child)) {
if (!OF_hasprop(child, "no-map"))
continue;
rv = OF_getprop(child, "reg", reg, sizeof(reg));
if (rv <= 0)
/* XXX: Does a no-map of a dynamic range make sense? */
continue;
fdt_data_to_res(reg, addr_cells, size_cells,
(u_long *)&reserved[i].mr_start,
(u_long *)&reserved[i].mr_size);
i++;
}
*mreserved = i;
return (0);
}
int int
fdt_get_mem_regions(struct mem_region *mr, int *mrcnt, uint64_t *memsize) fdt_get_mem_regions(struct mem_region *mr, int *mrcnt, uint64_t *memsize)
{ {
......
...@@ -85,6 +85,7 @@ int fdt_data_to_res(pcell_t *, int, int, u_long *, u_long *); ...@@ -85,6 +85,7 @@ int fdt_data_to_res(pcell_t *, int, int, u_long *, u_long *);
phandle_t fdt_find_compatible(phandle_t, const char *, int); phandle_t fdt_find_compatible(phandle_t, const char *, int);
phandle_t fdt_depth_search_compatible(phandle_t, const char *, int); phandle_t fdt_depth_search_compatible(phandle_t, const char *, int);
int fdt_get_mem_regions(struct mem_region *, int *, uint64_t *); int fdt_get_mem_regions(struct mem_region *, int *, uint64_t *);
int fdt_get_reserved_mem(struct mem_region *, int *);
int fdt_get_reserved_regions(struct mem_region *, int *); int fdt_get_reserved_regions(struct mem_region *, int *);
int fdt_get_phyaddr(phandle_t, device_t, int *, void **); int fdt_get_phyaddr(phandle_t, device_t, int *, void **);
int fdt_get_range(phandle_t, int, u_long *, u_long *); int fdt_get_range(phandle_t, int, u_long *, u_long *);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment