4 * Copyright IBM Corp. 1999, 2000
13 * struct __debug_entry must be defined outside of #ifdef __KERNEL__
14 * in order to allow a user program to analyze the 'raw'-view.
20 unsigned long long clock
:52;
21 unsigned long long exception
:1;
22 unsigned long long level
:3;
23 unsigned long long cpuid
:8;
26 unsigned long long stck
;
29 } __attribute__((packed
));
32 #define __DEBUG_FEATURE_VERSION 2 /* version of debug feature */
35 #include <linux/string.h>
36 #include <linux/spinlock.h>
37 #include <linux/kernel.h>
38 #include <linux/time.h>
40 #define DEBUG_MAX_LEVEL 6 /* debug levels range from 0 to 6 */
41 #define DEBUG_OFF_LEVEL -1 /* level where debug is switched off */
42 #define DEBUG_FLUSH_ALL -1 /* parameter to flush all areas */
43 #define DEBUG_MAX_VIEWS 10 /* max number of views in proc fs */
44 #define DEBUG_MAX_NAME_LEN 64 /* max length for a debugfs file name */
45 #define DEBUG_DEFAULT_LEVEL 3 /* initial debug level */
47 #define DEBUG_DIR_ROOT "s390dbf" /* name of debug root directory in proc fs */
49 #define DEBUG_DATA(entry) (char*)(entry + 1) /* data is stored behind */
50 /* the entry information */
52 typedef struct __debug_entry debug_entry_t
;
56 typedef struct debug_info
{
57 struct debug_info
* next
;
58 struct debug_info
* prev
;
66 debug_entry_t
*** areas
;
70 struct dentry
* debugfs_root_entry
;
71 struct dentry
* debugfs_entries
[DEBUG_MAX_VIEWS
];
72 struct debug_view
* views
[DEBUG_MAX_VIEWS
];
73 char name
[DEBUG_MAX_NAME_LEN
];
77 typedef int (debug_header_proc_t
) (debug_info_t
* id
,
78 struct debug_view
* view
,
83 typedef int (debug_format_proc_t
) (debug_info_t
* id
,
84 struct debug_view
* view
, char* out_buf
,
86 typedef int (debug_prolog_proc_t
) (debug_info_t
* id
,
87 struct debug_view
* view
,
89 typedef int (debug_input_proc_t
) (debug_info_t
* id
,
90 struct debug_view
* view
,
92 const char __user
*user_buf
,
93 size_t in_buf_size
, loff_t
* offset
);
95 int debug_dflt_header_fn(debug_info_t
* id
, struct debug_view
* view
,
96 int area
, debug_entry_t
* entry
, char* out_buf
);
99 char name
[DEBUG_MAX_NAME_LEN
];
100 debug_prolog_proc_t
* prolog_proc
;
101 debug_header_proc_t
* header_proc
;
102 debug_format_proc_t
* format_proc
;
103 debug_input_proc_t
* input_proc
;
107 extern struct debug_view debug_hex_ascii_view
;
108 extern struct debug_view debug_raw_view
;
109 extern struct debug_view debug_sprintf_view
;
111 /* do NOT use the _common functions */
113 debug_entry_t
* debug_event_common(debug_info_t
* id
, int level
,
114 const void* data
, int length
);
116 debug_entry_t
* debug_exception_common(debug_info_t
* id
, int level
,
117 const void* data
, int length
);
119 /* Debug Feature API: */
121 debug_info_t
*debug_register(const char *name
, int pages
, int nr_areas
,
124 debug_info_t
*debug_register_mode(const char *name
, int pages
, int nr_areas
,
125 int buf_size
, umode_t mode
, uid_t uid
,
128 void debug_unregister(debug_info_t
* id
);
130 void debug_set_level(debug_info_t
* id
, int new_level
);
132 void debug_set_critical(void);
133 void debug_stop_all(void);
135 static inline debug_entry_t
*
136 debug_event(debug_info_t
* id
, int level
, void* data
, int length
)
138 if ((!id
) || (level
> id
->level
) || (id
->pages_per_area
== 0))
140 return debug_event_common(id
,level
,data
,length
);
143 static inline debug_entry_t
*
144 debug_int_event(debug_info_t
* id
, int level
, unsigned int tag
)
147 if ((!id
) || (level
> id
->level
) || (id
->pages_per_area
== 0))
149 return debug_event_common(id
,level
,&t
,sizeof(unsigned int));
152 static inline debug_entry_t
*
153 debug_long_event (debug_info_t
* id
, int level
, unsigned long tag
)
156 if ((!id
) || (level
> id
->level
) || (id
->pages_per_area
== 0))
158 return debug_event_common(id
,level
,&t
,sizeof(unsigned long));
161 static inline debug_entry_t
*
162 debug_text_event(debug_info_t
* id
, int level
, const char* txt
)
164 if ((!id
) || (level
> id
->level
) || (id
->pages_per_area
== 0))
166 return debug_event_common(id
,level
,txt
,strlen(txt
));
170 * IMPORTANT: Use "%s" in sprintf format strings with care! Only pointers are
171 * stored in the s390dbf. See Documentation/s390/s390dbf.txt for more details!
173 extern debug_entry_t
*
174 debug_sprintf_event(debug_info_t
* id
,int level
,char *string
,...)
175 __attribute__ ((format(printf
, 3, 4)));
178 static inline debug_entry_t
*
179 debug_exception(debug_info_t
* id
, int level
, void* data
, int length
)
181 if ((!id
) || (level
> id
->level
) || (id
->pages_per_area
== 0))
183 return debug_exception_common(id
,level
,data
,length
);
186 static inline debug_entry_t
*
187 debug_int_exception(debug_info_t
* id
, int level
, unsigned int tag
)
190 if ((!id
) || (level
> id
->level
) || (id
->pages_per_area
== 0))
192 return debug_exception_common(id
,level
,&t
,sizeof(unsigned int));
195 static inline debug_entry_t
*
196 debug_long_exception (debug_info_t
* id
, int level
, unsigned long tag
)
199 if ((!id
) || (level
> id
->level
) || (id
->pages_per_area
== 0))
201 return debug_exception_common(id
,level
,&t
,sizeof(unsigned long));
204 static inline debug_entry_t
*
205 debug_text_exception(debug_info_t
* id
, int level
, const char* txt
)
207 if ((!id
) || (level
> id
->level
) || (id
->pages_per_area
== 0))
209 return debug_exception_common(id
,level
,txt
,strlen(txt
));
213 * IMPORTANT: Use "%s" in sprintf format strings with care! Only pointers are
214 * stored in the s390dbf. See Documentation/s390/s390dbf.txt for more details!
216 extern debug_entry_t
*
217 debug_sprintf_exception(debug_info_t
* id
,int level
,char *string
,...)
218 __attribute__ ((format(printf
, 3, 4)));
220 int debug_register_view(debug_info_t
* id
, struct debug_view
* view
);
221 int debug_unregister_view(debug_info_t
* id
, struct debug_view
* view
);
224 define the debug levels:
225 - 0 No debugging output to console or syslog
226 - 1 Log internal errors to syslog, ignore check conditions
227 - 2 Log internal errors and check conditions to syslog
228 - 3 Log internal errors to console, log check conditions to syslog
229 - 4 Log internal errors and check conditions to console
230 - 5 panic on internal errors, log check conditions to console
231 - 6 panic on both, internal errors and check conditions
235 #define DEBUG_LEVEL 4
238 #define INTERNAL_ERRMSG(x,y...) "E" __FILE__ "%d: " x, __LINE__, y
239 #define INTERNAL_WRNMSG(x,y...) "W" __FILE__ "%d: " x, __LINE__, y
240 #define INTERNAL_INFMSG(x,y...) "I" __FILE__ "%d: " x, __LINE__, y
241 #define INTERNAL_DEBMSG(x,y...) "D" __FILE__ "%d: " x, __LINE__, y
244 #define PRINT_DEBUG(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
245 #define PRINT_INFO(x...) printk ( KERN_INFO PRINTK_HEADER x )
246 #define PRINT_WARN(x...) printk ( KERN_WARNING PRINTK_HEADER x )
247 #define PRINT_ERR(x...) printk ( KERN_ERR PRINTK_HEADER x )
248 #define PRINT_FATAL(x...) panic ( PRINTK_HEADER x )
250 #define PRINT_DEBUG(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
251 #define PRINT_INFO(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
252 #define PRINT_WARN(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
253 #define PRINT_ERR(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
254 #define PRINT_FATAL(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
255 #endif /* DASD_DEBUG */
257 #endif /* __KERNEL__ */