svn commit: r257669 - in head/sys/arm: allwinner arm broadcom/bcm2835 freescale/imx include lpc mv rockchip samsung/exynos tegra ti versatile xilinx

Ian Lepore ian at FreeBSD.org
Tue Nov 5 02:57:37 UTC 2013


Author: ian
Date: Tue Nov  5 02:57:34 2013
New Revision: 257669
URL: http://svnweb.freebsd.org/changeset/base/257669

Log:
  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.
  
  Rename platform_devmap_init() to initarm_devmap_init() to match all the
  other init routines called from initarm() that are designed to be
  implemented by platform code.
  
  Add a comment block that explains when these routines are called and the
  type of work expected to be done in each of them.

Modified:
  head/sys/arm/allwinner/a10_machdep.c
  head/sys/arm/arm/machdep.c
  head/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
  head/sys/arm/freescale/imx/imx_machdep.c
  head/sys/arm/include/machdep.h
  head/sys/arm/lpc/lpc_machdep.c
  head/sys/arm/mv/mv_machdep.c
  head/sys/arm/rockchip/rk30xx_machdep.c
  head/sys/arm/samsung/exynos/exynos5_machdep.c
  head/sys/arm/tegra/tegra2_machdep.c
  head/sys/arm/ti/ti_machdep.c
  head/sys/arm/versatile/versatile_machdep.c
  head/sys/arm/xilinx/zy7_machdep.c

Modified: head/sys/arm/allwinner/a10_machdep.c
==============================================================================
--- head/sys/arm/allwinner/a10_machdep.c	Tue Nov  5 02:22:04 2013	(r257668)
+++ head/sys/arm/allwinner/a10_machdep.c	Tue Nov  5 02:57:34 2013	(r257669)
@@ -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: head/sys/arm/arm/machdep.c
==============================================================================
--- head/sys/arm/arm/machdep.c	Tue Nov  5 02:22:04 2013	(r257668)
+++ head/sys/arm/arm/machdep.c	Tue Nov  5 02:57:34 2013	(r257669)
@@ -1303,7 +1303,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();
 
@@ -1419,9 +1419,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: head/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
==============================================================================
--- head/sys/arm/broadcom/bcm2835/bcm2835_machdep.c	Tue Nov  5 02:22:04 2013	(r257668)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_machdep.c	Tue Nov  5 02:57:34 2013	(r257669)
@@ -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: head/sys/arm/freescale/imx/imx_machdep.c
==============================================================================
--- head/sys/arm/freescale/imx/imx_machdep.c	Tue Nov  5 02:22:04 2013	(r257668)
+++ head/sys/arm/freescale/imx/imx_machdep.c	Tue Nov  5 02:57:34 2013	(r257669)
@@ -88,31 +88,24 @@ vm_offset_t
 initarm_lastaddr(void)
 {
 
+	return (devmap_vaddr);
+}
+
+void
+initarm_early_init(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)
+initarm_devmap_init(void)
 {
 
-	/* On imx this work is done during initarm_lastaddr(). */
+	imx_devmap_init();
+	arm_devmap_register_table(devmap_entries);
 	return (0);
 }
 

Modified: head/sys/arm/include/machdep.h
==============================================================================
--- head/sys/arm/include/machdep.h	Tue Nov  5 02:22:04 2013	(r257668)
+++ head/sys/arm/include/machdep.h	Tue Nov  5 02:57:34 2013	(r257669)
@@ -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: head/sys/arm/lpc/lpc_machdep.c
==============================================================================
--- head/sys/arm/lpc/lpc_machdep.c	Tue Nov  5 02:22:04 2013	(r257668)
+++ head/sys/arm/lpc/lpc_machdep.c	Tue Nov  5 02:57:34 2013	(r257669)
@@ -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: head/sys/arm/mv/mv_machdep.c
==============================================================================
--- head/sys/arm/mv/mv_machdep.c	Tue Nov  5 02:22:04 2013	(r257668)
+++ head/sys/arm/mv/mv_machdep.c	Tue Nov  5 02:57:34 2013	(r257669)
@@ -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: head/sys/arm/rockchip/rk30xx_machdep.c
==============================================================================
--- head/sys/arm/rockchip/rk30xx_machdep.c	Tue Nov  5 02:22:04 2013	(r257668)
+++ head/sys/arm/rockchip/rk30xx_machdep.c	Tue Nov  5 02:57:34 2013	(r257669)
@@ -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: head/sys/arm/samsung/exynos/exynos5_machdep.c
==============================================================================
--- head/sys/arm/samsung/exynos/exynos5_machdep.c	Tue Nov  5 02:22:04 2013	(r257668)
+++ head/sys/arm/samsung/exynos/exynos5_machdep.c	Tue Nov  5 02:57:34 2013	(r257669)
@@ -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: head/sys/arm/tegra/tegra2_machdep.c
==============================================================================
--- head/sys/arm/tegra/tegra2_machdep.c	Tue Nov  5 02:22:04 2013	(r257668)
+++ head/sys/arm/tegra/tegra2_machdep.c	Tue Nov  5 02:57:34 2013	(r257669)
@@ -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: head/sys/arm/ti/ti_machdep.c
==============================================================================
--- head/sys/arm/ti/ti_machdep.c	Tue Nov  5 02:22:04 2013	(r257668)
+++ head/sys/arm/ti/ti_machdep.c	Tue Nov  5 02:57:34 2013	(r257669)
@@ -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: head/sys/arm/versatile/versatile_machdep.c
==============================================================================
--- head/sys/arm/versatile/versatile_machdep.c	Tue Nov  5 02:22:04 2013	(r257668)
+++ head/sys/arm/versatile/versatile_machdep.c	Tue Nov  5 02:57:34 2013	(r257669)
@@ -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: head/sys/arm/xilinx/zy7_machdep.c
==============================================================================
--- head/sys/arm/xilinx/zy7_machdep.c	Tue Nov  5 02:22:04 2013	(r257668)
+++ head/sys/arm/xilinx/zy7_machdep.c	Tue Nov  5 02:57:34 2013	(r257669)
@@ -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;
 


More information about the svn-src-head mailing list