qemu: Fix compilation

This commit is contained in:
Vladimir Serbinenko 2015-02-21 19:55:53 +01:00
parent 44ff462e83
commit e62ca2a870
2 changed files with 20 additions and 2 deletions

View file

@ -48,7 +48,7 @@ VARIABLE(grub_core_entry_addr)
/* Transition to protected mode. We use pushl to force generation /* Transition to protected mode. We use pushl to force generation
of a flat return address. */ of a flat return address. */
pushl $1f pushl $1f
jmpl real_to_prot jmp real_to_prot
.code32 .code32
/* Ensure A20 is enabled. We're in qemu, so control port A works /* Ensure A20 is enabled. We're in qemu, so control port A works
and there is no need to wait since there is no real logic, it's and there is no need to wait since there is no real logic, it's

View file

@ -137,7 +137,22 @@ real_to_prot:
/* load the GDT register */ /* load the GDT register */
xorw %ax, %ax xorw %ax, %ax
movw %ax, %ds movw %ax, %ds
#ifdef GRUB_MACHINE_QEMU
/*
qemu is special: gdtdesc is in ROM.
%cs = 0xf000
_start + GRUB_BOOT_MACHINE_SIZE = 0x100000
So
_start + GRUB_BOOT_MACHINE_SIZE - 0x10000 points to the same point
as %cs.
gdtdesc - (_start + GRUB_BOOT_MACHINE_SIZE - 0x10000)
= gdtdesc - _start - GRUB_BOOT_MACHINE_SIZE + 0x10000
but the later can be computed by assembly.
*/
lgdtl %cs:(gdtdesc - _start - GRUB_BOOT_MACHINE_SIZE + 0x10000)
#else
lgdtl gdtdesc lgdtl gdtdesc
#endif
/* turn on protected mode */ /* turn on protected mode */
movl %cr0, %eax movl %cr0, %eax
@ -178,6 +193,9 @@ protcseg:
/* return on the old (or initialized) stack! */ /* return on the old (or initialized) stack! */
ret ret
/* prot_to_real assumes that this code is under 64K which is not
true for qemu. */
#ifndef GRUB_MACHINE_QEMU
/* /*
* GRUB -- GRand Unified Bootloader * GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2009,2010 Free Software Foundation, Inc. * Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2009,2010 Free Software Foundation, Inc.
@ -259,5 +277,5 @@ realcseg:
/* return on new stack! */ /* return on new stack! */
retl retl
#endif
.code32 .code32