diff options
author | rsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-04-14 10:47:19 +0000 |
---|---|---|
committer | rsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-04-14 10:47:19 +0000 |
commit | cb7d01c0c9fd199742d0fed6aa69dab0c79c3338 (patch) | |
tree | 920a78778c9de452a58ee0d0df2893e7c4822bdb /MdeModulePkg/Universal/DriverSampleDxe | |
parent | 169a34619b6d583d9f2934a6a3e9caf6e5c6e355 (diff) | |
download | edk2-platforms-cb7d01c0c9fd199742d0fed6aa69dab0c79c3338.tar.xz |
HII Library Class interface refine.
The "HiiLib" prefix for all HII Library API function names changed to "Hii".
Remove:
HiiLibPreparePackageList(), replaced by HiiAddPackages()
HiiLibNewString(), replaced by HiiSetString()
HiiLibGetStringFromHandle(), replaced by HiiGetString()
HiiLibGetStringFromToken(), replaced by HiiGetPackageString()
HiiLibExtractGuidFromHiiHandle()
HiiLibDevicePathToHiiHandle()
HiiLibGetSupportedSecondaryLanguages()
HiiLibGetSupportedLanguageNumber()
HiiLibExportPackageLists()
HiiLibListPackageLists()
Interface change:
HiiAddPackages()
HiiSetString()
HiiGetString()
HiiGetHiiHandles()
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8083 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/DriverSampleDxe')
3 files changed, 42 insertions, 53 deletions
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c index 409c8e4740..573374f59b 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c @@ -170,21 +170,21 @@ ValidatePassword ( //
// Get user input password
//
- BufferSize = 21 * sizeof (CHAR16);
- Password = AllocateZeroPool (BufferSize);
- ASSERT (Password != NULL);
-
- Status = HiiLibGetString (PrivateData->HiiHandle[0], StringId, Password, &BufferSize);
- if (EFI_ERROR (Status)) {
+ Password = HiiGetString (PrivateData->HiiHandle[0], StringId, NULL);
+ if (Password == NULL) {
+ return EFI_NOT_READY;
+ }
+ if (StrLen (Password) > 20) {
FreePool (Password);
- return Status;
+ return EFI_NOT_READY;
}
//
// Validate old password
//
- EncodedPassword = AllocateCopyPool (21 * sizeof (CHAR16), Password);
+ EncodedPassword = AllocateZeroPool (21 * sizeof (CHAR16));
ASSERT (EncodedPassword != NULL);
+ StrnCpy (EncodedPassword, Password, 21);
EncodePassword (EncodedPassword, 20 * sizeof (CHAR16));
if (CompareMem (EncodedPassword, PrivateData->Configuration.WhatIsThePassword2, 20 * sizeof (CHAR16)) != 0) {
//
@@ -219,6 +219,7 @@ SetPassword ( {
EFI_STATUS Status;
CHAR16 *Password;
+ CHAR16 *TempPassword;
UINTN PasswordSize;
DRIVER_SAMPLE_CONFIGURATION *Configuration;
UINTN BufferSize;
@@ -242,13 +243,19 @@ SetPassword ( // Get user input password
//
Password = &PrivateData->Configuration.WhatIsThePassword2[0];
- PasswordSize = sizeof (PrivateData->Configuration.WhatIsThePassword2);
-
+ PasswordSize = sizeof (PrivateData->Configuration.WhatIsThePassword2);
ZeroMem (Password, PasswordSize);
- Status = HiiLibGetString (PrivateData->HiiHandle[0], StringId, Password, &BufferSize);
- if (EFI_ERROR (Status)) {
- return Status;
+
+ TempPassword = HiiGetString (PrivateData->HiiHandle[0], StringId, NULL);
+ if (TempPassword == NULL) {
+ return EFI_NOT_READY;
+ }
+ if (StrLen (TempPassword) > PasswordSize / sizeof (CHAR16)) {
+ FreePool (TempPassword);
+ return EFI_NOT_READY;
}
+ StrnCpy (Password, TempPassword, PasswordSize / sizeof (CHAR16));
+ FreePool (TempPassword);
//
// Retrive uncommitted data from Browser
@@ -786,7 +793,6 @@ DriverSampleInit ( {
EFI_STATUS Status;
EFI_STATUS SavedStatus;
- EFI_HII_PACKAGE_LIST_HEADER *PackageList;
EFI_HII_HANDLE HiiHandle[2];
EFI_SCREEN_DESCRIPTOR Screen;
EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
@@ -878,26 +884,17 @@ DriverSampleInit ( //
// Publish our HII data
//
- PackageList = HiiLibPreparePackageList (
- 2,
- &mFormSetGuid,
- DriverSampleStrings,
- VfrBin
- );
- if (PackageList == NULL) {
+ HiiHandle[0] = HiiAddPackages (
+ &mFormSetGuid,
+ DriverHandle[0],
+ DriverSampleStrings,
+ VfrBin,
+ NULL
+ );
+ if (HiiHandle[0] == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- Status = HiiDatabase->NewPackageList (
- HiiDatabase,
- PackageList,
- DriverHandle[0],
- &HiiHandle[0]
- );
- FreePool (PackageList);
- if (EFI_ERROR (Status)) {
- return Status;
- }
PrivateData->HiiHandle[0] = HiiHandle[0];
//
@@ -913,26 +910,17 @@ DriverSampleInit ( PrivateData->DriverHandle[1] = DriverHandle[1];
- PackageList = HiiLibPreparePackageList (
- 2,
- &mInventoryGuid,
- DriverSampleStrings,
- InventoryBin
- );
- if (PackageList == NULL) {
+ HiiHandle[1] = HiiAddPackages (
+ &mInventoryGuid,
+ DriverHandle[1],
+ DriverSampleStrings,
+ InventoryBin,
+ NULL
+ );
+ if (HiiHandle[1] == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- Status = HiiDatabase->NewPackageList (
- HiiDatabase,
- PackageList,
- DriverHandle[1],
- &HiiHandle[1]
- );
- FreePool (PackageList);
- if (EFI_ERROR (Status)) {
- return Status;
- }
PrivateData->HiiHandle[1] = HiiHandle[1];
//
@@ -941,9 +929,8 @@ DriverSampleInit ( //
NewString = L"700 Mhz";
- Status = HiiLibSetString (HiiHandle[0], STRING_TOKEN (STR_CPU_STRING2), NewString);
- if (EFI_ERROR (Status)) {
- return Status;
+ if (HiiSetString (HiiHandle[0], STRING_TOKEN (STR_CPU_STRING2), NewString, NULL) == 0) {
+ return EFI_OUT_OF_RESOURCES;
}
//
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h index 3317e4fdc2..ded33121ec 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h @@ -34,6 +34,7 @@ Revision History #include <Guid/MdeModuleHii.h>
#include <Library/DebugLib.h>
+#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiDriverEntryPoint.h>
@@ -53,7 +54,7 @@ extern UINT8 VfrMyIfrNVDataBlockName[]; //
// This is the generated IFR binary data for each formset defined in VFR.
-// This data array is ready to be used as input of HiiLibPreparePackageList() to
+// This data array is ready to be used as input of HiiAddPackages() to
// create a packagelist (which contains Form packages, String packages, etc).
//
extern UINT8 VfrBin[];
@@ -61,7 +62,7 @@ extern UINT8 InventoryBin[]; //
// This is the generated String package data for all .UNI files.
-// This data array is ready to be used as input of HiiLibPreparePackageList() to
+// This data array is ready to be used as input of HiiAddPackages() to
// create a packagelist (which contains Form packages, String packages, etc).
//
extern UINT8 DriverSampleStrings[];
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf b/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf index 3ed56e934e..657d0ca78e 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf @@ -46,6 +46,7 @@ [LibraryClasses]
+ BaseLib
MemoryAllocationLib
UefiBootServicesTableLib
UefiDriverEntryPoint
|