diff options
author | Jaben Carsey <jaben.carsey@intel.com> | 2014-08-06 16:18:38 +0000 |
---|---|---|
committer | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2014-08-06 16:18:38 +0000 |
commit | 09fd5328a48faf4f4dfda78015842317cd41c98c (patch) | |
tree | 51649255f54f134001cf6b583dcaf82284f52f92 | |
parent | 7aae3c355fda9d4548983edfdd27e0460fb9376c (diff) | |
download | edk2-09fd5328a48faf4f4dfda78015842317cd41c98c.tar.gz edk2-09fd5328a48faf4f4dfda78015842317cd41c98c.tar.bz2 edk2-09fd5328a48faf4f4dfda78015842317cd41c98c.zip |
Updates the UEFI Shell to produce the new protocol with additional 4 functions.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>
Reviewed by: Daryl McDaniel <daryl.mcdaniel@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15764 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | ShellPkg/Application/Shell/Shell.h | 2 | ||||
-rw-r--r-- | ShellPkg/Application/Shell/ShellProtocol.c | 212 | ||||
-rw-r--r-- | ShellPkg/Application/Shell/ShellProtocol.h | 6 |
3 files changed, 182 insertions, 38 deletions
diff --git a/ShellPkg/Application/Shell/Shell.h b/ShellPkg/Application/Shell/Shell.h index 72dde69645..f78e559665 100644 --- a/ShellPkg/Application/Shell/Shell.h +++ b/ShellPkg/Application/Shell/Shell.h @@ -96,7 +96,7 @@ typedef struct { typedef struct {
EFI_SHELL_PARAMETERS_PROTOCOL *NewShellParametersProtocol;
- EFI_SHELL_PROTOCOL *NewEfiShellProtocol;
+ EFI_SHELL_PROTOCOL21 *NewEfiShellProtocol;
BOOLEAN PageBreakEnabled;
BOOLEAN RootShellInstance;
SHELL_INIT_SETTINGS ShellInitSettings;
diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c index 403bed4516..798f5476f6 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.c +++ b/ShellPkg/Application/Shell/ShellProtocol.c @@ -1145,13 +1145,40 @@ EfiShellCreateFile( return (EFI_NOT_FOUND);
}
- Status = InternalOpenFileDevicePath(DevicePath, FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, FileAttribs); // 0 = no specific file attributes
+ Status = InternalOpenFileDevicePath(DevicePath, FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, FileAttribs);
FreePool(DevicePath);
return(Status);
}
/**
+ Register a GUID and a localized human readable name for it.
+
+ If Guid is not assigned a name, then assign GuidName to Guid. This list of GUID
+ names must be used whenever a shell command outputs GUID information.
+
+ This function is only available when the major and minor versions in the
+ EfiShellProtocol are greater than or equal to 2 and 1, respectively.
+
+ @param[in] Guid A pointer to the GUID being registered.
+ @param[in] GuidName A pointer to the localized name for the GUID being registered.
+
+ @retval EFI_SUCCESS The operation was successful.
+ @retval EFI_INVALID_PARAMETER Guid was NULL.
+ @retval EFI_INVALID_PARAMETER GuidName was NULL.
+ @retval EFI_ACCESS_DENIED Guid already is assigned a name.
+**/
+EFI_STATUS
+EFIAPI
+EfiShellRegisterGuidName(
+ IN CONST EFI_GUID *Guid,
+ IN CONST CHAR16 *GuidName
+ )
+{
+ return (AddNewGuidNameMapping(Guid, GuidName, NULL));
+}
+
+/**
Opens a file or a directory by file name.
This function opens the specified file in the specified OpenMode and returns a file
@@ -2027,6 +2054,87 @@ EfiShellFindFilesInDir( }
SHELL_FREE_NON_NULL(BasePath);
return(Status);
+ }
+
+/**
+ Get the GUID value from a human readable name.
+
+ If GuidName is a known GUID name, then update Guid to have the correct value for
+ that GUID.
+
+ This function is only available when the major and minor versions in the
+ EfiShellProtocol are greater than or equal to 2 and 1, respectively.
+
+ @param[in] GuidName A pointer to the localized name for the GUID being queried.
+ @param[out] Guid A pointer to the GUID structure to be filled in.
+
+ @retval EFI_SUCCESS The operation was successful.
+ @retval EFI_INVALID_PARAMETER Guid was NULL.
+ @retval EFI_INVALID_PARAMETER GuidName was NULL.
+ @retval EFI_NOT_FOUND GuidName is not a known GUID Name.
+**/
+EFI_STATUS
+EFIAPI
+EfiShellGetGuidFromName(
+ IN CONST CHAR16 *GuidName,
+ OUT EFI_GUID *Guid
+ )
+{
+ EFI_GUID *NewGuid;
+ EFI_STATUS Status;
+
+ if (Guid == NULL || GuidName == NULL) {
+ return (EFI_INVALID_PARAMETER);
+ }
+
+ Status = GetGuidFromStringName(GuidName, NULL, &NewGuid);
+
+ if (!EFI_ERROR(Status)) {
+ CopyGuid(NewGuid, Guid);
+ }
+
+ return (Status);
+}
+
+/**
+ Get the human readable name for a GUID from the value.
+
+ If Guid is assigned a name, then update *GuidName to point to the name. The callee
+ should not modify the value.
+
+ This function is only available when the major and minor versions in the
+ EfiShellProtocol are greater than or equal to 2 and 1, respectively.
+
+ @param[in] Guid A pointer to the GUID being queried.
+ @param[out] GuidName A pointer to a pointer the localized to name for the GUID being requested
+
+ @retval EFI_SUCCESS The operation was successful.
+ @retval EFI_INVALID_PARAMETER Guid was NULL.
+ @retval EFI_INVALID_PARAMETER GuidName was NULL.
+ @retval EFI_NOT_FOUND Guid is not assigned a name.
+**/
+EFI_STATUS
+EFIAPI
+EfiShellGetGuidName(
+ IN CONST EFI_GUID *Guid,
+ OUT CONST CHAR16 **GuidName
+ )
+{
+ CHAR16 *Name;
+
+ if (Guid == NULL || GuidName == NULL) {
+ return (EFI_INVALID_PARAMETER);
+ }
+
+ Name = GetStringNameFromGuid(Guid, NULL);
+ if (Name == NULL || StrLen(Name) == 0) {
+ SHELL_FREE_NON_NULL(Name);
+ return (EFI_NOT_FOUND);
+ }
+
+ *GuidName = AddBufferToFreeList(Name);
+
+ return (EFI_SUCCESS);
}
/**
@@ -2461,34 +2569,32 @@ EfiShellOpenFileList( }
/**
- This function updated with errata.
-
- Gets either a single or list of environment variables.
-
- If name is not NULL then this function returns the current value of the specified
- environment variable.
-
- If Name is NULL, then a list of all environment variable names is returned. Each is a
- NULL terminated string with a double NULL terminating the list.
-
- @param Name A pointer to the environment variable name. If
- Name is NULL, then the function will return all
- of the defined shell environment variables. In
- the case where multiple environment variables are
- being returned, each variable will be terminated by
- a NULL, and the list will be terminated by a double
- NULL.
-
- @return !=NULL A pointer to the returned string.
- The returned pointer does not need to be freed by the caller.
-
- @retval NULL The environment variable doesn't exist or there are
- no environment variables.
+ Gets the environment variable and Attributes, or list of environment variables. Can be
+ used instead of GetEnv().
+
+ This function returns the current value of the specified environment variable and
+ the Attributes. If no variable name was specified, then all of the known
+ variables will be returned.
+
+ @param[in] Name A pointer to the environment variable name. If Name is NULL,
+ then the function will return all of the defined shell
+ environment variables. In the case where multiple environment
+ variables are being returned, each variable will be terminated
+ by a NULL, and the list will be terminated by a double NULL.
+ @param[out] Attributes If not NULL, a pointer to the returned attributes bitmask for
+ the environment variable. In the case where Name is NULL, and
+ multiple environment variables are being returned, Attributes
+ is undefined.
+
+ @retval NULL The environment variable doesn’t exist.
+ @return A non-NULL value points to the variable’s value. The returned
+ pointer does not need to be freed by the caller.
**/
CONST CHAR16 *
-EFIAPI
-EfiShellGetEnv(
- IN CONST CHAR16 *Name
+EFIAPI
+EfiShellGetEnvEx(
+ IN CONST CHAR16 *Name,
+ OUT UINT32 *Attributes OPTIONAL
)
{
EFI_STATUS Status;
@@ -2556,14 +2662,14 @@ EfiShellGetEnv( //
// get the size we need for this EnvVariable
//
- Status = SHELL_GET_ENVIRONMENT_VARIABLE(Name, &Size, Buffer);
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(Name, Attributes, &Size, Buffer);
if (Status == EFI_BUFFER_TOO_SMALL) {
//
// Allocate the space and recall the get function
//
Buffer = AllocateZeroPool(Size);
ASSERT(Buffer != NULL);
- Status = SHELL_GET_ENVIRONMENT_VARIABLE(Name, &Size, Buffer);
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(Name, Attributes, &Size, Buffer);
}
//
// we didnt get it (might not exist)
@@ -2584,6 +2690,38 @@ EfiShellGetEnv( }
/**
+ Gets either a single or list of environment variables.
+
+ If name is not NULL then this function returns the current value of the specified
+ environment variable.
+
+ If Name is NULL, then a list of all environment variable names is returned. Each is a
+ NULL terminated string with a double NULL terminating the list.
+
+ @param Name A pointer to the environment variable name. If
+ Name is NULL, then the function will return all
+ of the defined shell environment variables. In
+ the case where multiple environment variables are
+ being returned, each variable will be terminated by
+ a NULL, and the list will be terminated by a double
+ NULL.
+
+ @retval !=NULL A pointer to the returned string.
+ The returned pointer does not need to be freed by the caller.
+
+ @retval NULL The environment variable doesn't exist or there are
+ no environment variables.
+**/
+CONST CHAR16 *
+EFIAPI
+EfiShellGetEnv(
+ IN CONST CHAR16 *Name
+ )
+{
+ return (EfiShellGetEnvEx(Name, NULL));
+}
+
+/**
Internal variable setting function. Allows for setting of the read only variables.
@param Name Points to the NULL-terminated environment variable name.
@@ -3241,7 +3379,7 @@ EfiShellSetAlias( // Pure FILE_HANDLE operations are passed to FileHandleLib
// these functions are indicated by the *
-EFI_SHELL_PROTOCOL mShellProtocol = {
+EFI_SHELL_PROTOCOL21 mShellProtocol = {
EfiShellExecute,
EfiShellGetEnv,
EfiShellSetEnv,
@@ -3282,8 +3420,14 @@ EFI_SHELL_PROTOCOL mShellProtocol = { EfiShellOpenRoot,
EfiShellOpenRootByHandle,
NULL,
- SHELL_MAJOR_VERSION,
- SHELL_MINOR_VERSION
+ 2, // SHELL_MAJOR_VERSION,
+ 1, // SHELL_MINOR_VERSION,
+
+ // New for UEFI Shell 2.1
+ EfiShellRegisterGuidName,
+ EfiShellGetGuidName,
+ EfiShellGetGuidFromName,
+ EfiShellGetEnvEx
};
/**
@@ -3303,7 +3447,7 @@ EFI_SHELL_PROTOCOL mShellProtocol = { EFI_STATUS
EFIAPI
CreatePopulateInstallShellProtocol (
- IN OUT EFI_SHELL_PROTOCOL **NewShell
+ IN OUT EFI_SHELL_PROTOCOL21 **NewShell
)
{
EFI_STATUS Status;
@@ -3430,7 +3574,7 @@ CreatePopulateInstallShellProtocol ( EFI_STATUS
EFIAPI
CleanUpShellProtocol (
- IN OUT EFI_SHELL_PROTOCOL *NewShell
+ IN OUT EFI_SHELL_PROTOCOL21 *NewShell
)
{
EFI_STATUS Status;
diff --git a/ShellPkg/Application/Shell/ShellProtocol.h b/ShellPkg/Application/Shell/ShellProtocol.h index c473977ae0..e1369617f2 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.h +++ b/ShellPkg/Application/Shell/ShellProtocol.h @@ -44,7 +44,7 @@ typedef struct { EFI_STATUS
EFIAPI
CreatePopulateInstallShellProtocol (
- IN OUT EFI_SHELL_PROTOCOL **NewShell
+ IN OUT EFI_SHELL_PROTOCOL21 **NewShell
);
/**
@@ -60,7 +60,7 @@ CreatePopulateInstallShellProtocol ( EFI_STATUS
EFIAPI
CleanUpShellProtocol (
- IN OUT EFI_SHELL_PROTOCOL *NewShell
+ IN OUT EFI_SHELL_PROTOCOL21 *NewShell
);
/**
@@ -657,7 +657,7 @@ EfiShellOpenFileList( @param Name A pointer to the environment variable name
- @return !=NULL The environment variable's value. The returned
+ @retval !=NULL The environment variable's value. The returned
pointer does not need to be freed by the caller.
@retval NULL The environment variable doesn't exist.
**/
|