Merge tag 'mce-recovery-for-tip' of git://git.kernel.org/pub/scm/linux/kernel/git...
[deliverable/linux.git] / arch / s390 / include / asm / debug.h
CommitLineData
1da177e4
LT
1/*
2 * include/asm-s390/debug.h
3 * S/390 debug facility
4 *
5 * Copyright (C) 1999, 2000 IBM Deutschland Entwicklung GmbH,
6 * IBM Corporation
7 */
8
9#ifndef DEBUG_H
10#define DEBUG_H
11
66a464db 12#include <linux/fs.h>
1da177e4
LT
13
14/* Note:
15 * struct __debug_entry must be defined outside of #ifdef __KERNEL__
16 * in order to allow a user program to analyze the 'raw'-view.
17 */
18
19struct __debug_entry{
20 union {
21 struct {
22 unsigned long long clock:52;
23 unsigned long long exception:1;
24 unsigned long long level:3;
25 unsigned long long cpuid:8;
26 } fields;
27
28 unsigned long long stck;
29 } id;
30 void* caller;
31} __attribute__((packed));
32
33
66a464db 34#define __DEBUG_FEATURE_VERSION 2 /* version of debug feature */
1da177e4
LT
35
36#ifdef __KERNEL__
124b51c7 37#include <linux/string.h>
1da177e4
LT
38#include <linux/spinlock.h>
39#include <linux/kernel.h>
40#include <linux/time.h>
1da177e4
LT
41
42#define DEBUG_MAX_LEVEL 6 /* debug levels range from 0 to 6 */
43#define DEBUG_OFF_LEVEL -1 /* level where debug is switched off */
44#define DEBUG_FLUSH_ALL -1 /* parameter to flush all areas */
45#define DEBUG_MAX_VIEWS 10 /* max number of views in proc fs */
66a464db 46#define DEBUG_MAX_NAME_LEN 64 /* max length for a debugfs file name */
1da177e4
LT
47#define DEBUG_DEFAULT_LEVEL 3 /* initial debug level */
48
49#define DEBUG_DIR_ROOT "s390dbf" /* name of debug root directory in proc fs */
50
51#define DEBUG_DATA(entry) (char*)(entry + 1) /* data is stored behind */
52 /* the entry information */
53
1da177e4
LT
54typedef struct __debug_entry debug_entry_t;
55
56struct debug_view;
57
58typedef struct debug_info {
59 struct debug_info* next;
60 struct debug_info* prev;
61 atomic_t ref_count;
62 spinlock_t lock;
63 int level;
64 int nr_areas;
66a464db 65 int pages_per_area;
1da177e4
LT
66 int buf_size;
67 int entry_size;
66a464db 68 debug_entry_t*** areas;
1da177e4 69 int active_area;
66a464db
MH
70 int *active_pages;
71 int *active_entries;
72 struct dentry* debugfs_root_entry;
73 struct dentry* debugfs_entries[DEBUG_MAX_VIEWS];
1da177e4 74 struct debug_view* views[DEBUG_MAX_VIEWS];
66a464db 75 char name[DEBUG_MAX_NAME_LEN];
f4ae40a6 76 umode_t mode;
1da177e4
LT
77} debug_info_t;
78
79typedef int (debug_header_proc_t) (debug_info_t* id,
80 struct debug_view* view,
81 int area,
82 debug_entry_t* entry,
83 char* out_buf);
84
85typedef int (debug_format_proc_t) (debug_info_t* id,
86 struct debug_view* view, char* out_buf,
87 const char* in_buf);
88typedef int (debug_prolog_proc_t) (debug_info_t* id,
89 struct debug_view* view,
90 char* out_buf);
91typedef int (debug_input_proc_t) (debug_info_t* id,
92 struct debug_view* view,
93 struct file* file,
94 const char __user *user_buf,
95 size_t in_buf_size, loff_t* offset);
96
97int debug_dflt_header_fn(debug_info_t* id, struct debug_view* view,
98 int area, debug_entry_t* entry, char* out_buf);
99
100struct debug_view {
66a464db 101 char name[DEBUG_MAX_NAME_LEN];
1da177e4
LT
102 debug_prolog_proc_t* prolog_proc;
103 debug_header_proc_t* header_proc;
104 debug_format_proc_t* format_proc;
105 debug_input_proc_t* input_proc;
106 void* private_data;
107};
108
109extern struct debug_view debug_hex_ascii_view;
110extern struct debug_view debug_raw_view;
111extern struct debug_view debug_sprintf_view;
112
113/* do NOT use the _common functions */
114
115debug_entry_t* debug_event_common(debug_info_t* id, int level,
116 const void* data, int length);
117
118debug_entry_t* debug_exception_common(debug_info_t* id, int level,
119 const void* data, int length);
120
121/* Debug Feature API: */
122
5cbbf16a 123debug_info_t *debug_register(const char *name, int pages, int nr_areas,
1da177e4
LT
124 int buf_size);
125
5cbbf16a 126debug_info_t *debug_register_mode(const char *name, int pages, int nr_areas,
f4ae40a6 127 int buf_size, umode_t mode, uid_t uid,
9637c3f3
MH
128 gid_t gid);
129
1da177e4
LT
130void debug_unregister(debug_info_t* id);
131
132void debug_set_level(debug_info_t* id, int new_level);
133
134void debug_stop_all(void);
135
4448aaf0 136static inline debug_entry_t*
1da177e4
LT
137debug_event(debug_info_t* id, int level, void* data, int length)
138{
66a464db
MH
139 if ((!id) || (level > id->level) || (id->pages_per_area == 0))
140 return NULL;
1da177e4
LT
141 return debug_event_common(id,level,data,length);
142}
143
4448aaf0 144static inline debug_entry_t*
1da177e4
LT
145debug_int_event(debug_info_t* id, int level, unsigned int tag)
146{
147 unsigned int t=tag;
66a464db
MH
148 if ((!id) || (level > id->level) || (id->pages_per_area == 0))
149 return NULL;
1da177e4
LT
150 return debug_event_common(id,level,&t,sizeof(unsigned int));
151}
152
4448aaf0 153static inline debug_entry_t *
1da177e4
LT
154debug_long_event (debug_info_t* id, int level, unsigned long tag)
155{
156 unsigned long t=tag;
66a464db
MH
157 if ((!id) || (level > id->level) || (id->pages_per_area == 0))
158 return NULL;
1da177e4
LT
159 return debug_event_common(id,level,&t,sizeof(unsigned long));
160}
161
4448aaf0 162static inline debug_entry_t*
1da177e4
LT
163debug_text_event(debug_info_t* id, int level, const char* txt)
164{
66a464db
MH
165 if ((!id) || (level > id->level) || (id->pages_per_area == 0))
166 return NULL;
1da177e4
LT
167 return debug_event_common(id,level,txt,strlen(txt));
168}
169
f64d04c0
MH
170/*
171 * IMPORTANT: Use "%s" in sprintf format strings with care! Only pointers are
172 * stored in the s390dbf. See Documentation/s390/s390dbf.txt for more details!
173 */
1da177e4
LT
174extern debug_entry_t *
175debug_sprintf_event(debug_info_t* id,int level,char *string,...)
176 __attribute__ ((format(printf, 3, 4)));
177
178
4448aaf0 179static inline debug_entry_t*
1da177e4
LT
180debug_exception(debug_info_t* id, int level, void* data, int length)
181{
66a464db
MH
182 if ((!id) || (level > id->level) || (id->pages_per_area == 0))
183 return NULL;
1da177e4
LT
184 return debug_exception_common(id,level,data,length);
185}
186
4448aaf0 187static inline debug_entry_t*
1da177e4
LT
188debug_int_exception(debug_info_t* id, int level, unsigned int tag)
189{
190 unsigned int t=tag;
66a464db
MH
191 if ((!id) || (level > id->level) || (id->pages_per_area == 0))
192 return NULL;
1da177e4
LT
193 return debug_exception_common(id,level,&t,sizeof(unsigned int));
194}
195
4448aaf0 196static inline debug_entry_t *
1da177e4
LT
197debug_long_exception (debug_info_t* id, int level, unsigned long tag)
198{
199 unsigned long t=tag;
66a464db
MH
200 if ((!id) || (level > id->level) || (id->pages_per_area == 0))
201 return NULL;
1da177e4
LT
202 return debug_exception_common(id,level,&t,sizeof(unsigned long));
203}
204
4448aaf0 205static inline debug_entry_t*
1da177e4
LT
206debug_text_exception(debug_info_t* id, int level, const char* txt)
207{
66a464db
MH
208 if ((!id) || (level > id->level) || (id->pages_per_area == 0))
209 return NULL;
1da177e4
LT
210 return debug_exception_common(id,level,txt,strlen(txt));
211}
212
f64d04c0
MH
213/*
214 * IMPORTANT: Use "%s" in sprintf format strings with care! Only pointers are
215 * stored in the s390dbf. See Documentation/s390/s390dbf.txt for more details!
216 */
1da177e4
LT
217extern debug_entry_t *
218debug_sprintf_exception(debug_info_t* id,int level,char *string,...)
219 __attribute__ ((format(printf, 3, 4)));
220
221int debug_register_view(debug_info_t* id, struct debug_view* view);
222int debug_unregister_view(debug_info_t* id, struct debug_view* view);
223
224/*
225 define the debug levels:
226 - 0 No debugging output to console or syslog
227 - 1 Log internal errors to syslog, ignore check conditions
228 - 2 Log internal errors and check conditions to syslog
229 - 3 Log internal errors to console, log check conditions to syslog
230 - 4 Log internal errors and check conditions to console
231 - 5 panic on internal errors, log check conditions to console
232 - 6 panic on both, internal errors and check conditions
233 */
234
235#ifndef DEBUG_LEVEL
236#define DEBUG_LEVEL 4
237#endif
238
239#define INTERNAL_ERRMSG(x,y...) "E" __FILE__ "%d: " x, __LINE__, y
240#define INTERNAL_WRNMSG(x,y...) "W" __FILE__ "%d: " x, __LINE__, y
241#define INTERNAL_INFMSG(x,y...) "I" __FILE__ "%d: " x, __LINE__, y
242#define INTERNAL_DEBMSG(x,y...) "D" __FILE__ "%d: " x, __LINE__, y
243
244#if DEBUG_LEVEL > 0
245#define PRINT_DEBUG(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
246#define PRINT_INFO(x...) printk ( KERN_INFO PRINTK_HEADER x )
247#define PRINT_WARN(x...) printk ( KERN_WARNING PRINTK_HEADER x )
248#define PRINT_ERR(x...) printk ( KERN_ERR PRINTK_HEADER x )
249#define PRINT_FATAL(x...) panic ( PRINTK_HEADER x )
250#else
251#define PRINT_DEBUG(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
252#define PRINT_INFO(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
253#define PRINT_WARN(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
254#define PRINT_ERR(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
255#define PRINT_FATAL(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
256#endif /* DASD_DEBUG */
257
1da177e4
LT
258#endif /* __KERNEL__ */
259#endif /* DEBUG_H */
This page took 0.821473 seconds and 5 git commands to generate.