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>
This commit is contained in:
@ -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):
|
||||
|
Reference in New Issue
Block a user