summaryrefslogtreecommitdiff
path: root/Tools
diff options
context:
space:
mode:
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2006-07-06 06:10:20 +0000
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2006-07-06 06:10:20 +0000
commit1de04b4f83050f9a8f6c3eedce27f841591972f3 (patch)
treea0366962d8f231b1ab187246bb0c2916666270c5 /Tools
parent71baa24b6912dffc15058abc683eb6161a88a62f (diff)
downloadedk2-platforms-1de04b4f83050f9a8f6c3eedce27f841591972f3.tar.xz
Add in support for MaxSize and CurrentSize for PCD entry.
Change the behavior for PcdSET for Variable_Enabled Pcd entry. If a Variable does not exist, we will only save the value to a volatile space. We save it to variable ONLY when the variable exist. Fix a few bugs in Pcd Build tool when generated Pcd database for Pcd entry with Unicode String type. Support PcdSet to return MaxSize if the input SizeOfBuffer is greater than the Max Size declared in FPD file. Add SetValueWorker and GetValueWoker for each PcdSET and PcdGET function to reduce code size. Sync function prototype definition for PCD_PPI_SET_POINTER, PCD_PPI_SET_EX_POINTER, PCD_PROTOCOL_SET_POINTER and PCD_PROTOCOL_SET_EX_POINTER with PCD arch spec 0.52. Add ASSERTION in LibPcdSetPtr. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@789 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools')
-rw-r--r--Tools/Conf/Pcd/PcdDatabaseCommonDefinitions.sample35
-rw-r--r--Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java97
-rw-r--r--Tools/Source/GenBuild/org/tianocore/build/pcd/entity/Token.java73
3 files changed, 168 insertions, 37 deletions
diff --git a/Tools/Conf/Pcd/PcdDatabaseCommonDefinitions.sample b/Tools/Conf/Pcd/PcdDatabaseCommonDefinitions.sample
index 7bdb28293c..7df1a5a6f4 100644
--- a/Tools/Conf/Pcd/PcdDatabaseCommonDefinitions.sample
+++ b/Tools/Conf/Pcd/PcdDatabaseCommonDefinitions.sample
@@ -7,17 +7,32 @@
//
typedef UINT8 SKU_ID;
-#define PCD_TYPE_SHIFT 24
+#define PCD_TYPE_SHIFT 28
+#define PCD_TYPE_DATA (0x0 << PCD_TYPE_SHIFT)
+#define PCD_TYPE_HII (0x8 << PCD_TYPE_SHIFT)
+#define PCD_TYPE_VPD (0x4 << PCD_TYPE_SHIFT)
+#define PCD_TYPE_SKU_ENABLED (0x2 << PCD_TYPE_SHIFT)
+#define PCD_TYPE_STRING (0x1 << PCD_TYPE_SHIFT)
-#define PCD_TYPE_DATA (0x00 << PCD_TYPE_SHIFT)
-#define PCD_TYPE_HII (0x80 << PCD_TYPE_SHIFT)
-#define PCD_TYPE_VPD (0x40 << PCD_TYPE_SHIFT)
-#define PCD_TYPE_SKU_ENABLED (0x20 << PCD_TYPE_SHIFT)
-#define PCD_TYPE_STRING (0x10 << PCD_TYPE_SHIFT)
+#define PCD_TYPE_ALL_SET (PCD_TYPE_DATA | PCD_TYPE_HII | PCD_TYPE_VPD | PCD_TYPE_SKU_ENABLED | PCD_TYPE_STRING)
+#define PCD_DATUM_TYPE_SHIFT 24
-#define PCD_DATABASE_OFFSET_MASK (~(PCD_TYPE_HII | PCD_TYPE_VPD | PCD_TYPE_SKU_ENABLED | PCD_TYPE_STRING))
+#define PCD_DATUM_TYPE_POINTER (0x0 << PCD_DATUM_TYPE_SHIFT)
+#define PCD_DATUM_TYPE_UINT8 (0x1 << PCD_DATUM_TYPE_SHIFT)
+#define PCD_DATUM_TYPE_UINT16 (0x2 << PCD_DATUM_TYPE_SHIFT)
+#define PCD_DATUM_TYPE_UINT32 (0x4 << PCD_DATUM_TYPE_SHIFT)
+#define PCD_DATUM_TYPE_UINT64 (0x8 << PCD_DATUM_TYPE_SHIFT)
+
+#define PCD_DATUM_TYPE_ALL_SET (PCD_DATUM_TYPE_POINTER | \
+ PCD_DATUM_TYPE_UINT8 | \
+ PCD_DATUM_TYPE_UINT16 | \
+ PCD_DATUM_TYPE_UINT32 | \
+ PCD_DATUM_TYPE_UINT64)
+
+
+#define PCD_DATABASE_OFFSET_MASK (~(PCD_TYPE_ALL_SET | PCD_DATUM_TYPE_ALL_SET))
typedef struct {
UINT32 ExTokenNumber;
@@ -46,11 +61,7 @@ typedef struct {
typedef UINT16 STRING_HEAD;
-typedef struct {
- UINT32 LocalTokenNumber;
- UINT16 TokenNumber;
- UINT16 Size;
-} SIZEINFO;
+typedef UINT16 SIZE_INFO;
#define offsetof(s,m) (UINT32) (UINTN) &(((s *)0)->m)
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java
index 3a781c8001..396a1af442 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java
@@ -229,16 +229,24 @@ class StringTable {
**/
class SizeTable {
- private ArrayList<Integer> al;
+ private ArrayList<ArrayList<Integer>> al;
private ArrayList<String> alComments;
- private String phase;
private int len;
+ private String phase;
public SizeTable (String phase) {
- this.phase = phase;
- al = new ArrayList<Integer>();
+ al = new ArrayList<ArrayList<Integer>>();
alComments = new ArrayList<String>();
len = 0;
+ this.phase = phase;
+ }
+
+ public String getSizeMacro () {
+ return String.format(PcdDatabase.SizeTableSizeMacro, phase, getSize());
+ }
+
+ private int getSize() {
+ return len == 0 ? 1 : len;
}
public void genCode (ArrayList<CStructTypeDeclaration> declaList, HashMap<String, String> instTable, String phase) {
@@ -262,6 +270,7 @@ class SizeTable {
}
private ArrayList<String> getInstantiation () {
+ final String comma = ",";
ArrayList<String> Output = new ArrayList<String>();
Output.add("/* SizeTable */");
@@ -270,14 +279,23 @@ class SizeTable {
Output.add("\t0");
} else {
for (int index = 0; index < al.size(); index++) {
- Integer n = al.get(index);
- String str = "\t" + n.toString();
+ ArrayList<Integer> ial = al.get(index);
+
+ String str = "\t";
+
+ for (int index2 = 0; index2 < ial.size(); index2++) {
+ str += " " + ial.get(index2).toString();
+ if (index2 != ial.size() - 1) {
+ str += comma;
+ }
+ }
+ str += " /* " + alComments.get(index) + " */";
+
if (index != (al.size() - 1)) {
- str += ",";
+ str += comma;
}
- str += " /* " + alComments.get(index) + " */";
Output.add(str);
}
@@ -287,20 +305,25 @@ class SizeTable {
return Output;
}
- public int add (Token token) {
- int index = len;
+ public void add (Token token) {
- len++;
- al.add(token.datumSize);
+ //
+ // We only have size information for POINTER type PCD entry.
+ //
+ if (token.datumType != Token.DATUM_TYPE.POINTER) {
+ return;
+ }
+
+ ArrayList<Integer> ial = token.getPointerTypeSize();
+
+ len+= ial.size();
+
+ al.add(ial);
alComments.add(token.getPrimaryKeyString());
- return index;
+ return;
}
- public int getTableLen () {
- return al.size() == 0 ? 1 : al.size();
- }
-
}
/**
@@ -344,7 +367,7 @@ class GuidTable {
cCode += String.format(PcdDatabase.GuidTableDeclaration, phase);
decl = new CStructTypeDeclaration (
name,
- 8,
+ 4,
cCode,
true
);
@@ -674,6 +697,25 @@ class LocalTokenNumberTable {
str += " | PCD_TYPE_VPD";
}
+ switch (token.datumType) {
+ case UINT8:
+ case BOOLEAN:
+ str += " | PCD_DATUM_TYPE_UINT8";
+ break;
+ case UINT16:
+ str += " | PCD_DATUM_TYPE_UINT16";
+ break;
+ case UINT32:
+ str += " | PCD_DATUM_TYPE_UINT32";
+ break;
+ case UINT64:
+ str += " | PCD_DATUM_TYPE_UINT64";
+ break;
+ case POINTER:
+ str += " | PCD_DATUM_TYPE_POINTER";
+ break;
+ }
+
al.add(str);
alComment.add(token.getPrimaryKeyString());
@@ -851,7 +893,7 @@ class PcdDatabase {
public final static String GuidTableDeclaration = "EFI_GUID GuidTable[%s_GUID_TABLE_SIZE];\r\n";
public final static String LocalTokenNumberTableDeclaration = "UINT32 LocalTokenNumberTable[%s_LOCAL_TOKEN_NUMBER_TABLE_SIZE];\r\n";
public final static String StringTableDeclaration = "UINT16 StringTable[%s_STRING_TABLE_SIZE];\r\n";
- public final static String SizeTableDeclaration = "UINT16 SizeTable[%s_LOCAL_TOKEN_NUMBER_TABLE_SIZE];\r\n";
+ public final static String SizeTableDeclaration = "SIZE_INFO SizeTable[%s_SIZE_TABLE_SIZE];\r\n";
public final static String SkuIdTableDeclaration = "UINT8 SkuIdTable[%s_SKUID_TABLE_SIZE];\r\n";
@@ -860,6 +902,7 @@ class PcdDatabase {
public final static String GuidTableSizeMacro = "#define %s_GUID_TABLE_SIZE %d\r\n";
public final static String LocalTokenNumberTableSizeMacro = "#define %s_LOCAL_TOKEN_NUMBER_TABLE_SIZE %d\r\n";
public final static String LocalTokenNumberSizeMacro = "#define %s_LOCAL_TOKEN_NUMBER %d\r\n";
+ public final static String SizeTableSizeMacro = "#define %s_SIZE_TABLE_SIZE %d\r\n";
public final static String StringTableSizeMacro = "#define %s_STRING_TABLE_SIZE %d\r\n";
public final static String SkuIdTableSizeMacro = "#define %s_SKUID_TABLE_SIZE %d\r\n";
@@ -1144,6 +1187,7 @@ class PcdDatabase {
macroStr += skuIdTable.getSizeMacro();
macroStr += localTokenNumberTable.getSizeMacro();
macroStr += exMapTable.getSizeMacro();
+ macroStr += sizeTable.getSizeMacro();
//
// Generate existance info Macro for all Tables
@@ -1311,6 +1355,9 @@ class PcdDatabase {
}
}
+ //
+ // privateGlobalName and privateGlobalCCode is used to pass output to caller of getCDeclarationString
+ //
private void getCDeclarationString(Token t)
throws EntityException {
@@ -1321,7 +1368,7 @@ class PcdDatabase {
}
String type = getCType(t);
- if ((t.datumType == Token.DATUM_TYPE.POINTER) && (!t.isHiiEnable())) {
+ if ((t.datumType == Token.DATUM_TYPE.POINTER) && (!t.isHiiEnable()) && (!t.isUnicodeStringType())) {
int bufferSize;
if (t.isASCIIStringType()) {
//
@@ -3007,14 +3054,16 @@ public class CollectPCDAction {
**/
public static void main(String argv[]) throws EntityException {
CollectPCDAction ca = new CollectPCDAction();
- ca.setWorkspacePath("m:/tianocore/edk2");
- ca.setFPDFilePath("m:/tianocore/edk2/EdkNt32Pkg/Nt32.fpd");
+ String projectDir = "x:/edk2";
+ ca.setWorkspacePath(projectDir);
+ ca.setFPDFilePath(projectDir + "/EdkNt32Pkg/Nt32.fpd");
ca.setActionMessageLevel(ActionMessage.MAX_MESSAGE_LEVEL);
GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",
- "m:/tianocore/edk2",
+ projectDir,
"tools_def.txt");
+ System.out.println("After initInfo!");
FpdParserTask fpt = new FpdParserTask();
- fpt.parseFpdFile(new File("m:/tianocore/edk2/EdkNt32Pkg/Nt32.fpd"));
+ fpt.parseFpdFile(new File(projectDir + "/EdkNt32Pkg/Nt32.fpd"));
ca.execute();
}
}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/Token.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/Token.java
index 1ffad91183..94266cda36 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/Token.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/Token.java
@@ -574,7 +574,78 @@ public class Token {
public int getSkuIdCount () {
return this.skuData.size();
}
-
+
+ private void getCurrentSizeFromDefaultValue (String str, ArrayList<Integer> al) {
+ if (isValidNullValue(str)) {
+ al.add(new Integer(0));
+ } else {
+ //
+ // isValidNullValue has already make sure that str here
+ // always contain a valid default value of the following 3
+ // cases:
+ // 1) "Hello world" //Assci string
+ // 2) L"Hello" //Unicode string
+ // 3) {0x01, 0x02, 0x03} //Byte stream
+ //
+ if (str.startsWith("\"")) {
+ al.add(new Integer(str.length() - 2));
+ } else if (str.startsWith("L\"")){
+ //
+ // Unicode is 2 bytes each.
+ //
+ al.add(new Integer((str.length() - 3) * 2));
+ } else if (str.startsWith("{")) {
+ //
+ // We count the number of "," in the string.
+ // The number of byte is one plus the number of
+ // comma.
+ //
+ String str2 = str;
+
+ int cnt = 0;
+ int pos = 0;
+ pos = str2.indexOf(",", 0);
+ while (pos != -1) {
+ cnt++;
+ pos++;
+ pos = str2.indexOf(",", pos);
+ }
+ cnt++;
+ al.add(new Integer(cnt));
+ }
+ }
+ }
+ //
+ // This method can be used to get the MAX and current size
+ // for pointer type dynamic(ex) PCD entry
+ //
+ public ArrayList<Integer> getPointerTypeSize () {
+ ArrayList<Integer> al = new ArrayList<Integer>();
+
+ //
+ // For VPD_enabled and HII_enabled, we can only return the MAX size.
+ // For the default DATA type dynamic PCD entry, we will return
+ // the MAX size and current size for each SKU_ID.
+ //
+ al.add(new Integer(this.datumSize));
+
+ if (!this.isVpdEnable()) {
+ int idx;
+ if (this.isHiiEnable()){
+ for (idx = 0; idx < this.skuData.size(); idx++) {
+ String str = this.skuData.get(idx).value.hiiDefaultValue;
+ getCurrentSizeFromDefaultValue(str, al);
+ }
+ } else {
+ for (idx = 0; idx < this.skuData.size(); idx++) {
+ String str = this.skuData.get(idx).value.value;
+ getCurrentSizeFromDefaultValue(str, al);
+ }
+ }
+ }
+
+ return al;
+ }
/**
Get default value for a token, For HII type, HiiDefaultValue of default