[coreboot-gerrit] Patch set updated for coreboot: e69d707 arch/x86: Declare GDT symbols and move_gdt()

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Thu Dec 18 20:54:40 CET 2014


Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7858

-gerrit

commit e69d707dd818081864e6e5ecefb86fd6a4d2818e
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date:   Thu Dec 18 10:36:33 2014 +0200

    arch/x86: Declare GDT symbols and move_gdt()
    
    We relocate GDT to CBMEM, this can be done late in ramstage.
    Note: We currently do this for BSP CPU only.
    
    Change-Id: I626faaf22f846433f25ca2253d6a2a5230f50b6b
    Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
 src/arch/x86/boot/gdt.c            | 12 +++++-------
 src/arch/x86/boot/tables.c         |  2 +-
 src/cpu/x86/lapic/lapic_cpu_init.c |  7 +------
 src/cpu/x86/mp_init.c              |  5 +----
 src/include/cpu/x86/gdt.h          | 34 ++++++++++++++++++++++++++++++++++
 src/include/lib.h                  |  3 ---
 6 files changed, 42 insertions(+), 21 deletions(-)

diff --git a/src/arch/x86/boot/gdt.c b/src/arch/x86/boot/gdt.c
index 7ebf92a..7b64af7 100644
--- a/src/arch/x86/boot/gdt.c
+++ b/src/arch/x86/boot/gdt.c
@@ -20,12 +20,8 @@
 #include <types.h>
 #include <string.h>
 #include <cbmem.h>
-#include <lib.h>
 #include <console/console.h>
-
-// Global Descriptor Table, defined in c_start.S
-extern char gdt;
-extern char gdt_end;
+#include <cpu/x86/gdt.h>
 
 /* i386 lgdt argument */
 struct gdtarg {
@@ -33,11 +29,13 @@ struct gdtarg {
 	u32 base;
 } __attribute__((packed));
 
-// Copy GDT to new location and reload it
+/* Copy GDT to new location and reload it.
+ * FIXME: We only do this for BSP CPU.
+ */
 void move_gdt(void)
 {
 	void *newgdt;
-	u16 num_gdt_bytes = &gdt_end - &gdt;
+	u16 num_gdt_bytes = (u32)&gdt_end - (u32)&gdt;
 	struct gdtarg gdtarg;
 
 	newgdt = cbmem_find(CBMEM_ID_GDT);
diff --git a/src/arch/x86/boot/tables.c b/src/arch/x86/boot/tables.c
index 9f2afd4..8685ed4 100644
--- a/src/arch/x86/boot/tables.c
+++ b/src/arch/x86/boot/tables.c
@@ -21,6 +21,7 @@
 
 #include <console/console.h>
 #include <cpu/cpu.h>
+#include <cpu/x86/gdt.h>
 #include <boot/tables.h>
 #include <boot/coreboot_tables.h>
 #include <arch/pirq_routing.h>
@@ -28,7 +29,6 @@
 #include <arch/acpi.h>
 #include <string.h>
 #include <cbmem.h>
-#include <lib.h>
 #include <smbios.h>
 
 
diff --git a/src/cpu/x86/lapic/lapic_cpu_init.c b/src/cpu/x86/lapic/lapic_cpu_init.c
index 61b6bd7..472d6ed 100644
--- a/src/cpu/x86/lapic/lapic_cpu_init.c
+++ b/src/cpu/x86/lapic/lapic_cpu_init.c
@@ -21,6 +21,7 @@
  */
 
 #include <cpu/x86/cr.h>
+#include <cpu/x86/gdt.h>
 #include <cpu/x86/lapic.h>
 #include <delay.h>
 #include <halt.h>
@@ -53,11 +54,6 @@ char *lowmem_backup_ptr;
 int  lowmem_backup_size;
 #endif
 
-extern char _secondary_start[];
-extern char _secondary_gdt_addr[];
-extern char gdt[];
-extern char gdt_end[];
-
 static inline void setup_secondary_gdt(void)
 {
 	u16 *gdt_limit;
@@ -72,7 +68,6 @@ static inline void setup_secondary_gdt(void)
 
 static void copy_secondary_start_to_lowest_1M(void)
 {
-	extern char _secondary_start_end[];
 	unsigned long code_size;
 
 	/* Fill in secondary_start's local gdt. */
diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c
index a97a4c5..3e293f6 100644
--- a/src/cpu/x86/mp_init.c
+++ b/src/cpu/x86/mp_init.c
@@ -26,6 +26,7 @@
 #include <cpu/cpu.h>
 #include <cpu/intel/microcode.h>
 #include <cpu/x86/cache.h>
+#include <cpu/x86/gdt.h>
 #include <cpu/x86/lapic.h>
 #include <cpu/x86/name.h>
 #include <cpu/x86/msr.h>
@@ -67,10 +68,6 @@ struct saved_msr {
 
 /* The sipi vector rmodule is included in the ramstage using 'objdump -B'. */
 extern char _binary_sipi_vector_start[];
-/* These symbols are defined in c_start.S. */
-extern char gdt[];
-extern char gdt_end[];
-extern char idtarg[];
 
 /* The SIPI vector is loaded at the SMM_DEFAULT_BASE. The reason is at the
  * memory range is already reserved so the OS cannot use it. That region is
diff --git a/src/include/cpu/x86/gdt.h b/src/include/cpu/x86/gdt.h
new file mode 100644
index 0000000..260b158
--- /dev/null
+++ b/src/include/cpu/x86/gdt.h
@@ -0,0 +1,34 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef CPU_X86_GDT
+#define CPU_X86_GDT
+
+/* These symbols are defined in c_start.S. */
+extern char gdt[];
+extern char gdt_end[];
+extern char idtarg[];
+
+/* These symbols are defined in secondary.S. */
+extern char _secondary_gdt_addr[];
+extern char _secondary_start[];
+extern char _secondary_start_end[];
+
+/* Defined in src/arch/x86/boot/gdt.c */
+void move_gdt(void);
+
+#endif /* CPU_X86_GDT */
diff --git a/src/include/lib.h b/src/include/lib.h
index 8f02004..772a66f 100644
--- a/src/include/lib.h
+++ b/src/include/lib.h
@@ -33,9 +33,6 @@ unsigned long log2_ceil(unsigned long x);
 /* Defined in src/lib/lzma.c */
 unsigned long ulzma(unsigned char *src, unsigned char *dst);
 
-/* Defined in src/arch/x86/boot/gdt.c */
-void move_gdt(void);
-
 /* Defined in src/lib/ramtest.c */
 void ram_check(unsigned long start, unsigned long stop);
 int ram_check_nodie(unsigned long start, unsigned long stop);



More information about the coreboot-gerrit mailing list