Check the real-mode? OF property to find out whether we operate in real or

virtual mode. In virtual mode we have to do memory mapping. On PowerMacs it is
usually false while on pSeries we have found that it is true. The real-mode?
property is not available on sparc64.

Approved by: 	nwhitehorn (mentor)
This commit is contained in:
Andreas Tobler 2010-11-17 19:35:56 +00:00
parent cb1b50fa7c
commit da068879c5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=215438
3 changed files with 28 additions and 9 deletions

View File

@ -91,16 +91,22 @@ ofw_mapmem(vm_offset_t dest, const size_t len)
return (ENOMEM);
}
if (OF_call_method("claim", mmu, 3, 1, destp, dlen, 0, &addr) == -1) {
printf("ofw_mapmem: virtual claim failed\n");
return (ENOMEM);
}
if (OF_call_method("map", mmu, 4, 0, destp, destp, dlen, 0) == -1) {
printf("ofw_mapmem: map failed\n");
return (ENOMEM);
}
/*
* We only do virtual memory management when real_mode is false.
*/
if (real_mode == 0) {
if (OF_call_method("claim", mmu, 3, 1, destp, dlen, 0, &addr)
== -1) {
printf("ofw_mapmem: virtual claim failed\n");
return (ENOMEM);
}
if (OF_call_method("map", mmu, 4, 0, destp, destp, dlen, 0)
== -1) {
printf("ofw_mapmem: map failed\n");
return (ENOMEM);
}
}
last_dest = (vm_offset_t) destp;
last_len = dlen;

View File

@ -69,12 +69,15 @@ int (*openfirmware)(void *);
phandle_t chosen;
ihandle_t mmu;
ihandle_t memory;
int real_mode = 0;
/* Initialiser */
void
OF_init(int (*openfirm)(void *))
{
phandle_t options;
char mode[8];
openfirmware = openfirm;
@ -89,6 +92,15 @@ OF_init(int (*openfirm)(void *))
}
if (OF_getprop(chosen, "mmu", &mmu, sizeof(mmu)) == -1)
OF_exit();
/*
* Check if we run in real mode. If so, we do not need to map
* memory later on.
*/
options = OF_finddevice("/options");
OF_getprop(options, "real-mode?", mode, sizeof(mode));
if (strncmp(mode, "true", 4) == 0)
real_mode = 1;
}
/*

View File

@ -72,6 +72,7 @@ typedef unsigned long int cell_t;
extern int (*openfirmware)(void *);
extern phandle_t chosen;
extern ihandle_t memory, mmu;
extern int real_mode;
/*
* This isn't actually an Open Firmware function, but it seemed like the right