2 * include/asm-s390/debug.h
5 * Copyright (C) 1999, 2000 IBM Deutschland Entwicklung GmbH,
12 #include <linux/string.h>
15 * struct __debug_entry must be defined outside of #ifdef __KERNEL__
16 * in order to allow a user program to analyze the 'raw'-view.
22 unsigned long long clock:52;
23 unsigned long long exception:1;
24 unsigned long long level:3;
25 unsigned long long cpuid:8;
28 unsigned long long stck;
31 } __attribute__((packed));
34 #define __DEBUG_FEATURE_VERSION 1 /* version of debug feature */
37 #include <linux/version.h>
38 #include <linux/spinlock.h>
39 #include <linux/kernel.h>
40 #include <linux/time.h>
41 #include <linux/proc_fs.h>
43 #define DEBUG_MAX_LEVEL 6 /* debug levels range from 0 to 6 */
44 #define DEBUG_OFF_LEVEL -1 /* level where debug is switched off */
45 #define DEBUG_FLUSH_ALL -1 /* parameter to flush all areas */
46 #define DEBUG_MAX_VIEWS 10 /* max number of views in proc fs */
47 #define DEBUG_MAX_PROCF_LEN 16 /* max length for a proc file name */
48 #define DEBUG_DEFAULT_LEVEL 3 /* initial debug level */
50 #define DEBUG_DIR_ROOT "s390dbf" /* name of debug root directory in proc fs */
52 #define DEBUG_DATA(entry) (char*)(entry + 1) /* data is stored behind */
53 /* the entry information */
55 #define STCK(x) asm volatile ("STCK 0(%1)" : "=m" (x) : "a" (&(x)) : "cc")
57 typedef struct __debug_entry debug_entry_t;
61 typedef struct debug_info {
62 struct debug_info* next;
63 struct debug_info* prev;
71 debug_entry_t** areas;
74 struct proc_dir_entry* proc_root_entry;
75 struct proc_dir_entry* proc_entries[DEBUG_MAX_VIEWS];
76 struct debug_view* views[DEBUG_MAX_VIEWS];
77 char name[DEBUG_MAX_PROCF_LEN];
80 typedef int (debug_header_proc_t) (debug_info_t* id,
81 struct debug_view* view,
86 typedef int (debug_format_proc_t) (debug_info_t* id,
87 struct debug_view* view, char* out_buf,
89 typedef int (debug_prolog_proc_t) (debug_info_t* id,
90 struct debug_view* view,
92 typedef int (debug_input_proc_t) (debug_info_t* id,
93 struct debug_view* view,
95 const char __user *user_buf,
96 size_t in_buf_size, loff_t* offset);
98 int debug_dflt_header_fn(debug_info_t* id, struct debug_view* view,
99 int area, debug_entry_t* entry, char* out_buf);
102 char name[DEBUG_MAX_PROCF_LEN];
103 debug_prolog_proc_t* prolog_proc;
104 debug_header_proc_t* header_proc;
105 debug_format_proc_t* format_proc;
106 debug_input_proc_t* input_proc;
110 extern struct debug_view debug_hex_ascii_view;
111 extern struct debug_view debug_raw_view;
112 extern struct debug_view debug_sprintf_view;
114 /* do NOT use the _common functions */
116 debug_entry_t* debug_event_common(debug_info_t* id, int level,
117 const void* data, int length);
119 debug_entry_t* debug_exception_common(debug_info_t* id, int level,
120 const void* data, int length);
122 /* Debug Feature API: */
124 debug_info_t* debug_register(char* name, int pages_index, int nr_areas,
127 void debug_unregister(debug_info_t* id);
129 void debug_set_level(debug_info_t* id, int new_level);
131 extern inline debug_entry_t*
132 debug_event(debug_info_t* id, int level, void* data, int length)
134 if ((!id) || (level > id->level)) return NULL;
135 return debug_event_common(id,level,data,length);
138 extern inline debug_entry_t*
139 debug_int_event(debug_info_t* id, int level, unsigned int tag)
142 if ((!id) || (level > id->level)) return NULL;
143 return debug_event_common(id,level,&t,sizeof(unsigned int));
146 extern inline debug_entry_t *
147 debug_long_event (debug_info_t* id, int level, unsigned long tag)
150 if ((!id) || (level > id->level)) return NULL;
151 return debug_event_common(id,level,&t,sizeof(unsigned long));
154 extern inline debug_entry_t*
155 debug_text_event(debug_info_t* id, int level, const char* txt)
157 if ((!id) || (level > id->level)) return NULL;
158 return debug_event_common(id,level,txt,strlen(txt));
161 extern debug_entry_t *
162 debug_sprintf_event(debug_info_t* id,int level,char *string,...)
163 __attribute__ ((format(printf, 3, 4)));
166 extern inline debug_entry_t*
167 debug_exception(debug_info_t* id, int level, void* data, int length)
169 if ((!id) || (level > id->level)) return NULL;
170 return debug_exception_common(id,level,data,length);
173 extern inline debug_entry_t*
174 debug_int_exception(debug_info_t* id, int level, unsigned int tag)
177 if ((!id) || (level > id->level)) return NULL;
178 return debug_exception_common(id,level,&t,sizeof(unsigned int));
181 extern inline debug_entry_t *
182 debug_long_exception (debug_info_t* id, int level, unsigned long tag)
185 if ((!id) || (level > id->level)) return NULL;
186 return debug_exception_common(id,level,&t,sizeof(unsigned long));
189 extern inline debug_entry_t*
190 debug_text_exception(debug_info_t* id, int level, const char* txt)
192 if ((!id) || (level > id->level)) return NULL;
193 return debug_exception_common(id,level,txt,strlen(txt));
197 extern debug_entry_t *
198 debug_sprintf_exception(debug_info_t* id,int level,char *string,...)
199 __attribute__ ((format(printf, 3, 4)));
201 int debug_register_view(debug_info_t* id, struct debug_view* view);
202 int debug_unregister_view(debug_info_t* id, struct debug_view* view);
205 define the debug levels:
206 - 0 No debugging output to console or syslog
207 - 1 Log internal errors to syslog, ignore check conditions
208 - 2 Log internal errors and check conditions to syslog
209 - 3 Log internal errors to console, log check conditions to syslog
210 - 4 Log internal errors and check conditions to console
211 - 5 panic on internal errors, log check conditions to console
212 - 6 panic on both, internal errors and check conditions
216 #define DEBUG_LEVEL 4
219 #define INTERNAL_ERRMSG(x,y...) "E" __FILE__ "%d: " x, __LINE__, y
220 #define INTERNAL_WRNMSG(x,y...) "W" __FILE__ "%d: " x, __LINE__, y
221 #define INTERNAL_INFMSG(x,y...) "I" __FILE__ "%d: " x, __LINE__, y
222 #define INTERNAL_DEBMSG(x,y...) "D" __FILE__ "%d: " x, __LINE__, y
225 #define PRINT_DEBUG(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
226 #define PRINT_INFO(x...) printk ( KERN_INFO PRINTK_HEADER x )
227 #define PRINT_WARN(x...) printk ( KERN_WARNING PRINTK_HEADER x )
228 #define PRINT_ERR(x...) printk ( KERN_ERR PRINTK_HEADER x )
229 #define PRINT_FATAL(x...) panic ( PRINTK_HEADER x )
231 #define PRINT_DEBUG(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
232 #define PRINT_INFO(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
233 #define PRINT_WARN(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
234 #define PRINT_ERR(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
235 #define PRINT_FATAL(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
236 #endif /* DASD_DEBUG */
241 #define kmalloc(x...) (PRINT_INFO(" kmalloc %p\n",b=kmalloc(x)),b)
242 #define kfree(x) PRINT_INFO(" kfree %p\n",x);kfree(x)
243 #define get_zeroed_page(x...) (PRINT_INFO(" gfp %p\n",b=get_zeroed_page(x)),b)
244 #define __get_free_pages(x...) (PRINT_INFO(" gfps %p\n",b=__get_free_pages(x)),b)
245 #endif /* DEBUG_MALLOC */
247 #endif /* __KERNEL__ */