## @file
# Routines for generating AutoGen.h and AutoGen.c
#
# Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
## Import Modules
#
import string
from Common.BuildToolError import *
from StrGather import *
## PCD type string
TAB_PCDS_FEATURE_FLAG : 'FixedAtBuild',
TAB_PCDS_FIXED_AT_BUILD : 'FixedAtBuild',
TAB_PCDS_PATCHABLE_IN_MODULE: 'BinaryPatch',
TAB_PCDS_DYNAMIC : '',
TAB_PCDS_DYNAMIC_DEFAULT : '',
TAB_PCDS_DYNAMIC_VPD : '',
TAB_PCDS_DYNAMIC_HII : '',
TAB_PCDS_DYNAMIC_EX : '',
TAB_PCDS_DYNAMIC_EX_VPD : '',
TAB_PCDS_DYNAMIC_EX_HII : '',
}
## Dynamic PCD types
gDynamicPcd = [TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_HII]
## Dynamic-ex PCD types
gDynamicExPcd = [TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEFAULT, TAB_PCDS_DYNAMIC_EX_VPD, TAB_PCDS_DYNAMIC_EX_HII]
## Datum size
gDatumSizeStringDatabase = {'UINT8':'8','UINT16':'16','UINT32':'32','UINT64':'64','BOOLEAN':'BOOLEAN','VOID*':'8'}
gDatumSizeStringDatabaseH = {'UINT8':'8','UINT16':'16','UINT32':'32','UINT64':'64','BOOLEAN':'BOOL','VOID*':'PTR'}
gDatumSizeStringDatabaseLib = {'UINT8':'8','UINT16':'16','UINT32':'32','UINT64':'64','BOOLEAN':'Bool','VOID*':'Ptr'}
## Mapping between PCD driver type and EFI phase
gPcdPhaseMap = {
"PEI_PCD_DRIVER" : "PEI",
"DXE_PCD_DRIVER" : "DXE"
}
//
// The following definition will be generated by build tool
//
//
// Common definitions
//
typedef UINT8 SKU_ID;
#define PCD_TYPE_SHIFT 28
#define PCD_TYPE_DATA (0x0U << PCD_TYPE_SHIFT)
#define PCD_TYPE_HII (0x8U << PCD_TYPE_SHIFT)
#define PCD_TYPE_VPD (0x4U << PCD_TYPE_SHIFT)
#define PCD_TYPE_SKU_ENABLED (0x2U << PCD_TYPE_SHIFT)
#define PCD_TYPE_STRING (0x1U << 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_DATUM_TYPE_POINTER (0x0U << PCD_DATUM_TYPE_SHIFT)
#define PCD_DATUM_TYPE_UINT8 (0x1U << PCD_DATUM_TYPE_SHIFT)
#define PCD_DATUM_TYPE_UINT16 (0x2U << PCD_DATUM_TYPE_SHIFT)
#define PCD_DATUM_TYPE_UINT32 (0x4U << PCD_DATUM_TYPE_SHIFT)
#define PCD_DATUM_TYPE_UINT64 (0x8U << 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;
UINT16 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 {
UINT32 StringIndex; // Offset in String Table in units of UINT32.
UINT32 DefaultValueOffset; // Offset of the Default Value
UINT16 GuidTableIndex; // Offset in Guid Table in units of GUID.
UINT16 Offset; // Offset in Variable
} VARIABLE_HEAD;
typedef struct {
UINT32 Offset;
} VPD_HEAD;
typedef UINT32 STRING_HEAD;
typedef UINT16 SIZE_INFO;
#define offsetof(s,m) (UINT32) (UINTN) &(((s *)0)->m)
"""
typedef struct {
PEI_PCD_DATABASE PeiDb;
DXE_PCD_DATABASE DxeDb;
} PCD_DATABASE;
#define PCD_TOTAL_TOKEN_NUMBER (PEI_LOCAL_TOKEN_NUMBER + DXE_LOCAL_TOKEN_NUMBER)
"""
#define ${PHASE}_GUID_TABLE_SIZE ${GUID_TABLE_SIZE}
#define ${PHASE}_STRING_TABLE_SIZE ${STRING_TABLE_SIZE}
#define ${PHASE}_SKUID_TABLE_SIZE ${SKUID_TABLE_SIZE}
#define ${PHASE}_LOCAL_TOKEN_NUMBER_TABLE_SIZE ${LOCAL_TOKEN_NUMBER_TABLE_SIZE}
#define ${PHASE}_LOCAL_TOKEN_NUMBER ${LOCAL_TOKEN_NUMBER}
#define ${PHASE}_EXMAPPING_TABLE_SIZE ${EXMAPPING_TABLE_SIZE}
#define ${PHASE}_EX_TOKEN_NUMBER ${EX_TOKEN_NUMBER}
#define ${PHASE}_SIZE_TABLE_SIZE ${SIZE_TABLE_SIZE}
#define ${PHASE}_GUID_TABLE_EMPTY ${GUID_TABLE_EMPTY}
#define ${PHASE}_STRING_TABLE_EMPTY ${STRING_TABLE_EMPTY}
#define ${PHASE}_SKUID_TABLE_EMPTY ${SKUID_TABLE_EMPTY}
#define ${PHASE}_DATABASE_EMPTY ${DATABASE_EMPTY}
#define ${PHASE}_EXMAP_TABLE_EMPTY ${EXMAP_TABLE_EMPTY}
typedef struct {
${BEGIN} UINT64 ${INIT_CNAME_DECL_UINT64}_${INIT_GUID_DECL_UINT64}[${INIT_NUMSKUS_DECL_UINT64}];
${END}
${BEGIN} UINT64 ${VARDEF_CNAME_UINT64}_${VARDEF_GUID_UINT64}_VariableDefault_${VARDEF_SKUID_UINT64};
${END}
${BEGIN} UINT32 ${INIT_CNAME_DECL_UINT32}_${INIT_GUID_DECL_UINT32}[${INIT_NUMSKUS_DECL_UINT32}];
${END}
${BEGIN} UINT32 ${VARDEF_CNAME_UINT32}_${VARDEF_GUID_UINT32}_VariableDefault_${VARDEF_SKUID_UINT32};
${END}
${BEGIN} VPD_HEAD ${VPD_HEAD_CNAME_DECL}_${VPD_HEAD_GUID_DECL}[${VPD_HEAD_NUMSKUS_DECL}];
${END}
DYNAMICEX_MAPPING ExMapTable[${PHASE}_EXMAPPING_TABLE_SIZE];
UINT32 LocalTokenNumberTable[${PHASE}_LOCAL_TOKEN_NUMBER_TABLE_SIZE];
GUID GuidTable[${PHASE}_GUID_TABLE_SIZE];
${BEGIN} STRING_HEAD ${STRING_HEAD_CNAME_DECL}_${STRING_HEAD_GUID_DECL}[${STRING_HEAD_NUMSKUS_DECL}];
${END}
${BEGIN} VARIABLE_HEAD ${VARIABLE_HEAD_CNAME_DECL}_${VARIABLE_HEAD_GUID_DECL}_Variable_Header[${VARIABLE_HEAD_NUMSKUS_DECL}];
${END}
${BEGIN} UINT8 StringTable${STRING_TABLE_INDEX}[${STRING_TABLE_LENGTH}]; /* ${STRING_TABLE_CNAME}_${STRING_TABLE_GUID} */
${END}
SIZE_INFO SizeTable[${PHASE}_SIZE_TABLE_SIZE];
${BEGIN} UINT16 ${INIT_CNAME_DECL_UINT16}_${INIT_GUID_DECL_UINT16}[${INIT_NUMSKUS_DECL_UINT16}];
${END}
${BEGIN} UINT16 ${VARDEF_CNAME_UINT16}_${VARDEF_GUID_UINT16}_VariableDefault_${VARDEF_SKUID_UINT16};
${END}
${BEGIN} UINT8 ${INIT_CNAME_DECL_UINT8}_${INIT_GUID_DECL_UINT8}[${INIT_NUMSKUS_DECL_UINT8}];
${END}
${BEGIN} UINT8 ${VARDEF_CNAME_UINT8}_${VARDEF_GUID_UINT8}_VariableDefault_${VARDEF_SKUID_UINT8};
${END}
${BEGIN} BOOLEAN ${INIT_CNAME_DECL_BOOLEAN}_${INIT_GUID_DECL_BOOLEAN}[${INIT_NUMSKUS_DECL_BOOLEAN}];
${END}
${BEGIN} BOOLEAN ${VARDEF_CNAME_BOOLEAN}_${VARDEF_GUID_BOOLEAN}_VariableDefault_${VARDEF_SKUID_BOOLEAN};
${END}
UINT8 SkuIdTable[${PHASE}_SKUID_TABLE_SIZE];
${SYSTEM_SKU_ID}
} ${PHASE}_PCD_DATABASE_INIT;
typedef struct {
${PCD_DATABASE_UNINIT_EMPTY}
${BEGIN} UINT64 ${UNINIT_CNAME_DECL_UINT64}_${UNINIT_GUID_DECL_UINT64}[${UNINIT_NUMSKUS_DECL_UINT64}];
${END}
${BEGIN} UINT32 ${UNINIT_CNAME_DECL_UINT32}_${UNINIT_GUID_DECL_UINT32}[${UNINIT_NUMSKUS_DECL_UINT32}];
${END}
${BEGIN} UINT16 ${UNINIT_CNAME_DECL_UINT16}_${UNINIT_GUID_DECL_UINT16}[${UNINIT_NUMSKUS_DECL_UINT16}];
${END}
${BEGIN} UINT8 ${UNINIT_CNAME_DECL_UINT8}_${UNINIT_GUID_DECL_UINT8}[${UNINIT_NUMSKUS_DECL_UINT8}];
${END}
${BEGIN} BOOLEAN ${UNINIT_CNAME_DECL_BOOLEAN}_${UNINIT_GUID_DECL_BOOLEAN}[${UNINIT_NUMSKUS_DECL_BOOLEAN}];
${END}
} ${PHASE}_PCD_DATABASE_UNINIT;
#define PCD_${PHASE}_SERVICE_DRIVER_VERSION 2
typedef struct {
${PHASE}_PCD_DATABASE_INIT Init;
${PHASE}_PCD_DATABASE_UNINIT Uninit;
} ${PHASE}_PCD_DATABASE;
#define ${PHASE}_NEX_TOKEN_NUMBER (${PHASE}_LOCAL_TOKEN_NUMBER - ${PHASE}_EX_TOKEN_NUMBER)
""")
${PHASE}_PCD_DATABASE_INIT g${PHASE}PcdDbInit = {
/* ExMapTable */
{
{0, 0, 0}
},
/* LocalTokenNumberTable */
{
0
},
/* GuidTable */
{
{0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}
},
/* StringTable */
{ 0 },
/* SizeTable */
{
0, 0
},
/* SkuIdTable */
{ 0 },
${SYSTEM_SKU_ID_VALUE}
};
""")
${PHASE}_PCD_DATABASE_INIT g${PHASE}PcdDbInit = {
${BEGIN} { ${INIT_VALUE_UINT64} }, /* ${INIT_CNAME_DECL_UINT64}_${INIT_GUID_DECL_UINT64}[${INIT_NUMSKUS_DECL_UINT64}] */
${END}
${BEGIN} ${VARDEF_VALUE_UINT64}, /* ${VARDEF_CNAME_UINT64}_${VARDEF_GUID_UINT64}_VariableDefault_${VARDEF_SKUID_UINT64} */
${END}
${BEGIN} { ${INIT_VALUE_UINT32} }, /* ${INIT_CNAME_DECL_UINT32}_${INIT_GUID_DECL_UINT32}[${INIT_NUMSKUS_DECL_UINT32}] */
${END}
${BEGIN} ${VARDEF_VALUE_UINT32}, /* ${VARDEF_CNAME_UINT32}_${VARDEF_GUID_UINT32}_VariableDefault_${VARDEF_SKUID_UINT32} */
${END}
/* VPD */
${BEGIN} { ${VPD_HEAD_VALUE} }, /* ${VPD_HEAD_CNAME_DECL}_${VPD_HEAD_GUID_DECL}[${VPD_HEAD_NUMSKUS_DECL}] */
${END}
/* ExMapTable */
{
${BEGIN} { ${EXMAPPING_TABLE_EXTOKEN}, ${EXMAPPING_TABLE_LOCAL_TOKEN}, ${EXMAPPING_TABLE_GUID_INDEX} },
${END}
},
/* LocalTokenNumberTable */
{
${BEGIN} offsetof(${PHASE}_PCD_DATABASE, ${TOKEN_INIT}.${TOKEN_CNAME}_${TOKEN_GUID}${VARDEF_HEADER}) | ${TOKEN_TYPE},
${END}
},
/* GuidTable */
{
${BEGIN} ${GUID_STRUCTURE},
${END}
},
${BEGIN} { ${STRING_HEAD_VALUE} }, /* ${STRING_HEAD_CNAME_DECL}_${STRING_HEAD_GUID_DECL}[${STRING_HEAD_NUMSKUS_DECL}] */
${END}
${BEGIN} /* ${VARIABLE_HEAD_CNAME_DECL}_${VARIABLE_HEAD_GUID_DECL}_Variable_Header[${VARIABLE_HEAD_NUMSKUS_DECL}] */
{
${VARIABLE_HEAD_VALUE}
},
${END}
/* StringTable */
${BEGIN} ${STRING_TABLE_VALUE}, /* ${STRING_TABLE_CNAME}_${STRING_TABLE_GUID} */
${END}
/* SizeTable */
{
${BEGIN} ${SIZE_TABLE_MAXIMUM_LENGTH}, ${SIZE_TABLE_CURRENT_LENGTH}, /* ${SIZE_TABLE_CNAME}_${SIZE_TABLE_GUID} */
${END}
},
${BEGIN} { ${INIT_VALUE_UINT16} }, /* ${INIT_CNAME_DECL_UINT16}_${INIT_GUID_DECL_UINT16}[${INIT_NUMSKUS_DECL_UINT16}] */
${END}
${BEGIN} ${VARDEF_VALUE_UINT16}, /* ${VARDEF_CNAME_UINT16}_${VARDEF_GUID_UINT16}_VariableDefault_${VARDEF_SKUID_UINT16} */
${END}
${BEGIN} { ${INIT_VALUE_UINT8} }, /* ${INIT_CNAME_DECL_UINT8}_${INIT_GUID_DECL_UINT8}[${INIT_NUMSKUS_DECL_UINT8}] */
${END}
${BEGIN} ${VARDEF_VALUE_UINT8}, /* ${VARDEF_CNAME_UINT8}_${VARDEF_GUID_UINT8}_VariableDefault_${VARDEF_SKUID_UINT8} */
${END}
${BEGIN} { ${INIT_VALUE_BOOLEAN} }, /* ${INIT_CNAME_DECL_BOOLEAN}_${INIT_GUID_DECL_BOOLEAN}[${INIT_NUMSKUS_DECL_BOOLEAN}] */
${END}
${BEGIN} ${VARDEF_VALUE_BOOLEAN}, /* ${VARDEF_CNAME_BOOLEAN}_${VARDEF_GUID_BOOLEAN}_VariableDefault_${VARDEF_SKUID_BOOLEAN} */
${END}
/* SkuIdTable */
{ ${BEGIN}${SKUID_VALUE}, ${END} },
${SYSTEM_SKU_ID_VALUE}
};
""")
## AutoGen File Header Templates
/**
DO NOT EDIT
FILE auto-generated
Module name:
${FileName}
Abstract: Auto-generated ${FileName} for building module or library.
**/
""")
#ifndef _${File}_${Guid}
#define _${File}_${Guid}
""")
gAutoGenHCppPrologueString = """\
#ifdef __cplusplus
extern "C" {
#endif
"""
gAutoGenHEpilogueString = """
#ifdef __cplusplus
}
#endif
#endif
"""
## PEI Core Entry Point Templates
${BEGIN}
VOID
EFIAPI
${Function} (
IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,
IN VOID *Context
);
${END}
""")
${BEGIN}
VOID
EFIAPI
ProcessModuleEntryPointList (
IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,
IN VOID *Context
)
{
${Function} (SecCoreData, PpiList, Context);
}
${END}
""")
## DXE Core Entry Point Templates
${BEGIN}
VOID
EFIAPI
${Function} (
IN VOID *HobStart
);
${END}
""")
${BEGIN}
VOID
EFIAPI
ProcessModuleEntryPointList (
IN VOID *HobStart
)
{
${Function} (HobStart);
}
${END}
""")
## PEIM Entry Point Templates
${BEGIN}
EFI_STATUS
EFIAPI
${Function} (
IN EFI_PEI_FILE_HANDLE FileHandle,
IN CONST EFI_PEI_SERVICES **PeiServices
);
${END}
""")
TemplateString("""
GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = ${PiSpecVersion};
EFI_STATUS
EFIAPI
ProcessModuleEntryPointList (
IN EFI_PEI_FILE_HANDLE FileHandle,
IN CONST EFI_PEI_SERVICES **PeiServices
)
{
return EFI_SUCCESS;
}
"""),
TemplateString("""
GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = ${PiSpecVersion};
${BEGIN}
EFI_STATUS
EFIAPI
ProcessModuleEntryPointList (
IN EFI_PEI_FILE_HANDLE FileHandle,
IN CONST EFI_PEI_SERVICES **PeiServices
)
{
return ${Function} (FileHandle, PeiServices);
}
${END}
"""),
TemplateString("""
GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = ${PiSpecVersion};
EFI_STATUS
EFIAPI
ProcessModuleEntryPointList (
IN EFI_PEI_FILE_HANDLE FileHandle,
IN CONST EFI_PEI_SERVICES **PeiServices
)
{
EFI_STATUS Status;
EFI_STATUS CombinedStatus;
CombinedStatus = EFI_LOAD_ERROR;
${BEGIN}
Status = ${Function} (FileHandle, PeiServices);
if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {
CombinedStatus = Status;
}
${END}
return CombinedStatus;
}
""")
]
## SMM_CORE Entry Point Templates
${BEGIN}
EFI_STATUS
EFIAPI
${Function} (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
${END}
""")
${BEGIN}
const UINT32 _gUefiDriverRevision = ${UefiSpecVersion};
const UINT32 _gDxeRevision = ${PiSpecVersion};
EFI_STATUS
EFIAPI
ProcessModuleEntryPointList (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
return ${Function} (ImageHandle, SystemTable);
}
${END}
""")
## DXE SMM Entry Point Templates
${BEGIN}
EFI_STATUS
EFIAPI
${Function} (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
${END}
""")
TemplateString("""
const UINT32 _gUefiDriverRevision = ${UefiSpecVersion};
const UINT32 _gDxeRevision = ${PiSpecVersion};
EFI_STATUS
EFIAPI
ProcessModuleEntryPointList (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
return EFI_SUCCESS;
}
"""),
TemplateString("""
const UINT32 _gUefiDriverRevision = ${UefiSpecVersion};
const UINT32 _gDxeRevision = ${PiSpecVersion};
static BASE_LIBRARY_JUMP_BUFFER mJumpContext;
static EFI_STATUS mDriverEntryPointStatus;
VOID
EFIAPI
ExitDriver (
IN EFI_STATUS Status
)
{
if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {
mDriverEntryPointStatus = Status;
}
LongJump (&mJumpContext, (UINTN)-1);
ASSERT (FALSE);
}
EFI_STATUS
EFIAPI
ProcessModuleEntryPointList (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
mDriverEntryPointStatus = EFI_LOAD_ERROR;
${BEGIN}
if (SetJump (&mJumpContext) == 0) {
ExitDriver (${Function} (ImageHandle, SystemTable));
ASSERT (FALSE);
}
${END}
return mDriverEntryPointStatus;
}
""")
]
## UEFI Driver Entry Point Templates
${BEGIN}
EFI_STATUS
EFIAPI
${Function} (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
${END}
""")
TemplateString("""
const UINT32 _gUefiDriverRevision = ${UefiSpecVersion};
const UINT32 _gDxeRevision = ${PiSpecVersion};
EFI_STATUS
EFIAPI
ProcessModuleEntryPointList (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
return EFI_SUCCESS;
}
"""),
TemplateString("""
const UINT32 _gUefiDriverRevision = ${UefiSpecVersion};
const UINT32 _gDxeRevision = ${PiSpecVersion};
${BEGIN}
EFI_STATUS
EFIAPI
ProcessModuleEntryPointList (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
return ${Function} (ImageHandle, SystemTable);
}
${END}
VOID
EFIAPI
ExitDriver (
IN EFI_STATUS Status
)
{
if (EFI_ERROR (Status)) {
ProcessLibraryDestructorList (gImageHandle, gST);
}
gBS->Exit (gImageHandle, Status, 0, NULL);
}
"""),
TemplateString("""
const UINT32 _gUefiDriverRevision = ${UefiSpecVersion};
const UINT32 _gDxeRevision = ${PiSpecVersion};
static BASE_LIBRARY_JUMP_BUFFER mJumpContext;
static EFI_STATUS mDriverEntryPointStatus;
EFI_STATUS
EFIAPI
ProcessModuleEntryPointList (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
mDriverEntryPointStatus = EFI_LOAD_ERROR;
${BEGIN}
if (SetJump (&mJumpContext) == 0) {
ExitDriver (${Function} (ImageHandle, SystemTable));
ASSERT (FALSE);
}
${END}
return mDriverEntryPointStatus;
}
VOID
EFIAPI
ExitDriver (
IN EFI_STATUS Status
)
{
if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {
mDriverEntryPointStatus = Status;
}
LongJump (&mJumpContext, (UINTN)-1);
ASSERT (FALSE);
}
""")
]
## UEFI Application Entry Point Templates
${BEGIN}
EFI_STATUS
EFIAPI
${Function} (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
${END}
""")
TemplateString("""
const UINT32 _gUefiDriverRevision = ${UefiSpecVersion};
EFI_STATUS
EFIAPI
ProcessModuleEntryPointList (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
return EFI_SUCCESS;
}
"""),
TemplateString("""
const UINT32 _gUefiDriverRevision = ${UefiSpecVersion};
${BEGIN}
EFI_STATUS
EFIAPI
ProcessModuleEntryPointList (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
return ${Function} (ImageHandle, SystemTable);
}
${END}
VOID
EFIAPI
ExitDriver (
IN EFI_STATUS Status
)
{
if (EFI_ERROR (Status)) {
ProcessLibraryDestructorList (gImageHandle, gST);
}
gBS->Exit (gImageHandle, Status, 0, NULL);
}
"""),
TemplateString("""
const UINT32 _gUefiDriverRevision = ${UefiSpecVersion};
EFI_STATUS
EFIAPI
ProcessModuleEntryPointList (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
${BEGIN}
if (SetJump (&mJumpContext) == 0) {
ExitDriver (${Function} (ImageHandle, SystemTable));
ASSERT (FALSE);
}
${END}
return mDriverEntryPointStatus;
}
static BASE_LIBRARY_JUMP_BUFFER mJumpContext;
static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;
VOID
EFIAPI
ExitDriver (
IN EFI_STATUS Status
)
{
if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {
mDriverEntryPointStatus = Status;
}
LongJump (&mJumpContext, (UINTN)-1);
ASSERT (FALSE);
}
""")
]
## UEFI Unload Image Templates
${BEGIN}
EFI_STATUS
EFIAPI
${Function} (
IN EFI_HANDLE ImageHandle
);
${END}
""")
TemplateString("""
GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ${Count};
EFI_STATUS
EFIAPI
ProcessModuleUnloadList (
IN EFI_HANDLE ImageHandle
)
{
return EFI_SUCCESS;
}
"""),
TemplateString("""
GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ${Count};
${BEGIN}
EFI_STATUS
EFIAPI
ProcessModuleUnloadList (
IN EFI_HANDLE ImageHandle
)
{
return ${Function} (ImageHandle);
}
${END}
"""),
TemplateString("""
GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ${Count};
EFI_STATUS
EFIAPI
ProcessModuleUnloadList (
IN EFI_HANDLE ImageHandle
)
{
EFI_STATUS Status;
Status = EFI_SUCCESS;
${BEGIN}
if (EFI_ERROR (Status)) {
${Function} (ImageHandle);
} else {
Status = ${Function} (ImageHandle);
}
${END}
return Status;
}
""")
]
RETURN_STATUS
EFIAPI
${Function} (
VOID
);${END}
"""),
EFI_STATUS
EFIAPI
${Function} (
IN EFI_PEI_FILE_HANDLE FileHandle,
IN CONST EFI_PEI_SERVICES **PeiServices
);${END}
"""),
EFI_STATUS
EFIAPI
${Function} (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);${END}
"""),
}
Status = ${Function} ();
ASSERT_EFI_ERROR (Status);${END}
"""),
Status = ${Function} (FileHandle, PeiServices);
ASSERT_EFI_ERROR (Status);${END}
"""),
Status = ${Function} (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);${END}
"""),
}
## Library Constructor and Destructor Templates
gLibraryString = {
${BEGIN}${FunctionPrototype}${END}
VOID
EFIAPI
ProcessLibrary${Type}List (
VOID
)
{
${BEGIN} EFI_STATUS Status;
${FunctionCall}${END}
}
"""),
${BEGIN}${FunctionPrototype}${END}
VOID
EFIAPI
ProcessLibrary${Type}List (
IN EFI_PEI_FILE_HANDLE FileHandle,
IN CONST EFI_PEI_SERVICES **PeiServices
)
{
${BEGIN} EFI_STATUS Status;
${FunctionCall}${END}
}
"""),
${BEGIN}${FunctionPrototype}${END}
VOID
EFIAPI
ProcessLibrary${Type}List (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
${BEGIN} EFI_STATUS Status;
${FunctionCall}${END}
}
"""),
}
"BASE" : [gBasicHeaderFile],
"DXE_DRIVER" : ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
"DXE_SMM_DRIVER" : ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
"DXE_RUNTIME_DRIVER": ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
"DXE_SAL_DRIVER" : ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
"UEFI_DRIVER" : ["Uefi.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
"UEFI_APPLICATION" : ["Uefi.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiApplicationEntryPoint.h"],
"SMM_CORE" : ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiDriverEntryPoint.h"],
"USER_DEFINED" : [gBasicHeaderFile]
}
## Create code for module PCDs
#
# @param Info The ModuleAutoGen object
# @param AutoGenC The TemplateString object for C code
# @param AutoGenH The TemplateString object for header file
# @param Pcd The PCD object
#
#
# Write PCDs
#
else:
EdkLogger.debug(EdkLogger.DEBUG_3, "Creating code for " + Pcd.TokenCName + "." + Pcd.TokenSpaceGuidCName)
AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
else:
AutoGenH.Append('#define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdTokenName))
else:
AutoGenH.Append('#define %s(Value) LibPcdSet%s(%s, (Value))\n' % (SetModeName, DatumSizeLib, PcdTokenName))
else:
Const = 'const'
Const = ''
Type = ''
Array = ''
ValueNumber = 0
Value = '1U'
Value = '0U'
try:
else:
except:
"PCD value is not valid dec or hex number for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
if ValueNumber < 0:
"PCD can't be set to negative value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
elif ValueNumber >= 0x10000000000000000:
"Too large PCD value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
Value += 'ULL'
if ValueNumber < 0:
"PCD can't be set to negative value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
elif ValueNumber >= 0x100000000:
"Too large PCD value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
Value += 'U'
if ValueNumber < 0:
"PCD can't be set to negative value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
elif ValueNumber >= 0x10000:
"Too large PCD value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
Value += 'U'
if ValueNumber < 0:
"PCD can't be set to negative value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
elif ValueNumber >= 0x100:
"Too large PCD value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
Value += 'U'
Type = '(VOID *)'
else:
NewValue = '{'
if Unicode:
else:
if Unicode:
"The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
#
# skip casting for fixed at build since it breaks ARM assembly.
# Long term we need PCD macros that work in assembly
#
else:
#
# For unicode, UINT16 array will be generated, so the alignment of unicode is guaranteed.
#
if Unicode:
AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s UINT16 %s%s = %s;\n' % (Const, PcdVariableName, Array, Value))
else:
AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s UINT8 %s%s = %s;\n' % (Const, PcdVariableName, Array, Value))
else:
AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s %s %s = %s;\n' %(Const, Pcd.DatumType, PcdVariableName, PcdValueName))
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtr(_gPcd_BinaryPatch_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeName, Pcd.TokenCName, Pcd.TokenCName))
else:
else:
AutoGenH.Append('//#define %s ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD\n' % SetModeName)
## Create code for library module PCDs
#
# @param Info The ModuleAutoGen object
# @param AutoGenC The TemplateString object for C code
# @param AutoGenH The TemplateString object for header file
# @param Pcd The PCD object
#
# If PCD is DynamicEx, then use TokenNumber declared in DEC file
Type = ''
Array = ''
Type = '(VOID *)'
Array = '[]'
#if PcdItemType in gDynamicPcd:
# PcdItemType = TAB_PCDS_FIXED_AT_BUILD
# if (TokenCName, TokenSpaceGuidCName) in Info.PlatformInfo.Platform.Pcds:
# PcdItemType = Info.PlatformInfo.Platform.Pcds[TokenCName, TokenSpaceGuidCName].Type
if PcdItemType in gDynamicExPcd:
AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, TokenSpaceGuidCName, PcdTokenName))
if DatumType == 'VOID*':
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName,DatumSizeLib, TokenSpaceGuidCName, PcdTokenName))
else:
AutoGenH.Append('#define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, TokenSpaceGuidCName, PcdTokenName))
if PcdItemType in gDynamicPcd:
if DatumType == 'VOID*':
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdTokenName))
else:
AutoGenH.Append('#define %s(Value) LibPcdSet%s(%s, (Value))\n' % (SetModeName, DatumSizeLib, PcdTokenName))
PcdVariableName = '_gPcd_' + gItemTypeStringDatabase[TAB_PCDS_PATCHABLE_IN_MODULE] + '_' + TokenCName
#AutoGenH.Append('#define _PCD_VALUE_%s _gPcd_FixedAtBuild_%s\n' %(TokenCName, TokenCName))
AutoGenH.Append('//#define %s ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD\n' % SetModeName)
## Create code for PCD database in DXE or PEI phase
#
# @param Platform The platform object
# @retval tuple Two TemplateString objects for C code and header file,
# respectively
#
Dict = {
'PHASE' : Phase,
'GUID_TABLE_SIZE' : '1U',
'STRING_TABLE_SIZE' : '1U',
'SKUID_TABLE_SIZE' : '1U',
'LOCAL_TOKEN_NUMBER_TABLE_SIZE' : '1U',
'LOCAL_TOKEN_NUMBER' : '0U',
'EXMAPPING_TABLE_SIZE' : '1U',
'EX_TOKEN_NUMBER' : '0U',
'SIZE_TABLE_SIZE' : '2U',
'GUID_TABLE_EMPTY' : 'TRUE',
'STRING_TABLE_EMPTY' : 'TRUE',
'SKUID_TABLE_EMPTY' : 'TRUE',
'DATABASE_EMPTY' : 'TRUE',
'EXMAP_TABLE_EMPTY' : 'TRUE',
'PCD_DATABASE_UNINIT_EMPTY' : ' UINT8 dummy; /* PCD_DATABASE_UNINIT is emptry */',
'SYSTEM_SKU_ID' : ' SKU_ID SystemSkuId;',
'SYSTEM_SKU_ID_VALUE' : '0U'
}
Dict['STRING_TABLE_INDEX'] = []
Dict['STRING_TABLE_LENGTH'] = []
Dict['STRING_TABLE_CNAME'] = []
Dict['STRING_TABLE_GUID'] = []
Dict['STRING_TABLE_VALUE'] = []
Dict['SIZE_TABLE_CNAME'] = []
Dict['SIZE_TABLE_GUID'] = []
Dict['SIZE_TABLE_CURRENT_LENGTH'] = []
Dict['SIZE_TABLE_MAXIMUM_LENGTH'] = []
Dict['EXMAPPING_TABLE_EXTOKEN'] = []
Dict['EXMAPPING_TABLE_LOCAL_TOKEN'] = []
Dict['EXMAPPING_TABLE_GUID_INDEX'] = []
Dict['GUID_STRUCTURE'] = []
Dict['SKUID_VALUE'] = []
Dict['VARDEF_HEADER'] = []
if Phase == 'DXE':
StringTableIndex = 0
StringTableSize = 0
NumberOfExTokens = 0
GuidList = []
EdkLogger.debug(EdkLogger.DEBUG_3, "PCD: %s %s (%s : %s)" % (CName, TokenSpaceGuidCName, Pcd.Phase, Phase))
continue
#
# TODO: need GetGuidValue() definition
#
if TokenSpaceGuid not in GuidList:
GuidList += [TokenSpaceGuid]
NumberOfExTokens += 1
ValueList = []
StringHeadOffsetList = []
VpdHeadOffsetList = []
else:
Pcd.TokenTypeList = []
else:
continue
if StringTableIndex == 0:
else:
StringTableIndex += 1
if VariableGuid not in GuidList:
GuidList += [VariableGuid]
else:
VariableHeadValueList.append('%dU, offsetof(%s_PCD_DATABASE, Init.%s_%s_VariableDefault_%s), %dU, %sU' %
Dict['VARDEF_VALUE_' + Pcd.DatumType].append("%s_%s[%d]" % (Pcd.TokenCName, TokenSpaceGuid, SkuIdIndex))
else:
#
# ULL (for UINT64) or U(other integer type) should be append to avoid
# warning under linux building environment.
#
else:
continue
NumberOfSizeItems += 1
if StringTableIndex == 0:
else:
if MaxDatumSize < Size:
"The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
StringTableIndex += 1
StringTableSize += (Size)
else:
else:
try:
except:
pass
#
# For UNIT64 type PCD's value, ULL should be append to avoid
# warning under linux building environment.
#
else:
else:
else:
if Phase == 'PEI':
if Phase == 'DXE':
continue
TokenSpaceGuid = GuidStructureStringToGuidValueName(Pcd.TokenSpaceGuidValue) #(Platform.PackageList, TokenSpaceGuidCName))
if Phase == 'DXE':
#
# Update VARDEF_HEADER
#
else:
if Phase == 'DXE':
#
# Per, PCD architecture specification, PCD Token Number is 1 based and 0 is defined as invalid token number.
# For each EX type PCD, a PCD Token Number is assigned. When the
# Therefore, 1 is added to GeneratedTokenNumber to generate a PCD Token Number before being inserted
# to the EXMAPPING_TABLE.
#
if GuidList != []:
else:
if StringTableIndex == 0:
else:
if Dict['SIZE_TABLE_CNAME'] == []:
if NumberOfLocalTokens != 0:
if NumberOfExTokens != 0:
else:
if NumberOfSizeItems != 0:
if NumberOfLocalTokens == 0:
else:
#
# Update Size Table to the right order, it should be same with LocalTokenNumberTable
#
SizeCNameTempList = []
SizeGuidTempList = []
SizeCurLenTempList = []
SizeMaxLenTempList = []
if ReOrderFlag:
## Create code for PCD database
#
# @param Info The ModuleAutoGen object
# @param AutoGenC The TemplateString object for C code
# @param AutoGenH The TemplateString object for header file
#
return
AdditionalAutoGenH, AdditionalAutoGenC = CreatePcdDatabasePhaseSpecificAutoGen (Info.PlatformInfo, 'PEI')
if Phase == 'PEI':
if Phase == 'DXE':
AdditionalAutoGenH, AdditionalAutoGenC = CreatePcdDatabasePhaseSpecificAutoGen (Info.PlatformInfo, Phase)
## Create code for library constructor
#
# @param Info The ModuleAutoGen object
# @param AutoGenC The TemplateString object for C code
# @param AutoGenH The TemplateString object for header file
#
#
# Library Constructors
#
else:
for Lib in DependentLibraryList:
continue
'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:
else:
else:
Dict = {
'Type' : 'Constructor',
'FunctionPrototype' : ConstructorPrototypeList,
'FunctionCall' : ConstructorCallingList
}
else:
'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:
## Create code for library destructor
#
# @param Info The ModuleAutoGen object
# @param AutoGenC The TemplateString object for C code
# @param AutoGenH The TemplateString object for header file
#
#
# Library Destructors
#
else:
continue
'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION', 'SMM_CORE']:
else:
else:
Dict = {
'Type' : 'Destructor',
'FunctionPrototype' : DestructorPrototypeList,
'FunctionCall' : DestructorCallingList
}
else:
'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:
## Create code for ModuleEntryPoint
#
# @param Info The ModuleAutoGen object
# @param AutoGenC The TemplateString object for C code
# @param AutoGenH The TemplateString object for header file
#
return
#
# Module Entry Points
#
else:
PiSpecVersion = '0x00000000'
else:
UefiSpecVersion = '0x00000000'
Dict = {
}
if NumEntryPoints != 1:
"build",
)
if NumEntryPoints < 2:
else:
if NumEntryPoints < 2:
else:
if NumEntryPoints == 0:
else:
if NumEntryPoints < 2:
else:
## Create code for ModuleUnloadImage
#
# @param Info The ModuleAutoGen object
# @param AutoGenC The TemplateString object for C code
# @param AutoGenH The TemplateString object for header file
#
return
#
# Unload Image Handlers
#
if NumUnloadImage < 2:
else:
## Create code for GUID
#
# @param Info The ModuleAutoGen object
# @param AutoGenC The TemplateString object for C code
# @param AutoGenH The TemplateString object for header file
#
return
GuidType = "GUID"
else:
GuidType = "EFI_GUID"
#
# GUIDs
#
AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s %s = %s;\n' % (GuidType, Key, Info.GuidList[Key]))
## Create code for protocol
#
# @param Info The ModuleAutoGen object
# @param AutoGenC The TemplateString object for C code
# @param AutoGenH The TemplateString object for header file
#
return
GuidType = "GUID"
else:
GuidType = "EFI_GUID"
if Info.ProtocolList:
#
# Protocol GUIDs
#
AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s %s = %s;\n' % (GuidType, Key, Info.ProtocolList[Key]))
## Create code for PPI
#
# @param Info The ModuleAutoGen object
# @param AutoGenC The TemplateString object for C code
# @param AutoGenH The TemplateString object for header file
#
return
GuidType = "GUID"
else:
GuidType = "EFI_GUID"
#
# PPI GUIDs
#
## Create code for PCD
#
# @param Info The ModuleAutoGen object
# @param AutoGenC The TemplateString object for C code
# @param AutoGenH The TemplateString object for header file
#
# Collect Token Space GUIDs used by DynamicEc PCDs
TokenSpaceList = []
# Add extern declarations to AutoGen.h if one or more Token Space GUIDs were found
if TokenSpaceList <> []:
GuidType = "GUID"
else:
GuidType = "EFI_GUID"
for Item in TokenSpaceList:
if Info.ModulePcdList:
else:
if Info.ModulePcdList:
if Info.LibraryPcdList:
## Create code for unicode string definition
#
# @param Info The ModuleAutoGen object
# @param AutoGenC The TemplateString object for C code
# @param AutoGenH The TemplateString object for header file
# @param UniGenCFlag UniString is generated into AutoGen C file when it is set to True
# @param UniGenBinBuffer Buffer to store uni string package data
#
# Get all files under [Sources] section in inf file for EDK-II module
# Get all files under the module directory for EDK-I module
if 'CVS' in Dirs:
if '.svn' in Dirs:
continue
else:
#
# -s is a temporary option dedicated for building .UNI files with ISO 639-2 language codes of EDK Shell in EDK2
#
if CompatibleMode:
"-c and -s build options should be used exclusively",
else:
#RFC4646 is only for EDKII modules and ISO639-2 for EDK modules
if EDK2Module:
else:
Header, Code = GetStringFiles(Info.UnicodeFileList, SrcList, IncList, Info.IncludePathList, ['.uni', '.inf'], Info.Name, CompatibleMode, ShellMode, UniGenCFlag, UniGenBinBuffer, FilterInfo)
if CompatibleMode or UniGenCFlag:
if CompatibleMode or UniGenCFlag:
## Create common code
#
# @param Info The ModuleAutoGen object
# @param AutoGenC The TemplateString object for C code
# @param AutoGenH The TemplateString object for header file
#
# file header
# header file Prologue
AutoGenH.Append(gAutoGenHPrologueString.Replace({'File':'AUTOGENH','Guid':Info.Guid.replace('-','_')}))
# header files includes
#
# if either PcdLib in [LibraryClasses] sections or there exist Pcd section, add PcdLib.h
# As if modules only uses FixedPcd, then PcdLib is not needed in [LibraryClasses] section.
#
return
AutoGenH.Append("#define EFI_CALLER_ID_GUID \\\n %s\n" % GuidStringToGuidStructureString(Info.Guid))
return
# C file header
# C file header files includes
else:
#
# Publish the CallerId Guid
#
AutoGenC.Append('\nGLOBAL_REMOVE_IF_UNREFERENCED GUID gEfiCallerIdGuid = %s;\n' % GuidStringToGuidStructureString(Info.Guid))
## Create common code for header file
#
# @param Info The ModuleAutoGen object
# @param AutoGenC The TemplateString object for C code
# @param AutoGenH The TemplateString object for header file
#
## Create code for a module
#
# @param Info The ModuleAutoGen object
# @param AutoGenC The TemplateString object for C code
# @param AutoGenH The TemplateString object for header file
# @param UniGenCFlag UniString is generated into AutoGen C file when it is set to True
# @param UniGenBinBuffer Buffer to store uni string package data
#
if Info.UnicodeFileList:
StringH.Append(gAutoGenHPrologueString.Replace({'File':'STRDEFS', 'Guid':Info.Guid.replace('-','_')}))
# no generation of AutoGen.c for Edk modules without unicode file
## Create the code file
#
# @param FilePath The path of code file
# @param Content The content of code file
# @param IsBinaryFile The flag indicating if the file is binary file or not
#
# @retval True If file content is changed or file doesn't exist
# @retval False If the file exists and the content is not changed
#