ckb_debugger/
syscall_timestamp.rs1use ckb_vm::{
2 Error, Register, SupportMachine, Syscalls,
3 registers::{A0, A7},
4};
5
6pub struct Timestamp {}
7
8impl Timestamp {
9 pub fn new() -> Self {
10 Self {}
11 }
12}
13
14impl<Mac: SupportMachine> Syscalls<Mac> for Timestamp {
15 fn initialize(&mut self, _machine: &mut Mac) -> Result<(), Error> {
16 Ok(())
17 }
18
19 fn ecall(&mut self, machine: &mut Mac) -> Result<bool, Error> {
20 let id = machine.registers()[A7].to_u64();
21 if id != 9001 {
22 return Ok(false);
23 }
24 let timestamp = crate::arch::timestamp();
25 machine.set_register(A0, Mac::REG::from_u64(timestamp));
26 return Ok(true);
27 }
28}