[OpenBIOS] [commit] r766 - in trunk/openbios-devel: arch/sparc64 include/libopenbios libopenbios

Nick Couchman Nick.Couchman at seakr.com
Mon May 3 04:13:17 CEST 2010


After the changes in this rev, I get the following trying to compile:

nick at nick0:/home/nick/Temp/openbios-devel> ./config/scripts/switch-arch cross-sparc64
Configuring OpenBIOS on amd64 for cross-sparc64
Initializing build tree obj-sparc64...ok.
Creating target Makefile...ok.
Creating config files...ok.
nick at nick0:/home/nick/Temp/openbios-devel> make
Building OpenBIOS for sparc32 sparc64
Building...ok.
error:
  GEN   target/include/static-dict.h
  CC    target/arch/sparc64/builtin.o
  CC    target/arch/sparc64/openbios.o
  CC    target/arch/sparc64/console.o
  CC    target/arch/sparc64/lib.o
  CC    target/arch/sparc64/boot.o
  CC    target/arch/sparc64/context.o
  CC    target/arch/sparc64/switch.o
  CC    target/arch/sparc64/linux_load.o
  CC    target/arch/sparc64/sys_info.o
  CC    target/arch/sparc64/ofmem_sparc64.o
../arch/sparc64/ofmem_sparc64.c: In function `ofmem_init':
../arch/sparc64/ofmem_sparc64.c:106: warning: comparison is always false due to limited range of data type
make[1]: *** [target/arch/sparc64/ofmem_sparc64.o] Error 1
make[1]: Leaving directory `/home/nick/Temp/openbios-devel/obj-sparc64'
make: *** [build] Error 1

I'm using gcc 3.4.5 cross-compilers with glibc 2.3.6.

-Nick

>>> repository service  05/02/10 1:27 PM >>>
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 

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 )

-- 
OpenBIOS                 http://openbios.org/
Mailinglist:  http://lists.openbios.org/mailman/listinfo
Free your System - May the Forth be with you



--------
This e-mail may contain confidential and privileged material for the sole use of the intended recipient.  If this email is not intended for you, or you are not responsible for the delivery of this message to the intended recipient, please note that this message may contain SEAKR Engineering (SEAKR) Privileged/Proprietary Information.  In such a case, you are strictly prohibited from downloading, photocopying, distributing or otherwise using this message, its contents or attachments in any way.  If you have received this message in error, please notify us immediately by replying to this e-mail and delete the message from your mailbox.  Information contained in this message that does not relate to the business of SEAKR is neither endorsed by nor attributable to SEAKR.



More information about the OpenBIOS mailing list