debuggers.hg

view tools/vtpm_manager/util/log.h @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children
line source
1 // ===================================================================
2 //
3 // Copyright (c) 2005, Intel Corp.
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions
8 // are met:
9 //
10 // * Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 // * Redistributions in binary form must reproduce the above
13 // copyright notice, this list of conditions and the following
14 // disclaimer in the documentation and/or other materials provided
15 // with the distribution.
16 // * Neither the name of Intel Corporation nor the names of its
17 // contributors may be used to endorse or promote products derived
18 // from this software without specific prior written permission.
19 //
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31 // OF THE POSSIBILITY OF SUCH DAMAGE.
32 // ===================================================================
34 #ifndef __VTPM_LOG_H__
35 #define __VTPM_LOG_H__
37 #include <stdint.h> // for uint32_t
38 #include <stddef.h> // for pointer NULL
40 // =========================== LOGGING ==============================
42 // the logging module numbers
43 #define VTPM_LOG_CRYPTO 1
44 #define VTPM_LOG_BSG 2
45 #define VTPM_LOG_TXDATA 3
46 #define VTPM_LOG_TCS 4
47 #define VTPM_LOG_TCS_DEEP 5
48 #define VTPM_LOG_VTSP 6
49 #define VTPM_LOG_VTPM 7
50 #define VTPM_LOG_VTPM_DEEP 8
51 #define VTPM_LOG_VTSP_DEEP 9
53 static char *module_names[] = { "",
54 "CRYPTO",
55 "BSG",
56 "TXDATA",
57 "TCS",
58 "TCS",
59 "VTSP",
60 "VTPM",
61 "VTPM",
62 "VTSP"
63 };
65 // Default to standard logging
66 #ifndef LOGGING_MODULES
67 #define LOGGING_MODULES (BITMASK(VTPM_LOG_VTPM))
68 #endif
70 // bit-access macros
71 #define BITMASK(idx) ( 1U << (idx) )
72 #define GETBIT(num,idx) ( ((num) & BITMASK(idx)) >> idx )
73 #define SETBIT(num,idx) (num) |= BITMASK(idx)
74 #define CLEARBIT(num,idx) (num) &= ( ~ BITMASK(idx) )
76 #define vtpmloginfo(module, fmt, args...) \
77 if (GETBIT (LOGGING_MODULES, module) == 1) { \
78 fprintf (stdout, "INFO[%s]: " fmt, module_names[module], ##args); \
79 }
81 #define vtpmloginfomore(module, fmt, args...) \
82 if (GETBIT (LOGGING_MODULES, module) == 1) { \
83 fprintf (stdout, fmt,##args); \
84 }
86 #define vtpmlogerror(module, fmt, args...) \
87 fprintf (stderr, "ERROR[%s]: " fmt, module_names[module], ##args);
89 //typedef UINT32 tpm_size_t;
91 // helper function for the error codes:
92 const char* tpm_get_error_name (TPM_RESULT code);
94 #endif // _VTPM_LOG_H_