Merge branch 'master' into threads
This commit is contained in:
@@ -105,9 +105,9 @@ namespace RTL
|
||||
class String
|
||||
{
|
||||
public:
|
||||
STATIC XTAPI SIZE_T CompareString(IN PCSTR String1,
|
||||
IN PCSTR String2,
|
||||
IN SIZE_T Length);
|
||||
STATIC XTAPI LONG CompareString(IN PCSTR String1,
|
||||
IN PCSTR String2,
|
||||
IN SIZE_T Length);
|
||||
STATIC XTAPI SIZE_T StringLength(IN PCSTR String,
|
||||
IN SIZE_T MaxLength);
|
||||
STATIC XTAPI SIZE_T StringToWideString(OUT PWCHAR Destination,
|
||||
@@ -119,12 +119,12 @@ namespace RTL
|
||||
class WideString
|
||||
{
|
||||
public:
|
||||
STATIC XTAPI SIZE_T CompareWideString(IN PCWSTR String1,
|
||||
IN PCWSTR String2,
|
||||
IN SIZE_T Length);
|
||||
STATIC XTAPI SIZE_T CompareWideStringInsensitive(IN PCWSTR String1,
|
||||
IN PCWSTR String2,
|
||||
IN SIZE_T Length);
|
||||
STATIC XTAPI LONG CompareWideString(IN PCWSTR String1,
|
||||
IN PCWSTR String2,
|
||||
IN SIZE_T Length);
|
||||
STATIC XTAPI LONG CompareWideStringInsensitive(IN PCWSTR String1,
|
||||
IN PCWSTR String2,
|
||||
IN SIZE_T Length);
|
||||
STATIC XTAPI PWCHAR ConcatenateWideString(OUT PWCHAR Destination,
|
||||
IN PWCHAR Source,
|
||||
IN SIZE_T Count);
|
||||
|
||||
@@ -261,6 +261,7 @@ class Shell
|
||||
STATIC LIST_ENTRY ShellCommands;
|
||||
|
||||
public:
|
||||
STATIC XTCDECL VOID InitializeShell();
|
||||
STATIC XTCDECL EFI_STATUS RegisterCommand(IN PCWSTR Command,
|
||||
IN PCWSTR Description,
|
||||
IN PBL_SHELL_COMMAND Handler);
|
||||
|
||||
@@ -13,8 +13,78 @@
|
||||
MODULE_AUTHOR(L"Rafal Kupiec <belliash@codingworkshop.eu.org>");
|
||||
MODULE_DESCRIPTION(L"Plays a GRUB compatible tune via PC speaker");
|
||||
MODULE_LICENSE(L"GPLv3");
|
||||
MODULE_VERSION(L"0.1");
|
||||
MODULE_VERSION(L"0.2");
|
||||
|
||||
/**
|
||||
* Executes the beep shell command to play a musical tune.
|
||||
*
|
||||
* @param Argc
|
||||
* Supplies the number of arguments passed to the command line.
|
||||
*
|
||||
* @param Argv
|
||||
* Supplies a pointer to an array of null-terminated argument strings.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTCDECL
|
||||
VOID
|
||||
Beep::CommandBeep(IN ULONG Argc,
|
||||
IN PWCHAR *Argv)
|
||||
{
|
||||
WCHAR Tune[XTBL_SH_MAX_LINE_LENGTH];
|
||||
ULONG ArgumentIndex, TuneLength;
|
||||
PWCHAR Character;
|
||||
|
||||
/* Check the number of arguments */
|
||||
if(Argc < 2)
|
||||
{
|
||||
/* Invalid number of arguments, print usage message and return */
|
||||
XtLdrProtocol->Console.Print(L"Usage: beep <tempo> <pitch1> <duration1> [pitch2 duration2 ...]\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Rebuild the space-separated argument string */
|
||||
TuneLength = 0;
|
||||
for(ArgumentIndex = 1; ArgumentIndex < Argc; ArgumentIndex++)
|
||||
{
|
||||
/* Retrieve the pointer to the current argument string */
|
||||
Character = Argv[ArgumentIndex];
|
||||
while(*Character != L'\0')
|
||||
{
|
||||
/* Verify that the tune buffer has sufficient capacity */
|
||||
if(TuneLength >= XTBL_SH_MAX_LINE_LENGTH - 1)
|
||||
{
|
||||
/* Buffer capacity exceeded, print error message and return */
|
||||
XtLdrProtocol->Console.Print(L"ERROR: Tune is too long.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Copy the current character to the buffer and advance the source pointer */
|
||||
Tune[TuneLength++] = *Character++;
|
||||
}
|
||||
|
||||
/* Check if there are subsequent arguments */
|
||||
if(ArgumentIndex + 1 < Argc)
|
||||
{
|
||||
/* Verify that the tune buffer has sufficient capacity */
|
||||
if(TuneLength >= XTBL_SH_MAX_LINE_LENGTH - 1)
|
||||
{
|
||||
/* Buffer capacity exceeded, print error message and return */
|
||||
XtLdrProtocol->Console.Print(L"ERROR: Tune is too long.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Append a space character to the tune buffer */
|
||||
Tune[TuneLength++] = L' ';
|
||||
}
|
||||
}
|
||||
|
||||
/* Terminate the reconstructed string and dispatch it to the playback routine */
|
||||
Tune[TuneLength] = L'\0';
|
||||
PlayTune(Tune);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the PC speaker.
|
||||
@@ -102,6 +172,9 @@ Beep::InitializeModule(IN EFI_HANDLE ImageHandle,
|
||||
return STATUS_EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
/* Register the `beep` command */
|
||||
XtLdrProtocol->Shell.RegisterCommand(L"beep", L"Plays a GRUB compatible tune", CommandBeep);
|
||||
|
||||
/* Play the tune set in the configuration */
|
||||
XtLdrProtocol->Config.GetValue(L"TUNE", &Tune);
|
||||
PlayTune(Tune);
|
||||
|
||||
@@ -21,11 +21,12 @@ class Beep
|
||||
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 CommandBeep(IN ULONG Argc, IN PWCHAR *Argv);
|
||||
STATIC XTCDECL VOID DisableToneBeep();
|
||||
STATIC XTCDECL VOID EnableToneBeep(IN UINT Pitch);
|
||||
STATIC XTCDECL VOID PlayTune(IN PWCHAR Arguments);
|
||||
STATIC XTCDECL UINT WideStringToNumber(IN PWCHAR String);
|
||||
};
|
||||
|
||||
|
||||
@@ -307,6 +307,24 @@ Shell::ExecuteCommand(IN ULONG Argc,
|
||||
Console::Print(L"ERROR: '%S' is not recognized as a valid command.\n", Argv[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the bootloader shell.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTCDECL
|
||||
VOID
|
||||
Shell::InitializeShell()
|
||||
{
|
||||
/* Initialize the shell commands list */
|
||||
RTL::LinkedList::InitializeListHead(&ShellCommands);
|
||||
|
||||
/* Register all built-in commands */
|
||||
RegisterBuiltinCommands();
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits the supplied raw command line string into an argument count and an argument vector suitable
|
||||
* for command dispatch. The input string is tokenized by whitespace.
|
||||
@@ -881,12 +899,6 @@ Shell::StartLoaderShell()
|
||||
/* Initialize console */
|
||||
Console::InitializeConsole();
|
||||
|
||||
/* Initialize the shell commands list */
|
||||
RTL::LinkedList::InitializeListHead(&ShellCommands);
|
||||
|
||||
/* Register all built-in commands */
|
||||
RegisterBuiltinCommands();
|
||||
|
||||
/* Clear the shell exit request flag */
|
||||
ExitRequest = FALSE;
|
||||
|
||||
|
||||
@@ -456,7 +456,7 @@ Volume::GetDevicePath(IN PWCHAR SystemPath,
|
||||
if(Status != STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Failed to parse system path */
|
||||
Debug::Print(L"ERROR: Failed to parse system path: '%s' (Status Code: 0x%zX)\n", SystemPath, Status);
|
||||
Debug::Print(L"ERROR: Failed to parse system path: '%S' (Status Code: 0x%zX)\n", SystemPath, Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -842,26 +842,26 @@ Volume::DissectArcPath(IN PWCHAR SystemPath,
|
||||
*PartNumber = 0;
|
||||
|
||||
/* Look for the ARC path */
|
||||
if(RTL::WideString::CompareWideStringInsensitive(SystemPath, L"ramdisk(0)", 0) == 0)
|
||||
if(RTL::WideString::CompareWideStringInsensitive(SystemPath, L"ramdisk(0)", 10) == 0)
|
||||
{
|
||||
/* This is RAM disk */
|
||||
ArcLength = 10;
|
||||
*DriveType = XTBL_BOOT_DEVICE_RAMDISK;
|
||||
}
|
||||
else if(RTL::WideString::CompareWideStringInsensitive(SystemPath, L"multi(0)esp(0)", 0) == 0)
|
||||
else if(RTL::WideString::CompareWideStringInsensitive(SystemPath, L"multi(0)esp(0)", 14) == 0)
|
||||
{
|
||||
/* This is ESP */
|
||||
ArcLength = 14;
|
||||
*DriveType = XTBL_BOOT_DEVICE_ESP;
|
||||
}
|
||||
else if(RTL::WideString::CompareWideStringInsensitive(SystemPath, L"multi(0)disk(0)", 0) == 0)
|
||||
else if(RTL::WideString::CompareWideStringInsensitive(SystemPath, L"multi(0)disk(0)", 15) == 0)
|
||||
{
|
||||
/* This is a multi-disk port */
|
||||
ArcLength = 15;
|
||||
ArcPath = SystemPath + ArcLength;
|
||||
|
||||
/* Check for disk type */
|
||||
if(RTL::WideString::CompareWideStringInsensitive(ArcPath, L"cdrom(", 0) == 0)
|
||||
if(RTL::WideString::CompareWideStringInsensitive(ArcPath, L"cdrom(", 6) == 0)
|
||||
{
|
||||
/* This is an optical drive */
|
||||
ArcLength += 6;
|
||||
@@ -882,7 +882,7 @@ Volume::DissectArcPath(IN PWCHAR SystemPath,
|
||||
*DriveType = XTBL_BOOT_DEVICE_CDROM;
|
||||
ArcLength++;
|
||||
}
|
||||
else if(RTL::WideString::CompareWideStringInsensitive(ArcPath, L"fdisk(", 0) == 0)
|
||||
else if(RTL::WideString::CompareWideStringInsensitive(ArcPath, L"fdisk(", 6) == 0)
|
||||
{
|
||||
/* This is a floppy drive */
|
||||
ArcLength += 6;
|
||||
@@ -903,7 +903,7 @@ Volume::DissectArcPath(IN PWCHAR SystemPath,
|
||||
*DriveType = XTBL_BOOT_DEVICE_FLOPPY;
|
||||
ArcLength++;
|
||||
}
|
||||
else if(RTL::WideString::CompareWideStringInsensitive(ArcPath, L"rdisk(", 0) == 0)
|
||||
else if(RTL::WideString::CompareWideStringInsensitive(ArcPath, L"rdisk(", 6) == 0)
|
||||
{
|
||||
/* This is a hard disk */
|
||||
ArcLength += 6;
|
||||
@@ -926,7 +926,7 @@ Volume::DissectArcPath(IN PWCHAR SystemPath,
|
||||
ArcPath = SystemPath + ArcLength;
|
||||
|
||||
/* Look for a partition */
|
||||
if(RTL::WideString::CompareWideStringInsensitive(ArcPath, L"partition(", 0) == 0)
|
||||
if(RTL::WideString::CompareWideStringInsensitive(ArcPath, L"partition(", 10) == 0)
|
||||
{
|
||||
/* Partition information found */
|
||||
ArcLength += 10;
|
||||
|
||||
@@ -138,6 +138,9 @@ XtLoader::InitializeBootLoader(IN EFI_HANDLE ImageHandle,
|
||||
/* Initialize XTLDR configuration */
|
||||
Configuration::InitializeConfiguration();
|
||||
|
||||
/* Initialize shell */
|
||||
Shell::InitializeShell();
|
||||
|
||||
/* Store SecureBoot status */
|
||||
LoaderStatus.SecureBoot = EfiUtils::GetSecureBootStatus();
|
||||
|
||||
@@ -245,7 +248,7 @@ BlStartXtLoader(IN EFI_HANDLE ImageHandle,
|
||||
for(;;);
|
||||
}
|
||||
|
||||
/* Initialize XTLDR and */
|
||||
/* Initialize XTLDR */
|
||||
XtLoader::InitializeBootLoader(ImageHandle, SystemTable);
|
||||
|
||||
/* Parse configuration options passed from UEFI shell */
|
||||
|
||||
Reference in New Issue
Block a user