ctcdbug.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. *
  3. * linux/drivers/s390/net/ctcdbug.h ($Revision: 1.4 $)
  4. *
  5. * CTC / ESCON network driver - s390 dbf exploit.
  6. *
  7. * Copyright 2000,2003 IBM Corporation
  8. *
  9. * Author(s): Original Code written by
  10. * Peter Tiedemann (ptiedem@de.ibm.com)
  11. *
  12. * $Revision: 1.4 $ $Date: 2004/10/15 09:26:58 $
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2, or (at your option)
  17. * any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27. */
  28. #include <asm/debug.h>
  29. /**
  30. * Debug Facility stuff
  31. */
  32. #define CTC_DBF_SETUP_NAME "ctc_setup"
  33. #define CTC_DBF_SETUP_LEN 16
  34. #define CTC_DBF_SETUP_INDEX 3
  35. #define CTC_DBF_SETUP_NR_AREAS 1
  36. #define CTC_DBF_SETUP_LEVEL 3
  37. #define CTC_DBF_DATA_NAME "ctc_data"
  38. #define CTC_DBF_DATA_LEN 128
  39. #define CTC_DBF_DATA_INDEX 3
  40. #define CTC_DBF_DATA_NR_AREAS 1
  41. #define CTC_DBF_DATA_LEVEL 2
  42. #define CTC_DBF_TRACE_NAME "ctc_trace"
  43. #define CTC_DBF_TRACE_LEN 16
  44. #define CTC_DBF_TRACE_INDEX 2
  45. #define CTC_DBF_TRACE_NR_AREAS 2
  46. #define CTC_DBF_TRACE_LEVEL 3
  47. #define DBF_TEXT(name,level,text) \
  48. do { \
  49. debug_text_event(ctc_dbf_##name,level,text); \
  50. } while (0)
  51. #define DBF_HEX(name,level,addr,len) \
  52. do { \
  53. debug_event(ctc_dbf_##name,level,(void*)(addr),len); \
  54. } while (0)
  55. DECLARE_PER_CPU(char[256], ctc_dbf_txt_buf);
  56. extern debug_info_t *ctc_dbf_setup;
  57. extern debug_info_t *ctc_dbf_data;
  58. extern debug_info_t *ctc_dbf_trace;
  59. #define DBF_TEXT_(name,level,text...) \
  60. do { \
  61. char* ctc_dbf_txt_buf = get_cpu_var(ctc_dbf_txt_buf); \
  62. sprintf(ctc_dbf_txt_buf, text); \
  63. debug_text_event(ctc_dbf_##name,level,ctc_dbf_txt_buf); \
  64. put_cpu_var(ctc_dbf_txt_buf); \
  65. } while (0)
  66. #define DBF_SPRINTF(name,level,text...) \
  67. do { \
  68. debug_sprintf_event(ctc_dbf_trace, level, ##text ); \
  69. debug_sprintf_event(ctc_dbf_trace, level, text ); \
  70. } while (0)
  71. int ctc_register_dbf_views(void);
  72. void ctc_unregister_dbf_views(void);
  73. /**
  74. * some more debug stuff
  75. */
  76. #define HEXDUMP16(importance,header,ptr) \
  77. PRINT_##importance(header "%02x %02x %02x %02x %02x %02x %02x %02x " \
  78. "%02x %02x %02x %02x %02x %02x %02x %02x\n", \
  79. *(((char*)ptr)),*(((char*)ptr)+1),*(((char*)ptr)+2), \
  80. *(((char*)ptr)+3),*(((char*)ptr)+4),*(((char*)ptr)+5), \
  81. *(((char*)ptr)+6),*(((char*)ptr)+7),*(((char*)ptr)+8), \
  82. *(((char*)ptr)+9),*(((char*)ptr)+10),*(((char*)ptr)+11), \
  83. *(((char*)ptr)+12),*(((char*)ptr)+13), \
  84. *(((char*)ptr)+14),*(((char*)ptr)+15)); \
  85. PRINT_##importance(header "%02x %02x %02x %02x %02x %02x %02x %02x " \
  86. "%02x %02x %02x %02x %02x %02x %02x %02x\n", \
  87. *(((char*)ptr)+16),*(((char*)ptr)+17), \
  88. *(((char*)ptr)+18),*(((char*)ptr)+19), \
  89. *(((char*)ptr)+20),*(((char*)ptr)+21), \
  90. *(((char*)ptr)+22),*(((char*)ptr)+23), \
  91. *(((char*)ptr)+24),*(((char*)ptr)+25), \
  92. *(((char*)ptr)+26),*(((char*)ptr)+27), \
  93. *(((char*)ptr)+28),*(((char*)ptr)+29), \
  94. *(((char*)ptr)+30),*(((char*)ptr)+31));
  95. static inline void
  96. hex_dump(unsigned char *buf, size_t len)
  97. {
  98. size_t i;
  99. for (i = 0; i < len; i++) {
  100. if (i && !(i % 16))
  101. printk("\n");
  102. printk("%02x ", *(buf + i));
  103. }
  104. printk("\n");
  105. }