aboutsummaryrefslogtreecommitdiff
path: root/sys/arm64
diff options
context:
space:
mode:
authorAndrew Turner <andrew@FreeBSD.org>2018-05-22 11:07:04 +0000
committerAndrew Turner <andrew@FreeBSD.org>2018-05-22 11:07:04 +0000
commit79402150c1ce1c5d7905fb3a7e0e40eedc89ec12 (patch)
tree8d195d9151eb1c39f959f45cc53fced324e966fc /sys/arm64
parente95725feca4ad8142d472293c519687ec3098c6e (diff)
downloadsrc-79402150c1ce1c5d7905fb3a7e0e40eedc89ec12.tar.gz
src-79402150c1ce1c5d7905fb3a7e0e40eedc89ec12.zip
Switch arm64 to use the same physmem code as 32-bit arm.
The main advantage of this is to allow us to exclude memory from being used by the kernel. This may be from the memreserve property, or ranges marked as no-map under the reserved-memory node. More work is still needed to remove the physmap array. This is still used for creating the DMAP region, however other patches need to be committed before we can remove this. Obtained from: ABT Systems Ltd Sponsored by: Turing Robotic Industries
Notes
Notes: svn path=/head/; revision=334032
Diffstat (limited to 'sys/arm64')
-rw-r--r--sys/arm64/arm64/machdep.c23
-rw-r--r--sys/arm64/arm64/pmap.c74
2 files changed, 12 insertions, 85 deletions
diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
index f6749a8139ec..a4ee1a22d947 100644
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -80,6 +80,8 @@ __FBSDID("$FreeBSD$");
#include <machine/undefined.h>
#include <machine/vmparam.h>
+#include <arm/include/physmem.h>
+
#ifdef VFP
#include <machine/vfp.h>
#endif
@@ -101,13 +103,8 @@ struct pcpu __pcpu[MAXCPU];
static struct trapframe proc0_tf;
-vm_paddr_t phys_avail[PHYS_AVAIL_SIZE + 2];
-vm_paddr_t dump_avail[PHYS_AVAIL_SIZE + 2];
-
int early_boot = 1;
int cold = 1;
-long realmem = 0;
-long Maxmem = 0;
#define PHYSMAP_SIZE (2 * (VM_PHYSSEG_MAX - 1))
vm_paddr_t physmap[PHYSMAP_SIZE];
@@ -898,6 +895,8 @@ add_efi_map_entries(struct efi_map_header *efihdr, vm_paddr_t *physmap,
continue;
}
+ arm_physmem_hardware_region(p->md_phys,
+ p->md_pages * PAGE_SIZE);
if (!add_physmap_entry(p->md_phys, (p->md_pages * PAGE_SIZE),
physmap, physmap_idxp))
break;
@@ -1026,9 +1025,7 @@ initarm(struct arm64_bootparams *abp)
#endif
vm_offset_t lastaddr;
caddr_t kmdp;
- vm_paddr_t mem_len;
bool valid;
- int i;
/* Set the module data location */
preload_metadata = (caddr_t)(uintptr_t)(abp->modulep);
@@ -1064,19 +1061,10 @@ initarm(struct arm64_bootparams *abp)
panic("Cannot get physical memory regions");
add_fdt_mem_regions(mem_regions, mem_regions_sz, physmap,
&physmap_idx);
+ arm_physmem_hardware_regions(mem_regions, mem_regions_sz);
}
#endif
- /* Print the memory map */
- mem_len = 0;
- for (i = 0; i < physmap_idx; i += 2) {
- dump_avail[i] = physmap[i];
- dump_avail[i + 1] = physmap[i + 1];
- mem_len += physmap[i + 1] - physmap[i];
- }
- dump_avail[i] = 0;
- dump_avail[i + 1] = 0;
-
/* Set the pcpu data, this is needed by pmap_bootstrap */
pcpup = &__pcpu[0];
pcpu_init(pcpup, 0, sizeof(struct pcpu));
@@ -1100,6 +1088,7 @@ initarm(struct arm64_bootparams *abp)
/* Bootstrap enough of pmap to enter the kernel proper */
pmap_bootstrap(abp->kern_l0pt, abp->kern_l1pt,
KERNBASE - abp->kern_delta, lastaddr - KERNBASE);
+ arm_physmem_init_kernel_globals();
devmap_bootstrap(0, NULL);
diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c
index e25e2642353d..64623c372a7f 100644
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -146,6 +146,8 @@ __FBSDID("$FreeBSD$");
#include <machine/md_var.h>
#include <machine/pcb.h>
+#include <arm/include/physmem.h>
+
#define NL0PG (PAGE_SIZE/(sizeof (pd_entry_t)))
#define NL1PG (PAGE_SIZE/(sizeof (pd_entry_t)))
#define NL2PG (PAGE_SIZE/(sizeof (pd_entry_t)))
@@ -669,16 +671,15 @@ void
pmap_bootstrap(vm_offset_t l0pt, vm_offset_t l1pt, vm_paddr_t kernstart,
vm_size_t kernlen)
{
- u_int l1_slot, l2_slot, avail_slot, map_slot, used_map_slot;
+ u_int l1_slot, l2_slot;
uint64_t kern_delta;
pt_entry_t *l2;
vm_offset_t va, freemempos;
vm_offset_t dpcpu, msgbufpv;
- vm_paddr_t pa, max_pa, min_pa;
+ vm_paddr_t start_pa, pa, max_pa, min_pa;
int i;
kern_delta = KERNBASE - kernstart;
- physmem = 0;
printf("pmap_bootstrap %lx %lx %lx\n", l1pt, kernstart, kernlen);
printf("%lx\n", l1pt);
@@ -708,38 +709,7 @@ pmap_bootstrap(vm_offset_t l0pt, vm_offset_t l1pt, vm_paddr_t kernstart,
pmap_bootstrap_dmap(l1pt, min_pa, max_pa);
va = KERNBASE;
- pa = KERNBASE - kern_delta;
-
- /*
- * Start to initialise phys_avail by copying from physmap
- * up to the physical address KERNBASE points at.
- */
- map_slot = avail_slot = 0;
- for (; map_slot < (physmap_idx * 2) &&
- avail_slot < (PHYS_AVAIL_SIZE - 2); map_slot += 2) {
- if (physmap[map_slot] == physmap[map_slot + 1])
- continue;
-
- if (physmap[map_slot] <= pa &&
- physmap[map_slot + 1] > pa)
- break;
-
- phys_avail[avail_slot] = physmap[map_slot];
- phys_avail[avail_slot + 1] = physmap[map_slot + 1];
- physmem += (phys_avail[avail_slot + 1] -
- phys_avail[avail_slot]) >> PAGE_SHIFT;
- avail_slot += 2;
- }
-
- /* Add the memory before the kernel */
- if (physmap[avail_slot] < pa && avail_slot < (PHYS_AVAIL_SIZE - 2)) {
- phys_avail[avail_slot] = physmap[map_slot];
- phys_avail[avail_slot + 1] = pa;
- physmem += (phys_avail[avail_slot + 1] -
- phys_avail[avail_slot]) >> PAGE_SHIFT;
- avail_slot += 2;
- }
- used_map_slot = map_slot;
+ start_pa = pa = KERNBASE - kern_delta;
/*
* Read the page table to find out what is already mapped.
@@ -797,39 +767,7 @@ pmap_bootstrap(vm_offset_t l0pt, vm_offset_t l1pt, vm_paddr_t kernstart,
pa = pmap_early_vtophys(l1pt, freemempos);
- /* Finish initialising physmap */
- map_slot = used_map_slot;
- for (; avail_slot < (PHYS_AVAIL_SIZE - 2) &&
- map_slot < (physmap_idx * 2); map_slot += 2) {
- if (physmap[map_slot] == physmap[map_slot + 1])
- continue;
-
- /* Have we used the current range? */
- if (physmap[map_slot + 1] <= pa)
- continue;
-
- /* Do we need to split the entry? */
- if (physmap[map_slot] < pa) {
- phys_avail[avail_slot] = pa;
- phys_avail[avail_slot + 1] = physmap[map_slot + 1];
- } else {
- phys_avail[avail_slot] = physmap[map_slot];
- phys_avail[avail_slot + 1] = physmap[map_slot + 1];
- }
- physmem += (phys_avail[avail_slot + 1] -
- phys_avail[avail_slot]) >> PAGE_SHIFT;
-
- avail_slot += 2;
- }
- phys_avail[avail_slot] = 0;
- phys_avail[avail_slot + 1] = 0;
-
- /*
- * Maxmem isn't the "maximum memory", it's one larger than the
- * highest page of the physical address space. It should be
- * called something like "Maxphyspage".
- */
- Maxmem = atop(phys_avail[avail_slot - 1]);
+ arm_physmem_exclude_region(start_pa, pa - start_pa, EXFLAG_NOALLOC);
cpu_tlb_flushID();
}