Consolidate Apple firmware hacks and improve them by switching on the
presence of mac-io devices in the tree, which uniquely identifies Apple hardware. MFC after: 6 weeks
This commit is contained in:
parent
00a689c438
commit
bcb6fb8b55
@ -67,6 +67,7 @@ extern register_t ofmsr[5];
|
|||||||
extern void *openfirmware_entry;
|
extern void *openfirmware_entry;
|
||||||
static void *fdt;
|
static void *fdt;
|
||||||
int ofw_real_mode;
|
int ofw_real_mode;
|
||||||
|
static int apple_hacks;
|
||||||
|
|
||||||
int ofwcall(void *);
|
int ofwcall(void *);
|
||||||
static int openfirmware(void *args);
|
static int openfirmware(void *args);
|
||||||
@ -79,6 +80,9 @@ register_t ofw_sprg0_save;
|
|||||||
static __inline void
|
static __inline void
|
||||||
ofw_sprg_prepare(void)
|
ofw_sprg_prepare(void)
|
||||||
{
|
{
|
||||||
|
if (!apple_hacks)
|
||||||
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assume that interrupt are disabled at this point, or
|
* Assume that interrupt are disabled at this point, or
|
||||||
* SPRG1-3 could be trashed
|
* SPRG1-3 could be trashed
|
||||||
@ -98,6 +102,9 @@ ofw_sprg_prepare(void)
|
|||||||
static __inline void
|
static __inline void
|
||||||
ofw_sprg_restore(void)
|
ofw_sprg_restore(void)
|
||||||
{
|
{
|
||||||
|
if (!apple_hacks)
|
||||||
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note that SPRG1-3 contents are irrelevant. They are scratch
|
* Note that SPRG1-3 contents are irrelevant. They are scratch
|
||||||
* registers used in the early portion of trap handling when
|
* registers used in the early portion of trap handling when
|
||||||
@ -178,15 +185,10 @@ parse_ofw_memory(phandle_t node, const char *prop, struct mem_region *output)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* On Apple hardware, address_cells is always 1 for "available",
|
* On Apple hardware, address_cells is always 1 for "available",
|
||||||
* even when it is explicitly set to 2. Then all memory above 4 GB
|
* even when it is explicitly set to 2. All memory above 4 GB
|
||||||
* should be added by hand to the available list. Detect Apple hardware
|
* also needs to be added by hand to the available list.
|
||||||
* by seeing if ofw_real_mode is set -- only Apple seems to use
|
|
||||||
* virtual-mode OF.
|
|
||||||
*/
|
*/
|
||||||
if (strcmp(prop, "available") == 0 && !ofw_real_mode)
|
if (strcmp(prop, "available") == 0 && apple_hacks)
|
||||||
apple_hack_mode = 1;
|
|
||||||
|
|
||||||
if (apple_hack_mode)
|
|
||||||
address_cells = 1;
|
address_cells = 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -241,7 +243,7 @@ parse_ofw_memory(phandle_t node, const char *prop, struct mem_region *output)
|
|||||||
sz = j*sizeof(output[0]);
|
sz = j*sizeof(output[0]);
|
||||||
|
|
||||||
#ifdef __powerpc64__
|
#ifdef __powerpc64__
|
||||||
if (apple_hack_mode) {
|
if (strcmp(prop, "available") == 0 && apple_hacks) {
|
||||||
/* Add in regions above 4 GB to the available list */
|
/* Add in regions above 4 GB to the available list */
|
||||||
struct mem_region himem[16];
|
struct mem_region himem[16];
|
||||||
int hisz;
|
int hisz;
|
||||||
@ -480,6 +482,9 @@ OF_bootstrap()
|
|||||||
OF_init(fdt);
|
OF_init(fdt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Apple firmware has some bugs. Check for a "mac-io" alias. */
|
||||||
|
apple_hacks = (OF_finddevice("mac-io") != -1) ? 1 : 0;
|
||||||
|
|
||||||
return (status);
|
return (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user