| .. | .. |
|---|
| 2 | 2 | /* |
|---|
| 3 | 3 | * S/390 debug facility |
|---|
| 4 | 4 | * |
|---|
| 5 | | - * Copyright IBM Corp. 1999, 2000 |
|---|
| 5 | + * Copyright IBM Corp. 1999, 2020 |
|---|
| 6 | 6 | */ |
|---|
| 7 | | -#ifndef DEBUG_H |
|---|
| 8 | | -#define DEBUG_H |
|---|
| 7 | +#ifndef _ASM_S390_DEBUG_H |
|---|
| 8 | +#define _ASM_S390_DEBUG_H |
|---|
| 9 | 9 | |
|---|
| 10 | 10 | #include <linux/string.h> |
|---|
| 11 | 11 | #include <linux/spinlock.h> |
|---|
| 12 | 12 | #include <linux/kernel.h> |
|---|
| 13 | 13 | #include <linux/time.h> |
|---|
| 14 | 14 | #include <linux/refcount.h> |
|---|
| 15 | | -#include <uapi/asm/debug.h> |
|---|
| 15 | +#include <linux/fs.h> |
|---|
| 16 | 16 | |
|---|
| 17 | 17 | #define DEBUG_MAX_LEVEL 6 /* debug levels range from 0 to 6 */ |
|---|
| 18 | 18 | #define DEBUG_OFF_LEVEL -1 /* level where debug is switched off */ |
|---|
| .. | .. |
|---|
| 25 | 25 | |
|---|
| 26 | 26 | #define DEBUG_DATA(entry) (char *)(entry + 1) /* data is stored behind */ |
|---|
| 27 | 27 | /* the entry information */ |
|---|
| 28 | + |
|---|
| 29 | +#define __DEBUG_FEATURE_VERSION 3 /* version of debug feature */ |
|---|
| 30 | + |
|---|
| 31 | +struct __debug_entry { |
|---|
| 32 | + unsigned long clock : 60; |
|---|
| 33 | + unsigned long exception : 1; |
|---|
| 34 | + unsigned long level : 3; |
|---|
| 35 | + void *caller; |
|---|
| 36 | + unsigned short cpu; |
|---|
| 37 | +} __packed; |
|---|
| 28 | 38 | |
|---|
| 29 | 39 | typedef struct __debug_entry debug_entry_t; |
|---|
| 30 | 40 | |
|---|
| .. | .. |
|---|
| 82 | 92 | }; |
|---|
| 83 | 93 | |
|---|
| 84 | 94 | extern struct debug_view debug_hex_ascii_view; |
|---|
| 85 | | -extern struct debug_view debug_raw_view; |
|---|
| 86 | 95 | extern struct debug_view debug_sprintf_view; |
|---|
| 87 | 96 | |
|---|
| 88 | 97 | /* do NOT use the _common functions */ |
|---|
| .. | .. |
|---|
| 107 | 116 | void debug_set_level(debug_info_t *id, int new_level); |
|---|
| 108 | 117 | |
|---|
| 109 | 118 | void debug_set_critical(void); |
|---|
| 119 | + |
|---|
| 110 | 120 | void debug_stop_all(void); |
|---|
| 111 | 121 | |
|---|
| 122 | +/** |
|---|
| 123 | + * debug_level_enabled() - Returns true if debug events for the specified |
|---|
| 124 | + * level would be logged. Otherwise returns false. |
|---|
| 125 | + * |
|---|
| 126 | + * @id: handle for debug log |
|---|
| 127 | + * @level: debug level |
|---|
| 128 | + * |
|---|
| 129 | + * Return: |
|---|
| 130 | + * - %true if level is less or equal to the current debug level. |
|---|
| 131 | + */ |
|---|
| 112 | 132 | static inline bool debug_level_enabled(debug_info_t *id, int level) |
|---|
| 113 | 133 | { |
|---|
| 114 | 134 | return level <= id->level; |
|---|
| 115 | 135 | } |
|---|
| 116 | 136 | |
|---|
| 137 | +/** |
|---|
| 138 | + * debug_event() - writes binary debug entry to active debug area |
|---|
| 139 | + * (if level <= actual debug level) |
|---|
| 140 | + * |
|---|
| 141 | + * @id: handle for debug log |
|---|
| 142 | + * @level: debug level |
|---|
| 143 | + * @data: pointer to data for debug entry |
|---|
| 144 | + * @length: length of data in bytes |
|---|
| 145 | + * |
|---|
| 146 | + * Return: |
|---|
| 147 | + * - Address of written debug entry |
|---|
| 148 | + * - %NULL if error |
|---|
| 149 | + */ |
|---|
| 117 | 150 | static inline debug_entry_t *debug_event(debug_info_t *id, int level, |
|---|
| 118 | 151 | void *data, int length) |
|---|
| 119 | 152 | { |
|---|
| .. | .. |
|---|
| 122 | 155 | return debug_event_common(id, level, data, length); |
|---|
| 123 | 156 | } |
|---|
| 124 | 157 | |
|---|
| 158 | +/** |
|---|
| 159 | + * debug_int_event() - writes unsigned integer debug entry to active debug area |
|---|
| 160 | + * (if level <= actual debug level) |
|---|
| 161 | + * |
|---|
| 162 | + * @id: handle for debug log |
|---|
| 163 | + * @level: debug level |
|---|
| 164 | + * @tag: integer value for debug entry |
|---|
| 165 | + * |
|---|
| 166 | + * Return: |
|---|
| 167 | + * - Address of written debug entry |
|---|
| 168 | + * - %NULL if error |
|---|
| 169 | + */ |
|---|
| 125 | 170 | static inline debug_entry_t *debug_int_event(debug_info_t *id, int level, |
|---|
| 126 | 171 | unsigned int tag) |
|---|
| 127 | 172 | { |
|---|
| .. | .. |
|---|
| 132 | 177 | return debug_event_common(id, level, &t, sizeof(unsigned int)); |
|---|
| 133 | 178 | } |
|---|
| 134 | 179 | |
|---|
| 180 | +/** |
|---|
| 181 | + * debug_long_event() - writes unsigned long debug entry to active debug area |
|---|
| 182 | + * (if level <= actual debug level) |
|---|
| 183 | + * |
|---|
| 184 | + * @id: handle for debug log |
|---|
| 185 | + * @level: debug level |
|---|
| 186 | + * @tag: long integer value for debug entry |
|---|
| 187 | + * |
|---|
| 188 | + * Return: |
|---|
| 189 | + * - Address of written debug entry |
|---|
| 190 | + * - %NULL if error |
|---|
| 191 | + */ |
|---|
| 135 | 192 | static inline debug_entry_t *debug_long_event(debug_info_t *id, int level, |
|---|
| 136 | 193 | unsigned long tag) |
|---|
| 137 | 194 | { |
|---|
| .. | .. |
|---|
| 142 | 199 | return debug_event_common(id, level, &t, sizeof(unsigned long)); |
|---|
| 143 | 200 | } |
|---|
| 144 | 201 | |
|---|
| 202 | +/** |
|---|
| 203 | + * debug_text_event() - writes string debug entry in ascii format to active |
|---|
| 204 | + * debug area (if level <= actual debug level) |
|---|
| 205 | + * |
|---|
| 206 | + * @id: handle for debug log |
|---|
| 207 | + * @level: debug level |
|---|
| 208 | + * @txt: string for debug entry |
|---|
| 209 | + * |
|---|
| 210 | + * Return: |
|---|
| 211 | + * - Address of written debug entry |
|---|
| 212 | + * - %NULL if error |
|---|
| 213 | + */ |
|---|
| 145 | 214 | static inline debug_entry_t *debug_text_event(debug_info_t *id, int level, |
|---|
| 146 | 215 | const char *txt) |
|---|
| 147 | 216 | { |
|---|
| .. | .. |
|---|
| 152 | 221 | |
|---|
| 153 | 222 | /* |
|---|
| 154 | 223 | * IMPORTANT: Use "%s" in sprintf format strings with care! Only pointers are |
|---|
| 155 | | - * stored in the s390dbf. See Documentation/s390/s390dbf.txt for more details! |
|---|
| 224 | + * stored in the s390dbf. See Documentation/s390/s390dbf.rst for more details! |
|---|
| 156 | 225 | */ |
|---|
| 157 | 226 | extern debug_entry_t * |
|---|
| 158 | 227 | __debug_sprintf_event(debug_info_t *id, int level, char *string, ...) |
|---|
| 159 | 228 | __attribute__ ((format(printf, 3, 4))); |
|---|
| 160 | 229 | |
|---|
| 230 | +/** |
|---|
| 231 | + * debug_sprintf_event() - writes debug entry with format string |
|---|
| 232 | + * and varargs (longs) to active debug area |
|---|
| 233 | + * (if level $<=$ actual debug level). |
|---|
| 234 | + * |
|---|
| 235 | + * @_id: handle for debug log |
|---|
| 236 | + * @_level: debug level |
|---|
| 237 | + * @_fmt: format string for debug entry |
|---|
| 238 | + * @...: varargs used as in sprintf() |
|---|
| 239 | + * |
|---|
| 240 | + * Return: |
|---|
| 241 | + * - Address of written debug entry |
|---|
| 242 | + * - %NULL if error |
|---|
| 243 | + * |
|---|
| 244 | + * floats and long long datatypes cannot be used as varargs. |
|---|
| 245 | + */ |
|---|
| 161 | 246 | #define debug_sprintf_event(_id, _level, _fmt, ...) \ |
|---|
| 162 | 247 | ({ \ |
|---|
| 163 | 248 | debug_entry_t *__ret; \ |
|---|
| .. | .. |
|---|
| 172 | 257 | __ret; \ |
|---|
| 173 | 258 | }) |
|---|
| 174 | 259 | |
|---|
| 260 | +/** |
|---|
| 261 | + * debug_exception() - writes binary debug entry to active debug area |
|---|
| 262 | + * (if level <= actual debug level) |
|---|
| 263 | + * and switches to next debug area |
|---|
| 264 | + * |
|---|
| 265 | + * @id: handle for debug log |
|---|
| 266 | + * @level: debug level |
|---|
| 267 | + * @data: pointer to data for debug entry |
|---|
| 268 | + * @length: length of data in bytes |
|---|
| 269 | + * |
|---|
| 270 | + * Return: |
|---|
| 271 | + * - Address of written debug entry |
|---|
| 272 | + * - %NULL if error |
|---|
| 273 | + */ |
|---|
| 175 | 274 | static inline debug_entry_t *debug_exception(debug_info_t *id, int level, |
|---|
| 176 | 275 | void *data, int length) |
|---|
| 177 | 276 | { |
|---|
| .. | .. |
|---|
| 180 | 279 | return debug_exception_common(id, level, data, length); |
|---|
| 181 | 280 | } |
|---|
| 182 | 281 | |
|---|
| 282 | +/** |
|---|
| 283 | + * debug_int_exception() - writes unsigned int debug entry to active debug area |
|---|
| 284 | + * (if level <= actual debug level) |
|---|
| 285 | + * and switches to next debug area |
|---|
| 286 | + * |
|---|
| 287 | + * @id: handle for debug log |
|---|
| 288 | + * @level: debug level |
|---|
| 289 | + * @tag: integer value for debug entry |
|---|
| 290 | + * |
|---|
| 291 | + * Return: |
|---|
| 292 | + * - Address of written debug entry |
|---|
| 293 | + * - %NULL if error |
|---|
| 294 | + */ |
|---|
| 183 | 295 | static inline debug_entry_t *debug_int_exception(debug_info_t *id, int level, |
|---|
| 184 | 296 | unsigned int tag) |
|---|
| 185 | 297 | { |
|---|
| .. | .. |
|---|
| 190 | 302 | return debug_exception_common(id, level, &t, sizeof(unsigned int)); |
|---|
| 191 | 303 | } |
|---|
| 192 | 304 | |
|---|
| 305 | +/** |
|---|
| 306 | + * debug_long_exception() - writes long debug entry to active debug area |
|---|
| 307 | + * (if level <= actual debug level) |
|---|
| 308 | + * and switches to next debug area |
|---|
| 309 | + * |
|---|
| 310 | + * @id: handle for debug log |
|---|
| 311 | + * @level: debug level |
|---|
| 312 | + * @tag: long integer value for debug entry |
|---|
| 313 | + * |
|---|
| 314 | + * Return: |
|---|
| 315 | + * - Address of written debug entry |
|---|
| 316 | + * - %NULL if error |
|---|
| 317 | + */ |
|---|
| 193 | 318 | static inline debug_entry_t *debug_long_exception (debug_info_t *id, int level, |
|---|
| 194 | 319 | unsigned long tag) |
|---|
| 195 | 320 | { |
|---|
| .. | .. |
|---|
| 200 | 325 | return debug_exception_common(id, level, &t, sizeof(unsigned long)); |
|---|
| 201 | 326 | } |
|---|
| 202 | 327 | |
|---|
| 328 | +/** |
|---|
| 329 | + * debug_text_exception() - writes string debug entry in ascii format to active |
|---|
| 330 | + * debug area (if level <= actual debug level) |
|---|
| 331 | + * and switches to next debug area |
|---|
| 332 | + * area |
|---|
| 333 | + * |
|---|
| 334 | + * @id: handle for debug log |
|---|
| 335 | + * @level: debug level |
|---|
| 336 | + * @txt: string for debug entry |
|---|
| 337 | + * |
|---|
| 338 | + * Return: |
|---|
| 339 | + * - Address of written debug entry |
|---|
| 340 | + * - %NULL if error |
|---|
| 341 | + */ |
|---|
| 203 | 342 | static inline debug_entry_t *debug_text_exception(debug_info_t *id, int level, |
|---|
| 204 | 343 | const char *txt) |
|---|
| 205 | 344 | { |
|---|
| .. | .. |
|---|
| 210 | 349 | |
|---|
| 211 | 350 | /* |
|---|
| 212 | 351 | * IMPORTANT: Use "%s" in sprintf format strings with care! Only pointers are |
|---|
| 213 | | - * stored in the s390dbf. See Documentation/s390/s390dbf.txt for more details! |
|---|
| 352 | + * stored in the s390dbf. See Documentation/s390/s390dbf.rst for more details! |
|---|
| 214 | 353 | */ |
|---|
| 215 | 354 | extern debug_entry_t * |
|---|
| 216 | 355 | __debug_sprintf_exception(debug_info_t *id, int level, char *string, ...) |
|---|
| 217 | 356 | __attribute__ ((format(printf, 3, 4))); |
|---|
| 218 | 357 | |
|---|
| 358 | + |
|---|
| 359 | +/** |
|---|
| 360 | + * debug_sprintf_exception() - writes debug entry with format string and |
|---|
| 361 | + * varargs (longs) to active debug area |
|---|
| 362 | + * (if level <= actual debug level) |
|---|
| 363 | + * and switches to next debug area. |
|---|
| 364 | + * |
|---|
| 365 | + * @_id: handle for debug log |
|---|
| 366 | + * @_level: debug level |
|---|
| 367 | + * @_fmt: format string for debug entry |
|---|
| 368 | + * @...: varargs used as in sprintf() |
|---|
| 369 | + * |
|---|
| 370 | + * Return: |
|---|
| 371 | + * - Address of written debug entry |
|---|
| 372 | + * - %NULL if error |
|---|
| 373 | + * |
|---|
| 374 | + * floats and long long datatypes cannot be used as varargs. |
|---|
| 375 | + */ |
|---|
| 219 | 376 | #define debug_sprintf_exception(_id, _level, _fmt, ...) \ |
|---|
| 220 | 377 | ({ \ |
|---|
| 221 | 378 | debug_entry_t *__ret; \ |
|---|
| .. | .. |
|---|
| 231 | 388 | }) |
|---|
| 232 | 389 | |
|---|
| 233 | 390 | int debug_register_view(debug_info_t *id, struct debug_view *view); |
|---|
| 391 | + |
|---|
| 234 | 392 | int debug_unregister_view(debug_info_t *id, struct debug_view *view); |
|---|
| 235 | 393 | |
|---|
| 236 | 394 | /* |
|---|
| .. | .. |
|---|
| 267 | 425 | #define PRINT_FATAL(x...) printk(KERN_DEBUG PRINTK_HEADER x) |
|---|
| 268 | 426 | #endif /* DASD_DEBUG */ |
|---|
| 269 | 427 | |
|---|
| 270 | | -#endif /* DEBUG_H */ |
|---|
| 428 | +#endif /* _ASM_S390_DEBUG_H */ |
|---|