]>
Commit | Line | Data |
---|---|---|
30fdf114 LG |
1 | ## @file\r |
2 | # process OptionROM generation\r | |
3 | #\r | |
1be2ed90 | 4 | # Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r |
30fdf114 | 5 | #\r |
40d841f6 | 6 | # This program and the accompanying materials\r |
30fdf114 LG |
7 | # are licensed and made available under the terms and conditions of the BSD License\r |
8 | # which accompanies this distribution. The full text of the license may be found at\r | |
9 | # http://opensource.org/licenses/bsd-license.php\r | |
10 | #\r | |
11 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | #\r | |
14 | \r | |
15 | ##\r | |
16 | # Import Modules\r | |
17 | #\r | |
1be2ed90 | 18 | import Common.LongFilePathOs as os\r |
30fdf114 LG |
19 | import subprocess\r |
20 | import StringIO\r | |
21 | \r | |
22 | import OptRomInfStatement\r | |
23 | from GenFdsGlobalVariable import GenFdsGlobalVariable\r | |
24 | from GenFds import GenFds\r | |
25 | from CommonDataClass.FdfClass import OptionRomClassObject\r | |
26 | from Common.Misc import SaveFileOnChange\r | |
27 | from Common import EdkLogger\r | |
28 | from Common.BuildToolError import *\r | |
29 | \r | |
30 | T_CHAR_LF = '\n'\r | |
31 | \r | |
32 | ## \r | |
33 | #\r | |
34 | #\r | |
35 | class OPTIONROM (OptionRomClassObject):\r | |
36 | ## The constructor\r | |
37 | #\r | |
38 | # @param self The object pointer\r | |
39 | #\r | |
40 | def __init__(self):\r | |
41 | OptionRomClassObject.__init__(self)\r | |
42 | \r | |
43 | \r | |
44 | ## AddToBuffer()\r | |
45 | #\r | |
46 | # Generate Option ROM\r | |
47 | #\r | |
48 | # @param self The object pointer\r | |
49 | # @param Buffer The buffer generated OptROM data will be put\r | |
50 | # @retval string Generated OptROM file path\r | |
51 | #\r | |
52 | def AddToBuffer (self, Buffer) :\r | |
53 | \r | |
54 | GenFdsGlobalVariable.InfLogger( "\nGenerating %s Option ROM ..." %self.DriverName)\r | |
55 | \r | |
56 | EfiFileList = []\r | |
57 | BinFileList = []\r | |
58 | \r | |
59 | # Process Modules in FfsList\r | |
60 | for FfsFile in self.FfsList :\r | |
61 | \r | |
62 | if isinstance(FfsFile, OptRomInfStatement.OptRomInfStatement):\r | |
63 | FilePathNameList = FfsFile.GenFfs()\r | |
64 | if len(FilePathNameList) == 0:\r | |
65 | EdkLogger.error("GenFds", GENFDS_ERROR, "Module %s not produce .efi files, so NO file could be put into option ROM." % (FfsFile.InfFileName))\r | |
66 | if FfsFile.OverrideAttribs == None:\r | |
67 | EfiFileList.extend(FilePathNameList)\r | |
68 | else:\r | |
69 | FileName = os.path.basename(FilePathNameList[0])\r | |
70 | TmpOutputDir = os.path.join(GenFdsGlobalVariable.FvDir, self.DriverName)\r | |
71 | if not os.path.exists(TmpOutputDir) :\r | |
72 | os.makedirs(TmpOutputDir)\r | |
73 | TmpOutputFile = os.path.join(TmpOutputDir, FileName+'.tmp')\r | |
74 | \r | |
75 | GenFdsGlobalVariable.GenerateOptionRom(TmpOutputFile, \r | |
76 | FilePathNameList, \r | |
77 | [], \r | |
78 | FfsFile.OverrideAttribs.NeedCompress, \r | |
79 | FfsFile.OverrideAttribs.PciClassCode, \r | |
80 | FfsFile.OverrideAttribs.PciRevision, \r | |
81 | FfsFile.OverrideAttribs.PciDeviceId, \r | |
82 | FfsFile.OverrideAttribs.PciVendorId)\r | |
83 | BinFileList.append(TmpOutputFile)\r | |
84 | else:\r | |
85 | FilePathName = FfsFile.GenFfs()\r | |
86 | if FfsFile.OverrideAttribs != None:\r | |
87 | FileName = os.path.basename(FilePathName)\r | |
88 | TmpOutputDir = os.path.join(GenFdsGlobalVariable.FvDir, self.DriverName)\r | |
89 | if not os.path.exists(TmpOutputDir) :\r | |
90 | os.makedirs(TmpOutputDir)\r | |
91 | TmpOutputFile = os.path.join(TmpOutputDir, FileName+'.tmp')\r | |
92 | \r | |
93 | GenFdsGlobalVariable.GenerateOptionRom(TmpOutputFile, \r | |
94 | [FilePathName], \r | |
95 | [], \r | |
96 | FfsFile.OverrideAttribs.NeedCompress, \r | |
97 | FfsFile.OverrideAttribs.PciClassCode, \r | |
98 | FfsFile.OverrideAttribs.PciRevision, \r | |
99 | FfsFile.OverrideAttribs.PciDeviceId, \r | |
100 | FfsFile.OverrideAttribs.PciVendorId)\r | |
101 | BinFileList.append(TmpOutputFile)\r | |
102 | else:\r | |
103 | if FfsFile.FileType == 'EFI':\r | |
104 | EfiFileList.append(FilePathName)\r | |
105 | else:\r | |
106 | BinFileList.append(FilePathName)\r | |
107 | \r | |
108 | #\r | |
109 | # Call EfiRom tool\r | |
110 | #\r | |
111 | OutputFile = os.path.join(GenFdsGlobalVariable.FvDir, self.DriverName)\r | |
112 | OutputFile = OutputFile + '.rom'\r | |
113 | \r | |
114 | GenFdsGlobalVariable.GenerateOptionRom(\r | |
115 | OutputFile,\r | |
116 | EfiFileList,\r | |
117 | BinFileList\r | |
118 | )\r | |
119 | \r | |
120 | GenFdsGlobalVariable.InfLogger( "\nGenerate %s Option ROM Successfully" %self.DriverName)\r | |
121 | GenFdsGlobalVariable.SharpCounter = 0\r | |
122 | \r | |
123 | return OutputFile\r | |
124 | \r | |
125 | class OverrideAttribs:\r | |
126 | \r | |
127 | ## The constructor\r | |
128 | #\r | |
129 | # @param self The object pointer\r | |
130 | #\r | |
131 | def __init__(self):\r | |
132 | \r | |
133 | self.PciVendorId = None\r | |
134 | self.PciClassCode = None\r | |
135 | self.PciDeviceId = None\r | |
136 | self.PciRevision = None\r | |
fd171542 | 137 | self.NeedCompress = None\r |
30fdf114 LG |
138 | \r |
139 |