C to C++ migration and refactoring #17
@@ -362,6 +362,13 @@ Configuration::InitializeBootMenuList(IN ULONG MaxNameLength,
|
|||||||
return STATUS_EFI_SUCCESS;
|
return STATUS_EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the XTLDR configuration subsystem.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
VOID
|
VOID
|
||||||
Configuration::InitializeConfiguration()
|
Configuration::InitializeConfiguration()
|
||||||
|
@@ -387,9 +387,16 @@ Debug::PutChar(IN WCHAR Character)
|
|||||||
return HL::ComPort::WriteComPort(&SerialPort, Buffer[0]);
|
return HL::ComPort::WriteComPort(&SerialPort, Buffer[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if the serial port has been successfully initialized and is ready for communication.
|
||||||
|
*
|
||||||
|
* @return This routine returns TRUE if the serial port is initialized and ready, FALSE otherwise.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
Debug::SerialPortReady()
|
Debug::SerialPortReady()
|
||||||
{
|
{
|
||||||
return (BOOLEAN)(SerialPort.Flags & COMPORT_FLAG_INIT);
|
return (BOOLEAN)(SerialPort.Flags & COMPORT_FLAG_INIT);
|
||||||
belliash marked this conversation as resolved
Outdated
|
|||||||
}
|
}
|
||||||
|
@@ -9,6 +9,13 @@
|
|||||||
#include <xtldr.hh>
|
#include <xtldr.hh>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables access to EFI Boot Services.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
VOID
|
VOID
|
||||||
XtLoader::DisableBootServices()
|
XtLoader::DisableBootServices()
|
||||||
@@ -17,6 +24,13 @@ XtLoader::DisableBootServices()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Queries the availability of EFI Boot Services.
|
||||||
|
*
|
||||||
|
* @return This routine returns TRUE if EFI Boot Services are available, FALSE otherwise.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
XtLoader::GetBootServicesStatus()
|
XtLoader::GetBootServicesStatus()
|
||||||
@@ -24,6 +38,13 @@ XtLoader::GetBootServicesStatus()
|
|||||||
return LoaderStatus.BootServices;
|
return LoaderStatus.BootServices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the EFI image handle.
|
||||||
|
*
|
||||||
|
* @return This routine returns a handle to the EFI-loaded image.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_HANDLE
|
EFI_HANDLE
|
||||||
XtLoader::GetEfiImageHandle()
|
XtLoader::GetEfiImageHandle()
|
||||||
@@ -31,6 +52,13 @@ XtLoader::GetEfiImageHandle()
|
|||||||
return XtLoader::EfiImageHandle;
|
return XtLoader::EfiImageHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the EFI system table pointer.
|
||||||
|
*
|
||||||
|
* @return This routine returns a pointer to the EFI system table.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
PEFI_SYSTEM_TABLE
|
PEFI_SYSTEM_TABLE
|
||||||
XtLoader::GetEfiSystemTable()
|
XtLoader::GetEfiSystemTable()
|
||||||
@@ -38,6 +66,19 @@ XtLoader::GetEfiSystemTable()
|
|||||||
return XtLoader::EfiSystemTable;
|
return XtLoader::EfiSystemTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides base address and size of the XTLDR image.
|
||||||
|
*
|
||||||
|
* @param LoaderBase
|
||||||
|
* Supplies a pointer to a variable that receives the base address of the XTLDR image.
|
||||||
|
*
|
||||||
|
* @param LoaderSize
|
||||||
|
* Supplies a pointer to a variable that receives the size of the XTLDR image.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
VOID
|
VOID
|
||||||
XtLoader::GetLoaderImageInformation(PVOID *LoaderBase,
|
XtLoader::GetLoaderImageInformation(PVOID *LoaderBase,
|
||||||
@@ -47,6 +88,13 @@ XtLoader::GetLoaderImageInformation(PVOID *LoaderBase,
|
|||||||
*LoaderSize = XtLoader::LoaderStatus.LoaderSize;
|
*LoaderSize = XtLoader::LoaderStatus.LoaderSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the Secure Boot status.
|
||||||
|
*
|
||||||
|
* @return This routine returns SecureBoot status.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
INT_PTR
|
INT_PTR
|
||||||
XtLoader::GetSecureBootStatus()
|
XtLoader::GetSecureBootStatus()
|
||||||
@@ -143,6 +191,13 @@ XtLoader::RegisterBootMenu(IN PVOID BootMenuRoutine)
|
|||||||
BootMenu = (PBL_XT_BOOT_MENU)BootMenuRoutine;
|
BootMenu = (PBL_XT_BOOT_MENU)BootMenuRoutine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invokes either a custom boot menu handler, if one has been registered, or displays the default boot menu.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
VOID
|
VOID
|
||||||
XtLoader::ShowBootMenu()
|
XtLoader::ShowBootMenu()
|
||||||
|
Reference in New Issue
Block a user
Do we need to typecast each bool operation? In C this returned integer value and compiler knew how to cast it into our BOOLEAN enum. In C++, result value is of bool type that cannot be automatically typecasted into enum.
No, we do not have to. Alternatively, I can suggest moving the BOOLEAN type definition from xttypes.h to xtcompat.h:
This will allow us to maintain backward compatibility with C and get rid of explicit typecasts at the same time.
This should also work in the case of the quoted fragment, even though the result of the operation is not of type bool but int. The result of the expression will be 0 if the flag is not set, or the value of COMPORT_FLAG_INIT if it is. It is only the comparison of this result, for example (SerialPort.Flags & COMPORT_FLAG_INIT) != 0, that actually yields a bool type.
Please let me know if you accept this, then I will commit the proposed change.
You are right, this results in int, not bool. There are more such changes like this in the diff, and I added a comment to the first one, as its the only one that fits on first page. unfortunately. Never mind, I think the proposed solution will be OK.