2 * This file is part of the coreboot project.
4 * Copyright (C) 2008-2009 coresystems GmbH
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <console/console.h>
26 // Global Descriptor Table, defined in c_start.S
30 /* i386 lgdt argument */
34 } __attribute__((packed));
36 // Copy GDT to new location and reload it
40 u16 num_gdt_bytes = &gdt_end - &gdt;
43 newgdt = cbmem_find(CBMEM_ID_GDT);
45 newgdt = cbmem_add(CBMEM_ID_GDT, ALIGN(num_gdt_bytes, 512));
47 printk(BIOS_ERR, "Error: Could not relocate GDT.\n");
50 printk_debug("Moving GDT to %p...", newgdt);
51 memcpy((void*)newgdt, &gdt, num_gdt_bytes);
54 gdtarg.base = (u32)newgdt;
55 gdtarg.limit = num_gdt_bytes - 1;
57 __asm__ __volatile__ ("lgdt %0\n\t" : : "m" (gdtarg));