MOS Source Code
Toggle main menu visibility
Main Page
Topics
Classes
Class List
Class Index
Class Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
~
Functions
_
b
d
e
f
g
h
i
l
m
n
o
p
r
s
v
~
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Enumerations
Enumerator
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
Typedefs
a
b
c
d
f
g
h
i
k
l
m
o
p
r
s
t
u
v
x
Enumerations
c
e
f
g
h
i
l
m
o
p
r
s
t
v
x
Enumerator
_
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
v
w
x
y
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
y
Examples
▼
MOS Source Code
►
Topics
►
Classes
▼
Files
▼
File List
►
build
▼
kernel
►
arch
►
device
►
filesystem
►
include
►
interrupt
►
io
►
ipc
►
lib
▼
misc
►
cmdline.c
►
cpp_support.cpp
►
kallsyms.c
►
kutils.c
►
panic.c
►
platform.c
►
power.c
profiling.c
►
setup.c
►
ubsan.c
►
mm
►
syslog
►
tasks
►
tests
►
kmain.c
►
ksyscall.c
►
ksyscall_entry.c
►
libs
►
File Members
►
Examples
•
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Loading...
Searching...
No Matches
kutils.c
Go to the documentation of this file.
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
3
#include "
mos/misc/kutils.h
"
4
5
#include "
mos/syslog/printk.h
"
6
7
static
const
int
HEXDUMP_COLS
= 16;
8
9
void
hexdump
(
const
char
*data,
const
size_t
len)
10
{
11
if
(len)
12
pr_info
(
" "
PTR_FMT
": "
, (
ptr_t
) data);
13
14
for
(
size_t
i = 0; i < len; i++)
15
{
16
pr_cont
(
"%02hhx "
, (
char
) data[i]);
17
if
((i + 1) %
HEXDUMP_COLS
== 0)
18
{
19
for
(
size_t
j = i - (
HEXDUMP_COLS
- 1); j <= i; j++)
20
{
21
const
char
c = data[j];
22
pr_cont
(
"%c"
, c >= 32 && c <= 126 ? c :
'.'
);
23
}
24
25
if
(i + 1 < len)
26
pr_info
(
" "
PTR_FMT
": "
, (
ptr_t
) (data + i + 1));
27
}
28
}
29
30
if
(len %
HEXDUMP_COLS
!= 0)
31
{
32
const
size_t
spaces = (
HEXDUMP_COLS
- (len %
HEXDUMP_COLS
)) * 3;
33
pr_cont
(
"%*c"
, (
int
) spaces,
' '
);
34
for
(
size_t
i = len - (len %
HEXDUMP_COLS
); i < len; i++)
35
{
36
const
char
c = data[i];
37
pr_cont
(
"%c"
, c >= 32 && c <= 126 ? c :
'.'
);
38
}
39
}
40
41
pr_info
(
""
);
42
}
9
void
hexdump
(
const
char
*data,
const
size_t
len) {
…
}
hexdump
void hexdump(const char *data, const size_t len)
Definition
kutils.c:9
HEXDUMP_COLS
static const int HEXDUMP_COLS
Definition
kutils.c:7
kutils.h
printk.h
pr_info
#define pr_info(fmt,...)
Definition
printk.h:35
pr_cont
#define pr_cont(fmt,...)
Definition
printk.h:41
PTR_FMT
#define PTR_FMT
Definition
types.h:33
ptr_t
unsigned long ptr_t
Definition
types.h:25
kernel
misc
kutils.c
Generated on Sun Sep 1 2024 18:22:52 for MOS Source Code by
1.12.0