Changeset View
Changeset View
Standalone View
Standalone View
head/sys/powerpc/ofw/ofw_machdep.c
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
#include <machine/cpu.h> | #include <machine/cpu.h> | ||||
#include <machine/md_var.h> | #include <machine/md_var.h> | ||||
#include <machine/platform.h> | #include <machine/platform.h> | ||||
#include <machine/ofw_machdep.h> | #include <machine/ofw_machdep.h> | ||||
#include <machine/trap.h> | #include <machine/trap.h> | ||||
#include <contrib/libfdt/libfdt.h> | #include <contrib/libfdt/libfdt.h> | ||||
#ifdef POWERNV | |||||
#include <powerpc/powernv/opal.h> | |||||
#endif | |||||
static void *fdt; | static void *fdt; | ||||
int ofw_real_mode; | int ofw_real_mode; | ||||
#ifdef AIM | #ifdef AIM | ||||
extern register_t ofmsr[5]; | extern register_t ofmsr[5]; | ||||
extern void *openfirmware_entry; | extern void *openfirmware_entry; | ||||
char save_trap_init[0x2f00]; /* EXC_LAST */ | char save_trap_init[0x2f00]; /* EXC_LAST */ | ||||
char save_trap_of[0x2f00]; /* EXC_LAST */ | char save_trap_of[0x2f00]; /* EXC_LAST */ | ||||
▲ Show 20 Lines • Show All 253 Lines • ▼ Show 20 Lines | excise_initrd_region(struct mem_region *avail, int asz) | ||||
initrdmap[0].mr_start = start; | initrdmap[0].mr_start = start; | ||||
initrdmap[0].mr_size = end - start; | initrdmap[0].mr_size = end - start; | ||||
asz = excise_reserved_regions(avail, asz, initrdmap, 1); | asz = excise_reserved_regions(avail, asz, initrdmap, 1); | ||||
return (asz); | return (asz); | ||||
} | } | ||||
#ifdef POWERNV | |||||
static int | static int | ||||
excise_msi_region(struct mem_region *avail, int asz) | |||||
{ | |||||
uint64_t start, end; | |||||
struct mem_region initrdmap[1]; | |||||
/* | |||||
* This range of physical addresses is used to implement optimized | |||||
* 32 bit MSI interrupts on POWER9. Exclude it to avoid accidentally | |||||
* using it for DMA, as this will cause an immediate PHB fence. | |||||
* While we could theoretically turn off this behavior in the ETU, | |||||
* doing so would break 32-bit MSI, so just reserve the range in | |||||
* the physical map instead. | |||||
* See section 4.4.2.8 of the PHB4 specification. | |||||
*/ | |||||
start = 0x00000000ffff0000ul; | |||||
end = 0x00000000fffffffful; | |||||
initrdmap[0].mr_start = start; | |||||
initrdmap[0].mr_size = end - start; | |||||
asz = excise_reserved_regions(avail, asz, initrdmap, 1); | |||||
return (asz); | |||||
} | |||||
#endif | |||||
static int | |||||
excise_fdt_reserved(struct mem_region *avail, int asz) | excise_fdt_reserved(struct mem_region *avail, int asz) | ||||
{ | { | ||||
struct mem_region fdtmap[32]; | struct mem_region fdtmap[32]; | ||||
ssize_t fdtmapsize; | ssize_t fdtmapsize; | ||||
phandle_t chosen; | phandle_t chosen; | ||||
int j, fdtentries; | int j, fdtentries; | ||||
chosen = OF_finddevice("/chosen"); | chosen = OF_finddevice("/chosen"); | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | if (OF_hasprop(phandle, "fdtmemreserv")) | ||||
asz = excise_fdt_reserved(availp, asz); | asz = excise_fdt_reserved(availp, asz); | ||||
/* If the kernel is being loaded through kexec, initrd region is listed | /* If the kernel is being loaded through kexec, initrd region is listed | ||||
* in /chosen but the region is not marked as reserved, so, we might exclude | * in /chosen but the region is not marked as reserved, so, we might exclude | ||||
* it here. | * it here. | ||||
*/ | */ | ||||
if (OF_hasprop(phandle, "linux,initrd-start")) | if (OF_hasprop(phandle, "linux,initrd-start")) | ||||
asz = excise_initrd_region(availp, asz); | asz = excise_initrd_region(availp, asz); | ||||
#endif | |||||
#ifdef POWERNV | |||||
if (opal_check() == 0) | |||||
asz = excise_msi_region(availp, asz); | |||||
#endif | #endif | ||||
*memsz = msz; | *memsz = msz; | ||||
*availsz = asz; | *availsz = asz; | ||||
} | } | ||||
void | void | ||||
OF_initial_setup(void *fdt_ptr, void *junk, int (*openfirm)(void *)) | OF_initial_setup(void *fdt_ptr, void *junk, int (*openfirm)(void *)) | ||||
▲ Show 20 Lines • Show All 303 Lines • Show Last 20 Lines |