summaryrefslogtreecommitdiffstats
path: root/sys/arm/include
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2014-05-15 20:58:23 +0000
committerian <ian@FreeBSD.org>2014-05-15 20:58:23 +0000
commit1cfdd472969d9837ad42869895e71bff52d05811 (patch)
treea15ea62cc51e67b4eeebf39fcbd95cf0b8c6c835 /sys/arm/include
parent92d71aad7021b4ed31bde6c5ebd0729f936c2a7b (diff)
downloadFreeBSD-src-1cfdd472969d9837ad42869895e71bff52d05811.zip
FreeBSD-src-1cfdd472969d9837ad42869895e71bff52d05811.tar.gz
MFC r261643, r261646, r261648, r261649, r261651, r261656, r261657, r261663,
r261676, r261677, r261698, r261778 Consolidate code related to setting up physical memory configuration into a new physmem.c file. Replace compile-time constant KERNPHYSADDR with abp_physaddr Calculate the kernel's load address from the PC in the elf / gzip trampoline instead of relying on KERNPHYSADDR as a compile-time constant. It turns out a global variable is the only straightforward way to communicate the kernel's physical load address from where it's known in initarm() into cpu_mp_start() which is called from non-arm code and takes no parameters. Remove the now unused MMU_INIT macro. Use vm_paddr_t, not vm_offset_t, when dealing with physical addresses. No need to set physmem in each initarm() instance anymore, it's handled in common code now. Pass the pagetable used from locore.S to initarm to allow it to map data in as required. Fix the physmem exclude-region clipping logic for the edge-trim case. Add some extra debugging output when DEBUG is defined. Update legacy platforms to use new arm_physmem helper routines.
Diffstat (limited to 'sys/arm/include')
-rw-r--r--sys/arm/include/cpu.h6
-rw-r--r--sys/arm/include/machdep.h3
-rw-r--r--sys/arm/include/physmem.h91
3 files changed, 97 insertions, 3 deletions
diff --git a/sys/arm/include/cpu.h b/sys/arm/include/cpu.h
index 88dbcdb..c6f7088 100644
--- a/sys/arm/include/cpu.h
+++ b/sys/arm/include/cpu.h
@@ -35,6 +35,11 @@ get_cyclecount(void)
extern vm_offset_t vector_page;
+/*
+ * Params passed into initarm. If you change the size of this you will
+ * need to update locore.S to allocate more memory on the stack before
+ * it calls initarm.
+ */
struct arm_boot_params {
register_t abp_size; /* Size of this structure */
register_t abp_r0; /* r0 from the boot loader */
@@ -42,6 +47,7 @@ struct arm_boot_params {
register_t abp_r2; /* r2 from the boot loader */
register_t abp_r3; /* r3 from the boot loader */
vm_offset_t abp_physaddr; /* The kernel physical address */
+ vm_offset_t abp_pagetable; /* The early page table */
};
void arm_vector_init(vm_offset_t, int);
diff --git a/sys/arm/include/machdep.h b/sys/arm/include/machdep.h
index e8f5c4f..101adf7 100644
--- a/sys/arm/include/machdep.h
+++ b/sys/arm/include/machdep.h
@@ -71,7 +71,4 @@ void initarm_late_init(void);
void board_set_serial(uint64_t);
void board_set_revision(uint32_t);
-/* Setup standard arrays */
-void arm_dump_avail_init(vm_paddr_t, vm_offset_t, size_t);
-
#endif /* !_MACHINE_MACHDEP_H_ */
diff --git a/sys/arm/include/physmem.h b/sys/arm/include/physmem.h
new file mode 100644
index 0000000..76af0f6
--- /dev/null
+++ b/sys/arm/include/physmem.h
@@ -0,0 +1,91 @@
+/*-
+ * Copyright (c) 2014 Ian Lepore <ian@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _MACHINE_PHYSMEM_H_
+#define _MACHINE_PHYSMEM_H_
+
+/*
+ * The physical address at which the kernel was loaded.
+ */
+extern vm_paddr_t arm_physmem_kernaddr;
+
+/*
+ * Routines to help configure physical ram.
+ *
+ * Multiple regions of contiguous physical ram can be added (in any order).
+ *
+ * Multiple regions of physical ram that should be excluded from crash dumps, or
+ * memory allocation, or both, can be added (in any order).
+ *
+ * After all early kernel init is done and it's time to configure all
+ * remainining non-excluded physical ram for use by other parts of the kernel,
+ * arm_physmem_init_kernel_globals() processes the hardware regions and
+ * exclusion regions to generate the global dump_avail and phys_avail arrays
+ * that communicate physical ram configuration to other parts of the kernel.
+ */
+
+#define EXFLAG_NODUMP 0x01
+#define EXFLAG_NOALLOC 0x02
+
+void arm_physmem_hardware_region(vm_paddr_t pa, vm_size_t sz);
+void arm_physmem_exclude_region(vm_paddr_t pa, vm_size_t sz, uint32_t flags);
+void arm_physmem_init_kernel_globals(void);
+void arm_physmem_print_tables(void);
+
+/*
+ * Convenience routines for FDT.
+ */
+
+#ifdef FDT
+
+#include <machine/ofw_machdep.h>
+
+inline void
+arm_physmem_hardware_regions(struct mem_region * mrptr, int mrcount)
+{
+ while (mrcount--) {
+ arm_physmem_hardware_region(mrptr->mr_start, mrptr->mr_size);
+ ++mrptr;
+ }
+}
+
+inline void
+arm_physmem_exclude_regions(struct mem_region * mrptr, int mrcount,
+ uint32_t exflags)
+{
+ while (mrcount--) {
+ arm_physmem_exclude_region(mrptr->mr_start, mrptr->mr_size,
+ exflags);
+ ++mrptr;
+ }
+}
+
+#endif /* FDT */
+
+#endif
+
OpenPOWER on IntegriCloud