[OpenBIOS] [commit] r766 - in trunk/openbios-devel: arch/sparc64 include/libopenbios libopenbios
repository service
svn at openbios.org
Sun May 2 21:26:29 CEST 2010
Author: mcayland
Date: Sun May 2 21:26:29 2010
New Revision: 766
URL: http://tracker.coreboot.org/trac/openbios/changeset/766
Log:
Commit partial implementation of SUNW,retain for SPARC64 based upon the existing physical allocation routines. I've been unable
to finish the code and test retention after a restart since the OpenBIOS words reset and reset-all don't seem to work at the
moment. However, it enables OpenSolaris boot to get further in the meantime.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at siriusit.co.uk>
Modified:
trunk/openbios-devel/arch/sparc64/lib.c
trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c
trunk/openbios-devel/include/libopenbios/ofmem.h
trunk/openbios-devel/libopenbios/ofmem_common.c
Modified: trunk/openbios-devel/arch/sparc64/lib.c
==============================================================================
--- trunk/openbios-devel/arch/sparc64/lib.c Sat May 1 14:13:16 2010 (r765)
+++ trunk/openbios-devel/arch/sparc64/lib.c Sun May 2 21:26:29 2010 (r766)
@@ -394,11 +394,35 @@
ofmem_release_phys(phys, size);
}
+/* ( name-cstr phys size align --- phys ) */
+static void
+mem_retain ( void )
+{
+ ucell phys=-1UL, size, align;
+
+ align = POP();
+ size = POP();
+ if (!align) {
+ phys = POP();
+ phys <<= 32;
+ phys |= POP();
+ }
+
+ /* Currently do nothing with the name */
+ POP();
+
+ phys = ofmem_retain(phys, size, align);
+
+ PUSH(phys & 0xffffffffUL);
+ PUSH(phys >> 32);
+}
+
DECLARE_NODE(memory, INSTALL_OPEN, 0, "/memory");
NODE_METHODS( memory ) = {
{ "claim", mem_claim },
{ "release", mem_release },
+ { "SUNW,retain", mem_retain },
};
DECLARE_UNNAMED_NODE(mmu, INSTALL_OPEN, 0);
Modified: trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c
==============================================================================
--- trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c Sat May 1 14:13:16 2010 (r765)
+++ trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c Sun May 2 21:26:29 2010 (r766)
@@ -26,19 +26,19 @@
ofmem_t ofmem;
} s_ofmem_data;
-#define OFMEM (&s_ofmem_data.ofmem)
-#define TOP_OF_RAM (s_ofmem_data.memory + MEMSIZE)
+#define OFMEM (&s_ofmem_data.ofmem)
+#define TOP_OF_RAM (s_ofmem_data.memory + MEMSIZE)
translation_t **g_ofmem_translations = &s_ofmem_data.ofmem.trans;
-static ucell get_heap_top( void )
+static inline size_t ALIGN_SIZE(size_t x, size_t a)
{
- return (ucell)TOP_OF_RAM;
+ return (x + a - 1) & ~(a-1);
}
-static inline size_t ALIGN_SIZE(size_t x, size_t a)
+static ucell get_heap_top( void )
{
- return (x + a - 1) & ~(a-1);
+ return (ucell)(TOP_OF_RAM - ALIGN_SIZE(sizeof(retain_t), 8));
}
ofmem_t* ofmem_arch_get_private(void)
@@ -95,10 +95,27 @@
return 0;
}
+#define RETAIN_OFMEM (TOP_OF_RAM - ALIGN_SIZE(sizeof(retain_t), 8))
+#define RETAIN_MAGIC 0x1100220033004400
+
void ofmem_init( void )
{
- memset(&s_ofmem_data, 0, sizeof(s_ofmem_data));
- s_ofmem_data.ofmem.ramsize = qemu_mem_size;
+ retain_t *retained = (retain_t *)RETAIN_OFMEM;
+
+ /* Clear all memory except any retained areas */
+ if (!retained->magic == RETAIN_MAGIC) {
+ memset(&s_ofmem_data, 0, sizeof(s_ofmem_data));
+ s_ofmem_data.ofmem.ramsize = qemu_mem_size;
+
+ retained->magic = RETAIN_MAGIC;
+ } else {
+ /* TODO: walk retain_phys_range and add entries to phys_range to prevent
+ them being reused */
+ OFMEM_TRACE("ofmem_init has detected retained magic but currently not implemented");
+
+ memset(&s_ofmem_data, 0, sizeof(s_ofmem_data));
+ s_ofmem_data.ofmem.ramsize = qemu_mem_size;
+ }
/* inherit translations set up by entry.S */
ofmem_walk_boot_map(remap_page_range);
Modified: trunk/openbios-devel/include/libopenbios/ofmem.h
==============================================================================
--- trunk/openbios-devel/include/libopenbios/ofmem.h Sat May 1 14:13:16 2010 (r765)
+++ trunk/openbios-devel/include/libopenbios/ofmem.h Sun May 2 21:26:29 2010 (r766)
@@ -46,10 +46,17 @@
range_t *phys_range;
range_t *virt_range;
+ range_t *retain_phys_range; /* physical memory that should survive a warm reset */
translation_t *trans; /* this is really a translation_t */
} ofmem_t;
+/* structure for retained data at the top of the heap */
+typedef struct {
+ ucell magic;
+ range_t *retain_phys_range;
+} retain_t;
+
/* TODO: temporary migration interface */
extern ofmem_t* ofmem_arch_get_private(void);
extern void* ofmem_arch_get_malloc_base(void);
@@ -86,6 +93,8 @@
extern ucell ofmem_claim_phys( ucell mphys, ucell size, ucell align );
extern ucell ofmem_claim_virt( ucell mvirt, ucell size, ucell align );
+extern ucell ofmem_retain( ucell phys, ucell size, ucell align );
+
extern int ofmem_map( ucell phys, ucell virt, ucell size, ucell mode );
extern int ofmem_unmap( ucell virt, ucell size );
Modified: trunk/openbios-devel/libopenbios/ofmem_common.c
==============================================================================
--- trunk/openbios-devel/libopenbios/ofmem_common.c Sat May 1 14:13:16 2010 (r765)
+++ trunk/openbios-devel/libopenbios/ofmem_common.c Sun May 2 21:26:29 2010 (r766)
@@ -449,6 +449,23 @@
get_ram_size(), ofmem_arch_get_virt_top(), 0 );
}
+/* if align != 0, phys is ignored. Returns -1 on error */
+ucell ofmem_retain( ucell phys, ucell size, ucell align )
+{
+ ofmem_t *ofmem = ofmem_arch_get_private();
+ ucell retain_phys;
+
+ OFMEM_TRACE("ofmem_retain phys=" FMT_ucellx " size=" FMT_ucellx
+ " align=" FMT_ucellx "\n",
+ phys, size, align);
+
+ retain_phys = ofmem_claim_phys_( phys, size, align, 0, get_ram_size(), 0 );
+
+ /* Also add to the retain_phys_range list */
+ add_entry( phys, size, &ofmem->retain_phys_range );
+
+ return retain_phys;
+}
/* allocate both physical and virtual space and add a translation */
ucell ofmem_claim( ucell addr, ucell size, ucell align )
More information about the OpenBIOS
mailing list