syscall: gettimeofday: impement

Provide a dummy implementation of sys_gettimeofday
This commit is contained in:
Matthew Leach
2025-11-25 16:43:37 +00:00
committed by Matthew Leach
parent 5f42f74c5c
commit 6a029c340a
4 changed files with 35 additions and 2 deletions

View File

@@ -169,7 +169,7 @@
| 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 | false |
| 0xa8 (168) | getcpu | (unsigned *cpup, unsigned *nodep, struct getcpu_cache *unused) | __arm64_sys_getcpu | false |
| 0xa9 (169) | gettimeofday | (struct __kernel_old_timeval *tv, struct timezone *tz) | __arm64_sys_gettimeofday | false |
| 0xa9 (169) | gettimeofday | (struct __kernel_old_timeval *tv, struct timezone *tz) | __arm64_sys_gettimeofday | dummy |
| 0xaa (170) | settimeofday | (struct __kernel_old_timeval *tv, struct timezone *tz) | __arm64_sys_settimeofday | false |
| 0xab (171) | adjtimex | (struct __kernel_timex *txc_p) | __arm64_sys_adjtimex | false |
| 0xac (172) | getpid | () | __arm64_sys_getpid | true |

View File

@@ -1,7 +1,7 @@
use crate::kernel::power::sys_reboot;
use crate::{
arch::{Arch, ArchImpl},
clock::gettime::sys_clock_gettime,
clock::{gettime::sys_clock_gettime, timeofday::sys_gettimeofday},
fs::{
dir::sys_getdents64,
pipe::sys_pipe2,
@@ -210,6 +210,7 @@ pub async fn handle_syscall() {
0x9b => sys_getpgid(arg1 as _),
0xa0 => sys_uname(TUA::from_value(arg1 as _)).await,
0xa6 => sys_umask(arg1 as _).map_err(|e| match e {}),
0xa9 => sys_gettimeofday(TUA::from_value(arg1 as _), TUA::from_value(arg2 as _)).await,
0xac => sys_getpid().map_err(|e| match e {}),
0xad => sys_getppid().map_err(|e| match e {}),
0xae => sys_getuid().map_err(|e| match e {}),

View File

@@ -1,3 +1,4 @@
pub mod gettime;
pub mod realtime;
pub mod timeofday;
pub mod timespec;

31
src/clock/timeofday.rs Normal file
View File

@@ -0,0 +1,31 @@
use super::timespec::TimeSpec;
use crate::memory::uaccess::{UserCopyable, copy_to_user};
use core::time::Duration;
use libkernel::{error::Result, memory::address::TUA};
#[derive(Copy, Clone)]
pub struct TimeZone {
_tz_minuteswest: i32,
_tz_dsttime: i32,
}
unsafe impl UserCopyable for TimeZone {}
pub async fn sys_gettimeofday(tv: TUA<TimeSpec>, tz: TUA<TimeZone>) -> Result<usize> {
let time: TimeSpec = Duration::new(0, 0).into();
copy_to_user(tv, time).await?;
if !tz.is_null() {
copy_to_user(
tz,
TimeZone {
_tz_minuteswest: 0,
_tz_dsttime: 0,
},
)
.await?;
}
Ok(0)
}