summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2013-11-05 02:57:34 +0000
committerian <ian@FreeBSD.org>2013-11-05 02:57:34 +0000
commitb41cdbed2449cb7c863eb6c20c8081fc46e5415d (patch)
treec8199489e8d345aac66441bbe4373217ecb4dd06
parent3209347d81ca5822f60cb7e47498afb8373e582a (diff)
downloadFreeBSD-src-b41cdbed2449cb7c863eb6c20c8081fc46e5415d.zip
FreeBSD-src-b41cdbed2449cb7c863eb6c20c8081fc46e5415d.tar.gz
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.
-rw-r--r--sys/arm/allwinner/a10_machdep.c8
-rw-r--r--sys/arm/arm/machdep.c7
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_machdep.c8
-rw-r--r--sys/arm/freescale/imx/imx_machdep.c27
-rw-r--r--sys/arm/include/machdep.h32
-rw-r--r--sys/arm/lpc/lpc_machdep.c12
-rw-r--r--sys/arm/mv/mv_machdep.c12
-rw-r--r--sys/arm/rockchip/rk30xx_machdep.c8
-rw-r--r--sys/arm/samsung/exynos/exynos5_machdep.c8
-rw-r--r--sys/arm/tegra/tegra2_machdep.c11
-rw-r--r--sys/arm/ti/ti_machdep.c10
-rw-r--r--sys/arm/versatile/versatile_machdep.c8
-rw-r--r--sys/arm/xilinx/zy7_machdep.c8
13 files changed, 118 insertions, 41 deletions
diff --git a/sys/arm/allwinner/a10_machdep.c b/sys/arm/allwinner/a10_machdep.c
index e9f93e8..c77a2a5 100644
--- a/sys/arm/allwinner/a10_machdep.c
+++ b/sys/arm/allwinner/a10_machdep.c
@@ -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_devmap[FDT_DEVMAP_MAX] = {
* Construct pmap_devmap[] with DT-derived config data.
*/
int
-platform_devmap_init(void)
+initarm_devmap_init(void)
{
int i = 0;
diff --git a/sys/arm/arm/machdep.c b/sys/arm/arm/machdep.c
index ec6fa9c..c935a82 100644
--- a/sys/arm/arm/machdep.c
+++ b/sys/arm/arm/machdep.c
@@ -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;
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_machdep.c b/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
index dcf8178..a203e12 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
@@ -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_devmap[FDT_DEVMAP_MAX] = {
* Construct pmap_devmap[] with DT-derived config data.
*/
int
-platform_devmap_init(void)
+initarm_devmap_init(void)
{
int i = 0;
diff --git a/sys/arm/freescale/imx/imx_machdep.c b/sys/arm/freescale/imx/imx_machdep.c
index de0eb68..3f52206 100644
--- a/sys/arm/freescale/imx/imx_machdep.c
+++ b/sys/arm/freescale/imx/imx_machdep.c
@@ -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);
}
diff --git a/sys/arm/include/machdep.h b/sys/arm/include/machdep.h
index 08e9e21..46d7e66 100644
--- a/sys/arm/include/machdep.h
+++ b/sys/arm/include/machdep.h
@@ -33,11 +33,39 @@ vm_offset_t linux_parse_boot_param(struct arm_boot_params *abp);
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);
diff --git a/sys/arm/lpc/lpc_machdep.c b/sys/arm/lpc/lpc_machdep.c
index 576eda4..a900997 100644
--- a/sys/arm/lpc/lpc_machdep.c
+++ b/sys/arm/lpc/lpc_machdep.c
@@ -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_devmap[FDT_DEVMAP_MAX] = {
* Construct pmap_devmap[] with DT-derived config data.
*/
int
-platform_devmap_init(void)
+initarm_devmap_init(void)
{
/*
diff --git a/sys/arm/mv/mv_machdep.c b/sys/arm/mv/mv_machdep.c
index ace8dde..9758cfb 100644
--- a/sys/arm/mv/mv_machdep.c
+++ b/sys/arm/mv/mv_machdep.c
@@ -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_devmap, fdt_pci_devmap);
* 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;
diff --git a/sys/arm/rockchip/rk30xx_machdep.c b/sys/arm/rockchip/rk30xx_machdep.c
index e4eb162..daba99f 100644
--- a/sys/arm/rockchip/rk30xx_machdep.c
+++ b/sys/arm/rockchip/rk30xx_machdep.c
@@ -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_devmap[FDT_DEVMAP_MAX] = {
* Construct pmap_devmap[] with DT-derived config data.
*/
int
-platform_devmap_init(void)
+initarm_devmap_init(void)
{
int i = 0;
diff --git a/sys/arm/samsung/exynos/exynos5_machdep.c b/sys/arm/samsung/exynos/exynos5_machdep.c
index 1c5a879..742d63d 100644
--- a/sys/arm/samsung/exynos/exynos5_machdep.c
+++ b/sys/arm/samsung/exynos/exynos5_machdep.c
@@ -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_devmap[FDT_DEVMAP_MAX] = {
* Construct pmap_devmap[] with DT-derived config data.
*/
int
-platform_devmap_init(void)
+initarm_devmap_init(void)
{
int i;
diff --git a/sys/arm/tegra/tegra2_machdep.c b/sys/arm/tegra/tegra2_machdep.c
index 92ca04a..8904250 100644
--- a/sys/arm/tegra/tegra2_machdep.c
+++ b/sys/arm/tegra/tegra2_machdep.c
@@ -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_devmap[FDT_DEVMAP_MAX] = {
* 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;
diff --git a/sys/arm/ti/ti_machdep.c b/sys/arm/ti/ti_machdep.c
index 8a3184a..2f78a48 100644
--- a/sys/arm/ti/ti_machdep.c
+++ b/sys/arm/ti/ti_machdep.c
@@ -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_devmap[FDT_DEVMAP_MAX] = {
* Construct pmap_devmap[] with DT-derived config data.
*/
int
-platform_devmap_init(void)
+initarm_devmap_init(void)
{
int i = 0;
#if defined(SOC_OMAP4)
diff --git a/sys/arm/versatile/versatile_machdep.c b/sys/arm/versatile/versatile_machdep.c
index 08ce039..0be0ad5 100644
--- a/sys/arm/versatile/versatile_machdep.c
+++ b/sys/arm/versatile/versatile_machdep.c
@@ -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_devmap[FDT_DEVMAP_MAX] = {
* 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;
diff --git a/sys/arm/xilinx/zy7_machdep.c b/sys/arm/xilinx/zy7_machdep.c
index a2b01b5..8461fca 100644
--- a/sys/arm/xilinx/zy7_machdep.c
+++ b/sys/arm/xilinx/zy7_machdep.c
@@ -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_devmap[FDT_DEVMAP_SIZE];
* Construct pmap_devmap[] with DT-derived config data.
*/
int
-platform_devmap_init(void)
+initarm_devmap_init(void)
{
int i = 0;
OpenPOWER on IntegriCloud