[coreboot] New patch to review for coreboot: 58e2e5b rmodule: add ramstage support

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Tue Mar 19 01:58:52 CET 2013


Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2786

-gerrit

commit 58e2e5b399791b0a5a5a543de8e5a27ebfeb5850
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Wed Feb 6 15:47:31 2013 -0600

    rmodule: add ramstage support
    
    Coreboot's ramstage defines certain sections/symbols in its fixed
    static linker script. It uses these sections/symbols for locating the
    drivers as well as its own program information.  Add these sections
    and symbols to the rmodule linker script so that ramstage can be
    linked as an rmodule. These sections and symbols are a noop for other
    rmodule-linked programs, but they are vital to the ramstage.
    
    Also add a comment in coreboot_ram.ld to mirror any changes made there
    to the rmodule linker script.
    
    Change-Id: Ib9885a00e987aef0ee1ae34f1d73066e15bca9b1
    Signed-off-by: Aaron Durbin <adurbin at chromium.org>
---
 src/arch/x86/coreboot_ram.ld |  5 +++++
 src/include/rmodule.h        |  9 +++++----
 src/lib/rmodule.ld           | 28 +++++++++++++++++++++++++---
 3 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/src/arch/x86/coreboot_ram.ld b/src/arch/x86/coreboot_ram.ld
index d9f0909..2dd51d5 100644
--- a/src/arch/x86/coreboot_ram.ld
+++ b/src/arch/x86/coreboot_ram.ld
@@ -50,6 +50,10 @@ SECTIONS
 	.rodata : {
 		_rodata = .;
 		. = ALIGN(4);
+
+		/* If any changes are made to the driver start/symbols or the
+		 * section names the equivalent changes need to made to
+		 * rmodule.ld. */
 		console_drivers = .;
 		*(.rodata.console_drivers)
 		econsole_drivers = . ;
@@ -60,6 +64,7 @@ SECTIONS
 		cpu_drivers = . ;
 		*(.rodata.cpu_driver)
 		ecpu_drivers = . ;
+
 		*(.rodata)
 		*(.rodata.*)
 		/* kevinh/Ispiri - Added an align, because the objcopy tool
diff --git a/src/include/rmodule.h b/src/include/rmodule.h
index 30eee0e..5300c63 100644
--- a/src/include/rmodule.h
+++ b/src/include/rmodule.h
@@ -27,6 +27,7 @@
 enum {
 	RMODULE_TYPE_SMM,
 	RMODULE_TYPE_SIPI_VECTOR,
+	RMODULE_TYPE_STAGE,
 };
 
 struct rmodule;
@@ -58,8 +59,8 @@ int rmodule_load_alignment(const struct rmodule *m);
 	.module_entry_point = FIELD_ENTRY(entry_),			\
 	.parameters_begin = FIELD_ENTRY(_module_params_begin),		\
 	.parameters_end = FIELD_ENTRY(_module_params_end),		\
-	.bss_begin = FIELD_ENTRY(_bss_begin),				\
-	.bss_end = FIELD_ENTRY(_bss_end),				\
+	.bss_begin = FIELD_ENTRY(_bss),					\
+	.bss_end = FIELD_ENTRY(_ebss),					\
 }
 
 #define DEFINE_RMODULE_HEADER(name_, entry_, type_) \
@@ -119,8 +120,8 @@ extern char _relocations_begin_offset[];
 extern char _relocations_end_offset[];
 extern char _payload_end_offset[];
 extern char _payload_begin_offset[];
-extern char _bss_begin[];
-extern char _bss_end[];
+extern char _bss[];
+extern char _ebss[];
 extern char _module_program_size[];
 extern char _module_link_start_addr[];
 extern char _module_params_begin[];
diff --git a/src/lib/rmodule.ld b/src/lib/rmodule.ld
index fdee279..c8bd297 100644
--- a/src/lib/rmodule.ld
+++ b/src/lib/rmodule.ld
@@ -41,6 +41,22 @@ SECTIONS
 		*(.text.*);
 		/* C read-only data. */
 		. = ALIGN(16);
+
+		/* The driver sections are to allow linking coreboot's
+		 * ramstage with the rmodule linker. Any changes made in
+		 * coreboot_ram.ld should be made here as well. */
+		console_drivers = .;
+		*(.rodata.console_drivers)
+		econsole_drivers = . ;
+		. = ALIGN(4);
+		pci_drivers = . ;
+		*(.rodata.pci_driver)
+		epci_drivers = . ;
+		cpu_drivers = . ;
+		*(.rodata.cpu_driver)
+		ecpu_drivers = . ;
+		. = ALIGN(4);
+
 		*(.rodata);
 		*(.rodata.*);
 		. = ALIGN(4);
@@ -67,13 +83,13 @@ SECTIONS
 	_payload_end_offset = LOADADDR(.data) + SIZEOF(.data);
 
 	.bss (NOLOAD) : {
-		/* C uninitialized data of the SMM handler */
-		_bss_begin = .;
+		/* C uninitialized data of the module. */
+		_bss = .;
 		*(.bss);
 		*(.sbss);
 		*(COMMON);
 		. = ALIGN(8);
-		_bss_end = .;
+		_ebss = .;
 
 		/*
 		 * Place the heap after BSS. The heap size is passed in by
@@ -87,6 +103,12 @@ SECTIONS
 	/* _module_program_size is the total memory used by the program. */
 	_module_program_size = _eheap - _module_link_start_addr;
 
+	/* coreboot's ramstage uses the _ram_seg and _eram_seg symbols
+	 * for determining its load location. Provide those to help it out.
+	 * It's a nop for any non-ramstage rmodule. */
+	_ram_seg = _module_link_start_addr;
+	_eram_seg = _module_link_start_addr + _module_program_size;
+
 	/* The relocation information is linked on top of the BSS section
 	 * because the BSS section takes no space on disk. The relocation data
 	 * resides directly after the data section in the flat binary. */



More information about the coreboot mailing list