According to the IEEE-1275 SPARC supplement, the default load address
is the virtual address 0x4000, so looks like we don't have to map the
addresses 0x0 - 0x3fff.
I thought it might be useful actually not to map at least the page 0,
as it would help to catch null pointer dereferences.
So, I went on and made a trivial modification:
--- arch/sparc32/lib.c (revision 1024)
+++ arch/sparc32/lib.c (working copy)
@@ -461,7 +461,7 @@
map_pages(pa, va, size, ofmem_arch_default_translation_mode(pa));
// 1:1 mapping for RAM
- map_pages(0, 0, LOWMEMSZ, ofmem_arch_default_translation_mode(0));
+ map_pages(0x4000, 0x4000, LOWMEMSZ,
ofmem_arch_default_translation_mode(0));
/*
* Flush cache
___
Surprisingly, with this modification a null pointer dereference
happens much earlier than I'd expected: for some reason __context
doesn't get initialized in arch/sparc32/context.c, so OpenBIOS dies
before saying hello.
If I initialize it in start_main the same way it should have been
initialized statically,
start_main(void)
{
+ __context = &main_ctx;
then OpenBIOS starts and is able to boot at least Debian.
Any idea what might be wrong with the current static initialization?
For convenience I paste the code from arch/sparc32/context.c :
static struct context main_ctx = {
.regs[REG_SP] = (uint32_t) &_estack - 96,
.pc = (uint32_t) start_main,
.npc = (uint32_t) start_main + 4,
.return_addr = (uint32_t) __exit_context,
};
/* This is used by assembly routine to load/store the context which
* it is to switch/switched. */
struct context *__context = &main_ctx;
--
Regards,
Artyom Tarasenko
solaris/sparc under qemu blog: http://tyom.blogspot.com/
Author: mcayland
Date: Tue Feb 8 23:06:59 2011
New Revision: 1024
URL: http://tracker.coreboot.org/trac/openbios/changeset/1024
Log:
OFMEM: Fix bogus tail entry added to the end of the virtual memory available list.
Since top_address is 64-bit, the existing code would incorrectly think that the end of
virtual memory had not been reached and so add a bogus tail entry. Casting -1 to ucell
should ensure that we pass the correct top address for virtual memory.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)siriusit.co.uk>
Modified:
trunk/openbios-devel/libopenbios/ofmem_common.c
Modified: trunk/openbios-devel/libopenbios/ofmem_common.c
==============================================================================
--- trunk/openbios-devel/libopenbios/ofmem_common.c Tue Feb 8 23:06:56 2011 (r1023)
+++ trunk/openbios-devel/libopenbios/ofmem_common.c Tue Feb 8 23:06:59 2011 (r1024)
@@ -347,7 +347,7 @@
ofmem_update_memory_available(s_phandle_memory, ofmem->phys_range,
&phys_range_prop, &phys_range_prop_size, &phys_range_prop_used, ofmem_arch_get_phys_top());
ofmem_update_memory_available(s_phandle_mmu, ofmem->virt_range,
- &virt_range_prop, &virt_range_prop_size, &virt_range_prop_used, -1ULL);
+ &virt_range_prop, &virt_range_prop_size, &virt_range_prop_used, (ucell)-1);
ofmem_update_mmu_translations();
}