Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion etc/syscalls_linux_aarch64.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
| 0xa5 (165) | getrusage | (int who, struct rusage *ru) | __arm64_sys_getrusage | false |
| 0xa6 (166) | umask | (int mask) | __arm64_sys_umask | true |
| 0xa7 (167) | prctl | (int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5) | __arm64_sys_prctl | stub |
| 0xa8 (168) | getcpu | (unsigned *cpup, unsigned *nodep, struct getcpu_cache *unused) | __arm64_sys_getcpu | false |
| 0xa8 (168) | getcpu | (unsigned *cpup, unsigned *nodep, struct getcpu_cache *unused) | __arm64_sys_getcpu | true |
| 0xa9 (169) | gettimeofday | (struct __kernel_old_timeval *tv, struct timezone *tz) | __arm64_sys_gettimeofday | partial |
| 0xaa (170) | settimeofday | (struct __kernel_old_timeval *tv, struct timezone *tz) | __arm64_sys_settimeofday | partial |
| 0xab (171) | adjtimex | (struct __kernel_timex *txc_p) | __arm64_sys_adjtimex | false |
Expand Down
5 changes: 3 additions & 2 deletions src/arch/arm64/exceptions/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ use crate::{
},
},
kernel::{
hostname::sys_sethostname, power::sys_reboot, rand::sys_getrandom, sysinfo::sys_sysinfo,
uname::sys_uname,
getcpu::sys_getcpu, hostname::sys_sethostname, power::sys_reboot, rand::sys_getrandom,
sysinfo::sys_sysinfo, uname::sys_uname,
},
memory::{
brk::sys_brk,
Expand Down Expand Up @@ -561,6 +561,7 @@ pub async fn handle_syscall(mut ctx: ProcessCtx) {
0xa3 => Err(KernelError::InvalidValue),
0xa6 => sys_umask(&ctx, arg1 as _).map_err(|e| match e {}),
0xa7 => sys_prctl(&ctx, arg1 as _, arg2, arg3).await,
0xa8 => sys_getcpu(TUA::from_value(arg1 as _), TUA::from_value(arg2 as _)).await,
0xa9 => sys_gettimeofday(TUA::from_value(arg1 as _), TUA::from_value(arg2 as _)).await,
0xaa => sys_settimeofday(TUA::from_value(arg1 as _), TUA::from_value(arg2 as _)).await,
0xac => sys_getpid(&ctx).map_err(|e| match e {}),
Expand Down
10 changes: 10 additions & 0 deletions src/kernel/getcpu.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use crate::kernel::cpu_id::CpuId;
use crate::memory::uaccess::copy_to_user;
use libkernel::memory::address::TUA;

pub async fn sys_getcpu(cpu_ptr: TUA<u32>, _node_ptr: TUA<u32>) -> libkernel::error::Result<usize> {
let cpu_id = CpuId::this().value() as u32;
copy_to_user(cpu_ptr, cpu_id).await?;
// TODO: implement NUMA and write the node ID to node_ptr
Ok(0)
}
1 change: 1 addition & 0 deletions src/kernel/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod cpu_id;
pub mod getcpu;
pub mod hostname;
pub mod kpipe;
pub mod power;
Expand Down
Loading