Embeded autogenerated code in Java code instead of getting them from a real file.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1294 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qwang12 2006-08-16 10:51:01 +00:00
parent d2059d0594
commit 2c0e2bcf49
1 changed files with 101 additions and 52 deletions

View File

@ -13,9 +13,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.build.pcd.action;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
@ -1469,25 +1467,79 @@ public class PcdDatabase {
return s;
}
public static String getPcdDatabaseCommonDefinitions ()
throws EntityException {
public static String getPcdDatabaseCommonDefinitions () {
String retStr = "";
try {
File file = new File(GlobalData.getWorkspacePath() + File.separator +
"Tools" + File.separator +
"Conf" + File.separator +
"Pcd" + File.separator +
"PcdDatabaseCommonDefinitions.sample");
FileReader reader = new FileReader(file);
BufferedReader in = new BufferedReader(reader);
String str;
while ((str = in.readLine()) != null) {
retStr = retStr +"\r\n" + str;
}
} catch (Exception ex) {
throw new EntityException("Fatal error when generating PcdDatabase Common Definitions!");
}
String retStr;
retStr = "//\r\n";
retStr += "// The following definition will be generated by build tool\r\n";
retStr += "//\r\n";
retStr += "\r\n";
retStr += "//\r\n";
retStr += "// Common definitions\r\n";
retStr += "//\r\n";
retStr += "typedef UINT8 SKU_ID;\r\n";
retStr += "\r\n";
retStr += "#define PCD_TYPE_SHIFT 28\r\n";
retStr += "\r\n";
retStr += "#define PCD_TYPE_DATA (0x0 << PCD_TYPE_SHIFT)\r\n";
retStr += "#define PCD_TYPE_HII (0x8 << PCD_TYPE_SHIFT)\r\n";
retStr += "#define PCD_TYPE_VPD (0x4 << PCD_TYPE_SHIFT)\r\n";
retStr += "#define PCD_TYPE_SKU_ENABLED (0x2 << PCD_TYPE_SHIFT)\r\n";
retStr += "#define PCD_TYPE_STRING (0x1 << PCD_TYPE_SHIFT)\r\n";
retStr += "\r\n";
retStr += "#define PCD_TYPE_ALL_SET (PCD_TYPE_DATA | PCD_TYPE_HII | PCD_TYPE_VPD | PCD_TYPE_SKU_ENABLED | PCD_TYPE_STRING)\r\n";
retStr += "\r\n";
retStr += "#define PCD_DATUM_TYPE_SHIFT 24\r\n";
retStr += "\r\n";
retStr += "#define PCD_DATUM_TYPE_POINTER (0x0 << PCD_DATUM_TYPE_SHIFT)\r\n";
retStr += "#define PCD_DATUM_TYPE_UINT8 (0x1 << PCD_DATUM_TYPE_SHIFT)\r\n";
retStr += "#define PCD_DATUM_TYPE_UINT16 (0x2 << PCD_DATUM_TYPE_SHIFT)\r\n";
retStr += "#define PCD_DATUM_TYPE_UINT32 (0x4 << PCD_DATUM_TYPE_SHIFT)\r\n";
retStr += "#define PCD_DATUM_TYPE_UINT64 (0x8 << PCD_DATUM_TYPE_SHIFT)\r\n";
retStr += "\r\n";
retStr += "#define PCD_DATUM_TYPE_ALL_SET (PCD_DATUM_TYPE_POINTER | \\\r\n";
retStr += " PCD_DATUM_TYPE_UINT8 | \\\r\n";
retStr += " PCD_DATUM_TYPE_UINT16 | \\\r\n";
retStr += " PCD_DATUM_TYPE_UINT32 | \\\r\n";
retStr += " PCD_DATUM_TYPE_UINT64)\r\n";
retStr += "\r\n";
retStr += "\r\n";
retStr += "#define PCD_DATABASE_OFFSET_MASK (~(PCD_TYPE_ALL_SET | PCD_DATUM_TYPE_ALL_SET))\r\n";
retStr += "\r\n";
retStr += "typedef struct {\r\n";
retStr += " UINT32 ExTokenNumber;\r\n";
retStr += " UINT16 LocalTokenNumber; // PCD Number of this particular platform build\r\n";
retStr += " UINT16 ExGuidIndex; // Index of GuidTable\r\n";
retStr += "} DYNAMICEX_MAPPING;\r\n";
retStr += "\r\n";
retStr += "\r\n";
retStr += "typedef struct {\r\n";
retStr += " UINT32 SkuDataStartOffset; //We have to use offsetof MACRO as we don't know padding done by compiler\r\n";
retStr += " UINT32 SkuIdTableOffset; //Offset from the PCD_DB\r\n";
retStr += "} SKU_HEAD;\r\n";
retStr += "\r\n";
retStr += "\r\n";
retStr += "typedef struct {\r\n";
retStr += " UINT16 GuidTableIndex; // Offset in Guid Table in units of GUID.\r\n";
retStr += " UINT16 StringIndex; // Offset in String Table in units of UINT16.\r\n";
retStr += " UINT16 Offset; // Offset in Variable\r\n";
retStr += " UINT16 DefaultValueOffset; // Offset of the Default Value\r\n";
retStr += "} VARIABLE_HEAD ;\r\n";
retStr += "\r\n";
retStr += "\r\n";
retStr += "typedef struct {\r\n";
retStr += " UINT32 Offset;\r\n";
retStr += "} VPD_HEAD;\r\n";
retStr += "\r\n";
retStr += "typedef UINT16 STRING_HEAD;\r\n";
retStr += "\r\n";
retStr += "typedef UINT16 SIZE_INFO;\r\n";
retStr += "\r\n";
retStr += "#define offsetof(s,m) (UINT32) (UINTN) &(((s *)0)->m)\r\n";
retStr += "\r\n";
retStr += "\r\n";
retStr += "\r\n";
return retStr;
}
@ -1496,21 +1548,24 @@ public class PcdDatabase {
throws EntityException {
String retStr = "";
try {
File file = new File(GlobalData.getWorkspacePath() + File.separator +
"Tools" + File.separator +
"Conf" + File.separator +
"Pcd" + File.separator +
"PcdDatabaseDxeDefinitions.sample");
FileReader reader = new FileReader(file);
BufferedReader in = new BufferedReader(reader);
String str;
while ((str = in.readLine()) != null) {
retStr = retStr +"\r\n" + str;
}
} catch (Exception ex) {
throw new EntityException("Fatal error when generating PcdDatabase Dxe Definitions!");
}
retStr += "\r\n";
retStr += "typedef struct {\r\n";
retStr += " DXE_PCD_DATABASE_INIT Init;\r\n";
retStr += " DXE_PCD_DATABASE_UNINIT Uninit;\r\n";
retStr += "} DXE_PCD_DATABASE;\r\n";
retStr += "\r\n";
retStr += "\r\n";
retStr += "typedef struct {\r\n";
retStr += " PEI_PCD_DATABASE PeiDb;\r\n";
retStr += " DXE_PCD_DATABASE DxeDb;\r\n";
retStr += "} PCD_DATABASE;\r\n";
retStr += "\r\n";
retStr += "#define DXE_NEX_TOKEN_NUMBER (DXE_LOCAL_TOKEN_NUMBER - DXE_EX_TOKEN_NUMBER)\r\n";
retStr += "\r\n";
retStr += "#define PCD_TOTAL_TOKEN_NUMBER (PEI_LOCAL_TOKEN_NUMBER + DXE_LOCAL_TOKEN_NUMBER)\r\n";
retStr += "\r\n";
retStr += "\r\n";
return retStr;
}
@ -1519,21 +1574,15 @@ public class PcdDatabase {
throws EntityException {
String retStr = "";
try {
File file = new File(GlobalData.getWorkspacePath() + File.separator +
"Tools" + File.separator +
"Conf" + File.separator +
"Pcd" + File.separator +
"PcdDatabasePeiDefinitions.sample");
FileReader reader = new FileReader(file);
BufferedReader in = new BufferedReader(reader);
String str;
while ((str = in.readLine()) != null) {
retStr = retStr +"\r\n" + str;
}
} catch (Exception ex) {
throw new EntityException("Fatal error when generating PcdDatabase Pei Definitions!");
}
retStr += "\r\n";
retStr += "typedef struct {\r\n";
retStr += " PEI_PCD_DATABASE_INIT Init;\r\n";
retStr += " PEI_PCD_DATABASE_UNINIT Uninit;\r\n";
retStr += "} PEI_PCD_DATABASE;\r\n";
retStr += "\r\n";
retStr += "#define PEI_NEX_TOKEN_NUMBER (PEI_LOCAL_TOKEN_NUMBER - PEI_EX_TOKEN_NUMBER)\r\n";
retStr += "\r\n";
return retStr;
}