Author: mcayland Date: Fri Apr 22 02:13:53 2011 New Revision: 1035 URL: http://tracker.coreboot.org/trac/openbios/changeset/1035
Log: Implement new v3_memalloc romvec interface for allocating aligned memory.
When attempting to load kadb from a Solaris 8 CD at boot, it seems that in order for kadb to allocate enough memory to load the kernel (and its modules) the /openprom/aligned-allocator property must be present with length zero.
This has the additional side-effect that OpenBIOS memory allocations are redirected to a new romvec offset when this property is detected, which appears to have a similar interface to obp_dumb_memalloc() but with an extra alignment parameter. Hence we include a simple implementation which seems to be enough to be able to get kadb to load and attach to the kernel.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@siriusit.co.uk
Modified: trunk/openbios-devel/arch/sparc32/call-romvec.S trunk/openbios-devel/arch/sparc32/lib.c trunk/openbios-devel/arch/sparc32/openprom.h trunk/openbios-devel/arch/sparc32/romvec.c trunk/openbios-devel/arch/sparc32/romvec.h trunk/openbios-devel/arch/sparc32/tree.fs
Modified: trunk/openbios-devel/arch/sparc32/call-romvec.S ============================================================================== --- trunk/openbios-devel/arch/sparc32/call-romvec.S Fri Apr 8 11:03:59 2011 (r1034) +++ trunk/openbios-devel/arch/sparc32/call-romvec.S Fri Apr 22 02:13:53 2011 (r1035) @@ -89,4 +89,5 @@ ROMVEC_HANDLER(obp_getprop) ROMVEC_HANDLER(obp_setprop) ROMVEC_HANDLER(obp_nextprop) +ROMVEC_HANDLER(obp_memalloc)
Modified: trunk/openbios-devel/arch/sparc32/lib.c ============================================================================== --- trunk/openbios-devel/arch/sparc32/lib.c Fri Apr 8 11:03:59 2011 (r1034) +++ trunk/openbios-devel/arch/sparc32/lib.c Fri Apr 22 02:13:53 2011 (r1035) @@ -347,10 +347,25 @@ map_pages(phys, virt, size, mode); }
-char *obp_dumb_memalloc(char *va, unsigned int size) +char *obp_memalloc(char *va, unsigned int size, unsigned int align) { phys_addr_t phys; ucell virt; + + /* Claim physical memory */ + phys = ofmem_claim_phys(-1, size, align); + + /* Claim virtual memory */ + virt = ofmem_claim_virt(pointer2cell(va), size, 0); + + /* Map the memory */ + ofmem_map(phys, virt, size, ofmem_arch_default_translation_mode(phys)); + + return cell2pointer(virt); +} + +char *obp_dumb_memalloc(char *va, unsigned int size) +{ unsigned long align; int i;
@@ -371,16 +386,7 @@ align++; }
- /* Claim physical memory */ - phys = ofmem_claim_phys(-1, size, align); - - /* Claim virtual memory */ - virt = ofmem_claim_virt(pointer2cell(va), size, 0); - - /* Map the memory */ - ofmem_map(phys, virt, size, ofmem_arch_default_translation_mode(phys)); - - return cell2pointer(virt); + return obp_memalloc(va, size, align); }
void obp_dumb_memfree(__attribute__((unused))char *va,
Modified: trunk/openbios-devel/arch/sparc32/openprom.h ============================================================================== --- trunk/openbios-devel/arch/sparc32/openprom.h Fri Apr 8 11:03:59 2011 (r1034) +++ trunk/openbios-devel/arch/sparc32/openprom.h Fri Apr 22 02:13:53 2011 (r1035) @@ -135,7 +135,10 @@ struct linux_bootargs_v2 pv_v2bootargs; struct linux_dev_v2_funcs pv_v2devops;
- int filler[15]; + /* Prom version 3 memory allocation */ + char * (*v3_memalloc)(char *va, unsigned int size, unsigned int align); + + int filler[14];
/* This one is sun4c/sun4 only. */ void (*pv_setctxt)(int ctxt, char *va, int pmeg);
Modified: trunk/openbios-devel/arch/sparc32/romvec.c ============================================================================== --- trunk/openbios-devel/arch/sparc32/romvec.c Fri Apr 8 11:03:59 2011 (r1034) +++ trunk/openbios-devel/arch/sparc32/romvec.c Fri Apr 22 02:13:53 2011 (r1035) @@ -508,6 +508,8 @@ fword("open-dev"); obp_fd_stdout = POP();
+ romvec0.v3_memalloc = obp_memalloc_handler; + romvec0.v3_cpustart = obp_cpustart_handler; romvec0.v3_cpustop = obp_cpustop_handler; romvec0.v3_cpuidle = obp_cpuidle_handler;
Modified: trunk/openbios-devel/arch/sparc32/romvec.h ============================================================================== --- trunk/openbios-devel/arch/sparc32/romvec.h Fri Apr 8 11:03:59 2011 (r1034) +++ trunk/openbios-devel/arch/sparc32/romvec.h Fri Apr 22 02:13:53 2011 (r1035) @@ -74,3 +74,5 @@ __attribute__((unused)) int len); const char *obp_nextprop(int node, const char *name); const char *obp_nextprop_handler(int node, const char *name); +char *obp_memalloc(char *va, unsigned int size, unsigned int align); +char *obp_memalloc_handler(char *va, unsigned int size, unsigned int align);
Modified: trunk/openbios-devel/arch/sparc32/tree.fs ============================================================================== --- trunk/openbios-devel/arch/sparc32/tree.fs Fri Apr 8 11:03:59 2011 (r1034) +++ trunk/openbios-devel/arch/sparc32/tree.fs Fri Apr 22 02:13:53 2011 (r1035) @@ -125,3 +125,6 @@
" /options" find-device " disk" encode-string " boot-from" property + +" /openprom" find-device + 0 0 " aligned-allocator" property