summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/Common/Misc.py
diff options
context:
space:
mode:
authorYonghong Zhu <yonghong.zhu@intel.com>2017-12-27 14:12:29 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2017-12-31 13:10:49 +0800
commit7dbc50bd244d95fdc1741b9cfc561f0bfd724de1 (patch)
tree7f317c3cd6f55654c41e88a39ae76881844f61c6 /BaseTools/Source/Python/Common/Misc.py
parentf13f306b3b07330191ba4620e49c2a9151b8e575 (diff)
downloadedk2-7dbc50bd244d95fdc1741b9cfc561f0bfd724de1.tar.gz
edk2-7dbc50bd244d95fdc1741b9cfc561f0bfd724de1.tar.bz2
edk2-7dbc50bd244d95fdc1741b9cfc561f0bfd724de1.zip
BaseTools: Add DevicePath support for PCD values
Use C code parse device path to output hex string, and Python run command when PCD Value need device path parse. https://bugzilla.tianocore.org/show_bug.cgi?id=541 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com> Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/Common/Misc.py')
-rw-r--r--BaseTools/Source/Python/Common/Misc.py34
1 files changed, 32 insertions, 2 deletions
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 59d1ba2639..15ad9e4f2e 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -38,7 +38,7 @@ from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.MultipleWorkspace import MultipleWorkspace as mws
import uuid
from CommonDataClass.Exceptions import BadExpression
-
+import subprocess
## Regular expression used to find out place holders in string template
gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE | re.UNICODE)
@@ -1474,7 +1474,37 @@ def AnalyzePcdExpression(Setting):
return FieldList
def ParseDevPathValue (Value):
- pass
+ DevPathList = [ "Path","HardwarePath","Pci","PcCard","MemoryMapped","VenHw","Ctrl","BMC","AcpiPath","Acpi","PciRoot",
+ "PcieRoot","Floppy","Keyboard","Serial","ParallelPort","AcpiEx","AcpiExp","AcpiAdr","Msg","Ata","Scsi",
+ "Fibre","FibreEx","I1394","USB","I2O","Infiniband","VenMsg","VenPcAnsi","VenVt100","VenVt100Plus",
+ "VenUtf8","UartFlowCtrl","SAS","SasEx","NVMe","UFS","SD","eMMC","DebugPort","MAC","IPv4","IPv6","Uart",
+ "UsbClass","UsbAudio","UsbCDCControl","UsbHID","UsbImage","UsbPrinter","UsbMassStorage","UsbHub",
+ "UsbCDCData","UsbSmartCard","UsbVideo","UsbDiagnostic","UsbWireless","UsbDeviceFirmwareUpdate",
+ "UsbIrdaBridge","UsbTestAndMeasurement","UsbWwid","Unit","iSCSI","Vlan","Uri","Bluetooth","Wi-Fi",
+ "MediaPath","HD","CDROM","VenMedia","Media","Fv","FvFile","Offset","RamDisk","VirtualDisk","VirtualCD",
+ "PersistentVirtualDisk","PersistentVirtualCD","BbsPath","BBS","Sata" ]
+ if '\\' in Value:
+ Value.replace('\\', '/').replace(' ', '')
+ for Item in Value.split('/'):
+ Key = Item.strip().split('(')[0]
+ if Key not in DevPathList:
+ pass
+
+ Cmd = 'DevicePath ' + '"' + Value + '"'
+ try:
+ p = subprocess.Popen(Cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
+ out, err = p.communicate()
+ except Exception, X:
+ raise BadExpression("DevicePath: %s" % (str(X)) )
+ finally:
+ subprocess._cleanup()
+ p.stdout.close()
+ p.stderr.close()
+ if err:
+ raise BadExpression("DevicePath: %s" % str(err))
+ Size = len(out.split())
+ out = ','.join(out.split())
+ return '{' + out + '}', Size
def ParseFieldValue (Value):
if type(Value) == type(0):