forked from barebox/barebox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug_ll.h
107 lines (87 loc) · 1.98 KB
/
debug_ll.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* debug_ll.h
*
* written by Marc Singer
* 12 Feb 2005
*
* Copyright (C) 2005 Marc Singer
*/
#ifndef __INCLUDE_DEBUG_LL_H__
#define __INCLUDE_DEBUG_LL_H__
#ifdef CONFIG_HAS_DEBUG_LL
/*
* asm/debug_ll.h should implement PUTC_LL. This can be a macro or a static
* inline function. Note that several SoCs expect the UART to be initialized
* by a debugger or a first stage bootloader. You won't see anything without
* this initialization. Depending on the PUTC_LL implementation the board might
* also hang in PUTC_LL without proper initialization.
*/
#include <asm/debug_ll.h>
#endif
#if defined (CONFIG_DEBUG_LL)
static inline void putc_ll(char value)
{
PUTC_LL(value);
}
static inline void puthexc_ll(unsigned char value)
{
int i; unsigned char ch;
for (i = 2; i--; ) {
ch = ((value >> (i * 4)) & 0xf);
ch += (ch >= 10) ? 'a' - 10 : '0';
putc_ll(ch);
}
}
static inline void puthex_ll(unsigned long value)
{
int i;
for (i = sizeof(unsigned long); i--; )
puthexc_ll(value >> (i * 8));
}
/*
* Be careful with puts_ll, it only works if the binary is running at the
* link address which often is not the case during early startup. If in doubt
* don't use it.
*/
static inline void puts_ll(const char * str)
{
while (*str) {
if (*str == '\n')
putc_ll('\r');
putc_ll(*str);
str++;
}
}
static inline void putws_ll(const unsigned short * wstr)
{
while (*wstr) {
if (*wstr == L'\n')
putc_ll('\r');
putc_ll(*wstr);
wstr++;
}
}
#else
static inline void putc_ll(char value)
{
}
static inline void putws_ll(const unsigned short * wstr)
{
}
static inline void puthexc_ll(unsigned char value)
{
}
static inline void puthex_ll(unsigned long value)
{
}
/*
* Be careful with puts_ll, it only works if the binary is running at the
* link address which often is not the case during early startup. If in doubt
* don't use it.
*/
static inline void puts_ll(const char * str)
{
}
#endif
#endif /* __INCLUDE_DEBUG_LL_H__ */