Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
educg-net-28668-2608132
OSKernel2024-Quantum_Mind_OS-1066
Commits
bb788c78
Commit
bb788c78
authored
7 months ago
by
若尘
Browse files
Options
Download
Patches
Plain Diff
改格式
parent
43c2df56
master
version0.4
version0.5
version0.6
version0.7
version0.8
version0.9
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/lib/print.h
+1
-1
include/lib/print.h
kernel/lib/print.c
+7
-14
kernel/lib/print.c
with
8 additions
and
15 deletions
+8
-15
include/lib/print.h
+
1
−
1
View file @
bb788c78
...
...
@@ -5,7 +5,7 @@
void
print_init
(
void
);
void
printf
(
const
char
*
fmt
,
...);
void
panic
(
const
char
*
warning
);
void
panic
(
const
char
*
warning
,...
);
void
assert
(
bool
condition
,
const
char
*
warning
);
#endif
\ No newline at end of file
This diff is collapsed.
Click to expand it.
kernel/lib/print.c
+
7
−
14
View file @
bb788c78
...
...
@@ -68,20 +68,19 @@ printptr(uint64 x)
void
printf
(
const
char
*
fmt
,
...)
{
va_list
ap
;
//va_list用于接收...的所有参数
int
i
,
c
,
locking
;
//
int
i
,
c
,
locking
;
char
*
s
;
locking
=
pr
.
locking
;
locking
=
pr
.
locking
;
if
(
locking
)
spinlock_acquire
(
&
pr
.
lock
);
if
(
fmt
==
0
)
panic
(
"null fmt"
);
va_start
(
ap
,
fmt
);
//初始化fmt
//关键函数,借鉴xv6
for
(
i
=
0
;
(
c
=
fmt
[
i
]
&
0xff
)
!=
0
;
i
++
)
{
va_start
(
ap
,
fmt
);
//初始化fmt
for
(
i
=
0
;
(
c
=
fmt
[
i
]
&
0xff
)
!=
0
;
i
++
)
{
if
(
c
!=
'%'
){
uart_putc_sync
(
c
);
continue
;
...
...
@@ -89,7 +88,8 @@ va_start(ap, fmt);//初始化fmt
c
=
fmt
[
++
i
]
&
0xff
;
if
(
c
==
0
)
break
;
switch
(
c
){
switch
(
c
)
{
case
'd'
:
printint
(
va_arg
(
ap
,
int
),
10
,
1
);
break
;
...
...
@@ -113,12 +113,6 @@ va_start(ap, fmt);//初始化fmt
uart_putc_sync
(
'%'
);
uart_putc_sync
(
c
);
break
;
//条件: default: 这一部分是在 switch 语句中处理所有未明确处理的字符。
//在格式字符串中,如果 % 后面跟随的字符不是有效的格式说明符(如 d, x, s 等),程序会进入这一部分。
// 输出:
}
}
...
...
@@ -129,7 +123,6 @@ va_start(ap, fmt);//初始化fmt
void
panic
(
const
char
*
s
)
{
spinlock_acquire
(
&
panic_lock
);
pr
.
locking
=
0
;
printf
(
"panic: %s
\n
"
,
s
);
// 单次调用
panicked
=
1
;
// freeze uart output from other CPUs
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets