## @file
#
# This package manage the VPD PCD information file which will be generated
# by build tool's autogen.
# The VPD PCD information file will be input for third-party BPDG tool which
# is pointed by *_*_*_VPD_TOOL_GUID in conf/tools_def.txt
#
#
# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
# 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
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
import os
import re
import subprocess
"""
## @file
#
# THIS IS AUTO-GENERATED FILE BY BUILD TOOLS AND PLEASE DO NOT MAKE MODIFICATION.
#
# This file lists all VPD informations for a platform collected by build.exe.
#
# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
# 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
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
"""
## The class manage VpdInfoFile.
#
# This file contains an ordered (based on position in the DSC file) list of the PCDs specified in the platform description file (DSC). The Value field that will be assigned to the PCD comes from the DSC file, INF file (if not defined in the DSC file) or the DEC file (if not defined in the INF file). This file is used as an input to the BPDG tool.
# Format for this file (using EBNF notation) is:
# <File> :: = [<CommentBlock>]
# [<PcdEntry>]*
# <CommentBlock> ::= ["#" <String> <EOL>]*
# <PcdEntry> ::= <PcdName> "|" <Offset> "|" <Size> "|" <Value> <EOL>
# <PcdName> ::= <TokenSpaceCName> "." <PcdCName>
# <TokenSpaceCName> ::= C Variable Name of the Token Space GUID
# <PcdCName> ::= C Variable Name of the PCD
# <Offset> ::= {"*"} {<HexNumber>}
# <HexNumber> ::= "0x" (a-fA-F0-9){1,8}
# <Size> ::= <HexNumber>
# <Value> ::= {<HexNumber>} {<NonNegativeInt>} {<QString>} {<Array>}
# <NonNegativeInt> ::= (0-9)+
# <QString> ::= ["L"] <DblQuote> <String> <DblQuote>
# <DblQuote> ::= 0x22
# <Array> ::= {<CArray>} {<NList>}
# <CArray> ::= "{" <HexNumber> ["," <HexNumber>]* "}"
# <NList> ::= <HexNumber> ["," <HexNumber>]*
#
class VpdInfoFile:
## The mapping dictionary from datum type to size string.
_rVpdPcdLine = None
## Constructor
## Dictionary for VPD in following format
#
# Key : PcdClassObject instance.
# @see BuildClassObject.PcdClassObject
# Value : offset in different SKU such as [sku1_offset, sku2_offset]
## Add a VPD PCD collected from platform's autogen when building.
#
# @param vpds The list of VPD PCD collected for a platform.
# @see BuildClassObject.PcdClassObject
#
# @param offset integer value for VPD's offset in specific SKU.
#
if (Vpd == None):
EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID, "Invalid offset parameter: %s." % Offset)
else:
"Invalid DatumType %s for VPD PCD %s.%s" % (Vpd.DatumType, Vpd.TokenSpaceGuidCName, Vpd.TokenCName))
#
# If there is no Vpd instance in dict, that imply this offset for a given SKU is a new one
#
else:
#
# If there is an offset for a specific SKU in dict, then append this offset for other sku to array.
#
## Generate VPD PCD information into a text file
#
# If parameter FilePath is invalid, then assert.
# If
# @param FilePath The given file path which would hold VPD information
"Invalid parameter FilePath: %s." % FilePath)
try:
except:
"Fail to open file %s for written." % FilePath)
try:
# write file header
# write each of PCD in VPD type
if PcdValue == "" :
fd.write("%s.%s|%s|%s|%s \n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, str(Offset).strip(), str(Pcd.MaxDatumSize).strip(),PcdValue))
except:
"Fail to write file %s" % FilePath)
## Read an existing VPD PCD info file.
#
# This routine will read VPD PCD information from existing file and construct
# internal PcdClassObject array.
# This routine could be used by third-party tool to parse VPD info file content.
#
# @param FilePath The full path string for existing VPD PCD info file.
try:
except:
"Fail to open file %s for written." % FilePath)
continue
#
# the line must follow output format defined in BPDG spec.
#
try:
except:
EdkLogger.error("BPDG", BuildToolError.PARSER_ERROR, "Fail to parse VPD information file %s" % FilePath)
if VpdObject.TokenSpaceGuidCName == TokenSpaceName and VpdObject.TokenCName == PcdTokenName.strip():
if Offset == "*":
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "The offset of %s has not been fixed up by third-party BPDG tool." % PcdName)
break
if not Found:
## Get count of VPD PCD collected from platform's autogen when building.
#
# @return The integer count value
Count = 0
return Count
## Get an offset value for a given VPD PCD
#
# Because BPDG only support one Sku, so only return offset for SKU default.
#
# @param vpd A given VPD PCD
return None
return None
## Call external BPDG tool to process VPD file
#
# @param ToolPath The string path name for BPDG tool
# @param VpdFileName The string path name for VPD information guid.txt
#
assert ToolPath != None, "Invalid parameter ToolPath"
try:
'-o', OutputBinFileName,
'-m', OutputMapFileName,
'-q',
'-f',
except Exception, X:
print out
while PopenObject.returncode == None :
EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, "Fail to execute BPDG tool with exit code: %d, the error message is: \n %s" % \
return PopenObject.returncode