Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 May 2018 16:03:41 +0000 (UTC)
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r334056 - head/sys/dev/fdt
Message-ID:  <201805221603.w4MG3fPd088222@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andrew
Date: Tue May 22 16:03:41 2018
New Revision: 334056
URL: https://svnweb.freebsd.org/changeset/base/334056

Log:
  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

Modified:
  head/sys/dev/fdt/fdt_common.c
  head/sys/dev/fdt/fdt_common.h

Modified: head/sys/dev/fdt/fdt_common.c
==============================================================================
--- head/sys/dev/fdt/fdt_common.c	Tue May 22 16:01:56 2018	(r334055)
+++ head/sys/dev/fdt/fdt_common.c	Tue May 22 16:03:41 2018	(r334056)
@@ -500,6 +500,47 @@ out:
 }
 
 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
 fdt_get_mem_regions(struct mem_region *mr, int *mrcnt, uint64_t *memsize)
 {
 	pcell_t reg[FDT_REG_CELLS * FDT_MEM_REGIONS];

Modified: head/sys/dev/fdt/fdt_common.h
==============================================================================
--- head/sys/dev/fdt/fdt_common.h	Tue May 22 16:01:56 2018	(r334055)
+++ head/sys/dev/fdt/fdt_common.h	Tue May 22 16:03:41 2018	(r334056)
@@ -85,6 +85,7 @@ int fdt_data_to_res(pcell_t *, int, int, u_long *, u_l
 phandle_t fdt_find_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_reserved_mem(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_range(phandle_t, int, u_long *, u_long *);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805221603.w4MG3fPd088222>