merge mainline into backtrace

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-11-14 10:50:24 +01:00
commit 245f4582f9
871 changed files with 102908 additions and 16407 deletions

View file

@ -19,6 +19,7 @@
#include <grub/cpu/io.h>
#include <grub/misc.h>
#include <grub/acpi.h>
#include <grub/i18n.h>
const char bochs_shutdown[] = "Shutdown";
@ -52,7 +53,7 @@ grub_halt (void)
for (i = 0; i < sizeof (bochs_shutdown) - 1; i++)
grub_outb (bochs_shutdown[i], 0x8900);
grub_printf ("GRUB doesn't know how to halt this machine yet!\n");
grub_puts_ (N_("GRUB doesn't know how to halt this machine yet!"));
/* In order to return we'd have to check what the previous status of IF
flag was. But user most likely doesn't want to return anyway ... */

View file

@ -19,11 +19,12 @@
#include <grub/env.h>
#include <grub/misc.h>
#include <grub/disk.h>
#include <grub/machine/biosnum.h>
static int
grub_get_root_biosnumber_default (void)
{
char *biosnum;
const char *biosnum;
int ret = -1;
grub_device_t dev;

View file

@ -0,0 +1,127 @@
#include <grub/i386/pc/vesa_modes_table.h>
/* This is the reverse of the table in [linux]/Documentation/fb/vesafb.txt
plus a few more modes based on the table in
http://en.wikipedia.org/wiki/VESA_BIOS_Extensions */
struct grub_vesa_mode_table_entry
grub_vesa_mode_table[GRUB_VESA_MODE_TABLE_END
- GRUB_VESA_MODE_TABLE_START + 1] =
{
{ 640, 400, 8 }, /* 0x300 */
{ 640, 480, 8 }, /* 0x301 */
{ 800, 600, 4 }, /* 0x302 */
{ 800, 600, 8 }, /* 0x303 */
{ 1024, 768, 4 }, /* 0x304 */
{ 1024, 768, 8 }, /* 0x305 */
{ 1280, 1024, 4 }, /* 0x306 */
{ 1280, 1024, 8 }, /* 0x307 */
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 320, 200, 15 }, /* 0x30d */
{ 320, 200, 16 }, /* 0x30e */
{ 320, 200, 24 }, /* 0x30f */
{ 640, 480, 15 }, /* 0x310 */
{ 640, 480, 16 }, /* 0x311 */
{ 640, 480, 24 }, /* 0x312 */
{ 800, 600, 15 }, /* 0x313 */
{ 800, 600, 16 }, /* 0x314 */
{ 800, 600, 24 }, /* 0x315 */
{ 1024, 768, 15 }, /* 0x316 */
{ 1024, 768, 16 }, /* 0x317 */
{ 1024, 768, 24 }, /* 0x318 */
{ 1280, 1024, 15 }, /* 0x319 */
{ 1280, 1024, 16 }, /* 0x31a */
{ 1280, 1024, 24 }, /* 0x31b */
{ 1600, 1200, 8 }, /* 0x31c */
{ 1600, 1200, 15 }, /* 0x31d */
{ 1600, 1200, 16 }, /* 0x31e */
{ 1600, 1200, 24 }, /* 0x31f */
{ 0, 0, 0 },
{ 640, 400, 15 }, /* 0x321 */
{ 640, 400, 16 }, /* 0x322 */
{ 640, 400, 24 }, /* 0x323 */
{ 640, 400, 32 }, /* 0x324 */
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 640, 480, 32 }, /* 0x329 */
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 896, 672, 8 }, /* 0x32f */
{ 896, 672, 15 }, /* 0x330 */
{ 896, 672, 16 }, /* 0x331 */
{ 896, 672, 24 }, /* 0x332 */
{ 896, 672, 32 }, /* 0x333 */
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 1600, 1200, 32 }, /* 0x342 */
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 1440, 900, 8 }, /* 0x360 */
{ 1440, 900, 15 }, /* 0x361 */
{ 1440, 900, 16 }, /* 0x362 */
{ 1440, 900, 24 }, /* 0x363 */
{ 1440, 900, 32 }, /* 0x364 */
{ 1152, 720, 8 }, /* 0x365 */
{ 1152, 720, 15 }, /* 0x366 */
{ 1152, 720, 16 }, /* 0x367 */
{ 1152, 720, 24 }, /* 0x368 */
{ 1152, 720, 32 }, /* 0x369 */
{ 1024, 640, 8 }, /* 0x36a */
{ 1024, 640, 15 }, /* 0x36b */
{ 1024, 640, 16 }, /* 0x36c */
{ 1024, 640, 24 }, /* 0x36d */
{ 1024, 640, 32 }, /* 0x36e */
{ 800, 500, 8 }, /* 0x36f */
{ 800, 500, 15 }, /* 0x370 */
{ 800, 500, 16 }, /* 0x371 */
{ 800, 500, 24 }, /* 0x372 */
{ 800, 500, 32 }, /* 0x373 */
};

View file

@ -0,0 +1,60 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2011 Free Software Foundation, Inc.
*
* GRUB 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 3 of the License, or
* (at your option) any later version.
*
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/relocator.h>
#include <grub/cpu/relocator.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/cpu/reboot.h>
#include <grub/i386/floppy.h>
void
grub_reboot (void)
{
struct grub_relocator *relocator = NULL;
grub_relocator_chunk_t ch;
grub_err_t err;
void *buf;
struct grub_relocator16_state state;
grub_uint16_t segment;
relocator = grub_relocator_new ();
if (!relocator)
while (1);
err = grub_relocator_alloc_chunk_align (relocator, &ch, 0x1000, 0x1000,
grub_reboot_end - grub_reboot_start,
16, GRUB_RELOCATOR_PREFERENCE_NONE);
if (err)
while (1);
buf = get_virtual_current_address (ch);
grub_memcpy (buf, grub_reboot_start, grub_reboot_end - grub_reboot_start);
segment = ((grub_addr_t) get_physical_target_address (ch)) >> 4;
state.gs = state.fs = state.es = state.ds = state.ss = segment;
state.sp = 0;
state.cs = segment;
state.ip = 0;
state.a20 = 0;
grub_stop_floppy ();
err = grub_relocator16_boot (relocator, state);
while (1);
}

View file

@ -0,0 +1,34 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2011 Free Software Foundation, Inc.
*
* GRUB 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 3 of the License, or
* (at your option) any later version.
*
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/symbol.h>
#include <grub/i386/reboot.h>
.p2align 4
VARIABLE(grub_reboot_start)
.code16
/* set 0x472 to 0x0000 for cold boot (0x1234 for warm boot) */
movw $0x0472, %di
xorw %ax, %ax
movw %ax, (%di)
ljmp $0xf000, $0xfff0
.code32
VARIABLE(grub_reboot_end)

View file

@ -50,6 +50,10 @@ extern grub_uint16_t grub_relocator16_gs;
extern grub_uint16_t grub_relocator16_ss;
extern grub_uint16_t grub_relocator16_sp;
extern grub_uint32_t grub_relocator16_edx;
extern grub_uint32_t grub_relocator16_ebx;
extern grub_uint32_t grub_relocator16_esi;
extern grub_uint16_t grub_relocator16_keep_a20_enabled;
extern grub_uint8_t grub_relocator32_start;
extern grub_uint8_t grub_relocator32_end;
@ -194,7 +198,8 @@ grub_relocator16_boot (struct grub_relocator *rel,
void *relst;
grub_relocator_chunk_t ch;
err = grub_relocator_alloc_chunk_align (rel, &ch, 0,
/* Put it higher than the byte it checks for A20 check. */
err = grub_relocator_alloc_chunk_align (rel, &ch, 0x8010,
0xa0000 - RELOCATOR_SIZEOF (16),
RELOCATOR_SIZEOF (16), 16,
GRUB_RELOCATOR_PREFERENCE_NONE);
@ -212,7 +217,11 @@ grub_relocator16_boot (struct grub_relocator *rel,
grub_relocator16_ss = state.ss;
grub_relocator16_sp = state.sp;
grub_relocator16_ebx = state.ebx;
grub_relocator16_edx = state.edx;
grub_relocator16_esi = state.esi;
grub_relocator16_keep_a20_enabled = state.a20;
grub_memmove (get_virtual_current_address (ch), &grub_relocator16_start,
RELOCATOR_SIZEOF (16));

View file

@ -93,6 +93,85 @@ LOCAL(segment):
.word 0
LOCAL(cont3):
/* movw imm16, %ax. */
.byte 0xb8
VARIABLE(grub_relocator16_keep_a20_enabled)
.word 0
test %ax, %ax
jnz LOCAL(gate_a20_done)
/* first of all, test if already in a good state */
call LOCAL(gate_a20_check_state)
testb %al, %al
jz LOCAL(gate_a20_done)
/* second, try a BIOS call */
movw $0x2400, %ax
int $0x15
call LOCAL(gate_a20_check_state)
testb %al, %al
jz LOCAL(gate_a20_done)
/*
* In macbook, the keyboard test would hang the machine, so we move
* this forward.
*/
/* fourth, try the system control port A */
inb $0x92
andb $(~0x03), %al
outb $0x92
/* When turning off Gate A20, do not check the state strictly,
because a failure is not fatal usually, and Gate A20 is always
on some modern machines. */
jmp LOCAL(gate_a20_done)
LOCAL(gate_a20_check_state):
/* iterate the checking for a while */
movw $100, %cx
1:
call 3f
testb %al, %al
jz 2f
loop 1b
2:
ret
3:
xorw %ax, %ax
movw %ax, %ds
decw %ax
movw %ax, %es
xorw %ax, %ax
movw $0x8000, %ax
/* compare the byte at ADDR with that at 0x100000 + ADDR */
movw %ax, %si
addw $0x10, %ax
movw %ax, %di
/* save the original byte in DL */
movb %ds:(%si), %dl
movb %es:(%di), %al
/* try to set one less value at ADDR */
movb %al, %dh
decb %dh
movb %dh, %ds:(%si)
/* serialize */
outb %al, $0x80
outb %al, $0x80
/* obtain the value at 0x100000 + ADDR in CH */
movb %es:(%di), %dh
/* this result is 1 if A20 is on or 0 if it is off */
subb %dh, %al
xorb $1, %al
/* restore the original */
movb %dl, %es:(%di)
ret
LOCAL(gate_a20_done):
/* we are in real mode now
* set up the real mode segment registers : DS, SS, ES
*/
@ -130,13 +209,24 @@ VARIABLE(grub_relocator16_ss)
.byte 0xb8
VARIABLE(grub_relocator16_sp)
.word 0
movw %ax, %ss
movzwl %ax, %esp
/* movw imm32, %eax. */
.byte 0x66, 0xb8
VARIABLE(grub_relocator16_esi)
.long 0
movl %eax, %esi
/* movw imm32, %edx. */
.byte 0x66, 0xba
VARIABLE(grub_relocator16_edx)
.long 0
/* movw imm32, %ebx. */
.byte 0x66, 0xbb
VARIABLE(grub_relocator16_ebx)
.long 0
/* Cleared direction flag is of no problem with any current
payload and makes this implementation easier. */
cld

View file

@ -17,9 +17,12 @@
*/
#include <grub/symbol.h>
#include <grub/dl.h>
.file "setjmp.S"
GRUB_MOD_LICENSE ("GPLv3+")
.text
/*