From 4acf8ce7da7a8125ec83c6ce6d4dd675314e3d59 Mon Sep 17 00:00:00 2001 From: qwang12 Date: Fri, 26 May 2006 11:00:44 +0000 Subject: [PATCH] Add version check in both PCD database generation and service driver. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@292 6f19259b-4bc3-4df7-8a09-765794883524 --- EdkModulePkg/Universal/PCD/Dxe/Service.h | 191 +----------------- EdkModulePkg/Universal/PCD/Pei/Service.h | 14 ++ .../build/pcd/action/CollectPCDAction.java | 27 +-- 3 files changed, 35 insertions(+), 197 deletions(-) diff --git a/EdkModulePkg/Universal/PCD/Dxe/Service.h b/EdkModulePkg/Universal/PCD/Dxe/Service.h index d5918f2693..54ab1b6551 100644 --- a/EdkModulePkg/Universal/PCD/Dxe/Service.h +++ b/EdkModulePkg/Universal/PCD/Dxe/Service.h @@ -18,197 +18,20 @@ Module Name: Service.h #ifndef _SERVICE_H #define _SERVICE_H -#define USE_AUTOGEN - -#ifndef USE_AUTOGEN // -// The following definition will be generated by build tool +// Please make sure the PCD Serivce PEIM Version is consistent with +// the version of PCD Database generation tool // +#define PCD_DXE_SERVICE_DRIVER_VERSION 1 // -// Common definitions -// -#define PCD_TYPE_SHIFT 24 - - -#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_DATABASE_OFFSET_MASK (~(PCD_TYPE_HII | PCD_TYPE_VPD | PCD_TYPE_SKU_ENABLED)) - -typedef struct { - UINT32 ExTokenNumber; - UINT32 LocalTokenNumber; // PCD Number of this particular platform build - UINT16 ExGuidIndex; // Index of GuidTable -} DYNAMICEX_MAPPING; - - -typedef struct { - UINT32 SkuDataStartOffset; //We have to use offsetof MACRO as we don't know padding done by compiler - UINT32 SkuIdTableOffset; //Offset from the PCD_DB -} SKU_HEAD; - - -typedef struct { - UINT16 GuidTableIndex; // Offset in Guid Table in units of GUID. - UINT16 StringIndex; // Offset in String Table in units of UINT16. - UINT16 Offset; // Offset in Variable -} VARIABLE_HEAD ; - - -typedef struct { - UINT32 Offset; -} VPD_HEAD; - -typedef struct { - UINT32 LocalTokenNumber; - UINT16 TokenNumber; - UINT16 Size; -} SIZEINFO; - -#define offsetof(s,m) (UINT32)&(((s *)0)->m) - - - -// -// C Structure generate for PEI PCD Database -// -#define PEI_EXMAPPING_TABLE_SIZE 1 -#define PEI_GUID_TABLE_SIZE 1 -#define PEI_LOCAL_TOKEN_NUMBER 1 -#define PEI_EXTOKEN_NUMBER 1 -#define PEI_STRING_TABLE_SIZE 2 -#define PEI_SKUID_TABLE_SIZE 3 -#define PEI_SIZE_TABLE_SIZE 1 - -#define PEI_DATABASE_EMPTRY FALSE -#define PEI_DYNAMICEX_MAPPING_EMPTY FALSE -#define PEI_GUID_TABLE_EMPTY FALSE -#define PEI_STRINGTABLE_EMPTY FALSE -#define PEI_SIZETABLE_EMPTY FALSE -#define PEI_SKUID_TABLE_EMPTY FALSE - - -typedef struct { - - DYNAMICEX_MAPPING ExMapTable[PEI_EXMAPPING_TABLE_SIZE]; - EFI_GUID GuidTable[PEI_GUID_TABLE_SIZE]; - - UINT32 LocalTokenNumberTable[PEI_LOCAL_TOKEN_NUMBER]; - - - UINT16 StringTable[PEI_STRING_TABLE_SIZE]; - UINT16 SizeTable[PEI_LOCAL_TOKEN_NUMBER]; - - SKU_ID SkuIdTable[PEI_SKUID_TABLE_SIZE]; - - SKU_ID SystemSkuId; - -} PEI_PCD_DATABASE_INIT; - -typedef struct { - UINT8 Dummy; -} PEI_PCD_DATABASE_UNINIT; - -// -// Following code should be generated for PCD DXE driver -// - -#define DXE_EXMAPPING_TABLE_SIZE 1 -#define DXE_GUID_TABLE_SIZE 1 -#define DXE_TOKEN_NUMBER 1 -#define DXE_EXTOKEN_NUMBER 1 -#define DXE_STRING_TABLE_SIZE 2 -#define DXE_SKUID_TABLE_SIZE 3 -#define DXE_SIZE_TABLE_SIZE 1 - -#define DXE_DATABASE_EMPTRY FALSE -#define DXE_DYNAMICEX_MAPPING_EMPTY FALSE -#define DXE_GUID_TABLE_EMPTY FALSE -#define DXE_STRINGTABLE_EMPTY FALSE -#define DXE_SIZETABLE_EMPTY FALSE -#define DXE_SKUID_TABLE_EMPTY FALSE - -typedef struct { - DYNAMICEX_MAPPING ExMapTable[DXE_EXMAPPING_TABLE_SIZE]; - EFI_GUID GuidTable[DXE_GUID_TABLE_SIZE]; - - UINT32 LocalTokenNumberTable[DXE_TOKEN_NUMBER]; - - - UINT16 StringTable[DXE_STRING_TABLE_SIZE]; - UINT16 SizeTable[DXE_TOKEN_NUMBER]; - - SKU_ID SkuIdTable[DXE_SKUID_TABLE_SIZE]; - -} DXE_PCD_DATABASE_INIT; - -typedef struct { - UINT8 Dummy; -} DXE_PCD_DATABASE_UNINIT; - - -#define DXE_PCD_DB_INIT_VALUE \ - /* ExMapTable */ \ - { \ - { /* ExTokenNumber */ 0x00000001, /* LocalTokenNumberIndex */ 0, /* ExGuidIndex */ 0} \ - }, \ - \ - /* GuidTable */ \ - { \ - { 0xBB25CF6F, 0xF1D4, 0x11D2, {0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD }} \ - }, \ - \ - /* LocalTokenNumberTable */ \ - { \ - 0 \ - }, \ - \ - /* StringTable */ \ - { \ - L"\0" \ - }, \ - \ - /* SizeTable */ \ - { \ - 4 \ - }, \ - \ - /* SkuIdTable */ \ - { \ - /*MaxSku*/ 2, /*SkuId*/ 100, /*SkuId*/200 \ - },\ - \ - -// -// End of Autogen Code +// PCD_DXE_DATABASE_GENTOOL_VERSION is defined in Autogen.h +// and generated by PCD Database generation tool. // +#if (PCD_DXE_SERVICE_PEIM_VERSION != PCD_DXE_DATABASE_GENTOOL_VERSION) + #error "Please make sure the version of PCD Service DXE Driver and PCD DXE Database Generation Tool matches" #endif -/* -typedef struct { - PEI_PCD_DATABASE_INIT Init; - PEI_PCD_DATABASE_UNINIT Uninit; -} PEI_PCD_DATABASE; - - - -typedef struct { - DXE_PCD_DATABASE_INIT Init; - DXE_PCD_DATABASE_UNINIT Uninit; -} DXE_PCD_DATABASE; - - -typedef struct { - PEI_PCD_DATABASE PeiDb; - DXE_PCD_DATABASE DxeDb; -} PCD_DATABASE; -*/ - - // // Internal Functions // diff --git a/EdkModulePkg/Universal/PCD/Pei/Service.h b/EdkModulePkg/Universal/PCD/Pei/Service.h index 0059b2365e..5f334e141d 100644 --- a/EdkModulePkg/Universal/PCD/Pei/Service.h +++ b/EdkModulePkg/Universal/PCD/Pei/Service.h @@ -18,6 +18,20 @@ Module Name: Service.h #ifndef _SERVICE_H #define _SERVICE_H +// +// Please make sure the PCD Serivce PEIM Version is consistent with +// the version of PCD Database generation tool +// +#define PCD_PEI_SERVICE_DRIVER_VERSION 1 + +// +// PCD_PEI_DATABASE_GENTOOL_VERSION is defined in Autogen.h +// and generated by PCD Database generation tool. +// +#if (PCD_PEI_SERVICE_PEIM_VERSION != PCD_PEI_DATABASE_GENTOOL_VERSION) + #error "Please make sure the version of PCD Service PEIM and PCD PEI Database Generation Tool matches" +#endif + /* Internal Function definitions */ PEI_PCD_DATABASE * 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 6cc73ff228..9df18008cc 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java +++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java @@ -217,7 +217,7 @@ class SizeTable { return index; } - + private int getDatumSize(Token token) { /* switch (token.datumType) { @@ -674,6 +674,15 @@ class PcdDatabase { private ArrayList alTokens; private String phase; private int assignedTokenNumber; + + // + // After Major changes done to the PCD + // database generation class PcdDatabase + // Please increment the version and please + // also update the version number in PCD + // service PEIM and DXE driver accordingly. + // + private final int version = 1; private String hString; private String cString; @@ -754,10 +763,8 @@ class PcdDatabase { public void genCode () { final String newLine = "\r\n"; - final String instNewLine = "\\\r\n"; final String declNewLine = ";\r\n"; final String tab = "\t"; - final String commaInstNewLine = "\t,\\\r\n"; final String commaNewLine = ", \r\n"; int i; @@ -790,7 +797,8 @@ class PcdDatabase { // Generate Structure Declaration for PcdTokens without Default Value // PEI_PCD_DATABASE_UNINIT // - java.util.Collections.sort(uninitTokens, comparator); + list = uninitTokens; + java.util.Collections.sort(list, comparator); uninitCode = processTokens(uninitTokens); // @@ -851,12 +859,6 @@ class PcdDatabase { initInstStr += tab + genInstantiationStr(exMapTable.getInstantiation()) + commaNewLine; initInstStr += tab + genInstantiationStr(guidTable.getInstantiation()) + commaNewLine; initInstStr += tab + genInstantiationStr(localTokenNumberTable.getInstantiation()) + commaNewLine; - /* - inst = stringTable.getInstantiation(); - for (i = 0; i < inst.size(); i++ ) { - initInstStr += tab + inst.get(i) + commaNewLine; - } - */ initInstStr += tab + genInstantiationStr(stringTable.getInstantiation()) + commaNewLine; initInstStr += tab + genInstantiationStr(sizeTable.getInstantiation()) + commaNewLine; initInstStr += tab + genInstantiationStr(skuIdTable.getInstantiation()) + commaNewLine; @@ -907,6 +909,8 @@ class PcdDatabase { + initDeclStr + newLine + uninitDeclStr + newLine + newLine; + + hString += String.format("#define PCD_%s_SERVICE_DRIVER_VERSION %d", phase, version); } @@ -924,7 +928,6 @@ class PcdDatabase { private HashMap> processTokens (List alToken) { - ArrayList[] output = new ArrayList[4]; HashMap > map = new HashMap>(); ArrayList decl = new ArrayList(); @@ -1039,8 +1042,6 @@ class PcdDatabase { private String getDataTypeInstantiation (Token token) { - String typeStr = ""; - if (token.datumType == Token.DATUM_TYPE.POINTER) { return String.format("%s /* %s */", token.datum.toString(), token.getPrimaryKeyString()); } else {