blob: 7d6afa1627c3534cc86f1805f9f4da45c92fa47e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 *
Michael Holzheu66a464d2005-06-25 14:55:33 -07003 * linux/drivers/s390/net/ctcdbug.h ($Revision: 1.6 $)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
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 *
Michael Holzheu66a464d2005-06-25 14:55:33 -070012 * $Revision: 1.6 $ $Date: 2005/05/11 08:10:17 $
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 *
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 */
Frank Pavlic7394c922005-05-12 20:36:47 +020028#ifndef _CTCDBUG_H_
29#define _CTCDBUG_H_
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31#include <asm/debug.h>
Frank Pavlic7394c922005-05-12 20:36:47 +020032#include "ctcmain.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070033/**
34 * Debug Facility stuff
35 */
36#define CTC_DBF_SETUP_NAME "ctc_setup"
37#define CTC_DBF_SETUP_LEN 16
Michael Holzheu66a464d2005-06-25 14:55:33 -070038#define CTC_DBF_SETUP_PAGES 8
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#define CTC_DBF_SETUP_NR_AREAS 1
40#define CTC_DBF_SETUP_LEVEL 3
41
42#define CTC_DBF_DATA_NAME "ctc_data"
43#define CTC_DBF_DATA_LEN 128
Michael Holzheu66a464d2005-06-25 14:55:33 -070044#define CTC_DBF_DATA_PAGES 8
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#define CTC_DBF_DATA_NR_AREAS 1
Frank Pavlic7394c922005-05-12 20:36:47 +020046#define CTC_DBF_DATA_LEVEL 3
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
48#define CTC_DBF_TRACE_NAME "ctc_trace"
49#define CTC_DBF_TRACE_LEN 16
Michael Holzheu66a464d2005-06-25 14:55:33 -070050#define CTC_DBF_TRACE_PAGES 4
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#define CTC_DBF_TRACE_NR_AREAS 2
52#define CTC_DBF_TRACE_LEVEL 3
53
54#define DBF_TEXT(name,level,text) \
55 do { \
56 debug_text_event(ctc_dbf_##name,level,text); \
57 } while (0)
58
59#define DBF_HEX(name,level,addr,len) \
60 do { \
61 debug_event(ctc_dbf_##name,level,(void*)(addr),len); \
62 } while (0)
63
64DECLARE_PER_CPU(char[256], ctc_dbf_txt_buf);
65extern debug_info_t *ctc_dbf_setup;
66extern debug_info_t *ctc_dbf_data;
67extern debug_info_t *ctc_dbf_trace;
68
69
70#define DBF_TEXT_(name,level,text...) \
71 do { \
72 char* ctc_dbf_txt_buf = get_cpu_var(ctc_dbf_txt_buf); \
73 sprintf(ctc_dbf_txt_buf, text); \
74 debug_text_event(ctc_dbf_##name,level,ctc_dbf_txt_buf); \
75 put_cpu_var(ctc_dbf_txt_buf); \
76 } while (0)
77
78#define DBF_SPRINTF(name,level,text...) \
79 do { \
80 debug_sprintf_event(ctc_dbf_trace, level, ##text ); \
81 debug_sprintf_event(ctc_dbf_trace, level, text ); \
82 } while (0)
83
84
85int ctc_register_dbf_views(void);
86
87void ctc_unregister_dbf_views(void);
88
89/**
90 * some more debug stuff
91 */
92
93#define HEXDUMP16(importance,header,ptr) \
94PRINT_##importance(header "%02x %02x %02x %02x %02x %02x %02x %02x " \
95 "%02x %02x %02x %02x %02x %02x %02x %02x\n", \
96 *(((char*)ptr)),*(((char*)ptr)+1),*(((char*)ptr)+2), \
97 *(((char*)ptr)+3),*(((char*)ptr)+4),*(((char*)ptr)+5), \
98 *(((char*)ptr)+6),*(((char*)ptr)+7),*(((char*)ptr)+8), \
99 *(((char*)ptr)+9),*(((char*)ptr)+10),*(((char*)ptr)+11), \
100 *(((char*)ptr)+12),*(((char*)ptr)+13), \
101 *(((char*)ptr)+14),*(((char*)ptr)+15)); \
102PRINT_##importance(header "%02x %02x %02x %02x %02x %02x %02x %02x " \
103 "%02x %02x %02x %02x %02x %02x %02x %02x\n", \
104 *(((char*)ptr)+16),*(((char*)ptr)+17), \
105 *(((char*)ptr)+18),*(((char*)ptr)+19), \
106 *(((char*)ptr)+20),*(((char*)ptr)+21), \
107 *(((char*)ptr)+22),*(((char*)ptr)+23), \
108 *(((char*)ptr)+24),*(((char*)ptr)+25), \
109 *(((char*)ptr)+26),*(((char*)ptr)+27), \
110 *(((char*)ptr)+28),*(((char*)ptr)+29), \
111 *(((char*)ptr)+30),*(((char*)ptr)+31));
112
113static inline void
114hex_dump(unsigned char *buf, size_t len)
115{
116 size_t i;
117
118 for (i = 0; i < len; i++) {
119 if (i && !(i % 16))
120 printk("\n");
121 printk("%02x ", *(buf + i));
122 }
123 printk("\n");
124}
125
Frank Pavlic7394c922005-05-12 20:36:47 +0200126
127#endif