diff options
author | andrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-01-26 08:49:22 +0000 |
---|---|---|
committer | andrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-01-26 08:49:22 +0000 |
commit | b02127ec88a3edb6942b28b818cee6f4a73d1551 (patch) | |
tree | e4b5413bcc0bf25708e3e32c073dccca64df4464 /EmulatorPkg | |
parent | a0af6b27288fb1797e618d45ba3b4d6a9c742944 (diff) | |
download | edk2-b02127ec88a3edb6942b28b818cee6f4a73d1551.zip edk2-b02127ec88a3edb6942b28b818cee6f4a73d1551.tar.gz edk2-b02127ec88a3edb6942b28b818cee6f4a73d1551.tar.bz2 |
Fix bug where { NULL } did not terminate with a double NULL. Add support for passing in NULL for the string pack. Update the comments.
signed-off-by: andrewfish
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12955 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EmulatorPkg')
-rw-r--r-- | EmulatorPkg/CpuRuntimeDxe/Cpu.c | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/EmulatorPkg/CpuRuntimeDxe/Cpu.c b/EmulatorPkg/CpuRuntimeDxe/Cpu.c index 7be4146..fc8d325 100644 --- a/EmulatorPkg/CpuRuntimeDxe/Cpu.c +++ b/EmulatorPkg/CpuRuntimeDxe/Cpu.c @@ -137,12 +137,30 @@ CHAR8 *mCpuSmbiosType4Strings[] = { /**
- Logs SMBIOS record.
-
- Note: This should be a genric library function.
+ Create SMBIOS record.
+
+ Converts a fixed SMBIOS structure and an array of pointers to strings into
+ an SMBIOS record where the strings are cat'ed on the end of the fixed record
+ and terminated via a double NULL and add to SMBIOS table.
+
+ SMBIOS_TABLE_TYPE32 gSmbiosType12 = {
+ { EFI_SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS, sizeof (SMBIOS_TABLE_TYPE12), 0 },
+ 1 // StringCount
+ };
+ CHAR8 *gSmbiosType12Strings[] = {
+ "Not Found",
+ NULL
+ };
+
+ ...
+ LogSmbiosData (
+ (EFI_SMBIOS_TABLE_HEADER*)&gSmbiosType12,
+ gSmbiosType12Strings
+ );
- @param Template Fixed SMBIOS structure
- @param StringPack Array of strings to convert to an SMBIOS string pack.
+ @param Template Fixed SMBIOS structure, required.
+ @param StringArray Array of strings to convert to an SMBIOS string pack.
+ NULL is OK.
**/
EFI_STATUS
@@ -170,12 +188,21 @@ LogSmbiosData ( // Calculate the size of the fixed record and optional string pack
Size = Template->Length;
- for (Index = 0; StringPack[Index] != NULL; Index++) {
- StringSize = AsciiStrSize (StringPack[Index]);
- Size += StringSize;
+ if (StringPack == NULL) {
+ // At least a double null is required
+ Size += 2;
+ } else {
+ for (Index = 0; StringPack[Index] != NULL; Index++) {
+ StringSize = AsciiStrSize (StringPack[Index]);
+ Size += StringSize;
+ }
+ if (StringPack[0] == NULL) {
+ // At least a double null is required
+ Size += 1;
+ }
+ // Don't forget the terminating double null
+ Size += 1;
}
- // Don't forget the terminating double null
- Size += 1;
// Copy over Template
Record = (EFI_SMBIOS_TABLE_HEADER *)AllocateZeroPool (Size);
|