Skip to content

Commit

Permalink
Add helpers to format DP type and subtype to str
Browse files Browse the repository at this point in the history
  • Loading branch information
Inokinoki committed Apr 10, 2022
1 parent 1760ac5 commit 51afa0d
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ set(PROJECT_SOURCES
qefientry.h
qefientrystaticlist.cpp
qefientrystaticlist.h
helpers.cpp
helpers.h
qefivar/qefi.cpp
)

Expand Down
146 changes: 146 additions & 0 deletions helpers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
#include "helpers.h"

// Helpers to convert device path to string
QString convert_device_path_subtype_to_name(
QEFIDevicePathType type, quint8 subtype)
{
switch (type)
{
case QEFIDevicePathType::DP_Hardware:
switch (subtype) {
case QEFIDevicePathHardwareSubType::HW_PCI:
return "PCI";
case QEFIDevicePathHardwareSubType::HW_PCCard:
return "PCCard";
case QEFIDevicePathHardwareSubType::HW_MMIO:
return "MMIO";
case QEFIDevicePathHardwareSubType::HW_Vendor:
return "Vendor";
case QEFIDevicePathHardwareSubType::HW_Controller:
return "Controller";
case QEFIDevicePathHardwareSubType::HW_BMC:
return "BMC";
}
break;
case QEFIDevicePathType::DP_ACPI:
switch (subtype) {
case QEFIDevicePathACPISubType::ACPI_HID:
return "HID";
case QEFIDevicePathACPISubType::ACPI_HIDEX:
return "HIDEX";
case QEFIDevicePathACPISubType::ACPI_ADR:
return "ADR";
}
break;
case QEFIDevicePathType::DP_Message:
switch (subtype) {
case QEFIDevicePathMessageSubType::MSG_ATAPI:
return "ATAPI";
case QEFIDevicePathMessageSubType::MSG_SCSI:
return "SCSI";
case QEFIDevicePathMessageSubType::MSG_FibreChan:
return "Fibre Channel";
case QEFIDevicePathMessageSubType::MSG_1394:
return "1394";
case QEFIDevicePathMessageSubType::MSG_USB:
return "USB";
case QEFIDevicePathMessageSubType::MSG_I2O:
return "I2O";
case QEFIDevicePathMessageSubType::MSG_InfiniBand:
return "Inifiband";
case QEFIDevicePathMessageSubType::MSG_Vendor:
return "Vendor";
case QEFIDevicePathMessageSubType::MSG_MACAddr:
return "MAC";
case QEFIDevicePathMessageSubType::MSG_IPv4:
return "IPv4";
case QEFIDevicePathMessageSubType::MSG_IPv6:
return "IPv6";
case QEFIDevicePathMessageSubType::MSG_UART:
return "UART";
case QEFIDevicePathMessageSubType::MSG_USBClass:
return "USB Class";

case QEFIDevicePathMessageSubType::MSG_USBWWID:
return "USB WWID";

case QEFIDevicePathMessageSubType::MSG_LUN:
return "LUN";
case QEFIDevicePathMessageSubType::MSG_SATA:
return "SATA";
case QEFIDevicePathMessageSubType::MSG_ISCSI:
return "ISCSI";
case QEFIDevicePathMessageSubType::MSG_VLAN:
return "VLAN";

case QEFIDevicePathMessageSubType::MSG_FibreChanEx:
return "Fibre Channel Ex";
case QEFIDevicePathMessageSubType::MSG_SASEX:
return "SAS Ex";

case QEFIDevicePathMessageSubType::MSG_NVME:
return "NVME";
case QEFIDevicePathMessageSubType::MSG_URI:
return "URI";
case QEFIDevicePathMessageSubType::MSG_UFS:
return "UFS";
case QEFIDevicePathMessageSubType::MSG_SD:
return "SD";
case QEFIDevicePathMessageSubType::MSG_BT:
return "Bluetooth";
case QEFIDevicePathMessageSubType::MSG_WiFi:
return "WiFi";
case QEFIDevicePathMessageSubType::MSG_EMMC:
return "EMMC";
case QEFIDevicePathMessageSubType::MSG_BTLE:
return "BLE";
case QEFIDevicePathMessageSubType::MSG_DNS:
return "DNS";
case QEFIDevicePathMessageSubType::MSG_NVDIMM:
return "NVDIMM";
}
break;
case QEFIDevicePathType::DP_Media:
switch (subtype) {
case QEFIDevicePathMediaSubType::MEDIA_HD:
return "HD";
case QEFIDevicePathMediaSubType::MEDIA_File:
return "File";
case QEFIDevicePathMediaSubType::MEDIA_CDROM:
return "CDROM";
case QEFIDevicePathMediaSubType::MEDIA_Vendor:
return "Vendor";
case QEFIDevicePathMediaSubType::MEDIA_Protocol:
return "Protocol";
case QEFIDevicePathMediaSubType::MEDIA_FirmwareFile:
return "Firmware file";
case QEFIDevicePathMediaSubType::MEDIA_FirmwareVolume:
return "FV";
case QEFIDevicePathMediaSubType::MEDIA_RelativeOffset:
return "Relative offset";
case QEFIDevicePathMediaSubType::MEDIA_RamDisk:
return "RAMDisk";
}
case QEFIDevicePathType::DP_BIOSBoot:
return "Boot";
}
return "Unknown";
}

QString convert_device_path_type_to_name(QEFIDevicePathType type)
{
switch (type)
{
case DP_Hardware:
return "Hardware";
case DP_ACPI:
return "ACPI";
case DP_Message:
return "Message";
case DP_Media:
return "Media";
case DP_BIOSBoot:
return "BIOS";
}
return "Unknown";
}
9 changes: 9 additions & 0 deletions helpers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef HELPERS_H
#define HELPERS_H

#include <qefi.h>

QString convert_device_path_type_to_name(QEFIDevicePathType type);
QString convert_device_path_subtype_to_name(QEFIDevicePathType type, quint8 subtype);

#endif // HELPERS_H
9 changes: 6 additions & 3 deletions qefientrydetailview.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "qefientrydetailview.h"
#include "helpers.h"

QEFIEntryDetailView::QEFIEntryDetailView(QEFIEntry &entry, QWidget *parent)
: QWidget(parent), m_entry(entry)
Expand All @@ -18,10 +19,12 @@ QEFIEntryDetailView::QEFIEntryDetailView(QEFIEntry &entry, QWidget *parent)
new QLabel(QString::number(dpList.size())));
// TODO: Add a tab to display each DP
for (int i = 0; i < dpList.size(); i++) {
// TODO: Replace by name
// Display type name
m_briefLayout->addRow(QString::asprintf("Device Path %d type:", i + 1),
new QLabel(QString::asprintf("%02X %02X",
dpList[i]->type(), dpList[i]->subType())));
new QLabel(
convert_device_path_type_to_name(dpList[i]->type()) + " " +
convert_device_path_subtype_to_name(dpList[i]->type(),
dpList[i]->subType())));
}
} else {
m_briefLayout->addRow("Device Path instance:",
Expand Down

0 comments on commit 51afa0d

Please sign in to comment.