diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-s390/debug.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'include/asm-s390/debug.h')
-rw-r--r-- | include/asm-s390/debug.h | 249 |
1 files changed, 249 insertions, 0 deletions
diff --git a/include/asm-s390/debug.h b/include/asm-s390/debug.h new file mode 100644 index 000000000000..28ef2354b1b2 --- /dev/null +++ b/include/asm-s390/debug.h | |||
@@ -0,0 +1,249 @@ | |||
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 | |||
12 | #include <linux/string.h> | ||
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 | |||
19 | struct __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 | |||
34 | #define __DEBUG_FEATURE_VERSION 1 /* version of debug feature */ | ||
35 | |||
36 | #ifdef __KERNEL__ | ||
37 | #include <linux/spinlock.h> | ||
38 | #include <linux/kernel.h> | ||
39 | #include <linux/time.h> | ||
40 | #include <linux/proc_fs.h> | ||
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 */ | ||
46 | #define DEBUG_MAX_PROCF_LEN 16 /* max length for a proc file name */ | ||
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 | |||
54 | #define STCK(x) asm volatile ("STCK 0(%1)" : "=m" (x) : "a" (&(x)) : "cc") | ||
55 | |||
56 | typedef struct __debug_entry debug_entry_t; | ||
57 | |||
58 | struct debug_view; | ||
59 | |||
60 | typedef struct debug_info { | ||
61 | struct debug_info* next; | ||
62 | struct debug_info* prev; | ||
63 | atomic_t ref_count; | ||
64 | spinlock_t lock; | ||
65 | int level; | ||
66 | int nr_areas; | ||
67 | int page_order; | ||
68 | int buf_size; | ||
69 | int entry_size; | ||
70 | debug_entry_t** areas; | ||
71 | int active_area; | ||
72 | int *active_entry; | ||
73 | struct proc_dir_entry* proc_root_entry; | ||
74 | struct proc_dir_entry* proc_entries[DEBUG_MAX_VIEWS]; | ||
75 | struct debug_view* views[DEBUG_MAX_VIEWS]; | ||
76 | char name[DEBUG_MAX_PROCF_LEN]; | ||
77 | } debug_info_t; | ||
78 | |||
79 | typedef 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 | |||
85 | typedef int (debug_format_proc_t) (debug_info_t* id, | ||
86 | struct debug_view* view, char* out_buf, | ||
87 | const char* in_buf); | ||
88 | typedef int (debug_prolog_proc_t) (debug_info_t* id, | ||
89 | struct debug_view* view, | ||
90 | char* out_buf); | ||
91 | typedef 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 | |||
97 | int debug_dflt_header_fn(debug_info_t* id, struct debug_view* view, | ||
98 | int area, debug_entry_t* entry, char* out_buf); | ||
99 | |||
100 | struct debug_view { | ||
101 | char name[DEBUG_MAX_PROCF_LEN]; | ||
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 | |||
109 | extern struct debug_view debug_hex_ascii_view; | ||
110 | extern struct debug_view debug_raw_view; | ||
111 | extern struct debug_view debug_sprintf_view; | ||
112 | |||
113 | /* do NOT use the _common functions */ | ||
114 | |||
115 | debug_entry_t* debug_event_common(debug_info_t* id, int level, | ||
116 | const void* data, int length); | ||
117 | |||
118 | debug_entry_t* debug_exception_common(debug_info_t* id, int level, | ||
119 | const void* data, int length); | ||
120 | |||
121 | /* Debug Feature API: */ | ||
122 | |||
123 | debug_info_t* debug_register(char* name, int pages_index, int nr_areas, | ||
124 | int buf_size); | ||
125 | |||
126 | void debug_unregister(debug_info_t* id); | ||
127 | |||
128 | void debug_set_level(debug_info_t* id, int new_level); | ||
129 | |||
130 | void debug_stop_all(void); | ||
131 | |||
132 | extern inline debug_entry_t* | ||
133 | debug_event(debug_info_t* id, int level, void* data, int length) | ||
134 | { | ||
135 | if ((!id) || (level > id->level)) return NULL; | ||
136 | return debug_event_common(id,level,data,length); | ||
137 | } | ||
138 | |||
139 | extern inline debug_entry_t* | ||
140 | debug_int_event(debug_info_t* id, int level, unsigned int tag) | ||
141 | { | ||
142 | unsigned int t=tag; | ||
143 | if ((!id) || (level > id->level)) return NULL; | ||
144 | return debug_event_common(id,level,&t,sizeof(unsigned int)); | ||
145 | } | ||
146 | |||
147 | extern inline debug_entry_t * | ||
148 | debug_long_event (debug_info_t* id, int level, unsigned long tag) | ||
149 | { | ||
150 | unsigned long t=tag; | ||
151 | if ((!id) || (level > id->level)) return NULL; | ||
152 | return debug_event_common(id,level,&t,sizeof(unsigned long)); | ||
153 | } | ||
154 | |||
155 | extern inline debug_entry_t* | ||
156 | debug_text_event(debug_info_t* id, int level, const char* txt) | ||
157 | { | ||
158 | if ((!id) || (level > id->level)) return NULL; | ||
159 | return debug_event_common(id,level,txt,strlen(txt)); | ||
160 | } | ||
161 | |||
162 | extern debug_entry_t * | ||
163 | debug_sprintf_event(debug_info_t* id,int level,char *string,...) | ||
164 | __attribute__ ((format(printf, 3, 4))); | ||
165 | |||
166 | |||
167 | extern inline debug_entry_t* | ||
168 | debug_exception(debug_info_t* id, int level, void* data, int length) | ||
169 | { | ||
170 | if ((!id) || (level > id->level)) return NULL; | ||
171 | return debug_exception_common(id,level,data,length); | ||
172 | } | ||
173 | |||
174 | extern inline debug_entry_t* | ||
175 | debug_int_exception(debug_info_t* id, int level, unsigned int tag) | ||
176 | { | ||
177 | unsigned int t=tag; | ||
178 | if ((!id) || (level > id->level)) return NULL; | ||
179 | return debug_exception_common(id,level,&t,sizeof(unsigned int)); | ||
180 | } | ||
181 | |||
182 | extern inline debug_entry_t * | ||
183 | debug_long_exception (debug_info_t* id, int level, unsigned long tag) | ||
184 | { | ||
185 | unsigned long t=tag; | ||
186 | if ((!id) || (level > id->level)) return NULL; | ||
187 | return debug_exception_common(id,level,&t,sizeof(unsigned long)); | ||
188 | } | ||
189 | |||
190 | extern inline debug_entry_t* | ||
191 | debug_text_exception(debug_info_t* id, int level, const char* txt) | ||
192 | { | ||
193 | if ((!id) || (level > id->level)) return NULL; | ||
194 | return debug_exception_common(id,level,txt,strlen(txt)); | ||
195 | } | ||
196 | |||
197 | |||
198 | extern debug_entry_t * | ||
199 | debug_sprintf_exception(debug_info_t* id,int level,char *string,...) | ||
200 | __attribute__ ((format(printf, 3, 4))); | ||
201 | |||
202 | int debug_register_view(debug_info_t* id, struct debug_view* view); | ||
203 | int debug_unregister_view(debug_info_t* id, struct debug_view* view); | ||
204 | |||
205 | /* | ||
206 | define the debug levels: | ||
207 | - 0 No debugging output to console or syslog | ||
208 | - 1 Log internal errors to syslog, ignore check conditions | ||
209 | - 2 Log internal errors and check conditions to syslog | ||
210 | - 3 Log internal errors to console, log check conditions to syslog | ||
211 | - 4 Log internal errors and check conditions to console | ||
212 | - 5 panic on internal errors, log check conditions to console | ||
213 | - 6 panic on both, internal errors and check conditions | ||
214 | */ | ||
215 | |||
216 | #ifndef DEBUG_LEVEL | ||
217 | #define DEBUG_LEVEL 4 | ||
218 | #endif | ||
219 | |||
220 | #define INTERNAL_ERRMSG(x,y...) "E" __FILE__ "%d: " x, __LINE__, y | ||
221 | #define INTERNAL_WRNMSG(x,y...) "W" __FILE__ "%d: " x, __LINE__, y | ||
222 | #define INTERNAL_INFMSG(x,y...) "I" __FILE__ "%d: " x, __LINE__, y | ||
223 | #define INTERNAL_DEBMSG(x,y...) "D" __FILE__ "%d: " x, __LINE__, y | ||
224 | |||
225 | #if DEBUG_LEVEL > 0 | ||
226 | #define PRINT_DEBUG(x...) printk ( KERN_DEBUG PRINTK_HEADER x ) | ||
227 | #define PRINT_INFO(x...) printk ( KERN_INFO PRINTK_HEADER x ) | ||
228 | #define PRINT_WARN(x...) printk ( KERN_WARNING PRINTK_HEADER x ) | ||
229 | #define PRINT_ERR(x...) printk ( KERN_ERR PRINTK_HEADER x ) | ||
230 | #define PRINT_FATAL(x...) panic ( PRINTK_HEADER x ) | ||
231 | #else | ||
232 | #define PRINT_DEBUG(x...) printk ( KERN_DEBUG PRINTK_HEADER x ) | ||
233 | #define PRINT_INFO(x...) printk ( KERN_DEBUG PRINTK_HEADER x ) | ||
234 | #define PRINT_WARN(x...) printk ( KERN_DEBUG PRINTK_HEADER x ) | ||
235 | #define PRINT_ERR(x...) printk ( KERN_DEBUG PRINTK_HEADER x ) | ||
236 | #define PRINT_FATAL(x...) printk ( KERN_DEBUG PRINTK_HEADER x ) | ||
237 | #endif /* DASD_DEBUG */ | ||
238 | |||
239 | #undef DEBUG_MALLOC | ||
240 | #ifdef DEBUG_MALLOC | ||
241 | void *b; | ||
242 | #define kmalloc(x...) (PRINT_INFO(" kmalloc %p\n",b=kmalloc(x)),b) | ||
243 | #define kfree(x) PRINT_INFO(" kfree %p\n",x);kfree(x) | ||
244 | #define get_zeroed_page(x...) (PRINT_INFO(" gfp %p\n",b=get_zeroed_page(x)),b) | ||
245 | #define __get_free_pages(x...) (PRINT_INFO(" gfps %p\n",b=__get_free_pages(x)),b) | ||
246 | #endif /* DEBUG_MALLOC */ | ||
247 | |||
248 | #endif /* __KERNEL__ */ | ||
249 | #endif /* DEBUG_H */ | ||