2006-04-23 Yoshinori K. Okuji <okuji@enbug.org>

Use grub_abort instead of grub_stop, and grub_exit must be
        define in each architecture now. Also, this change adds support
        for EFI disks.

        * util/i386/pc/grub-probefs.c: Include grub/term.h.
        (grub_getkey): New function.
        (grub_term_get_current): Likewise.

        * util/i386/pc/grub-setup.c: Include grub/term.h.
        (grub_getkey): New function.
        (grub_term_get_current): Likewise.

        * util/misc.c (grub_stop): Renamed to ...
        (grub_exit): ... this.

        * kern/powerpc/ieee1275/init.c (abort): Renamed to ...
        (grub_exit): ... this.
        (grub_machine_init): Use grub_abort instead of abort.
        (grub_stop): Removed.

        * kern/powerpc/ieee1275/cmain.c (cmain): Use grub_abort instead of
        abort.

        * kern/i386/pc/startup.S (grub_exit): New function.
        (cold_reboot): New label.

        * kern/efi/init.c: Include grub/efi/disk.h and grub/env.h.
        (grub_efi_init): Call grub_efidisk_init.
        (grub_efi_fini): Call grub_efidisk_fini.

        * kern/efi/efi.c: Include grub/mm.h.
        (grub_efi_console_control_guid): Renamed to ...
        (console_control_guid): ... this.
        (grub_efi_loaded_image_guid): Renamed to ...
        (loaded_image_guid): ... this.
        (grub_efi_locate_handle): New function.
        (grub_efi_open_protocol): Likewise.
        (grub_efi_set_text_mode): Use CONSOLE_CONTROL_GUID instead of
        GRUB_EFI_CONSOLE_CONTROL_GUID.
        (grub_efi_exit): Removed.
        (grub_stop): Likewise.
        (grub_efi_get_loaded_image): Use grub_efi_open_protocol.
        (grub_exit): New function.
        (grub_print_device_path): Likewise.

        * kern/rescue.c (grub_rescue_cmd_exit): New function.
        (grub_enter_rescue_mode): Register "exit".

        * kern/misc.c (grub_real_dprintf): A cosmetic change.
        (grub_abort): New function.

        * kern/err.c (grub_fatal): Use grub_abort instead of grub_stop.

        * include/grub/sparc64/ieee1275/kernel.h (abort): Removed.

        * include/grub/powerpc/ieee1275/kernel.h (abort): Removed.

        * include/grub/efi/efi.h (grub_efi_exit): Removed.
        (grub_print_device_path): New prototype.
        (grub_efi_locate_handle): Likewise.
        (grub_efi_open_protocol): Likewise.

        * include/grub/efi/disk.h (grub_efidisk_fini): New file.
        * disk/efi/efidisk.c: Likewise.

        * DISTLIST: Added disk/efi/efidisk.c and include/grub/efi/disk.h.

        * include/grub/efi/console_control.h
        (GRUB_EFI_CONSOLE_CONTROL_GUID): Use an array for the last 8 bytes.

        * include/grub/efi/api.h (GRUB_EFI_LOADED_IMAGE_GUID): Specify the
        last 8 bytes as an array.
        (GRUB_EFI_DISK_IO_GUID): New macro.
        (GRUB_EFI_BLOCK_IO_GUID): Likewise.
        (GRUB_EFI_DEVICE_PATH_GUID): Likewise.
        (grub_efi_ipv6_address_t): Change the type to grub_uint16_t from
        grub_uint8_t.
        (struct grub_efi_guid): Use an array to specify the last 8 bytes.
        (struct grub_efi_device_path): Rename the member "sub_type" to
        "subtype".
        (GRUB_EFI_DEVICE_PATH_TYPE): New macro.
        (GRUB_EFI_DEVICE_PATH_SUBTYPE): Likewise.
        (GRUB_EFI_DEVICE_PATH_LENGTH): Likewise.
        (GRUB_EFI_END_DEVICE_PATH_TYPE): Likewise.
        (GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE): Likewise.
        (GRUB_EFI_END_THIS_DEVICE_PATH_SUBTYPE): Likewise.
        (GRUB_EFI_END_ENTIRE_DEVICE_PATH): Likewise.
        (GRUB_EFI_NEXT_DEVICE_PATH): Likewise.
        (GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE): Likewise.
        (GRUB_EFI_PCI_DEVICE_PATH_SUBTYPE): Likewise.
        (struct grub_efi_pci_device_path): New structure.
        (grub_efi_pci_device_path_t): New type.
        (GRUB_EFI_PCCARD_DEVICE_PATH_SUBTYPE): New macro.
        (struct grub_efi_pccard_device_path): New structure.
        (grub_efi_pccard_device_path_t): New type.
        (GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE): New macro.
        (struct grub_efi_memory_mapped_device_path): New structure.
        (grub_efi_memory_mapped_device_path_t): New type.
        (GRUB_EFI_VENDOR_DEVICE_PATH_SUBTYPE): New macro.
        (struct grub_efi_vendor_device_path): New structure.
        (grub_efi_vendor_device_path_t): New type.
        (GRUB_EFI_CONTROLLER_DEVICE_PATH_SUBTYPE): New macro.
        (struct grub_efi_controller_device_path): New structure.
        (grub_efi_controller_device_path_t): New type.
        (GRUB_EFI_ACPI_DEVICE_PATH_TYPE): New macro.
        (GRUB_EFI_ACPI_DEVICE_PATH_SUBTYPE): Likewise.
        (struct grub_efi_acpi_device_path): New structure.
        (grub_efi_acpi_device_path_t): New type.
        (GRUB_EFI_EXPANDED_ACPI_DEVICE_PATH_SUBTYPE): New macro.
        (struct grub_efi_expanded_acpi_device_path): New structure.
        (grub_efi_expanded_acpi_device_path_t): New type.
        (GRUB_EFI_EXPANDED_ACPI_HIDSTR): New macro.
        (GRUB_EFI_EXPANDED_ACPI_UIDSTR): Likewise.
        (GRUB_EFI_EXPANDED_ACPI_CIDSTR): Likewise.
        (GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE): Likewise.
        (GRUB_EFI_ATAPI_DEVICE_PATH_SUBTYPE): Likewise.
        (struct grub_efi_atapi_device_path): New structure.
        (grub_efi_atapi_device_path_t): New type.
        (GRUB_EFI_FIBRE_CHANNEL_DEVICE_PATH_SUBTYPE): New macro.
        (struct grub_efi_fibre_channel_device_path): New structure.
        (grub_efi_fibre_channel_device_path_t): New type.
        (GRUB_EFI_1394_DEVICE_PATH_SUBTYPE): New macro.
        (struct grub_efi_1394_device_path): New structure.
        (grub_efi_1394_device_path_t): New type.
        (GRUB_EFI_USB_DEVICE_PATH_SUBTYPE): New macro.
        (struct grub_efi_usb_device_path): New structure.
        (grub_efi_usb_device_path_t): New type.
        (GRUB_EFI_USB_CLASS_DEVICE_PATH_SUBTYPE): New macro.
        (struct grub_efi_usb_class_device_path): New structure.
        (grub_efi_usb_class_device_path_t): New type.
        (GRUB_EFI_I2O_DEVICE_PATH_SUBTYPE): New macro.
        (struct grub_efi_i2o_device_path): New structure.
        (grub_efi_i2o_device_path_t): New type.
        (GRUB_EFI_MAC_ADDRESS_DEVICE_PATH_SUBTYPE): New macro.
        (struct grub_efi_mac_address_device_path): New structure.
        (grub_efi_mac_address_device_path_t): New type.
        (GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE): New macro.
        (struct grub_efi_ipv4_device_path): New structure.
        (grub_efi_ipv4_device_path_t): New type.
        (GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE): New macro.
        (struct grub_efi_ipv6_device_path): New structure.
        (grub_efi_ipv6_device_path_t): New type.
        (GRUB_EFI_INFINIBAND_DEVICE_PATH_SUBTYPE): New macro.
        (struct grub_efi_infiniband_device_path): New structure.
        (grub_efi_infiniband_device_path_t): New type.
        (GRUB_EFI_UART_DEVICE_PATH_SUBTYPE): New macro.
        (struct grub_efi_uart_device_path): New structure.
        (grub_efi_uart_device_path_t): New type.
        (GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE): New macro.
        (struct grub_efi_vendor_messaging_device_path): New structure.
        (grub_efi_vendor_messaging_device_path_t): New type.
        (GRUB_EFI_MEDIA_DEVICE_PATH_TYPE): New macro.
        (GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE): Likewise.
        (struct grub_efi_hard_drive_device_path): New structure.
        (grub_efi_hard_drive_device_path_t): New type.
        (GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE): New macro.
        (struct grub_efi_cdrom_device_path): New structure.
        (grub_efi_cdrom_device_path_t): New type.
        (GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE): New macro.
        (struct grub_efi_vendor_media_device_path): New structure.
        (grub_efi_vendor_media_device_path_t): New type.
        (GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE): New macro.
        (struct grub_efi_file_path_device_path): New structure.
        (grub_efi_file_path_device_path_t): New type.
        (GRUB_EFI_PROTOCOL_DEVICE_PATH_SUBTYPE): New macro.
        (struct grub_efi_protocol_device_path): New structure.
        (grub_efi_protocol_device_path_t): New type.
        (GRUB_EFI_BIOS_DEVICE_PATH_TYPE): New macro.
        (GRUB_EFI_BIOS_DEVICE_PATH_SUBTYPE): Likewise.
        (struct grub_efi_bios_device_path): New structure.
        (grub_efi_bios_device_path_t): New type.
        (struct grub_efi_disk_io): New structure.
        (grub_efi_disk_io_t): New type.
        (struct grub_efi_block_io_media): New structure.
        (grub_efi_block_io_media_t): New type.
        (struct grub_efi_block_io): New structure.
        (grub_efi_block_io_t): New type.

        * include/grub/misc.h (grub_stop): Removed.
        (grub_exit): New prototype.
        (grub_abort): Likewise.

        * include/grub/disk.h (enum grub_disk_dev_id): Added
        GRUB_DISK_DEVICE_EFIDISK_ID.

        * conf/i386-efi.rmk (kernel_mod_SOURCES): Added
        disk/efi/efidisk.c.
        (kernel_syms.lst): Remove the target if an error occurs.
This commit is contained in:
okuji 2006-04-23 13:37:36 +00:00
parent 49986a9f99
commit 9cacaa174c
24 changed files with 1853 additions and 85 deletions

View file

@ -26,6 +26,7 @@
#include <grub/machine/time.h>
#include <grub/term.h>
#include <grub/kernel.h>
#include <grub/mm.h>
/* The handle of GRUB itself. Filled in by the startup code. */
grub_efi_handle_t grub_efi_image_handle;
@ -33,8 +34,8 @@ 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;
static grub_efi_guid_t grub_efi_loaded_image_guid = GRUB_EFI_LOADED_IMAGE_GUID;
static grub_efi_guid_t console_control_guid = GRUB_EFI_CONSOLE_CONTROL_GUID;
static grub_efi_guid_t loaded_image_guid = GRUB_EFI_LOADED_IMAGE_GUID;
void *
grub_efi_locate_protocol (grub_efi_guid_t *protocol, void *registration)
@ -51,13 +52,77 @@ grub_efi_locate_protocol (grub_efi_guid_t *protocol, void *registration)
return interface;
}
/* Return the array of handles which meet the requirement. If successful,
the number of handles is stored in NUM_HANDLES. The array is allocated
from the heap. */
grub_efi_handle_t *
grub_efi_locate_handle (grub_efi_locate_search_type_t search_type,
grub_efi_guid_t *protocol,
void *search_key,
grub_efi_uintn_t *num_handles)
{
grub_efi_boot_services_t *b;
grub_efi_status_t status;
grub_efi_handle_t *buffer;
grub_efi_uintn_t buffer_size = 8 * sizeof (grub_efi_handle_t);
buffer = grub_malloc (buffer_size);
if (! buffer)
return 0;
b = grub_efi_system_table->boot_services;
status = b->locate_handle (search_type, protocol, search_key,
&buffer_size, buffer);
if (status == GRUB_EFI_BUFFER_TOO_SMALL)
{
grub_free (buffer);
buffer = grub_malloc (buffer_size);
if (! buffer)
return 0;
status = b->locate_handle (search_type, protocol, search_key,
&buffer_size, buffer);
}
if (status != GRUB_EFI_SUCCESS)
{
grub_free (buffer);
return 0;
}
*num_handles = buffer_size / sizeof (grub_efi_handle_t);
return buffer;
}
void *
grub_efi_open_protocol (grub_efi_handle_t handle,
grub_efi_guid_t *protocol,
grub_efi_uint32_t attributes)
{
grub_efi_boot_services_t *b;
grub_efi_status_t status;
void *interface;
b = grub_efi_system_table->boot_services;
status = b->open_protocol (handle,
protocol,
&interface,
grub_efi_image_handle,
0,
attributes);
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);
c = grub_efi_locate_protocol (&console_control_guid, 0);
if (! c)
return 0;
@ -72,14 +137,6 @@ grub_efi_set_text_mode (int on)
return 1;
}
void
grub_efi_exit (void)
{
grub_efi_system_table->boot_services->exit (grub_efi_image_handle,
GRUB_EFI_SUCCESS,
0, 0);
}
void
grub_efi_stall (grub_efi_uintn_t microseconds)
{
@ -89,31 +146,17 @@ grub_efi_stall (grub_efi_uintn_t microseconds)
grub_efi_loaded_image_t *
grub_efi_get_loaded_image (void)
{
grub_efi_boot_services_t *b;
void *interface;
grub_efi_status_t status;
b = grub_efi_system_table->boot_services;
status = b->open_protocol (grub_efi_image_handle,
&grub_efi_loaded_image_guid,
&interface,
grub_efi_image_handle,
0,
GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (status != GRUB_EFI_SUCCESS)
return 0;
return interface;
return grub_efi_open_protocol (grub_efi_image_handle,
&loaded_image_guid,
GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
}
void
grub_stop (void)
grub_exit (void)
{
grub_printf ("\nPress any key to abort.\n");
grub_getkey ();
grub_efi_fini ();
grub_efi_exit ();
grub_efi_system_table->boot_services->exit (grub_efi_image_handle,
GRUB_EFI_SUCCESS,
0, 0);
}
grub_uint32_t
@ -174,3 +217,422 @@ grub_arch_modules_addr (void)
return (grub_addr_t) info;
}
/* Print the chain of Device Path nodes. This is mainly for debugging. */
void
grub_print_device_path (grub_efi_device_path_t *dp)
{
while (1)
{
grub_efi_uint8_t type = GRUB_EFI_DEVICE_PATH_TYPE (dp);
grub_efi_uint8_t subtype = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp);
grub_efi_uint16_t len = GRUB_EFI_DEVICE_PATH_LENGTH (dp);
switch (type)
{
case GRUB_EFI_END_DEVICE_PATH_TYPE:
switch (subtype)
{
case GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE:
/* grub_printf ("/EndEntire\n"); */
grub_putchar ('\n');
break;
case GRUB_EFI_END_THIS_DEVICE_PATH_SUBTYPE:
/* grub_printf ("/EndThis\n"); */
grub_putchar ('\n');
break;
default:
grub_printf ("/EndUnknown(%x)\n", (unsigned) subtype);
break;
}
break;
case GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE:
switch (subtype)
{
case GRUB_EFI_PCI_DEVICE_PATH_SUBTYPE:
{
grub_efi_pci_device_path_t pci;
grub_memcpy (&pci, dp, len);
grub_printf ("/PCI(%x,%x)",
(unsigned) pci.function, (unsigned) pci.device);
}
break;
case GRUB_EFI_PCCARD_DEVICE_PATH_SUBTYPE:
{
grub_efi_pccard_device_path_t pccard;
grub_memcpy (&pccard, dp, len);
grub_printf ("/PCCARD(%x)",
(unsigned) pccard.function);
}
break;
case GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE:
{
grub_efi_memory_mapped_device_path_t mmapped;
grub_memcpy (&mmapped, dp, len);
grub_printf ("/MMap(%x,%llx,%llx)",
(unsigned) mmapped.memory_type,
mmapped.start_address,
mmapped.end_address);
}
break;
case GRUB_EFI_VENDOR_DEVICE_PATH_SUBTYPE:
{
grub_efi_vendor_device_path_t vendor;
grub_memcpy (&vendor, dp, sizeof (vendor));
grub_printf ("/Vendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
(unsigned) vendor.vendor_guid.data1,
(unsigned) vendor.vendor_guid.data2,
(unsigned) vendor.vendor_guid.data3,
(unsigned) vendor.vendor_guid.data4[0],
(unsigned) vendor.vendor_guid.data4[1],
(unsigned) vendor.vendor_guid.data4[2],
(unsigned) vendor.vendor_guid.data4[3],
(unsigned) vendor.vendor_guid.data4[4],
(unsigned) vendor.vendor_guid.data4[5],
(unsigned) vendor.vendor_guid.data4[6],
(unsigned) vendor.vendor_guid.data4[7]);
}
break;
case GRUB_EFI_CONTROLLER_DEVICE_PATH_SUBTYPE:
{
grub_efi_controller_device_path_t controller;
grub_memcpy (&controller, dp, len);
grub_printf ("/Ctrl(%x)",
(unsigned) controller.controller_number);
}
break;
default:
grub_printf ("/UnknownHW(%x)", (unsigned) subtype);
break;
}
break;
case GRUB_EFI_ACPI_DEVICE_PATH_TYPE:
switch (subtype)
{
case GRUB_EFI_ACPI_DEVICE_PATH_SUBTYPE:
{
grub_efi_acpi_device_path_t acpi;
grub_memcpy (&acpi, dp, len);
grub_printf ("/ACPI(%x,%x)",
(unsigned) acpi.hid,
(unsigned) acpi.uid);
}
break;
case GRUB_EFI_EXPANDED_ACPI_DEVICE_PATH_SUBTYPE:
{
grub_efi_expanded_acpi_device_path_t eacpi;
grub_memcpy (&eacpi, dp, sizeof (eacpi));
grub_printf ("/ACPI(");
if (GRUB_EFI_EXPANDED_ACPI_HIDSTR (dp)[0] == '\0')
grub_printf ("%x,", (unsigned) eacpi.hid);
else
grub_printf ("%s,", GRUB_EFI_EXPANDED_ACPI_HIDSTR (dp));
if (GRUB_EFI_EXPANDED_ACPI_UIDSTR (dp)[0] == '\0')
grub_printf ("%x,", (unsigned) eacpi.uid);
else
grub_printf ("%s,", GRUB_EFI_EXPANDED_ACPI_UIDSTR (dp));
if (GRUB_EFI_EXPANDED_ACPI_CIDSTR (dp)[0] == '\0')
grub_printf ("%x)", (unsigned) eacpi.cid);
else
grub_printf ("%s)", GRUB_EFI_EXPANDED_ACPI_CIDSTR (dp));
}
break;
default:
grub_printf ("/UnknownACPI(%x)", (unsigned) subtype);
break;
}
break;
case GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE:
switch (subtype)
{
case GRUB_EFI_ATAPI_DEVICE_PATH_SUBTYPE:
{
grub_efi_atapi_device_path_t atapi;
grub_memcpy (&atapi, dp, len);
grub_printf ("/ATAPI(%x,%x,%x)",
(unsigned) atapi.primary_secondary,
(unsigned) atapi.slave_master,
(unsigned) atapi.lun);
}
break;
case GRUB_EFI_SCSI_DEVICE_PATH_SUBTYPE:
{
grub_efi_scsi_device_path_t scsi;
grub_memcpy (&scsi, dp, len);
grub_printf ("/SCSI(%x,%x)",
(unsigned) scsi.pun,
(unsigned) scsi.lun);
}
break;
case GRUB_EFI_FIBRE_CHANNEL_DEVICE_PATH_SUBTYPE:
{
grub_efi_fibre_channel_device_path_t fc;
grub_memcpy (&fc, dp, len);
grub_printf ("/FibreChannel(%llx,%llx)",
fc.wwn, fc.lun);
}
break;
case GRUB_EFI_1394_DEVICE_PATH_SUBTYPE:
{
grub_efi_1394_device_path_t firewire;
grub_memcpy (&firewire, dp, len);
grub_printf ("/1394(%llx)", firewire.guid);
}
break;
case GRUB_EFI_USB_DEVICE_PATH_SUBTYPE:
{
grub_efi_usb_device_path_t usb;
grub_memcpy (&usb, dp, len);
grub_printf ("/USB(%x,%x)",
(unsigned) usb.parent_port_number,
(unsigned) usb.interface);
}
break;
case GRUB_EFI_USB_CLASS_DEVICE_PATH_SUBTYPE:
{
grub_efi_usb_class_device_path_t usb_class;
grub_memcpy (&usb_class, dp, len);
grub_printf ("/USBClass(%x,%x,%x,%x,%x)",
(unsigned) usb_class.vendor_id,
(unsigned) usb_class.product_id,
(unsigned) usb_class.device_class,
(unsigned) usb_class.device_subclass,
(unsigned) usb_class.device_protocol);
}
break;
case GRUB_EFI_I2O_DEVICE_PATH_SUBTYPE:
{
grub_efi_i2o_device_path_t i2o;
grub_memcpy (&i2o, dp, len);
grub_printf ("/I2O(%x)", (unsigned) i2o.tid);
}
break;
case GRUB_EFI_MAC_ADDRESS_DEVICE_PATH_SUBTYPE:
{
grub_efi_mac_address_device_path_t mac;
grub_memcpy (&mac, dp, len);
grub_printf ("/MacAddr(%02x:%02x:%02x:%02x:%02x:%02x,%x)",
(unsigned) mac.mac_address[0],
(unsigned) mac.mac_address[1],
(unsigned) mac.mac_address[2],
(unsigned) mac.mac_address[3],
(unsigned) mac.mac_address[4],
(unsigned) mac.mac_address[5],
(unsigned) mac.if_type);
}
break;
case GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE:
{
grub_efi_ipv4_device_path_t ipv4;
grub_memcpy (&ipv4, dp, len);
grub_printf ("/IPv4(%u.%u.%u.%u,%u.%u.%u.%u,%u,%u,%x,%x)",
(unsigned) ipv4.local_ip_address[0],
(unsigned) ipv4.local_ip_address[1],
(unsigned) ipv4.local_ip_address[2],
(unsigned) ipv4.local_ip_address[3],
(unsigned) ipv4.remote_ip_address[0],
(unsigned) ipv4.remote_ip_address[1],
(unsigned) ipv4.remote_ip_address[2],
(unsigned) ipv4.remote_ip_address[3],
(unsigned) ipv4.local_port,
(unsigned) ipv4.remote_port,
(unsigned) ipv4.protocol,
(unsigned) ipv4.static_ip_address);
}
break;
case GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE:
{
grub_efi_ipv6_device_path_t ipv6;
grub_memcpy (&ipv6, dp, len);
grub_printf ("/IPv6(%x:%x:%x:%x:%x:%x:%x:%x,%x:%x:%x:%x:%x:%x:%x:%x,%u,%u,%x,%x)",
(unsigned) ipv6.local_ip_address[0],
(unsigned) ipv6.local_ip_address[1],
(unsigned) ipv6.local_ip_address[2],
(unsigned) ipv6.local_ip_address[3],
(unsigned) ipv6.local_ip_address[4],
(unsigned) ipv6.local_ip_address[5],
(unsigned) ipv6.local_ip_address[6],
(unsigned) ipv6.local_ip_address[7],
(unsigned) ipv6.remote_ip_address[0],
(unsigned) ipv6.remote_ip_address[1],
(unsigned) ipv6.remote_ip_address[2],
(unsigned) ipv6.remote_ip_address[3],
(unsigned) ipv6.remote_ip_address[4],
(unsigned) ipv6.remote_ip_address[5],
(unsigned) ipv6.remote_ip_address[6],
(unsigned) ipv6.remote_ip_address[7],
(unsigned) ipv6.local_port,
(unsigned) ipv6.remote_port,
(unsigned) ipv6.protocol,
(unsigned) ipv6.static_ip_address);
}
break;
case GRUB_EFI_INFINIBAND_DEVICE_PATH_SUBTYPE:
{
grub_efi_infiniband_device_path_t ib;
grub_memcpy (&ib, dp, len);
grub_printf ("/InfiniBand(%x,%llx,%llx,%llx)",
(unsigned) ib.port_gid[0], /* XXX */
ib.remote_id,
ib.target_port_id,
ib.device_id);
}
break;
case GRUB_EFI_UART_DEVICE_PATH_SUBTYPE:
{
grub_efi_uart_device_path_t uart;
grub_memcpy (&uart, dp, len);
grub_printf ("/UART(%llu,%u,%x,%x)",
uart.baud_rate,
uart.data_bits,
uart.parity,
uart.stop_bits);
}
break;
case GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE:
{
grub_efi_vendor_messaging_device_path_t vendor;
grub_memcpy (&vendor, dp, sizeof (vendor));
grub_printf ("/Vendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
(unsigned) vendor.vendor_guid.data1,
(unsigned) vendor.vendor_guid.data2,
(unsigned) vendor.vendor_guid.data3,
(unsigned) vendor.vendor_guid.data4[0],
(unsigned) vendor.vendor_guid.data4[1],
(unsigned) vendor.vendor_guid.data4[2],
(unsigned) vendor.vendor_guid.data4[3],
(unsigned) vendor.vendor_guid.data4[4],
(unsigned) vendor.vendor_guid.data4[5],
(unsigned) vendor.vendor_guid.data4[6],
(unsigned) vendor.vendor_guid.data4[7]);
}
break;
default:
grub_printf ("/UnknownMessaging(%x)", (unsigned) subtype);
break;
}
break;
case GRUB_EFI_MEDIA_DEVICE_PATH_TYPE:
switch (subtype)
{
case GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE:
{
grub_efi_hard_drive_device_path_t hd;
grub_memcpy (&hd, dp, len);
grub_printf ("/HD(%u,%llx,%llx,%02x%02x%02x%02x%02x%02x%02x%02x,%x,%x)",
hd.partition_number,
hd.partition_start,
hd.partition_size,
(unsigned) hd.partition_signature[0],
(unsigned) hd.partition_signature[1],
(unsigned) hd.partition_signature[2],
(unsigned) hd.partition_signature[3],
(unsigned) hd.partition_signature[4],
(unsigned) hd.partition_signature[5],
(unsigned) hd.partition_signature[6],
(unsigned) hd.partition_signature[7],
(unsigned) hd.mbr_type,
(unsigned) hd.signature_type);
}
break;
case GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE:
{
grub_efi_cdrom_device_path_t cd;
grub_memcpy (&cd, dp, len);
grub_printf ("/CD(%u,%llx,%llx)",
cd.boot_entry,
cd.partition_start,
cd.partition_size);
}
break;
case GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE:
{
grub_efi_vendor_media_device_path_t vendor;
grub_memcpy (&vendor, dp, sizeof (vendor));
grub_printf ("/Vendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
(unsigned) vendor.vendor_guid.data1,
(unsigned) vendor.vendor_guid.data2,
(unsigned) vendor.vendor_guid.data3,
(unsigned) vendor.vendor_guid.data4[0],
(unsigned) vendor.vendor_guid.data4[1],
(unsigned) vendor.vendor_guid.data4[2],
(unsigned) vendor.vendor_guid.data4[3],
(unsigned) vendor.vendor_guid.data4[4],
(unsigned) vendor.vendor_guid.data4[5],
(unsigned) vendor.vendor_guid.data4[6],
(unsigned) vendor.vendor_guid.data4[7]);
}
break;
case GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE:
{
grub_efi_file_path_device_path_t *fp;
grub_uint8_t buf[(len - 4) * 4 + 1];
fp = (grub_efi_file_path_device_path_t *) dp;
*grub_utf16_to_utf8 (buf, fp->path_name, len - 4) = '\0';
grub_printf ("/File(%s)", buf);
}
break;
case GRUB_EFI_PROTOCOL_DEVICE_PATH_SUBTYPE:
{
grub_efi_protocol_device_path_t proto;
grub_memcpy (&proto, dp, sizeof (proto));
grub_printf ("/Protocol(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
(unsigned) proto.guid.data1,
(unsigned) proto.guid.data2,
(unsigned) proto.guid.data3,
(unsigned) proto.guid.data4[0],
(unsigned) proto.guid.data4[1],
(unsigned) proto.guid.data4[2],
(unsigned) proto.guid.data4[3],
(unsigned) proto.guid.data4[4],
(unsigned) proto.guid.data4[5],
(unsigned) proto.guid.data4[6],
(unsigned) proto.guid.data4[7]);
}
break;
default:
grub_printf ("/UnknownMedia(%x)", (unsigned) subtype);
break;
}
break;
case GRUB_EFI_BIOS_DEVICE_PATH_TYPE:
switch (subtype)
{
case GRUB_EFI_BIOS_DEVICE_PATH_SUBTYPE:
{
grub_efi_bios_device_path_t bios;
grub_memcpy (&bios, dp, sizeof (bios));
grub_printf ("/BIOS(%x,%x,%s)",
(unsigned) bios.device_type,
(unsigned) bios.status_flags,
(char *) (dp + 1));
}
break;
default:
grub_printf ("/UnknownBIOS(%x)", (unsigned) subtype);
break;
}
break;
default:
grub_printf ("/UnknownType(%x,%x)\n",
(unsigned) type,
(unsigned) subtype);
return;
break;
}
if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp))
break;
dp = (grub_efi_device_path_t *) ((char *) dp + len);
}
}

View file

@ -21,8 +21,10 @@
#include <grub/efi/efi.h>
#include <grub/efi/console.h>
#include <grub/efi/disk.h>
#include <grub/term.h>
#include <grub/misc.h>
#include <grub/env.h>
#include <grub/machine/kernel.h>
void
@ -35,6 +37,8 @@ grub_efi_init (void)
/* Initialize the memory management system. */
grub_efi_mm_init ();
grub_efidisk_init ();
/* FIXME: this must be set to something meaningful. */
grub_env_set ("prefix", grub_prefix);
}
@ -42,6 +46,7 @@ grub_efi_init (void)
void
grub_efi_fini (void)
{
grub_efidisk_fini ();
grub_efi_mm_fini ();
grub_console_fini ();
}

View file

@ -60,7 +60,7 @@ grub_fatal (const char *fmt, ...)
grub_vprintf (fmt, ap);
va_end (ap);
grub_stop ();
grub_abort ();
}
void

View file

@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2005 Free Software Foundation, Inc.
* Copyright (C) 1999,2000,2001,2002,2003,2005,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
@ -625,6 +625,18 @@ FUNCTION(grub_stop_floppy)
outb %al, %dx
ret
/*
* grub_exit()
*
* Exit the system.
*/
FUNCTION(grub_exit)
call prot_to_real
.code16
/* Tell the BIOS a boot failure. If this does not work, reboot. */
int $0x18
jmp cold_reboot
/*
* grub_reboot()
*
@ -633,6 +645,7 @@ FUNCTION(grub_stop_floppy)
FUNCTION(grub_reboot)
call prot_to_real
.code16
cold_reboot:
/* cold boot */
movw $0x0472, %di
movw %ax, (%di)

View file

@ -129,16 +129,18 @@ grub_printf (const char *fmt, ...)
}
void
grub_real_dprintf(const char *file, const int line, const char *condition,
const char *fmt, ...)
grub_real_dprintf (const char *file, const int line, const char *condition,
const char *fmt, ...)
{
va_list args;
const char *debug = grub_env_get ("debug");
if (! debug)
return;
if (grub_strword (debug, "all") || grub_strword (debug, condition))
{
grub_printf ("%s,%d : ", file, line);
grub_printf ("%s:%d: ", file, line);
va_start (args, fmt);
grub_vprintf (fmt, args);
va_end (args);
@ -955,3 +957,16 @@ grub_utf8_to_ucs4 (grub_uint32_t *dest, const grub_uint8_t *src,
return p - dest;
}
/* Abort GRUB. This function does not return. */
void
grub_abort (void)
{
if (grub_term_get_current ())
{
grub_printf ("Abort. Press any key to exit.");
grub_getkey ();
}
grub_exit ();
}

View file

@ -1,7 +1,7 @@
/* cmain.c - Startup code for the PowerPC. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
* Copyright (C) 2003,2004,2005,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
@ -86,7 +86,7 @@ cmain (uint32_t r3, uint32_t r4 __attribute__((unused)), uint32_t r5)
/* Need to claim ourselves so we don't cannibalize our memory later. */
if (grub_ieee1275_claim ((grub_addr_t) &_start, (grub_addr_t) &_end
- (grub_addr_t) &_start, 0, 0))
abort();
grub_abort ();
}
else
{

View file

@ -39,7 +39,7 @@ static const grub_addr_t grub_heap_start = 0x4000;
static grub_addr_t grub_heap_len;
void
abort (void)
grub_exit (void)
{
/* Trap to Open Firmware. */
asm ("trap");
@ -126,7 +126,7 @@ grub_machine_init (void)
{
grub_printf ("Failed to claim heap at 0x%x, len 0x%x\n", grub_heap_start,
grub_heap_len);
abort ();
grub_abort ();
}
grub_mm_init_region ((void *) grub_heap_start, grub_heap_len);
@ -177,12 +177,6 @@ grub_machine_fini (void)
grub_console_fini ();
}
void
grub_stop (void)
{
for (;;);
}
grub_uint32_t
grub_get_rtc (void)
{

View file

@ -580,6 +580,14 @@ grub_rescue_cmd_unset (int argc, char *argv[])
grub_env_unset (argv[0]);
}
/* exit */
static void
grub_rescue_cmd_exit (int argc __attribute__ ((unused)),
char *argv[] __attribute__ ((unused)))
{
grub_exit ();
}
static void
attempt_normal_mode (void)
{
@ -635,6 +643,8 @@ grub_enter_rescue_mode (void)
"set an environment variable");
grub_rescue_register_command ("unset", grub_rescue_cmd_unset,
"remove an environment variable");
grub_rescue_register_command ("exit", grub_rescue_cmd_exit,
"exit from GRUB");
while (1)
{