Changeset View
Changeset View
Standalone View
Standalone View
head/sys/powerpc/aim/mmu_oea64.c
Show First 20 Lines • Show All 689 Lines • ▼ Show 20 Lines | moea64_setup_direct_map(mmu_t mmup, vm_offset_t kernelstart, | ||||
* Allow user to override unmapped_buf_allowed for testing. | * Allow user to override unmapped_buf_allowed for testing. | ||||
* XXXKIB Only direct map implementation was tested. | * XXXKIB Only direct map implementation was tested. | ||||
*/ | */ | ||||
if (!TUNABLE_INT_FETCH("vfs.unmapped_buf_allowed", | if (!TUNABLE_INT_FETCH("vfs.unmapped_buf_allowed", | ||||
&unmapped_buf_allowed)) | &unmapped_buf_allowed)) | ||||
unmapped_buf_allowed = hw_direct_map; | unmapped_buf_allowed = hw_direct_map; | ||||
} | } | ||||
/* Quick sort callout for comparing physical addresses. */ | |||||
static int | |||||
pa_cmp(const void *a, const void *b) | |||||
{ | |||||
const vm_paddr_t *pa = a, *pb = b; | |||||
if (*pa < *pb) | |||||
return (-1); | |||||
else if (*pa > *pb) | |||||
return (1); | |||||
else | |||||
return (0); | |||||
} | |||||
void | void | ||||
moea64_early_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend) | moea64_early_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend) | ||||
{ | { | ||||
int i, j; | int i, j; | ||||
vm_size_t physsz, hwphyssz; | vm_size_t physsz, hwphyssz; | ||||
vm_paddr_t kernelphysstart, kernelphysend; | vm_paddr_t kernelphysstart, kernelphysend; | ||||
int rm_pavail; | |||||
#ifndef __powerpc64__ | #ifndef __powerpc64__ | ||||
/* We don't have a direct map since there is no BAT */ | /* We don't have a direct map since there is no BAT */ | ||||
hw_direct_map = 0; | hw_direct_map = 0; | ||||
/* Make sure battable is zero, since we have no BAT */ | /* Make sure battable is zero, since we have no BAT */ | ||||
for (i = 0; i < 16; i++) { | for (i = 0; i < 16; i++) { | ||||
battable[i].batu = 0; | battable[i].batu = 0; | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | for (i = 0, j = 0; i < regions_sz; i++, j += 2) { | ||||
} | } | ||||
phys_avail[j] = regions[i].mr_start; | phys_avail[j] = regions[i].mr_start; | ||||
phys_avail[j + 1] = regions[i].mr_start + regions[i].mr_size; | phys_avail[j + 1] = regions[i].mr_start + regions[i].mr_size; | ||||
phys_avail_count++; | phys_avail_count++; | ||||
physsz += regions[i].mr_size; | physsz += regions[i].mr_size; | ||||
} | } | ||||
/* Check for overlap with the kernel and exception vectors */ | /* Check for overlap with the kernel and exception vectors */ | ||||
rm_pavail = 0; | |||||
for (j = 0; j < 2*phys_avail_count; j+=2) { | for (j = 0; j < 2*phys_avail_count; j+=2) { | ||||
if (phys_avail[j] < EXC_LAST) | if (phys_avail[j] < EXC_LAST) | ||||
phys_avail[j] += EXC_LAST; | phys_avail[j] += EXC_LAST; | ||||
if (phys_avail[j] >= kernelphysstart && | |||||
phys_avail[j+1] <= kernelphysend) { | |||||
phys_avail[j] = phys_avail[j+1] = ~0; | |||||
rm_pavail++; | |||||
continue; | |||||
} | |||||
if (kernelphysstart >= phys_avail[j] && | if (kernelphysstart >= phys_avail[j] && | ||||
kernelphysstart < phys_avail[j+1]) { | kernelphysstart < phys_avail[j+1]) { | ||||
if (kernelphysend < phys_avail[j+1]) { | if (kernelphysend < phys_avail[j+1]) { | ||||
phys_avail[2*phys_avail_count] = | phys_avail[2*phys_avail_count] = | ||||
(kernelphysend & ~PAGE_MASK) + PAGE_SIZE; | (kernelphysend & ~PAGE_MASK) + PAGE_SIZE; | ||||
phys_avail[2*phys_avail_count + 1] = | phys_avail[2*phys_avail_count + 1] = | ||||
phys_avail[j+1]; | phys_avail[j+1]; | ||||
phys_avail_count++; | phys_avail_count++; | ||||
Show All 9 Lines | if (kernelphysend >= phys_avail[j] && | ||||
phys_avail[2*phys_avail_count + 1] = | phys_avail[2*phys_avail_count + 1] = | ||||
kernelphysstart & ~PAGE_MASK; | kernelphysstart & ~PAGE_MASK; | ||||
phys_avail_count++; | phys_avail_count++; | ||||
} | } | ||||
phys_avail[j] = (kernelphysend & ~PAGE_MASK) + | phys_avail[j] = (kernelphysend & ~PAGE_MASK) + | ||||
PAGE_SIZE; | PAGE_SIZE; | ||||
} | } | ||||
} | |||||
/* Remove physical available regions marked for removal (~0) */ | |||||
if (rm_pavail) { | |||||
qsort(phys_avail, 2*phys_avail_count, sizeof(phys_avail[0]), | |||||
pa_cmp); | |||||
phys_avail_count -= rm_pavail; | |||||
for (i = 2*phys_avail_count; | |||||
i < 2*(phys_avail_count + rm_pavail); i+=2) | |||||
phys_avail[i] = phys_avail[i+1] = 0; | |||||
} | } | ||||
physmem = btoc(physsz); | physmem = btoc(physsz); | ||||
#ifdef PTEGCOUNT | #ifdef PTEGCOUNT | ||||
moea64_pteg_count = PTEGCOUNT; | moea64_pteg_count = PTEGCOUNT; | ||||
#else | #else | ||||
moea64_pteg_count = 0x1000; | moea64_pteg_count = 0x1000; | ||||
▲ Show 20 Lines • Show All 2,057 Lines • Show Last 20 Lines |