From d0e1702d582a8cacabfdda86bbf842986beceefa Mon Sep 17 00:00:00 2001 From: andreast Date: Wed, 17 Nov 2010 19:35:56 +0000 Subject: 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) --- sys/boot/ofw/libofw/ofw_copy.c | 24 +++++++++++++++--------- sys/boot/ofw/libofw/openfirm.c | 12 ++++++++++++ sys/boot/ofw/libofw/openfirm.h | 1 + 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/sys/boot/ofw/libofw/ofw_copy.c b/sys/boot/ofw/libofw/ofw_copy.c index 781d423..ffd6987 100644 --- a/sys/boot/ofw/libofw/ofw_copy.c +++ b/sys/boot/ofw/libofw/ofw_copy.c @@ -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; diff --git a/sys/boot/ofw/libofw/openfirm.c b/sys/boot/ofw/libofw/openfirm.c index 4b84fa1..0114fb5 100644 --- a/sys/boot/ofw/libofw/openfirm.c +++ b/sys/boot/ofw/libofw/openfirm.c @@ -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; } /* diff --git a/sys/boot/ofw/libofw/openfirm.h b/sys/boot/ofw/libofw/openfirm.h index 6c7ffb2..c70c2e9 100644 --- a/sys/boot/ofw/libofw/openfirm.h +++ b/sys/boot/ofw/libofw/openfirm.h @@ -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 -- cgit v1.1