2009-04-10 Bean <bean123ch@gnail.com>
* include/grub/efi/api.h (grub_efi_configuration_table): Add packed attribute, otherwise the size would be wrong for i386 platform. * include/grub/pci.h (grub_pci_read_word): New inline function. (grub_pci_read_byte): Likewise. (grub_pci_write): Likewise. (grub_pci_write_word): Likewise. (grub_pci_write_byte): Likewise. * include/grub/pci.h (grub_pci_iteratefunc_t): Add NESTED_FUNC_ATTR. * loader/i386/efi/linux.c (fake_bios_data): Moved to loadbios module. (find_framebuf): Scan pci to locate the frame buffer address. * commands/efi/fixvideo.c: New file. * commands/efi/loadbios.c: Likewise. * commands/memrw.c: Likewise. * util/grub-dumpbios.in: Likewise. * conf/common.rmk (grub-dumpbios): New utility. (pkglib_MODULES): New module memrw.mod. (memrw_mod_SOURCE): New macro. (memrw_mod_CFLAGS): Likewise. (memrw_mod_LDFLAGS): Likewise. * conf/i386-efi.rmk (pkglig_MODULES): New module loadbios.mod and fixvideo.mod. (loadbios_mod_SOURCE): New macro. (loadbios_mod_CFLAGS): Likewise. (loadbios_mod_LDFLAGS): Likewise. (fixvideo_mod_SOURCE): Likewise. (fixvideo_mod_CFLAGS): Likewise. (fixvideo_mod_LDFLAGS): Likewise. * conf/x86_64.rmk (pkglig_MODULES): New module loadbios.mod and fixvideo.mod. (loadbios_mod_SOURCE): New macro. (loadbios_mod_CFLAGS): Likewise. (loadbios_mod_LDFLAGS): Likewise. (fixvideo_mod_SOURCE): Likewise. (fixvideo_mod_CFLAGS): Likewise. (fixvideo_mod_LDFLAGS): Likewise.
This commit is contained in:
parent
af63ada2bd
commit
e7e6862a4c
16 changed files with 1062 additions and 162 deletions
48
ChangeLog
48
ChangeLog
|
@ -1,3 +1,51 @@
|
||||||
|
2009-04-10 Bean <bean123ch@gnail.com>
|
||||||
|
|
||||||
|
* include/grub/efi/api.h (grub_efi_configuration_table): Add packed
|
||||||
|
attribute, otherwise the size would be wrong for i386 platform.
|
||||||
|
|
||||||
|
* include/grub/pci.h (grub_pci_read_word): New inline function.
|
||||||
|
(grub_pci_read_byte): Likewise.
|
||||||
|
(grub_pci_write): Likewise.
|
||||||
|
(grub_pci_write_word): Likewise.
|
||||||
|
(grub_pci_write_byte): Likewise.
|
||||||
|
|
||||||
|
* include/grub/pci.h (grub_pci_iteratefunc_t): Add NESTED_FUNC_ATTR.
|
||||||
|
|
||||||
|
* loader/i386/efi/linux.c (fake_bios_data): Moved to loadbios module.
|
||||||
|
(find_framebuf): Scan pci to locate the frame buffer address.
|
||||||
|
|
||||||
|
* commands/efi/fixvideo.c: New file.
|
||||||
|
|
||||||
|
* commands/efi/loadbios.c: Likewise.
|
||||||
|
|
||||||
|
* commands/memrw.c: Likewise.
|
||||||
|
|
||||||
|
* util/grub-dumpbios.in: Likewise.
|
||||||
|
|
||||||
|
* conf/common.rmk (grub-dumpbios): New utility.
|
||||||
|
(pkglib_MODULES): New module memrw.mod.
|
||||||
|
(memrw_mod_SOURCE): New macro.
|
||||||
|
(memrw_mod_CFLAGS): Likewise.
|
||||||
|
(memrw_mod_LDFLAGS): Likewise.
|
||||||
|
|
||||||
|
* conf/i386-efi.rmk (pkglig_MODULES): New module loadbios.mod and
|
||||||
|
fixvideo.mod.
|
||||||
|
(loadbios_mod_SOURCE): New macro.
|
||||||
|
(loadbios_mod_CFLAGS): Likewise.
|
||||||
|
(loadbios_mod_LDFLAGS): Likewise.
|
||||||
|
(fixvideo_mod_SOURCE): Likewise.
|
||||||
|
(fixvideo_mod_CFLAGS): Likewise.
|
||||||
|
(fixvideo_mod_LDFLAGS): Likewise.
|
||||||
|
|
||||||
|
* conf/x86_64.rmk (pkglig_MODULES): New module loadbios.mod and
|
||||||
|
fixvideo.mod.
|
||||||
|
(loadbios_mod_SOURCE): New macro.
|
||||||
|
(loadbios_mod_CFLAGS): Likewise.
|
||||||
|
(loadbios_mod_LDFLAGS): Likewise.
|
||||||
|
(fixvideo_mod_SOURCE): Likewise.
|
||||||
|
(fixvideo_mod_CFLAGS): Likewise.
|
||||||
|
(fixvideo_mod_LDFLAGS): Likewise.
|
||||||
|
|
||||||
2009-04-08 Felix Zielcke <fzielcke@z-51.de>
|
2009-04-08 Felix Zielcke <fzielcke@z-51.de>
|
||||||
|
|
||||||
* disk/lvm.c (grub_lvm_scan_device): Add a missing NULL check.
|
* disk/lvm.c (grub_lvm_scan_device): Add a missing NULL check.
|
||||||
|
|
4
DISTLIST
4
DISTLIST
|
@ -58,6 +58,7 @@ commands/loadenv.c
|
||||||
commands/ls.c
|
commands/ls.c
|
||||||
commands/lsmmap.c
|
commands/lsmmap.c
|
||||||
commands/lspci.c
|
commands/lspci.c
|
||||||
|
commands/memrw.c
|
||||||
commands/minicmd.c
|
commands/minicmd.c
|
||||||
commands/parttool.c
|
commands/parttool.c
|
||||||
commands/read.c
|
commands/read.c
|
||||||
|
@ -67,6 +68,8 @@ commands/sleep.c
|
||||||
commands/test.c
|
commands/test.c
|
||||||
commands/usbtest.c
|
commands/usbtest.c
|
||||||
commands/videotest.c
|
commands/videotest.c
|
||||||
|
commands/efi/fixvideo.c
|
||||||
|
commands/efi/loadbios.c
|
||||||
commands/i386/cpuid.c
|
commands/i386/cpuid.c
|
||||||
commands/i386/pc/halt.c
|
commands/i386/pc/halt.c
|
||||||
commands/i386/pc/play.c
|
commands/i386/pc/play.c
|
||||||
|
@ -446,6 +449,7 @@ term/i386/pc/vga_text.c
|
||||||
term/ieee1275/ofconsole.c
|
term/ieee1275/ofconsole.c
|
||||||
util/console.c
|
util/console.c
|
||||||
util/getroot.c
|
util/getroot.c
|
||||||
|
util/grub-dumpbios.in
|
||||||
util/grub-editenv.c
|
util/grub-editenv.c
|
||||||
util/grub-emu.c
|
util/grub-emu.c
|
||||||
util/grub-fstest.c
|
util/grub-fstest.c
|
||||||
|
|
110
commands/efi/fixvideo.c
Normal file
110
commands/efi/fixvideo.c
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
/* fixvideo.c - fix video problem in efi */
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2009 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/dl.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
#include <grub/file.h>
|
||||||
|
#include <grub/pci.h>
|
||||||
|
#include <grub/command.h>
|
||||||
|
|
||||||
|
static struct grub_video_patch
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
grub_uint32_t pci_id;
|
||||||
|
grub_uint32_t mmio_bar;
|
||||||
|
grub_uint32_t mmio_reg;
|
||||||
|
grub_uint32_t mmio_old;
|
||||||
|
} video_patches[] =
|
||||||
|
{
|
||||||
|
{"Intel 945GM", 0x27a28086, 0, 0x71184, 0x1000000}, /* DSPBBASE */
|
||||||
|
{"Intel 965GM", 0x2a028086, 0, 0x7119C, 0x1000000}, /* DSPBSURF */
|
||||||
|
{0, 0, 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
static int NESTED_FUNC_ATTR
|
||||||
|
scan_card (int bus, int dev, int func, grub_pci_id_t pciid)
|
||||||
|
{
|
||||||
|
grub_pci_address_t addr;
|
||||||
|
|
||||||
|
addr = grub_pci_make_address (bus, dev, func, 2);
|
||||||
|
if (grub_pci_read_byte (addr + 3) == 0x3)
|
||||||
|
{
|
||||||
|
struct grub_video_patch *p = video_patches;
|
||||||
|
|
||||||
|
while (p->name)
|
||||||
|
{
|
||||||
|
if (p->pci_id == pciid)
|
||||||
|
{
|
||||||
|
grub_target_addr_t base;
|
||||||
|
|
||||||
|
grub_printf ("Found graphic card: %s\n", p->name);
|
||||||
|
addr += 8 + p->mmio_bar * 4;
|
||||||
|
base = grub_pci_read (addr);
|
||||||
|
if ((! base) || (base & GRUB_PCI_ADDR_SPACE_IO) ||
|
||||||
|
(base & GRUB_PCI_ADDR_MEM_PREFETCH))
|
||||||
|
grub_printf ("Invalid MMIO bar %d\n", p->mmio_bar);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
base &= GRUB_PCI_ADDR_MEM_MASK;
|
||||||
|
base += p->mmio_reg;
|
||||||
|
|
||||||
|
if (*((volatile grub_uint32_t *) base) != p->mmio_old)
|
||||||
|
grub_printf ("Old value don't match\n");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*((volatile grub_uint32_t *) base) = 0;
|
||||||
|
if (*((volatile grub_uint32_t *) base))
|
||||||
|
grub_printf ("Set MMIO fails\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_printf ("Unknown graphic card: %x\n", pciid);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_cmd_fixvideo (grub_command_t cmd __attribute__ ((unused)),
|
||||||
|
int argc __attribute__ ((unused)),
|
||||||
|
char *argv[] __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
grub_pci_iterate (scan_card);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_command_t cmd_fixvideo;
|
||||||
|
|
||||||
|
GRUB_MOD_INIT(fixvideo)
|
||||||
|
{
|
||||||
|
(void) mod; /* To stop warning. */
|
||||||
|
cmd_fixvideo = grub_register_command ("fix_video", grub_cmd_fixvideo,
|
||||||
|
0, "Fix video problem.");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
GRUB_MOD_FINI(fixvideo)
|
||||||
|
{
|
||||||
|
grub_unregister_command (cmd_fixvideo);
|
||||||
|
}
|
212
commands/efi/loadbios.c
Normal file
212
commands/efi/loadbios.c
Normal file
|
@ -0,0 +1,212 @@
|
||||||
|
/* loadbios.c - command to load a bios dump */
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2009 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/dl.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
#include <grub/file.h>
|
||||||
|
#include <grub/efi/efi.h>
|
||||||
|
#include <grub/pci.h>
|
||||||
|
#include <grub/command.h>
|
||||||
|
|
||||||
|
static grub_efi_guid_t acpi_guid = GRUB_EFI_ACPI_TABLE_GUID;
|
||||||
|
static grub_efi_guid_t acpi2_guid = GRUB_EFI_ACPI_20_TABLE_GUID;
|
||||||
|
static grub_efi_guid_t smbios_guid = GRUB_EFI_SMBIOS_TABLE_GUID;
|
||||||
|
|
||||||
|
#define EBDA_SEG_ADDR 0x40e
|
||||||
|
#define LOW_MEM_ADDR 0x413
|
||||||
|
#define FAKE_EBDA_SEG 0x9fc0
|
||||||
|
|
||||||
|
#define BLANK_MEM 0xffffffff
|
||||||
|
#define VBIOS_ADDR 0xc0000
|
||||||
|
#define SBIOS_ADDR 0xf0000
|
||||||
|
|
||||||
|
static int
|
||||||
|
enable_rom_area (void)
|
||||||
|
{
|
||||||
|
grub_pci_address_t addr;
|
||||||
|
grub_uint32_t *rom_ptr;
|
||||||
|
|
||||||
|
rom_ptr = (grub_uint32_t *) VBIOS_ADDR;
|
||||||
|
if (*rom_ptr != BLANK_MEM)
|
||||||
|
{
|
||||||
|
grub_printf ("ROM image present.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
addr = grub_pci_make_address (0, 0, 0, 36);
|
||||||
|
grub_pci_write_byte (addr++, 0x30);
|
||||||
|
grub_pci_write_byte (addr++, 0x33);
|
||||||
|
grub_pci_write_byte (addr++, 0x33);
|
||||||
|
grub_pci_write_byte (addr++, 0x33);
|
||||||
|
grub_pci_write_byte (addr++, 0x33);
|
||||||
|
grub_pci_write_byte (addr++, 0x33);
|
||||||
|
grub_pci_write_byte (addr++, 0x33);
|
||||||
|
grub_pci_write_byte (addr, 0);
|
||||||
|
|
||||||
|
*rom_ptr = 0;
|
||||||
|
if (*rom_ptr != 0)
|
||||||
|
{
|
||||||
|
grub_printf ("Can\'t enable rom area.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
lock_rom_area (void)
|
||||||
|
{
|
||||||
|
grub_pci_address_t addr;
|
||||||
|
|
||||||
|
addr = grub_pci_make_address (0, 0, 0, 36);
|
||||||
|
grub_pci_write_byte (addr++, 0x10);
|
||||||
|
grub_pci_write_byte (addr++, 0x11);
|
||||||
|
grub_pci_write_byte (addr++, 0x11);
|
||||||
|
grub_pci_write_byte (addr++, 0x11);
|
||||||
|
grub_pci_write_byte (addr, 0x11);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fake_bios_data (int use_rom)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
void *acpi, *smbios;
|
||||||
|
grub_uint16_t *ebda_seg_ptr, *low_mem_ptr;
|
||||||
|
|
||||||
|
ebda_seg_ptr = (grub_uint16_t *) EBDA_SEG_ADDR;
|
||||||
|
low_mem_ptr = (grub_uint16_t *) LOW_MEM_ADDR;
|
||||||
|
if ((*ebda_seg_ptr) || (*low_mem_ptr))
|
||||||
|
return;
|
||||||
|
|
||||||
|
acpi = 0;
|
||||||
|
smbios = 0;
|
||||||
|
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
|
||||||
|
{
|
||||||
|
grub_efi_guid_t *guid =
|
||||||
|
&grub_efi_system_table->configuration_table[i].vendor_guid;
|
||||||
|
|
||||||
|
if (! grub_memcmp (guid, &acpi2_guid, sizeof (grub_efi_guid_t)))
|
||||||
|
{
|
||||||
|
acpi = grub_efi_system_table->configuration_table[i].vendor_table;
|
||||||
|
grub_dprintf ("efi", "ACPI2: %p\n", acpi);
|
||||||
|
}
|
||||||
|
else if (! grub_memcmp (guid, &acpi_guid, sizeof (grub_efi_guid_t)))
|
||||||
|
{
|
||||||
|
void *t;
|
||||||
|
|
||||||
|
t = grub_efi_system_table->configuration_table[i].vendor_table;
|
||||||
|
if (! acpi)
|
||||||
|
acpi = t;
|
||||||
|
grub_dprintf ("efi", "ACPI: %p\n", t);
|
||||||
|
}
|
||||||
|
else if (! grub_memcmp (guid, &smbios_guid, sizeof (grub_efi_guid_t)))
|
||||||
|
{
|
||||||
|
smbios = grub_efi_system_table->configuration_table[i].vendor_table;
|
||||||
|
grub_dprintf ("efi", "SMBIOS: %p\n", smbios);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*ebda_seg_ptr = FAKE_EBDA_SEG;
|
||||||
|
*low_mem_ptr = (FAKE_EBDA_SEG >> 6);
|
||||||
|
|
||||||
|
*((grub_uint16_t *) (FAKE_EBDA_SEG << 4)) = 640 - *low_mem_ptr;
|
||||||
|
|
||||||
|
if (acpi)
|
||||||
|
grub_memcpy ((char *) ((FAKE_EBDA_SEG << 4) + 16), acpi, 1024 - 16);
|
||||||
|
|
||||||
|
if ((use_rom) && (smbios))
|
||||||
|
grub_memcpy ((char *) SBIOS_ADDR, (char *) smbios + 16, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_cmd_fakebios (struct grub_command *cmd __attribute__ ((unused)),
|
||||||
|
int argc __attribute__ ((unused)),
|
||||||
|
char *argv[] __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
if (enable_rom_area ())
|
||||||
|
{
|
||||||
|
fake_bios_data (1);
|
||||||
|
lock_rom_area ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fake_bios_data (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_cmd_loadbios (grub_command_t cmd __attribute__ ((unused)),
|
||||||
|
int argc, char *argv[])
|
||||||
|
{
|
||||||
|
grub_file_t file;
|
||||||
|
int size;
|
||||||
|
|
||||||
|
if (argc == 0)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "No rom image specified");
|
||||||
|
|
||||||
|
if (argc > 1)
|
||||||
|
{
|
||||||
|
file = grub_file_open (argv[1]);
|
||||||
|
if (! file)
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
|
if (file->size != 4)
|
||||||
|
grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid int10 dump size");
|
||||||
|
else
|
||||||
|
grub_file_read (file, (char *) 0x40, 4);
|
||||||
|
|
||||||
|
grub_file_close (file);
|
||||||
|
if (grub_errno)
|
||||||
|
return grub_errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
file = grub_file_open (argv[0]);
|
||||||
|
if (! file)
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
|
size = file->size;
|
||||||
|
if ((size < 0x10000) || (size > 0x40000))
|
||||||
|
grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid bios dump size");
|
||||||
|
else if (enable_rom_area ())
|
||||||
|
{
|
||||||
|
grub_file_read (file, (char *) VBIOS_ADDR, size);
|
||||||
|
fake_bios_data (size <= 0x40000);
|
||||||
|
lock_rom_area ();
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_file_close (file);
|
||||||
|
return grub_errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_command_t cmd_fakebios, cmd_loadbios;
|
||||||
|
|
||||||
|
GRUB_MOD_INIT(loadbios)
|
||||||
|
{
|
||||||
|
(void) mod; /* To stop warning. */
|
||||||
|
cmd_fakebios = grub_register_command ("fakebios", grub_cmd_fakebios,
|
||||||
|
0, "fake bios.");
|
||||||
|
|
||||||
|
cmd_loadbios = grub_register_command ("loadbios", grub_cmd_loadbios,
|
||||||
|
"loadbios BIOS_DUMP [INT10_DUMP]",
|
||||||
|
"Load bios dump.");
|
||||||
|
}
|
||||||
|
|
||||||
|
GRUB_MOD_FINI(loadbios)
|
||||||
|
{
|
||||||
|
grub_unregister_command (cmd_fakebios);
|
||||||
|
grub_unregister_command (cmd_loadbios);
|
||||||
|
}
|
101
commands/memrw.c
Normal file
101
commands/memrw.c
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
/* memrw.c - command to read / write physical memory */
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2009 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/dl.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
#include <grub/command.h>
|
||||||
|
|
||||||
|
static grub_command_t cmd_read_byte, cmd_read_word, cmd_read_dword;
|
||||||
|
static grub_command_t cmd_write_byte, cmd_write_word, cmd_write_dword;
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_cmd_read (grub_command_t cmd, int argc, char **argv)
|
||||||
|
{
|
||||||
|
grub_target_addr_t addr;
|
||||||
|
grub_uint32_t value;
|
||||||
|
|
||||||
|
if (argc != 1)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid number of arguments");
|
||||||
|
|
||||||
|
addr = grub_strtoul (argv[0], 0, 0);
|
||||||
|
if (cmd->name[5] == 'd')
|
||||||
|
value = *((grub_uint32_t *) addr);
|
||||||
|
else if (cmd->name[5] == 'w')
|
||||||
|
value = *((grub_uint16_t *) addr);
|
||||||
|
else
|
||||||
|
value = *((grub_uint8_t *) addr);
|
||||||
|
|
||||||
|
grub_printf ("0x%x\n", value);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_cmd_write (grub_command_t cmd, int argc, char **argv)
|
||||||
|
{
|
||||||
|
grub_target_addr_t addr;
|
||||||
|
grub_uint32_t value;
|
||||||
|
|
||||||
|
if (argc != 2)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid number of arguments");
|
||||||
|
|
||||||
|
addr = grub_strtoul (argv[0], 0, 0);
|
||||||
|
value = grub_strtoul (argv[1], 0, 0);
|
||||||
|
if (cmd->name[6] == 'd')
|
||||||
|
*((grub_uint32_t *) addr) = value;
|
||||||
|
else if (cmd->name[6] == 'w')
|
||||||
|
*((grub_uint16_t *) addr) = (grub_uint16_t) value;
|
||||||
|
else
|
||||||
|
*((grub_uint8_t *) addr) = (grub_uint8_t) value;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GRUB_MOD_INIT(memrw)
|
||||||
|
{
|
||||||
|
(void) mod; /* To stop warning. */
|
||||||
|
cmd_read_byte =
|
||||||
|
grub_register_command ("read_byte", grub_cmd_read,
|
||||||
|
"read_byte ADDR", "read byte.");
|
||||||
|
cmd_read_word =
|
||||||
|
grub_register_command ("read_word", grub_cmd_read,
|
||||||
|
"read_word ADDR", "read word.");
|
||||||
|
cmd_read_dword =
|
||||||
|
grub_register_command ("read_dword", grub_cmd_read,
|
||||||
|
"read_dword ADDR", "read dword.");
|
||||||
|
cmd_write_byte =
|
||||||
|
grub_register_command ("write_byte", grub_cmd_write,
|
||||||
|
"write_byte ADDR VALUE", "write byte.");
|
||||||
|
cmd_write_word =
|
||||||
|
grub_register_command ("write_word", grub_cmd_write,
|
||||||
|
"write_word ADDR VALUE", "write word.");
|
||||||
|
cmd_write_dword =
|
||||||
|
grub_register_command ("write_dword", grub_cmd_write,
|
||||||
|
"write_dword ADDR VALUE", "write dword.");
|
||||||
|
}
|
||||||
|
|
||||||
|
GRUB_MOD_FINI(memrw)
|
||||||
|
{
|
||||||
|
grub_unregister_command (cmd_read_byte);
|
||||||
|
grub_unregister_command (cmd_read_word);
|
||||||
|
grub_unregister_command (cmd_read_dword);
|
||||||
|
grub_unregister_command (cmd_write_byte);
|
||||||
|
grub_unregister_command (cmd_write_word);
|
||||||
|
grub_unregister_command (cmd_write_dword);
|
||||||
|
}
|
|
@ -600,6 +600,12 @@ CLEANFILES += $(grub-mkconfig_SCRIPTS)
|
||||||
|
|
||||||
grub-mkconfig_DATA += util/grub.d/README
|
grub-mkconfig_DATA += util/grub.d/README
|
||||||
|
|
||||||
|
# For grub-dumpbios
|
||||||
|
grub-dumpbios: util/grub-dumpbios.in config.status
|
||||||
|
./config.status --file=$@:$<
|
||||||
|
chmod +x $@
|
||||||
|
sbin_SCRIPTS += grub-dumpbios
|
||||||
|
CLEANFILES += grub-dumpbios
|
||||||
|
|
||||||
# Filing systems.
|
# Filing systems.
|
||||||
pkglib_MODULES += fshelp.mod fat.mod ufs.mod ext2.mod ntfs.mod \
|
pkglib_MODULES += fshelp.mod fat.mod ufs.mod ext2.mod ntfs.mod \
|
||||||
|
@ -2444,7 +2450,8 @@ pkglib_MODULES += minicmd.mod extcmd.mod hello.mod handler.mod \
|
||||||
ls.mod cmp.mod cat.mod help.mod search.mod \
|
ls.mod cmp.mod cat.mod help.mod search.mod \
|
||||||
loopback.mod fs_uuid.mod configfile.mod echo.mod \
|
loopback.mod fs_uuid.mod configfile.mod echo.mod \
|
||||||
terminfo.mod test.mod blocklist.mod hexdump.mod \
|
terminfo.mod test.mod blocklist.mod hexdump.mod \
|
||||||
read.mod sleep.mod loadenv.mod crc.mod parttool.mod pcpart.mod
|
read.mod sleep.mod loadenv.mod crc.mod parttool.mod \
|
||||||
|
pcpart.mod memrw.mod
|
||||||
|
|
||||||
# For minicmd.mod.
|
# For minicmd.mod.
|
||||||
minicmd_mod_SOURCES = commands/minicmd.c
|
minicmd_mod_SOURCES = commands/minicmd.c
|
||||||
|
@ -3852,6 +3859,63 @@ partmap-crc_mod-lib_crc.lst: lib/crc.c $(lib/crc.c_DEPENDENCIES) genpartmaplist.
|
||||||
crc_mod_CFLAGS = $(COMMON_CFLAGS)
|
crc_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
crc_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
crc_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For memrw.mod.
|
||||||
|
memrw_mod_SOURCES = commands/memrw.c
|
||||||
|
CLEANFILES += memrw.mod mod-memrw.o mod-memrw.c pre-memrw.o memrw_mod-commands_memrw.o und-memrw.lst
|
||||||
|
ifneq ($(memrw_mod_EXPORTS),no)
|
||||||
|
CLEANFILES += def-memrw.lst
|
||||||
|
DEFSYMFILES += def-memrw.lst
|
||||||
|
endif
|
||||||
|
MOSTLYCLEANFILES += memrw_mod-commands_memrw.d
|
||||||
|
UNDSYMFILES += und-memrw.lst
|
||||||
|
|
||||||
|
memrw.mod: pre-memrw.o mod-memrw.o $(TARGET_OBJ2ELF)
|
||||||
|
-rm -f $@
|
||||||
|
$(TARGET_CC) $(memrw_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ pre-memrw.o mod-memrw.o
|
||||||
|
if test ! -z $(TARGET_OBJ2ELF); then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
|
||||||
|
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@
|
||||||
|
|
||||||
|
pre-memrw.o: $(memrw_mod_DEPENDENCIES) memrw_mod-commands_memrw.o
|
||||||
|
-rm -f $@
|
||||||
|
$(TARGET_CC) $(memrw_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ memrw_mod-commands_memrw.o
|
||||||
|
|
||||||
|
mod-memrw.o: mod-memrw.c
|
||||||
|
$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(memrw_mod_CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
mod-memrw.c: $(builddir)/moddep.lst $(srcdir)/genmodsrc.sh
|
||||||
|
sh $(srcdir)/genmodsrc.sh 'memrw' $< > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
ifneq ($(memrw_mod_EXPORTS),no)
|
||||||
|
def-memrw.lst: pre-memrw.o
|
||||||
|
$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 memrw/' > $@
|
||||||
|
endif
|
||||||
|
|
||||||
|
und-memrw.lst: pre-memrw.o
|
||||||
|
echo 'memrw' > $@
|
||||||
|
$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
|
||||||
|
|
||||||
|
memrw_mod-commands_memrw.o: commands/memrw.c $(commands/memrw.c_DEPENDENCIES)
|
||||||
|
$(TARGET_CC) -Icommands -I$(srcdir)/commands $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(memrw_mod_CFLAGS) -MD -c -o $@ $<
|
||||||
|
-include memrw_mod-commands_memrw.d
|
||||||
|
|
||||||
|
CLEANFILES += cmd-memrw_mod-commands_memrw.lst fs-memrw_mod-commands_memrw.lst partmap-memrw_mod-commands_memrw.lst
|
||||||
|
COMMANDFILES += cmd-memrw_mod-commands_memrw.lst
|
||||||
|
FSFILES += fs-memrw_mod-commands_memrw.lst
|
||||||
|
PARTMAPFILES += partmap-memrw_mod-commands_memrw.lst
|
||||||
|
|
||||||
|
cmd-memrw_mod-commands_memrw.lst: commands/memrw.c $(commands/memrw.c_DEPENDENCIES) gencmdlist.sh
|
||||||
|
set -e; $(TARGET_CC) -Icommands -I$(srcdir)/commands $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(memrw_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh memrw > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
fs-memrw_mod-commands_memrw.lst: commands/memrw.c $(commands/memrw.c_DEPENDENCIES) genfslist.sh
|
||||||
|
set -e; $(TARGET_CC) -Icommands -I$(srcdir)/commands $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(memrw_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh memrw > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
partmap-memrw_mod-commands_memrw.lst: commands/memrw.c $(commands/memrw.c_DEPENDENCIES) genpartmaplist.sh
|
||||||
|
set -e; $(TARGET_CC) -Icommands -I$(srcdir)/commands $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(memrw_mod_CFLAGS) -E $< | sh $(srcdir)/genpartmaplist.sh memrw > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
|
||||||
|
memrw_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
memrw_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# Common Video Subsystem specific modules.
|
# Common Video Subsystem specific modules.
|
||||||
pkglib_MODULES += video.mod videotest.mod bitmap.mod tga.mod jpeg.mod \
|
pkglib_MODULES += video.mod videotest.mod bitmap.mod tga.mod jpeg.mod \
|
||||||
png.mod font.mod gfxterm.mod
|
png.mod font.mod gfxterm.mod
|
||||||
|
|
|
@ -155,6 +155,12 @@ CLEANFILES += $(grub-mkconfig_SCRIPTS)
|
||||||
|
|
||||||
grub-mkconfig_DATA += util/grub.d/README
|
grub-mkconfig_DATA += util/grub.d/README
|
||||||
|
|
||||||
|
# For grub-dumpbios
|
||||||
|
grub-dumpbios: util/grub-dumpbios.in config.status
|
||||||
|
./config.status --file=$@:$<
|
||||||
|
chmod +x $@
|
||||||
|
sbin_SCRIPTS += grub-dumpbios
|
||||||
|
CLEANFILES += grub-dumpbios
|
||||||
|
|
||||||
# Filing systems.
|
# Filing systems.
|
||||||
pkglib_MODULES += fshelp.mod fat.mod ufs.mod ext2.mod ntfs.mod \
|
pkglib_MODULES += fshelp.mod fat.mod ufs.mod ext2.mod ntfs.mod \
|
||||||
|
@ -335,7 +341,8 @@ pkglib_MODULES += minicmd.mod extcmd.mod hello.mod handler.mod \
|
||||||
ls.mod cmp.mod cat.mod help.mod search.mod \
|
ls.mod cmp.mod cat.mod help.mod search.mod \
|
||||||
loopback.mod fs_uuid.mod configfile.mod echo.mod \
|
loopback.mod fs_uuid.mod configfile.mod echo.mod \
|
||||||
terminfo.mod test.mod blocklist.mod hexdump.mod \
|
terminfo.mod test.mod blocklist.mod hexdump.mod \
|
||||||
read.mod sleep.mod loadenv.mod crc.mod parttool.mod pcpart.mod
|
read.mod sleep.mod loadenv.mod crc.mod parttool.mod \
|
||||||
|
pcpart.mod memrw.mod
|
||||||
|
|
||||||
# For minicmd.mod.
|
# For minicmd.mod.
|
||||||
minicmd_mod_SOURCES = commands/minicmd.c
|
minicmd_mod_SOURCES = commands/minicmd.c
|
||||||
|
@ -452,6 +459,11 @@ crc_mod_SOURCES = commands/crc.c lib/crc.c
|
||||||
crc_mod_CFLAGS = $(COMMON_CFLAGS)
|
crc_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
crc_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
crc_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For memrw.mod.
|
||||||
|
memrw_mod_SOURCES = commands/memrw.c
|
||||||
|
memrw_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
memrw_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# Common Video Subsystem specific modules.
|
# Common Video Subsystem specific modules.
|
||||||
pkglib_MODULES += video.mod videotest.mod bitmap.mod tga.mod jpeg.mod \
|
pkglib_MODULES += video.mod videotest.mod bitmap.mod tga.mod jpeg.mod \
|
||||||
png.mod font.mod gfxterm.mod
|
png.mod font.mod gfxterm.mod
|
||||||
|
|
116
conf/i386-efi.mk
116
conf/i386-efi.mk
|
@ -120,7 +120,7 @@ grub-install: util/i386/efi/grub-install.in $(util/i386/efi/grub-install.in_DEPE
|
||||||
# Modules.
|
# Modules.
|
||||||
pkglib_MODULES = kernel.mod normal.mod chain.mod appleldr.mod \
|
pkglib_MODULES = kernel.mod normal.mod chain.mod appleldr.mod \
|
||||||
linux.mod halt.mod reboot.mod pci.mod lspci.mod \
|
linux.mod halt.mod reboot.mod pci.mod lspci.mod \
|
||||||
datetime.mod date.mod datehook.mod
|
datetime.mod date.mod datehook.mod loadbios.mod fixvideo.mod
|
||||||
|
|
||||||
# For kernel.mod.
|
# For kernel.mod.
|
||||||
kernel_mod_EXPORTS = no
|
kernel_mod_EXPORTS = no
|
||||||
|
@ -1759,5 +1759,119 @@ partmap-datehook_mod-hook_datehook.lst: hook/datehook.c $(hook/datehook.c_DEPEND
|
||||||
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For loadbios.mod
|
||||||
|
loadbios_mod_SOURCES = commands/efi/loadbios.c
|
||||||
|
CLEANFILES += loadbios.mod mod-loadbios.o mod-loadbios.c pre-loadbios.o loadbios_mod-commands_efi_loadbios.o und-loadbios.lst
|
||||||
|
ifneq ($(loadbios_mod_EXPORTS),no)
|
||||||
|
CLEANFILES += def-loadbios.lst
|
||||||
|
DEFSYMFILES += def-loadbios.lst
|
||||||
|
endif
|
||||||
|
MOSTLYCLEANFILES += loadbios_mod-commands_efi_loadbios.d
|
||||||
|
UNDSYMFILES += und-loadbios.lst
|
||||||
|
|
||||||
|
loadbios.mod: pre-loadbios.o mod-loadbios.o $(TARGET_OBJ2ELF)
|
||||||
|
-rm -f $@
|
||||||
|
$(TARGET_CC) $(loadbios_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ pre-loadbios.o mod-loadbios.o
|
||||||
|
if test ! -z $(TARGET_OBJ2ELF); then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
|
||||||
|
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@
|
||||||
|
|
||||||
|
pre-loadbios.o: $(loadbios_mod_DEPENDENCIES) loadbios_mod-commands_efi_loadbios.o
|
||||||
|
-rm -f $@
|
||||||
|
$(TARGET_CC) $(loadbios_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ loadbios_mod-commands_efi_loadbios.o
|
||||||
|
|
||||||
|
mod-loadbios.o: mod-loadbios.c
|
||||||
|
$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(loadbios_mod_CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
mod-loadbios.c: $(builddir)/moddep.lst $(srcdir)/genmodsrc.sh
|
||||||
|
sh $(srcdir)/genmodsrc.sh 'loadbios' $< > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
ifneq ($(loadbios_mod_EXPORTS),no)
|
||||||
|
def-loadbios.lst: pre-loadbios.o
|
||||||
|
$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 loadbios/' > $@
|
||||||
|
endif
|
||||||
|
|
||||||
|
und-loadbios.lst: pre-loadbios.o
|
||||||
|
echo 'loadbios' > $@
|
||||||
|
$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
|
||||||
|
|
||||||
|
loadbios_mod-commands_efi_loadbios.o: commands/efi/loadbios.c $(commands/efi/loadbios.c_DEPENDENCIES)
|
||||||
|
$(TARGET_CC) -Icommands/efi -I$(srcdir)/commands/efi $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(loadbios_mod_CFLAGS) -MD -c -o $@ $<
|
||||||
|
-include loadbios_mod-commands_efi_loadbios.d
|
||||||
|
|
||||||
|
CLEANFILES += cmd-loadbios_mod-commands_efi_loadbios.lst fs-loadbios_mod-commands_efi_loadbios.lst partmap-loadbios_mod-commands_efi_loadbios.lst
|
||||||
|
COMMANDFILES += cmd-loadbios_mod-commands_efi_loadbios.lst
|
||||||
|
FSFILES += fs-loadbios_mod-commands_efi_loadbios.lst
|
||||||
|
PARTMAPFILES += partmap-loadbios_mod-commands_efi_loadbios.lst
|
||||||
|
|
||||||
|
cmd-loadbios_mod-commands_efi_loadbios.lst: commands/efi/loadbios.c $(commands/efi/loadbios.c_DEPENDENCIES) gencmdlist.sh
|
||||||
|
set -e; $(TARGET_CC) -Icommands/efi -I$(srcdir)/commands/efi $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(loadbios_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh loadbios > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
fs-loadbios_mod-commands_efi_loadbios.lst: commands/efi/loadbios.c $(commands/efi/loadbios.c_DEPENDENCIES) genfslist.sh
|
||||||
|
set -e; $(TARGET_CC) -Icommands/efi -I$(srcdir)/commands/efi $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(loadbios_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh loadbios > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
partmap-loadbios_mod-commands_efi_loadbios.lst: commands/efi/loadbios.c $(commands/efi/loadbios.c_DEPENDENCIES) genpartmaplist.sh
|
||||||
|
set -e; $(TARGET_CC) -Icommands/efi -I$(srcdir)/commands/efi $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(loadbios_mod_CFLAGS) -E $< | sh $(srcdir)/genpartmaplist.sh loadbios > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
|
||||||
|
loadbios_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
loadbios_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For fixvideo.mod
|
||||||
|
fixvideo_mod_SOURCES = commands/efi/fixvideo.c
|
||||||
|
CLEANFILES += fixvideo.mod mod-fixvideo.o mod-fixvideo.c pre-fixvideo.o fixvideo_mod-commands_efi_fixvideo.o und-fixvideo.lst
|
||||||
|
ifneq ($(fixvideo_mod_EXPORTS),no)
|
||||||
|
CLEANFILES += def-fixvideo.lst
|
||||||
|
DEFSYMFILES += def-fixvideo.lst
|
||||||
|
endif
|
||||||
|
MOSTLYCLEANFILES += fixvideo_mod-commands_efi_fixvideo.d
|
||||||
|
UNDSYMFILES += und-fixvideo.lst
|
||||||
|
|
||||||
|
fixvideo.mod: pre-fixvideo.o mod-fixvideo.o $(TARGET_OBJ2ELF)
|
||||||
|
-rm -f $@
|
||||||
|
$(TARGET_CC) $(fixvideo_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ pre-fixvideo.o mod-fixvideo.o
|
||||||
|
if test ! -z $(TARGET_OBJ2ELF); then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
|
||||||
|
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@
|
||||||
|
|
||||||
|
pre-fixvideo.o: $(fixvideo_mod_DEPENDENCIES) fixvideo_mod-commands_efi_fixvideo.o
|
||||||
|
-rm -f $@
|
||||||
|
$(TARGET_CC) $(fixvideo_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ fixvideo_mod-commands_efi_fixvideo.o
|
||||||
|
|
||||||
|
mod-fixvideo.o: mod-fixvideo.c
|
||||||
|
$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(fixvideo_mod_CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
mod-fixvideo.c: $(builddir)/moddep.lst $(srcdir)/genmodsrc.sh
|
||||||
|
sh $(srcdir)/genmodsrc.sh 'fixvideo' $< > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
ifneq ($(fixvideo_mod_EXPORTS),no)
|
||||||
|
def-fixvideo.lst: pre-fixvideo.o
|
||||||
|
$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 fixvideo/' > $@
|
||||||
|
endif
|
||||||
|
|
||||||
|
und-fixvideo.lst: pre-fixvideo.o
|
||||||
|
echo 'fixvideo' > $@
|
||||||
|
$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
|
||||||
|
|
||||||
|
fixvideo_mod-commands_efi_fixvideo.o: commands/efi/fixvideo.c $(commands/efi/fixvideo.c_DEPENDENCIES)
|
||||||
|
$(TARGET_CC) -Icommands/efi -I$(srcdir)/commands/efi $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(fixvideo_mod_CFLAGS) -MD -c -o $@ $<
|
||||||
|
-include fixvideo_mod-commands_efi_fixvideo.d
|
||||||
|
|
||||||
|
CLEANFILES += cmd-fixvideo_mod-commands_efi_fixvideo.lst fs-fixvideo_mod-commands_efi_fixvideo.lst partmap-fixvideo_mod-commands_efi_fixvideo.lst
|
||||||
|
COMMANDFILES += cmd-fixvideo_mod-commands_efi_fixvideo.lst
|
||||||
|
FSFILES += fs-fixvideo_mod-commands_efi_fixvideo.lst
|
||||||
|
PARTMAPFILES += partmap-fixvideo_mod-commands_efi_fixvideo.lst
|
||||||
|
|
||||||
|
cmd-fixvideo_mod-commands_efi_fixvideo.lst: commands/efi/fixvideo.c $(commands/efi/fixvideo.c_DEPENDENCIES) gencmdlist.sh
|
||||||
|
set -e; $(TARGET_CC) -Icommands/efi -I$(srcdir)/commands/efi $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(fixvideo_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh fixvideo > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
fs-fixvideo_mod-commands_efi_fixvideo.lst: commands/efi/fixvideo.c $(commands/efi/fixvideo.c_DEPENDENCIES) genfslist.sh
|
||||||
|
set -e; $(TARGET_CC) -Icommands/efi -I$(srcdir)/commands/efi $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(fixvideo_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh fixvideo > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
partmap-fixvideo_mod-commands_efi_fixvideo.lst: commands/efi/fixvideo.c $(commands/efi/fixvideo.c_DEPENDENCIES) genpartmaplist.sh
|
||||||
|
set -e; $(TARGET_CC) -Icommands/efi -I$(srcdir)/commands/efi $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(fixvideo_mod_CFLAGS) -E $< | sh $(srcdir)/genpartmaplist.sh fixvideo > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
|
||||||
|
fixvideo_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
fixvideo_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
include $(srcdir)/conf/i386.mk
|
include $(srcdir)/conf/i386.mk
|
||||||
include $(srcdir)/conf/common.mk
|
include $(srcdir)/conf/common.mk
|
||||||
|
|
|
@ -81,7 +81,7 @@ grub_install_SOURCES = util/i386/efi/grub-install.in
|
||||||
# Modules.
|
# Modules.
|
||||||
pkglib_MODULES = kernel.mod normal.mod chain.mod appleldr.mod \
|
pkglib_MODULES = kernel.mod normal.mod chain.mod appleldr.mod \
|
||||||
linux.mod halt.mod reboot.mod pci.mod lspci.mod \
|
linux.mod halt.mod reboot.mod pci.mod lspci.mod \
|
||||||
datetime.mod date.mod datehook.mod
|
datetime.mod date.mod datehook.mod loadbios.mod fixvideo.mod
|
||||||
|
|
||||||
# For kernel.mod.
|
# For kernel.mod.
|
||||||
kernel_mod_EXPORTS = no
|
kernel_mod_EXPORTS = no
|
||||||
|
@ -184,5 +184,15 @@ datehook_mod_SOURCES = hook/datehook.c
|
||||||
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For loadbios.mod
|
||||||
|
loadbios_mod_SOURCES = commands/efi/loadbios.c
|
||||||
|
loadbios_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
loadbios_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For fixvideo.mod
|
||||||
|
fixvideo_mod_SOURCES = commands/efi/fixvideo.c
|
||||||
|
fixvideo_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
fixvideo_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
include $(srcdir)/conf/i386.mk
|
include $(srcdir)/conf/i386.mk
|
||||||
include $(srcdir)/conf/common.mk
|
include $(srcdir)/conf/common.mk
|
||||||
|
|
|
@ -108,7 +108,7 @@ grub-install: util/i386/efi/grub-install.in $(util/i386/efi/grub-install.in_DEPE
|
||||||
# Modules.
|
# Modules.
|
||||||
pkglib_MODULES = kernel.mod normal.mod chain.mod appleldr.mod \
|
pkglib_MODULES = kernel.mod normal.mod chain.mod appleldr.mod \
|
||||||
halt.mod reboot.mod linux.mod pci.mod lspci.mod \
|
halt.mod reboot.mod linux.mod pci.mod lspci.mod \
|
||||||
datetime.mod date.mod datehook.mod
|
datetime.mod date.mod datehook.mod loadbios.mod fixvideo.mod
|
||||||
|
|
||||||
# For kernel.mod.
|
# For kernel.mod.
|
||||||
kernel_mod_EXPORTS = no
|
kernel_mod_EXPORTS = no
|
||||||
|
@ -1767,5 +1767,119 @@ partmap-datehook_mod-hook_datehook.lst: hook/datehook.c $(hook/datehook.c_DEPEND
|
||||||
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For loadbios.mod
|
||||||
|
loadbios_mod_SOURCES = commands/efi/loadbios.c
|
||||||
|
CLEANFILES += loadbios.mod mod-loadbios.o mod-loadbios.c pre-loadbios.o loadbios_mod-commands_efi_loadbios.o und-loadbios.lst
|
||||||
|
ifneq ($(loadbios_mod_EXPORTS),no)
|
||||||
|
CLEANFILES += def-loadbios.lst
|
||||||
|
DEFSYMFILES += def-loadbios.lst
|
||||||
|
endif
|
||||||
|
MOSTLYCLEANFILES += loadbios_mod-commands_efi_loadbios.d
|
||||||
|
UNDSYMFILES += und-loadbios.lst
|
||||||
|
|
||||||
|
loadbios.mod: pre-loadbios.o mod-loadbios.o $(TARGET_OBJ2ELF)
|
||||||
|
-rm -f $@
|
||||||
|
$(TARGET_CC) $(loadbios_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ pre-loadbios.o mod-loadbios.o
|
||||||
|
if test ! -z $(TARGET_OBJ2ELF); then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
|
||||||
|
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@
|
||||||
|
|
||||||
|
pre-loadbios.o: $(loadbios_mod_DEPENDENCIES) loadbios_mod-commands_efi_loadbios.o
|
||||||
|
-rm -f $@
|
||||||
|
$(TARGET_CC) $(loadbios_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ loadbios_mod-commands_efi_loadbios.o
|
||||||
|
|
||||||
|
mod-loadbios.o: mod-loadbios.c
|
||||||
|
$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(loadbios_mod_CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
mod-loadbios.c: $(builddir)/moddep.lst $(srcdir)/genmodsrc.sh
|
||||||
|
sh $(srcdir)/genmodsrc.sh 'loadbios' $< > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
ifneq ($(loadbios_mod_EXPORTS),no)
|
||||||
|
def-loadbios.lst: pre-loadbios.o
|
||||||
|
$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 loadbios/' > $@
|
||||||
|
endif
|
||||||
|
|
||||||
|
und-loadbios.lst: pre-loadbios.o
|
||||||
|
echo 'loadbios' > $@
|
||||||
|
$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
|
||||||
|
|
||||||
|
loadbios_mod-commands_efi_loadbios.o: commands/efi/loadbios.c $(commands/efi/loadbios.c_DEPENDENCIES)
|
||||||
|
$(TARGET_CC) -Icommands/efi -I$(srcdir)/commands/efi $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(loadbios_mod_CFLAGS) -MD -c -o $@ $<
|
||||||
|
-include loadbios_mod-commands_efi_loadbios.d
|
||||||
|
|
||||||
|
CLEANFILES += cmd-loadbios_mod-commands_efi_loadbios.lst fs-loadbios_mod-commands_efi_loadbios.lst partmap-loadbios_mod-commands_efi_loadbios.lst
|
||||||
|
COMMANDFILES += cmd-loadbios_mod-commands_efi_loadbios.lst
|
||||||
|
FSFILES += fs-loadbios_mod-commands_efi_loadbios.lst
|
||||||
|
PARTMAPFILES += partmap-loadbios_mod-commands_efi_loadbios.lst
|
||||||
|
|
||||||
|
cmd-loadbios_mod-commands_efi_loadbios.lst: commands/efi/loadbios.c $(commands/efi/loadbios.c_DEPENDENCIES) gencmdlist.sh
|
||||||
|
set -e; $(TARGET_CC) -Icommands/efi -I$(srcdir)/commands/efi $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(loadbios_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh loadbios > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
fs-loadbios_mod-commands_efi_loadbios.lst: commands/efi/loadbios.c $(commands/efi/loadbios.c_DEPENDENCIES) genfslist.sh
|
||||||
|
set -e; $(TARGET_CC) -Icommands/efi -I$(srcdir)/commands/efi $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(loadbios_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh loadbios > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
partmap-loadbios_mod-commands_efi_loadbios.lst: commands/efi/loadbios.c $(commands/efi/loadbios.c_DEPENDENCIES) genpartmaplist.sh
|
||||||
|
set -e; $(TARGET_CC) -Icommands/efi -I$(srcdir)/commands/efi $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(loadbios_mod_CFLAGS) -E $< | sh $(srcdir)/genpartmaplist.sh loadbios > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
|
||||||
|
loadbios_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
loadbios_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For fixvideo.mod
|
||||||
|
fixvideo_mod_SOURCES = commands/efi/fixvideo.c
|
||||||
|
CLEANFILES += fixvideo.mod mod-fixvideo.o mod-fixvideo.c pre-fixvideo.o fixvideo_mod-commands_efi_fixvideo.o und-fixvideo.lst
|
||||||
|
ifneq ($(fixvideo_mod_EXPORTS),no)
|
||||||
|
CLEANFILES += def-fixvideo.lst
|
||||||
|
DEFSYMFILES += def-fixvideo.lst
|
||||||
|
endif
|
||||||
|
MOSTLYCLEANFILES += fixvideo_mod-commands_efi_fixvideo.d
|
||||||
|
UNDSYMFILES += und-fixvideo.lst
|
||||||
|
|
||||||
|
fixvideo.mod: pre-fixvideo.o mod-fixvideo.o $(TARGET_OBJ2ELF)
|
||||||
|
-rm -f $@
|
||||||
|
$(TARGET_CC) $(fixvideo_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ pre-fixvideo.o mod-fixvideo.o
|
||||||
|
if test ! -z $(TARGET_OBJ2ELF); then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
|
||||||
|
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@
|
||||||
|
|
||||||
|
pre-fixvideo.o: $(fixvideo_mod_DEPENDENCIES) fixvideo_mod-commands_efi_fixvideo.o
|
||||||
|
-rm -f $@
|
||||||
|
$(TARGET_CC) $(fixvideo_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ fixvideo_mod-commands_efi_fixvideo.o
|
||||||
|
|
||||||
|
mod-fixvideo.o: mod-fixvideo.c
|
||||||
|
$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(fixvideo_mod_CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
mod-fixvideo.c: $(builddir)/moddep.lst $(srcdir)/genmodsrc.sh
|
||||||
|
sh $(srcdir)/genmodsrc.sh 'fixvideo' $< > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
ifneq ($(fixvideo_mod_EXPORTS),no)
|
||||||
|
def-fixvideo.lst: pre-fixvideo.o
|
||||||
|
$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 fixvideo/' > $@
|
||||||
|
endif
|
||||||
|
|
||||||
|
und-fixvideo.lst: pre-fixvideo.o
|
||||||
|
echo 'fixvideo' > $@
|
||||||
|
$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
|
||||||
|
|
||||||
|
fixvideo_mod-commands_efi_fixvideo.o: commands/efi/fixvideo.c $(commands/efi/fixvideo.c_DEPENDENCIES)
|
||||||
|
$(TARGET_CC) -Icommands/efi -I$(srcdir)/commands/efi $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(fixvideo_mod_CFLAGS) -MD -c -o $@ $<
|
||||||
|
-include fixvideo_mod-commands_efi_fixvideo.d
|
||||||
|
|
||||||
|
CLEANFILES += cmd-fixvideo_mod-commands_efi_fixvideo.lst fs-fixvideo_mod-commands_efi_fixvideo.lst partmap-fixvideo_mod-commands_efi_fixvideo.lst
|
||||||
|
COMMANDFILES += cmd-fixvideo_mod-commands_efi_fixvideo.lst
|
||||||
|
FSFILES += fs-fixvideo_mod-commands_efi_fixvideo.lst
|
||||||
|
PARTMAPFILES += partmap-fixvideo_mod-commands_efi_fixvideo.lst
|
||||||
|
|
||||||
|
cmd-fixvideo_mod-commands_efi_fixvideo.lst: commands/efi/fixvideo.c $(commands/efi/fixvideo.c_DEPENDENCIES) gencmdlist.sh
|
||||||
|
set -e; $(TARGET_CC) -Icommands/efi -I$(srcdir)/commands/efi $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(fixvideo_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh fixvideo > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
fs-fixvideo_mod-commands_efi_fixvideo.lst: commands/efi/fixvideo.c $(commands/efi/fixvideo.c_DEPENDENCIES) genfslist.sh
|
||||||
|
set -e; $(TARGET_CC) -Icommands/efi -I$(srcdir)/commands/efi $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(fixvideo_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh fixvideo > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
partmap-fixvideo_mod-commands_efi_fixvideo.lst: commands/efi/fixvideo.c $(commands/efi/fixvideo.c_DEPENDENCIES) genpartmaplist.sh
|
||||||
|
set -e; $(TARGET_CC) -Icommands/efi -I$(srcdir)/commands/efi $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(fixvideo_mod_CFLAGS) -E $< | sh $(srcdir)/genpartmaplist.sh fixvideo > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
|
||||||
|
fixvideo_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
fixvideo_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
include $(srcdir)/conf/i386.mk
|
include $(srcdir)/conf/i386.mk
|
||||||
include $(srcdir)/conf/common.mk
|
include $(srcdir)/conf/common.mk
|
||||||
|
|
|
@ -83,7 +83,7 @@ grub_install_SOURCES = util/i386/efi/grub-install.in
|
||||||
# Modules.
|
# Modules.
|
||||||
pkglib_MODULES = kernel.mod normal.mod chain.mod appleldr.mod \
|
pkglib_MODULES = kernel.mod normal.mod chain.mod appleldr.mod \
|
||||||
halt.mod reboot.mod linux.mod pci.mod lspci.mod \
|
halt.mod reboot.mod linux.mod pci.mod lspci.mod \
|
||||||
datetime.mod date.mod datehook.mod
|
datetime.mod date.mod datehook.mod loadbios.mod fixvideo.mod
|
||||||
|
|
||||||
# For kernel.mod.
|
# For kernel.mod.
|
||||||
kernel_mod_EXPORTS = no
|
kernel_mod_EXPORTS = no
|
||||||
|
@ -187,5 +187,15 @@ datehook_mod_SOURCES = hook/datehook.c
|
||||||
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For loadbios.mod
|
||||||
|
loadbios_mod_SOURCES = commands/efi/loadbios.c
|
||||||
|
loadbios_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
loadbios_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For fixvideo.mod
|
||||||
|
fixvideo_mod_SOURCES = commands/efi/fixvideo.c
|
||||||
|
fixvideo_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
fixvideo_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
include $(srcdir)/conf/i386.mk
|
include $(srcdir)/conf/i386.mk
|
||||||
include $(srcdir)/conf/common.mk
|
include $(srcdir)/conf/common.mk
|
||||||
|
|
|
@ -933,7 +933,7 @@ struct grub_efi_configuration_table
|
||||||
{
|
{
|
||||||
grub_efi_guid_t vendor_guid;
|
grub_efi_guid_t vendor_guid;
|
||||||
void *vendor_table;
|
void *vendor_table;
|
||||||
};
|
} __attribute__ ((packed));
|
||||||
typedef struct grub_efi_configuration_table grub_efi_configuration_table_t;
|
typedef struct grub_efi_configuration_table grub_efi_configuration_table_t;
|
||||||
|
|
||||||
struct grub_efi_simple_input_interface
|
struct grub_efi_simple_input_interface
|
||||||
|
|
|
@ -32,4 +32,39 @@ grub_pci_read (grub_pci_address_t addr)
|
||||||
return grub_inl (GRUB_PCI_DATA_REG);
|
return grub_inl (GRUB_PCI_DATA_REG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline grub_uint16_t
|
||||||
|
grub_pci_read_word (grub_pci_address_t addr)
|
||||||
|
{
|
||||||
|
grub_outl (addr & ~3, GRUB_PCI_ADDR_REG);
|
||||||
|
return grub_inw (GRUB_PCI_DATA_REG + (addr & 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline grub_uint8_t
|
||||||
|
grub_pci_read_byte (grub_pci_address_t addr)
|
||||||
|
{
|
||||||
|
grub_outl (addr & ~3, GRUB_PCI_ADDR_REG);
|
||||||
|
return grub_inb (GRUB_PCI_DATA_REG + (addr & 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
grub_pci_write (grub_pci_address_t addr, grub_uint32_t data)
|
||||||
|
{
|
||||||
|
grub_outl (addr, GRUB_PCI_ADDR_REG);
|
||||||
|
grub_outl (data, GRUB_PCI_DATA_REG);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
grub_pci_write_word (grub_pci_address_t addr, grub_uint16_t data)
|
||||||
|
{
|
||||||
|
grub_outl (addr & ~3, GRUB_PCI_ADDR_REG);
|
||||||
|
grub_outw (data, GRUB_PCI_DATA_REG + (addr & 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
grub_pci_write_byte (grub_pci_address_t addr, grub_uint8_t data)
|
||||||
|
{
|
||||||
|
grub_outl (addr & ~3, GRUB_PCI_ADDR_REG);
|
||||||
|
grub_outb (data, GRUB_PCI_DATA_REG + (addr & 3));
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* GRUB_CPU_PCI_H */
|
#endif /* GRUB_CPU_PCI_H */
|
||||||
|
|
|
@ -36,8 +36,8 @@
|
||||||
#define GRUB_PCI_ADDR_IO_MASK ~0x03
|
#define GRUB_PCI_ADDR_IO_MASK ~0x03
|
||||||
|
|
||||||
typedef grub_uint32_t grub_pci_id_t;
|
typedef grub_uint32_t grub_pci_id_t;
|
||||||
typedef int (*grub_pci_iteratefunc_t) (int bus, int device, int func,
|
typedef int NESTED_FUNC_ATTR (*grub_pci_iteratefunc_t)
|
||||||
grub_pci_id_t pciid);
|
(int bus, int device, int func, grub_pci_id_t pciid);
|
||||||
typedef grub_uint32_t grub_pci_address_t;
|
typedef grub_uint32_t grub_pci_address_t;
|
||||||
|
|
||||||
grub_pci_address_t EXPORT_FUNC(grub_pci_make_address) (int bus, int device,
|
grub_pci_address_t EXPORT_FUNC(grub_pci_make_address) (int bus, int device,
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <grub/efi/api.h>
|
#include <grub/efi/api.h>
|
||||||
#include <grub/efi/efi.h>
|
#include <grub/efi/efi.h>
|
||||||
#include <grub/efi/uga_draw.h>
|
#include <grub/efi/uga_draw.h>
|
||||||
|
#include <grub/pci.h>
|
||||||
#include <grub/command.h>
|
#include <grub/command.h>
|
||||||
|
|
||||||
#define GRUB_LINUX_CL_OFFSET 0x1000
|
#define GRUB_LINUX_CL_OFFSET 0x1000
|
||||||
|
@ -283,57 +284,6 @@ grub_e820_add_region (struct grub_e820_mmap *e820_map, int *e820_num,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_efi_guid_t acpi_guid = GRUB_EFI_ACPI_TABLE_GUID;
|
|
||||||
static grub_efi_guid_t acpi2_guid = GRUB_EFI_ACPI_20_TABLE_GUID;
|
|
||||||
|
|
||||||
#define EBDA_SEG_ADDR 0x40e
|
|
||||||
#define LOW_MEM_ADDR 0x413
|
|
||||||
#define FAKE_EBDA_SEG 0x9fc0
|
|
||||||
|
|
||||||
static void
|
|
||||||
fake_bios_data (void)
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
void *acpi;
|
|
||||||
grub_uint16_t *ebda_seg_ptr, *low_mem_ptr;
|
|
||||||
|
|
||||||
acpi = 0;
|
|
||||||
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
|
|
||||||
{
|
|
||||||
grub_efi_guid_t *guid =
|
|
||||||
&grub_efi_system_table->configuration_table[i].vendor_guid;
|
|
||||||
|
|
||||||
if (! grub_memcmp (guid, &acpi2_guid, sizeof (grub_efi_guid_t)))
|
|
||||||
{
|
|
||||||
acpi = grub_efi_system_table->configuration_table[i].vendor_table;
|
|
||||||
grub_dprintf ("linux", "ACPI2: %p\n", acpi);
|
|
||||||
}
|
|
||||||
else if (! grub_memcmp (guid, &acpi_guid, sizeof (grub_efi_guid_t)))
|
|
||||||
{
|
|
||||||
void *t;
|
|
||||||
|
|
||||||
t = grub_efi_system_table->configuration_table[i].vendor_table;
|
|
||||||
if (! acpi)
|
|
||||||
acpi = t;
|
|
||||||
grub_dprintf ("linux", "ACPI: %p\n", t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (acpi == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ebda_seg_ptr = (grub_uint16_t *) EBDA_SEG_ADDR;
|
|
||||||
low_mem_ptr = (grub_uint16_t *) LOW_MEM_ADDR;
|
|
||||||
|
|
||||||
if ((*ebda_seg_ptr) || (*low_mem_ptr))
|
|
||||||
return;
|
|
||||||
|
|
||||||
*ebda_seg_ptr = FAKE_EBDA_SEG;
|
|
||||||
*low_mem_ptr = FAKE_EBDA_SEG >> 6;
|
|
||||||
|
|
||||||
grub_memcpy ((char *) (FAKE_EBDA_SEG << 4), acpi, 1024);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __x86_64__
|
#ifdef __x86_64__
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
@ -353,8 +303,6 @@ grub_linux_boot (void)
|
||||||
grub_efi_memory_descriptor_t *desc;
|
grub_efi_memory_descriptor_t *desc;
|
||||||
int e820_num;
|
int e820_num;
|
||||||
|
|
||||||
fake_bios_data ();
|
|
||||||
|
|
||||||
params = real_mode_mem;
|
params = real_mode_mem;
|
||||||
|
|
||||||
grub_dprintf ("linux", "code32_start = %x, idt_desc = %lx, gdt_desc = %lx\n",
|
grub_dprintf ("linux", "code32_start = %x, idt_desc = %lx, gdt_desc = %lx\n",
|
||||||
|
@ -520,17 +468,10 @@ static grub_efi_guid_t uga_draw_guid = GRUB_EFI_UGA_DRAW_GUID;
|
||||||
#define FBTEST_STEP (0x10000 >> 2)
|
#define FBTEST_STEP (0x10000 >> 2)
|
||||||
#define FBTEST_COUNT 8
|
#define FBTEST_COUNT 8
|
||||||
|
|
||||||
static grub_uint32_t fb_list[]=
|
|
||||||
{0x40000000, 0x80000000, 0xc0000000, 0};
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
find_framebuf (grub_uint32_t *fb_base, grub_uint32_t *line_len)
|
find_line_len (grub_uint32_t *fb_base, grub_uint32_t *line_len)
|
||||||
{
|
{
|
||||||
grub_uint32_t *fb;
|
grub_uint32_t *base = (grub_uint32_t *) (grub_target_addr_t) *fb_base;
|
||||||
|
|
||||||
for (fb = fb_list; *fb; fb++)
|
|
||||||
{
|
|
||||||
grub_uint32_t *base = (grub_uint32_t *) (grub_target_addr_t) *fb;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < FBTEST_COUNT; i++, base += FBTEST_STEP)
|
for (i = 0; i < FBTEST_COUNT; i++, base += FBTEST_STEP)
|
||||||
|
@ -546,15 +487,87 @@ find_framebuf (grub_uint32_t *fb_base, grub_uint32_t *line_len)
|
||||||
*fb_base = (grub_uint32_t) (grub_target_addr_t) base;
|
*fb_base = (grub_uint32_t) (grub_target_addr_t) base;
|
||||||
*line_len = j << 2;
|
*line_len = j << 2;
|
||||||
|
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
find_framebuf (grub_uint32_t *fb_base, grub_uint32_t *line_len)
|
||||||
|
{
|
||||||
|
int found = 0;
|
||||||
|
|
||||||
|
auto int NESTED_FUNC_ATTR find_card (int bus, int dev, int func,
|
||||||
|
grub_pci_id_t pciid);
|
||||||
|
|
||||||
|
int NESTED_FUNC_ATTR find_card (int bus, int dev, int func,
|
||||||
|
grub_pci_id_t pciid)
|
||||||
|
{
|
||||||
|
grub_pci_address_t addr;
|
||||||
|
|
||||||
|
addr = grub_pci_make_address (bus, dev, func, 2);
|
||||||
|
if (grub_pci_read (addr) >> 24 == 0x3)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
grub_printf ("Display controller: %d:%d.%d\nDevice id: %x\n",
|
||||||
|
bus, dev, func, pciid);
|
||||||
|
addr += 8;
|
||||||
|
for (i = 0; i < 6; i++, addr += 4)
|
||||||
|
{
|
||||||
|
grub_uint32_t old_bar1, old_bar2, type;
|
||||||
|
grub_uint64_t base64;
|
||||||
|
|
||||||
|
old_bar1 = grub_pci_read (addr);
|
||||||
|
if ((! old_bar1) || (old_bar1 & GRUB_PCI_ADDR_SPACE_IO))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
type = old_bar1 & GRUB_PCI_ADDR_MEM_TYPE_MASK;
|
||||||
|
if (type == GRUB_PCI_ADDR_MEM_TYPE_64)
|
||||||
|
{
|
||||||
|
if (i == 5)
|
||||||
|
break;
|
||||||
|
|
||||||
|
old_bar2 = grub_pci_read (addr + 4);
|
||||||
}
|
}
|
||||||
return 1;
|
else
|
||||||
|
old_bar2 = 0;
|
||||||
|
|
||||||
|
base64 = old_bar2;
|
||||||
|
base64 <<= 32;
|
||||||
|
base64 |= (old_bar1 & GRUB_PCI_ADDR_MEM_MASK);
|
||||||
|
|
||||||
|
grub_printf ("%s(%d): 0x%llx\n",
|
||||||
|
((old_bar1 & GRUB_PCI_ADDR_MEM_PREFETCH) ?
|
||||||
|
"VMEM" : "MMIO"), i,
|
||||||
|
(unsigned long long) base64);
|
||||||
|
|
||||||
|
if ((old_bar1 & GRUB_PCI_ADDR_MEM_PREFETCH) && (! found))
|
||||||
|
{
|
||||||
|
*fb_base = base64;
|
||||||
|
if (find_line_len (fb_base, line_len))
|
||||||
|
found++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == GRUB_PCI_ADDR_MEM_TYPE_64)
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
addr += 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_pci_iterate (find_card);
|
||||||
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -580,13 +593,13 @@ grub_linux_setup_video (struct linux_kernel_params *params)
|
||||||
ret = find_framebuf (&fb_base, &line_len);
|
ret = find_framebuf (&fb_base, &line_len);
|
||||||
grub_efi_set_text_mode (1);
|
grub_efi_set_text_mode (1);
|
||||||
|
|
||||||
if (ret)
|
if (! ret)
|
||||||
{
|
{
|
||||||
grub_printf ("Can\'t find frame buffer address\n");
|
grub_printf ("Can\'t find frame buffer address\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_printf ("Video frame buffer: 0x%x\n", fb_base);
|
grub_printf ("Frame buffer base: 0x%x\n", fb_base);
|
||||||
grub_printf ("Video line length: %d\n", line_len);
|
grub_printf ("Video line length: %d\n", line_len);
|
||||||
|
|
||||||
params->lfb_width = width;
|
params->lfb_width = width;
|
||||||
|
@ -606,6 +619,9 @@ grub_linux_setup_video (struct linux_kernel_params *params)
|
||||||
params->reserved_mask_size = 8;
|
params->reserved_mask_size = 8;
|
||||||
params->reserved_field_pos = 24;
|
params->reserved_field_pos = 24;
|
||||||
|
|
||||||
|
params->have_vga = GRUB_VIDEO_TYPE_VLFB;
|
||||||
|
params->vid_mode = 0x338; /* 1024x768x32 */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,7 +637,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||||
grub_ssize_t len;
|
grub_ssize_t len;
|
||||||
int i;
|
int i;
|
||||||
char *dest;
|
char *dest;
|
||||||
int video_type;
|
|
||||||
|
|
||||||
grub_dl_ref (my_mod);
|
grub_dl_ref (my_mod);
|
||||||
|
|
||||||
|
@ -808,9 +823,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||||
grub_printf (" [Linux-bzImage, setup=0x%x, size=0x%x]\n",
|
grub_printf (" [Linux-bzImage, setup=0x%x, size=0x%x]\n",
|
||||||
(unsigned) real_size, (unsigned) prot_size);
|
(unsigned) real_size, (unsigned) prot_size);
|
||||||
|
|
||||||
|
grub_linux_setup_video (params);
|
||||||
|
|
||||||
/* Detect explicitly specified memory size, if any. */
|
/* Detect explicitly specified memory size, if any. */
|
||||||
linux_mem_size = 0;
|
linux_mem_size = 0;
|
||||||
video_type = 0;
|
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
if (grub_memcmp (argv[i], "mem=", 4) == 0)
|
if (grub_memcmp (argv[i], "mem=", 4) == 0)
|
||||||
{
|
{
|
||||||
|
@ -846,18 +862,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||||
linux_mem_size <<= shift;
|
linux_mem_size <<= shift;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (grub_memcmp (argv[i], "video=", 6) == 0)
|
else if (grub_memcmp (argv[i], "video=efifb", 11) == 0)
|
||||||
{
|
{
|
||||||
if (grub_memcmp (&argv[i][6], "vesafb", 6) == 0)
|
if (params->have_vga)
|
||||||
video_type = GRUB_VIDEO_TYPE_VLFB;
|
params->have_vga = GRUB_VIDEO_TYPE_EFI;
|
||||||
else if (grub_memcmp (&argv[i][6], "efifb", 5) == 0)
|
|
||||||
video_type = GRUB_VIDEO_TYPE_EFI;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (video_type)
|
|
||||||
{
|
|
||||||
if (! grub_linux_setup_video (params))
|
|
||||||
params->have_vga = video_type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Specify the boot file. */
|
/* Specify the boot file. */
|
||||||
|
|
58
util/grub-dumpbios.in
Normal file
58
util/grub-dumpbios.in
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
#! /bin/sh
|
||||||
|
#
|
||||||
|
# Copyright (C) 2009 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/>.
|
||||||
|
|
||||||
|
# Usage: usage
|
||||||
|
# Print the usage.
|
||||||
|
usage () {
|
||||||
|
cat <<EOF
|
||||||
|
Usage: $0 [OPTION]
|
||||||
|
Create vbios and int10 dump
|
||||||
|
|
||||||
|
-o, --output=DIR set output directory
|
||||||
|
-h, --help print this message and exit
|
||||||
|
-v, --version print the version information and exit
|
||||||
|
|
||||||
|
Report bugs to <bug-grub@gnu.org>.
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check the arguments.
|
||||||
|
for option in "$@"; do
|
||||||
|
case "$option" in
|
||||||
|
-h | --help)
|
||||||
|
usage
|
||||||
|
exit 0 ;;
|
||||||
|
-v | --version)
|
||||||
|
echo "$0 (GNU GRUB @PACKAGE_VERSION@)"
|
||||||
|
exit 0 ;;
|
||||||
|
-o)
|
||||||
|
shift
|
||||||
|
output_dir=$1
|
||||||
|
;;
|
||||||
|
--output=)
|
||||||
|
output_dir=`echo "$option" | sed 's/--output=//'`
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
echo "Unrecognized option \`$option'" 1>&2
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
dd if=/dev/mem of=${output_dir}vbios.bin bs=65536 skip=12 count=1
|
||||||
|
dd if=/dev/mem of=${output_dir}int10.bin bs=4 skip=16 count=1
|
Loading…
Add table
Reference in a new issue