Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
linux-arm
kvm-unit-tests-ae
Commits
ea7d43d0
Commit
ea7d43d0
authored
Aug 17, 2010
by
Avi Kivity
Browse files
Parse multiboot command line into argc/argv
Signed-off-by:
Avi Kivity
<
avi@redhat.com
>
parent
0d4c7614
Changes
4
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
ea7d43d0
...
...
@@ -15,6 +15,7 @@ cflatobjs := \
lib/panic.o
\
lib/printf.o
\
lib/string.o
cflatobjs
+=
lib/argv.o
#include architecure specific make rules
include
config-$(ARCH).mak
...
...
lib/argv.c
0 → 100644
View file @
ea7d43d0
#include
"libcflat.h"
int
__argc
;
char
*
__argv
[
100
];
char
*
__args
;
char
__args_copy
[
1000
];
static
bool
isblank
(
char
p
)
{
return
p
==
' '
||
p
==
'\t'
;
}
static
char
*
skip_blanks
(
char
*
p
)
{
while
(
isblank
(
*
p
))
++
p
;
return
p
;
}
void
__setup_args
(
void
)
{
char
*
args
=
__args
;
char
**
argv
=
__argv
;
char
*
p
=
__args_copy
;
while
(
*
(
args
=
skip_blanks
(
args
))
!=
'\0'
)
{
*
argv
++
=
p
;
while
(
*
args
!=
'\0'
&&
!
isblank
(
*
args
))
*
p
++
=
*
args
++
;
*
p
++
=
'\0'
;
}
__argc
=
argv
-
__argv
;
}
x86/cstart.S
View file @
ea7d43d0
...
...
@@ -9,9 +9,15 @@ mb_flags = 0x0
#
multiboot
header
.
long
mb_magic
,
mb_flags
,
0
-
(
mb_magic
+
mb_flags
)
mb_cmdline
=
16
.
globl
start
start
:
mov
mb_cmdline
(%
ebx
),
%
eax
mov
%
eax
,
__args
call
__setup_args
pushl
$
__argv
pushl
__argc
call
main
push
%
eax
call
exit
...
...
x86/cstart64.S
View file @
ea7d43d0
...
...
@@ -75,6 +75,8 @@ i = i + 1
.
endr
tss_end
:
mb_boot_info
:
.
quad
0
.
section
.
init
.
code32
...
...
@@ -84,6 +86,7 @@ mb_flags = 0x0
#
multiboot
header
.
long
mb_magic
,
mb_flags
,
0
-
(
mb_magic
+
mb_flags
)
mb_cmdline
=
16
MSR_GS_BASE
=
0xc0000101
...
...
@@ -96,6 +99,7 @@ MSR_GS_BASE = 0xc0000101
.
globl
start
start
:
mov
%
ebx
,
mb_boot_info
mov
$stacktop
,
%
esp
setup_percpu_area
call
prepare_64
...
...
@@ -179,6 +183,12 @@ start64:
call
enable_apic
call
smp_init
call
enable_x2apic
mov
mb_boot_info
(%
rip
),
%
rax
mov
mb_cmdline
(%
rax
),
%
rax
mov
%
rax
,
__args
(%
rip
)
call
__setup_args
mov
__argc
(%
rip
),
%
edi
lea
__argv
(%
rip
),
%
rsi
call
main
mov
%
eax
,
%
edi
call
exit
...
...
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!
Cancel
Please
register
or
sign in
to comment