2N/A/*
2N/A * GRUB -- GRand Unified Bootloader
2N/A * Copyright (C) 2009,2010 Free Software Foundation, Inc.
2N/A *
2N/A * GRUB is free software: you can redistribute it and/or modify
2N/A * it under the terms of the GNU General Public License as published by
2N/A * the Free Software Foundation, either version 3 of the License, or
2N/A * (at your option) any later version.
2N/A *
2N/A * GRUB is distributed in the hope that it will be useful,
2N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
2N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2N/A * GNU General Public License for more details.
2N/A *
2N/A * You should have received a copy of the GNU General Public License
2N/A * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
2N/A */
2N/A
2N/A
2N/A#include <grub/symbol.h>
2N/A#include <grub/i386/memory.h>
2N/A
2N/A#ifdef __x86_64__
2N/A#define RAX %rax
2N/A#define RSI %rsi
2N/A#else
2N/A#define RAX %eax
2N/A#define RSI %esi
2N/A#endif
2N/A
2N/A .macro DISABLE_PAGING
2N/A#ifdef GRUB_MACHINE_IEEE1275
2N/A#endif
2N/A
2N/A movl %cr0, %eax
2N/A andl $(~GRUB_MEMORY_CPU_CR0_PAGING_ON), %eax
2N/A movl %eax, %cr0
2N/A .endm
2N/A
2N/A .macro PREAMBLE
2N/ALOCAL(base):
2N/A /* %rax contains now our new 'base'. */
2N/A mov RAX, RSI
2N/A
2N/A add $(LOCAL(cont0) - LOCAL(base)), RAX
2N/A jmp *RAX
2N/ALOCAL(cont0):
2N/A .endm
2N/A
2N/A .macro RELOAD_GDT
2N/A lea (LOCAL(cont1) - LOCAL(base)) (RSI, 1), RAX
2N/A movl %eax, (LOCAL(jump_vector) - LOCAL(base)) (RSI, 1)
2N/A
2N/A lea (LOCAL(gdt) - LOCAL(base)) (RSI, 1), RAX
2N/A mov RAX, (LOCAL(gdt_addr) - LOCAL(base)) (RSI, 1)
2N/A
2N/A /* Switch to compatibility mode. */
2N/A lgdt (LOCAL(gdtdesc) - LOCAL(base)) (RSI, 1)
2N/A
2N/A /* Update %cs. */
2N/A ljmp *(LOCAL(jump_vector) - LOCAL(base)) (RSI, 1)
2N/A
2N/A .p2align 4
2N/ALOCAL(gdtdesc):
2N/A .word LOCAL(gdt_end) - LOCAL(gdt)
2N/ALOCAL(gdt_addr):
2N/A#ifdef __x86_64__
2N/A /* Filled by the code. */
2N/A .quad 0
2N/A#else
2N/A /* Filled by the code. */
2N/A .long 0
2N/A#endif
2N/A
2N/A .p2align 4
2N/ALOCAL(jump_vector):
2N/A /* Jump location. Is filled by the code */
2N/A .long 0
2N/A .long CODE_SEGMENT
2N/A
2N/ALOCAL(cont1):
2N/A .endm