Home | History | Annotate | Download | only in UefiVfrCompile
      1 /*++
      2 
      3 Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
      4 This program and the accompanying materials
      5 are licensed and made available under the terms and conditions of the BSD License
      6 which accompanies this distribution.  The full text of the license may be found at
      7 http://opensource.org/licenses/bsd-license.php
      8 
      9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     11 
     12 Module Name:
     13 
     14   VfrError.h
     15 
     16 Abstract:
     17 
     18 --*/
     19 
     20 #ifndef _VFRERROR_H_
     21 #define _VFRERROR_H_
     22 
     23 #include "Tiano.h"
     24 #include "EfiTypes.h"
     25 
     26 typedef enum {
     27   VFR_RETURN_SUCCESS = 0,
     28   VFR_RETURN_ERROR_SKIPED,
     29   VFR_RETURN_FATAL_ERROR,
     30   VFR_RETURN_MISMATCHED,
     31   VFR_RETURN_INVALID_PARAMETER,
     32   VFR_RETURN_OUT_FOR_RESOURCES,
     33   VFR_RETURN_UNSUPPORTED,
     34   VFR_RETURN_REDEFINED,
     35   VFR_RETURN_FORMID_REDEFINED,
     36   VFR_RETURN_QUESTIONID_REDEFINED,
     37   VFR_RETURN_VARSTOREID_REDEFINED,
     38   VFR_RETURN_UNDEFINED,
     39   VFR_RETURN_VAR_NOTDEFINED_BY_QUESTION,
     40   VFR_RETURN_GET_EFIVARSTORE_ERROR,
     41   VFR_RETURN_EFIVARSTORE_USE_ERROR,
     42   VFR_RETURN_EFIVARSTORE_SIZE_ERROR,
     43   VFR_RETURN_GET_NVVARSTORE_ERROR,
     44   VFR_RETURN_QVAR_REUSE,
     45   VFR_RETURN_FLAGS_UNSUPPORTED,
     46   VFR_RETURN_ERROR_ARRARY_NUM,
     47   VFR_RETURN_DATA_STRING_ERROR,
     48   VFR_RETURN_DEFAULT_VALUE_REDEFINED,
     49   VFR_RETURN_CONSTANT_ONLY,
     50   VFR_RETURN_CODEUNDEFINED
     51 } EFI_VFR_RETURN_CODE;
     52 
     53 typedef struct _SVFR_ERROR_HANDLE {
     54   EFI_VFR_RETURN_CODE    mErrorCode;
     55   INT8                   *mErrorMsg;
     56 } SVFR_ERROR_HANDLE;
     57 
     58 struct SVfrFileScopeRecord {
     59   INT8                  *mFileName;
     60   UINT32                mWholeScopeLine;
     61   UINT32                mScopeLineStart;
     62   SVfrFileScopeRecord *mNext;
     63 
     64   SVfrFileScopeRecord (IN INT8 *, IN UINT32);
     65   ~SVfrFileScopeRecord();
     66 };
     67 
     68 class CVfrErrorHandle {
     69 private:
     70   INT8                *mInputFileName;
     71   SVFR_ERROR_HANDLE   *mVfrErrorHandleTable;
     72   SVfrFileScopeRecord *mScopeRecordListHead;
     73   SVfrFileScopeRecord *mScopeRecordListTail;
     74 
     75 public:
     76   CVfrErrorHandle (VOID);
     77   ~CVfrErrorHandle (VOID);
     78 
     79   VOID  SetInputFile (IN INT8 *);
     80   VOID  ParseFileScopeRecord (IN INT8 *, IN UINT32);
     81   VOID  GetFileNameLineNum (IN UINT32, OUT INT8 **, OUT UINT32 *);
     82   UINT8 HandleError (IN EFI_VFR_RETURN_CODE, IN UINT32 LineNum = 0, IN INT8 *TokName = "\0");
     83   VOID  PrintMsg (IN UINT32 LineNum = 0, IN INT8 *TokName = "\0", IN INT8 *MsgType = "Error", IN INT8 *ErrorMsg = "\0");
     84 };
     85 
     86 #define CHECK_ERROR_RETURN(f, v) do { EFI_VFR_RETURN_CODE r; if ((r = (f)) != (v)) { return r; } } while (0)
     87 
     88 extern CVfrErrorHandle gCVfrErrorHandle;
     89 
     90 #endif
     91