- if args.MaxSize is None:\r
- #\r
- # If --max-size is not provided, then do not generate the syntax that\r
- # includes the maximum size.\r
- #\r
- Pcd = ' %s|%s' % (args.PcdName, ByteArray (Buffer))\r
- elif args.MaxSize < len(Buffer):\r
- print 'BinToPcd: error: argument --max-size is smaller than input file.'\r
- sys.exit()\r
- else:\r
- Pcd = ' %s|%s|VOID*|%d' % (args.PcdName, ByteArray (Buffer), args.MaxSize)\r
- args.MaxSize = len(Buffer)\r
- \r
- if args.Verbose:\r
- print 'PcdToBin: Convert binary file to PCD statement compatible with PCD sections:'\r
- print ' [PcdsFixedAtBuild]'\r
- print ' [PcdsPatchableInModule]'\r
- print ' [PcdsDynamicDefault]'\r
- print ' [PcdsDynamicExDefault]'\r
- elif args.PcdType == 'VPD':\r
- if args.MaxSize is None:\r
- #\r
- # If --max-size is not provided, then set maximum size to the size of the\r
- # binary input file\r
- #\r
- args.MaxSize = len(Buffer)\r
- if args.MaxSize < len(Buffer):\r
- print 'BinToPcd: error: argument --max-size is smaller than input file.'\r
- sys.exit()\r
- if args.Offset is None:\r
- #\r
- # if --offset is not provided, then set offset field to '*' so build\r
- # tools will compute offset of PCD in VPD region.\r
- #\r
- Pcd = ' %s|*|%d|%s' % (args.PcdName, args.MaxSize, ByteArray (Buffer))\r
- else:\r
- #\r
- # Use the --offset value provided.\r
- #\r
- Pcd = ' %s|%d|%d|%s' % (args.PcdName, args.Offset, args.MaxSize, ByteArray (Buffer))\r
- if args.Verbose:\r
- print 'PcdToBin: Convert binary file to PCD statement compatible with PCD sections'\r
- print ' [PcdsDynamicVpd]'\r
- print ' [PcdsDynamicExVpd]'\r
- elif args.PcdType == 'HII':\r
- if args.VariableGuid is None:\r
- print 'BinToPcd: error: argument --variable-guid is required for --type HII.'\r
- sys.exit()\r
- if args.VariableName is None:\r
- print 'BinToPcd: error: argument --variable-name is required for --type HII.'\r
- sys.exit()\r
- if args.Offset is None:\r
- #\r
- # Use UEFI Variable offset of 0 if --offset is not provided\r
- #\r
- args.Offset = 0\r
- Pcd = ' %s|L"%s"|%s|%d|%s' % (args.PcdName, args.VariableName, args.VariableGuid, args.Offset, ByteArray (Buffer))\r
- if args.Verbose:\r
- print 'PcdToBin: Convert binary file to PCD statement compatible with PCD sections'\r
- print ' [PcdsDynamicHii]'\r
- print ' [PcdsDynamicExHii]'\r
+ if args.PcdName is None:\r
+ #\r
+ # If PcdName is None, then only a PCD value is being requested.\r
+ #\r
+ Pcd = PcdValue\r
+ if args.Verbose:\r
+ print ('BinToPcd: Convert binary file to PCD Value')\r
+ elif args.PcdType is None:\r
+ #\r
+ # If --type is neither VPD nor HII, then use PCD statement syntax that is\r
+ # compatible with [PcdsFixedAtBuild], [PcdsPatchableInModule],\r
+ # [PcdsDynamicDefault], and [PcdsDynamicExDefault].\r
+ #\r
+ if args.MaxSize is None:\r
+ #\r
+ # If --max-size is not provided, then do not generate the syntax that\r
+ # includes the maximum size.\r
+ #\r
+ Pcd = ' {Name}|{Value}'.format (Name = args.PcdName, Value = PcdValue)\r
+ elif args.MaxSize < PcdSize:\r
+ print ('BinToPcd: error: argument --max-size is smaller than input file.')\r
+ sys.exit (1)\r
+ else:\r
+ Pcd = ' {Name}|{Value}|VOID*|{Size}'.format (Name = args.PcdName, Value = PcdValue, Size = args.MaxSize)\r
+\r
+ if args.Verbose:\r
+ print ('BinToPcd: Convert binary file to PCD statement compatible with PCD sections:')\r
+ print (' [PcdsFixedAtBuild]')\r
+ print (' [PcdsPatchableInModule]')\r
+ print (' [PcdsDynamicDefault]')\r
+ print (' [PcdsDynamicExDefault]')\r
+ elif args.PcdType == 'VPD':\r
+ if args.MaxSize is None:\r
+ #\r
+ # If --max-size is not provided, then set maximum size to the size of the\r
+ # binary input file\r
+ #\r
+ args.MaxSize = PcdSize\r
+ if args.MaxSize < PcdSize:\r
+ print ('BinToPcd: error: argument --max-size is smaller than input file.')\r
+ sys.exit (1)\r
+ if args.Offset is None:\r
+ #\r
+ # if --offset is not provided, then set offset field to '*' so build\r
+ # tools will compute offset of PCD in VPD region.\r
+ #\r
+ Pcd = ' {Name}|*|{Size}|{Value}'.format (Name = args.PcdName, Size = args.MaxSize, Value = PcdValue)\r
+ else:\r
+ #\r
+ # --offset value must be 8-byte aligned\r
+ #\r
+ if (args.Offset % 8) != 0:\r
+ print ('BinToPcd: error: argument --offset must be 8-byte aligned.')\r
+ sys.exit (1)\r
+ #\r
+ # Use the --offset value provided.\r
+ #\r
+ Pcd = ' {Name}|{Offset}|{Size}|{Value}'.format (Name = args.PcdName, Offset = args.Offset, Size = args.MaxSize, Value = PcdValue)\r
+ if args.Verbose:\r
+ print ('BinToPcd: Convert binary file to PCD statement compatible with PCD sections')\r
+ print (' [PcdsDynamicVpd]')\r
+ print (' [PcdsDynamicExVpd]')\r
+ elif args.PcdType == 'HII':\r
+ if args.VariableGuid is None or args.VariableName is None:\r
+ print ('BinToPcd: error: arguments --variable-guid and --variable-name are required for --type HII.')\r
+ sys.exit (1)\r
+ if args.Offset is None:\r
+ #\r
+ # Use UEFI Variable offset of 0 if --offset is not provided\r
+ #\r
+ args.Offset = 0\r
+ #\r
+ # --offset value must be 8-byte aligned\r
+ #\r
+ if (args.Offset % 8) != 0:\r
+ print ('BinToPcd: error: argument --offset must be 8-byte aligned.')\r
+ sys.exit (1)\r
+ Pcd = ' {Name}|L"{VarName}"|{VarGuid}|{Offset}|{Value}'.format (Name = args.PcdName, VarName = args.VariableName, VarGuid = args.VariableGuid, Offset = args.Offset, Value = PcdValue)\r
+ if args.Verbose:\r
+ print ('BinToPcd: Convert binary file to PCD statement compatible with PCD sections')\r
+ print (' [PcdsDynamicHii]')\r
+ print (' [PcdsDynamicExHii]')\r