]>
Commit | Line | Data |
---|---|---|
1 | ## @file\r | |
2 | # process OptionROM generation\r | |
3 | #\r | |
4 | # Copyright (c) 2007, Intel Corporation\r | |
5 | #\r | |
6 | # All rights reserved. This program and the accompanying materials\r | |
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 | |
18 | import os\r | |
19 | import shutil\r | |
20 | import subprocess\r | |
21 | import StringIO\r | |
22 | \r | |
23 | import OptRomInfStatement\r | |
24 | from GenFdsGlobalVariable import GenFdsGlobalVariable\r | |
25 | from GenFds import GenFds\r | |
26 | from CommonDataClass.FdfClass import OptionRomClassObject\r | |
27 | from Common.Misc import SaveFileOnChange\r | |
28 | from Common import EdkLogger\r | |
29 | from Common.BuildToolError import *\r | |
30 | \r | |
31 | T_CHAR_LF = '\n'\r | |
32 | \r | |
33 | ## \r | |
34 | #\r | |
35 | #\r | |
36 | class OPTIONROM (OptionRomClassObject):\r | |
37 | ## The constructor\r | |
38 | #\r | |
39 | # @param self The object pointer\r | |
40 | #\r | |
41 | def __init__(self):\r | |
42 | OptionRomClassObject.__init__(self)\r | |
43 | \r | |
44 | \r | |
45 | ## AddToBuffer()\r | |
46 | #\r | |
47 | # Generate Option ROM\r | |
48 | #\r | |
49 | # @param self The object pointer\r | |
50 | # @param Buffer The buffer generated OptROM data will be put\r | |
51 | # @retval string Generated OptROM file path\r | |
52 | #\r | |
53 | def AddToBuffer (self, Buffer) :\r | |
54 | \r | |
55 | GenFdsGlobalVariable.InfLogger( "\nGenerating %s Option ROM ..." %self.DriverName)\r | |
56 | \r | |
57 | EfiFileList = []\r | |
58 | BinFileList = []\r | |
59 | \r | |
60 | # Process Modules in FfsList\r | |
61 | for FfsFile in self.FfsList :\r | |
62 | \r | |
63 | if isinstance(FfsFile, OptRomInfStatement.OptRomInfStatement):\r | |
64 | FilePathNameList = FfsFile.GenFfs()\r | |
65 | if len(FilePathNameList) == 0:\r | |
66 | EdkLogger.error("GenFds", GENFDS_ERROR, "Module %s not produce .efi files, so NO file could be put into option ROM." % (FfsFile.InfFileName))\r | |
67 | if FfsFile.OverrideAttribs == None:\r | |
68 | EfiFileList.extend(FilePathNameList)\r | |
69 | else:\r | |
70 | FileName = os.path.basename(FilePathNameList[0])\r | |
71 | TmpOutputDir = os.path.join(GenFdsGlobalVariable.FvDir, self.DriverName)\r | |
72 | if not os.path.exists(TmpOutputDir) :\r | |
73 | os.makedirs(TmpOutputDir)\r | |
74 | TmpOutputFile = os.path.join(TmpOutputDir, FileName+'.tmp')\r | |
75 | \r | |
76 | GenFdsGlobalVariable.GenerateOptionRom(TmpOutputFile, \r | |
77 | FilePathNameList, \r | |
78 | [], \r | |
79 | FfsFile.OverrideAttribs.NeedCompress, \r | |
80 | FfsFile.OverrideAttribs.PciClassCode, \r | |
81 | FfsFile.OverrideAttribs.PciRevision, \r | |
82 | FfsFile.OverrideAttribs.PciDeviceId, \r | |
83 | FfsFile.OverrideAttribs.PciVendorId)\r | |
84 | BinFileList.append(TmpOutputFile)\r | |
85 | else:\r | |
86 | FilePathName = FfsFile.GenFfs()\r | |
87 | if FfsFile.OverrideAttribs != None:\r | |
88 | FileName = os.path.basename(FilePathName)\r | |
89 | TmpOutputDir = os.path.join(GenFdsGlobalVariable.FvDir, self.DriverName)\r | |
90 | if not os.path.exists(TmpOutputDir) :\r | |
91 | os.makedirs(TmpOutputDir)\r | |
92 | TmpOutputFile = os.path.join(TmpOutputDir, FileName+'.tmp')\r | |
93 | \r | |
94 | GenFdsGlobalVariable.GenerateOptionRom(TmpOutputFile, \r | |
95 | [FilePathName], \r | |
96 | [], \r | |
97 | FfsFile.OverrideAttribs.NeedCompress, \r | |
98 | FfsFile.OverrideAttribs.PciClassCode, \r | |
99 | FfsFile.OverrideAttribs.PciRevision, \r | |
100 | FfsFile.OverrideAttribs.PciDeviceId, \r | |
101 | FfsFile.OverrideAttribs.PciVendorId)\r | |
102 | BinFileList.append(TmpOutputFile)\r | |
103 | else:\r | |
104 | if FfsFile.FileType == 'EFI':\r | |
105 | EfiFileList.append(FilePathName)\r | |
106 | else:\r | |
107 | BinFileList.append(FilePathName)\r | |
108 | \r | |
109 | #\r | |
110 | # Call EfiRom tool\r | |
111 | #\r | |
112 | OutputFile = os.path.join(GenFdsGlobalVariable.FvDir, self.DriverName)\r | |
113 | OutputFile = OutputFile + '.rom'\r | |
114 | \r | |
115 | GenFdsGlobalVariable.GenerateOptionRom(\r | |
116 | OutputFile,\r | |
117 | EfiFileList,\r | |
118 | BinFileList\r | |
119 | )\r | |
120 | \r | |
121 | GenFdsGlobalVariable.InfLogger( "\nGenerate %s Option ROM Successfully" %self.DriverName)\r | |
122 | GenFdsGlobalVariable.SharpCounter = 0\r | |
123 | \r | |
124 | return OutputFile\r | |
125 | \r | |
126 | class OverrideAttribs:\r | |
127 | \r | |
128 | ## The constructor\r | |
129 | #\r | |
130 | # @param self The object pointer\r | |
131 | #\r | |
132 | def __init__(self):\r | |
133 | \r | |
134 | self.PciVendorId = None\r | |
135 | self.PciClassCode = None\r | |
136 | self.PciDeviceId = None\r | |
137 | self.PciRevision = None\r | |
138 | self.NeedCompress = None\r | |
139 | \r | |
140 |