]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFsp2Pkg/Tools/UserManuals/GenCfgOptUserManual.md
IntelFsp2Pkg: Fix various typos
[mirror_edk2.git] / IntelFsp2Pkg / Tools / UserManuals / GenCfgOptUserManual.md
CommitLineData
eeb71f29
MG
1#Name\r
2**GenCfgOpt.py** The python script that generates UPD text (**.txt**) files for\r
3the compiler, header files for the UPD regions, and generates a Boot Settings\r
4File (**BSF**), all from an EDK II Platform Description (**DSC**) file.\r
5\r
6#Synopsis\r
7```\r
8GenCfgOpt UPDTXT PlatformDscFile BuildFvDir [TxtOutFile] [-D Macros]\r
9GenCfgOpt HEADER PlatformDscFile BuildFvDir [InputHFile] [-D Macros]\r
10GenCfgOpt GENBSF PlatformDscFile BuildFvDir BsfOutFile [-D Macros]\r
11```\r
12\r
13#Description\r
14**GenCfgOpt.py** is a script that generates configuration options from an\r
15**EDK II Platform Description (DSC)** file. It has three functions.\r
16\r
17 1. It produces a **.txt** file that is used by the compiler that summarizes\r
18 the UPD section in the DSC file.\r
19 2. It generates header files for the UPD regions.\r
20 3. It generates a **Boot Settings File (BSF)** that can be used by the\r
21 **Binary Configuration Tool (BCT)** to provide a graphical user\r
22 interface for manipulating settings in the UPD regions.\r
23\r
24The **GenCfgOpt.py** script generates important files that are vital parts of\r
25your build process. The **UPDTXT** and **HEADER** use cases must be done before\r
26the **'build'** command; the **GENBSF** use case may be done at any time.\r
27\r
28The following sections explain the three use cases.\r
29\r
30## 1. GenCfgOpt.py UPDTXT\r
31The **UPDTXT** option creates a text file with all the UPD entries, offsets,\r
32size in bytes, and values. **GenCfgOpt** reads this information from the\r
33**[PcdsDynamicVpd.Upd]** section of the project's DSC file. The DSC file allows\r
34you to specify offsets and sizes for each entry, opening up the possibility of\r
35introducing gaps between entries. **GenCfgOpt** fills in these gaps with UPD\r
36entries that have the generic names **UnusedUpdSpaceN** where N begins with 0\r
37and increments. The command signature for **UPDTXT** is:\r
38\r
39```\r
40GenCfgOpt UPDTXT PlatformDscFile BuildFvDir [TxtOutFile] [-D Macros]\r
41```\r
42\r
43**PlatformDscFile** must be the location of the DSC file for the platform you're\r
44building. **BuildFvDir** is the location where the binary will be stored. The\r
45optional **TxtOutFile** is a name and location for the output of **GenCfgOpt**.\r
46The default name and location is the ```<UPD_TOOL_GUID>.txt``` in the directory\r
47specified by **BuildFvDir**. The macro ```UPD_TOOL_GUID``` must be defined in\r
48the DSC file or in the optional Macros arguments. Each optional macro argument\r
49must follow the form ```?D <MACRO_NAME>=<VALUE>```.\r
50\r
51**GenCfgOpt** checks to see if the UPD txt file has already been created and\r
52will only re-create it if the DSC was modified after it was created.\r
53\r
54## 2. GenCfgOpt.py HEADER\r
55The **HEADER** option creates header files in the build folder. Both header\r
56files define the ```_UPD_DATA_REGION``` data structures in FspUpd.h, FsptUpd.h,\r
57FspmUpd.h and FspsUpd.h. In these header files any undefined elements of\r
58structures will be added as **ReservedUpdSpaceN** beginning with N=0. The\r
59command signature for **HEADER** is\r
60\r
61```GenCfgOpt HEADER PlatformDscFile BuildFvDir [InputHFile] [-D Macros]```\r
62\r
63**PlatformDscFile** and **BuildFvDir** are described in the previous section.\r
64The optional **InputHFile** is a header file that may contain data definitions\r
65that are used by variables in the UPD regions. This header file must contain\r
66the special keywords ```!EXPORT EXTERNAL_BOOTLOADER_STRUCT_BEGIN``` and\r
67```!EXPORT EXTERNAL_BOOTLOADER_STRUCT_END``` in comments. Everything between\r
68these two keywords will be included in the generated header file.\r
69The mechanism to specify whether a variable appears as **ReservedUpdSpaceN** in\r
70the FspUpd.h header file is in special commands that appear in the comments of\r
71the DSC file. The special commands begin with ```!HDR```, for header. The\r
72following table summarizes the two command options.\r
73\r
74### HEADER\r
75Use the **HEADER** command to hide specific variables in the public header file.\r
76In your project DSC file, use ```!HDR HEADER:{OFF}``` at the beginning of the\r
77section you wish to hide and ```!HDR HEADER:{ON}``` at the end.\r
78\r
79### STRUCT\r
80The **STRUCT** command allows you to specify a specific data type for a\r
81variable. You can specify a pointer to a data struct, for example. You define\r
82the data structure in the **InputHFile** between\r
83```!EXPORT EXTERNAL_BOOTLOADER_STRUCT_BEGIN``` and\r
84```!EXPORT EXTERNAL_BOOTLOADER_STRUCT_END```.\r
85\r
86#####Example:\r
87```!HDR STRUCT:{MY_DATA_STRUCT*}```\r
88\r
89You then define ```MY_DATA_STRUCT``` in **InputHFile**.\r
90\r
91### EMBED\r
92The **EMBED** command allows you to put one or more UPD data into a specify data\r
93structure. You can utilize it as a group of UPD for example. You must specify a\r
94start and an end for the specify data structure.\r
95\r
96#####Example:\r
97```\r
98 !HDR EMBED:{MY_DATA_STRUCT:MyDataStructure:START}\r
99 gTokenSpaceGuid.Upd1 | 0x0020 | 0x01 | 0x00\r
100 gTokenSpaceGuid.Upd2 | 0x0021 | 0x01 | 0x00\r
101 !HDR EMBED:{MY_DATA_STRUCT:MyDataStructure:END}\r
102 gTokenSpaceGuid.UpdN | 0x0022 | 0x01 | 0x00\r
103```\r
104\r
105#####Result:\r
106```\r
107 typedef struct {\r
108 /** Offset 0x0020\r
109 **/\r
110 UINT8 Upd1;\r
111 /** Offset 0x0021\r
112 **/\r
113 UINT8 Upd2;\r
114 /** Offset 0x0022\r
115 **/\r
116 UINT8 UpdN;\r
117 } MY_DATA_STRUCT;\r
118\r
119 typedef struct _UPD_DATA_REGION {\r
120 ...\r
121 /** Offset 0x0020\r
122 **/\r
123 MY_DATA_STRUCT MyDataStruct;\r
124 ...\r
125 } UPD_DATA_REGION;\r
126```\r
127\r
128## 3. GenCfgOpt .py GENBSF\r
129The **GENBSF** option generates a BSF from the UPD entries in a package's DSC\r
130file. It does this by parsing special commands found in the comments of the DSC\r
131file. They roughly match the keywords that define the different sections of the\r
132BSF.\r
133\r
134The command signature for **GENBSF** is\r
135\r
136```GenCfgOpt GENBSF PlatformDscFile BuildFvDir BsfOutFile [-D Macros]```\r
137\r
138In this case, the **BsfOutFile** parameter is required; it should be the\r
139relative path to where the BSF should be stored.\r
140\r
141Every BSF command in the DSC file begins with **!BSF** or **@Bsf**. The\r
142following table summarizes the options that come after **!BSF** or **@Bsf**:\r
143\r
144# BSF Commands Description\r
145###PAGES\r
146**PAGES** maps abbreviations to friendly-text descriptions of the pages in a BSF.\r
147\r
148#####Example:\r
149```!BSF PAGES:{PG1:?Page 1?, PG2:?Page 2?}``` or\r
150\r
151```@Bsf PAGES:{PG1:?Page 1?, PG2:?Page 2?}```\r
152\r
153###PAGE\r
154This marks the beginning of a page. Use the abbreviation specified in **PAGES**\r
155command.\r
156\r
157#####Example:\r
158```!BSF PAGE:{PG1}``` or\r
159\r
160```@Bsf PAGE:{PG1}```\r
161\r
162All the entries that come after this command are assumed to be on that page,\r
163until the next **PAGE** command\r
164\r
165###FIND\r
166FIND maps to the BSF **Find** command. It will be placed in the **StructDef**\r
167region of the BSF and should come at the beginning of the UPD sections of the\r
168DSC, immediately before the signatures that mark the beginning of these\r
169sections. The content should be the plain-text equivalent of the signature. The\r
170signature is usually 8 characters.\r
171\r
172#####Example:\r
173```!BSF FIND:{PROJSIG1}``` or\r
174\r
175```@Bsf FIND:{PROJSIG1}```\r
176\r
177###BLOCK\r
178The BLOCK command maps to the **BeginInfoBlock** section of the BSF. There are\r
179two elements: a version number and a plain-text description.\r
180\r
181#####Example:\r
182```!BSF BLOCK:{NAME:"My platform name", VER:"0.1"}``` or\r
183\r
184```@Bsf BLOCK:{NAME:"My platform name", VER:"0.1"}```\r
185\r
186###NAME\r
187**NAME** gives a plain-text for a variable. This is the text label that will\r
188appear next to the control in **BCT**.\r
189\r
190#####Example:\r
191```!BSF NAME:{Variable 0}``` or\r
192\r
193```@Bsf NAME:{Variable 0}```\r
194\r
195If the **!BSF NAME** or **@Bsf NAME** command does not appear before an entry\r
196in the UPD region of the DSC file, then that entry will not appear in the BSF.\r
197\r
198###TYPE\r
199The **TYPE** command is used either by itself or with the **NAME** command. It\r
200is usually used by itself when defining an **EditNum** field for the BSF. You\r
201specify the type of data in the second parameter and the range of valid values\r
202in the third.\r
203\r
204#####Example:\r
205```!BSF TYPE:{EditNum, HEX, (0x00,0xFF)}``` or\r
206\r
207```@Bsf TYPE:{EditNum, HEX, (0x00,0xFF)}```\r
208\r
209**TYPE** appears on the same line as the **NAME** command when using a combo-box.\r
210\r
211#####Example:\r
212```!BSF NAME:{Variable 1} TYPE:{Combo}``` or\r
213```@Bsf NAME:{Variable 1} TYPE:{Combo}```\r
214\r
215There is a special **None** type that puts the variable in the **StructDef**\r
91cc60ba 216region of the BSF, but doesn't put it in any **Page** section. This makes the\r
eeb71f29
MG
217variable visible to BCT, but not to the end user.\r
218\r
219###HELP\r
220The **HELP** command defines what will appear in the help text for each control\r
221in BCT.\r
222\r
223#####Example:\r
224```!BSF HELP:{Enable/disable LAN controller.}``` or\r
225\r
226```@Bsf HELP:{Enable/disable LAN controller.}```\r
227\r
228###OPTION\r
229The **OPTION** command allows you to custom-define combo boxes and map integer\r
230or hex values to friendly-text options.\r
231\r
232#####Example:\r
233```!BSF OPTION:{0:IDE, 1:AHCI, 2:RAID}```\r
234\r
235```!BSF OPTION:{0x00:0 MB, 0x01:32 MB, 0x02:64 MB}```\r
236\r
237or\r
238\r
239```@Bsf OPTION:{0:IDE, 1:AHCI, 2:RAID}```\r
240\r
241```@Bsf OPTION:{0x00:0 MB, 0x01:32 MB, 0x02:64 MB}```\r
242\r
243###FIELD\r
244The **FIELD** command can be used to define a section of a consolidated PCD\r
245such that the PCD will be displayed in several fields via BCT interface instead\r
246of one long entry.\r
247\r
248#####Example:\r
249```!BSF FIELD:{PcdDRAMSpeed:1}``` or\r
250\r
251```@Bsf FIELD:{PcdDRAMSpeed:1}```\r
252\r
253###ORDER\r
254The **ORDER** command can be used to adjust the display order for the BSF items.\r
255By default the order value for a BSF item is assigned to be the UPD item\r
256```(Offset * 256)```. It can be overridden by declaring **ORDER** command using\r
257format ORDER: ```{HexMajor.HexMinor}```. In this case the order value will be\r
258```(HexMajor*256+HexMinor)```. The item order value will be used as the sort key\r
259during the BSF item display.\r
260\r
261#####Example:\r
262```!BSF ORDER:{0x0040.01}``` or\r
263\r
264```@Bsf ORDER:{0x0040.01}```\r
265\r
266For **OPTION** and **HELP** commands, it allows to split the contents into\r
267multiple lines by adding multiple **OPTION** and **HELP** command lines. The\r
268lines except for the very first line need to start with **+** in the content to\r
269tell the tool to append this string to the previous one.\r
270\r
271For example, the statement\r
272\r
273```!BSF OPTION:{0x00:0 MB, 0x01:32 MB, 0x02:64 MB}```\r
274\r
275is equivalent to:\r
276\r
277```!BSF OPTION:{0x00:0 MB, 0x01:32 MB,}```\r
278\r
279```!BSF OPTION:{+ 0x02:64 MB}```\r
280\r
281or\r
282\r
283```@Bsf OPTION:{0x00:0 MB, 0x01:32 MB, 0x02:64 MB}```\r
284\r
285is equivalent to:\r
286\r
287```@Bsf OPTION:{0x00:0 MB, 0x01:32 MB,}```\r
288\r
289```@Bsf OPTION:{+ 0x02:64 MB}```\r
290\r
291The **NAME**, **OPTION**, **TYPE**, and **HELP** commands can all appear on the\r
292same line following the **!BSF** or **@Bsf** keyword or they may appear on\r
293separate lines to improve readability.\r
294\r
295There are four alternative ways to replace current BSF commands.\r
296### 1. ```# @Prompt```\r
297An alternative way replacing **NAME** gives a plain-text for a\r
298variable. This is the text label that will appear next to the control in BCT.\r
299\r
300#####Example:\r
301```# @Prompt Variable 0```\r
302\r
303The above example can replace the two methods as below.\r
304\r
305```!BSF NAME:{Variable 0}``` or\r
306\r
307```@Bsf NAME:{Variable 0}```\r
308\r
309If the ```# @Prompt``` command does not appear before an entry in the UPD region\r
310of the DSC file, then that entry will not appear in the BSF.\r
311\r
312### 2. ```##```\r
313An alternative way replacing **HELP** command defines what will appear in the\r
314help text for each control in BCT.\r
315\r
316#####Example:\r
317```## Enable/disable LAN controller.```\r
318\r
319The above example can replace the two methods as below.\r
320\r
321```!BSF HELP:{Enable/disable LAN controller.}``` or\r
322\r
323```@Bsf HELP:{Enable/disable LAN controller.}```\r
324\r
325### 3. ```# @ValidList```\r
326An alternative way replacing **OPTION** command allows you to custom-define\r
327combo boxes and map integer or hex values to friendly-text options.\r
328\r
329#####Example:\r
330``` # @ValidList 0x80000003 | 0, 1, 2 | IDE, AHCI, RAID\r
331 Error Code | Options | Descriptions\r
332```\r
333\r
334The above example can replace the two methods as below.\r
335\r
336```!BSF OPTION:{0:IDE, 1:AHCI, 2:RAID}``` or\r
337\r
338```@Bsf OPTION:{0:IDE, 1:AHCI, 2:RAID}```\r
339\r
340### 4. ```# @ValidRange```\r
341An alternative way replace **EditNum** field for the BSF.\r
342\r
343#####Example:\r
344```# @ValidRange 0x80000001 | 0x0 ? 0xFF\r
345 Error Code | Range\r
346```\r
347\r
348The above example can replace the two methods as below.\r
349\r
350```!BSF TYPE:{EditNum, HEX, (0x00,0xFF)}``` or\r
351\r
352```@Bsf TYPE:{EditNum, HEX, (0x00,0xFF)}```\r
353\r