/* chainloader.c - boot another boot loader */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2004,2006,2007,2008 Free Software Foundation, Inc.
*
* 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/>.
*/
/* TODO: support load options. */
GRUB_MOD_LICENSE ("GPLv3+");
static grub_err_t
grub_chainloader_unload (void)
{
cmdline = 0;
file_path = 0;
return GRUB_ERR_NONE;
}
static grub_err_t
grub_chainloader_boot (void)
{
if (status != GRUB_EFI_SUCCESS)
{
if (exit_data)
{
char *buf;
if (buf)
{
exit_data, exit_data_size) = 0;
}
else
}
}
if (exit_data)
return grub_errno;
}
static void
{
{
/* FIXME: this assumes that the path is in ASCII. */
}
}
static grub_efi_device_path_t *
{
char *dir_start;
char *dir_end;
if (! dir_start)
else
dir_start++;
if (! dir_end)
{
return 0;
}
size = 0;
d = dp;
while (1)
{
size += GRUB_EFI_DEVICE_PATH_LENGTH (d);
if ((GRUB_EFI_END_ENTIRE_DEVICE_PATH (d)))
break;
d = GRUB_EFI_NEXT_DEVICE_PATH (d);
}
* sizeof (grub_efi_char16_t))
+ sizeof (grub_efi_file_path_device_path_t) * 2);
if (! file_path)
return 0;
/* Fill the file path for the directory. */
d = (grub_efi_device_path_t *) ((char *) file_path
+ ((char *) d - (char *) dp));
/* Fill the file path for the file. */
d = GRUB_EFI_NEXT_DEVICE_PATH (d);
/* Fill the end of device path nodes. */
d = GRUB_EFI_NEXT_DEVICE_PATH (d);
d->length[0] = sizeof (*d);
d->length[1] = 0;
return file_path;
}
static grub_err_t
{
char *filename;
if (argc == 0)
/* Initialize some global variables. */
address = 0;
image_handle = 0;
file_path = 0;
if (! file)
goto fail;
/* Get the root device's device path. */
dev = grub_device_open (0);
if (! dev)
goto fail;
{
if (dev_handle)
}
{
goto fail;
}
if (! file_path)
goto fail;
grub_printf ("file path: ");
if (!size)
{
goto fail;
}
if (status != GRUB_EFI_SUCCESS)
{
goto fail;
}
{
if (grub_errno == GRUB_ERR_NONE)
goto fail;
}
&image_handle);
if (status != GRUB_EFI_SUCCESS)
{
if (status == GRUB_EFI_OUT_OF_RESOURCES)
else
goto fail;
}
/* LoadImage does not set a device handler when the image is
loaded from memory, so it is necessary to set it explicitly here.
This is a mess. */
if (! loaded_image)
{
goto fail;
}
if (argc > 1)
{
int i, len;
len *= sizeof (grub_efi_char16_t);
if (! cmdline)
goto fail;
for (i = 1; i < argc; i++)
{
char *p8;
while (*p8)
*(p16++) = ' ';
}
*(--p16) = 0;
}
return 0;
fail:
if (dev)
if (file)
if (address)
return grub_errno;
}
{
0, N_("Load another boot loader."));
}
{
}