[SeaBIOS] [PATCH 10/10] build: Get fixed address variables from 32bit compile pass (not 16bit)

Kevin O'Connor kevin at koconnor.net
Wed Jun 11 21:24:50 CEST 2014


Update the layoutrom.py build script so that fixed address sections
can come from the 32bit compiled C code.  Update the C code so that
all VAR16FIXED variables instead use the new VARFSEGFIXED which is
defined in 32bit mode.

Signed-off-by: Kevin O'Connor <kevin at koconnor.net>
---
 Makefile             | 11 ++++++-----
 scripts/layoutrom.py |  8 +++++---
 src/font.c           |  2 +-
 src/misc.c           | 18 +++++++++---------
 src/types.h          |  8 ++++----
 5 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/Makefile b/Makefile
index e095601..e492f80 100644
--- a/Makefile
+++ b/Makefile
@@ -27,17 +27,18 @@ IASL:=iasl
 LD32BIT_FLAG:=-melf_i386
 
 # Source files
-SRCBOTH=misc.c stacks.c output.c string.c x86.c block.c cdrom.c mouse.c kbd.c \
-    serial.c clock.c resume.c pnpbios.c vgahooks.c pcibios.c apm.c \
+SRCBOTH=misc.c stacks.c output.c string.c x86.c block.c cdrom.c \
+    system.c disk.c mouse.c kbd.c serial.c clock.c resume.c \
+    pnpbios.c vgahooks.c pcibios.c apm.c \
     hw/pci.c hw/timer.c hw/rtc.c hw/dma.c hw/pic.c hw/ps2port.c hw/serialio.c \
     hw/usb.c hw/usb-uhci.c hw/usb-ohci.c hw/usb-ehci.c \
     hw/usb-hid.c hw/usb-msc.c hw/usb-uas.c \
     hw/blockcmd.c hw/floppy.c hw/ata.c hw/ramdisk.c \
     hw/virtio-ring.c hw/virtio-pci.c hw/virtio-blk.c hw/virtio-scsi.c \
     hw/lsi-scsi.c hw/esp-scsi.c hw/megasas.c
-SRC16=$(SRCBOTH) system.c disk.c font.c
-SRC32FLAT=$(SRCBOTH) post.c memmap.c malloc.c pmm.c romfile.c optionroms.c \
-    boot.c bootsplash.c jpeg.c bmp.c \
+SRC16=$(SRCBOTH)
+SRC32FLAT=$(SRCBOTH) post.c memmap.c malloc.c romfile.c optionroms.c \
+    pmm.c font.c boot.c bootsplash.c jpeg.c bmp.c \
     hw/ahci.c hw/pvscsi.c hw/usb-xhci.c hw/usb-hub.c \
     fw/coreboot.c fw/lzmadecode.c fw/csm.c fw/biostables.c \
     fw/paravirt.c fw/shadow.c fw/pciinit.c fw/smm.c fw/smp.c fw/mtrr.c fw/xen.c \
diff --git a/scripts/layoutrom.py b/scripts/layoutrom.py
index ba557e6..bd90706 100755
--- a/scripts/layoutrom.py
+++ b/scripts/layoutrom.py
@@ -179,7 +179,7 @@ def doLayout(sections, config, genreloc):
     textsections = getSectionsPrefix(sections16, '.text.')
     rodatasections = getSectionsPrefix(sections16, '.rodata')
     datasections = getSectionsPrefix(sections16, '.data16.')
-    fixedsections = getSectionsPrefix(sections16, '.fixedaddr.')
+    fixedsections = getSectionsCategory(sections, 'fixed')
 
     firstfixed = fitSections(fixedsections, textsections)
     remsections = [s for s in textsections+rodatasections+datasections
@@ -643,7 +643,7 @@ def main():
     else:
         entrysym = symbols['16'].get('reset_vector')
     anchorsections = [entrysym.section] + [
-        section for section in info16[0]
+        section for section in allsections
         if section.name.startswith('.fixedaddr.')]
     keepsections = findReachable(anchorsections, checkKeep, symbols)
     sections = [section for section in allsections if section in keepsections]
@@ -652,13 +652,15 @@ def main():
     anchorsections = [
         section for section in sections
         if ('.data.varlow.' in section.name or '.data.varfseg.' in section.name
-            or '.runtime.' in section.name)]
+            or '.fixedaddr.' in section.name or '.runtime.' in section.name)]
     runtimesections = findReachable(anchorsections, checkRuntime, None)
     for section in sections:
         if section.name.startswith('.data.varlow.'):
             section.category = '32low'
         elif section.name.startswith('.data.varfseg.'):
             section.category = '32fseg'
+        elif section.name.startswith('.fixedaddr.'):
+            section.category = 'fixed'
         elif section.fileid == '32flat' and section not in runtimesections:
             section.category = '32init'
         else:
diff --git a/src/font.c b/src/font.c
index 3f8662f..67e5d46 100644
--- a/src/font.c
+++ b/src/font.c
@@ -7,7 +7,7 @@
  * found at ftp://ftp.simtel.net/pub/simtelnet/msdos/screen/fntcol16.zip
  * This font is public domain
  */
-u8 vgafont8[128*8] VAR16FIXED(0xfa6e) = {
+u8 vgafont8[128*8] VARFSEGFIXED(0xfa6e) = {
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e,
     0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e,
diff --git a/src/misc.c b/src/misc.c
index 889064a..8caaf31 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -117,7 +117,7 @@ handle_75(void)
 // INT 16/AH=09h (keyboard functionality) supported
 #define CBT_F2_INT1609  (1<<6)
 
-struct bios_config_table_s BIOS_CONFIG_TABLE VAR16FIXED(0xe6f5) = {
+struct bios_config_table_s BIOS_CONFIG_TABLE VARFSEGFIXED(0xe6f5) = {
     .size     = sizeof(BIOS_CONFIG_TABLE) - 2,
     .model    = BUILD_MODEL_ID,
     .submodel = BUILD_SUBMODEL_ID,
@@ -182,22 +182,22 @@ struct descloc_s rombios32_gdt_48 VARFSEG = {
  ****************************************************************/
 
 // BIOS build date
-char BiosDate[] VAR16FIXED(0xfff5) = "06/23/99";
+char BiosDate[] VARFSEGFIXED(0xfff5) = "06/23/99";
 
-u8 BiosModelId VAR16FIXED(0xfffe) = BUILD_MODEL_ID;
+u8 BiosModelId VARFSEGFIXED(0xfffe) = BUILD_MODEL_ID;
 
-u8 BiosChecksum VAR16FIXED(0xffff);
+u8 BiosChecksum VARFSEGFIXED(0xffff);
 
-struct floppy_dbt_s diskette_param_table VAR16FIXED(0xefc7);
+struct floppy_dbt_s diskette_param_table VARFSEGFIXED(0xefc7);
 
 // Old Fixed Disk Parameter Table (newer tables are in the ebda).
-struct fdpt_s OldFDPT VAR16FIXED(0xe401);
+struct fdpt_s OldFDPT VARFSEGFIXED(0xe401);
 
 // XXX - Baud Rate Generator Table
-u8 BaudTable[16] VAR16FIXED(0xe729);
+u8 BaudTable[16] VARFSEGFIXED(0xe729);
 
 // XXX - Initial Interrupt Vector Offsets Loaded by POST
-u8 InitVectors[13] VAR16FIXED(0xfef3);
+u8 InitVectors[13] VARFSEGFIXED(0xfef3);
 
 // XXX - INT 1D - SYSTEM DATA - VIDEO PARAMETER TABLES
-u8 VideoParams[88] VAR16FIXED(0xf0a4);
+u8 VideoParams[88] VARFSEGFIXED(0xf0a4);
diff --git a/src/types.h b/src/types.h
index 3466b3a..097372c 100644
--- a/src/types.h
+++ b/src/types.h
@@ -62,14 +62,14 @@ extern void __force_link_error__only_in_16bit(void) __noreturn;
 # define VISIBLE32SEG
 // Designate a variable as (only) visible to 16bit code.
 # define VAR16 __section(".data16." UNIQSEC)
-// Designate a variable at a specific 16bit address
-# define VAR16FIXED(addr) __aligned(1) __VISIBLE __section(".fixedaddr." __stringify(addr))
 // Designate a variable as (only) visible to 32bit segmented code.
 # define VAR32SEG __section(".discard.var32seg." UNIQSEC)
 // Designate a variable as visible and located in the e-segment.
 # define VARLOW __section(".discard.varlow." UNIQSEC) __VISIBLE __weak
 // Designate a variable as visible and located in the f-segment.
 # define VARFSEG __section(".discard.varfseg." UNIQSEC) __VISIBLE __weak
+// Designate a variable at a specific address in the f-segment.
+# define VARFSEGFIXED(addr) __section(".discard.varfixed." UNIQSEC) __VISIBLE __weak
 // Verify a variable is only accessable via 32bit "init" functions
 # define VARVERIFY32INIT __section(".discard.varinit." UNIQSEC)
 // Designate top-level assembler as 16bit only.
@@ -86,10 +86,10 @@ extern void __force_link_error__only_in_16bit(void) __noreturn;
 # define VISIBLE32INIT
 # define VISIBLE32SEG __VISIBLE
 # define VAR16 __section(".discard.var16." UNIQSEC)
-# define VAR16FIXED(addr) VAR16 __VISIBLE __weak
 # define VAR32SEG __section(".data32seg." UNIQSEC)
 # define VARLOW __section(".discard.varlow." UNIQSEC) __VISIBLE __weak
 # define VARFSEG __section(".discard.varfseg." UNIQSEC) __VISIBLE __weak
+# define VARFSEGFIXED(addr) __section(".discard.varfixed." UNIQSEC) __VISIBLE __weak
 # define VARVERIFY32INIT __section(".discard.varinit." UNIQSEC)
 # define ASM16(code)
 # define ASM32FLAT(code)
@@ -102,10 +102,10 @@ extern void __force_link_error__only_in_16bit(void) __noreturn;
 # define VISIBLE32INIT __section(".text.init." UNIQSEC) __VISIBLE
 # define VISIBLE32SEG
 # define VAR16 __section(".discard.var16." UNIQSEC)
-# define VAR16FIXED(addr) VAR16 __VISIBLE __weak
 # define VAR32SEG __section(".discard.var32seg." UNIQSEC)
 # define VARLOW __section(".data.varlow." UNIQSEC) __VISIBLE __weak
 # define VARFSEG __section(".data.varfseg." UNIQSEC) __VISIBLE
+# define VARFSEGFIXED(addr) __section(".fixedaddr." __stringify(addr)) __VISIBLE __aligned(1)
 # define VARVERIFY32INIT __section(".data.varinit." UNIQSEC)
 # define ASM16(code)
 # define ASM32FLAT(code) __ASM(code)
-- 
1.9.3




More information about the SeaBIOS mailing list