internal_log.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright (C) 2011-2018 Intel Corporation. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in
  12. * the documentation and/or other materials provided with the
  13. * distribution.
  14. * * Neither the name of Intel Corporation nor the names of its
  15. * contributors may be used to endorse or promote products derived
  16. * from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. *
  30. */
  31. #ifndef __OAL_INTERNAL_LOG_H__
  32. #define __OAL_INTERNAL_LOG_H__
  33. #ifdef DBG_LOG
  34. #include <stdint.h>
  35. #define FATAL_LOG_LEVEL 0 /*report critical internal error*/
  36. #define ERROR_LOG_LEVEL 1 /*report internal error message*/
  37. #define WARN_LOG_LEVEL 2 /*report internal warning messages*/
  38. #define INFO_LOG_LEVEL 3 /*aesm high level trace information, usually information for each components*/
  39. #define DEBUG_LOG_LEVEL 4 /*aesm middle level trace information, usually information for each function*/
  40. #define TRACE_LOG_LEVEL 5 /*aesm low level trace information, usually inside a control flow*/
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif/*__cplusplus*/
  44. void aesm_internal_log(const char *filename, int line_no, const char *funname, int level, const char *format, ...);
  45. void aesm_set_log_level(int level);
  46. void aesm_dbg_format_hex(const uint8_t *data, uint32_t data_len, char *out_buf, uint32_t buf_size);
  47. int enter_module(int module_index);
  48. void leave_module(int module_index);
  49. #ifdef __cplusplus
  50. };
  51. #endif/*__cplusplus*/
  52. #define AESM_DBG_FATAL(format, args...) aesm_internal_log(__FILE__, __LINE__, __FUNCTION__, FATAL_LOG_LEVEL, format, ## args)
  53. #define AESM_DBG_ERROR(format, args...) aesm_internal_log(__FILE__, __LINE__, __FUNCTION__, ERROR_LOG_LEVEL, format, ## args)
  54. #define AESM_DBG_WARN(format, args...) aesm_internal_log(__FILE__, __LINE__, __FUNCTION__, WARN_LOG_LEVEL, format, ## args)
  55. #define AESM_DBG_INFO(format, args...) aesm_internal_log(__FILE__, __LINE__, __FUNCTION__, INFO_LOG_LEVEL, format, ## args)
  56. #define AESM_DBG_DEBUG(format, args...) aesm_internal_log(__FILE__, __LINE__, __FUNCTION__, DEBUG_LOG_LEVEL, format, ## args)
  57. #define AESM_DBG_TRACE(format, args...) aesm_internal_log(__FILE__, __LINE__, __FUNCTION__, TRACE_LOG_LEVEL, format, ## args)
  58. #define AESM_SET_DBG_LEVEL(level) aesm_set_log_level(level)
  59. #else
  60. #define AESM_DBG_FATAL(args...)
  61. #define AESM_DBG_ERROR(args...)
  62. #define AESM_DBG_WARN(args...)
  63. #define AESM_DBG_INFO(args...)
  64. #define AESM_DBG_DEBUG(args...)
  65. #define AESM_DBG_TRACE(args...)
  66. #define AESM_SET_DBG_LEVEL(level)
  67. #endif/*DBG_LOG*/
  68. #define SGX_DBGPRINT_ONE_STRING_ONE_INT(x,y) AESM_DBG_WARN("%s %d", x, y)
  69. #define SGX_DBGPRINT_ONE_STRING_ONE_INT_LTP(x,y) AESM_DBG_WARN("LTP: %s %d", x, y)
  70. #define SGX_DBGPRINT_PRINT_FUNCTION_AND_RETURNVAL(x,y) AESM_DBG_WARN("%s returned %d",x,y)
  71. #define SGX_DBGPRINT_PRINT_TWO_STRINGS(x,y) AESM_DBG_WARN("%s %s",x, y)
  72. #define SGX_DBGPRINT_PRINT_TWO_STRINGS_ONE_INT(x,y,z) AESM_DBG_WARN("%s %s %d", x,y,z)
  73. #define SGX_DBGPRINT_PRINT_FIVE_STRINGS(a,b,c,d,e) AESM_DBG_WARN("%s %s %s %s %s",a,b,c,d,e)
  74. #define SGX_DBGPRINT_PRINT_ANSI_STRING(x) AESM_DBG_WARN("%s",x)
  75. #define SGX_DBGPRINT_PRINT_STRING_LTP(x) AESM_DBG_WARN("%s",x)
  76. #define SGX_DBGPRINT_PRINT_STRING(x) AESM_DBG_WARN("%s",x)
  77. #define SGX_DBGPRINT_ONE_STRING_ONE_INT_CERT(x,y) AESM_DBG_WARN("cert: %s %d", x, y)
  78. #define SGX_DBGPRINT_ONE_STRING_ONE_INT_OCSP(x,y) AESM_DBG_WARN("OCSP: %s %d", x, y)
  79. #define SGX_DBGPRINT_ONE_STRING_TWO_INTS_EPH(x,y,z)
  80. #define SGX_DBGPRINT_ONE_STRING_TWO_INTS_CREATE_SESSION(x,y,z)
  81. #define SGX_DBGPRINT_ONE_STRING_TWO_INTS_ENDPOINT_SELECTION(x,y,z)
  82. #endif/*__OAL_INTERNAL_LOG_H__*/