summaryrefslogtreecommitdiffstats
path: root/sys/arm/xscale
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/xscale
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/xscale')
-rw-r--r--sys/arm/xscale/i80321/ep80219_machdep.c32
-rw-r--r--sys/arm/xscale/i80321/iq31244_machdep.c31
-rw-r--r--sys/arm/xscale/i8134x/crb_machdep.c33
-rw-r--r--sys/arm/xscale/ixp425/avila_machdep.c43
-rw-r--r--sys/arm/xscale/pxa/pxa_machdep.c50
5 files changed, 93 insertions, 96 deletions
diff --git a/sys/arm/xscale/i80321/ep80219_machdep.c b/sys/arm/xscale/i80321/ep80219_machdep.c
index c5e9141..5797b57 100644
--- a/sys/arm/xscale/i80321/ep80219_machdep.c
+++ b/sys/arm/xscale/i80321/ep80219_machdep.c
@@ -86,6 +86,7 @@ __FBSDID("$FreeBSD$");
#include <machine/metadata.h>
#include <machine/armreg.h>
#include <machine/bus.h>
+#include <machine/physmem.h>
#include <sys/reboot.h>
#include <arm/xscale/i80321/i80321reg.h>
@@ -110,9 +111,6 @@ struct pv_addr kernel_pt_table[NUM_KERNEL_PTS];
/* Physical and virtual addresses for some global pages */
-vm_paddr_t phys_avail[10];
-vm_paddr_t dump_avail[4];
-
struct pv_addr systempage;
struct pv_addr msgbufpv;
struct pv_addr irqstack;
@@ -178,6 +176,7 @@ initarm(struct arm_boot_params *abp)
uint32_t memsize, memstart;
lastaddr = parse_boot_param(abp);
+ arm_physmem_kernaddr = abp->abp_physaddr;
set_cpufuncs();
pcpu_init(pcpup, 0, sizeof(struct pcpu));
PCPU_SET(curthread, &thread0);
@@ -334,24 +333,27 @@ initarm(struct arm_boot_params *abp)
/* Enable MMU, I-cache, D-cache, write buffer. */
arm_vector_init(ARM_VECTORS_HIGH, ARM_VEC_ALL);
- pmap_curmaxkvaddr = afterkern + PAGE_SIZE;
- dump_avail[0] = 0xa0000000;
- dump_avail[1] = 0xa0000000 + memsize;
- dump_avail[2] = 0;
- dump_avail[3] = 0;
-
vm_max_kernel_address = 0xd0000000;
pmap_bootstrap(pmap_curmaxkvaddr, &kernel_l1pt);
msgbufp = (void*)msgbufpv.pv_va;
msgbufinit(msgbufp, msgbufsize);
mutex_init();
- i = 0;
- phys_avail[i++] = round_page(virtual_avail - KERNBASE + IQ80321_SDRAM_START);
- phys_avail[i++] = trunc_page(0xa0000000 + memsize - 1);
- phys_avail[i++] = 0;
- phys_avail[i] = 0;
-
+ /*
+ * Add the physical ram we have available.
+ *
+ * Exclude the kernel (and all the things we allocated which immediately
+ * follow the kernel) from the VM allocation pool but not from crash
+ * dumps. virtual_avail is a global variable which tracks the kva we've
+ * "allocated" while setting up pmaps.
+ *
+ * Prepare the list of physical memory available to the vm subsystem.
+ */
+ arm_physmem_hardware_region(IQ80321_SDRAM_START, memsize);
+ arm_physmem_exclude_region(abp->abp_physaddr,
+ virtual_avail - KERNVIRTADDR, EXFLAG_NOALLOC);
+ arm_physmem_init_kernel_globals();
+
init_param2(physmem);
kdb_init();
return ((void *)(kernelstack.pv_va + USPACE_SVC_STACK_TOP -
diff --git a/sys/arm/xscale/i80321/iq31244_machdep.c b/sys/arm/xscale/i80321/iq31244_machdep.c
index 31b9d70..c52b1ac 100644
--- a/sys/arm/xscale/i80321/iq31244_machdep.c
+++ b/sys/arm/xscale/i80321/iq31244_machdep.c
@@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
#include <sys/msgbuf.h>
#include <machine/reg.h>
#include <machine/cpu.h>
+#include <machine/physmem.h>
#include <vm/vm.h>
#include <vm/pmap.h>
@@ -110,9 +111,6 @@ struct pv_addr kernel_pt_table[NUM_KERNEL_PTS];
/* Physical and virtual addresses for some global pages */
-vm_paddr_t phys_avail[10];
-vm_paddr_t dump_avail[4];
-
struct pv_addr systempage;
struct pv_addr msgbufpv;
struct pv_addr irqstack;
@@ -179,6 +177,7 @@ initarm(struct arm_boot_params *abp)
uint32_t memsize, memstart;
lastaddr = parse_boot_param(abp);
+ arm_physmem_kernaddr = abp->abp_physaddr;
set_cpufuncs();
pcpu_init(pcpup, 0, sizeof(struct pcpu));
PCPU_SET(curthread, &thread0);
@@ -336,23 +335,27 @@ initarm(struct arm_boot_params *abp)
arm_vector_init(ARM_VECTORS_HIGH, ARM_VEC_ALL);
pmap_curmaxkvaddr = afterkern + PAGE_SIZE;
- dump_avail[0] = 0xa0000000;
- dump_avail[1] = 0xa0000000 + memsize;
- dump_avail[2] = 0;
- dump_avail[3] = 0;
-
vm_max_kernel_address = 0xd0000000;
pmap_bootstrap(pmap_curmaxkvaddr, &kernel_l1pt);
msgbufp = (void*)msgbufpv.pv_va;
msgbufinit(msgbufp, msgbufsize);
mutex_init();
- i = 0;
- phys_avail[i++] = round_page(virtual_avail - KERNBASE + SDRAM_START);
- phys_avail[i++] = trunc_page(0xa0000000 + memsize - 1);
- phys_avail[i++] = 0;
- phys_avail[i] = 0;
-
+ /*
+ * Add the physical ram we have available.
+ *
+ * Exclude the kernel (and all the things we allocated which immediately
+ * follow the kernel) from the VM allocation pool but not from crash
+ * dumps. virtual_avail is a global variable which tracks the kva we've
+ * "allocated" while setting up pmaps.
+ *
+ * Prepare the list of physical memory available to the vm subsystem.
+ */
+ arm_physmem_hardware_region(SDRAM_START, memsize);
+ arm_physmem_exclude_region(abp->abp_physaddr,
+ virtual_avail - KERNVIRTADDR, EXFLAG_NOALLOC);
+ arm_physmem_init_kernel_globals();
+
init_param2(physmem);
kdb_init();
return ((void *)(kernelstack.pv_va + USPACE_SVC_STACK_TOP -
diff --git a/sys/arm/xscale/i8134x/crb_machdep.c b/sys/arm/xscale/i8134x/crb_machdep.c
index 1cf79b9..6e223b6 100644
--- a/sys/arm/xscale/i8134x/crb_machdep.c
+++ b/sys/arm/xscale/i8134x/crb_machdep.c
@@ -86,6 +86,7 @@ __FBSDID("$FreeBSD$");
#include <machine/metadata.h>
#include <machine/armreg.h>
#include <machine/bus.h>
+#include <machine/physmem.h>
#include <sys/reboot.h>
@@ -113,9 +114,6 @@ struct pv_addr kernel_pt_table[NUM_KERNEL_PTS];
/* Physical and virtual addresses for some global pages */
-vm_paddr_t phys_avail[10];
-vm_paddr_t dump_avail[4];
-
struct pv_addr systempage;
struct pv_addr msgbufpv;
struct pv_addr irqstack;
@@ -178,6 +176,7 @@ initarm(struct arm_boot_params *abp)
uint32_t memsize, memstart;
lastaddr = parse_boot_param(abp);
+ arm_physmem_kernaddr = abp->abp_physaddr;
set_cpufuncs();
pcpu_init(pcpup, 0, sizeof(struct pcpu));
PCPU_SET(curthread, &thread0);
@@ -314,23 +313,27 @@ initarm(struct arm_boot_params *abp)
pmap_curmaxkvaddr = afterkern + PAGE_SIZE;
- dump_avail[0] = 0x00000000;
- dump_avail[1] = 0x00000000 + memsize;
- dump_avail[2] = 0;
- dump_avail[3] = 0;
-
vm_max_kernel_address = 0xd0000000;
pmap_bootstrap(pmap_curmaxkvaddr, &kernel_l1pt);
msgbufp = (void*)msgbufpv.pv_va;
msgbufinit(msgbufp, msgbufsize);
mutex_init();
-
- i = 0;
- phys_avail[i++] = round_page(virtual_avail - KERNBASE + SDRAM_START);
- phys_avail[i++] = trunc_page(0x00000000 + memsize - 1);
- phys_avail[i++] = 0;
- phys_avail[i] = 0;
-
+
+ /*
+ * Add the physical ram we have available.
+ *
+ * Exclude the kernel (and all the things we allocated which immediately
+ * follow the kernel) from the VM allocation pool but not from crash
+ * dumps. virtual_avail is a global variable which tracks the kva we've
+ * "allocated" while setting up pmaps.
+ *
+ * Prepare the list of physical memory available to the vm subsystem.
+ */
+ arm_physmem_hardware_region(SDRAM_START, memsize);
+ arm_physmem_exclude_region(abp->abp_physaddr,
+ virtual_avail - KERNVIRTADDR, EXFLAG_NOALLOC);
+ arm_physmem_init_kernel_globals();
+
init_param2(physmem);
kdb_init();
return ((void *)(kernelstack.pv_va + USPACE_SVC_STACK_TOP -
diff --git a/sys/arm/xscale/ixp425/avila_machdep.c b/sys/arm/xscale/ixp425/avila_machdep.c
index 3abdf22..b4ac7a7 100644
--- a/sys/arm/xscale/ixp425/avila_machdep.c
+++ b/sys/arm/xscale/ixp425/avila_machdep.c
@@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$");
#include <sys/exec.h>
#include <sys/kdb.h>
#include <sys/msgbuf.h>
+#include <machine/physmem.h>
#include <machine/reg.h>
#include <machine/cpu.h>
@@ -91,11 +92,6 @@ __FBSDID("$FreeBSD$");
#include <arm/xscale/ixp425/ixp425reg.h>
#include <arm/xscale/ixp425/ixp425var.h>
-/* kernel text starts where we were loaded at boot */
-#define KERNEL_TEXT_OFF (KERNPHYSADDR - PHYSADDR)
-#define KERNEL_TEXT_BASE (KERNBASE + KERNEL_TEXT_OFF)
-#define KERNEL_TEXT_PHYS (PHYSADDR + KERNEL_TEXT_OFF)
-
#define KERNEL_PT_SYS 0 /* Page table for mapping proc0 zero page */
#define KERNEL_PT_IO 1
#define KERNEL_PT_IO_NUM 3
@@ -114,9 +110,6 @@ struct pv_addr kernel_pt_table[NUM_KERNEL_PTS];
/* Physical and virtual addresses for some global pages */
-vm_paddr_t phys_avail[10];
-vm_paddr_t dump_avail[4];
-
struct pv_addr systempage;
struct pv_addr msgbufpv;
struct pv_addr irqstack;
@@ -223,7 +216,13 @@ initarm(struct arm_boot_params *abp)
vm_offset_t lastaddr;
uint32_t memsize;
+ /* kernel text starts where we were loaded at boot */
+#define KERNEL_TEXT_OFF (abp->abp_physaddr - PHYSADDR)
+#define KERNEL_TEXT_BASE (KERNBASE + KERNEL_TEXT_OFF)
+#define KERNEL_TEXT_PHYS (PHYSADDR + KERNEL_TEXT_OFF)
+
lastaddr = parse_boot_param(abp);
+ arm_physmem_kernaddr = abp->abp_physaddr;
set_cpufuncs(); /* NB: sets cputype */
pcpu_init(pcpup, 0, sizeof(struct pcpu));
PCPU_SET(curthread, &thread0);
@@ -242,7 +241,7 @@ initarm(struct arm_boot_params *abp)
* write-through). Note this leaves a gap for expansion
* (or might be repurposed).
*/
- freemempos = KERNPHYSADDR;
+ freemempos = abp->abp_physaddr;
/* macros to simplify initial memory allocation */
#define alloc_pages(var, np) do { \
@@ -253,7 +252,7 @@ initarm(struct arm_boot_params *abp)
} while (0)
#define valloc_pages(var, np) do { \
alloc_pages((var).pv_pa, (np)); \
- (var).pv_va = (var).pv_pa + (KERNVIRTADDR - KERNPHYSADDR); \
+ (var).pv_va = (var).pv_pa + (KERNVIRTADDR - abp->abp_physaddr); \
} while (0)
/* force L1 page table alignment */
@@ -272,7 +271,7 @@ initarm(struct arm_boot_params *abp)
L2_TABLE_SIZE_REAL;
kernel_pt_table[loop].pv_va =
kernel_pt_table[loop].pv_pa +
- (KERNVIRTADDR - KERNPHYSADDR);
+ (KERNVIRTADDR - abp->abp_physaddr);
}
}
freemem_pt = freemempos; /* base of allocated pt's */
@@ -393,7 +392,6 @@ initarm(struct arm_boot_params *abp)
memsize = ixp435_ddram_size();
else
memsize = ixp425_sdram_size();
- physmem = memsize / PAGE_SIZE;
/* Set stack for exception handlers */
@@ -407,19 +405,26 @@ initarm(struct arm_boot_params *abp)
arm_vector_init(ARM_VECTORS_HIGH, ARM_VEC_ALL);
pmap_curmaxkvaddr = afterkern + PAGE_SIZE;
- arm_dump_avail_init(abp->abp_physaddr, memsize,
- sizeof(dump_avail) / sizeof(dump_avail[0]));
vm_max_kernel_address = 0xd0000000;
pmap_bootstrap(pmap_curmaxkvaddr, &kernel_l1pt);
msgbufp = (void*)msgbufpv.pv_va;
msgbufinit(msgbufp, msgbufsize);
mutex_init();
- i = 0;
- phys_avail[i++] = round_page(virtual_avail - KERNBASE + PHYSADDR);
- phys_avail[i++] = trunc_page(PHYSADDR + memsize - 1);
- phys_avail[i++] = 0;
- phys_avail[i] = 0;
+ /*
+ * Add the physical ram we have available.
+ *
+ * Exclude the kernel, and all the things we allocated which immediately
+ * follow the kernel, from the VM allocation pool but not from crash
+ * dumps. virtual_avail is a global variable which tracks the kva we've
+ * "allocated" while setting up pmaps.
+ *
+ * Prepare the list of physical memory available to the vm subsystem.
+ */
+ arm_physmem_hardware_region(PHYSADDR, memsize);
+ arm_physmem_exclude_region(abp->abp_physaddr,
+ virtual_avail - KERNVIRTADDR, EXFLAG_NOALLOC);
+ arm_physmem_init_kernel_globals();
init_param2(physmem);
kdb_init();
diff --git a/sys/arm/xscale/pxa/pxa_machdep.c b/sys/arm/xscale/pxa/pxa_machdep.c
index a9cf13f..23bdf0e 100644
--- a/sys/arm/xscale/pxa/pxa_machdep.c
+++ b/sys/arm/xscale/pxa/pxa_machdep.c
@@ -88,6 +88,7 @@ __FBSDID("$FreeBSD$");
#include <machine/metadata.h>
#include <machine/armreg.h>
#include <machine/bus.h>
+#include <machine/physmem.h>
#include <sys/reboot.h>
#include <arm/xscale/pxa/pxareg.h>
@@ -110,9 +111,6 @@ struct pv_addr kernel_pt_table[NUM_KERNEL_PTS];
/* Physical and virtual addresses for some global pages */
-vm_paddr_t phys_avail[PXA2X0_SDRAM_BANKS * 2 + 4];
-vm_paddr_t dump_avail[PXA2X0_SDRAM_BANKS * 2 + 4];
-
struct pv_addr systempage;
struct pv_addr msgbufpv;
struct pv_addr irqstack;
@@ -160,6 +158,7 @@ initarm(struct arm_boot_params *abp)
uint32_t memsize[PXA2X0_SDRAM_BANKS], memstart[PXA2X0_SDRAM_BANKS];
lastaddr = parse_boot_param(abp);
+ arm_physmem_kernaddr = abp->abp_physaddr;
set_cpufuncs();
pcpu_init(pcpup, 0, sizeof(struct pcpu));
PCPU_SET(curthread, &thread0);
@@ -309,11 +308,6 @@ initarm(struct arm_boot_params *abp)
*/
pxa_probe_sdram(obio_tag, PXA2X0_MEMCTL_BASE, memstart, memsize);
- physmem = 0;
- for (i = 0; i < PXA2X0_SDRAM_BANKS; i++) {
- physmem += memsize[i] / PAGE_SIZE;
- }
-
/* Fire up consoles. */
cninit();
@@ -329,39 +323,29 @@ initarm(struct arm_boot_params *abp)
arm_vector_init(ARM_VECTORS_HIGH, ARM_VEC_ALL);
pmap_curmaxkvaddr = afterkern + PAGE_SIZE;
- i = 0;
- for (j = 0; j < PXA2X0_SDRAM_BANKS; j++) {
- if (memsize[j] > 0) {
- dump_avail[i++] = round_page(memstart[j]);
- dump_avail[i++] =
- trunc_page(memstart[j] + memsize[j]);
- }
- }
- dump_avail[i] = 0;
- dump_avail[i] = 0;
vm_max_kernel_address = 0xd0000000;
pmap_bootstrap(pmap_curmaxkvaddr, &kernel_l1pt);
msgbufp = (void*)msgbufpv.pv_va;
msgbufinit(msgbufp, msgbufsize);
mutex_init();
- i = 0;
+ /*
+ * Add the physical ram we have available.
+ *
+ * Exclude the kernel (and all the things we allocated which immediately
+ * follow the kernel) from the VM allocation pool but not from crash
+ * dumps. virtual_avail is a global variable which tracks the kva we've
+ * "allocated" while setting up pmaps.
+ *
+ * Prepare the list of physical memory available to the vm subsystem.
+ */
for (j = 0; j < PXA2X0_SDRAM_BANKS; j++) {
- if (memsize[j] > 0) {
- phys_avail[i] = round_page(memstart[j]);
- dump_avail[i++] = round_page(memstart[j]);
- phys_avail[i] =
- trunc_page(memstart[j] + memsize[j]);
- dump_avail[i++] =
- trunc_page(memstart[j] + memsize[j]);
- }
+ if (memsize[j] > 0)
+ arm_physmem_hardware_region(memstart[j], memsize[j]);
}
-
- dump_avail[i] = 0;
- phys_avail[i++] = 0;
- dump_avail[i] = 0;
- phys_avail[i] = 0;
- phys_avail[0] = round_page(virtual_avail - KERNBASE + phys_avail[0]);
+ arm_physmem_exclude_region(abp->abp_physaddr,
+ virtual_avail - KERNVIRTADDR, EXFLAG_NOALLOC);
+ arm_physmem_init_kernel_globals();
init_param2(physmem);
kdb_init();
OpenPOWER on IntegriCloud