Skip to content

Commit

Permalink
Ring3: Added UnicodeCollationProtocol wrappers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Krichanov committed Mar 9, 2024
1 parent 47134f0 commit 73e36a1
Show file tree
Hide file tree
Showing 8 changed files with 658 additions and 9 deletions.
1 change: 1 addition & 0 deletions MdeModulePkg/Core/Dxe/DxeMain.inf
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
gEfiComponentNameProtocolGuid ## SOMETIMES_CONSUMES
gEfiDiskIoProtocolGuid ## SOMETIMES_CONSUMES
gEfiBlockIoProtocolGuid ## SOMETIMES_CONSUMES
gEfiUnicodeCollationProtocolGuid ## SOMETIMES_CONSUMES

# Arch Protocols
gEfiBdsArchProtocolGuid ## CONSUMES
Expand Down
1 change: 1 addition & 0 deletions MdeModulePkg/Core/Dxe/DxeRing3/DxeRing3.inf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
gEfiDiskIoProtocolGuid ## SOMETIMES_CONSUMES
gEfiBlockIoProtocolGuid ## SOMETIMES_CONSUMES
gEfiDevicePathProtocolGuid ## SOMETIMES_CONSUMES
gEfiUnicodeCollationProtocolGuid ## SOMETIMES_CONSUMES

[Depex]
TRUE
115 changes: 115 additions & 0 deletions MdeModulePkg/Core/Dxe/DxeRing3/Ring3.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <Protocol/DevicePathUtilities.h>
#include <Protocol/DiskIo.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/UnicodeCollation.h>

EFI_STATUS
EFIAPI
Expand Down Expand Up @@ -1547,3 +1548,117 @@ Ring3QueryVariableInfo (
OUT UINT64 *RemainingVariableStorageSize,
OUT UINT64 *MaximumVariableSize
);

/**
Performs a case-insensitive comparison of two Null-terminated strings.
@param This A pointer to the EFI_UNICODE_COLLATION_PROTOCOL instance.
@param Str1 A pointer to a Null-terminated string.
@param Str2 A pointer to a Null-terminated string.
@retval 0 Str1 is equivalent to Str2.
@retval >0 Str1 is lexically greater than Str2.
@retval <0 Str1 is lexically less than Str2.
**/
INTN
EFIAPI
Ring3UnicodeStriColl (
IN EFI_UNICODE_COLLATION_PROTOCOL *This,
IN CHAR16 *Str1,
IN CHAR16 *Str2
);

/**
Performs a case-insensitive comparison of a Null-terminated
pattern string and a Null-terminated string.
@param This A pointer to the EFI_UNICODE_COLLATION_PROTOCOL instance.
@param String A pointer to a Null-terminated string.
@param Pattern A pointer to a Null-terminated pattern string.
@retval TRUE Pattern was found in String.
@retval FALSE Pattern was not found in String.
**/
BOOLEAN
EFIAPI
Ring3UnicodeMetaiMatch (
IN EFI_UNICODE_COLLATION_PROTOCOL *This,
IN CHAR16 *String,
IN CHAR16 *Pattern
);

/**
Converts all the characters in a Null-terminated string to
lower case characters.
@param This A pointer to the EFI_UNICODE_COLLATION_PROTOCOL instance.
@param String A pointer to a Null-terminated string.
**/
VOID
EFIAPI
Ring3UnicodeStrLwr (
IN EFI_UNICODE_COLLATION_PROTOCOL *This,
IN OUT CHAR16 *Str
);

/**
Converts all the characters in a Null-terminated string to upper
case characters.
@param This A pointer to the EFI_UNICODE_COLLATION_PROTOCOL instance.
@param String A pointer to a Null-terminated string.
**/
VOID
EFIAPI
Ring3UnicodeStrUpr (
IN EFI_UNICODE_COLLATION_PROTOCOL *This,
IN OUT CHAR16 *Str
);

/**
Converts an 8.3 FAT file name in an OEM character set to a Null-terminated
string.
@param This A pointer to the EFI_UNICODE_COLLATION_PROTOCOL instance.
@param FatSize The size of the string Fat in bytes.
@param Fat A pointer to a Null-terminated string that contains an 8.3 file
name using an 8-bit OEM character set.
@param String A pointer to a Null-terminated string. The string must
be allocated in advance to hold FatSize characters.
**/
VOID
EFIAPI
Ring3UnicodeFatToStr (
IN EFI_UNICODE_COLLATION_PROTOCOL *This,
IN UINTN FatSize,
IN CHAR8 *Fat,
OUT CHAR16 *String
);

/**
Converts a Null-terminated string to legal characters in a FAT
filename using an OEM character set.
@param This A pointer to the EFI_UNICODE_COLLATION_PROTOCOL instance.
@param String A pointer to a Null-terminated string.
@param FatSize The size of the string Fat in bytes.
@param Fat A pointer to a string that contains the converted version of
String using legal FAT characters from an OEM character set.
@retval TRUE One or more conversions failed and were substituted with '_'
@retval FALSE None of the conversions failed.
**/
BOOLEAN
EFIAPI
Ring3UnicodeStrToFat (
IN EFI_UNICODE_COLLATION_PROTOCOL *This,
IN CHAR16 *String,
IN UINTN FatSize,
OUT CHAR8 *Fat
);
96 changes: 96 additions & 0 deletions MdeModulePkg/Core/Dxe/DxeRing3/Ring3Protocols.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,99 @@ Ring3DiskIoWrite (
Buffer
);
}

INTN
EFIAPI
Ring3UnicodeStriColl (
IN EFI_UNICODE_COLLATION_PROTOCOL *This,
IN CHAR16 *Str1,
IN CHAR16 *Str2
)
{
return (INTN)SysCall (
SysCallUnicodeStriColl,
This,
Str1,
Str2
);
}

BOOLEAN
EFIAPI
Ring3UnicodeMetaiMatch (
IN EFI_UNICODE_COLLATION_PROTOCOL *This,
IN CHAR16 *String,
IN CHAR16 *Pattern
)
{
return (BOOLEAN)SysCall (
SysCallUnicodeMetaiMatch,
This,
String,
Pattern
);
}

VOID
EFIAPI
Ring3UnicodeStrLwr (
IN EFI_UNICODE_COLLATION_PROTOCOL *This,
IN OUT CHAR16 *Str
)
{
SysCall (
SysCallUnicodeStrLwr,
This,
Str
);
}

VOID
EFIAPI
Ring3UnicodeStrUpr (
IN EFI_UNICODE_COLLATION_PROTOCOL *This,
IN OUT CHAR16 *Str
)
{
SysCall (
SysCallUnicodeStrUpr,
This,
Str
);
}

VOID
EFIAPI
Ring3UnicodeFatToStr (
IN EFI_UNICODE_COLLATION_PROTOCOL *This,
IN UINTN FatSize,
IN CHAR8 *Fat,
OUT CHAR16 *String
)
{
SysCall (
SysCallUnicodeFatToStr,
This,
FatSize,
Fat,
String
);
}

BOOLEAN
EFIAPI
Ring3UnicodeStrToFat (
IN EFI_UNICODE_COLLATION_PROTOCOL *This,
IN CHAR16 *String,
IN UINTN FatSize,
OUT CHAR8 *Fat
)
{
return (BOOLEAN)SysCall (
SysCallUnicodeStrToFat,
This,
String,
FatSize,
Fat
);
}
22 changes: 19 additions & 3 deletions MdeModulePkg/Core/Dxe/DxeRing3/Ring3UefiBootServices.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ FixInterface (
EFI_BLOCK_IO_PROTOCOL *BlockIo;
EFI_DISK_IO_PROTOCOL *DiskIo;
EFI_DEVICE_PATH_UTILITIES_PROTOCOL *DevicePath;
EFI_UNICODE_COLLATION_PROTOCOL *Unicode;

ASSERT (Protocol != NULL);
ASSERT (Interface != NULL);
Expand Down Expand Up @@ -71,6 +72,16 @@ FixInterface (
DevicePath->IsDevicePathMultiInstance = NULL;
DevicePath->CreateDeviceNode = NULL;

} else if (CompareGuid (Protocol, &gEfiUnicodeCollationProtocolGuid)) {
Unicode = (EFI_UNICODE_COLLATION_PROTOCOL *)*Interface;

Unicode->StriColl = Ring3UnicodeStriColl;
Unicode->MetaiMatch = Ring3UnicodeMetaiMatch;
Unicode->StrLwr = Ring3UnicodeStrLwr;
Unicode->StrUpr = Ring3UnicodeStrUpr;
Unicode->FatToStr = Ring3UnicodeFatToStr;
Unicode->StrToFat = Ring3UnicodeStrToFat;

} else {
return EFI_UNSUPPORTED;
}
Expand Down Expand Up @@ -568,9 +579,14 @@ Ring3LocateHandleBuffer (
OUT EFI_HANDLE **Buffer
)
{
DEBUG ((DEBUG_ERROR, "Ring3: LocateHandleBuffer is not supported\n"));

return EFI_UNSUPPORTED;
return SysCall (
SysCallLocateHandleBuffer,
SearchType,
Protocol,
SearchKey,
NumberHandles,
Buffer
);
}

EFI_STATUS
Expand Down
Loading

0 comments on commit 73e36a1

Please sign in to comment.