From 87046b77c7da350d406abb8cc4fc533853796ec6 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Mon, 24 Jun 2024 22:15:35 +0200 Subject: [PATCH] Compile on aarch64. --- src/arch/aarch64/interrupt/handler.rs | 12 ++++++++++++ src/context/signal.rs | 1 + src/scheme/dtb.rs | 21 +++++++++++++++++---- syscall | 2 +- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/arch/aarch64/interrupt/handler.rs b/src/arch/aarch64/interrupt/handler.rs index 815e55828a..13aa805159 100644 --- a/src/arch/aarch64/interrupt/handler.rs +++ b/src/arch/aarch64/interrupt/handler.rs @@ -26,6 +26,12 @@ pub struct ScratchRegisters { } impl ScratchRegisters { + pub fn a(&self) -> usize { + self.x0 + } + pub fn b(&self) -> usize { + self.x1 + } pub fn dump(&self) { println!("X0: {:>016X}", { self.x0 }); println!("X1: {:>016X}", { self.x1 }); @@ -123,6 +129,12 @@ impl InterruptStack { pub fn set_instr_pointer(&mut self, ip: usize) { self.iret.elr_el1 = ip; } + pub fn instr_pointer(&self) -> usize { + self.iret.elr_el1 + } + pub fn flags(&self) -> usize { + 0 // TODO + } // TODO: This can maybe be done in userspace? pub fn set_syscall_ret_reg(&mut self, ret: usize) { self.scratch.x0 = ret; diff --git a/src/context/signal.rs b/src/context/signal.rs index 75736580cd..08de1da5fd 100644 --- a/src/context/signal.rs +++ b/src/context/signal.rs @@ -100,6 +100,7 @@ pub fn signal_handler() { thread_ctl.saved_scratch_b.set(scratch_b); thread_ctl.control_flags.store((control_flags | SigcontrolFlags::INHIBIT_DELIVERY).bits(), Ordering::Release); + log::info!("delivering"); } pub fn excp_handler(signal: usize) { let current = context::current().expect("CPU exception but not inside of context!"); diff --git a/src/scheme/dtb.rs b/src/scheme/dtb.rs index e65f1c9222..84312e649b 100644 --- a/src/scheme/dtb.rs +++ b/src/scheme/dtb.rs @@ -74,6 +74,21 @@ impl KernelScheme for DtbScheme { Err(Error::new(ENOENT)) } + fn fsize(&self, id: usize) -> Result { + let mut handles = HANDLES.write(); + let handle = handles.get_mut(&id).ok_or(Error::new(EBADF))?; + + if handle.stat { + return Err(Error::new(EBADF)); + } + + let file_len = match handle.kind { + HandleKind::RawData => DATA.get().ok_or(Error::new(EBADFD))?.len(), + }; + + Ok(file_len as u64) + } + fn close(&self, id: usize) -> Result<()> { if HANDLES.write().remove(&id).is_none() { return Err(Error::new(EBADF)); @@ -81,7 +96,7 @@ impl KernelScheme for DtbScheme { Ok(()) } - fn kreadoff(&self, id: usize, dst_buf: UserSliceWo, offset: u64, flags: u32, _stored_flags: u32) -> Result { + fn kreadoff(&self, id: usize, dst_buf: UserSliceWo, offset: u64, _flags: u32, _stored_flags: u32) -> Result { let mut handles = HANDLES.write(); let handle = handles.get_mut(&id).ok_or(Error::new(EBADF))?; @@ -98,9 +113,7 @@ impl KernelScheme for DtbScheme { .get(src_offset..) .expect("expected data to be at least data.len() bytes long"); - let bytes_copied = dst_buf.copy_common_bytes_from_slice(src_buf)?; - - Ok(bytes_copied) + dst_buf.copy_common_bytes_from_slice(src_buf) } fn kfstat(&self, id: usize, buf: UserSliceWo) -> Result<()> { diff --git a/syscall b/syscall index c230cec21c..9eb2eccfc3 160000 --- a/syscall +++ b/syscall @@ -1 +1 @@ -Subproject commit c230cec21c5f2bce486140b977ce1f6860d6df93 +Subproject commit 9eb2eccfc304ec2255d9bb1daddd9c246927bca3