summaryrefslogtreecommitdiffstats
path: root/arch/x86/lib/gdt.c
diff options
context:
space:
mode:
authorJuergen Beisert <jbe@pengutronix.de>2010-01-12 11:15:40 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2010-01-14 10:06:15 +0100
commit2bdd75bd02f3d214b285429be72b3a0eab4e9610 (patch)
treea5f10a6e4221d2e5ce3716c2518d1de1e4fc3666 /arch/x86/lib/gdt.c
parentc7f2adaf7dfd9b752972a5ebf48baf30684106cc (diff)
downloadbarebox-2bdd75bd02f3d214b285429be72b3a0eab4e9610.tar.gz
barebox-2bdd75bd02f3d214b285429be72b3a0eab4e9610.tar.xz
Add some generic functions to make x86 work
Add some generic functions to make barebox work on x86. Signed-off-by: Juergen Beisert <jbe@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/x86/lib/gdt.c')
-rw-r--r--arch/x86/lib/gdt.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/arch/x86/lib/gdt.c b/arch/x86/lib/gdt.c
new file mode 100644
index 0000000000..a9c4d0e9dd
--- /dev/null
+++ b/arch/x86/lib/gdt.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2009 Juergen Beisert, Pengutronix
+ *
+ * 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; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+
+/**
+ * @file
+ * @brief Definition of the Global Descriptor Table
+ */
+
+#include <types.h>
+#include <asm/modes.h>
+#include <asm/segment.h>
+
+/**
+ * The 'Global Descriptor Table' used in barebox
+ *
+ * Note: This table must reachable by real and flat mode code
+ */
+uint64_t gdt[] __attribute__((aligned(16))) __bootdata = {
+ /* CS: code, read/execute, 4 GB, base 0 */
+ [GDT_ENTRY_BOOT_CS] = GDT_ENTRY(0xc09b, 0, 0xfffff),
+ /* DS: data, read/write, 4 GB, base 0 */
+ [GDT_ENTRY_BOOT_DS] = GDT_ENTRY(0xc093, 0, 0xfffff),
+ /* CS: for real mode calls */
+ [GDT_ENTRY_REAL_CS] = GDT_ENTRY(0x009E, 0, 0x0ffff),
+ /* DS: for real mode calls */
+ [GDT_ENTRY_REAL_DS] = GDT_ENTRY(0x0092, 0, 0x0ffff),
+ /* TSS: 32-bit tss, 104 bytes, base 4096 */
+ /* We only have a TSS here to keep Intel VT happy;
+ we don't actually use it for anything. */
+ [GDT_ENTRY_BOOT_TSS] = GDT_ENTRY(0x0089, 4096, 103),
+};
+
+/**
+ * Size of the GDT must be known to load it
+ *
+ * Note: This varibale must reachable by real and flat mode code
+ */
+unsigned gdt_size __bootdata = sizeof(gdt);