• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2 
3   VfrCompiler Error definition
4 
5 Copyright (c) 2004 - 2013, 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 
78 class CVfrErrorHandle {
79 private:
80   CHAR8               *mInputFileName;
81   SVFR_ERROR_HANDLE   *mVfrErrorHandleTable;
82   SVFR_WARNING_HANDLE *mVfrWarningHandleTable;
83   SVfrFileScopeRecord *mScopeRecordListHead;
84   SVfrFileScopeRecord *mScopeRecordListTail;
85   BOOLEAN             mWarningAsError;
86 
87 public:
88   CVfrErrorHandle (VOID);
89   ~CVfrErrorHandle (VOID);
90 
91   VOID  SetWarningAsError (IN BOOLEAN);
92   VOID  SetInputFile (IN CHAR8 *);
93   VOID  ParseFileScopeRecord (IN CHAR8 *, IN UINT32);
94   VOID  GetFileNameLineNum (IN UINT32, OUT CHAR8 **, OUT UINT32 *);
95   UINT8 HandleError (IN EFI_VFR_RETURN_CODE, IN UINT32 LineNum = 0, IN CHAR8 *TokName = NULL);
96   UINT8 HandleWarning (IN EFI_VFR_WARNING_CODE, IN UINT32 LineNum = 0, IN CHAR8 *TokName = NULL);
97   VOID  PrintMsg (IN UINT32 LineNum = 0, IN CHAR8 *TokName = NULL, IN CONST CHAR8 *MsgType = "Error", IN CONST CHAR8 *ErrorMsg = "");
98 };
99 
100 #define CHECK_ERROR_RETURN(f, v) do { EFI_VFR_RETURN_CODE r; if ((r = (f)) != (v)) { return r; } } while (0)
101 
102 extern CVfrErrorHandle gCVfrErrorHandle;
103 
104 #endif
105