Do not assume a value for #address-cells when parsing the OF translations
map. This allows the kernel to get farther with OpenBIOS on 64-bit CPUs.
This commit is contained in:
parent
ebd672f58f
commit
fe875ee040
@ -187,8 +187,7 @@ uintptr_t moea64_get_unique_vsid(void);
|
||||
struct ofw_map {
|
||||
cell_t om_va;
|
||||
cell_t om_len;
|
||||
cell_t om_pa_hi;
|
||||
cell_t om_pa_lo;
|
||||
uint64_t om_pa;
|
||||
cell_t om_mode;
|
||||
};
|
||||
|
||||
@ -478,13 +477,9 @@ om_cmp(const void *a, const void *b)
|
||||
|
||||
mapa = a;
|
||||
mapb = b;
|
||||
if (mapa->om_pa_hi < mapb->om_pa_hi)
|
||||
if (mapa->om_pa < mapb->om_pa)
|
||||
return (-1);
|
||||
else if (mapa->om_pa_hi > mapb->om_pa_hi)
|
||||
return (1);
|
||||
else if (mapa->om_pa_lo < mapb->om_pa_lo)
|
||||
return (-1);
|
||||
else if (mapa->om_pa_lo > mapb->om_pa_lo)
|
||||
else if (mapa->om_pa > mapb->om_pa)
|
||||
return (1);
|
||||
else
|
||||
return (0);
|
||||
@ -493,26 +488,41 @@ om_cmp(const void *a, const void *b)
|
||||
static void
|
||||
moea64_add_ofw_mappings(mmu_t mmup, phandle_t mmu, size_t sz)
|
||||
{
|
||||
struct ofw_map translations[sz/sizeof(struct ofw_map)];
|
||||
struct ofw_map translations[sz/(4*sizeof(cell_t))]; /*>= 4 cells per */
|
||||
pcell_t acells, trans_cells[sz/sizeof(cell_t)];
|
||||
register_t msr;
|
||||
vm_offset_t off;
|
||||
vm_paddr_t pa_base;
|
||||
int i;
|
||||
int i, j;
|
||||
|
||||
bzero(translations, sz);
|
||||
if (OF_getprop(mmu, "translations", translations, sz) == -1)
|
||||
OF_getprop(OF_finddevice("/"), "#address-cells", &acells,
|
||||
sizeof(acells));
|
||||
if (OF_getprop(mmu, "translations", trans_cells, sz) == -1)
|
||||
panic("moea64_bootstrap: can't get ofw translations");
|
||||
|
||||
CTR0(KTR_PMAP, "moea64_add_ofw_mappings: translations");
|
||||
sz /= sizeof(*translations);
|
||||
sz /= sizeof(cell_t);
|
||||
for (i = 0, j = 0; i < sz; j++) {
|
||||
translations[j].om_va = trans_cells[i++];
|
||||
translations[j].om_len = trans_cells[i++];
|
||||
translations[j].om_pa = trans_cells[i++];
|
||||
if (acells == 2) {
|
||||
translations[j].om_pa <<= 32;
|
||||
translations[j].om_pa |= trans_cells[i++];
|
||||
}
|
||||
translations[j].om_mode = trans_cells[i++];
|
||||
}
|
||||
KASSERT(i == sz, ("Translations map has incorrect cell count (%d/%zd)",
|
||||
i, sz));
|
||||
|
||||
sz = j;
|
||||
qsort(translations, sz, sizeof (*translations), om_cmp);
|
||||
|
||||
for (i = 0; i < sz; i++) {
|
||||
pa_base = translations[i].om_pa_lo;
|
||||
#ifdef __powerpc64__
|
||||
pa_base += (vm_offset_t)translations[i].om_pa_hi << 32;
|
||||
#else
|
||||
if (translations[i].om_pa_hi)
|
||||
pa_base = translations[i].om_pa;
|
||||
#ifndef __powerpc64__
|
||||
if ((translations[i].om_pa >> 32) != 0)
|
||||
panic("OFW translations above 32-bit boundary!");
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user