summaryrefslogtreecommitdiffstats
path: root/sys/arm/include
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2013-12-14 00:16:08 +0000
committerian <ian@FreeBSD.org>2013-12-14 00:16:08 +0000
commitf1d49f684de2d9eaa8fc5074d87fb2767fc56741 (patch)
tree3c0e8ffd313e6a983ce387f815a5a22f8f6a07d3 /sys/arm/include
parenteae48ec05ef90176b68b7b5c7ebf3e4c792448aa (diff)
downloadFreeBSD-src-f1d49f684de2d9eaa8fc5074d87fb2767fc56741.zip
FreeBSD-src-f1d49f684de2d9eaa8fc5074d87fb2767fc56741.tar.gz
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.
Diffstat (limited to 'sys/arm/include')
-rw-r--r--sys/arm/include/devmap.h27
-rw-r--r--sys/arm/include/machdep.h32
-rw-r--r--sys/arm/include/pmap.h1
3 files changed, 53 insertions, 7 deletions
diff --git a/sys/arm/include/devmap.h b/sys/arm/include/devmap.h
index ee16b67..028f40d 100644
--- a/sys/arm/include/devmap.h
+++ b/sys/arm/include/devmap.h
@@ -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
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/include/pmap.h b/sys/arm/include/pmap.h
index 9dee28d..9374ab5 100644
--- a/sys/arm/include/pmap.h
+++ b/sys/arm/include/pmap.h
@@ -67,6 +67,7 @@
#else
#define PTE_NOCACHE 1
#define PTE_CACHE 2
+#define PTE_DEVICE PTE_NOCACHE
#define PTE_PAGETABLE 3
#endif
OpenPOWER on IntegriCloud