mirror of
https://github.com/grub4dos/ntloader.git
synced 2025-05-11 13:01:33 +08:00
rm efipath
This commit is contained in:
parent
4512426e9a
commit
77ac605bda
2
Makefile
2
Makefile
@ -8,7 +8,7 @@ SBAT_GENERATION := 1
|
|||||||
#
|
#
|
||||||
OBJECTS := prefix.o startup.o callback.o main.o vsprintf.o string.o peloader.o
|
OBJECTS := prefix.o startup.o callback.o main.o vsprintf.o string.o peloader.o
|
||||||
OBJECTS += int13.o vdisk.o cpio.o stdio.o die.o efi.o efimain.o
|
OBJECTS += int13.o vdisk.o cpio.o stdio.o die.o efi.o efimain.o
|
||||||
OBJECTS += efiguid.o efifile.o efipath.o efiboot.o efiblock.o cmdline.o
|
OBJECTS += efifile.o efiboot.o efiblock.o cmdline.o
|
||||||
OBJECTS += cookie.o paging.o memmap.o
|
OBJECTS += cookie.o paging.o memmap.o
|
||||||
OBJECTS += reg.o charset.o bcd.o fsuuid.o gpt.o msdos.o
|
OBJECTS += reg.o charset.o bcd.o fsuuid.o gpt.o msdos.o
|
||||||
OBJECTS += biosdisk.o efidisk.o payload.o
|
OBJECTS += biosdisk.o efidisk.o payload.o
|
||||||
|
40
efiblock.c
40
efiblock.c
@ -30,7 +30,6 @@
|
|||||||
#include "ntloader.h"
|
#include "ntloader.h"
|
||||||
#include "vdisk.h"
|
#include "vdisk.h"
|
||||||
#include "efi.h"
|
#include "efi.h"
|
||||||
#include "efipath.h"
|
|
||||||
#include "efiblock.h"
|
#include "efiblock.h"
|
||||||
|
|
||||||
/** A block I/O device */
|
/** A block I/O device */
|
||||||
@ -131,7 +130,8 @@ efi_flush_blocks (EFI_BLOCK_IO_PROTOCOL *this)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** GUID used in vendor device path */
|
/** GUID used in vendor device path */
|
||||||
#define EFIBLOCK_GUID { \
|
#define EFIBLOCK_GUID \
|
||||||
|
{ \
|
||||||
0x1322d197, 0x15dc, 0x4a45, \
|
0x1322d197, 0x15dc, 0x4a45, \
|
||||||
{ 0xa6, 0xa4, 0xfa, 0x57, 0x05, 0x4e, 0xa6, 0x14 } \
|
{ 0xa6, 0xa4, 0xfa, 0x57, 0x05, 0x4e, 0xa6, 0x14 } \
|
||||||
}
|
}
|
||||||
@ -141,8 +141,10 @@ efi_flush_blocks (EFI_BLOCK_IO_PROTOCOL *this)
|
|||||||
*
|
*
|
||||||
* @v name Variable name
|
* @v name Variable name
|
||||||
*/
|
*/
|
||||||
#define EFIBLOCK_DEVPATH_VENDOR_INIT(name) { \
|
#define EFIBLOCK_DEVPATH_VENDOR_INIT(name) \
|
||||||
.Header = EFI_DEVPATH_INIT (name, HARDWARE_DEVICE_PATH, \
|
{ \
|
||||||
|
.Header = EFI_DEVPATH_INIT (name, \
|
||||||
|
HARDWARE_DEVICE_PATH, \
|
||||||
HW_VENDOR_DP), \
|
HW_VENDOR_DP), \
|
||||||
.Guid = EFIBLOCK_GUID, \
|
.Guid = EFIBLOCK_GUID, \
|
||||||
}
|
}
|
||||||
@ -152,8 +154,10 @@ efi_flush_blocks (EFI_BLOCK_IO_PROTOCOL *this)
|
|||||||
*
|
*
|
||||||
* @v name Variable name
|
* @v name Variable name
|
||||||
*/
|
*/
|
||||||
#define EFIBLOCK_DEVPATH_ATA_INIT(name) { \
|
#define EFIBLOCK_DEVPATH_ATA_INIT(name) \
|
||||||
.Header = EFI_DEVPATH_INIT (name, MESSAGING_DEVICE_PATH, \
|
{ \
|
||||||
|
.Header = EFI_DEVPATH_INIT (name, \
|
||||||
|
MESSAGING_DEVICE_PATH, \
|
||||||
MSG_ATAPI_DP), \
|
MSG_ATAPI_DP), \
|
||||||
.PrimarySecondary = 0, \
|
.PrimarySecondary = 0, \
|
||||||
.SlaveMaster = 0, \
|
.SlaveMaster = 0, \
|
||||||
@ -165,8 +169,10 @@ efi_flush_blocks (EFI_BLOCK_IO_PROTOCOL *this)
|
|||||||
*
|
*
|
||||||
* @v name Variable name
|
* @v name Variable name
|
||||||
*/
|
*/
|
||||||
#define EFIBLOCK_DEVPATH_HD_INIT(name) { \
|
#define EFIBLOCK_DEVPATH_HD_INIT(name) \
|
||||||
.Header = EFI_DEVPATH_INIT (name, MEDIA_DEVICE_PATH, \
|
{ \
|
||||||
|
.Header = EFI_DEVPATH_INIT (name, \
|
||||||
|
MEDIA_DEVICE_PATH, \
|
||||||
MEDIA_HARDDRIVE_DP), \
|
MEDIA_HARDDRIVE_DP), \
|
||||||
.PartitionNumber = 1, \
|
.PartitionNumber = 1, \
|
||||||
.PartitionStart = VDISK_PARTITION_LBA, \
|
.PartitionStart = VDISK_PARTITION_LBA, \
|
||||||
@ -206,7 +212,8 @@ static struct
|
|||||||
/** Virtual disk device */
|
/** Virtual disk device */
|
||||||
static struct efi_block efi_vdisk =
|
static struct efi_block efi_vdisk =
|
||||||
{
|
{
|
||||||
.block = {
|
.block =
|
||||||
|
{
|
||||||
.Revision = EFI_BLOCK_IO_PROTOCOL_REVISION,
|
.Revision = EFI_BLOCK_IO_PROTOCOL_REVISION,
|
||||||
.Media = &efi_vdisk_media,
|
.Media = &efi_vdisk_media,
|
||||||
.Reset = efi_reset_blocks,
|
.Reset = efi_reset_blocks,
|
||||||
@ -248,7 +255,8 @@ static struct
|
|||||||
/** Virtual partition device */
|
/** Virtual partition device */
|
||||||
static struct efi_block efi_vpartition =
|
static struct efi_block efi_vpartition =
|
||||||
{
|
{
|
||||||
.block = {
|
.block =
|
||||||
|
{
|
||||||
.Revision = EFI_BLOCK_IO_PROTOCOL_REVISION,
|
.Revision = EFI_BLOCK_IO_PROTOCOL_REVISION,
|
||||||
.Media = &efi_vpartition_media,
|
.Media = &efi_vpartition_media,
|
||||||
.Reset = efi_reset_blocks,
|
.Reset = efi_reset_blocks,
|
||||||
@ -286,8 +294,10 @@ void efi_install (EFI_HANDLE *vdisk, EFI_HANDLE *vpartition)
|
|||||||
/* Install virtual partition */
|
/* Install virtual partition */
|
||||||
if ((efirc = bs->InstallMultipleProtocolInterfaces (
|
if ((efirc = bs->InstallMultipleProtocolInterfaces (
|
||||||
vpartition,
|
vpartition,
|
||||||
&efi_block_io_protocol_guid, &efi_vpartition.block,
|
&efi_block_io_protocol_guid,
|
||||||
&efi_device_path_protocol_guid, efi_vpartition.path,
|
&efi_vpartition.block,
|
||||||
|
&efi_device_path_protocol_guid,
|
||||||
|
efi_vpartition.path,
|
||||||
NULL)) != 0)
|
NULL)) != 0)
|
||||||
{
|
{
|
||||||
die ("Could not install partition block I/O protocols: %#lx\n",
|
die ("Could not install partition block I/O protocols: %#lx\n",
|
||||||
@ -313,7 +323,8 @@ static struct
|
|||||||
.vendor = EFIBLOCK_DEVPATH_VENDOR_INIT (efi_bootmgfw_path.vendor),
|
.vendor = EFIBLOCK_DEVPATH_VENDOR_INIT (efi_bootmgfw_path.vendor),
|
||||||
.ata = EFIBLOCK_DEVPATH_ATA_INIT (efi_bootmgfw_path.ata),
|
.ata = EFIBLOCK_DEVPATH_ATA_INIT (efi_bootmgfw_path.ata),
|
||||||
.hd = EFIBLOCK_DEVPATH_HD_INIT (efi_bootmgfw_path.hd),
|
.hd = EFIBLOCK_DEVPATH_HD_INIT (efi_bootmgfw_path.hd),
|
||||||
.file = {
|
.file =
|
||||||
|
{
|
||||||
.header = EFI_DEVPATH_INIT (efi_bootmgfw_path.file,
|
.header = EFI_DEVPATH_INIT (efi_bootmgfw_path.file,
|
||||||
MEDIA_DEVICE_PATH,
|
MEDIA_DEVICE_PATH,
|
||||||
MEDIA_FILEPATH_DP),
|
MEDIA_FILEPATH_DP),
|
||||||
@ -323,4 +334,5 @@ static struct
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Boot image path */
|
/** Boot image path */
|
||||||
EFI_DEVICE_PATH_PROTOCOL *bootmgfw_path = &efi_bootmgfw_path.vendor.Header;
|
EFI_DEVICE_PATH_PROTOCOL *bootmgfw_path =
|
||||||
|
&efi_bootmgfw_path.vendor.Header;
|
||||||
|
89
efiboot.c
89
efiboot.c
@ -30,72 +30,8 @@
|
|||||||
#include "cmdline.h"
|
#include "cmdline.h"
|
||||||
#include "vdisk.h"
|
#include "vdisk.h"
|
||||||
#include "efi.h"
|
#include "efi.h"
|
||||||
#include "efi/Protocol/GraphicsOutput.h"
|
|
||||||
#include "efipath.h"
|
|
||||||
#include "efiboot.h"
|
#include "efiboot.h"
|
||||||
|
|
||||||
#if 0
|
|
||||||
/** Original OpenProtocol() method */
|
|
||||||
static EFI_OPEN_PROTOCOL orig_open_protocol;
|
|
||||||
|
|
||||||
/** Dummy "opening graphics output protocol blocked once" protocol GUID */
|
|
||||||
static EFI_GUID efi_graphics_output_protocol_blocked_guid =
|
|
||||||
{
|
|
||||||
0xbd1598bf, 0x8e65, 0x47e0,
|
|
||||||
{ 0x80, 0x01, 0xe4, 0x62, 0x4c, 0xab, 0xa4, 0x7f }
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Dummy "opening graphics output protocol blocked once" protocol instance */
|
|
||||||
static uint8_t efi_graphics_output_protocol_blocked;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Intercept OpenProtocol()
|
|
||||||
*
|
|
||||||
* @v handle EFI handle
|
|
||||||
* @v protocol Protocol GUID
|
|
||||||
* @v interface Opened interface
|
|
||||||
* @v agent_handle Agent handle
|
|
||||||
* @v controller_handle Controller handle
|
|
||||||
* @v attributes Attributes
|
|
||||||
* @ret efirc EFI status code
|
|
||||||
*/
|
|
||||||
static EFI_STATUS EFIAPI
|
|
||||||
efi_open_protocol_wrapper (EFI_HANDLE handle, EFI_GUID *protocol,
|
|
||||||
VOID **interface, EFI_HANDLE agent_handle,
|
|
||||||
EFI_HANDLE controller_handle, UINT32 attributes)
|
|
||||||
{
|
|
||||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
|
||||||
EFI_STATUS efirc;
|
|
||||||
|
|
||||||
/* Open the protocol */
|
|
||||||
if ((efirc = orig_open_protocol (handle, protocol, interface,
|
|
||||||
agent_handle, controller_handle,
|
|
||||||
attributes)) != 0)
|
|
||||||
return efirc;
|
|
||||||
|
|
||||||
/* Block first attempt by bootmgfw.efi to open each
|
|
||||||
* EFI_GRAPHICS_OUTPUT_PROTOCOL. This forces error messages
|
|
||||||
* to be displayed in text mode (thereby avoiding the totally
|
|
||||||
* blank error screen if the fonts are missing). We must
|
|
||||||
* allow subsequent attempts to succeed, otherwise the OS will
|
|
||||||
* fail to boot.
|
|
||||||
*/
|
|
||||||
if ((memcmp (protocol, &efi_graphics_output_protocol_guid,
|
|
||||||
sizeof (*protocol)) == 0) &&
|
|
||||||
(bs->InstallMultipleProtocolInterfaces (
|
|
||||||
&handle,
|
|
||||||
&efi_graphics_output_protocol_blocked_guid,
|
|
||||||
&efi_graphics_output_protocol_blocked,
|
|
||||||
NULL) == 0))
|
|
||||||
{
|
|
||||||
DBG ("Forcing text mode output\n");
|
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boot from EFI device
|
* Boot from EFI device
|
||||||
*
|
*
|
||||||
@ -119,9 +55,10 @@ void efi_boot (EFI_DEVICE_PATH_PROTOCOL *path,
|
|||||||
|
|
||||||
/* Allocate memory */
|
/* Allocate memory */
|
||||||
pages = ((nt_cmdline->bootmgr_length + PAGE_SIZE - 1) / PAGE_SIZE);
|
pages = ((nt_cmdline->bootmgr_length + PAGE_SIZE - 1) / PAGE_SIZE);
|
||||||
if ((efirc = bs->AllocatePages (AllocateAnyPages,
|
efirc = bs->AllocatePages (AllocateAnyPages,
|
||||||
EfiBootServicesData, pages,
|
EfiBootServicesData, pages,
|
||||||
&phys)) != 0)
|
&phys);
|
||||||
|
if (efirc != 0)
|
||||||
{
|
{
|
||||||
die ("Could not allocate %d pages: %#lx\n",
|
die ("Could not allocate %d pages: %#lx\n",
|
||||||
pages, ((unsigned long) efirc));
|
pages, ((unsigned long) efirc));
|
||||||
@ -133,8 +70,9 @@ void efi_boot (EFI_DEVICE_PATH_PROTOCOL *path,
|
|||||||
memcpy (data, nt_cmdline->bootmgr, nt_cmdline->bootmgr_length);
|
memcpy (data, nt_cmdline->bootmgr, nt_cmdline->bootmgr_length);
|
||||||
|
|
||||||
/* Load image */
|
/* Load image */
|
||||||
if ((efirc = bs->LoadImage (FALSE, efi_image_handle, path, data,
|
efirc = bs->LoadImage (FALSE, efi_image_handle, path, data,
|
||||||
nt_cmdline->bootmgr_length, &handle)) != 0)
|
nt_cmdline->bootmgr_length, &handle);
|
||||||
|
if (efirc != 0)
|
||||||
{
|
{
|
||||||
die ("Could not load bootmgfw.efi: %#lx\n",
|
die ("Could not load bootmgfw.efi: %#lx\n",
|
||||||
((unsigned long) efirc));
|
((unsigned long) efirc));
|
||||||
@ -142,12 +80,13 @@ void efi_boot (EFI_DEVICE_PATH_PROTOCOL *path,
|
|||||||
DBG ("Loaded bootmgfw.efi\n");
|
DBG ("Loaded bootmgfw.efi\n");
|
||||||
|
|
||||||
/* Get loaded image protocol */
|
/* Get loaded image protocol */
|
||||||
if ((efirc = bs->OpenProtocol (handle,
|
efirc = bs->OpenProtocol (handle,
|
||||||
&efi_loaded_image_protocol_guid,
|
&efi_loaded_image_protocol_guid,
|
||||||
&loaded.intf, efi_image_handle, NULL,
|
&loaded.intf, efi_image_handle, NULL,
|
||||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL))!=0)
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL);
|
||||||
|
if (efirc != 0)
|
||||||
{
|
{
|
||||||
die ("Could not get loaded image protocol for bootmgfw.efi: %#lx\n",
|
die ("Could not get loaded image protocol: %#lx\n",
|
||||||
((unsigned long) efirc));
|
((unsigned long) efirc));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,14 +98,6 @@ void efi_boot (EFI_DEVICE_PATH_PROTOCOL *path,
|
|||||||
loaded.image->DeviceHandle = device;
|
loaded.image->DeviceHandle = device;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* Intercept calls to OpenProtocol() */
|
|
||||||
orig_open_protocol =
|
|
||||||
loaded.image->SystemTable->BootServices->OpenProtocol;
|
|
||||||
loaded.image->SystemTable->BootServices->OpenProtocol =
|
|
||||||
efi_open_protocol_wrapper;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Start image */
|
/* Start image */
|
||||||
if ((efirc = bs->StartImage (handle, NULL, NULL)) != 0)
|
if ((efirc = bs->StartImage (handle, NULL, NULL)) != 0)
|
||||||
{
|
{
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
#include "payload.h"
|
#include "payload.h"
|
||||||
#include "efi.h"
|
#include "efi.h"
|
||||||
#include "efifile.h"
|
#include "efifile.h"
|
||||||
#include "efipath.h"
|
|
||||||
#include "efi/Protocol/LoadFile2.h"
|
#include "efi/Protocol/LoadFile2.h"
|
||||||
#include "efi/Guid/LinuxEfiInitrdMedia.h"
|
#include "efi/Guid/LinuxEfiInitrdMedia.h"
|
||||||
|
|
||||||
|
58
efiguid.c
58
efiguid.c
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
*
|
|
||||||
* EFI GUIDs
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "ntloader.h"
|
|
||||||
#include "efi.h"
|
|
||||||
#include "efi/Protocol/BlockIo.h"
|
|
||||||
#include "efi/Protocol/DevicePath.h"
|
|
||||||
#include "efi/Protocol/GraphicsOutput.h"
|
|
||||||
#include "efi/Protocol/LoadedImage.h"
|
|
||||||
#include "efi/Protocol/SimpleFileSystem.h"
|
|
||||||
#include "efi/Protocol/LoadFile2.h"
|
|
||||||
|
|
||||||
/** Block I/O protocol GUID */
|
|
||||||
EFI_GUID efi_block_io_protocol_guid
|
|
||||||
= EFI_BLOCK_IO_PROTOCOL_GUID;
|
|
||||||
|
|
||||||
/** Device path protocol GUID */
|
|
||||||
EFI_GUID efi_device_path_protocol_guid
|
|
||||||
= EFI_DEVICE_PATH_PROTOCOL_GUID;
|
|
||||||
|
|
||||||
/** Graphics output protocol GUID */
|
|
||||||
EFI_GUID efi_graphics_output_protocol_guid
|
|
||||||
= EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
|
|
||||||
|
|
||||||
/** Loaded image protocol GUID */
|
|
||||||
EFI_GUID efi_loaded_image_protocol_guid
|
|
||||||
= EFI_LOADED_IMAGE_PROTOCOL_GUID;
|
|
||||||
|
|
||||||
/** Simple file system protocol GUID */
|
|
||||||
EFI_GUID efi_simple_file_system_protocol_guid
|
|
||||||
= EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID;
|
|
||||||
|
|
||||||
/** Load File 2 protocol GUID */
|
|
||||||
EFI_GUID efi_load_file2_protocol_guid
|
|
||||||
= EFI_LOAD_FILE2_PROTOCOL_GUID;
|
|
28
efimain.c
28
efimain.c
@ -33,6 +33,11 @@
|
|||||||
#include "efiboot.h"
|
#include "efiboot.h"
|
||||||
#include "efidisk.h"
|
#include "efidisk.h"
|
||||||
#include "bcd.h"
|
#include "bcd.h"
|
||||||
|
#include "efi/Protocol/BlockIo.h"
|
||||||
|
#include "efi/Protocol/DevicePath.h"
|
||||||
|
#include "efi/Protocol/LoadedImage.h"
|
||||||
|
#include "efi/Protocol/SimpleFileSystem.h"
|
||||||
|
#include "efi/Protocol/LoadFile2.h"
|
||||||
|
|
||||||
/** SBAT section attributes */
|
/** SBAT section attributes */
|
||||||
#define __sbat __attribute__ ((section (".sbat"), aligned (512)))
|
#define __sbat __attribute__ ((section (".sbat"), aligned (512)))
|
||||||
@ -55,6 +60,26 @@
|
|||||||
/** SBAT metadata (with no terminating NUL) */
|
/** SBAT metadata (with no terminating NUL) */
|
||||||
const char sbat[ sizeof (SBAT_CSV) - 1 ] __sbat = SBAT_CSV;
|
const char sbat[ sizeof (SBAT_CSV) - 1 ] __sbat = SBAT_CSV;
|
||||||
|
|
||||||
|
/** Block I/O protocol GUID */
|
||||||
|
EFI_GUID efi_block_io_protocol_guid
|
||||||
|
= EFI_BLOCK_IO_PROTOCOL_GUID;
|
||||||
|
|
||||||
|
/** Device path protocol GUID */
|
||||||
|
EFI_GUID efi_device_path_protocol_guid
|
||||||
|
= EFI_DEVICE_PATH_PROTOCOL_GUID;
|
||||||
|
|
||||||
|
/** Loaded image protocol GUID */
|
||||||
|
EFI_GUID efi_loaded_image_protocol_guid
|
||||||
|
= EFI_LOADED_IMAGE_PROTOCOL_GUID;
|
||||||
|
|
||||||
|
/** Simple file system protocol GUID */
|
||||||
|
EFI_GUID efi_simple_file_system_protocol_guid
|
||||||
|
= EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID;
|
||||||
|
|
||||||
|
/** Load File 2 protocol GUID */
|
||||||
|
EFI_GUID efi_load_file2_protocol_guid
|
||||||
|
= EFI_LOAD_FILE2_PROTOCOL_GUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process command line
|
* Process command line
|
||||||
*
|
*
|
||||||
@ -102,8 +127,7 @@ EFI_STATUS EFIAPI efi_main (EFI_HANDLE image_handle,
|
|||||||
init_cookie();
|
init_cookie();
|
||||||
|
|
||||||
/* Print welcome banner */
|
/* Print welcome banner */
|
||||||
printf ("\n\nntloader " VERSION " -- Windows NT6+ OS/VHD/WIM "
|
printf ("\n\nntloader " VERSION "\n\n");
|
||||||
"loader -- https://github.com/grub4dos/ntloader\n\n");
|
|
||||||
|
|
||||||
/* Get loaded image protocol */
|
/* Get loaded image protocol */
|
||||||
if ((efirc = bs->OpenProtocol (image_handle,
|
if ((efirc = bs->OpenProtocol (image_handle,
|
||||||
|
48
efipath.c
48
efipath.c
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
*
|
|
||||||
* EFI device paths
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "ntloader.h"
|
|
||||||
#include "efi.h"
|
|
||||||
#include "efipath.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find end of device path
|
|
||||||
*
|
|
||||||
* @v path Path to device
|
|
||||||
* @ret path_end End of device path
|
|
||||||
*/
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *efi_devpath_end (EFI_DEVICE_PATH_PROTOCOL *path)
|
|
||||||
{
|
|
||||||
|
|
||||||
while (path->Type != END_DEVICE_PATH_TYPE)
|
|
||||||
{
|
|
||||||
path = (((void *) path) +
|
|
||||||
/* There's this amazing new-fangled thing known as
|
|
||||||
* a UINT16, but who wants to use one of those? */
|
|
||||||
((path->Length[1] << 8) | path->Length[0]));
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
}
|
|
@ -39,13 +39,38 @@
|
|||||||
|
|
||||||
#include "efi/Uefi.h"
|
#include "efi/Uefi.h"
|
||||||
#include "efi/Protocol/LoadedImage.h"
|
#include "efi/Protocol/LoadedImage.h"
|
||||||
|
#include "efi/Protocol/DevicePath.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise device path
|
||||||
|
*
|
||||||
|
* @v name Variable name
|
||||||
|
* @v type Type
|
||||||
|
* @v subtype Subtype
|
||||||
|
*/
|
||||||
|
#define EFI_DEVPATH_INIT(name, type, subtype) \
|
||||||
|
{ \
|
||||||
|
.Type = (type), \
|
||||||
|
.SubType = (subtype), \
|
||||||
|
.Length[0] = (sizeof (name) & 0xff), \
|
||||||
|
.Length[1] = (sizeof (name) >> 8), \
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise device path end
|
||||||
|
*
|
||||||
|
* @v name Variable name
|
||||||
|
*/
|
||||||
|
#define EFI_DEVPATH_END_INIT(name) \
|
||||||
|
EFI_DEVPATH_INIT (name, \
|
||||||
|
END_DEVICE_PATH_TYPE, \
|
||||||
|
END_ENTIRE_DEVICE_PATH_SUBTYPE)
|
||||||
|
|
||||||
extern EFI_SYSTEM_TABLE *efi_systab;
|
extern EFI_SYSTEM_TABLE *efi_systab;
|
||||||
extern EFI_HANDLE efi_image_handle;
|
extern EFI_HANDLE efi_image_handle;
|
||||||
|
|
||||||
extern EFI_GUID efi_block_io_protocol_guid;
|
extern EFI_GUID efi_block_io_protocol_guid;
|
||||||
extern EFI_GUID efi_device_path_protocol_guid;
|
extern EFI_GUID efi_device_path_protocol_guid;
|
||||||
extern EFI_GUID efi_graphics_output_protocol_guid;
|
|
||||||
extern EFI_GUID efi_loaded_image_protocol_guid;
|
extern EFI_GUID efi_loaded_image_protocol_guid;
|
||||||
extern EFI_GUID efi_simple_file_system_protocol_guid;
|
extern EFI_GUID efi_simple_file_system_protocol_guid;
|
||||||
extern EFI_GUID efi_load_file2_protocol_guid;
|
extern EFI_GUID efi_load_file2_protocol_guid;
|
||||||
|
@ -1,90 +0,0 @@
|
|||||||
#ifndef _EFIPATH_H
|
|
||||||
#define _EFIPATH_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
*
|
|
||||||
* EFI device paths
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "efi.h"
|
|
||||||
#include "efi/Protocol/DevicePath.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialise device path
|
|
||||||
*
|
|
||||||
* @v name Variable name
|
|
||||||
* @v type Type
|
|
||||||
* @v subtype Subtype
|
|
||||||
*/
|
|
||||||
#define EFI_DEVPATH_INIT(name, type, subtype) \
|
|
||||||
{ \
|
|
||||||
.Type = (type), \
|
|
||||||
.SubType = (subtype), \
|
|
||||||
.Length[0] = (sizeof (name) & 0xff), \
|
|
||||||
.Length[1] = (sizeof (name) >> 8), \
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialise device path
|
|
||||||
*
|
|
||||||
* @v path Device path
|
|
||||||
* @v type Type
|
|
||||||
* @v subtype Subtype
|
|
||||||
* @v len Length
|
|
||||||
*/
|
|
||||||
static inline __attribute__ ((always_inline)) void
|
|
||||||
efi_devpath_init (EFI_DEVICE_PATH_PROTOCOL *path, unsigned int type,
|
|
||||||
unsigned int subtype, size_t len)
|
|
||||||
{
|
|
||||||
|
|
||||||
path->Type = type;
|
|
||||||
path->SubType = subtype;
|
|
||||||
path->Length[0] = (len & 0xff);
|
|
||||||
path->Length[1] = (len >> 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialise device path end
|
|
||||||
*
|
|
||||||
* @v name Variable name
|
|
||||||
*/
|
|
||||||
#define EFI_DEVPATH_END_INIT(name) \
|
|
||||||
EFI_DEVPATH_INIT (name, END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialise device path end
|
|
||||||
*
|
|
||||||
* @v path Device path
|
|
||||||
*/
|
|
||||||
static inline __attribute__ ((always_inline)) void
|
|
||||||
efi_devpath_end_init (EFI_DEVICE_PATH_PROTOCOL *path)
|
|
||||||
{
|
|
||||||
efi_devpath_init (path, END_DEVICE_PATH_TYPE,
|
|
||||||
END_ENTIRE_DEVICE_PATH_SUBTYPE, sizeof (*path));
|
|
||||||
}
|
|
||||||
|
|
||||||
extern EFI_DEVICE_PATH_PROTOCOL *
|
|
||||||
efi_devpath_end (EFI_DEVICE_PATH_PROTOCOL *path);
|
|
||||||
|
|
||||||
#endif /* _EFIPATH_H */
|
|
15
main.c
15
main.c
@ -97,18 +97,6 @@ static void call_interrupt_wrapper (struct bootapp_callback_params *params)
|
|||||||
disable_paging (&state);
|
disable_paging (&state);
|
||||||
|
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
else if ((params->vector.interrupt == 0x10) &&
|
|
||||||
(params->ax == 0x4f01))
|
|
||||||
{
|
|
||||||
|
|
||||||
/* Mark all VESA video modes as unsupported */
|
|
||||||
uint16_t *attributes = REAL_PTR (params->es, params->di);
|
|
||||||
call_interrupt (params);
|
|
||||||
*attributes &= ~0x0001;
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -253,8 +241,7 @@ int main (void)
|
|||||||
init_cookie();
|
init_cookie();
|
||||||
|
|
||||||
/* Print welcome banner */
|
/* Print welcome banner */
|
||||||
printf ("\n\nntloader " VERSION " -- Windows NT6+ OS/VHD/WIM "
|
printf ("\n\nntloader " VERSION "\n\n");
|
||||||
"loader -- https://github.com/grub4dos/ntloader\n\n");
|
|
||||||
|
|
||||||
/* Process command line */
|
/* Process command line */
|
||||||
process_cmdline (cmdline);
|
process_cmdline (cmdline);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user