2014-02-27 17:14:41 +08:00
|
|
|
/* types.cpp
|
|
|
|
|
2016-02-02 09:08:08 +08:00
|
|
|
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
|
2014-02-27 17:14:41 +08:00
|
|
|
This program and the accompanying materials
|
|
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
*/
|
|
|
|
|
2016-06-26 11:54:21 +08:00
|
|
|
#include "ustring.h"
|
2014-02-27 17:14:41 +08:00
|
|
|
#include "types.h"
|
|
|
|
#include "ffs.h"
|
|
|
|
|
2016-06-26 11:54:21 +08:00
|
|
|
UString regionTypeToUString(const UINT8 type)
|
2014-02-27 17:14:41 +08:00
|
|
|
{
|
2016-06-26 11:54:21 +08:00
|
|
|
switch (type) {
|
|
|
|
case Subtypes::DescriptorRegion: return UString("Descriptor");
|
|
|
|
case Subtypes::BiosRegion: return UString("BIOS");
|
|
|
|
case Subtypes::MeRegion: return UString("ME");
|
|
|
|
case Subtypes::GbeRegion: return UString("GbE");
|
|
|
|
case Subtypes::PdrRegion: return UString("PDR");
|
|
|
|
case Subtypes::Reserved1Region: return UString("Reserved1");
|
|
|
|
case Subtypes::Reserved2Region: return UString("Reserved2");
|
|
|
|
case Subtypes::Reserved3Region: return UString("Reserved3");
|
|
|
|
case Subtypes::EcRegion: return UString("EC");
|
|
|
|
case Subtypes::Reserved4Region: return UString("Reserved4");
|
2014-02-27 17:14:41 +08:00
|
|
|
};
|
2016-04-17 07:48:07 +08:00
|
|
|
|
2016-06-26 11:54:21 +08:00
|
|
|
return UString("Unknown");
|
2014-02-27 17:14:41 +08:00
|
|
|
}
|
|
|
|
|
2016-06-26 11:54:21 +08:00
|
|
|
UString itemTypeToUString(const UINT8 type)
|
2014-02-27 17:14:41 +08:00
|
|
|
{
|
|
|
|
switch (type) {
|
2016-06-26 11:54:21 +08:00
|
|
|
case Types::Root: return UString("Root");
|
|
|
|
case Types::Image: return UString("Image");
|
|
|
|
case Types::Capsule: return UString("Capsule");
|
|
|
|
case Types::Region: return UString("Region");
|
|
|
|
case Types::Volume: return UString("Volume");
|
|
|
|
case Types::Padding: return UString("Padding");
|
|
|
|
case Types::File: return UString("File");
|
|
|
|
case Types::Section: return UString("Section");
|
|
|
|
case Types::FreeSpace: return UString("Free space");
|
|
|
|
case Types::VssStore: return UString("VSS store");
|
|
|
|
case Types::FtwStore: return UString("FTW store");
|
|
|
|
case Types::FdcStore: return UString("FDC store");
|
|
|
|
case Types::FsysStore: return UString("Fsys store");
|
|
|
|
case Types::EvsaStore: return UString("EVSA store");
|
|
|
|
case Types::CmdbStore: return UString("CMDB store");
|
|
|
|
case Types::FlashMapStore: return UString("FlashMap store");
|
|
|
|
case Types::NvarEntry: return UString("NVAR entry");
|
|
|
|
case Types::VssEntry: return UString("VSS entry");
|
|
|
|
case Types::FsysEntry: return UString("Fsys entry");
|
|
|
|
case Types::EvsaEntry: return UString("EVSA entry");
|
|
|
|
case Types::FlashMapEntry: return UString("FlashMap entry");
|
|
|
|
case Types::Microcode: return UString("Microcode");
|
|
|
|
case Types::SlicData: return UString("SLIC data");
|
2014-02-27 17:14:41 +08:00
|
|
|
}
|
2016-04-17 07:48:07 +08:00
|
|
|
|
2016-06-26 11:54:21 +08:00
|
|
|
return UString("Unknown");
|
2014-02-27 17:14:41 +08:00
|
|
|
}
|
|
|
|
|
2016-06-26 11:54:21 +08:00
|
|
|
UString itemSubtypeToUString(const UINT8 type, const UINT8 subtype)
|
2014-02-27 17:14:41 +08:00
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case Types::Root:
|
2016-04-15 02:36:59 +08:00
|
|
|
case Types::FreeSpace:
|
2016-04-17 07:25:44 +08:00
|
|
|
case Types::VssStore:
|
|
|
|
case Types::FdcStore:
|
|
|
|
case Types::FsysStore:
|
|
|
|
case Types::EvsaStore:
|
|
|
|
case Types::FtwStore:
|
|
|
|
case Types::FlashMapStore:
|
|
|
|
case Types::CmdbStore:
|
|
|
|
case Types::FsysEntry:
|
2016-06-26 11:54:21 +08:00
|
|
|
case Types::SlicData: return UString();
|
2014-02-27 17:14:41 +08:00
|
|
|
case Types::Image:
|
2016-06-26 11:54:21 +08:00
|
|
|
if (subtype == Subtypes::IntelImage) return UString("Intel");
|
|
|
|
if (subtype == Subtypes::UefiImage) return UString("UEFI");
|
2016-04-15 02:36:59 +08:00
|
|
|
break;
|
2014-02-27 17:14:41 +08:00
|
|
|
case Types::Padding:
|
2016-06-26 11:54:21 +08:00
|
|
|
if (subtype == Subtypes::ZeroPadding) return UString("Empty (0x00)");
|
|
|
|
if (subtype == Subtypes::OnePadding) return UString("Empty (0xFF)");
|
|
|
|
if (subtype == Subtypes::DataPadding) return UString("Non-empty");
|
2016-04-15 02:36:59 +08:00
|
|
|
break;
|
2015-02-06 16:47:19 +08:00
|
|
|
case Types::Volume:
|
2016-06-26 11:54:21 +08:00
|
|
|
if (subtype == Subtypes::UnknownVolume) return UString("Unknown");
|
|
|
|
if (subtype == Subtypes::Ffs2Volume) return UString("FFSv2");
|
|
|
|
if (subtype == Subtypes::Ffs3Volume) return UString("FFSv3");
|
|
|
|
if (subtype == Subtypes::NvramVolume) return UString("NVRAM");
|
2016-04-15 02:36:59 +08:00
|
|
|
break;
|
2015-02-06 16:47:19 +08:00
|
|
|
case Types::Capsule:
|
2016-06-26 11:54:21 +08:00
|
|
|
if (subtype == Subtypes::AptioSignedCapsule) return UString("Aptio signed");
|
|
|
|
if (subtype == Subtypes::AptioUnsignedCapsule) return UString("Aptio unsigned");
|
|
|
|
if (subtype == Subtypes::UefiCapsule) return UString("UEFI 2.0");
|
|
|
|
if (subtype == Subtypes::ToshibaCapsule) return UString("Toshiba");
|
2016-04-15 02:36:59 +08:00
|
|
|
break;
|
2016-06-26 11:54:21 +08:00
|
|
|
case Types::Region: return regionTypeToUString(subtype);
|
|
|
|
case Types::File: return fileTypeToUString(subtype);
|
|
|
|
case Types::Section: return sectionTypeToUString(subtype);
|
2016-04-17 07:25:44 +08:00
|
|
|
case Types::NvarEntry:
|
2016-06-26 11:54:21 +08:00
|
|
|
if (subtype == Subtypes::InvalidNvarEntry) return UString("Invalid");
|
|
|
|
if (subtype == Subtypes::InvalidLinkNvarEntry) return UString("Invalid link");
|
|
|
|
if (subtype == Subtypes::LinkNvarEntry) return UString("Link");
|
|
|
|
if (subtype == Subtypes::DataNvarEntry) return UString("Data");
|
|
|
|
if (subtype == Subtypes::FullNvarEntry) return UString("Full");
|
2016-04-15 02:36:59 +08:00
|
|
|
break;
|
2016-04-17 07:25:44 +08:00
|
|
|
case Types::VssEntry:
|
2016-06-26 11:54:21 +08:00
|
|
|
if (subtype == Subtypes::InvalidVssEntry) return UString("Invalid");
|
|
|
|
if (subtype == Subtypes::StandardVssEntry) return UString("Standard");
|
|
|
|
if (subtype == Subtypes::AppleVssEntry) return UString("Apple");
|
|
|
|
if (subtype == Subtypes::AuthVssEntry) return UString("Auth");
|
2016-04-15 02:36:59 +08:00
|
|
|
break;
|
2016-04-17 07:25:44 +08:00
|
|
|
case Types::EvsaEntry:
|
2016-06-26 11:54:21 +08:00
|
|
|
if (subtype == Subtypes::InvalidEvsaEntry) return UString("Invalid");
|
|
|
|
if (subtype == Subtypes::UnknownEvsaEntry) return UString("Unknown");
|
|
|
|
if (subtype == Subtypes::GuidEvsaEntry) return UString("GUID");
|
|
|
|
if (subtype == Subtypes::NameEvsaEntry) return UString("Name");
|
|
|
|
if (subtype == Subtypes::DataEvsaEntry) return UString("Data");
|
2016-04-15 02:36:59 +08:00
|
|
|
break;
|
2016-04-17 07:25:44 +08:00
|
|
|
case Types::FlashMapEntry:
|
2016-06-26 11:54:21 +08:00
|
|
|
if (subtype == Subtypes::VolumeFlashMapEntry) return UString("Volume");
|
|
|
|
if (subtype == Subtypes::DataFlashMapEntry) return UString("Data");
|
2016-04-15 02:36:59 +08:00
|
|
|
break;
|
|
|
|
case Types::Microcode:
|
2016-06-26 11:54:21 +08:00
|
|
|
if (subtype == Subtypes::IntelMicrocode) return UString("Intel");
|
|
|
|
if (subtype == Subtypes::AmdMicrocode) return UString("AMD");
|
2016-04-15 02:36:59 +08:00
|
|
|
break;
|
2014-02-27 17:14:41 +08:00
|
|
|
}
|
2016-04-17 07:48:07 +08:00
|
|
|
|
2016-06-26 11:54:21 +08:00
|
|
|
return UString("Unknown");
|
2014-02-27 17:14:41 +08:00
|
|
|
}
|
|
|
|
|
2016-06-26 11:54:21 +08:00
|
|
|
UString compressionTypeToUString(const UINT8 algorithm)
|
2014-02-27 17:14:41 +08:00
|
|
|
{
|
|
|
|
switch (algorithm) {
|
2016-06-26 11:54:21 +08:00
|
|
|
case COMPRESSION_ALGORITHM_NONE: return UString("None");
|
|
|
|
case COMPRESSION_ALGORITHM_EFI11: return UString("EFI 1.1");
|
|
|
|
case COMPRESSION_ALGORITHM_TIANO: return UString("Tiano");
|
|
|
|
case COMPRESSION_ALGORITHM_UNDECIDED: return UString("Undecided Tiano/EFI 1.1");
|
|
|
|
case COMPRESSION_ALGORITHM_LZMA: return UString("LZMA");
|
|
|
|
case COMPRESSION_ALGORITHM_IMLZMA: return UString("Intel modified LZMA");
|
2014-02-27 17:14:41 +08:00
|
|
|
}
|
2016-04-17 07:25:44 +08:00
|
|
|
|
2016-06-26 11:54:21 +08:00
|
|
|
return UString("Unknown");
|
2014-02-27 17:14:41 +08:00
|
|
|
}
|
|
|
|
|
2016-06-26 11:54:21 +08:00
|
|
|
UString actionTypeToUString(const UINT8 action)
|
2014-02-27 17:14:41 +08:00
|
|
|
{
|
|
|
|
switch (action) {
|
2016-06-26 11:54:21 +08:00
|
|
|
case Actions::NoAction: return UString();
|
|
|
|
case Actions::Create: return UString("Create");
|
|
|
|
case Actions::Insert: return UString("Insert");
|
|
|
|
case Actions::Replace: return UString("Replace");
|
|
|
|
case Actions::Remove: return UString("Remove");
|
|
|
|
case Actions::Rebuild: return UString("Rebuild");
|
|
|
|
case Actions::Rebase: return UString("Rebase");
|
2014-02-27 17:14:41 +08:00
|
|
|
}
|
2016-04-17 07:48:07 +08:00
|
|
|
|
2016-06-26 11:54:21 +08:00
|
|
|
return UString("Unknown");
|
2014-07-25 07:59:51 +08:00
|
|
|
}
|