Home | History | Annotate | Download | only in VfrCompile
      1 /** @file
      2 
      3   VfrCompiler internal defintions.
      4 
      5 Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
      6 This program and the accompanying materials
      7 are licensed and made available under the terms and conditions of the BSD License
      8 which accompanies this distribution.  The full text of the license may be found at
      9 http://opensource.org/licenses/bsd-license.php
     10 
     11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     13 
     14 **/
     15 
     16 #ifndef _VFRCOMPILER_H_
     17 #define _VFRCOMPILER_H_
     18 
     19 #include "Common/UefiBaseTypes.h"
     20 #include "EfiVfr.h"
     21 #include "VfrFormPkg.h"
     22 #include "VfrUtilityLib.h"
     23 #include "ParseInf.h"
     24 
     25 #define PROGRAM_NAME                       "VfrCompile"
     26 #define VFR_COMPILER_VERSION               " 2.01 (UEFI 2.4) "
     27 //
     28 // This is how we invoke the C preprocessor on the VFR source file
     29 // to resolve #defines, #includes, etc. To make C source files
     30 // shareable between VFR and drivers, define VFRCOMPILE so that
     31 // #ifdefs can be used in shared .h files.
     32 //
     33 #define PREPROCESSOR_COMMAND                "cl "
     34 #define PREPROCESSOR_OPTIONS                "/nologo /E /TC /DVFRCOMPILE "
     35 
     36 //
     37 // Specify the filename extensions for the files we generate.
     38 //
     39 #define VFR_PREPROCESS_FILENAME_EXTENSION   ".i"
     40 #define VFR_PACKAGE_FILENAME_EXTENSION      ".hpk"
     41 #define VFR_RECORDLIST_FILENAME_EXTENSION   ".lst"
     42 
     43 typedef struct {
     44   CHAR8   *VfrFileName;
     45   CHAR8   *RecordListFile;
     46   CHAR8   *PkgOutputFileName;
     47   CHAR8   *COutputFileName;
     48   bool    CreateRecordListFile;
     49   bool    CreateIfrPkgFile;
     50   CHAR8   *OutputDirectory;
     51   CHAR8   *PreprocessorOutputFileName;
     52   CHAR8   *VfrBaseFileName;  // name of input VFR file with no path or extension
     53   CHAR8   *IncludePaths;
     54   bool    SkipCPreprocessor;
     55   CHAR8   *CPreprocessorOptions;
     56   BOOLEAN CompatibleMode;
     57   BOOLEAN HasOverrideClassGuid;
     58   EFI_GUID OverrideClassGuid;
     59   BOOLEAN WarningAsError;
     60   BOOLEAN AutoDefault;
     61   BOOLEAN CheckDefault;
     62 } OPTIONS;
     63 
     64 typedef enum {
     65   STATUS_STARTED = 0,
     66   STATUS_INITIALIZED,
     67   STATUS_PREPROCESSED,
     68   STATUS_COMPILEED,
     69   STATUS_GENBINARY,
     70   STATUS_FINISHED,
     71   STATUS_FAILED,
     72   STATUS_DEAD,
     73 } COMPILER_RUN_STATUS;
     74 
     75 class CVfrCompiler {
     76 private:
     77   COMPILER_RUN_STATUS  mRunStatus;
     78   OPTIONS              mOptions;
     79   CHAR8                *mPreProcessCmd;
     80   CHAR8                *mPreProcessOpt;
     81 
     82   VOID    OptionInitialization (IN INT32 , IN CHAR8 **);
     83   VOID    AppendIncludePath (IN CHAR8 *);
     84   VOID    AppendCPreprocessorOptions (IN CHAR8 *);
     85   INT8    SetBaseFileName (VOID);
     86   INT8    SetPkgOutputFileName (VOID);
     87   INT8    SetCOutputFileName(VOID);
     88   INT8    SetPreprocessorOutputFileName (VOID);
     89   INT8    SetRecordListFileName (VOID);
     90 
     91   VOID    SET_RUN_STATUS (IN COMPILER_RUN_STATUS);
     92   BOOLEAN IS_RUN_STATUS (IN COMPILER_RUN_STATUS);
     93 
     94 public:
     95   COMPILER_RUN_STATUS RunStatus (VOID) {
     96     return mRunStatus;
     97   }
     98 
     99 public:
    100   CVfrCompiler (IN INT32 , IN CHAR8 **);
    101   ~CVfrCompiler ();
    102 
    103   VOID                Usage (VOID);
    104   VOID                Version (VOID);
    105 
    106   VOID                PreProcess (VOID);
    107   VOID                Compile (VOID);
    108   VOID                AdjustBin (VOID);
    109   VOID                GenBinary (VOID);
    110   VOID                GenCFile (VOID);
    111   VOID                GenRecordListFile (VOID);
    112   VOID                DebugError (IN CHAR8*, IN UINT32, IN UINT32, IN CONST CHAR8*, IN CONST CHAR8*, ...);
    113 };
    114 
    115 #endif
    116