2006-04-18 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added conf/i386-efi.mk, conf/i386-efi.rmk, include/grub/efi/api.h, include/grub/efi/console_control.h, include/grub/efi/efi.h, include/grub/efi/pe32.h, include/grub/i386/efi/time.h, kern/efi/efi.c, kern/i386/efi/init.c, kern/i386/efi/startup.S, and util/i386/efi/grub-mkimage.c. * Makefile.in (RMKFILES): Added i386-efi.rmk. * genmk.rb (PModule#rule): Do not export symbols if #{prefix}_EXPORTS is set to "no". * conf/i386-efi.mk: New file. * conf/i386-efi.rmk: Likewise. * include/grub/efi/api.h: Likewise. * include/grub/efi/console_control.h: Likewise. * include/grub/efi/efi.h: Likewise. * include/grub/efi/pe32.h: Likewise. * include/grub/i386/efi/time.h: Likewise. * kern/efi/efi.c: Likewise. * kern/i386/efi/init.c: Likewise. * kern/i386/efi/startup.S: Likewise. * util/i386/efi/grub-mkimage.c: Likewise.
This commit is contained in:
parent
bfa2bd9efb
commit
837091258d
19 changed files with 3804 additions and 182 deletions
97
kern/efi/efi.c
Normal file
97
kern/efi/efi.c
Normal file
|
@ -0,0 +1,97 @@
|
|||
/* efi.c - generic EFI support */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
*
|
||||
* This program 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 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <grub/misc.h>
|
||||
#include <grub/efi/api.h>
|
||||
#include <grub/efi/efi.h>
|
||||
#include <grub/efi/console_control.h>
|
||||
|
||||
/* The handle of GRUB itself. Filled in by the startup code. */
|
||||
grub_efi_handle_t grub_efi_image_handle;
|
||||
|
||||
/* The pointer to a system table. Filled in by the startup code. */
|
||||
grub_efi_system_table_t *grub_efi_system_table;
|
||||
|
||||
static grub_efi_guid_t grub_efi_console_control_guid = GRUB_EFI_CONSOLE_CONTROL_GUID;
|
||||
|
||||
void *
|
||||
grub_efi_locate_protocol (grub_efi_guid_t *protocol, void *registration)
|
||||
{
|
||||
void *interface;
|
||||
grub_efi_status_t status;
|
||||
|
||||
status = grub_efi_system_table->boot_services->locate_protocol (protocol,
|
||||
registration,
|
||||
&interface);
|
||||
if (status != GRUB_EFI_SUCCESS)
|
||||
return 0;
|
||||
|
||||
return interface;
|
||||
}
|
||||
|
||||
int
|
||||
grub_efi_set_text_mode (int on)
|
||||
{
|
||||
grub_efi_console_control_protocol_t *c;
|
||||
grub_efi_screen_mode_t mode, new_mode;
|
||||
|
||||
c = grub_efi_locate_protocol (&grub_efi_console_control_guid, 0);
|
||||
if (! c)
|
||||
return 0;
|
||||
|
||||
if (c->get_mode (c, &mode, 0, 0) != GRUB_EFI_SUCCESS)
|
||||
return 0;
|
||||
|
||||
new_mode = on ? GRUB_EFI_SCREEN_TEXT : GRUB_EFI_SCREEN_GRAPHICS;
|
||||
if (mode != new_mode)
|
||||
if (c->set_mode (c, new_mode) != GRUB_EFI_SUCCESS)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
grub_efi_exit (void)
|
||||
{
|
||||
grub_efi_system_table->boot_services->exit (grub_efi_image_handle,
|
||||
GRUB_EFI_SUCCESS,
|
||||
0, 0);
|
||||
}
|
||||
|
||||
int
|
||||
grub_efi_output_string (const char *str)
|
||||
{
|
||||
grub_efi_simple_text_output_interface_t *o;
|
||||
grub_size_t len = grub_strlen (str);
|
||||
grub_efi_char16_t utf16_str[len + 1];
|
||||
grub_efi_status_t status;
|
||||
|
||||
/* XXX Assume that STR is all ASCII characters. */
|
||||
do
|
||||
{
|
||||
utf16_str[len] = str[len];
|
||||
}
|
||||
while (len--);
|
||||
|
||||
o = grub_efi_system_table->con_out;
|
||||
status = o->output_string (o, utf16_str);
|
||||
return status >= 0;
|
||||
}
|
||||
|
69
kern/i386/efi/init.c
Normal file
69
kern/i386/efi/init.c
Normal file
|
@ -0,0 +1,69 @@
|
|||
/* init.c - initialize an x86-based EFI system */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
*
|
||||
* This program 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 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/cache.h>
|
||||
#include <grub/kernel.h>
|
||||
#include <grub/efi/efi.h>
|
||||
#include <grub/machine/time.h>
|
||||
|
||||
void
|
||||
grub_stop (void)
|
||||
{
|
||||
grub_efi_exit ();
|
||||
}
|
||||
|
||||
grub_uint32_t
|
||||
grub_get_rtc (void)
|
||||
{
|
||||
return 0; /* FIXME */
|
||||
}
|
||||
|
||||
void
|
||||
grub_machine_init (void)
|
||||
{
|
||||
grub_efi_set_text_mode (1);
|
||||
grub_efi_output_string ("test!\r\n");
|
||||
|
||||
/* Stop immediately at the moment... */
|
||||
grub_stop ();
|
||||
}
|
||||
|
||||
void
|
||||
grub_machine_fini (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
grub_arch_sync_caches (void *address __attribute__ ((unused)),
|
||||
grub_size_t len __attribute__ ((unused)))
|
||||
{
|
||||
}
|
||||
|
||||
grub_addr_t
|
||||
grub_arch_modules_addr (void)
|
||||
{
|
||||
return 0;
|
||||
}
|
65
kern/i386/efi/startup.S
Normal file
65
kern/i386/efi/startup.S
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* startup.S - bootstrap GRUB itself */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
*
|
||||
* This program 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 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/boot.h>
|
||||
|
||||
.file "startup.S"
|
||||
.text
|
||||
.globl start, _start
|
||||
start:
|
||||
_start:
|
||||
jmp codestart
|
||||
|
||||
/*
|
||||
* Compatibility version number
|
||||
*
|
||||
* These MUST be at byte offset 6 and 7 of the executable
|
||||
* DO NOT MOVE !!!
|
||||
*/
|
||||
. = EXT_C(start) + 0x6
|
||||
.byte GRUB_BOOT_VERSION_MAJOR, GRUB_BOOT_VERSION_MINOR
|
||||
|
||||
/*
|
||||
* This is a special data area 8 bytes from the beginning.
|
||||
*/
|
||||
|
||||
. = EXT_C(start) + 0x8
|
||||
|
||||
VARIABLE(grub_prefix)
|
||||
.string "/boot/grub"
|
||||
|
||||
/*
|
||||
* Leave some breathing room for the prefix.
|
||||
*/
|
||||
|
||||
. = EXT_C(start) + 0x50
|
||||
|
||||
codestart:
|
||||
/*
|
||||
* EFI_SYSTEM_TABLE * and EFI_HANDLE are passed on the stack.
|
||||
*/
|
||||
movl 4(%esp), %eax
|
||||
movl %eax, EXT_C(grub_efi_image_handle)
|
||||
movl 8(%esp), %eax
|
||||
movl %eax, EXT_C(grub_efi_system_table)
|
||||
call EXT_C(grub_main)
|
||||
ret
|
Loading…
Add table
Add a link
Reference in a new issue