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
郑友捷
starry-next
Commits
37873ae8
Commit
37873ae8
authored
4 months ago
by
Youjie Zheng
Browse files
Options
Download
Patches
Plain Diff
[style] Fix code style according to the PR content
parent
ade3b4ca
zg-dev
pre2025
pre2025test
yyy-dev
No related merge requests found
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
configs/aarch64.toml
+3
-13
configs/aarch64.toml
configs/riscv64.toml
+3
-13
configs/riscv64.toml
configs/x86_64.toml
+3
-13
configs/x86_64.toml
src/loader.rs
+1
-1
src/loader.rs
src/main.rs
+1
-1
src/main.rs
src/mm.rs
+10
-10
src/mm.rs
src/syscall_imp/fs/io.rs
+1
-0
src/syscall_imp/fs/io.rs
src/syscall_imp/fs/mod.rs
+2
-2
src/syscall_imp/fs/mod.rs
src/syscall_imp/mm/mmap.rs
+2
-4
src/syscall_imp/mm/mmap.rs
src/syscall_imp/mm/mod.rs
+1
-1
src/syscall_imp/mm/mod.rs
src/syscall_imp/mod.rs
+1
-0
src/syscall_imp/mod.rs
src/syscall_imp/task/mod.rs
+2
-2
src/syscall_imp/task/mod.rs
src/syscall_imp/task/thread.rs
+7
-7
src/syscall_imp/task/thread.rs
with
37 additions
and
67 deletions
+37
-67
configs/aarch64.toml
+
3
−
13
View file @
37873ae8
# The base address of the user space.
user_space_base
=
0x1000
# The size of the user space.
user_space_size
=
0x7fff_ffff_f000
# The base address of the user heap.
user
_
heap
_
base
=
0x3fc0_0000
user
-
heap
-
base
=
0x3fc0_0000
# The size of the user heap.
user_heap_size
=
0x40_0000
# The highest address of the user stack.
user_stack_top
=
0x7fff_0000_0000
# The size of the user stack.
user_stack_size
=
0x1_0000
user-heap-size
=
0x40_0000
# The size of the kernel stack.
kernel_stack_size
=
0x40000
\ No newline at end of file
kernel-stack-size
=
0x40000
\ No newline at end of file
This diff is collapsed.
Click to expand it.
configs/riscv64.toml
+
3
−
13
View file @
37873ae8
# The base address of the user space.
user_space_base
=
0x1000
# The size of the user space.
user_space_size
=
0x3f_ffff_f000
# The base address of the user heap.
user_heap_base
=
0x3fc0_0000
# The size of the user heap.
user_heap_size
=
0x40_0000
# The highest address of the user stack.
user
_
stack
_
top
=
0x4_0000_0000
user
-
stack
-
top
=
0x4_0000_0000
# The size of the user stack.
user
_
stack
_
size
=
0x1_0000
user
-
stack
-
size
=
0x1_0000
# The size of the kernel stack.
kernel_stack_size
=
0x40000
\ No newline at end of file
kernel-stack-size
=
0x40000
\ No newline at end of file
This diff is collapsed.
Click to expand it.
configs/x86_64.toml
+
3
−
13
View file @
37873ae8
# The base address of the user space.
user_space_base
=
0x1000
# The size of the user space.
user_space_size
=
0x7fff_ffff_f000
# The base address of the user heap.
user_heap_base
=
0x3fc0_0000
# The size of the user heap.
user_heap_size
=
0x40_0000
# The highest address of the user stack.
user
_
stack
_
top
=
0x7fff_0000_0000
user
-
stack
-
top
=
0x7fff_0000_0000
# The size of the user stack.
user
_
stack
_
size
=
0x1_0000
user
-
stack
-
size
=
0x1_0000
# The size of the kernel stack.
kernel_stack_size
=
0x40000
\ No newline at end of file
kernel-stack-size
=
0x40000
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/loader.rs
+
1
−
1
View file @
37873ae8
...
...
@@ -143,7 +143,7 @@ pub(crate) fn load_elf(name: &str, base_addr: VirtAddr) -> ELFInfo {
let
elf_offset
=
kernel_elf_parser
::
get_elf_base_addr
(
&
elf
,
base_addr
.as_usize
())
.unwrap
();
assert!
(
elf_offset
&
0xfff
==
0
,
memory_addr
::
is_aligned_4k
(
elf_offset
)
,
"ELF base address must be aligned to 4k"
);
...
...
This diff is collapsed.
Click to expand it.
src/main.rs
+
1
−
1
View file @
37873ae8
...
...
@@ -6,7 +6,7 @@
extern
crate
log
;
extern
crate
alloc
;
extern
crate
axstd
;
#[allow(unused)]
mod
config
;
mod
loader
;
mod
mm
;
...
...
This diff is collapsed.
Click to expand it.
src/mm.rs
+
10
−
10
View file @
37873ae8
...
...
@@ -40,33 +40,33 @@ pub fn load_user_app(app_name: &str) -> AxResult<(VirtAddr, VirtAddr, AddrSpace)
}
// The user stack is divided into two parts:
// `ustack_
bottom
` -> `ustack
top
`: It is the stack space that users actually read and write.
// `ustack_
top
` -> `ustack
end`: It is the space that contains the arguments, environment variables and auxv passed to the app.
// When the app starts running, the stack pointer points to `ustack_
top
`.
// `ustack_
start
` -> `ustack
_pointer
`: It is the stack space that users actually read and write.
// `ustack_
pointer
` -> `ustack
_
end`: It is the space that contains the arguments, environment variables and auxv passed to the app.
// When the app starts running, the stack pointer points to `ustack_
pointer
`.
let
ustack_end
=
VirtAddr
::
from_usize
(
config
::
USER_STACK_TOP
);
let
ustack_size
=
config
::
USER_STACK_SIZE
;
let
ustack_
bottom
=
ustack_end
-
ustack_size
;
let
ustack_
start
=
ustack_end
-
ustack_size
;
debug!
(
"Mapping user stack: {:#x?} -> {:#x?}"
,
ustack_
bottom
,
ustack_end
ustack_
start
,
ustack_end
);
// FIXME: Add more arguments and environment variables
let
(
stack_data
,
ustack_
top
)
=
kernel_elf_parser
::
get_app_stack_region
(
let
(
stack_data
,
ustack_
pointer
)
=
kernel_elf_parser
::
get_app_stack_region
(
&
[
app_name
.to_string
()],
&
[],
&
elf_info
.auxv
,
ustack_
bottom
,
ustack_
start
,
ustack_size
,
);
uspace
.map_alloc
(
ustack_
bottom
,
ustack_
start
,
ustack_size
,
MappingFlags
::
READ
|
MappingFlags
::
WRITE
|
MappingFlags
::
USER
,
true
,
)
?
;
uspace
.write
(
VirtAddr
::
from_usize
(
ustack_
top
),
stack_data
.as_slice
())
?
;
Ok
((
elf_info
.entry
,
VirtAddr
::
from
(
ustack_
top
),
uspace
))
uspace
.write
(
VirtAddr
::
from_usize
(
ustack_
pointer
),
stack_data
.as_slice
())
?
;
Ok
((
elf_info
.entry
,
VirtAddr
::
from
(
ustack_
pointer
),
uspace
))
}
#[register_trap_handler(PAGE_FAULT)]
...
...
This diff is collapsed.
Click to expand it.
src/syscall_imp/fs/io.rs
+
1
−
0
View file @
37873ae8
...
...
@@ -5,6 +5,7 @@ use arceos_posix_api as api;
pub
(
crate
)
fn
sys_read
(
fd
:
i32
,
buf
:
*
mut
c_void
,
count
:
usize
)
->
isize
{
api
::
sys_read
(
fd
,
buf
,
count
)
}
pub
(
crate
)
fn
sys_write
(
fd
:
i32
,
buf
:
*
const
c_void
,
count
:
usize
)
->
isize
{
api
::
sys_write
(
fd
,
buf
,
count
)
}
...
...
This diff is collapsed.
Click to expand it.
src/syscall_imp/fs/mod.rs
+
2
−
2
View file @
37873ae8
mod
ctl
;
mod
io
;
pub
(
crate
)
use
ctl
::
*
;
pub
(
crate
)
use
io
::
*
;
pub
(
crate
)
use
self
::
ctl
::
*
;
pub
(
crate
)
use
self
::
io
::
*
;
This diff is collapsed.
Click to expand it.
src/syscall_imp/mm/mmap.rs
+
2
−
4
View file @
37873ae8
use
axerrno
::
{
AxError
,
LinuxError
}
;
use
axerrno
::
LinuxError
;
use
axhal
::
paging
::
MappingFlags
;
use
axtask
::{
current
,
TaskExtRef
};
use
memory_addr
::{
VirtAddr
,
VirtAddrRange
};
...
...
@@ -91,9 +91,7 @@ pub(crate) fn sys_mmap(
.ok_or
(
LinuxError
::
ENOMEM
)
?
};
aspace
.map_alloc
(
start_addr
,
length
,
permission_flags
.into
(),
false
)
.map_err
(
<
AxError
as
From
<
_
>>
::
from
)
?
;
aspace
.map_alloc
(
start_addr
,
length
,
permission_flags
.into
(),
false
)
?
;
Ok
(
start_addr
.as_usize
())
})
...
...
This diff is collapsed.
Click to expand it.
src/syscall_imp/mm/mod.rs
+
1
−
1
View file @
37873ae8
mod
mmap
;
pub
(
crate
)
use
mmap
::
*
;
pub
(
crate
)
use
self
::
mmap
::
*
;
This diff is collapsed.
Click to expand it.
src/syscall_imp/mod.rs
+
1
−
0
View file @
37873ae8
...
...
@@ -12,6 +12,7 @@ use mm::*;
use
syscalls
::
Sysno
;
use
task
::
*
;
use
time
::
*
;
/// Macro to generate syscall body
///
/// It will receive a function which return Result<_, LinuxError> and convert it to
...
...
This diff is collapsed.
Click to expand it.
src/syscall_imp/task/mod.rs
+
2
−
2
View file @
37873ae8
mod
schedule
;
mod
thread
;
pub
(
crate
)
use
schedule
::
*
;
pub
(
crate
)
use
thread
::
*
;
pub
(
crate
)
use
self
::
schedule
::
*
;
pub
(
crate
)
use
self
::
thread
::
*
;
This diff is collapsed.
Click to expand it.
src/syscall_imp/task/thread.rs
+
7
−
7
View file @
37873ae8
...
...
@@ -5,12 +5,12 @@ use num_enum::TryFromPrimitive;
use
crate
::
syscall_body
;
#[derive(Debug,
Eq,
PartialEq,
TryFromPrimitive)]
#[repr(i32)]
/// ARCH_PRCTL codes
///
/// It is only avaliable on x86_64, and is not convenient
/// to generate automatically via c_to_rust binding.
#[derive(Debug,
Eq,
PartialEq,
TryFromPrimitive)]
#[repr(i32)]
enum
ArchPrctlCode
{
/// Set the GS segment base
SetGs
=
0x1001
,
...
...
@@ -61,32 +61,32 @@ pub(crate) fn sys_set_tid_address(tid_ptd: *const i32) -> isize {
}
#[cfg(target_arch
=
"x86_64"
)]
pub
(
crate
)
fn
sys_arch_prctl
(
code
:
i32
,
addr
:
*
mut
usize
)
->
isize
{
pub
(
crate
)
fn
sys_arch_prctl
(
code
:
i32
,
addr
:
u64
)
->
isize
{
use
axerrno
::
LinuxError
;
syscall_body!
(
sys_arch_prctl
,
{
match
ArchPrctlCode
::
try_from
(
code
)
{
// TODO: check the legality of the address
Ok
(
ArchPrctlCode
::
SetFs
)
=>
{
unsafe
{
axhal
::
arch
::
write_thread_pointer
(
*
addr
);
axhal
::
arch
::
write_thread_pointer
(
addr
as
usize
);
}
Ok
(
0
)
}
Ok
(
ArchPrctlCode
::
GetFs
)
=>
{
unsafe
{
*
addr
=
axhal
::
arch
::
read_thread_pointer
();
*
(
addr
as
*
mut
u64
)
=
axhal
::
arch
::
read_thread_pointer
()
as
u64
;
}
Ok
(
0
)
}
Ok
(
ArchPrctlCode
::
SetGs
)
=>
{
unsafe
{
x86
::
msr
::
wrmsr
(
x86
::
msr
::
IA32_KERNEL_GSBASE
,
*
addr
as
u64
);
x86
::
msr
::
wrmsr
(
x86
::
msr
::
IA32_KERNEL_GSBASE
,
addr
);
}
Ok
(
0
)
}
Ok
(
ArchPrctlCode
::
GetGs
)
=>
{
unsafe
{
*
addr
=
x86
::
msr
::
rdmsr
(
x86
::
msr
::
IA32_KERNEL_GSBASE
)
as
usize
;
*
(
addr
as
*
mut
u64
)
=
x86
::
msr
::
rdmsr
(
x86
::
msr
::
IA32_KERNEL_GSBASE
);
}
Ok
(
0
)
}
...
...
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