Home | History | Annotate | Download | only in VfrCompile
      1 /** @file
      2 
      3   VfrCompiler Error definition
      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 _VFRERROR_H_
     17 #define _VFRERROR_H_
     18 
     19 #include "Common/UefiBaseTypes.h"
     20 
     21 typedef enum {
     22   VFR_RETURN_SUCCESS = 0,
     23   VFR_RETURN_ERROR_SKIPED,
     24   VFR_RETURN_FATAL_ERROR,
     25   VFR_RETURN_MISMATCHED,
     26   VFR_RETURN_INVALID_PARAMETER,
     27   VFR_RETURN_OUT_FOR_RESOURCES,
     28   VFR_RETURN_UNSUPPORTED,
     29   VFR_RETURN_REDEFINED,
     30   VFR_RETURN_FORMID_REDEFINED,
     31   VFR_RETURN_QUESTIONID_REDEFINED,
     32   VFR_RETURN_VARSTOREID_REDEFINED,
     33   VFR_RETURN_UNDEFINED,
     34   VFR_RETURN_VAR_NOTDEFINED_BY_QUESTION,
     35   VFR_RETURN_VARSTORE_DATATYPE_REDEFINED_ERROR,
     36   VFR_RETURN_GET_EFIVARSTORE_ERROR,
     37   VFR_RETURN_EFIVARSTORE_USE_ERROR,
     38   VFR_RETURN_EFIVARSTORE_SIZE_ERROR,
     39   VFR_RETURN_GET_NVVARSTORE_ERROR,
     40   VFR_RETURN_QVAR_REUSE,
     41   VFR_RETURN_FLAGS_UNSUPPORTED,
     42   VFR_RETURN_ERROR_ARRARY_NUM,
     43   VFR_RETURN_DATA_STRING_ERROR,
     44   VFR_RETURN_DEFAULT_VALUE_REDEFINED,
     45   VFR_RETURN_CONSTANT_ONLY,
     46   VFR_RETURN_VARSTORE_NAME_REDEFINED_ERROR,
     47   VFR_RETURN_CODEUNDEFINED
     48 } EFI_VFR_RETURN_CODE;
     49 
     50 typedef enum {
     51   VFR_WARNING_DEFAULT_VALUE_REDEFINED = 0,
     52   VFR_WARNING_STRING_TO_UINT_OVERFLOW,
     53   VFR_WARNING_ACTION_WITH_TEXT_TWO,
     54   VFR_WARNING_OBSOLETED_FRAMEWORK_OPCODE,
     55   VFR_WARNING_CODEUNDEFINED
     56 } EFI_VFR_WARNING_CODE;
     57 
     58 typedef struct _SVFR_ERROR_HANDLE {
     59   EFI_VFR_RETURN_CODE    mErrorCode;
     60   CONST CHAR8            *mErrorMsg;
     61 } SVFR_ERROR_HANDLE;
     62 
     63 typedef struct _SVFR_WARNING_HANDLE {
     64   EFI_VFR_WARNING_CODE    mWarningCode;
     65   CONST CHAR8            *mWarningMsg;
     66 } SVFR_WARNING_HANDLE;
     67 
     68 struct SVfrFileScopeRecord {
     69   CHAR8                 *mFileName;
     70   UINT32                mWholeScopeLine;
     71   UINT32                mScopeLineStart;
     72   SVfrFileScopeRecord *mNext;
     73 
     74   SVfrFileScopeRecord (IN CHAR8 *, IN UINT32);
     75   ~SVfrFileScopeRecord();
     76 
     77 private:
     78   SVfrFileScopeRecord (IN CONST SVfrFileScopeRecord&);             // Prevent copy-construction
     79   SVfrFileScopeRecord& operator= (IN CONST SVfrFileScopeRecord&);  // Prevent assignment
     80 };
     81 
     82 class CVfrErrorHandle {
     83 private:
     84   CHAR8               *mInputFileName;
     85   SVFR_ERROR_HANDLE   *mVfrErrorHandleTable;
     86   SVFR_WARNING_HANDLE *mVfrWarningHandleTable;
     87   SVfrFileScopeRecord *mScopeRecordListHead;
     88   SVfrFileScopeRecord *mScopeRecordListTail;
     89   BOOLEAN             mWarningAsError;
     90 
     91 public:
     92   CVfrErrorHandle (VOID);
     93   ~CVfrErrorHandle (VOID);
     94 
     95   VOID  SetWarningAsError (IN BOOLEAN);
     96   VOID  SetInputFile (IN CHAR8 *);
     97   VOID  ParseFileScopeRecord (IN CHAR8 *, IN UINT32);
     98   VOID  GetFileNameLineNum (IN UINT32, OUT CHAR8 **, OUT UINT32 *);
     99   UINT8 HandleError (IN EFI_VFR_RETURN_CODE, IN UINT32 LineNum = 0, IN CHAR8 *TokName = NULL);
    100   UINT8 HandleWarning (IN EFI_VFR_WARNING_CODE, IN UINT32 LineNum = 0, IN CHAR8 *TokName = NULL);
    101   VOID  PrintMsg (IN UINT32 LineNum = 0, IN CHAR8 *TokName = NULL, IN CONST CHAR8 *MsgType = "Error", IN CONST CHAR8 *ErrorMsg = "");
    102 
    103 private:
    104   CVfrErrorHandle (IN CONST CVfrErrorHandle&);             // Prevent copy-construction
    105   CVfrErrorHandle& operator= (IN CONST CVfrErrorHandle&);  // Prevent assignment
    106 };
    107 
    108 #define CHECK_ERROR_RETURN(f, v) do { EFI_VFR_RETURN_CODE r; if ((r = (f)) != (v)) { return r; } } while (0)
    109 
    110 extern CVfrErrorHandle gCVfrErrorHandle;
    111 
    112 #endif
    113