[SeaBIOS] [PATCH 13/13] Drop handle_post() from image for CSM build

David Woodhouse dwmw2 at infradead.org
Mon Jan 28 17:23:46 CET 2013


From: David Woodhouse <David.Woodhouse at intel.com>

This removes 25KiB of unused cruft from the image, crucially making the
difference between a 128KiB image (which works with OVMF) and a 256KiB
image (which doesn't).

Not-yet-signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 src/pirtable.c     |  2 +-
 src/romlayout.S    |  6 ++++++
 tools/layoutrom.py | 20 ++++++++++++--------
 3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/src/pirtable.c b/src/pirtable.c
index 2ba70ee..3c06db1 100644
--- a/src/pirtable.c
+++ b/src/pirtable.c
@@ -94,7 +94,7 @@ struct pir_table PIR_TABLE __aligned(16) VAR16EXPORT = {
 void
 pirtable_setup(void)
 {
-    if (! CONFIG_PIRTABLE || CONFIG_CSM)
+    if (! CONFIG_PIRTABLE)
         return;
 
     dprintf(3, "init PIR table\n");
diff --git a/src/romlayout.S b/src/romlayout.S
index 0c1cfb4..3176067 100644
--- a/src/romlayout.S
+++ b/src/romlayout.S
@@ -366,6 +366,7 @@ entry_bios32:
 2:      popfl
         lretl
 
+#if !CONFIG_CSM
 // 32bit elf entry point
         EXPORTFUNC entry_elf
 entry_elf:
@@ -381,6 +382,7 @@ entry_elf:
         movw %ax, %ss
         movl $BUILD_STACK_ADDR, %esp
         ljmpl $SEG32_MODE32_CS, $_cfunc32flat_handle_post
+#endif
 
         .code16gcc
 
@@ -526,9 +528,13 @@ entry_18:
 
         ORG 0xe05b
 entry_post:
+#if CONFIG_CSM
+        jmp entry_resume
+#else
         cmpl $0, %cs:HaveRunPost                // Check for resume/reboot
         jnz entry_resume
         ENTRY_INTO32 _cfunc32flat_handle_post   // Normal entry point
+#endif
 
         ORG 0xe2c3
         IRQ_ENTRY 02
diff --git a/tools/layoutrom.py b/tools/layoutrom.py
index 75c49be..eecb141 100755
--- a/tools/layoutrom.py
+++ b/tools/layoutrom.py
@@ -353,7 +353,6 @@ def writeLinkerScripts(li, entrysym, genreloc, exportsyms, out16, out32seg, out3
     # Write 32flat linker script
     sections32all = li.sections32flat + li.sections32init + li.sections32low
     sec32all_start = li.sec32low_start
-    entrysympos = entrysym.section.finalloc + entrysym.offset
     relocstr = ""
     if genreloc:
         # Generate relocations
@@ -371,8 +370,10 @@ def writeLinkerScripts(li, entrysym, genreloc, exportsyms, out16, out32seg, out3
                     + strRelocs("_reloc_datalow", "code32flat_start", lowrelocs))
         numrelocs = len(absrelocs + relrelocs + initrelocs + lowrelocs)
         sec32all_start -= numrelocs * 4
-    out = outXRefs(sections32all, exportsyms=exportsyms) + """
-    %s = 0x%x ;
+    out = outXRefs(sections32all, exportsyms=exportsyms)
+    if entrysym is not None:
+        out = out +  "%s = 0x%x ;\n" % ( entrysym.name, entrysym.section.finalloc + entrysym.offset )
+    out = out + """
     _reloc_min_align = 0x%x ;
     datalow_base = 0x%x ;
     final_datalow_start = 0x%x ;
@@ -393,8 +394,7 @@ def writeLinkerScripts(li, entrysym, genreloc, exportsyms, out16, out32seg, out3
         *(.text16)
         code32flat_end = ABSOLUTE(.) ;
     } :text
-""" % (entrysym.name, entrysympos,
-       li.sec32init_align,
+""" % (li.sec32init_align,
        li.datalow_base,
        li.final_sec32low_start,
        sec32all_start,
@@ -405,12 +405,13 @@ def writeLinkerScripts(li, entrysym, genreloc, exportsyms, out16, out32seg, out3
        li.sec32seg_start,
        li.sec16_start)
     out = COMMONHEADER + out + COMMONTRAILER + """
-ENTRY(%s)
 PHDRS
 {
         text PT_LOAD AT ( code32flat_start ) ;
 }
-""" % (entrysym.name,)
+"""
+    if entrysym is not None:
+        out = out + "\nENTRY(%s)\n" % entrysym.name
     outfile = open(out32flat, 'wb')
     outfile.write(out)
     outfile.close()
@@ -638,7 +639,10 @@ def main():
     li = doLayout(sections, genreloc)
 
     # Write out linker script files.
-    entrysym = info16[1]['entry_elf']
+    if 'entry_elf' in info16[1]:
+        entrysym = info16[1]['entry_elf']
+    else:
+        entrysym = None
     writeLinkerScripts(li, entrysym, genreloc, exportsyms, out16, out32seg, out32flat)
 
 if __name__ == '__main__':
-- 
1.8.0.2




More information about the SeaBIOS mailing list