Migrate XTLDR modules to C++
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
* Aiken Harris <harraiken91@gmail.com>
|
* Aiken Harris <harraiken91@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xtldr.h>
|
#include <xtldr.hh>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
* Aiken Harris <harraiken91@gmail.com>
|
* Aiken Harris <harraiken91@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xtldr.h>
|
#include <xtldr.hh>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
* DEVELOPERS: Aiken Harris <harraiken91@gmail.com>
|
* DEVELOPERS: Aiken Harris <harraiken91@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xtldr.h>
|
#include <xtldr.hh>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
* Aiken Harris <harraiken91@gmail.com>
|
* Aiken Harris <harraiken91@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xtldr.h>
|
#include <xtldr.hh>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xtldr.h>
|
#include <xtldr.hh>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xtldr.h>
|
#include <xtldr.hh>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xtldr.h>
|
#include <xtldr.hh>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xtldr.h>
|
#include <xtldr.hh>
|
||||||
|
|
||||||
|
|
||||||
/* XT Boot Loader registered boot protocol list */
|
/* XT Boot Loader registered boot protocol list */
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xtldr.h>
|
#include <xtldr.hh>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
/**
|
/**
|
||||||
* PROJECT: ExectOS
|
* PROJECT: ExectOS
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
* FILE: xtldr/includes/globals.h
|
* FILE: xtldr/includes/globals.hh
|
||||||
* DESCRIPTION: XTLDR global variables
|
* DESCRIPTION: XTLDR global variables
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __XTLDR_GLOBALS_H
|
#ifndef __XTLDR_GLOBALS_HH
|
||||||
#define __XTLDR_GLOBALS_H
|
#define __XTLDR_GLOBALS_HH
|
||||||
|
|
||||||
#include <xtblapi.h>
|
#include <xtblapi.h>
|
||||||
|
|
||||||
@@ -48,4 +48,4 @@ EXTERN EFI_HANDLE EfiImageHandle;
|
|||||||
/* EFI System Table */
|
/* EFI System Table */
|
||||||
EXTERN PEFI_SYSTEM_TABLE EfiSystemTable;
|
EXTERN PEFI_SYSTEM_TABLE EfiSystemTable;
|
||||||
|
|
||||||
#endif /* __XTLDR_GLOBALS_H */
|
#endif /* __XTLDR_GLOBALS_HH */
|
@@ -1,18 +1,18 @@
|
|||||||
/**
|
/**
|
||||||
* PROJECT: ExectOS
|
* PROJECT: ExectOS
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
* FILE: xtldr/includes/xtldr.h
|
* FILE: xtldr/includes/xtldr.hh
|
||||||
* DESCRIPTION: Top level header for XTLDR
|
* DESCRIPTION: Top level header for XTLDR
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __XTLDR_XTLDR_H
|
#ifndef __XTLDR_XTLDR_HH
|
||||||
#define __XTLDR_XTLDR_H
|
#define __XTLDR_XTLDR_HH
|
||||||
|
|
||||||
#include <xtblapi.h>
|
#include <xtblapi.h>
|
||||||
#include <xtver.h>
|
#include <xtver.h>
|
||||||
|
|
||||||
#include <globals.h>
|
#include <globals.hh>
|
||||||
|
|
||||||
|
|
||||||
/* XTLDR routines forward references */
|
/* XTLDR routines forward references */
|
||||||
@@ -579,4 +579,4 @@ XTCDECL
|
|||||||
VOID
|
VOID
|
||||||
BlpUpdateConfiguration(IN PLIST_ENTRY NewConfig);
|
BlpUpdateConfiguration(IN PLIST_ENTRY NewConfig);
|
||||||
|
|
||||||
#endif /* __XTLDR_XTLDR_H */
|
#endif /* __XTLDR_XTLDR_HH */
|
@@ -6,7 +6,7 @@
|
|||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xtldr.h>
|
#include <xtldr.hh>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xtldr.h>
|
#include <xtldr.hh>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -8,8 +8,8 @@ include_directories(
|
|||||||
|
|
||||||
# Specify list of source code files
|
# Specify list of source code files
|
||||||
list(APPEND XTLDR_ACPI_SOURCE
|
list(APPEND XTLDR_ACPI_SOURCE
|
||||||
${XTLDR_ACPI_SOURCE_DIR}/acpi.c
|
${XTLDR_ACPI_SOURCE_DIR}/acpi.cc
|
||||||
${XTLDR_ACPI_SOURCE_DIR}/globals.c)
|
${XTLDR_ACPI_SOURCE_DIR}/data.cc)
|
||||||
|
|
||||||
# Link module executable
|
# Link module executable
|
||||||
add_executable(acpi ${XTLDR_ACPI_SOURCE})
|
add_executable(acpi ${XTLDR_ACPI_SOURCE})
|
||||||
|
@@ -1,20 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* PROJECT: ExectOS
|
* PROJECT: ExectOS
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
* FILE: xtldr/modules/acpi/acpi.c
|
* FILE: xtldr/modules/acpi/acpi.cc
|
||||||
* DESCRIPTION: XTLDR ACPI Support Module
|
* DESCRIPTION: XTLDR ACPI Support Module
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <acpi.h>
|
#include <acpi.hh>
|
||||||
|
|
||||||
|
|
||||||
/* Dummy module information */
|
/* ACPI module information */
|
||||||
MODULE_AUTHOR(L"Rafal Kupiec <belliash@codingworkshop.eu.org>");
|
MODULE_AUTHOR(L"Rafal Kupiec <belliash@codingworkshop.eu.org>");
|
||||||
MODULE_DESCRIPTION(L"ACPI support");
|
MODULE_DESCRIPTION(L"ACPI support");
|
||||||
MODULE_LICENSE(L"GPLv3");
|
MODULE_LICENSE(L"GPLv3");
|
||||||
MODULE_VERSION(L"0.1");
|
MODULE_VERSION(L"0.1");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to get XSDP. If it is not found or checksum mismatch, it will try to get RSDP instead.
|
* Attempts to get XSDP. If it is not found or checksum mismatch, it will try to get RSDP instead.
|
||||||
*
|
*
|
||||||
@@ -27,12 +28,12 @@ MODULE_VERSION(L"0.1");
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
AcGetAcpiDescriptionPointer(OUT PVOID *AcpiTable)
|
Acpi::GetAcpiDescriptionPointer(OUT PVOID *AcpiTable)
|
||||||
{
|
{
|
||||||
PVOID Rsdp;
|
PVOID Rsdp;
|
||||||
|
|
||||||
/* Try to get XSDP (ACPI 2.0) from system configuration tables */
|
/* Try to get XSDP (ACPI 2.0) from system configuration tables */
|
||||||
if(AcGetXsdpTable(&Rsdp) == STATUS_EFI_SUCCESS)
|
if(GetXsdpTable(&Rsdp) == STATUS_EFI_SUCCESS)
|
||||||
{
|
{
|
||||||
/* XSDP found, return success */
|
/* XSDP found, return success */
|
||||||
*AcpiTable = Rsdp;
|
*AcpiTable = Rsdp;
|
||||||
@@ -40,7 +41,7 @@ AcGetAcpiDescriptionPointer(OUT PVOID *AcpiTable)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Try to get RSDP (ACPI 1.0) from system configuration tables */
|
/* Try to get RSDP (ACPI 1.0) from system configuration tables */
|
||||||
if(AcGetRsdpTable(&Rsdp) == STATUS_EFI_SUCCESS)
|
if(GetRsdpTable(&Rsdp) == STATUS_EFI_SUCCESS)
|
||||||
{
|
{
|
||||||
/* RSDP found, return success */
|
/* RSDP found, return success */
|
||||||
*AcpiTable = Rsdp;
|
*AcpiTable = Rsdp;
|
||||||
@@ -69,7 +70,7 @@ AcGetAcpiDescriptionPointer(OUT PVOID *AcpiTable)
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
AcGetAcpiTable(IN CONST UINT Signature,
|
Acpi::GetAcpiTable(IN CONST UINT Signature,
|
||||||
IN PVOID PreviousTable,
|
IN PVOID PreviousTable,
|
||||||
OUT PVOID *AcpiTable)
|
OUT PVOID *AcpiTable)
|
||||||
{
|
{
|
||||||
@@ -85,7 +86,7 @@ AcGetAcpiTable(IN CONST UINT Signature,
|
|||||||
*AcpiTable = NULLPTR;
|
*AcpiTable = NULLPTR;
|
||||||
|
|
||||||
/* Get Root System Description Table Pointer */
|
/* Get Root System Description Table Pointer */
|
||||||
Status = AcGetAcpiDescriptionPointer((PVOID)&Rsdp);
|
Status = GetAcpiDescriptionPointer((PVOID*)&Rsdp);
|
||||||
if(Status != STATUS_EFI_SUCCESS)
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
{
|
{
|
||||||
/* ACPI tables not found, return error */
|
/* ACPI tables not found, return error */
|
||||||
@@ -159,7 +160,7 @@ AcGetAcpiTable(IN CONST UINT Signature,
|
|||||||
if(TableHeader->Signature != ACPI_FADT_SIGNATURE || TableHeader->Revision > 2)
|
if(TableHeader->Signature != ACPI_FADT_SIGNATURE || TableHeader->Revision > 2)
|
||||||
{
|
{
|
||||||
/* Validate table checksum */
|
/* Validate table checksum */
|
||||||
if(!AcpValidateAcpiTable(TableHeader, TableHeader->Length))
|
if(!ValidateAcpiTable(TableHeader, TableHeader->Length))
|
||||||
{
|
{
|
||||||
/* Checksum mismatch, return error */
|
/* Checksum mismatch, return error */
|
||||||
return STATUS_EFI_CRC_ERROR;
|
return STATUS_EFI_CRC_ERROR;
|
||||||
@@ -183,7 +184,7 @@ AcGetAcpiTable(IN CONST UINT Signature,
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
AcGetApicBase(OUT PVOID *ApicBase)
|
Acpi::GetApicBase(OUT PVOID *ApicBase)
|
||||||
{
|
{
|
||||||
CPUID_REGISTERS CpuRegisters;
|
CPUID_REGISTERS CpuRegisters;
|
||||||
|
|
||||||
@@ -220,7 +221,7 @@ AcGetApicBase(OUT PVOID *ApicBase)
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
AcGetRsdpTable(OUT PVOID *AcpiTable)
|
Acpi::GetRsdpTable(OUT PVOID *AcpiTable)
|
||||||
{
|
{
|
||||||
EFI_GUID AcpiGuid = EFI_CONFIG_TABLE_ACPI_TABLE_GUID;
|
EFI_GUID AcpiGuid = EFI_CONFIG_TABLE_ACPI_TABLE_GUID;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
@@ -228,7 +229,7 @@ AcGetRsdpTable(OUT PVOID *AcpiTable)
|
|||||||
|
|
||||||
/* Get RSDP (ACPI 1.0) table from system configuration tables */
|
/* Get RSDP (ACPI 1.0) table from system configuration tables */
|
||||||
Status = XtLdrProtocol->Util.GetConfigurationTable(&AcpiGuid, &RsdpTable);
|
Status = XtLdrProtocol->Util.GetConfigurationTable(&AcpiGuid, &RsdpTable);
|
||||||
if(Status != STATUS_EFI_SUCCESS || !AcpValidateAcpiTable(RsdpTable, 20))
|
if(Status != STATUS_EFI_SUCCESS || !ValidateAcpiTable(RsdpTable, 20))
|
||||||
{
|
{
|
||||||
/* RSDP not found or checksum mismatch */
|
/* RSDP not found or checksum mismatch */
|
||||||
*AcpiTable = NULLPTR;
|
*AcpiTable = NULLPTR;
|
||||||
@@ -252,15 +253,15 @@ AcGetRsdpTable(OUT PVOID *AcpiTable)
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
AcGetSMBiosTable(OUT PVOID *SmBiosTable)
|
Acpi::GetSMBiosTable(OUT PVOID *SmBiosTable)
|
||||||
{
|
{
|
||||||
EFI_GUID SmBiosGuid = EFI_CONFIG_TABLE_SMBIOS_TABLE_GUID;
|
EFI_GUID SmBiosGuid = EFI_CONFIG_TABLE_SMBIOS_TABLE_GUID;
|
||||||
PSMBIOS_TABLE_HEADER SmBios;
|
PSMBIOS_TABLE_HEADER SmBios;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
/* Get SMBIOS table from system configuration tables */
|
/* Get SMBIOS table from system configuration tables */
|
||||||
Status = XtLdrProtocol->Util.GetConfigurationTable(&SmBiosGuid, (PVOID)&SmBios);
|
Status = XtLdrProtocol->Util.GetConfigurationTable(&SmBiosGuid, (PVOID*)&SmBios);
|
||||||
if(Status != STATUS_EFI_SUCCESS || !AcpValidateAcpiTable(SmBios, SmBios->Length))
|
if(Status != STATUS_EFI_SUCCESS || !ValidateAcpiTable(SmBios, SmBios->Length))
|
||||||
{
|
{
|
||||||
/* SMBIOS not found or checksum mismatch */
|
/* SMBIOS not found or checksum mismatch */
|
||||||
*SmBiosTable = NULLPTR;
|
*SmBiosTable = NULLPTR;
|
||||||
@@ -284,15 +285,15 @@ AcGetSMBiosTable(OUT PVOID *SmBiosTable)
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
AcGetSMBios3Table(OUT PVOID *SmBiosTable)
|
Acpi::GetSMBios3Table(OUT PVOID *SmBiosTable)
|
||||||
{
|
{
|
||||||
EFI_GUID SmBios3Guid = EFI_CONFIG_TABLE_SMBIOS3_TABLE_GUID;
|
EFI_GUID SmBios3Guid = EFI_CONFIG_TABLE_SMBIOS3_TABLE_GUID;
|
||||||
PSMBIOS3_TABLE_HEADER SmBios;
|
PSMBIOS3_TABLE_HEADER SmBios;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
/* Get SMBIOS3 table from system configuration tables */
|
/* Get SMBIOS3 table from system configuration tables */
|
||||||
Status = XtLdrProtocol->Util.GetConfigurationTable(&SmBios3Guid, (PVOID)&SmBios);
|
Status = XtLdrProtocol->Util.GetConfigurationTable(&SmBios3Guid, (PVOID*)&SmBios);
|
||||||
if(Status != STATUS_EFI_SUCCESS || !AcpValidateAcpiTable(SmBios, SmBios->Length))
|
if(Status != STATUS_EFI_SUCCESS || !ValidateAcpiTable(SmBios, SmBios->Length))
|
||||||
{
|
{
|
||||||
/* SMBIOS3 not found or checksum mismatch */
|
/* SMBIOS3 not found or checksum mismatch */
|
||||||
*SmBiosTable = NULLPTR;
|
*SmBiosTable = NULLPTR;
|
||||||
@@ -316,7 +317,7 @@ AcGetSMBios3Table(OUT PVOID *SmBiosTable)
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
AcGetXsdpTable(OUT PVOID *AcpiTable)
|
Acpi::GetXsdpTable(OUT PVOID *AcpiTable)
|
||||||
{
|
{
|
||||||
EFI_GUID AcpiGuid = EFI_CONFIG_TABLE_ACPI20_TABLE_GUID;
|
EFI_GUID AcpiGuid = EFI_CONFIG_TABLE_ACPI20_TABLE_GUID;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
@@ -324,7 +325,7 @@ AcGetXsdpTable(OUT PVOID *AcpiTable)
|
|||||||
|
|
||||||
/* Get XSDP (ACPI 2.0) from system configuration tables */
|
/* Get XSDP (ACPI 2.0) from system configuration tables */
|
||||||
Status = XtLdrProtocol->Util.GetConfigurationTable(&AcpiGuid, &XsdpTable);
|
Status = XtLdrProtocol->Util.GetConfigurationTable(&AcpiGuid, &XsdpTable);
|
||||||
if(Status != STATUS_EFI_SUCCESS || !AcpValidateAcpiTable(XsdpTable, 36))
|
if(Status != STATUS_EFI_SUCCESS || !ValidateAcpiTable(XsdpTable, 36))
|
||||||
{
|
{
|
||||||
/* XSDP not found or checksum mismatch */
|
/* XSDP not found or checksum mismatch */
|
||||||
*AcpiTable = NULLPTR;
|
*AcpiTable = NULLPTR;
|
||||||
@@ -336,6 +337,48 @@ AcGetXsdpTable(OUT PVOID *AcpiTable)
|
|||||||
return STATUS_EFI_SUCCESS;
|
return STATUS_EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes ACPI module by opening XTLDR protocol and installing ACPI protocol.
|
||||||
|
*
|
||||||
|
* @param ImageHandle
|
||||||
|
* Firmware-allocated handle that identifies the image.
|
||||||
|
*
|
||||||
|
* @param SystemTable
|
||||||
|
* Provides the EFI system table.
|
||||||
|
*
|
||||||
|
* @return This routine returns status code.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
EFI_STATUS
|
||||||
|
Acpi::InitializeModule(IN EFI_HANDLE ImageHandle,
|
||||||
|
IN PEFI_SYSTEM_TABLE SystemTable)
|
||||||
|
{
|
||||||
|
EFI_GUID Guid = XT_ACPI_PROTOCOL_GUID;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
/* Open the XTLDR protocol */
|
||||||
|
Status = BlGetXtLdrProtocol(SystemTable, ImageHandle, &XtLdrProtocol);
|
||||||
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
/* Failed to open the protocol, return error */
|
||||||
|
return STATUS_EFI_PROTOCOL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set routines available via ACPI protocol */
|
||||||
|
AcpiProtocol.GetAcpiDescriptionPointer = GetAcpiDescriptionPointer;
|
||||||
|
AcpiProtocol.GetAcpiTable = GetAcpiTable;
|
||||||
|
AcpiProtocol.GetApicBase = GetApicBase;
|
||||||
|
AcpiProtocol.GetRsdpTable = GetRsdpTable;
|
||||||
|
AcpiProtocol.GetSMBiosTable = GetSMBiosTable;
|
||||||
|
AcpiProtocol.GetSMBios3Table = GetSMBios3Table;
|
||||||
|
AcpiProtocol.GetXsdpTable = GetXsdpTable;
|
||||||
|
|
||||||
|
/* Install ACPI protocol */
|
||||||
|
return XtLdrProtocol->Protocol.Install(&AcpiProtocol, &Guid);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates given ACPI table by calculating its checksum.
|
* Validates given ACPI table by calculating its checksum.
|
||||||
*
|
*
|
||||||
@@ -351,7 +394,7 @@ AcGetXsdpTable(OUT PVOID *AcpiTable)
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
AcpValidateAcpiTable(IN PVOID Buffer,
|
Acpi::ValidateAcpiTable(IN PVOID Buffer,
|
||||||
IN UINT_PTR Size)
|
IN UINT_PTR Size)
|
||||||
{
|
{
|
||||||
PUCHAR Pointer;
|
PUCHAR Pointer;
|
||||||
@@ -359,7 +402,7 @@ AcpValidateAcpiTable(IN PVOID Buffer,
|
|||||||
|
|
||||||
/* Initialize variables */
|
/* Initialize variables */
|
||||||
Sum = 0;
|
Sum = 0;
|
||||||
Pointer = Buffer;
|
Pointer = (PUCHAR)Buffer;
|
||||||
|
|
||||||
/* Calculate checksum of given table */
|
/* Calculate checksum of given table */
|
||||||
while(Size != 0)
|
while(Size != 0)
|
||||||
@@ -391,26 +434,6 @@ EFI_STATUS
|
|||||||
XtLdrModuleMain(IN EFI_HANDLE ImageHandle,
|
XtLdrModuleMain(IN EFI_HANDLE ImageHandle,
|
||||||
IN PEFI_SYSTEM_TABLE SystemTable)
|
IN PEFI_SYSTEM_TABLE SystemTable)
|
||||||
{
|
{
|
||||||
EFI_GUID Guid = XT_ACPI_PROTOCOL_GUID;
|
/* Initialize ACPI module */
|
||||||
EFI_STATUS Status;
|
return Acpi::InitializeModule(ImageHandle, SystemTable);
|
||||||
|
|
||||||
/* Open the XTLDR protocol */
|
|
||||||
Status = BlGetXtLdrProtocol(SystemTable, ImageHandle, &XtLdrProtocol);
|
|
||||||
if(Status != STATUS_EFI_SUCCESS)
|
|
||||||
{
|
|
||||||
/* Failed to open the protocol, return error */
|
|
||||||
return STATUS_EFI_PROTOCOL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set routines available via ACPI protocol */
|
|
||||||
AcpAcpiProtocol.GetAcpiDescriptionPointer = AcGetAcpiDescriptionPointer;
|
|
||||||
AcpAcpiProtocol.GetAcpiTable = AcGetAcpiTable;
|
|
||||||
AcpAcpiProtocol.GetApicBase = AcGetApicBase;
|
|
||||||
AcpAcpiProtocol.GetRsdpTable = AcGetRsdpTable;
|
|
||||||
AcpAcpiProtocol.GetSMBiosTable = AcGetSMBiosTable;
|
|
||||||
AcpAcpiProtocol.GetSMBios3Table = AcGetSMBios3Table;
|
|
||||||
AcpAcpiProtocol.GetXsdpTable = AcGetXsdpTable;
|
|
||||||
|
|
||||||
/* Install ACPI protocol */
|
|
||||||
return XtLdrProtocol->Protocol.Install(&AcpAcpiProtocol, &Guid);
|
|
||||||
}
|
}
|
@@ -1,16 +1,16 @@
|
|||||||
/**
|
/**
|
||||||
* PROJECT: ExectOS
|
* PROJECT: ExectOS
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
* FILE: xtldr/modules/acpi/globals.c
|
* FILE: xtldr/modules/acpi/data.cc
|
||||||
* DESCRIPTION: ACPI module global variables
|
* DESCRIPTION: ACPI module global and static data
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xtblapi.h>
|
#include <acpi.hh>
|
||||||
|
|
||||||
|
|
||||||
/* ACPI Protocol */
|
/* ACPI Protocol */
|
||||||
XTBL_ACPI_PROTOCOL AcpAcpiProtocol;
|
XTBL_ACPI_PROTOCOL Acpi::AcpiProtocol;
|
||||||
|
|
||||||
/* XTLDR protocol handler */
|
/* XTLDR protocol handler */
|
||||||
PXTBL_LOADER_PROTOCOL XtLdrProtocol;
|
PXTBL_LOADER_PROTOCOL Acpi::XtLdrProtocol;
|
@@ -1,57 +0,0 @@
|
|||||||
/**
|
|
||||||
* PROJECT: ExectOS
|
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
|
||||||
* FILE: xtldr/modules/acpi/includes/acpi.h
|
|
||||||
* DESCRIPTION: XTLDR ACPI module header file
|
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __XTLDR_ACPI_ACPI_H
|
|
||||||
#define __XTLDR_ACPI_ACPI_H
|
|
||||||
|
|
||||||
#include <xtblapi.h>
|
|
||||||
#include <globals.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* ACPI module routines forward references */
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
AcGetAcpiDescriptionPointer(OUT PVOID *AcpiTable);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
AcGetAcpiTable(IN CONST UINT Signature,
|
|
||||||
IN PVOID PreviousTable,
|
|
||||||
OUT PVOID *AcpiTable);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
AcGetApicBase(OUT PVOID *ApicBase);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
AcGetRsdpTable(OUT PVOID *AcpiTable);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
AcGetSMBiosTable(OUT PVOID *SmBiosTable);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
AcGetSMBios3Table(OUT PVOID *SmBiosTable);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
AcGetXsdpTable(OUT PVOID *AcpiTable);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
BOOLEAN
|
|
||||||
AcpValidateAcpiTable(IN PVOID Buffer,
|
|
||||||
IN UINT_PTR Size);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
XtLdrModuleMain(IN EFI_HANDLE ImageHandle,
|
|
||||||
IN PEFI_SYSTEM_TABLE SystemTable);
|
|
||||||
|
|
||||||
#endif/* __XTLDR_ACPI_ACPI_H */
|
|
40
xtldr/modules/acpi/includes/acpi.hh
Normal file
40
xtldr/modules/acpi/includes/acpi.hh
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
* PROJECT: ExectOS
|
||||||
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
|
* FILE: xtldr/modules/acpi/includes/acpi.hh
|
||||||
|
* DESCRIPTION: XTLDR ACPI module header file
|
||||||
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __XTLDR_ACPI_ACPI_HH
|
||||||
|
#define __XTLDR_ACPI_ACPI_HH
|
||||||
|
|
||||||
|
#include <xtblapi.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* ACPI module for XTLDR */
|
||||||
|
class Acpi
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
STATIC XTBL_ACPI_PROTOCOL AcpiProtocol;
|
||||||
|
STATIC PXTBL_LOADER_PROTOCOL XtLdrProtocol;
|
||||||
|
|
||||||
|
public:
|
||||||
|
STATIC XTCDECL EFI_STATUS GetAcpiDescriptionPointer(OUT PVOID *AcpiTable);
|
||||||
|
STATIC XTCDECL EFI_STATUS GetAcpiTable(IN CONST UINT Signature,
|
||||||
|
IN PVOID PreviousTable,
|
||||||
|
OUT PVOID *AcpiTable);
|
||||||
|
STATIC XTCDECL EFI_STATUS GetApicBase(OUT PVOID *ApicBase);
|
||||||
|
STATIC XTCDECL EFI_STATUS GetRsdpTable(OUT PVOID *AcpiTable);
|
||||||
|
STATIC XTCDECL EFI_STATUS GetSMBiosTable(OUT PVOID *SmBiosTable);
|
||||||
|
STATIC XTCDECL EFI_STATUS GetSMBios3Table(OUT PVOID *SmBiosTable);
|
||||||
|
STATIC XTCDECL EFI_STATUS GetXsdpTable(OUT PVOID *AcpiTable);
|
||||||
|
STATIC XTCDECL EFI_STATUS InitializeModule(IN EFI_HANDLE ImageHandle,
|
||||||
|
IN PEFI_SYSTEM_TABLE SystemTable);
|
||||||
|
|
||||||
|
private:
|
||||||
|
STATIC XTCDECL BOOLEAN ValidateAcpiTable(IN PVOID Buffer,
|
||||||
|
IN UINT_PTR Size);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __XTLDR_ACPI_ACPI_HH */
|
@@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* PROJECT: ExectOS
|
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
|
||||||
* FILE: xtldr/modules/acpi/includes/globals.h
|
|
||||||
* DESCRIPTION: ACPI Module global variables
|
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __XTLDR_ACPI_GLOBALS_H
|
|
||||||
#define __XTLDR_ACPI_GLOBALS_H
|
|
||||||
|
|
||||||
#include <acpi.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* ACPI Protocol */
|
|
||||||
EXTERN XTBL_ACPI_PROTOCOL AcpAcpiProtocol;
|
|
||||||
|
|
||||||
/* XTLDR protocol handler */
|
|
||||||
EXTERN PXTBL_LOADER_PROTOCOL XtLdrProtocol;
|
|
||||||
|
|
||||||
#endif/* __XTLDR_ACPI_GLOBALS_H */
|
|
@@ -8,8 +8,8 @@ include_directories(
|
|||||||
|
|
||||||
# Specify list of source code files
|
# Specify list of source code files
|
||||||
list(APPEND XTLDR_BEEP_SOURCE
|
list(APPEND XTLDR_BEEP_SOURCE
|
||||||
${XTLDR_BEEP_SOURCE_DIR}/beep.c
|
${XTLDR_BEEP_SOURCE_DIR}/beep.cc
|
||||||
${XTLDR_BEEP_SOURCE_DIR}/globals.c)
|
${XTLDR_BEEP_SOURCE_DIR}/data.cc)
|
||||||
|
|
||||||
# Link module executable
|
# Link module executable
|
||||||
add_executable(beep ${XTLDR_BEEP_SOURCE})
|
add_executable(beep ${XTLDR_BEEP_SOURCE})
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* PROJECT: ExectOS
|
* PROJECT: ExectOS
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
* FILE: xtldr/modules/beep/beep.c
|
* FILE: xtldr/modules/beep/beep.cc
|
||||||
* DESCRIPTION: XTLDR Beep Module
|
* DESCRIPTION: XTLDR Beep Module
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <beep.h>
|
#include <beep.hh>
|
||||||
|
|
||||||
|
|
||||||
/* Beep module information */
|
/* Beep module information */
|
||||||
@@ -15,6 +15,7 @@ MODULE_DESCRIPTION(L"Plays a GRUB compatible tune via PC speaker");
|
|||||||
MODULE_LICENSE(L"GPLv3");
|
MODULE_LICENSE(L"GPLv3");
|
||||||
MODULE_VERSION(L"0.1");
|
MODULE_VERSION(L"0.1");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disables the PC speaker.
|
* Disables the PC speaker.
|
||||||
*
|
*
|
||||||
@@ -24,7 +25,7 @@ MODULE_VERSION(L"0.1");
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
VOID
|
VOID
|
||||||
BpDisableToneBeep()
|
Beep::DisableToneBeep()
|
||||||
{
|
{
|
||||||
UCHAR Status;
|
UCHAR Status;
|
||||||
|
|
||||||
@@ -45,7 +46,7 @@ BpDisableToneBeep()
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
VOID
|
VOID
|
||||||
BpEnableToneBeep(IN UINT Pitch)
|
Beep::EnableToneBeep(IN UINT Pitch)
|
||||||
{
|
{
|
||||||
UINT Counter;
|
UINT Counter;
|
||||||
UCHAR Status;
|
UCHAR Status;
|
||||||
@@ -72,6 +73,43 @@ BpEnableToneBeep(IN UINT Pitch)
|
|||||||
HlWritePort8(0x61, Status | 0x03);
|
HlWritePort8(0x61, Status | 0x03);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes BEEP module by opening XTLDR protocol and playing the tune.
|
||||||
|
*
|
||||||
|
* @param ImageHandle
|
||||||
|
* Firmware-allocated handle that identifies the image.
|
||||||
|
*
|
||||||
|
* @param SystemTable
|
||||||
|
* Provides the EFI system table.
|
||||||
|
*
|
||||||
|
* @return This routine returns status code.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
EFI_STATUS
|
||||||
|
Beep::InitializeModule(IN EFI_HANDLE ImageHandle,
|
||||||
|
IN PEFI_SYSTEM_TABLE SystemTable)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
PWCHAR Tune;
|
||||||
|
|
||||||
|
/* Open the XTLDR protocol */
|
||||||
|
Status = BlGetXtLdrProtocol(SystemTable, ImageHandle, &XtLdrProtocol);
|
||||||
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
/* Failed to open the protocol, return error */
|
||||||
|
return STATUS_EFI_PROTOCOL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Play the tune set in the configuration */
|
||||||
|
XtLdrProtocol->Config.GetValue(L"TUNE", &Tune);
|
||||||
|
PlayTune(Tune);
|
||||||
|
|
||||||
|
/* Return success */
|
||||||
|
return STATUS_EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This routine plays a tune.
|
* This routine plays a tune.
|
||||||
*
|
*
|
||||||
@@ -84,7 +122,7 @@ BpEnableToneBeep(IN UINT Pitch)
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
VOID
|
VOID
|
||||||
BpPlayTune(IN PWCHAR Arguments)
|
Beep::PlayTune(IN PWCHAR Arguments)
|
||||||
{
|
{
|
||||||
LONG Pitch, Duration, Tempo;
|
LONG Pitch, Duration, Tempo;
|
||||||
PWCHAR Argument, LastArgument;
|
PWCHAR Argument, LastArgument;
|
||||||
@@ -104,28 +142,28 @@ BpPlayTune(IN PWCHAR Arguments)
|
|||||||
if(Tempo < 0)
|
if(Tempo < 0)
|
||||||
{
|
{
|
||||||
/* Set the tempo */
|
/* Set the tempo */
|
||||||
Tempo = BpWideStringToNumber(Argument);
|
Tempo = WideStringToNumber(Argument);
|
||||||
}
|
}
|
||||||
else if(Pitch < 0)
|
else if(Pitch < 0)
|
||||||
{
|
{
|
||||||
/* Set the pitch */
|
/* Set the pitch */
|
||||||
Pitch = BpWideStringToNumber(Argument);
|
Pitch = WideStringToNumber(Argument);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Set the duration */
|
/* Set the duration */
|
||||||
Duration = BpWideStringToNumber(Argument);
|
Duration = WideStringToNumber(Argument);
|
||||||
|
|
||||||
/* Check pitch value */
|
/* Check pitch value */
|
||||||
if(Pitch > 0)
|
if(Pitch > 0)
|
||||||
{
|
{
|
||||||
/* Emit the beep tone */
|
/* Emit the beep tone */
|
||||||
BpEnableToneBeep(Pitch);
|
EnableToneBeep(Pitch);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Stop emitting beep tone */
|
/* Stop emitting beep tone */
|
||||||
BpDisableToneBeep();
|
DisableToneBeep();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait for duration time */
|
/* Wait for duration time */
|
||||||
@@ -141,7 +179,7 @@ BpPlayTune(IN PWCHAR Arguments)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Stop emitting beep tone */
|
/* Stop emitting beep tone */
|
||||||
BpDisableToneBeep();
|
DisableToneBeep();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -156,7 +194,7 @@ BpPlayTune(IN PWCHAR Arguments)
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
UINT
|
UINT
|
||||||
BpWideStringToNumber(IN PWCHAR String)
|
Beep::WideStringToNumber(IN PWCHAR String)
|
||||||
{
|
{
|
||||||
ULONG Number = 0;
|
ULONG Number = 0;
|
||||||
|
|
||||||
@@ -195,21 +233,6 @@ EFI_STATUS
|
|||||||
XtLdrModuleMain(IN EFI_HANDLE ImageHandle,
|
XtLdrModuleMain(IN EFI_HANDLE ImageHandle,
|
||||||
IN PEFI_SYSTEM_TABLE SystemTable)
|
IN PEFI_SYSTEM_TABLE SystemTable)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
/* Initialize BEEP module */
|
||||||
PWCHAR Tune;
|
return Beep::InitializeModule(ImageHandle, SystemTable);
|
||||||
|
|
||||||
/* Open the XTLDR protocol */
|
|
||||||
Status = BlGetXtLdrProtocol(SystemTable, ImageHandle, &XtLdrProtocol);
|
|
||||||
if(Status != STATUS_EFI_SUCCESS)
|
|
||||||
{
|
|
||||||
/* Failed to open the protocol, return error */
|
|
||||||
return STATUS_EFI_PROTOCOL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Play the tune set in the configuration */
|
|
||||||
XtLdrProtocol->Config.GetValue(L"TUNE", &Tune);
|
|
||||||
BpPlayTune(Tune);
|
|
||||||
|
|
||||||
/* Return success */
|
|
||||||
return STATUS_EFI_SUCCESS;
|
|
||||||
}
|
}
|
@@ -1,13 +1,13 @@
|
|||||||
/**
|
/**
|
||||||
* PROJECT: ExectOS
|
* PROJECT: ExectOS
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
* FILE: xtldr/modules/beep/globals.c
|
* FILE: xtldr/modules/beep/data.cc
|
||||||
* DESCRIPTION: Beep module global variables
|
* DESCRIPTION: BEEP module global and static data
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xtblapi.h>
|
#include <beep.hh>
|
||||||
|
|
||||||
|
|
||||||
/* XTLDR protocol handler */
|
/* XTLDR protocol handler */
|
||||||
PXTBL_LOADER_PROTOCOL XtLdrProtocol;
|
PXTBL_LOADER_PROTOCOL Beep::XtLdrProtocol;
|
@@ -1,38 +0,0 @@
|
|||||||
/**
|
|
||||||
* PROJECT: ExectOS
|
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
|
||||||
* FILE: xtldr/modules/beep/includes/beep.h
|
|
||||||
* DESCRIPTION: XTLDR Beep Module header file
|
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __XTLDR_BEEP_BEEP_H
|
|
||||||
#define __XTLDR_BEEP_BEEP_H
|
|
||||||
|
|
||||||
#include <xtblapi.h>
|
|
||||||
#include <globals.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Beep module routines forward references */
|
|
||||||
XTCDECL
|
|
||||||
VOID
|
|
||||||
BpDisableToneBeep();
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
VOID
|
|
||||||
BpEnableToneBeep(IN UINT Pitch);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
VOID
|
|
||||||
BpPlayTune(IN PWCHAR Arguments);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
UINT
|
|
||||||
BpWideStringToNumber(IN PWCHAR String);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
XtLdrModuleMain(IN EFI_HANDLE ImageHandle,
|
|
||||||
IN PEFI_SYSTEM_TABLE SystemTable);
|
|
||||||
|
|
||||||
#endif/* __XTLDR_BEEP_BEEP_H */
|
|
32
xtldr/modules/beep/includes/beep.hh
Normal file
32
xtldr/modules/beep/includes/beep.hh
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* PROJECT: ExectOS
|
||||||
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
|
* FILE: xtldr/modules/beep/includes/beep.hh
|
||||||
|
* DESCRIPTION: XTLDR Beep Module header file
|
||||||
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __XTLDR_BEEP_BEEP_HH
|
||||||
|
#define __XTLDR_BEEP_BEEP_HH
|
||||||
|
|
||||||
|
#include <xtblapi.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* BEEP module for XTLDR */
|
||||||
|
class Beep
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
STATIC PXTBL_LOADER_PROTOCOL XtLdrProtocol;
|
||||||
|
|
||||||
|
public:
|
||||||
|
STATIC XTCDECL EFI_STATUS InitializeModule(IN EFI_HANDLE ImageHandle,
|
||||||
|
IN PEFI_SYSTEM_TABLE SystemTable);
|
||||||
|
STATIC XTCDECL VOID PlayTune(IN PWCHAR Arguments);
|
||||||
|
|
||||||
|
private:
|
||||||
|
STATIC XTCDECL VOID DisableToneBeep();
|
||||||
|
STATIC XTCDECL VOID EnableToneBeep(IN UINT Pitch);
|
||||||
|
STATIC XTCDECL UINT WideStringToNumber(IN PWCHAR String);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __XTLDR_BEEP_BEEP_HH */
|
@@ -1,18 +0,0 @@
|
|||||||
/**
|
|
||||||
* PROJECT: ExectOS
|
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
|
||||||
* FILE: xtldr/modules/beep/includes/globals.h
|
|
||||||
* DESCRIPTION: XTLDR Beep Module global variables
|
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __XTLDR_BEEP_GLOBALS_H
|
|
||||||
#define __XTLDR_BEEP_GLOBALS_H
|
|
||||||
|
|
||||||
#include <beep.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* XTLDR protocol handler */
|
|
||||||
EXTERN PXTBL_LOADER_PROTOCOL XtLdrProtocol;
|
|
||||||
|
|
||||||
#endif/* __XTLDR_BEEP_GLOBALS_H */
|
|
@@ -8,8 +8,8 @@ include_directories(
|
|||||||
|
|
||||||
# Specify list of source code files
|
# Specify list of source code files
|
||||||
list(APPEND XTLDR_CHAINLDR_SOURCE
|
list(APPEND XTLDR_CHAINLDR_SOURCE
|
||||||
${XTLDR_CHAINLDR_SOURCE_DIR}/chainldr.c
|
${XTLDR_CHAINLDR_SOURCE_DIR}/chainldr.cc
|
||||||
${XTLDR_CHAINLDR_SOURCE_DIR}/globals.c)
|
${XTLDR_CHAINLDR_SOURCE_DIR}/data.cc)
|
||||||
|
|
||||||
# Link module executable
|
# Link module executable
|
||||||
add_executable(chainldr ${XTLDR_CHAINLDR_SOURCE})
|
add_executable(chainldr ${XTLDR_CHAINLDR_SOURCE})
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* PROJECT: ExectOS
|
* PROJECT: ExectOS
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
* FILE: xtldr/modules/chainldr/chainldr.c
|
* FILE: xtldr/modules/chainldr/chainldr.cc
|
||||||
* DESCRIPTION: XTLDR Chain Loader
|
* DESCRIPTION: XTLDR Chain Loader
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <chainldr.h>
|
#include <chainldr.hh>
|
||||||
|
|
||||||
|
|
||||||
/* ChainLoader module information */
|
/* ChainLoader module information */
|
||||||
@@ -15,6 +15,7 @@ MODULE_DESCRIPTION(L"XTLDR Chain Loader");
|
|||||||
MODULE_LICENSE(L"GPLv3");
|
MODULE_LICENSE(L"GPLv3");
|
||||||
MODULE_VERSION(L"0.1");
|
MODULE_VERSION(L"0.1");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chainloads another boot loader.
|
* Chainloads another boot loader.
|
||||||
*
|
*
|
||||||
@@ -27,7 +28,7 @@ MODULE_VERSION(L"0.1");
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
ChBootSystem(IN PXTBL_BOOT_PARAMETERS Parameters)
|
ChainLoader::BootSystem(IN PXTBL_BOOT_PARAMETERS Parameters)
|
||||||
{
|
{
|
||||||
EFI_GUID LIPGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
|
EFI_GUID LIPGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
|
||||||
EFI_MEMMAP_DEVICE_PATH MemoryDevicePath[2];
|
EFI_MEMMAP_DEVICE_PATH MemoryDevicePath[2];
|
||||||
@@ -66,14 +67,14 @@ ChBootSystem(IN PXTBL_BOOT_PARAMETERS Parameters)
|
|||||||
XtLdrProtocol->Debug.Print(L"ERROR: Unable to open system boot directory (Status Code: 0x%zX)\n", Status);
|
XtLdrProtocol->Debug.Print(L"ERROR: Unable to open system boot directory (Status Code: 0x%zX)\n", Status);
|
||||||
|
|
||||||
/* Close volume and return error code */
|
/* Close volume and return error code */
|
||||||
XtLdrProtocol->Disk.CloseVolume(DiskHandle);
|
XtLdrProtocol->Disk.CloseVolume(&DiskHandle);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read EFI image file from disk and close both directory and EFI volume */
|
/* Read EFI image file from disk and close both directory and EFI volume */
|
||||||
Status = XtLdrProtocol->Disk.ReadFile(BootDir, Parameters->KernelFile, &LoaderData, &LoaderSize);
|
Status = XtLdrProtocol->Disk.ReadFile(BootDir, Parameters->KernelFile, &LoaderData, &LoaderSize);
|
||||||
BootDir->Close(BootDir);
|
BootDir->Close(BootDir);
|
||||||
XtLdrProtocol->Disk.CloseVolume(DiskHandle);
|
XtLdrProtocol->Disk.CloseVolume(&DiskHandle);
|
||||||
|
|
||||||
/* Setup device path for EFI image */
|
/* Setup device path for EFI image */
|
||||||
MemoryDevicePath[0].Header.Length[0] = sizeof(EFI_MEMMAP_DEVICE_PATH);
|
MemoryDevicePath[0].Header.Length[0] = sizeof(EFI_MEMMAP_DEVICE_PATH);
|
||||||
@@ -123,6 +124,45 @@ ChBootSystem(IN PXTBL_BOOT_PARAMETERS Parameters)
|
|||||||
return XtLdrProtocol->Util.StartEfiImage(LoaderHandle);
|
return XtLdrProtocol->Util.StartEfiImage(LoaderHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes CHAINLDR module by opening XTLDR protocol and installing CHAINLOADER protocol.
|
||||||
|
*
|
||||||
|
* @param ImageHandle
|
||||||
|
* Firmware-allocated handle that identifies the image.
|
||||||
|
*
|
||||||
|
* @param SystemTable
|
||||||
|
* Provides the EFI system table.
|
||||||
|
*
|
||||||
|
* @return This routine returns status code.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
EFI_STATUS
|
||||||
|
ChainLoader::InitializeModule(IN EFI_HANDLE ImageHandle,
|
||||||
|
IN PEFI_SYSTEM_TABLE SystemTable)
|
||||||
|
{
|
||||||
|
EFI_GUID Guid = XT_CHAIN_BOOT_PROTOCOL_GUID;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
/* Open the XTLDR protocol */
|
||||||
|
Status = BlGetXtLdrProtocol(SystemTable, ImageHandle, &XtLdrProtocol);
|
||||||
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
/* Failed to open the protocol, return error */
|
||||||
|
return STATUS_EFI_PROTOCOL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set routines available via ChainLoader boot protocol */
|
||||||
|
BootProtocol.BootSystem = BootSystem;
|
||||||
|
|
||||||
|
/* Register XTOS boot protocol */
|
||||||
|
XtLdrProtocol->Boot.RegisterProtocol(L"CHAINLOADER", &Guid);
|
||||||
|
|
||||||
|
/* Install XTOS protocol */
|
||||||
|
return XtLdrProtocol->Protocol.Install(&BootProtocol, &Guid);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This routine is the entry point of the XT EFI boot loader module.
|
* This routine is the entry point of the XT EFI boot loader module.
|
||||||
*
|
*
|
||||||
@@ -141,23 +181,6 @@ EFI_STATUS
|
|||||||
XtLdrModuleMain(IN EFI_HANDLE ImageHandle,
|
XtLdrModuleMain(IN EFI_HANDLE ImageHandle,
|
||||||
IN PEFI_SYSTEM_TABLE SystemTable)
|
IN PEFI_SYSTEM_TABLE SystemTable)
|
||||||
{
|
{
|
||||||
EFI_GUID Guid = XT_CHAIN_BOOT_PROTOCOL_GUID;
|
/* Initialize CHAINLDR module */
|
||||||
EFI_STATUS Status;
|
return ChainLoader::InitializeModule(ImageHandle, SystemTable);
|
||||||
|
|
||||||
/* Open the XTLDR protocol */
|
|
||||||
Status = BlGetXtLdrProtocol(SystemTable, ImageHandle, &XtLdrProtocol);
|
|
||||||
if(Status != STATUS_EFI_SUCCESS)
|
|
||||||
{
|
|
||||||
/* Failed to open the protocol, return error */
|
|
||||||
return STATUS_EFI_PROTOCOL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set routines available via ChainLoader boot protocol */
|
|
||||||
ChpBootProtocol.BootSystem = ChBootSystem;
|
|
||||||
|
|
||||||
/* Register XTOS boot protocol */
|
|
||||||
XtLdrProtocol->Boot.RegisterProtocol(L"CHAINLOADER", &Guid);
|
|
||||||
|
|
||||||
/* Install XTOS protocol */
|
|
||||||
return XtLdrProtocol->Protocol.Install(&ChpBootProtocol, &Guid);
|
|
||||||
}
|
}
|
@@ -1,16 +1,16 @@
|
|||||||
/**
|
/**
|
||||||
* PROJECT: ExectOS
|
* PROJECT: ExectOS
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
* FILE: xtldr/modules/chainldr/globals.c
|
* FILE: xtldr/modules/chainldr/data.cc
|
||||||
* DESCRIPTION: XTLDR Chain Loader global variables
|
* DESCRIPTION: CHAINLDR module global and static data
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xtblapi.h>
|
#include <chainldr.hh>
|
||||||
|
|
||||||
|
|
||||||
/* ChainLoader Boot Protocol */
|
/* ChainLoader Boot Protocol */
|
||||||
XTBL_BOOT_PROTOCOL ChpBootProtocol;
|
XTBL_BOOT_PROTOCOL ChainLoader::BootProtocol;
|
||||||
|
|
||||||
/* XTLDR protocol handler */
|
/* XTLDR protocol handler */
|
||||||
PXTBL_LOADER_PROTOCOL XtLdrProtocol;
|
PXTBL_LOADER_PROTOCOL ChainLoader::XtLdrProtocol;
|
@@ -1,26 +0,0 @@
|
|||||||
/**
|
|
||||||
* PROJECT: ExectOS
|
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
|
||||||
* FILE: xtldr/modules/chainldr/includes/chainldr.h
|
|
||||||
* DESCRIPTION: XTLDR Chain Loader header file
|
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __XTLDR_CHAINLDR_CHAINLDR_H
|
|
||||||
#define __XTLDR_CHAINLDR_CHAINLDR_H
|
|
||||||
|
|
||||||
#include <xtblapi.h>
|
|
||||||
#include <globals.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* ChainLoader module routines forward references */
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
ChBootSystem(IN PXTBL_BOOT_PARAMETERS Parameters);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
XtLdrModuleMain(IN EFI_HANDLE ImageHandle,
|
|
||||||
IN PEFI_SYSTEM_TABLE SystemTable);
|
|
||||||
|
|
||||||
#endif/* __XTLDR_CHAINLDR_CHAINLDR_H */
|
|
28
xtldr/modules/chainldr/includes/chainldr.hh
Normal file
28
xtldr/modules/chainldr/includes/chainldr.hh
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/**
|
||||||
|
* PROJECT: ExectOS
|
||||||
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
|
* FILE: xtldr/modules/chainldr/includes/chainldr.hh
|
||||||
|
* DESCRIPTION: XTLDR Chain Loader header file
|
||||||
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __XTLDR_CHAINLDR_CHAINLDR_HH
|
||||||
|
#define __XTLDR_CHAINLDR_CHAINLDR_HH
|
||||||
|
|
||||||
|
#include <xtblapi.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* CHAINLDR module for XTLDR */
|
||||||
|
class ChainLoader
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
STATIC XTBL_BOOT_PROTOCOL BootProtocol;
|
||||||
|
STATIC PXTBL_LOADER_PROTOCOL XtLdrProtocol;
|
||||||
|
|
||||||
|
public:
|
||||||
|
STATIC XTCDECL EFI_STATUS BootSystem(IN PXTBL_BOOT_PARAMETERS Parameters);
|
||||||
|
STATIC XTCDECL EFI_STATUS InitializeModule(IN EFI_HANDLE ImageHandle,
|
||||||
|
IN PEFI_SYSTEM_TABLE SystemTable);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __XTLDR_CHAINLDR_CHAINLDR_HH */
|
@@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* PROJECT: ExectOS
|
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
|
||||||
* FILE: xtldr/modules/chainldr/includes/globals.h
|
|
||||||
* DESCRIPTION: XTLDR Chain Loader global variables
|
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __XTLDR_CHAINLDR_GLOBALS_H
|
|
||||||
#define __XTLDR_CHAINLDR_GLOBALS_H
|
|
||||||
|
|
||||||
#include <chainldr.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* ChainLoader Boot Protocol */
|
|
||||||
EXTERN XTBL_BOOT_PROTOCOL ChpBootProtocol;
|
|
||||||
|
|
||||||
/* XTLDR protocol handler */
|
|
||||||
EXTERN PXTBL_LOADER_PROTOCOL XtLdrProtocol;
|
|
||||||
|
|
||||||
#endif/* __XTLDR_CHAINLDR_GLOBALS_H */
|
|
@@ -8,8 +8,8 @@ include_directories(
|
|||||||
|
|
||||||
# Specify list of source code files
|
# Specify list of source code files
|
||||||
list(APPEND XTLDR_DUMMY_SOURCE
|
list(APPEND XTLDR_DUMMY_SOURCE
|
||||||
${XTLDR_DUMMY_SOURCE_DIR}/dummy.c
|
${XTLDR_DUMMY_SOURCE_DIR}/dummy.cc
|
||||||
${XTLDR_DUMMY_SOURCE_DIR}/globals.c)
|
${XTLDR_DUMMY_SOURCE_DIR}/data.cc)
|
||||||
|
|
||||||
# Link module executable
|
# Link module executable
|
||||||
add_executable(dummy ${XTLDR_DUMMY_SOURCE})
|
add_executable(dummy ${XTLDR_DUMMY_SOURCE})
|
||||||
|
@@ -1,16 +1,16 @@
|
|||||||
/**
|
/**
|
||||||
* PROJECT: ExectOS
|
* PROJECT: ExectOS
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
* FILE: xtldr/modules/dummy/globals.c
|
* FILE: xtldr/modules/dummy/data.cc
|
||||||
* DESCRIPTION: Dummy XTLDR module global variables
|
* DESCRIPTION: Dummy XTLDR module global and static data
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <dummy.h>
|
#include <dummy.hh>
|
||||||
|
|
||||||
|
|
||||||
/* XTLDR protocol handler */
|
|
||||||
PXTBL_LOADER_PROTOCOL XtLdrProtocol;
|
|
||||||
|
|
||||||
/* Dummy Boot Protocol handler */
|
/* Dummy Boot Protocol handler */
|
||||||
XTBL_BOOT_PROTOCOL BlpDummyProtocol;
|
XTBL_BOOT_PROTOCOL Dummy::DummyProtocol;
|
||||||
|
|
||||||
|
/* XTLDR protocol handler */
|
||||||
|
PXTBL_LOADER_PROTOCOL Dummy::XtLdrProtocol;
|
@@ -1,12 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* PROJECT: ExectOS
|
* PROJECT: ExectOS
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
* FILE: xtldr/modules/dummy/dummy.c
|
* FILE: xtldr/modules/dummy/dummy.cc
|
||||||
* DESCRIPTION: XTLDR Dummy Module
|
* DESCRIPTION: XTLDR Dummy Module
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <dummy.h>
|
#include <dummy.hh>
|
||||||
|
|
||||||
|
|
||||||
/* Dummy module information */
|
/* Dummy module information */
|
||||||
@@ -15,6 +15,7 @@ MODULE_DESCRIPTION(L"XTLDR Dummy Module");
|
|||||||
MODULE_LICENSE(L"GPLv3");
|
MODULE_LICENSE(L"GPLv3");
|
||||||
MODULE_VERSION(L"0.1");
|
MODULE_VERSION(L"0.1");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stub boot routine.
|
* Stub boot routine.
|
||||||
*
|
*
|
||||||
@@ -27,11 +28,50 @@ MODULE_VERSION(L"0.1");
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
DmBootSystem(IN PXTBL_BOOT_PARAMETERS Parameters)
|
Dummy::BootSystem(IN PXTBL_BOOT_PARAMETERS Parameters)
|
||||||
{
|
{
|
||||||
return STATUS_EFI_SUCCESS;
|
return STATUS_EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes DUMMY module by opening XTLDR protocol and installing DUMMY protocol.
|
||||||
|
*
|
||||||
|
* @param ImageHandle
|
||||||
|
* Firmware-allocated handle that identifies the image.
|
||||||
|
*
|
||||||
|
* @param SystemTable
|
||||||
|
* Provides the EFI system table.
|
||||||
|
*
|
||||||
|
* @return This routine returns status code.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
EFI_STATUS
|
||||||
|
Dummy::InitializeModule(IN EFI_HANDLE ImageHandle,
|
||||||
|
IN PEFI_SYSTEM_TABLE SystemTable)
|
||||||
|
{
|
||||||
|
EFI_GUID DummyGuid = XT_DUMMY_BOOT_PROTOCOL_GUID;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
/* Open the XTLDR protocol */
|
||||||
|
Status = BlGetXtLdrProtocol(SystemTable, ImageHandle, &XtLdrProtocol);
|
||||||
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
/* Failed to open the protocol, return error */
|
||||||
|
return STATUS_EFI_PROTOCOL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set boot protocol routines */
|
||||||
|
DummyProtocol.BootSystem = BootSystem;
|
||||||
|
|
||||||
|
/* Register XTOS boot protocol */
|
||||||
|
XtLdrProtocol->Boot.RegisterProtocol(L"DUMMYOS", &DummyGuid);
|
||||||
|
|
||||||
|
/* Register DUMMY protocol as XTOS boot protocol */
|
||||||
|
return XtLdrProtocol->Protocol.Install(&DummyProtocol, &DummyGuid);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This routine is the entry point of the XT EFI boot loader module.
|
* This routine is the entry point of the XT EFI boot loader module.
|
||||||
*
|
*
|
||||||
@@ -50,23 +90,6 @@ EFI_STATUS
|
|||||||
XtLdrModuleMain(IN EFI_HANDLE ImageHandle,
|
XtLdrModuleMain(IN EFI_HANDLE ImageHandle,
|
||||||
IN PEFI_SYSTEM_TABLE SystemTable)
|
IN PEFI_SYSTEM_TABLE SystemTable)
|
||||||
{
|
{
|
||||||
EFI_GUID DummyGuid = XT_DUMMY_BOOT_PROTOCOL_GUID;
|
/* Initialize DUMMY module */
|
||||||
EFI_STATUS Status;
|
return Dummy::InitializeModule(ImageHandle, SystemTable);
|
||||||
|
|
||||||
/* Open the XTLDR protocol */
|
|
||||||
Status = BlGetXtLdrProtocol(SystemTable, ImageHandle, &XtLdrProtocol);
|
|
||||||
if(Status != STATUS_EFI_SUCCESS)
|
|
||||||
{
|
|
||||||
/* Failed to open the protocol, return error */
|
|
||||||
return STATUS_EFI_PROTOCOL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set boot protocol routines */
|
|
||||||
BlpDummyProtocol.BootSystem = DmBootSystem;
|
|
||||||
|
|
||||||
/* Register XTOS boot protocol */
|
|
||||||
XtLdrProtocol->Boot.RegisterProtocol(L"DUMMYOS", &DummyGuid);
|
|
||||||
|
|
||||||
/* Register DUMMY protocol as XTOS boot protocol */
|
|
||||||
return XtLdrProtocol->Protocol.Install(&BlpDummyProtocol, &DummyGuid);
|
|
||||||
}
|
}
|
@@ -1,26 +0,0 @@
|
|||||||
/**
|
|
||||||
* PROJECT: ExectOS
|
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
|
||||||
* FILE: xtldr/modules/dummy/includes/dummy.h
|
|
||||||
* DESCRIPTION: XTLDR Dummy Module header file
|
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __XTLDR_DUMMY_DUMMY_H
|
|
||||||
#define __XTLDR_DUMMY_DUMMY_H
|
|
||||||
|
|
||||||
#include <xtblapi.h>
|
|
||||||
#include <globals.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Dummy module routines forward references */
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
DmBootSystem(IN PXTBL_BOOT_PARAMETERS Parameters);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
XtLdrModuleMain(IN EFI_HANDLE ImageHandle,
|
|
||||||
IN PEFI_SYSTEM_TABLE SystemTable);
|
|
||||||
|
|
||||||
#endif/* __XTLDR_DUMMY_DUMMY_H */
|
|
28
xtldr/modules/dummy/includes/dummy.hh
Normal file
28
xtldr/modules/dummy/includes/dummy.hh
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/**
|
||||||
|
* PROJECT: ExectOS
|
||||||
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
|
* FILE: xtldr/modules/dummy/includes/dummy.hh
|
||||||
|
* DESCRIPTION: XTLDR Dummy Module header file
|
||||||
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __XTLDR_DUMMY_DUMMY_HH
|
||||||
|
#define __XTLDR_DUMMY_DUMMY_HH
|
||||||
|
|
||||||
|
#include <xtblapi.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* DUMMY module for XTLDR */
|
||||||
|
class Dummy
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
STATIC XTBL_BOOT_PROTOCOL DummyProtocol;
|
||||||
|
STATIC PXTBL_LOADER_PROTOCOL XtLdrProtocol;
|
||||||
|
|
||||||
|
public:
|
||||||
|
STATIC EFI_STATUS BootSystem(IN PXTBL_BOOT_PARAMETERS Parameters);
|
||||||
|
STATIC EFI_STATUS InitializeModule(IN EFI_HANDLE ImageHandle,
|
||||||
|
IN PEFI_SYSTEM_TABLE SystemTable);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif/* __XTLDR_DUMMY_DUMMY_HH */
|
@@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* PROJECT: ExectOS
|
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
|
||||||
* FILE: xtldr/modules/dummy/includes/globals.h
|
|
||||||
* DESCRIPTION: XTLDR Dummy Module global variables
|
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __XTLDR_DUMMY_GLOBALS_H
|
|
||||||
#define __XTLDR_DUMMY_GLOBALS_H
|
|
||||||
|
|
||||||
#include <dummy.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* XTLDR protocol handler */
|
|
||||||
EXTERN PXTBL_LOADER_PROTOCOL XtLdrProtocol;
|
|
||||||
|
|
||||||
/* Dummy Boot Protocol handler */
|
|
||||||
EXTERN XTBL_BOOT_PROTOCOL BlpDummyProtocol;
|
|
||||||
|
|
||||||
#endif/* __XTLDR_DUMMY_GLOBALS_H */
|
|
@@ -8,8 +8,8 @@ include_directories(
|
|||||||
|
|
||||||
# Specify list of source code files
|
# Specify list of source code files
|
||||||
list(APPEND XTLDR_FRAMEBUF_SOURCE
|
list(APPEND XTLDR_FRAMEBUF_SOURCE
|
||||||
${XTLDR_FRAMEBUF_SOURCE_DIR}/framebuf.c
|
${XTLDR_FRAMEBUF_SOURCE_DIR}/framebuf.cc
|
||||||
${XTLDR_FRAMEBUF_SOURCE_DIR}/globals.c)
|
${XTLDR_FRAMEBUF_SOURCE_DIR}/data.cc)
|
||||||
|
|
||||||
# Link bootloader executable
|
# Link bootloader executable
|
||||||
add_executable(framebuf ${XTLDR_FRAMEBUF_SOURCE})
|
add_executable(framebuf ${XTLDR_FRAMEBUF_SOURCE})
|
||||||
|
19
xtldr/modules/framebuf/data.cc
Normal file
19
xtldr/modules/framebuf/data.cc
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/**
|
||||||
|
* PROJECT: ExectOS
|
||||||
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
|
* FILE: xtldr/modules/framebuf/data.cc
|
||||||
|
* DESCRIPTION: EFI framebuffer module global and static data
|
||||||
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <framebuf.hh>
|
||||||
|
|
||||||
|
|
||||||
|
/* Framebuffer display information */
|
||||||
|
XTBL_FRAMEBUFFER_INFORMATION FrameBuffer::DisplayInfo;
|
||||||
|
|
||||||
|
/* Framebuffer protocol handler */
|
||||||
|
XTBL_FRAMEBUFFER_PROTOCOL FrameBuffer::FbProtocol;
|
||||||
|
|
||||||
|
/* XTLDR protocol handler */
|
||||||
|
PXTBL_LOADER_PROTOCOL FrameBuffer::XtLdrProtocol;
|
File diff suppressed because it is too large
Load Diff
@@ -1,19 +0,0 @@
|
|||||||
/**
|
|
||||||
* PROJECT: ExectOS
|
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
|
||||||
* FILE: xtldr/modules/framebuf/globals.c
|
|
||||||
* DESCRIPTION: EFI framebuffer module global variables
|
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <framebuf.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Framebuffer display information */
|
|
||||||
XTBL_FRAMEBUFFER_INFORMATION FbpDisplayInfo;
|
|
||||||
|
|
||||||
/* Framebuffer protocol handler */
|
|
||||||
XTBL_FRAMEBUFFER_PROTOCOL FbpFrameBufferProtocol;
|
|
||||||
|
|
||||||
/* XTLDR protocol handler */
|
|
||||||
PXTBL_LOADER_PROTOCOL XtLdrProtocol;
|
|
@@ -1,64 +0,0 @@
|
|||||||
/**
|
|
||||||
* PROJECT: ExectOS
|
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
|
||||||
* FILE: xtldr/modules/framebuf/includes/framebuf.h
|
|
||||||
* DESCRIPTION: EFI Framebuffer support module header file
|
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __XTLDR_MODULES_FRAMEBUF_H
|
|
||||||
#define __XTLDR_MODULES_FRAMEBUF_H
|
|
||||||
|
|
||||||
#include <xtblapi.h>
|
|
||||||
#include <globals.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* FrameBuffer support protocol related routines forward references */
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
FbGetDisplayDriver(OUT PEFI_GRAPHICS_PROTOCOL Protocol);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
FbGetDisplayInformation(OUT PEFI_PHYSICAL_ADDRESS FrameBufferBase,
|
|
||||||
OUT PULONG_PTR FrameBufferSize,
|
|
||||||
OUT PXTBL_FRAMEBUFFER_MODE_INFORMATION ModeInfo);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
FbGetPreferredScreenResolution(OUT PUINT PreferredWidth,
|
|
||||||
OUT PUINT PreferredHeight);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
FbInitializeDisplay();
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
FbSetScreenResolution(IN UINT Width,
|
|
||||||
IN UINT Height);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
FbpFindFramebufferAddress(OUT PEFI_PHYSICAL_ADDRESS Address);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
VOID
|
|
||||||
FbpGetColorMask(IN UINT EfiMask,
|
|
||||||
OUT PUSHORT ColorSize,
|
|
||||||
OUT PUSHORT ColorShift);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
FbpGetModeInfo();
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
VOID
|
|
||||||
FbpGetPixelInformation(IN PEFI_PIXEL_BITMASK PixelsBitMask);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
XtLdrModuleMain(IN EFI_HANDLE ImageHandle,
|
|
||||||
IN PEFI_SYSTEM_TABLE SystemTable);
|
|
||||||
|
|
||||||
#endif /* __XTLDR_MODULES_FRAMEBUF_H */
|
|
44
xtldr/modules/framebuf/includes/framebuf.hh
Normal file
44
xtldr/modules/framebuf/includes/framebuf.hh
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/**
|
||||||
|
* PROJECT: ExectOS
|
||||||
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
|
* FILE: xtldr/modules/framebuf/includes/framebuf.hh
|
||||||
|
* DESCRIPTION: EFI Framebuffer support module header file
|
||||||
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __XTLDR_MODULES_FRAMEBUF_HH
|
||||||
|
#define __XTLDR_MODULES_FRAMEBUF_HH
|
||||||
|
|
||||||
|
#include <xtblapi.h>
|
||||||
|
|
||||||
|
|
||||||
|
class FrameBuffer
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
STATIC XTBL_FRAMEBUFFER_INFORMATION DisplayInfo;
|
||||||
|
STATIC XTBL_FRAMEBUFFER_PROTOCOL FbProtocol;
|
||||||
|
STATIC PXTBL_LOADER_PROTOCOL XtLdrProtocol;
|
||||||
|
|
||||||
|
public:
|
||||||
|
STATIC XTCDECL EFI_STATUS GetDisplayDriver(OUT PEFI_GRAPHICS_PROTOCOL Protocol);
|
||||||
|
STATIC XTCDECL EFI_STATUS GetDisplayInformation(OUT PEFI_PHYSICAL_ADDRESS FrameBufferBase,
|
||||||
|
OUT PULONG_PTR FrameBufferSize,
|
||||||
|
OUT PXTBL_FRAMEBUFFER_MODE_INFORMATION ModeInfo);
|
||||||
|
STATIC XTCDECL EFI_STATUS GetPreferredScreenResolution(OUT PUINT PreferredWidth,
|
||||||
|
OUT PUINT PreferredHeight);
|
||||||
|
STATIC XTCDECL EFI_STATUS InitializeDisplay();
|
||||||
|
STATIC XTCDECL EFI_STATUS InitializeModule(IN EFI_HANDLE ImageHandle,
|
||||||
|
IN PEFI_SYSTEM_TABLE SystemTable);
|
||||||
|
STATIC XTCDECL EFI_STATUS SetScreenResolution(IN UINT Width,
|
||||||
|
IN UINT Height);
|
||||||
|
|
||||||
|
private:
|
||||||
|
STATIC EFI_STATUS FindFramebufferAddress(OUT PEFI_PHYSICAL_ADDRESS Address);
|
||||||
|
STATIC XTCDECL VOID GetColorMask(IN UINT EfiMask,
|
||||||
|
OUT PUSHORT ColorSize,
|
||||||
|
OUT PUSHORT ColorShift);
|
||||||
|
STATIC XTCDECL EFI_STATUS GetModeInformation();
|
||||||
|
STATIC XTCDECL VOID GetPixelInformation(IN PEFI_PIXEL_BITMASK PixelsBitMask);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __XTLDR_MODULES_FRAMEBUF_HH */
|
@@ -1,24 +0,0 @@
|
|||||||
/**
|
|
||||||
* PROJECT: ExectOS
|
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
|
||||||
* FILE: xtldr/modules/framebuf/includes/globals.h
|
|
||||||
* DESCRIPTION: EFI Framebuffer module global variables
|
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __XTLDR_MODULES_GLOBALS_H
|
|
||||||
#define __XTLDR_MODULES_GLOBALS_H
|
|
||||||
|
|
||||||
#include <xtblapi.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Framebuffer display information */
|
|
||||||
EXTERN XTBL_FRAMEBUFFER_INFORMATION FbpDisplayInfo;
|
|
||||||
|
|
||||||
/* Framebuffer protocol handler */
|
|
||||||
EXTERN XTBL_FRAMEBUFFER_PROTOCOL FbpFrameBufferProtocol;
|
|
||||||
|
|
||||||
/* XTLDR protocol handler */
|
|
||||||
EXTERN PXTBL_LOADER_PROTOCOL XtLdrProtocol;
|
|
||||||
|
|
||||||
#endif /* __XTLDR_MODULES_GLOBALS_H */
|
|
@@ -8,8 +8,8 @@ include_directories(
|
|||||||
|
|
||||||
# Specify list of source code files
|
# Specify list of source code files
|
||||||
list(APPEND XTLDR_PECOFF_SOURCE
|
list(APPEND XTLDR_PECOFF_SOURCE
|
||||||
${XTLDR_PECOFF_SOURCE_DIR}/globals.c
|
${XTLDR_PECOFF_SOURCE_DIR}/data.cc
|
||||||
${XTLDR_PECOFF_SOURCE_DIR}/pecoff.c)
|
${XTLDR_PECOFF_SOURCE_DIR}/pecoff.cc)
|
||||||
|
|
||||||
# Link module executable
|
# Link module executable
|
||||||
add_executable(pecoff ${XTLDR_PECOFF_SOURCE})
|
add_executable(pecoff ${XTLDR_PECOFF_SOURCE})
|
||||||
|
16
xtldr/modules/pecoff/data.cc
Normal file
16
xtldr/modules/pecoff/data.cc
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/**
|
||||||
|
* PROJECT: ExectOS
|
||||||
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
|
* FILE: xtldr/modules/pecoff/globals.cc
|
||||||
|
* DESCRIPTION: Basic PE/COFF executable file format global and static data
|
||||||
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <pecoff.hh>
|
||||||
|
|
||||||
|
|
||||||
|
/* XTOS PE/COFF Image Protocol */
|
||||||
|
XTBL_EXECUTABLE_IMAGE_PROTOCOL PeCoff::PeProtocol;
|
||||||
|
|
||||||
|
/* EFI XT Loader Protocol */
|
||||||
|
PXTBL_LOADER_PROTOCOL PeCoff::XtLdrProtocol;
|
@@ -1,16 +0,0 @@
|
|||||||
/**
|
|
||||||
* PROJECT: ExectOS
|
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
|
||||||
* FILE: xtldr/modules/pecoff/globals.c
|
|
||||||
* DESCRIPTION: Basic PE/COFF executable file format support global variables
|
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <pecoff.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* XTOS PE/COFF Image Protocol */
|
|
||||||
XTBL_EXECUTABLE_IMAGE_PROTOCOL PeCoffProtocol;
|
|
||||||
|
|
||||||
/* EFI XT Loader Protocol */
|
|
||||||
PXTBL_LOADER_PROTOCOL XtLdrProtocol;
|
|
@@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* PROJECT: ExectOS
|
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
|
||||||
* FILE: xtldr/modules/pecoff/includes/globals.h
|
|
||||||
* DESCRIPTION: Basic PE/COFF executable file format support global variables
|
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __XTLDR_PECOFF_GLOBALS_H
|
|
||||||
#define __XTLDR_PECOFF_GLOBALS_H
|
|
||||||
|
|
||||||
#include <xtblapi.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* XTOS PE/COFF Image Protocol */
|
|
||||||
EXTERN XTBL_EXECUTABLE_IMAGE_PROTOCOL PeCoffProtocol;
|
|
||||||
|
|
||||||
/* EFI XT Loader Protocol */
|
|
||||||
EXTERN PXTBL_LOADER_PROTOCOL XtLdrProtocol;
|
|
||||||
|
|
||||||
#endif /* __XTLDR_PECOFF_GLOBALS_H */
|
|
@@ -1,82 +0,0 @@
|
|||||||
/**
|
|
||||||
* PROJECT: ExectOS
|
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
|
||||||
* FILE: xtldr/modules/pecoff/includes/pecoff.h
|
|
||||||
* DESCRIPTION: Basic PE/COFF executable file format support header
|
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __XTLDR_PECOFF_H
|
|
||||||
#define __XTLDR_PECOFF_H
|
|
||||||
|
|
||||||
#include <xtblapi.h>
|
|
||||||
#include <globals.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* PE/COFF image protocol related routines forward references */
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
PeGetEntryPoint(IN PVOID ImagePointer,
|
|
||||||
OUT PVOID *EntryPoint);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
PeGetFileSize(IN PVOID ImagePointer,
|
|
||||||
OUT PULONGLONG FileSize);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
PeGetImageSize(IN PVOID ImagePointer,
|
|
||||||
OUT PUINT ImageSize);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
PeGetMachineType(IN PVOID ImagePointer,
|
|
||||||
OUT PUSHORT MachineType);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
PeGetSection(IN PVOID ImagePointer,
|
|
||||||
IN PCHAR SectionName,
|
|
||||||
OUT PULONG *RawData);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
PeGetSubSystem(IN PVOID ImagePointer,
|
|
||||||
OUT PUSHORT SubSystem);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
PeGetVersion(IN PVOID ImagePointer,
|
|
||||||
OUT PUSHORT Version);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
PeLoadImage(IN PEFI_FILE_HANDLE FileHandle,
|
|
||||||
IN LOADER_MEMORY_TYPE MemoryType,
|
|
||||||
IN PVOID VirtualAddress,
|
|
||||||
OUT PVOID *ImagePointer);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
PeRelocateImage(IN PVOID ImagePointer,
|
|
||||||
IN EFI_VIRTUAL_ADDRESS Address);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
PeUnloadImage(IN PVOID ImagePointer);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
PeVerifyImage(IN PVOID ImagePointer);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
PepRelocateLoadedImage(IN PPECOFF_IMAGE_CONTEXT Image);
|
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
BlXtLdrModuleMain(IN EFI_HANDLE ImageHandle,
|
|
||||||
IN PEFI_SYSTEM_TABLE SystemTable);
|
|
||||||
|
|
||||||
#endif /* __XTLDR_PECOFF_H */
|
|
53
xtldr/modules/pecoff/includes/pecoff.hh
Normal file
53
xtldr/modules/pecoff/includes/pecoff.hh
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
* PROJECT: ExectOS
|
||||||
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
|
* FILE: xtldr/modules/pecoff/includes/pecoff.hh
|
||||||
|
* DESCRIPTION: Basic PE/COFF executable file format support header
|
||||||
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __XTLDR_PECOFF_HH
|
||||||
|
#define __XTLDR_PECOFF_HH
|
||||||
|
|
||||||
|
#include <xtblapi.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* PE/COFF module for XTLDR */
|
||||||
|
class PeCoff
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
STATIC XTBL_EXECUTABLE_IMAGE_PROTOCOL PeProtocol;
|
||||||
|
STATIC PXTBL_LOADER_PROTOCOL XtLdrProtocol;
|
||||||
|
|
||||||
|
public:
|
||||||
|
STATIC XTCDECL EFI_STATUS GetEntryPoint(IN PVOID ImagePointer,
|
||||||
|
OUT PVOID *EntryPoint);
|
||||||
|
STATIC XTCDECL EFI_STATUS GetFileSize(IN PVOID ImagePointer,
|
||||||
|
OUT PULONGLONG FileSize);
|
||||||
|
STATIC XTCDECL EFI_STATUS GetImageSize(IN PVOID ImagePointer,
|
||||||
|
OUT PUINT ImageSize);
|
||||||
|
STATIC XTCDECL EFI_STATUS GetMachineType(IN PVOID ImagePointer,
|
||||||
|
OUT PUSHORT MachineType);
|
||||||
|
STATIC XTCDECL EFI_STATUS GetSection(IN PVOID ImagePointer,
|
||||||
|
IN PCHAR SectionName,
|
||||||
|
OUT PULONG *RawData);
|
||||||
|
STATIC XTCDECL EFI_STATUS GetSubSystem(IN PVOID ImagePointer,
|
||||||
|
OUT PUSHORT SubSystem);
|
||||||
|
STATIC XTCDECL EFI_STATUS GetVersion(IN PVOID ImagePointer,
|
||||||
|
OUT PUSHORT Version);
|
||||||
|
STATIC XTCDECL EFI_STATUS InitializeModule(IN EFI_HANDLE ImageHandle,
|
||||||
|
IN PEFI_SYSTEM_TABLE SystemTable);
|
||||||
|
STATIC XTCDECL EFI_STATUS LoadImage(IN PEFI_FILE_HANDLE FileHandle,
|
||||||
|
IN LOADER_MEMORY_TYPE MemoryType,
|
||||||
|
IN PVOID VirtualAddress,
|
||||||
|
OUT PVOID *ImagePointer);
|
||||||
|
STATIC XTCDECL EFI_STATUS RelocateImage(IN PVOID ImagePointer,
|
||||||
|
IN EFI_VIRTUAL_ADDRESS Address);
|
||||||
|
STATIC XTCDECL EFI_STATUS UnloadImage(IN PVOID ImagePointer);
|
||||||
|
STATIC XTCDECL EFI_STATUS VerifyImage(IN PVOID ImagePointer);
|
||||||
|
|
||||||
|
private:
|
||||||
|
STATIC XTCDECL EFI_STATUS RelocateLoadedImage(IN PPECOFF_IMAGE_CONTEXT Image);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __XTLDR_PECOFF_HH */
|
@@ -1,12 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* PROJECT: ExectOS
|
* PROJECT: ExectOS
|
||||||
* COPYRIGHT: See COPYING.md in the top level directory
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
* FILE: xtldr/modules/pecoff/pecoff.c
|
* FILE: xtldr/modules/pecoff/pecoff.cc
|
||||||
* DESCRIPTION: Basic PE/COFF executable file format support module
|
* DESCRIPTION: Basic PE/COFF executable file format support module
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pecoff.h>
|
#include <pecoff.hh>
|
||||||
|
|
||||||
|
|
||||||
/* PE/COFF_O module information */
|
/* PE/COFF_O module information */
|
||||||
@@ -15,6 +15,7 @@ MODULE_DESCRIPTION(L"Basic PE/COFF executable file format support");
|
|||||||
MODULE_LICENSE(L"GPLv3");
|
MODULE_LICENSE(L"GPLv3");
|
||||||
MODULE_VERSION(L"0.1");
|
MODULE_VERSION(L"0.1");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the address of the entry point.
|
* Returns the address of the entry point.
|
||||||
*
|
*
|
||||||
@@ -30,10 +31,13 @@ MODULE_VERSION(L"0.1");
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
PeGetEntryPoint(IN PVOID ImagePointer,
|
PeCoff::GetEntryPoint(IN PVOID ImagePointer,
|
||||||
OUT PVOID *EntryPoint)
|
OUT PVOID *EntryPoint)
|
||||||
{
|
{
|
||||||
PPECOFF_IMAGE_CONTEXT Image = ImagePointer;
|
PPECOFF_IMAGE_CONTEXT Image;
|
||||||
|
|
||||||
|
/* Get PE/COFF image pointer*/
|
||||||
|
Image = (PPECOFF_IMAGE_CONTEXT)ImagePointer;
|
||||||
|
|
||||||
/* Validate input data */
|
/* Validate input data */
|
||||||
if(!Image || !Image->PeHeader)
|
if(!Image || !Image->PeHeader)
|
||||||
@@ -46,12 +50,12 @@ PeGetEntryPoint(IN PVOID ImagePointer,
|
|||||||
if(Image->PeHeader->OptionalHeader32.Magic == PECOFF_IMAGE_PE_OPTIONAL_HDR64_MAGIC)
|
if(Image->PeHeader->OptionalHeader32.Magic == PECOFF_IMAGE_PE_OPTIONAL_HDR64_MAGIC)
|
||||||
{
|
{
|
||||||
/* Get entry point from 64-bit optional header */
|
/* Get entry point from 64-bit optional header */
|
||||||
*EntryPoint = (PUINT8)Image->VirtualAddress + Image->PeHeader->OptionalHeader64.AddressOfEntryPoint;
|
*EntryPoint = (PUCHAR)Image->VirtualAddress + Image->PeHeader->OptionalHeader64.AddressOfEntryPoint;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Get entry point from 32-bit optional header */
|
/* Get entry point from 32-bit optional header */
|
||||||
*EntryPoint = (PUINT8)Image->VirtualAddress + Image->PeHeader->OptionalHeader32.AddressOfEntryPoint;
|
*EntryPoint = (PUCHAR)Image->VirtualAddress + Image->PeHeader->OptionalHeader32.AddressOfEntryPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return success */
|
/* Return success */
|
||||||
@@ -73,13 +77,13 @@ PeGetEntryPoint(IN PVOID ImagePointer,
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
PeGetFileSize(IN PVOID ImagePointer,
|
PeCoff::GetFileSize(IN PVOID ImagePointer,
|
||||||
OUT PULONGLONG FileSize)
|
OUT PULONGLONG FileSize)
|
||||||
{
|
{
|
||||||
PPECOFF_IMAGE_CONTEXT Image;
|
PPECOFF_IMAGE_CONTEXT Image;
|
||||||
|
|
||||||
/* Get PE/COFF image pointer*/
|
/* Get PE/COFF image pointer*/
|
||||||
Image = ImagePointer;
|
Image = (PPECOFF_IMAGE_CONTEXT)ImagePointer;
|
||||||
|
|
||||||
/* Validate input data */
|
/* Validate input data */
|
||||||
if(!Image || !Image->ImageSize)
|
if(!Image || !Image->ImageSize)
|
||||||
@@ -108,13 +112,13 @@ PeGetFileSize(IN PVOID ImagePointer,
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
PeGetImageSize(IN PVOID ImagePointer,
|
PeCoff::GetImageSize(IN PVOID ImagePointer,
|
||||||
OUT PUINT ImageSize)
|
OUT PUINT ImageSize)
|
||||||
{
|
{
|
||||||
PPECOFF_IMAGE_CONTEXT Image;
|
PPECOFF_IMAGE_CONTEXT Image;
|
||||||
|
|
||||||
/* Get PE/COFF image pointer*/
|
/* Get PE/COFF image pointer*/
|
||||||
Image = ImagePointer;
|
Image = (PPECOFF_IMAGE_CONTEXT)ImagePointer;
|
||||||
|
|
||||||
/* Validate input data */
|
/* Validate input data */
|
||||||
if(!Image || !Image->ImageSize)
|
if(!Image || !Image->ImageSize)
|
||||||
@@ -143,10 +147,13 @@ PeGetImageSize(IN PVOID ImagePointer,
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
PeGetMachineType(IN PVOID ImagePointer,
|
PeCoff::GetMachineType(IN PVOID ImagePointer,
|
||||||
OUT PUSHORT MachineType)
|
OUT PUSHORT MachineType)
|
||||||
{
|
{
|
||||||
PPECOFF_IMAGE_CONTEXT Image = ImagePointer;
|
PPECOFF_IMAGE_CONTEXT Image;
|
||||||
|
|
||||||
|
/* Get PE/COFF image pointer*/
|
||||||
|
Image = (PPECOFF_IMAGE_CONTEXT)ImagePointer;
|
||||||
|
|
||||||
/* Validate input data */
|
/* Validate input data */
|
||||||
if(!Image || !Image->PeHeader)
|
if(!Image || !Image->PeHeader)
|
||||||
@@ -178,7 +185,7 @@ PeGetMachineType(IN PVOID ImagePointer,
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
PeGetSection(IN PVOID ImagePointer,
|
PeCoff::GetSection(IN PVOID ImagePointer,
|
||||||
IN PCHAR SectionName,
|
IN PCHAR SectionName,
|
||||||
OUT PULONG *RawData)
|
OUT PULONG *RawData)
|
||||||
{
|
{
|
||||||
@@ -188,7 +195,7 @@ PeGetSection(IN PVOID ImagePointer,
|
|||||||
USHORT SectionIndex;
|
USHORT SectionIndex;
|
||||||
|
|
||||||
/* Get PE/COFF image pointer*/
|
/* Get PE/COFF image pointer*/
|
||||||
Image = ImagePointer;
|
Image = (PPECOFF_IMAGE_CONTEXT)ImagePointer;
|
||||||
|
|
||||||
/* Validate input data */
|
/* Validate input data */
|
||||||
if(!Image || !Image->PeHeader)
|
if(!Image || !Image->PeHeader)
|
||||||
@@ -221,7 +228,7 @@ PeGetSection(IN PVOID ImagePointer,
|
|||||||
if(RtlCompareString((PCHAR)SectionHeader[SectionIndex].Name, SectionName, SectionNameLength) == 0)
|
if(RtlCompareString((PCHAR)SectionHeader[SectionIndex].Name, SectionName, SectionNameLength) == 0)
|
||||||
{
|
{
|
||||||
/* Store section address and return */
|
/* Store section address and return */
|
||||||
*RawData = Image->Data + SectionHeader[SectionIndex].PointerToRawData;
|
*RawData = (PULONG)((PUCHAR)Image->Data + SectionHeader[SectionIndex].PointerToRawData);
|
||||||
return STATUS_EFI_SUCCESS;
|
return STATUS_EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -245,10 +252,13 @@ PeGetSection(IN PVOID ImagePointer,
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
PeGetSubSystem(IN PVOID ImagePointer,
|
PeCoff::GetSubSystem(IN PVOID ImagePointer,
|
||||||
OUT PUSHORT SubSystem)
|
OUT PUSHORT SubSystem)
|
||||||
{
|
{
|
||||||
PPECOFF_IMAGE_CONTEXT Image = ImagePointer;
|
PPECOFF_IMAGE_CONTEXT Image;
|
||||||
|
|
||||||
|
/* Get PE/COFF image pointer*/
|
||||||
|
Image = (PPECOFF_IMAGE_CONTEXT)ImagePointer;
|
||||||
|
|
||||||
/* Validate input data */
|
/* Validate input data */
|
||||||
if(!Image || !Image->PeHeader)
|
if(!Image || !Image->PeHeader)
|
||||||
@@ -288,10 +298,13 @@ PeGetSubSystem(IN PVOID ImagePointer,
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
PeGetVersion(IN PVOID ImagePointer,
|
PeCoff::GetVersion(IN PVOID ImagePointer,
|
||||||
OUT PUSHORT Version)
|
OUT PUSHORT Version)
|
||||||
{
|
{
|
||||||
PPECOFF_IMAGE_CONTEXT Image = ImagePointer;
|
PPECOFF_IMAGE_CONTEXT Image;
|
||||||
|
|
||||||
|
/* Get PE/COFF image pointer*/
|
||||||
|
Image = (PPECOFF_IMAGE_CONTEXT)ImagePointer;
|
||||||
|
|
||||||
/* Validate input data */
|
/* Validate input data */
|
||||||
if(!Image || !Image->PeHeader)
|
if(!Image || !Image->PeHeader)
|
||||||
@@ -316,6 +329,52 @@ PeGetVersion(IN PVOID ImagePointer,
|
|||||||
return STATUS_EFI_SUCCESS;
|
return STATUS_EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes PECOFF module by opening XTLDR protocol and installing PECOFF protocol.
|
||||||
|
*
|
||||||
|
* @param ImageHandle
|
||||||
|
* Firmware-allocated handle that identifies the image.
|
||||||
|
*
|
||||||
|
* @param SystemTable
|
||||||
|
* Provides the EFI system table.
|
||||||
|
*
|
||||||
|
* @return This routine returns status code.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
EFI_STATUS
|
||||||
|
PeCoff::InitializeModule(IN EFI_HANDLE ImageHandle,
|
||||||
|
IN PEFI_SYSTEM_TABLE SystemTable)
|
||||||
|
{
|
||||||
|
EFI_GUID Guid = XT_PECOFF_IMAGE_PROTOCOL_GUID;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
/* Open the XTLDR protocol */
|
||||||
|
Status = BlGetXtLdrProtocol(SystemTable, ImageHandle, &XtLdrProtocol);
|
||||||
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
/* Failed to open loader protocol */
|
||||||
|
return STATUS_EFI_PROTOCOL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set routines available via PE/COFF image protocol */
|
||||||
|
PeProtocol.GetEntryPoint = GetEntryPoint;
|
||||||
|
PeProtocol.GetFileSize = GetFileSize;
|
||||||
|
PeProtocol.GetImageSize = GetImageSize;
|
||||||
|
PeProtocol.GetMachineType = GetMachineType;
|
||||||
|
PeProtocol.GetSection = GetSection;
|
||||||
|
PeProtocol.GetSubSystem = GetSubSystem;
|
||||||
|
PeProtocol.GetVersion = GetVersion;
|
||||||
|
PeProtocol.LoadImage = LoadImage;
|
||||||
|
PeProtocol.RelocateImage = RelocateImage;
|
||||||
|
PeProtocol.UnloadImage = UnloadImage;
|
||||||
|
PeProtocol.VerifyImage = VerifyImage;
|
||||||
|
|
||||||
|
/* Register PE/COFF protocol */
|
||||||
|
return XtLdrProtocol->Protocol.Install(&PeProtocol, &Guid);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a PE/COFF image file.
|
* Loads a PE/COFF image file.
|
||||||
*
|
*
|
||||||
@@ -337,7 +396,7 @@ PeGetVersion(IN PVOID ImagePointer,
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
PeLoadImage(IN PEFI_FILE_HANDLE FileHandle,
|
PeCoff::LoadImage(IN PEFI_FILE_HANDLE FileHandle,
|
||||||
IN LOADER_MEMORY_TYPE MemoryType,
|
IN LOADER_MEMORY_TYPE MemoryType,
|
||||||
IN PVOID VirtualAddress,
|
IN PVOID VirtualAddress,
|
||||||
OUT PVOID *ImagePointer)
|
OUT PVOID *ImagePointer)
|
||||||
@@ -433,10 +492,10 @@ PeLoadImage(IN PEFI_FILE_HANDLE FileHandle,
|
|||||||
|
|
||||||
/* Extract DOS and PE headers */
|
/* Extract DOS and PE headers */
|
||||||
ImageData->DosHeader = (PPECOFF_IMAGE_DOS_HEADER)Data;
|
ImageData->DosHeader = (PPECOFF_IMAGE_DOS_HEADER)Data;
|
||||||
ImageData->PeHeader = (PPECOFF_IMAGE_PE_HEADER)((PUINT8)Data + ImageData->DosHeader->PeHeaderOffset);
|
ImageData->PeHeader = (PPECOFF_IMAGE_PE_HEADER)((PUCHAR)Data + ImageData->DosHeader->PeHeaderOffset);
|
||||||
|
|
||||||
/* Validate headers */
|
/* Validate headers */
|
||||||
Status = PeVerifyImage(ImageData);
|
Status = PeCoff::VerifyImage(ImageData);
|
||||||
if(Status != STATUS_EFI_SUCCESS)
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
{
|
{
|
||||||
/* Header validation failed, probably broken or invalid PE/COFF image */
|
/* Header validation failed, probably broken or invalid PE/COFF image */
|
||||||
@@ -482,7 +541,7 @@ PeLoadImage(IN PEFI_FILE_HANDLE FileHandle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Store image data and virtual address */
|
/* Store image data and virtual address */
|
||||||
ImageData->Data = (PUINT8)(UINT_PTR)Address;
|
ImageData->Data = (PUCHAR)(UINT_PTR)Address;
|
||||||
ImageData->PhysicalAddress = (PVOID)(UINT_PTR)Address;
|
ImageData->PhysicalAddress = (PVOID)(UINT_PTR)Address;
|
||||||
if(VirtualAddress)
|
if(VirtualAddress)
|
||||||
{
|
{
|
||||||
@@ -534,7 +593,7 @@ PeLoadImage(IN PEFI_FILE_HANDLE FileHandle,
|
|||||||
if(SectionSize > 0 && SectionHeader[Index].PointerToRawData != 0)
|
if(SectionSize > 0 && SectionHeader[Index].PointerToRawData != 0)
|
||||||
{
|
{
|
||||||
/* Copy section */
|
/* Copy section */
|
||||||
XtLdrProtocol->Memory.CopyMemory((PUINT8)ImageData->Data + SectionHeader[Index].VirtualAddress,
|
XtLdrProtocol->Memory.CopyMemory((PUCHAR)ImageData->Data + SectionHeader[Index].VirtualAddress,
|
||||||
Data + SectionHeader[Index].PointerToRawData, SectionSize);
|
Data + SectionHeader[Index].PointerToRawData, SectionSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -542,7 +601,7 @@ PeLoadImage(IN PEFI_FILE_HANDLE FileHandle,
|
|||||||
if(SectionSize < SectionHeader[Index].Misc.VirtualSize)
|
if(SectionSize < SectionHeader[Index].Misc.VirtualSize)
|
||||||
{
|
{
|
||||||
/* Fill remaining space with zeroes */
|
/* Fill remaining space with zeroes */
|
||||||
XtLdrProtocol->Memory.ZeroMemory((PUINT8)ImageData->Data + SectionHeader[Index].VirtualAddress + SectionSize,
|
XtLdrProtocol->Memory.ZeroMemory((PUCHAR)ImageData->Data + SectionHeader[Index].VirtualAddress + SectionSize,
|
||||||
SectionHeader[Index].Misc.VirtualSize - SectionSize);
|
SectionHeader[Index].Misc.VirtualSize - SectionSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -551,7 +610,7 @@ PeLoadImage(IN PEFI_FILE_HANDLE FileHandle,
|
|||||||
XtLdrProtocol->Memory.FreePages((EFI_PHYSICAL_ADDRESS)(UINT_PTR)Data, Pages);
|
XtLdrProtocol->Memory.FreePages((EFI_PHYSICAL_ADDRESS)(UINT_PTR)Data, Pages);
|
||||||
|
|
||||||
/* Perform relocation fixups */
|
/* Perform relocation fixups */
|
||||||
Status = PepRelocateLoadedImage(ImageData);
|
Status = PeCoff::RelocateLoadedImage(ImageData);
|
||||||
if(Status != STATUS_EFI_SUCCESS)
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
{
|
{
|
||||||
/* Failed to relocate image */
|
/* Failed to relocate image */
|
||||||
@@ -581,14 +640,16 @@ PeLoadImage(IN PEFI_FILE_HANDLE FileHandle,
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
PeRelocateImage(IN PVOID ImagePointer,
|
PeCoff::RelocateImage(IN PVOID ImagePointer,
|
||||||
IN EFI_VIRTUAL_ADDRESS Address)
|
IN EFI_VIRTUAL_ADDRESS Address)
|
||||||
{
|
{
|
||||||
PPECOFF_IMAGE_CONTEXT Image = ImagePointer;
|
PPECOFF_IMAGE_CONTEXT Image;
|
||||||
|
ULONGLONG ImageBase, OldVirtualAddress;
|
||||||
UINT64 ImageBase, OldVirtualAddress;
|
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
/* Get PE/COFF image pointer*/
|
||||||
|
Image = (PPECOFF_IMAGE_CONTEXT)ImagePointer;
|
||||||
|
|
||||||
/* Store original virtual address */
|
/* Store original virtual address */
|
||||||
OldVirtualAddress = (UINT_PTR)Image->VirtualAddress;
|
OldVirtualAddress = (UINT_PTR)Image->VirtualAddress;
|
||||||
|
|
||||||
@@ -606,7 +667,7 @@ PeRelocateImage(IN PVOID ImagePointer,
|
|||||||
|
|
||||||
/* Overwrite virtual address and relocate image once again */
|
/* Overwrite virtual address and relocate image once again */
|
||||||
Image->VirtualAddress = (PVOID)(Address - OldVirtualAddress + ImageBase);
|
Image->VirtualAddress = (PVOID)(Address - OldVirtualAddress + ImageBase);
|
||||||
Status = PepRelocateLoadedImage(Image);
|
Status = PeCoff::RelocateLoadedImage(Image);
|
||||||
if(Status != STATUS_EFI_SUCCESS)
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
{
|
{
|
||||||
/* Relocation failed */
|
/* Relocation failed */
|
||||||
@@ -620,98 +681,6 @@ PeRelocateImage(IN PVOID ImagePointer,
|
|||||||
return STATUS_EFI_SUCCESS;
|
return STATUS_EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Unloads a PE/COFF image file and frees allocated memory.
|
|
||||||
*
|
|
||||||
* @param ImagePointer
|
|
||||||
* Supplies a pointer to the PE/COFF context structure representing the loaded image.
|
|
||||||
*
|
|
||||||
* @return This routine returns a status code.
|
|
||||||
*
|
|
||||||
* @since XT 1.0
|
|
||||||
*/
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
PeUnloadImage(IN PVOID ImagePointer)
|
|
||||||
{
|
|
||||||
PPECOFF_IMAGE_CONTEXT Image;
|
|
||||||
EFI_STATUS Status;
|
|
||||||
|
|
||||||
/* Get PE/COFF image pointer*/
|
|
||||||
Image = ImagePointer;
|
|
||||||
|
|
||||||
/* Validate input data */
|
|
||||||
if(!Image || !Image->Data)
|
|
||||||
{
|
|
||||||
/* Invalid parameter passed */
|
|
||||||
return STATUS_EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free memory allocated for the image */
|
|
||||||
Status = XtLdrProtocol->Memory.FreePages(Image->ImagePages, (EFI_PHYSICAL_ADDRESS)(UINT_PTR)Image->Data);
|
|
||||||
Status |= XtLdrProtocol->Memory.FreePool(Image);
|
|
||||||
|
|
||||||
/* Return status */
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates a PE/COFF image headers.
|
|
||||||
*
|
|
||||||
* @param ImagePointer
|
|
||||||
* Supplies a pointer to the PE/COFF context structure representing the loaded image.
|
|
||||||
*
|
|
||||||
* @return This routine returns a status code.
|
|
||||||
*
|
|
||||||
* @since XT 1.0
|
|
||||||
*/
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
PeVerifyImage(IN PVOID ImagePointer)
|
|
||||||
{
|
|
||||||
PPECOFF_IMAGE_CONTEXT Image = ImagePointer;
|
|
||||||
|
|
||||||
/* Validate input data */
|
|
||||||
if(!Image || !Image->PeHeader)
|
|
||||||
{
|
|
||||||
/* Invalid parameter passed */
|
|
||||||
return STATUS_EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Validate file size */
|
|
||||||
if(Image->FileSize < sizeof(PECOFF_IMAGE_DOS_HEADER))
|
|
||||||
{
|
|
||||||
/* PE/COFF image shorter than DOS header, return error*/
|
|
||||||
return STATUS_EFI_END_OF_FILE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Validate DOS header */
|
|
||||||
if(Image->DosHeader->Magic != PECOFF_IMAGE_DOS_SIGNATURE)
|
|
||||||
{
|
|
||||||
/* Invalid DOS signature, return error */
|
|
||||||
return STATUS_EFI_INCOMPATIBLE_VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Validate PE header */
|
|
||||||
if(Image->PeHeader->Signature != PECOFF_IMAGE_NT_SIGNATURE &&
|
|
||||||
Image->PeHeader->Signature != PECOFF_IMAGE_XT_SIGNATURE)
|
|
||||||
{
|
|
||||||
/* Invalid PE signature, return error */
|
|
||||||
return STATUS_EFI_INCOMPATIBLE_VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Validate optional header */
|
|
||||||
if(Image->PeHeader->OptionalHeader32.Magic != PECOFF_IMAGE_PE_OPTIONAL_HDR32_MAGIC &&
|
|
||||||
Image->PeHeader->OptionalHeader64.Magic != PECOFF_IMAGE_PE_OPTIONAL_HDR64_MAGIC)
|
|
||||||
{
|
|
||||||
/* Invalid optional header signature, return error */
|
|
||||||
return STATUS_EFI_INCOMPATIBLE_VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return success */
|
|
||||||
return STATUS_EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Relocates a loaded PE/COFF image.
|
* Relocates a loaded PE/COFF image.
|
||||||
*
|
*
|
||||||
@@ -724,15 +693,15 @@ PeVerifyImage(IN PVOID ImagePointer)
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
PepRelocateLoadedImage(IN PPECOFF_IMAGE_CONTEXT Image)
|
PeCoff::RelocateLoadedImage(IN PPECOFF_IMAGE_CONTEXT Image)
|
||||||
{
|
{
|
||||||
PPECOFF_IMAGE_BASE_RELOCATION RelocationDir, RelocationEnd;
|
PPECOFF_IMAGE_BASE_RELOCATION RelocationDir, RelocationEnd;
|
||||||
PPECOFF_IMAGE_DATA_DIRECTORY DataDirectory;
|
PPECOFF_IMAGE_DATA_DIRECTORY DataDirectory;
|
||||||
USHORT Offset, Type, Count;
|
USHORT Offset, Type, Count;
|
||||||
PUSHORT TypeOffset;
|
PUSHORT TypeOffset;
|
||||||
UINT64 ImageBase;
|
ULONGLONG ImageBase;
|
||||||
PUINT32 Address;
|
PUINT Address;
|
||||||
PUINT64 LongPtr;
|
PULONGLONG LongPtr;
|
||||||
PUINT ShortPtr;
|
PUINT ShortPtr;
|
||||||
|
|
||||||
/* Make sure image is not stripped */
|
/* Make sure image is not stripped */
|
||||||
@@ -793,7 +762,7 @@ PepRelocateLoadedImage(IN PPECOFF_IMAGE_CONTEXT Image)
|
|||||||
Type = *TypeOffset >> 12;
|
Type = *TypeOffset >> 12;
|
||||||
|
|
||||||
/* Check if end of the loaded address reached */
|
/* Check if end of the loaded address reached */
|
||||||
if((PVOID)(PUSHORT)(Address + Offset) >= Image->Data + Image->ImageSize)
|
if((PVOID)(PUSHORT)(Address + Offset) >= (PUCHAR)Image->Data + Image->ImageSize)
|
||||||
{
|
{
|
||||||
/* Do not relocate after the end of loaded image */
|
/* Do not relocate after the end of loaded image */
|
||||||
break;
|
break;
|
||||||
@@ -816,7 +785,7 @@ PepRelocateLoadedImage(IN PPECOFF_IMAGE_CONTEXT Image)
|
|||||||
break;
|
break;
|
||||||
case PECOFF_IMAGE_REL_BASED_HIGHLOW:
|
case PECOFF_IMAGE_REL_BASED_HIGHLOW:
|
||||||
/* 32-bit relocation of hight and low half of address */
|
/* 32-bit relocation of hight and low half of address */
|
||||||
ShortPtr = (PUINT32)((PUCHAR)Address + Offset);
|
ShortPtr = (PUINT)((PUCHAR)Address + Offset);
|
||||||
*ShortPtr = *ShortPtr - ImageBase + (UINT_PTR)Image->VirtualAddress;
|
*ShortPtr = *ShortPtr - ImageBase + (UINT_PTR)Image->VirtualAddress;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -836,6 +805,101 @@ PepRelocateLoadedImage(IN PPECOFF_IMAGE_CONTEXT Image)
|
|||||||
return STATUS_EFI_SUCCESS;
|
return STATUS_EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unloads a PE/COFF image file and frees allocated memory.
|
||||||
|
*
|
||||||
|
* @param ImagePointer
|
||||||
|
* Supplies a pointer to the PE/COFF context structure representing the loaded image.
|
||||||
|
*
|
||||||
|
* @return This routine returns a status code.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
EFI_STATUS
|
||||||
|
PeCoff::UnloadImage(IN PVOID ImagePointer)
|
||||||
|
{
|
||||||
|
PPECOFF_IMAGE_CONTEXT Image;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
/* Get PE/COFF image pointer*/
|
||||||
|
Image = (PPECOFF_IMAGE_CONTEXT)ImagePointer;
|
||||||
|
|
||||||
|
/* Validate input data */
|
||||||
|
if(!Image || !Image->Data)
|
||||||
|
{
|
||||||
|
/* Invalid parameter passed */
|
||||||
|
return STATUS_EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free memory allocated for the image */
|
||||||
|
Status = XtLdrProtocol->Memory.FreePages(Image->ImagePages, (EFI_PHYSICAL_ADDRESS)(UINT_PTR)Image->Data);
|
||||||
|
Status |= XtLdrProtocol->Memory.FreePool(Image);
|
||||||
|
|
||||||
|
/* Return status */
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates a PE/COFF image headers.
|
||||||
|
*
|
||||||
|
* @param ImagePointer
|
||||||
|
* Supplies a pointer to the PE/COFF context structure representing the loaded image.
|
||||||
|
*
|
||||||
|
* @return This routine returns a status code.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
EFI_STATUS
|
||||||
|
PeCoff::VerifyImage(IN PVOID ImagePointer)
|
||||||
|
{
|
||||||
|
PPECOFF_IMAGE_CONTEXT Image;
|
||||||
|
|
||||||
|
/* Get PE/COFF image pointer*/
|
||||||
|
Image = (PPECOFF_IMAGE_CONTEXT)ImagePointer;
|
||||||
|
|
||||||
|
/* Validate input data */
|
||||||
|
if(!Image || !Image->PeHeader)
|
||||||
|
{
|
||||||
|
/* Invalid parameter passed */
|
||||||
|
return STATUS_EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Validate file size */
|
||||||
|
if(Image->FileSize < sizeof(PECOFF_IMAGE_DOS_HEADER))
|
||||||
|
{
|
||||||
|
/* PE/COFF image shorter than DOS header, return error*/
|
||||||
|
return STATUS_EFI_END_OF_FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Validate DOS header */
|
||||||
|
if(Image->DosHeader->Magic != PECOFF_IMAGE_DOS_SIGNATURE)
|
||||||
|
{
|
||||||
|
/* Invalid DOS signature, return error */
|
||||||
|
return STATUS_EFI_INCOMPATIBLE_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Validate PE header */
|
||||||
|
if(Image->PeHeader->Signature != PECOFF_IMAGE_NT_SIGNATURE &&
|
||||||
|
Image->PeHeader->Signature != PECOFF_IMAGE_XT_SIGNATURE)
|
||||||
|
{
|
||||||
|
/* Invalid PE signature, return error */
|
||||||
|
return STATUS_EFI_INCOMPATIBLE_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Validate optional header */
|
||||||
|
if(Image->PeHeader->OptionalHeader32.Magic != PECOFF_IMAGE_PE_OPTIONAL_HDR32_MAGIC &&
|
||||||
|
Image->PeHeader->OptionalHeader64.Magic != PECOFF_IMAGE_PE_OPTIONAL_HDR64_MAGIC)
|
||||||
|
{
|
||||||
|
/* Invalid optional header signature, return error */
|
||||||
|
return STATUS_EFI_INCOMPATIBLE_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return success */
|
||||||
|
return STATUS_EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This routine is the entry point of the XT EFI boot loader module.
|
* This routine is the entry point of the XT EFI boot loader module.
|
||||||
*
|
*
|
||||||
@@ -854,30 +918,6 @@ EFI_STATUS
|
|||||||
XtLdrModuleMain(IN EFI_HANDLE ImageHandle,
|
XtLdrModuleMain(IN EFI_HANDLE ImageHandle,
|
||||||
IN PEFI_SYSTEM_TABLE SystemTable)
|
IN PEFI_SYSTEM_TABLE SystemTable)
|
||||||
{
|
{
|
||||||
EFI_GUID Guid = XT_PECOFF_IMAGE_PROTOCOL_GUID;
|
/* Initialize PECOFF module */
|
||||||
EFI_STATUS Status;
|
return PeCoff::InitializeModule(ImageHandle, SystemTable);
|
||||||
|
|
||||||
/* Open the XTLDR protocol */
|
|
||||||
Status = BlGetXtLdrProtocol(SystemTable, ImageHandle, &XtLdrProtocol);
|
|
||||||
if(Status != STATUS_EFI_SUCCESS)
|
|
||||||
{
|
|
||||||
/* Failed to open loader protocol */
|
|
||||||
return STATUS_EFI_PROTOCOL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set routines available via PE/COFF image protocol */
|
|
||||||
PeCoffProtocol.GetEntryPoint = PeGetEntryPoint;
|
|
||||||
PeCoffProtocol.GetFileSize = PeGetFileSize;
|
|
||||||
PeCoffProtocol.GetImageSize = PeGetImageSize;
|
|
||||||
PeCoffProtocol.GetMachineType = PeGetMachineType;
|
|
||||||
PeCoffProtocol.GetSection = PeGetSection;
|
|
||||||
PeCoffProtocol.GetSubSystem = PeGetSubSystem;
|
|
||||||
PeCoffProtocol.GetVersion = PeGetVersion;
|
|
||||||
PeCoffProtocol.LoadImage = PeLoadImage;
|
|
||||||
PeCoffProtocol.RelocateImage = PeRelocateImage;
|
|
||||||
PeCoffProtocol.UnloadImage = PeUnloadImage;
|
|
||||||
PeCoffProtocol.VerifyImage = PeVerifyImage;
|
|
||||||
|
|
||||||
/* Register PE/COFF protocol */
|
|
||||||
return XtLdrProtocol->Protocol.Install(&PeCoffProtocol, &Guid);
|
|
||||||
}
|
}
|
@@ -6,7 +6,7 @@
|
|||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xtldr.h>
|
#include <xtldr.hh>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xtldr.h>
|
#include <xtldr.hh>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
* Aiken Harris <harraiken91@gmail.com>
|
* Aiken Harris <harraiken91@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xtldr.h>
|
#include <xtldr.hh>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
* Aiken Harris <harraiken91@gmail.com>
|
* Aiken Harris <harraiken91@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xtldr.h>
|
#include <xtldr.hh>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xtldr.h>
|
#include <xtldr.hh>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user