1 /* 2 * kernelspecs.h 3 * 4 * SAL 2 annotations for kernel mode drivers 5 * 6 * This file is part of the ReactOS DDK package. 7 * 8 * Contributor: 9 * Timo Kreuzer (timo.kreuzer@reactos.org) 10 * 11 * THIS SOFTWARE IS NOT COPYRIGHTED 12 * 13 * This source code is offered for use in the public domain. You may 14 * use, modify or distribute it freely. 15 * 16 * This code is distributed in the hope that it will be useful but 17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 * DISCLAIMED. This includes but is not limited to warranties of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 * 21 */ 22 #pragma once 23 24 #define KERNELSPECS_H 25 26 #include "driverspecs.h" 27 28 #ifdef _PREFAST_ 29 30 /* Make sure we have IRQL level definitions early */ 31 #define DISPATCH_LEVEL 2 32 #define APC_LEVEL 1 33 #define PASSIVE_LEVEL 0 34 #if defined(_X86_) 35 #define HIGH_LEVEL 31 36 #elif defined(_AMD64_) 37 #define HIGH_LEVEL 15 38 #elif defined(_ARM_) 39 #define HIGH_LEVEL 15 40 #elif defined(_IA64_) 41 #define HIGH_LEVEL 15 42 #endif 43 44 #undef _IRQL_always_function_max_ 45 #undef _IRQL_always_function_min_ 46 #undef _IRQL_raises_ 47 #undef _IRQL_requires_ 48 #undef _IRQL_requires_max_ 49 #undef _IRQL_requires_min_ 50 #undef _IRQL_requires_same_ 51 #undef _IRQL_restores_ 52 #undef _IRQL_restores_global_ 53 #undef _IRQL_saves_ 54 #undef _IRQL_saves_global_ 55 #undef _IRQL_uses_cancel_ 56 #undef _IRQL_is_cancel_ 57 #undef __drv_setsIRQL 58 #undef __drv_raisesIRQL 59 #undef __drv_requiresIRQL 60 #undef __drv_maxIRQL 61 #undef __drv_minIRQL 62 #undef __drv_savesIRQL 63 #undef __drv_savesIRQLGlobal 64 #undef __drv_restoresIRQL 65 #undef __drv_restoresIRQLGlobal 66 #undef __drv_minFunctionIRQL 67 #undef __drv_maxFunctionIRQL 68 #undef __drv_sameIRQL 69 #undef __drv_useCancelIRQL 70 #undef __drv_isCancelIRQL 71 72 #define _IRQL_always_function_max_(irql) _Pre_ _SA_annotes1(SAL_maxFunctionIrql,irql) 73 #define _IRQL_always_function_min_(irql) _Pre_ _SA_annotes1(SAL_minFunctionIrql,irql) 74 #define _IRQL_raises_(irql) _Post_ _SA_annotes1(SAL_raiseIRQL,irql) 75 #define _IRQL_requires_(irql) _Pre_ _SA_annotes1(SAL_IRQL,irql) 76 #define _IRQL_requires_max_(irql) _Pre_ _SA_annotes1(SAL_maxIRQL,irql) 77 #define _IRQL_requires_min_(irql) _Pre_ _SA_annotes1(SAL_minIRQL,irql) 78 #define _IRQL_requires_same_ _Post_ _SA_annotes0(SAL_sameIRQL) 79 #define _IRQL_restores_ _Post_ _SA_annotes0(SAL_restoreIRQL) 80 #define _IRQL_restores_global_(kind,param) _Post_ _SA_annotes2(SAL_restoreIRQLGlobal, #kind, param\t) 81 #define _IRQL_saves_ _Post_ _SA_annotes0(SAL_saveIRQL) 82 #define _IRQL_saves_global_(kind,param) _Post_ _SA_annotes2(SAL_saveIRQLGlobal,#kind, param\t) 83 #define _IRQL_uses_cancel_ _Post_ _SA_annotes0(SAL_UseCancelIrql) 84 #define _IRQL_is_cancel_ _IRQL_uses_cancel_ _Releases_nonreentrant_lock_(_Global_cancel_spin_lock_) \ 85 _At_(return, _IRQL_always_function_min_(DISPATCH_LEVEL) _IRQL_requires_(DISPATCH_LEVEL)) 86 #define __drv_setsIRQL(irql) _Post_ _SA_annotes1(SAL_IRQL,irql) 87 #define __drv_raisesIRQL(irql) _IRQL_raises_(irql) 88 #define __drv_requiresIRQL(irql) _IRQL_requires_(irql) 89 #define __drv_maxIRQL(irql) _IRQL_requires_max_(irql) 90 #define __drv_minIRQL(irql) _IRQL_requires_min_(irql) 91 #define __drv_savesIRQL _IRQL_saves_ 92 #define __drv_savesIRQLGlobal(kind,param) _IRQL_saves_global_(kind,param) 93 #define __drv_restoresIRQL _IRQL_restores_ 94 #define __drv_restoresIRQLGlobal(kind,param) _IRQL_restores_global_(kind,param) 95 #define __drv_minFunctionIRQL(irql) _IRQL_always_function_min_(irql) 96 #define __drv_maxFunctionIRQL(irql) _IRQL_always_function_max_(irql) 97 #define __drv_sameIRQL _IRQL_requires_same_ 98 #define __drv_useCancelIRQL _IRQL_uses_cancel_ 99 #define __drv_isCancelIRQL _IRQL_is_cancel_ 100 101 #ifdef __cplusplus 102 extern "C" { 103 #endif 104 105 __ANNOTATION(SAL_IRQL(__int64);) 106 __ANNOTATION(SAL_raiseIRQL(__int64);) 107 __ANNOTATION(SAL_maxIRQL(__int64);) 108 __ANNOTATION(SAL_minIRQL(__int64);) 109 __ANNOTATION(SAL_saveIRQL(void);) 110 __ANNOTATION(SAL_saveIRQLGlobal(_In_ char *, ...);) 111 __ANNOTATION(SAL_restoreIRQL(void);) 112 __ANNOTATION(SAL_restoreIRQLGlobal(_In_ char *, ...);) 113 __ANNOTATION(SAL_minFunctionIrql(__int64);) 114 __ANNOTATION(SAL_maxFunctionIrql(__int64);) 115 __ANNOTATION(SAL_sameIRQL(void);) 116 __ANNOTATION(SAL_UseCancelIrql(void);) 117 118 #ifdef __cplusplus 119 } // extern "C" 120 #endif 121 122 #endif /* _PREFAST_ */ 123