Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Dec 2013 00:16:09 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r259365 - in stable/10/sys/arm: allwinner arm broadcom/bcm2835 freescale/imx include lpc mv rockchip samsung/exynos tegra ti versatile xilinx
Message-ID:  <201312140016.rBE0G9ql095137@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Sat Dec 14 00:16:08 2013
New Revision: 259365
URL: http://svnweb.freebsd.org/changeset/base/259365

Log:
  MFC r257669, r257672, r257673, r257676, r257678:
  
    Call initarm_lastaddr() later in the init sequence, after establishing
    static device mappings, rather than as the first of the initializations
    that a platform can hook into.  This allows a platform to allocate KVA
    from the top of the address space downwards for things like static device
    mapping, and return the final "last usable address" result after that and
    other early init work is done.
  
    Because some platforms were doing work in initarm_lastaddr() that needs to
    be done early, add a new initarm_early_init() routine and move the early
    init code to that routine on those platforms.
  
    Make PTE_DEVICE a synonym for PTE_NOCACHE on armv4, to make it easier to
    share the same code on both architectures.
  
    Add new helper routines for arm static device mapping.  The new code
    allocates kva space from the top down for the device mappings and builds
    entries in an internal table which is automatically used later by
    arm_devmap_bootstrap().  The platform code just calls the new
    arm_devmap_add_entry() function as many times as it needs to (up to 32
    entries allowed; most platforms use 2 or 3 at most).
  
    Remove imx local devmap code and use the essentially identical common
    code that got moved from imx_machdep.c to arm/devmap.c.

Modified:
  stable/10/sys/arm/allwinner/a10_machdep.c
  stable/10/sys/arm/arm/devmap.c
  stable/10/sys/arm/arm/machdep.c
  stable/10/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
  stable/10/sys/arm/freescale/imx/imx51_machdep.c
  stable/10/sys/arm/freescale/imx/imx53_machdep.c
  stable/10/sys/arm/freescale/imx/imx6_machdep.c
  stable/10/sys/arm/freescale/imx/imx_machdep.c
  stable/10/sys/arm/include/devmap.h
  stable/10/sys/arm/include/machdep.h
  stable/10/sys/arm/include/pmap.h
  stable/10/sys/arm/lpc/lpc_machdep.c
  stable/10/sys/arm/mv/mv_machdep.c
  stable/10/sys/arm/rockchip/rk30xx_machdep.c
  stable/10/sys/arm/samsung/exynos/exynos5_machdep.c
  stable/10/sys/arm/tegra/tegra2_machdep.c
  stable/10/sys/arm/ti/ti_machdep.c
  stable/10/sys/arm/versatile/versatile_machdep.c
  stable/10/sys/arm/xilinx/zy7_machdep.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/arm/allwinner/a10_machdep.c
==============================================================================
--- stable/10/sys/arm/allwinner/a10_machdep.c	Fri Dec 13 23:56:53 2013	(r259364)
+++ stable/10/sys/arm/allwinner/a10_machdep.c	Sat Dec 14 00:16:08 2013	(r259365)
@@ -62,6 +62,12 @@ initarm_lastaddr(void)
 }
 
 void
+initarm_early_init(void)
+{
+
+}
+
+void
 initarm_gpio_init(void)
 {
 }
@@ -80,7 +86,7 @@ static struct arm_devmap_entry fdt_devma
  * Construct pmap_devmap[] with DT-derived config data.
  */
 int
-platform_devmap_init(void)
+initarm_devmap_init(void)
 {
 	int i = 0;
 

Modified: stable/10/sys/arm/arm/devmap.c
==============================================================================
--- stable/10/sys/arm/arm/devmap.c	Fri Dec 13 23:56:53 2013	(r259364)
+++ stable/10/sys/arm/arm/devmap.c	Sat Dec 14 00:16:08 2013	(r259365)
@@ -36,9 +36,89 @@ __FBSDID("$FreeBSD$");
 #include <vm/vm.h>
 #include <vm/vm_extern.h>
 #include <vm/pmap.h>
+#include <machine/armreg.h>
 #include <machine/devmap.h>
 
 static const struct arm_devmap_entry *devmap_table;
+static boolean_t devmap_bootstrap_done = false;
+
+/*
+ * The allocated-kva (akva) devmap table and metadata.  Platforms can call
+ * arm_devmap_add_entry() to add static device mappings to this table using
+ * automatically allocated virtual addresses carved out of the top of kva space.
+ * Allocation begins immediately below the ARM_VECTORS_HIGH address.
+ */
+#define	AKVA_DEVMAP_MAX_ENTRIES	32
+static struct arm_devmap_entry	akva_devmap_entries[AKVA_DEVMAP_MAX_ENTRIES];
+static u_int			akva_devmap_idx;
+static vm_offset_t		akva_devmap_vaddr = ARM_VECTORS_HIGH;
+
+/*
+ * Return the "last" kva address used by the registered devmap table.  It's
+ * actually the lowest address used by the static mappings, i.e., the address of
+ * the first unusable byte of KVA.
+ */
+vm_offset_t
+arm_devmap_lastaddr()
+{
+	const struct arm_devmap_entry *pd;
+	vm_offset_t lowaddr;
+
+	if (akva_devmap_idx > 0)
+		return (akva_devmap_vaddr);
+
+	if (devmap_table == NULL)
+		panic("arm_devmap_lastaddr(): No devmap table registered.");
+
+	lowaddr = ARM_VECTORS_HIGH;
+	for (pd = devmap_table; pd->pd_size != 0; ++pd) {
+		if (lowaddr > pd->pd_va)
+			lowaddr = pd->pd_va;
+	}
+
+	return (lowaddr);
+}
+
+/*
+ * Add an entry to the internal "akva" static devmap table using the given
+ * physical address and size and a virtual address allocated from the top of
+ * kva.  This automatically registers the akva table on the first call, so all a
+ * platform has to do is call this routine to install as many mappings as it
+ * needs and when initarm() calls arm_devmap_bootstrap() it will pick up all the
+ * entries in the akva table automatically.
+ */
+void
+arm_devmap_add_entry(vm_paddr_t pa, vm_size_t sz)
+{
+	struct arm_devmap_entry *m;
+
+	if (devmap_bootstrap_done)
+		panic("arm_devmap_add_entry() after arm_devmap_bootstrap()");
+
+	if (akva_devmap_idx == (AKVA_DEVMAP_MAX_ENTRIES - 1))
+		panic("AKVA_DEVMAP_MAX_ENTRIES is too small");
+
+	if (akva_devmap_idx == 0)
+		arm_devmap_register_table(akva_devmap_entries);
+
+	/*
+	 * Allocate virtual address space from the top of kva downwards.  If the
+	 * range being mapped is aligned and sized to 1MB boundaries then also
+	 * align the virtual address to the next-lower 1MB boundary so that we
+	 * end up with a nice efficient section mapping.
+	 */
+	if ((pa & 0x000fffff) == 0 && (sz & 0x000fffff) == 0) {
+		akva_devmap_vaddr = trunc_1mpage(akva_devmap_vaddr - sz);
+	} else {
+		akva_devmap_vaddr = trunc_page(akva_devmap_vaddr - sz);
+	}
+	m = &akva_devmap_entries[akva_devmap_idx++];
+	m->pd_va    = akva_devmap_vaddr;
+	m->pd_pa    = pa;
+	m->pd_size  = sz;
+	m->pd_prot  = VM_PROT_READ | VM_PROT_WRITE;
+	m->pd_cache = PTE_DEVICE;
+}
 
 /*
  * Register the given table as the one to use in arm_devmap_bootstrap().
@@ -73,12 +153,14 @@ arm_devmap_bootstrap(vm_offset_t l1pt, c
 	if (table != NULL)
 		devmap_table = table;
 	else if (devmap_table == NULL)
-		panic("arm_devmap_bootstrap: No devmap table registered.");
+		panic("arm_devmap_bootstrap(): No devmap table registered");
 
 	for (pd = devmap_table; pd->pd_size != 0; ++pd) {
 		pmap_map_chunk(l1pt, pd->pd_va, pd->pd_pa, pd->pd_size,
 		    pd->pd_prot,pd->pd_cache);
 	}
+
+	devmap_bootstrap_done = true;
 }
 
 /*

Modified: stable/10/sys/arm/arm/machdep.c
==============================================================================
--- stable/10/sys/arm/arm/machdep.c	Fri Dec 13 23:56:53 2013	(r259364)
+++ stable/10/sys/arm/arm/machdep.c	Sat Dec 14 00:16:08 2013	(r259365)
@@ -1299,7 +1299,7 @@ initarm(struct arm_boot_params *abp)
 	availmem_regions_sz = curr;
 
 	/* Platform-specific initialisation */
-	vm_max_kernel_address = initarm_lastaddr();
+	initarm_early_init();
 
 	pcpu0_init();
 
@@ -1415,9 +1415,10 @@ initarm(struct arm_boot_params *abp)
 	pmap_map_entry(l1pagetable, ARM_VECTORS_HIGH, systempage.pv_pa,
 	    VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE, PTE_CACHE);
 
-	/* Map pmap_devmap[] entries */
-	err_devmap = platform_devmap_init();
+	/* Establish static device mappings. */
+	err_devmap = initarm_devmap_init();
 	arm_devmap_bootstrap(l1pagetable, NULL);
+	vm_max_kernel_address = initarm_lastaddr();
 
 	cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL * 2)) | DOMAIN_CLIENT);
 	pmap_pa = kernel_l1pt.pv_pa;

Modified: stable/10/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
==============================================================================
--- stable/10/sys/arm/broadcom/bcm2835/bcm2835_machdep.c	Fri Dec 13 23:56:53 2013	(r259364)
+++ stable/10/sys/arm/broadcom/bcm2835/bcm2835_machdep.c	Sat Dec 14 00:16:08 2013	(r259365)
@@ -70,6 +70,12 @@ initarm_lastaddr(void)
 }
 
 void
+initarm_early_init(void)
+{
+
+}
+
+void
 initarm_gpio_init(void)
 {
 }
@@ -103,7 +109,7 @@ static struct arm_devmap_entry fdt_devma
  * Construct pmap_devmap[] with DT-derived config data.
  */
 int
-platform_devmap_init(void)
+initarm_devmap_init(void)
 {
 	int i = 0;
 

Modified: stable/10/sys/arm/freescale/imx/imx51_machdep.c
==============================================================================
--- stable/10/sys/arm/freescale/imx/imx51_machdep.c	Fri Dec 13 23:56:53 2013	(r259364)
+++ stable/10/sys/arm/freescale/imx/imx51_machdep.c	Sat Dec 14 00:16:08 2013	(r259365)
@@ -34,26 +34,58 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <sys/reboot.h>
 
+#include <vm/vm.h>
+
+#include <machine/bus.h>
+#include <machine/devmap.h>
 #include <machine/machdep.h>
+
 #include <arm/freescale/imx/imx_machdep.h>
 
+vm_offset_t
+initarm_lastaddr(void)
+{
+
+	return (arm_devmap_lastaddr());
+}
+
+void
+initarm_early_init(void)
+{
+
+	/* XXX - Get rid of this stuff soon. */
+	boothowto |= RB_VERBOSE|RB_MULTIPLE;
+	bootverbose = 1;
+}
+
+void
+initarm_gpio_init(void)
+{
+
+}
+
+void
+initarm_late_init(void)
+{
+
+}
+
 /*
  * Set up static device mappings.  This is hand-optimized platform-specific
  * config data which covers most of the common on-chip devices with a few 1MB
  * section mappings.
  *
  * Notably missing are entries for GPU, IPU, in general anything video related.
- *
- * Note that for imx this is called from initarm_lastaddr() so that the lowest
- * kva address used for static device mapping can be known at that point.
  */
-void
-imx_devmap_init(void)
+int
+initarm_devmap_init(void)
 {
 
-	imx_devmap_addentry(0x70000000, 0x00100000);
-	imx_devmap_addentry(0x73f00000, 0x00100000);
-	imx_devmap_addentry(0x83f00000, 0x00100000);
+	arm_devmap_add_entry(0x70000000, 0x00100000);
+	arm_devmap_add_entry(0x73f00000, 0x00100000);
+	arm_devmap_add_entry(0x83f00000, 0x00100000);
+
+	return (0);
 }
 
 void

Modified: stable/10/sys/arm/freescale/imx/imx53_machdep.c
==============================================================================
--- stable/10/sys/arm/freescale/imx/imx53_machdep.c	Fri Dec 13 23:56:53 2013	(r259364)
+++ stable/10/sys/arm/freescale/imx/imx53_machdep.c	Sat Dec 14 00:16:08 2013	(r259365)
@@ -34,26 +34,57 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <sys/reboot.h>
 
+#include <vm/vm.h>
+
+#include <machine/bus.h>
+#include <machine/devmap.h>
 #include <machine/machdep.h>
 #include <arm/freescale/imx/imx_machdep.h>
 
+vm_offset_t
+initarm_lastaddr(void)
+{
+
+	return (arm_devmap_lastaddr());
+}
+
+void
+initarm_early_init(void)
+{
+
+	/* XXX - Get rid of this stuff soon. */
+	boothowto |= RB_VERBOSE|RB_MULTIPLE;
+	bootverbose = 1;
+}
+
+void
+initarm_gpio_init(void)
+{
+
+}
+
+void
+initarm_late_init(void)
+{
+
+}
+
 /*
  * Set up static device mappings.  This is hand-optimized platform-specific
  * config data which covers most of the common on-chip devices with a few 1MB
  * section mappings.
  *
  * Notably missing are entries for GPU, IPU, in general anything video related.
- *
- * Note that for imx this is called from initarm_lastaddr() so that the lowest
- * kva address used for static device mapping can be known at that point.
  */
-void
-imx_devmap_init(void)
+int
+initarm_devmap_init(void)
 {
 
-	imx_devmap_addentry(0x50000000, 0x00100000);
-	imx_devmap_addentry(0x53f00000, 0x00100000);
-	imx_devmap_addentry(0x63f00000, 0x00100000);
+	arm_devmap_add_entry(0x50000000, 0x00100000);
+	arm_devmap_add_entry(0x53f00000, 0x00100000);
+	arm_devmap_add_entry(0x63f00000, 0x00100000);
+
+	return (0);
 }
 
 void

Modified: stable/10/sys/arm/freescale/imx/imx6_machdep.c
==============================================================================
--- stable/10/sys/arm/freescale/imx/imx6_machdep.c	Fri Dec 13 23:56:53 2013	(r259364)
+++ stable/10/sys/arm/freescale/imx/imx6_machdep.c	Sat Dec 14 00:16:08 2013	(r259365)
@@ -35,19 +35,45 @@ __FBSDID("$FreeBSD$");
 #include <sys/reboot.h>
 
 #include <vm/vm.h>
-#include <vm/pmap.h>
 
 #include <machine/bus.h>
 #include <machine/devmap.h>
+#include <machine/machdep.h>
 
 #include <arm/freescale/imx/imx6_anatopreg.h>
 #include <arm/freescale/imx/imx6_anatopvar.h>
 #include <arm/freescale/imx/imx_machdep.h>
 
+vm_offset_t
+initarm_lastaddr(void)
+{
+
+	return (arm_devmap_lastaddr());
+}
+
+void
+initarm_early_init(void)
+{
+
+	/* XXX - Get rid of this stuff soon. */
+	boothowto |= RB_VERBOSE|RB_MULTIPLE;
+	bootverbose = 1;
+}
+
+void
+initarm_gpio_init(void)
+{
+
+}
+
+void
+initarm_late_init(void)
+{
+
+}
+
 /*
- * Set up static device mappings.  Note that for imx this is called from
- * initarm_lastaddr() so that it can return the lowest address used for static
- * device mapping, maximizing kva space.
+ * Set up static device mappings.
  *
  * This attempts to cover the most-used devices with 1MB section mappings, which
  * is good for performance (uses fewer TLB entries for device access).
@@ -62,8 +88,8 @@ __FBSDID("$FreeBSD$");
  * static map some of that area.  Be careful with other things in that area such
  * as OCRAM that probably shouldn't be mapped as PTE_DEVICE memory.
  */
-void
-imx_devmap_init(void)
+int
+initarm_devmap_init(void)
 {
 	const uint32_t IMX6_ARMMP_PHYS = 0x00a00000;
 	const uint32_t IMX6_ARMMP_SIZE = 0x00100000;
@@ -72,9 +98,11 @@ imx_devmap_init(void)
 	const uint32_t IMX6_AIPS2_PHYS = 0x02100000;
 	const uint32_t IMX6_AIPS2_SIZE = 0x00100000;
 
-	imx_devmap_addentry(IMX6_ARMMP_PHYS, IMX6_ARMMP_SIZE);
-	imx_devmap_addentry(IMX6_AIPS1_PHYS, IMX6_AIPS1_SIZE);
-	imx_devmap_addentry(IMX6_AIPS2_PHYS, IMX6_AIPS2_SIZE);
+	arm_devmap_add_entry(IMX6_ARMMP_PHYS, IMX6_ARMMP_SIZE);
+	arm_devmap_add_entry(IMX6_AIPS1_PHYS, IMX6_AIPS1_SIZE);
+	arm_devmap_add_entry(IMX6_AIPS2_PHYS, IMX6_AIPS2_SIZE);
+
+	return (0);
 }
 
 void

Modified: stable/10/sys/arm/freescale/imx/imx_machdep.c
==============================================================================
--- stable/10/sys/arm/freescale/imx/imx_machdep.c	Fri Dec 13 23:56:53 2013	(r259364)
+++ stable/10/sys/arm/freescale/imx/imx_machdep.c	Sat Dec 14 00:16:08 2013	(r259365)
@@ -45,106 +45,6 @@ __FBSDID("$FreeBSD$");
 #include <arm/freescale/imx/imx_machdep.h>
 #include <arm/freescale/imx/imx_wdogreg.h>
 
-#define	IMX_MAX_DEVMAP_ENTRIES	8
-
-static struct arm_devmap_entry devmap_entries[IMX_MAX_DEVMAP_ENTRIES];
-static u_int		  devmap_idx;
-static vm_offset_t	  devmap_vaddr = ARM_VECTORS_HIGH;
-
-void
-imx_devmap_addentry(vm_paddr_t pa, vm_size_t sz) 
-{
-	struct arm_devmap_entry *m;
-
-	/*
-	 * The last table entry is the all-zeroes end-of-table marker.  If we're
-	 * about to overwrite it the world is coming to an end.  This code runs
-	 * too early for the panic to be printed unless a special early-debug
-	 * console is in use, but there's nothing else we can do.
-	 */
-	if (devmap_idx == (IMX_MAX_DEVMAP_ENTRIES - 1))
-		panic("IMX_MAX_DEVMAP_ENTRIES is too small!\n");
-
-	/*
-	 * Allocate virtual address space from the top of kva downwards.  If the
-	 * range being mapped is aligned and sized to 1MB boundaries then also
-	 * align the virtual address to the next-lower 1MB boundary so that we
-	 * end up with a section mapping.
-	 */
-	if ((pa & 0x000fffff) == 0 && (sz & 0x000fffff) == 0) {
-		devmap_vaddr = (devmap_vaddr - sz) & ~0x000fffff;
-	} else {
-		devmap_vaddr = (devmap_vaddr - sz) & ~0x00000fff;
-	}
-	m = &devmap_entries[devmap_idx++];
-	m->pd_va    = devmap_vaddr;
-	m->pd_pa    = pa;
-	m->pd_size  = sz;
-	m->pd_prot  = VM_PROT_READ | VM_PROT_WRITE;
-	m->pd_cache = PTE_DEVICE;
-}
-
-vm_offset_t
-initarm_lastaddr(void)
-{
-
-	/* XXX - Get rid of this stuff soon. */
-	boothowto |= RB_VERBOSE|RB_MULTIPLE;
-	bootverbose = 1;
-
-	/*
-	 * Normally initarm() calls platform_devmap_init() much later in the
-	 * init process to set up static device mappings.  To calculate the
-	 * highest available kva address we have to do that setup first.  It
-	 * maps downwards from ARM_VECTORS_HIGH and the last usable kva address
-	 * is the point right before the virtual address of the first static
-	 * mapping.  So go set up the static mapping table now, then we can
-	 * return the lowest static devmap vaddr as the end of usable kva.
-	 */
-	imx_devmap_init();
-
-	arm_devmap_register_table(devmap_entries);
-
-	return (devmap_vaddr);
-}
-
-int
-platform_devmap_init(void)
-{
-
-	/* On imx this work is done during initarm_lastaddr(). */
-	return (0);
-}
-
-/*
- * Set initial values of GPIO output ports
- */
-void
-initarm_gpio_init(void)
-{
-
-}
-
-void
-initarm_late_init(void)
-{
-	struct arm_devmap_entry *m;
-
-	/*
-	 * We did the static devmap setup earlier, during initarm_lastaddr(),
-	 * but now the console should be working and we can be verbose about
-	 * what we did.
-	 */
-	if (bootverbose) {
-		for (m = devmap_entries; m->pd_va != 0; ++m) {
-			printf("Devmap: phys 0x%08x virt 0x%08x size %uK\n",
-			    m->pd_pa, m->pd_va, m->pd_size / 1024);
-		}
-	}
-
-
-}
-
 struct arm32_dma_range *
 bus_dma_get_range(void)
 {

Modified: stable/10/sys/arm/include/devmap.h
==============================================================================
--- stable/10/sys/arm/include/devmap.h	Fri Dec 13 23:56:53 2013	(r259364)
+++ stable/10/sys/arm/include/devmap.h	Sat Dec 14 00:16:08 2013	(r259365)
@@ -42,6 +42,22 @@ struct arm_devmap_entry {
 };
 
 /*
+ * Return the lowest KVA address used in any entry in the registered devmap
+ * table.  This works with whatever table is registered, including the internal
+ * table used by arm_devmap_add_entry() if that routine was used. Platforms can
+ * implement initarm_lastaddr() by calling this if static device mappings are
+ * their only use of high KVA space.
+ */
+vm_offset_t arm_devmap_lastaddr(void);
+
+/*
+ * Automatically allocate KVA (from the top of the address space downwards) and
+ * make static device mapping entries in an internal table.  The internal table
+ * is automatically registered on the first call to this.
+ */
+void arm_devmap_add_entry(vm_paddr_t pa, vm_size_t sz);
+
+/*
  * Register a platform-local table to be bootstrapped by the generic
  * initarm() in arm/machdep.c.  This is used by newer code that allocates and
  * fills in its own local table but does not have its own initarm() routine.
@@ -49,16 +65,17 @@ struct arm_devmap_entry {
 void arm_devmap_register_table(const struct arm_devmap_entry * _table);
 
 /*
- * Directly process a table; called from initarm() of older platforms that don't
- * use the generic initarm() in arm/machdep.c.  If the table pointer is NULL,
- * this will use the table installed previously by arm_devmap_register_table().
+ * Establish mappings for all the entries in the table.  This is called
+ * automatically from the common initarm() in arm/machdep.c, and also from the
+ * custom initarm() routines in older code.  If the table pointer is NULL, this
+ * will use the table installed previously by arm_devmap_register_table().
  */
 void arm_devmap_bootstrap(vm_offset_t _l1pt, 
     const struct arm_devmap_entry *_table);
 
 /*
- * Routines to translate between virtual and physical addresses within a region
- * that is static-mapped by the devmap code.  If the given address range isn't
+ * Translate between virtual and physical addresses within a region that is
+ * static-mapped by the devmap code.  If the given address range isn't
  * static-mapped, then ptov returns NULL and vtop returns DEVMAP_PADDR_NOTFOUND.
  * The latter implies that you can't vtop just the last byte of physical address
  * space.  This is not as limiting as it might sound, because even if a device

Modified: stable/10/sys/arm/include/machdep.h
==============================================================================
--- stable/10/sys/arm/include/machdep.h	Fri Dec 13 23:56:53 2013	(r259364)
+++ stable/10/sys/arm/include/machdep.h	Sat Dec 14 00:16:08 2013	(r259365)
@@ -33,11 +33,39 @@ vm_offset_t linux_parse_boot_param(struc
 vm_offset_t fake_preload_metadata(struct arm_boot_params *abp);
 vm_offset_t parse_boot_param(struct arm_boot_params *abp);
 
-/* Called by initarm */
+/*
+ * Initialization functions called by the common initarm() function in
+ * arm/machdep.c (but not necessarily from the custom initarm() functions of
+ * older code).
+ *
+ *  - initarm_early_init() is called very early, after parsing the boot params
+ *    and after physical memory has been located and sized.
+ *
+ *  - platform_devmap_init() is called as one of the last steps of early virtual
+ *    memory initialization, shortly before the new page tables are installed.
+ *
+ *  - initarm_lastaddr() is called after platform_devmap_init(), and must return
+ *    the address of the first byte of unusable KVA space.  This allows a
+ *    platform to carve out of the top of the KVA space whatever reserves it
+ *    needs for things like static device mapping, and this is called to get the
+ *    value before calling pmap_bootstrap() which uses the value to size the
+ *    available KVA.
+ *
+ *  - initarm_gpio_init() is called after the static device mappings are
+ *    established and just before cninit().  The intention is that the routine
+ *    can do any hardware setup (such as gpio or pinmux) necessary to make the
+ *    console functional.
+ *
+ *  - initarm_late_init() is called just after cninit().  This is the first of
+ *    the init routines that can use printf() and expect the output to appear on
+ *    a standard console.
+ *
+ */
+void initarm_early_init(void);
+int initarm_devmap_init(void);
 vm_offset_t initarm_lastaddr(void);
 void initarm_gpio_init(void);
 void initarm_late_init(void);
-int platform_devmap_init(void);
 
 /* Board-specific attributes */
 void board_set_serial(uint64_t);

Modified: stable/10/sys/arm/include/pmap.h
==============================================================================
--- stable/10/sys/arm/include/pmap.h	Fri Dec 13 23:56:53 2013	(r259364)
+++ stable/10/sys/arm/include/pmap.h	Sat Dec 14 00:16:08 2013	(r259365)
@@ -67,6 +67,7 @@
 #else
 #define PTE_NOCACHE	1
 #define PTE_CACHE	2
+#define PTE_DEVICE	PTE_NOCACHE
 #define PTE_PAGETABLE	3
 #endif
 

Modified: stable/10/sys/arm/lpc/lpc_machdep.c
==============================================================================
--- stable/10/sys/arm/lpc/lpc_machdep.c	Fri Dec 13 23:56:53 2013	(r259364)
+++ stable/10/sys/arm/lpc/lpc_machdep.c	Sat Dec 14 00:16:08 2013	(r259365)
@@ -63,11 +63,15 @@ vm_offset_t
 initarm_lastaddr(void)
 {
 
+	return (fdt_immr_va);
+}
+
+void
+initarm_early_init(void)
+{
+
 	if (fdt_immr_addr(LPC_DEV_BASE) != 0)
 		while (1);
-
-	/* Platform-specific initialisation */
-	return (fdt_immr_va);
 }
 
 void
@@ -94,7 +98,7 @@ static struct arm_devmap_entry fdt_devma
  * Construct pmap_devmap[] with DT-derived config data.
  */
 int
-platform_devmap_init(void)
+initarm_devmap_init(void)
 {
 
 	/*

Modified: stable/10/sys/arm/mv/mv_machdep.c
==============================================================================
--- stable/10/sys/arm/mv/mv_machdep.c	Fri Dec 13 23:56:53 2013	(r259364)
+++ stable/10/sys/arm/mv/mv_machdep.c	Sat Dec 14 00:16:08 2013	(r259365)
@@ -203,11 +203,15 @@ vm_offset_t
 initarm_lastaddr(void)
 {
 
+	return (fdt_immr_va);
+}
+
+void
+initarm_early_init(void)
+{
+
 	if (fdt_immr_addr(MV_BASE) != 0)
 		while (1);
-
-	/* Platform-specific initialisation */
-	return (fdt_immr_va);
 }
 
 void
@@ -316,7 +320,7 @@ __weak_reference(mv_default_fdt_pci_devm
  * Construct pmap_devmap[] with DT-derived config data.
  */
 int
-platform_devmap_init(void)
+initarm_devmap_init(void)
 {
 	phandle_t root, child;
 	pcell_t bank_count;

Modified: stable/10/sys/arm/rockchip/rk30xx_machdep.c
==============================================================================
--- stable/10/sys/arm/rockchip/rk30xx_machdep.c	Fri Dec 13 23:56:53 2013	(r259364)
+++ stable/10/sys/arm/rockchip/rk30xx_machdep.c	Sat Dec 14 00:16:08 2013	(r259365)
@@ -60,6 +60,12 @@ initarm_lastaddr(void)
 }
 
 void
+initarm_early_init(void)
+{
+
+}
+
+void
 initarm_gpio_init(void)
 {
 }
@@ -82,7 +88,7 @@ static struct arm_devmap_entry fdt_devma
  * Construct pmap_devmap[] with DT-derived config data.
  */
 int
-platform_devmap_init(void)
+initarm_devmap_init(void)
 {
 	int i = 0;
 

Modified: stable/10/sys/arm/samsung/exynos/exynos5_machdep.c
==============================================================================
--- stable/10/sys/arm/samsung/exynos/exynos5_machdep.c	Fri Dec 13 23:56:53 2013	(r259364)
+++ stable/10/sys/arm/samsung/exynos/exynos5_machdep.c	Sat Dec 14 00:16:08 2013	(r259365)
@@ -54,6 +54,12 @@ initarm_lastaddr(void)
 }
 
 void
+initarm_early_init(void)
+{
+
+}
+
+void
 initarm_gpio_init(void)
 {
 }
@@ -72,7 +78,7 @@ static struct arm_devmap_entry fdt_devma
  * Construct pmap_devmap[] with DT-derived config data.
  */
 int
-platform_devmap_init(void)
+initarm_devmap_init(void)
 {
 	int i;
 

Modified: stable/10/sys/arm/tegra/tegra2_machdep.c
==============================================================================
--- stable/10/sys/arm/tegra/tegra2_machdep.c	Fri Dec 13 23:56:53 2013	(r259364)
+++ stable/10/sys/arm/tegra/tegra2_machdep.c	Sat Dec 14 00:16:08 2013	(r259365)
@@ -107,10 +107,15 @@ vm_offset_t
 initarm_lastaddr(void)
 {
 
+	return (fdt_immr_va);
+}
+
+void
+initarm_early_init(void)
+{
+
 	if (fdt_immr_addr(TEGRA2_BASE) != 0)				/* FIXME ???? */
 		while (1);
-
-	return (fdt_immr_va);
 }
 
 void
@@ -132,7 +137,7 @@ static struct arm_devmap_entry fdt_devma
  * Construct pmap_devmap[] with DT-derived config data.
  */
 int
-platform_devmap_init(void)
+initarm_devmap_init(void)
 {
 	int i = 0;
 	fdt_devmap[i].pd_va = 0xe0000000;

Modified: stable/10/sys/arm/ti/ti_machdep.c
==============================================================================
--- stable/10/sys/arm/ti/ti_machdep.c	Fri Dec 13 23:56:53 2013	(r259364)
+++ stable/10/sys/arm/ti/ti_machdep.c	Sat Dec 14 00:16:08 2013	(r259365)
@@ -63,11 +63,17 @@ vm_offset_t
 initarm_lastaddr(void)
 {
 
-	ti_cpu_reset = NULL;
 	return (DEVMAP_BOOTSTRAP_MAP_START);
 }
 
 void
+initarm_early_init(void)
+{
+
+	ti_cpu_reset = NULL;
+}
+
+void
 initarm_gpio_init(void)
 {
 }
@@ -87,7 +93,7 @@ static struct arm_devmap_entry fdt_devma
  * Construct pmap_devmap[] with DT-derived config data.
  */
 int
-platform_devmap_init(void)
+initarm_devmap_init(void)
 {
 	int i = 0;
 #if defined(SOC_OMAP4)

Modified: stable/10/sys/arm/versatile/versatile_machdep.c
==============================================================================
--- stable/10/sys/arm/versatile/versatile_machdep.c	Fri Dec 13 23:56:53 2013	(r259364)
+++ stable/10/sys/arm/versatile/versatile_machdep.c	Sat Dec 14 00:16:08 2013	(r259365)
@@ -65,6 +65,12 @@ initarm_lastaddr(void)
 }
 
 void
+initarm_early_init(void)
+{
+
+}
+
+void
 initarm_gpio_init(void)
 {
 }
@@ -85,7 +91,7 @@ static struct arm_devmap_entry fdt_devma
  * Construct pmap_devmap[] with DT-derived config data.
  */
 int
-platform_devmap_init(void)
+initarm_devmap_init(void)
 {
 	int i = 0;
 	fdt_devmap[i].pd_va = 0xf0100000;

Modified: stable/10/sys/arm/xilinx/zy7_machdep.c
==============================================================================
--- stable/10/sys/arm/xilinx/zy7_machdep.c	Fri Dec 13 23:56:53 2013	(r259364)
+++ stable/10/sys/arm/xilinx/zy7_machdep.c	Sat Dec 14 00:16:08 2013	(r259365)
@@ -64,6 +64,12 @@ initarm_lastaddr(void)
 }
 
 void
+initarm_early_init(void)
+{
+
+}
+
+void
 initarm_gpio_init(void)
 {
 }
@@ -80,7 +86,7 @@ static struct arm_devmap_entry fdt_devma
  * Construct pmap_devmap[] with DT-derived config data.
  */
 int
-platform_devmap_init(void)
+initarm_devmap_init(void)
 {
 	int i = 0;
 



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