-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathlog.h
73 lines (51 loc) · 1.79 KB
/
log.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
log.h
Copyright (C) 2015 Juha Aaltonen
This file is part of standalone gdb stub for Raspberry Pi 2B.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LOG_H_
#define LOG_H_
// stuff for debugging
//#define LOGGING_ON
#include "io_dev.h"
#ifndef LOGGING_ON
#define LOG_PR_STR(x)
#define LOG_PR_STR_CONT(x)
#define LOG_PR_VAL(x, y)
#define LOG_PR_VAL_CONT(x, y)
#define LOG_NEWLINE()
#define LOG_DUMP_BYTES(x, y)
#define LOG_GET_CALLER(x)
#else
#define LOG_PR_STR(x) \
log_pr_head(__builtin_FILE (), __builtin_LINE ());\
log_pr_str(x)
#define LOG_PR_STR_CONT(x) log_pr_str(x)
#define LOG_PR_VAL(x, y) \
log_pr_head(__builtin_FILE (), __builtin_LINE ());\
log_pr_val((x),(y))
#define LOG_PR_VAL_CONT(x, y) log_pr_val((x),(y))
#define LOG_NEWLINE() log_pr_str("\r\n")
#define LOG_DUMP_BYTES(x, y) log_dump_bytes((x),(y))
#define LOG_GET_CALLER(x) asm volatile("mov %[reg], lr\n\t" :[reg] "=r" (x)::)
#endif
// initialize logging
void log_init(io_device *device);
// print log header
void log_pr_head(const char *file, int line);
// print a log string - blocking
void log_pr_str(char *str);
// print an unsigned integer
void log_pr_val(char *str, unsigned int val);
// dump number of bytes from memory
void log_dump_bytes(unsigned char *mem, int bytes);
#endif /* LOG_H_ */