2N/A * GRUB -- GRand Unified Bootloader 2N/A * Copyright (C) 2009,2010 Free Software Foundation, Inc. 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 * 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 * You should have received a copy of the GNU General Public License 2N/A/* The code segment of the protected mode. */ 2N/A/* The data segment of the protected mode. */ 2N/A#
include "relocator_common.S" 2N/A /* Update other registers. */ 2N/A /* Disable amd64. */ 2N/A /* Update other registers. */ 2N/A /* jump to a 16 bit segment */ 2N/A /* clear the PE bit of CR0 */ 2N/A /* flush prefetch queue, reload %cs */ 2N/A /* movw imm16, %ax. */ 2N/A /* first of all, test if already in a good state */ 2N/A /* second, try a BIOS call */ 2N/A * In macbook, the keyboard test would hang the machine, so we move 2N/A /* fourth, try the system control port A */ 2N/A /* When turning off Gate A20, do not check the state strictly, 2N/A because a failure is not fatal usually, and Gate A20 is always 2N/A on some modern machines. */ 2N/A /* iterate the checking for a while */ 2N/A /* compare the byte at ADDR with that at 0x100000 + ADDR */ 2N/A /* save the original byte in DL */ 2N/A /* try to set one less value at ADDR */ 2N/A /* obtain the value at 0x100000 + ADDR in CH */ 2N/A /* this result is 1 if A20 is on or 0 if it is off */ 2N/A /* restore the original */ 2N/A /* we are in real mode now 2N/A * set up the real mode segment registers : DS, SS, ES 2N/A /* movw imm16, %ax. */ 2N/A /* movw imm16, %ax. */ 2N/A /* movw imm16, %ax. */ 2N/A /* movw imm16, %ax. */ 2N/A /* movw imm16, %ax. */ 2N/A /* movw imm16, %ax. */ 2N/A /* movw imm32, %eax. */ 2N/A /* movw imm32, %edx. */ 2N/A /* movw imm32, %ebx. */ 2N/A /* Cleared direction flag is of no problem with any current 2N/A payload and makes this implementation easier. */ 2N/A /* -- code segment -- 2N/A * base = 0x00000000, limit = 0xFFFFF (4 KiB Granularity), present 2N/A /* -- data segment -- 2N/A * base = 0x00000000, limit 0xFFFFF (4 KiB Granularity), present 2N/A /* -- 16 bit real mode CS -- 2N/A * base = 0x00000000, limit 0x0FFFF (1 B Granularity), present 2N/A /* -- 16 bit real mode DS -- 2N/A * base = 0x00000000, limit 0x0FFFF (1 B Granularity), present