OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [asm-s390/] [debug.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1276 phoenix
/*
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
/* Note:
13
 * struct __debug_entry must be defined outside of #ifdef __KERNEL__
14
 * in order to allow a user program to analyze the 'raw'-view.
15
 */
16
 
17
struct __debug_entry{
18
        union {
19
                struct {
20
                        unsigned long long clock:52;
21
                        unsigned long long exception:1;
22
                        unsigned long long level:3;
23
                        unsigned long long cpuid:8;
24
                } fields;
25
 
26
                unsigned long long stck;
27
        } id;
28
        void* caller;
29
} __attribute__((packed));
30
 
31
 
32
#define __DEBUG_FEATURE_VERSION      1  /* version of debug feature */
33
 
34
#ifdef __KERNEL__
35
#include <linux/version.h>
36
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
37
 #include <asm/spinlock.h>
38
#else
39
 #include <linux/spinlock.h>
40
#endif /* LINUX_VERSION_CODE */
41
#include <linux/kernel.h>
42
#include <linux/time.h>
43
#include <linux/proc_fs.h>
44
 
45
#define DEBUG_MAX_LEVEL            6  /* debug levels range from 0 to 6 */
46
#define DEBUG_OFF_LEVEL            -1 /* level where debug is switched off */
47
#define DEBUG_FLUSH_ALL            -1 /* parameter to flush all areas */
48
#define DEBUG_MAX_VIEWS            10 /* max number of views in proc fs */
49
#define DEBUG_MAX_PROCF_LEN        16 /* max length for a proc file name */
50
#define DEBUG_DEFAULT_LEVEL        3  /* initial debug level */
51
 
52
#define DEBUG_DIR_ROOT "s390dbf" /* name of debug root directory in proc fs */
53
 
54
#define DEBUG_DATA(entry) (char*)(entry + 1) /* data is stored behind */
55
                                             /* the entry information */
56
 
57
#define STCK(x) asm volatile ("STCK 0(%0)" : : "a" (&(x)) : "memory", "cc")
58
 
59
typedef struct __debug_entry debug_entry_t;
60
 
61
struct debug_view;
62
 
63
typedef struct debug_info {
64
        struct debug_info* next;
65
        struct debug_info* prev;
66
        atomic_t ref_count;
67
        spinlock_t lock;
68
        int level;
69
        int nr_areas;
70
        int page_order;
71
        int buf_size;
72
        int entry_size;
73
        debug_entry_t** areas;
74
        int active_area;
75
        int *active_entry;
76
        struct proc_dir_entry* proc_root_entry;
77
        struct proc_dir_entry* proc_entries[DEBUG_MAX_VIEWS];
78
        struct debug_view* views[DEBUG_MAX_VIEWS];
79
        char name[DEBUG_MAX_PROCF_LEN];
80
} debug_info_t;
81
 
82
typedef int (debug_header_proc_t) (debug_info_t* id,
83
                                   struct debug_view* view,
84
                                   int area,
85
                                   debug_entry_t* entry,
86
                                   char* out_buf);
87
 
88
typedef int (debug_format_proc_t) (debug_info_t* id,
89
                                   struct debug_view* view, char* out_buf,
90
                                   const char* in_buf);
91
typedef int (debug_prolog_proc_t) (debug_info_t* id,
92
                                   struct debug_view* view,
93
                                   char* out_buf);
94
typedef int (debug_input_proc_t) (debug_info_t* id,
95
                                  struct debug_view* view,
96
                                  struct file* file, const char* user_buf,
97
                                  size_t in_buf_size, loff_t* offset);
98
 
99
int debug_dflt_header_fn(debug_info_t* id, struct debug_view* view,
100
                         int area, debug_entry_t* entry, char* out_buf);
101
 
102
struct debug_view {
103
        char name[DEBUG_MAX_PROCF_LEN];
104
        debug_prolog_proc_t* prolog_proc;
105
        debug_header_proc_t* header_proc;
106
        debug_format_proc_t* format_proc;
107
        debug_input_proc_t*  input_proc;
108
        void*                private_data;
109
};
110
 
111
extern struct debug_view debug_hex_ascii_view;
112
extern struct debug_view debug_raw_view;
113
extern struct debug_view debug_sprintf_view;
114
 
115
/* do NOT use the _common functions */
116
 
117
debug_entry_t* debug_event_common(debug_info_t* id, int level,
118
                                  const void* data, int length);
119
 
120
debug_entry_t* debug_exception_common(debug_info_t* id, int level,
121
                                      const void* data, int length);
122
 
123
/* Debug Feature API: */
124
 
125
debug_info_t* debug_register(char* name, int pages_index, int nr_areas,
126
                             int buf_size);
127
 
128
void debug_unregister(debug_info_t* id);
129
 
130
void debug_set_level(debug_info_t* id, int new_level);
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
 
165
 
166
extern inline debug_entry_t*
167
debug_exception(debug_info_t* id, int level, void* data, int length)
168
{
169
        if ((!id) || (level > id->level)) return NULL;
170
        return debug_exception_common(id,level,data,length);
171
}
172
 
173
extern inline debug_entry_t*
174
debug_int_exception(debug_info_t* id, int level, unsigned int tag)
175
{
176
        unsigned int t=tag;
177
        if ((!id) || (level > id->level)) return NULL;
178
        return debug_exception_common(id,level,&t,sizeof(unsigned int));
179
}
180
 
181
extern inline debug_entry_t *
182
debug_long_exception (debug_info_t* id, int level, unsigned long tag)
183
{
184
        unsigned long t=tag;
185
        if ((!id) || (level > id->level)) return NULL;
186
        return debug_exception_common(id,level,&t,sizeof(unsigned long));
187
}
188
 
189
extern inline debug_entry_t*
190
debug_text_exception(debug_info_t* id, int level, const char* txt)
191
{
192
        if ((!id) || (level > id->level)) return NULL;
193
        return debug_exception_common(id,level,txt,strlen(txt));
194
}
195
 
196
 
197
extern debug_entry_t *
198
debug_sprintf_exception(debug_info_t* id,int level,char *string,...);
199
 
200
int debug_register_view(debug_info_t* id, struct debug_view* view);
201
int debug_unregister_view(debug_info_t* id, struct debug_view* view);
202
 
203
/*
204
   define the debug levels:
205
   - 0 No debugging output to console or syslog
206
   - 1 Log internal errors to syslog, ignore check conditions
207
   - 2 Log internal errors and check conditions to syslog
208
   - 3 Log internal errors to console, log check conditions to syslog
209
   - 4 Log internal errors and check conditions to console
210
   - 5 panic on internal errors, log check conditions to console
211
   - 6 panic on both, internal errors and check conditions
212
 */
213
 
214
#ifndef DEBUG_LEVEL
215
#define DEBUG_LEVEL 4
216
#endif
217
 
218
#define INTERNAL_ERRMSG(x,y...) "E" __FILE__ "%d: " x, __LINE__, y
219
#define INTERNAL_WRNMSG(x,y...) "W" __FILE__ "%d: " x, __LINE__, y
220
#define INTERNAL_INFMSG(x,y...) "I" __FILE__ "%d: " x, __LINE__, y
221
#define INTERNAL_DEBMSG(x,y...) "D" __FILE__ "%d: " x, __LINE__, y
222
 
223
#if DEBUG_LEVEL > 0
224
#define PRINT_DEBUG(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
225
#define PRINT_INFO(x...) printk ( KERN_INFO PRINTK_HEADER x )
226
#define PRINT_WARN(x...) printk ( KERN_WARNING PRINTK_HEADER x )
227
#define PRINT_ERR(x...) printk ( KERN_ERR PRINTK_HEADER x )
228
#define PRINT_FATAL(x...) panic ( PRINTK_HEADER x )
229
#else
230
#define PRINT_DEBUG(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
231
#define PRINT_INFO(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
232
#define PRINT_WARN(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
233
#define PRINT_ERR(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
234
#define PRINT_FATAL(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
235
#endif                          /* DASD_DEBUG */
236
 
237
#if DASD_DEBUG > 4
238
#define INTERNAL_ERROR(x...) PRINT_FATAL ( INTERNAL_ERRMSG ( x ) )
239
#elif DASD_DEBUG > 2
240
#define INTERNAL_ERROR(x...) PRINT_ERR ( INTERNAL_ERRMSG ( x ) )
241
#elif DASD_DEBUG > 0
242
#define INTERNAL_ERROR(x...) PRINT_WARN ( INTERNAL_ERRMSG ( x ) )
243
#else
244
#define INTERNAL_ERROR(x...)
245
#endif                          /* DASD_DEBUG */
246
 
247
#if DASD_DEBUG > 5
248
#define INTERNAL_CHECK(x...) PRINT_FATAL ( INTERNAL_CHKMSG ( x ) )
249
#elif DASD_DEBUG > 3
250
#define INTERNAL_CHECK(x...) PRINT_ERR ( INTERNAL_CHKMSG ( x ) )
251
#elif DASD_DEBUG > 1
252
#define INTERNAL_CHECK(x...) PRINT_WARN ( INTERNAL_CHKMSG ( x ) )
253
#else
254
#define INTERNAL_CHECK(x...)
255
#endif                          /* DASD_DEBUG */
256
 
257
#undef DEBUG_MALLOC
258
#ifdef DEBUG_MALLOC
259
void *b;
260
#define kmalloc(x...) (PRINT_INFO(" kmalloc %p\n",b=kmalloc(x)),b)
261
#define kfree(x) PRINT_INFO(" kfree %p\n",x);kfree(x)
262
#define get_free_page(x...) (PRINT_INFO(" gfp %p\n",b=get_free_page(x)),b)
263
#define __get_free_pages(x...) (PRINT_INFO(" gfps %p\n",b=__get_free_pages(x)),b)
264
#endif                          /* DEBUG_MALLOC */
265
 
266
#endif                          /* __KERNEL__ */
267
#endif                          /* DEBUG_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.