Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Tomas Pilar <tpi...@solarflare.com>
---
 .../Source/Python/Capsule/GenerateCapsule.py  | 25 ++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/Python/Capsule/GenerateCapsule.py 
b/BaseTools/Source/Python/Capsule/GenerateCapsule.py
index 7b08918857..4b275b092b 100644
--- a/BaseTools/Source/Python/Capsule/GenerateCapsule.py
+++ b/BaseTools/Source/Python/Capsule/GenerateCapsule.py
@@ -9,8 +9,7 @@
 # system firmware or device firmware for integrated devices.  In order to
 # keep the tool as simple as possible, it has the following limitations:
 #   * Do not support multiple payloads in a capsule.
-#   * Do not support optional drivers in a capsule.
-#   * Do not support vendor code bytes in a capsule.
+#   * Support at most one optional driver in a capsule.
 #
 # Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
 # This program and the accompanying materials
@@ -236,6 +235,12 @@ if __name__ == '__main__':
                         help = "Input binary payload filename.")
     parser.add_argument("-o", "--output", dest = 'OutputFile', type = 
argparse.FileType('wb'),
                         help = "Output filename.")
+
+    #
+    # Add optional embedded driver and vendor code arguments
+    #
+    parser.add_argument("--driver", dest = 'Driver', type = 
argparse.FileType('rb'),
+                        help = "Input binary embedded driver to package 
alongside the image")
     #
     # Add group for -e and -d flags that are mutually exclusive and required
     #
@@ -355,7 +360,7 @@ if __name__ == '__main__':
             parser.error ('the following option is not supported for dumpinfo 
operations: --output')
 
     #
-    # Read binary input file
+    # Read binary input files
     #
     try:
         if args.Verbose:
@@ -366,6 +371,17 @@ if __name__ == '__main__':
         print ('GenerateCapsule: error: can not read binary input file 
{File}'.format (File = args.InputFile.name))
         sys.exit (1)
 
+    DriverBuffer = b''
+    if args.Driver:
+        try:
+            if args.Verbose:
+                print ('Read binary embedded driver {File}'.format (File = 
args.Driver.name))
+            DriverBuffer = args.Driver.read ()
+            args.Driver.close ()
+        except:
+            print ('GenerateCapsule: error: can not read supplied binary 
embedded driver file {File}'.format (File = args.Driver.name))
+            sys.exit (1)
+
     #
     # Create objects
     #
@@ -423,6 +439,9 @@ if __name__ == '__main__':
 
         try:
             FmpCapsuleHeader.AddPayload (args.Guid, Result, HardwareInstance = 
args.HardwareInstance)
+            if args.Driver:
+                FmpCapsuleHeader.AddEmbeddedDriver(DriverBuffer)
+
             Result = FmpCapsuleHeader.Encode ()
             if args.Verbose:
                 FmpCapsuleHeader.DumpInfo ()
-- 
2.17.2

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to