Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalmiel committed Oct 24, 2023
1 parent 393b7a8 commit e8e42a3
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 17 deletions.
21 changes: 16 additions & 5 deletions cykusz-rs/src/arch/x86_64/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ pub fn log_fmt(args: core::fmt::Arguments) -> core::fmt::Result {
core::fmt::write(&mut Log {}, args)
}

pub fn log_fmt_disabled(_args: core::fmt::Arguments) -> core::fmt::Result {
//core::fmt::write(&mut Log {}, args)
Ok(())
}

#[macro_export]
macro_rules! println {
($fmt:expr) => (print!(concat!($fmt, "\n")));
Expand All @@ -215,9 +220,11 @@ macro_rules! logln_disabled {
}

#[macro_export]
#[allow(unused)]
macro_rules! log_disabled {
($($arg:tt)*) => {{
//$crate::arch::output::log_fmt(format_args!($($arg)*)).unwrap();
let _ = ($($arg)*);
$crate::arch::output::log_fmt_disabled(format_args!($($arg)*)).unwrap();
}};
}

Expand All @@ -228,9 +235,10 @@ macro_rules! logln {
}

#[macro_export]
#[allow(unused)]
macro_rules! log {
($($arg:tt)*) => ({
//$crate::arch::output::log_fmt(format_args!($($arg)*)).unwrap();
$crate::arch::output::log_fmt_disabled(format_args!($($arg)*)).unwrap();
});
}
#[macro_export]
Expand All @@ -240,9 +248,10 @@ macro_rules! logln2 {
}

#[macro_export]
#[allow(unused)]
macro_rules! log2 {
($($arg:tt)*) => {{
//$crate::arch::output::log_fmt(format_args!($($arg)*)).unwrap();
$crate::arch::output::log_fmt_disabled(format_args!($($arg)*)).unwrap();
}};
}
#[macro_export]
Expand All @@ -252,9 +261,10 @@ macro_rules! logln3 {
}

#[macro_export]
#[allow(unused)]
macro_rules! log3 {
($($arg:tt)*) => {{
//$crate::arch::output::log_fmt(format_args!($($arg)*)).unwrap();
$crate::arch::output::log_fmt_disabled(format_args!($($arg)*)).unwrap();
}};
}

Expand All @@ -265,8 +275,9 @@ macro_rules! logln4 {
}

#[macro_export]
#[allow(unused)]
macro_rules! log4 {
($($arg:tt)*) => {{
$crate::arch::output::log_fmt(format_args!($($arg)*)).unwrap();
$crate::arch::output::log_fmt_disabled(format_args!($($arg)*)).unwrap();
}};
}
2 changes: 1 addition & 1 deletion cykusz-rs/src/arch/x86_64/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub extern "C" fn fast_syscall_handler(sys_frame: &mut SyscallFrame, regs: &mut
regs.rax, regs.rdi, regs.rsi, regs.rdx, regs.r10, regs.r8, regs.r9,
);

logln_disabled!("done syscall {} = {}", regs.rax, res);
logln_disabled!("done syscall {} = {:?}", regs.rax, res);

crate::arch::signal::arch_sys_check_signals(res, sys_frame, regs);
}
Expand Down
3 changes: 1 addition & 2 deletions cykusz-rs/src/arch/x86_64/utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use alloc::vec::Vec;
use crate::arch::mm::VirtAddr;
use crate::drivers::elf::types::AuxvType;
use crate::drivers::elf::ElfHeader;
Expand Down Expand Up @@ -61,7 +60,7 @@ impl<'a> StackHelper<'a> {
}

pub unsafe fn write_aux(&mut self, hdr: &ElfHeader, base_addr: VirtAddr, path_ptr: u64) {
let mut hdr: [(AuxvType, usize); 5] = [
let hdr: [(AuxvType, usize); 5] = [
(AuxvType::AtPhdr, hdr.e_phoff as usize + base_addr.0),
(AuxvType::AtPhEnt, hdr.e_phentsize as usize),
(AuxvType::AtPhNum, hdr.e_phnum as usize),
Expand Down
2 changes: 1 addition & 1 deletion cykusz-rs/src/kernel/fs/ext2/blockgroup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ impl BlockGroupDescriptors {
pub fn debug(&self) {
let l = self.d_desc.lock();

for _d in l.vec.iter() {
for d in l.vec.iter() {
logln_disabled!("{:?}", d);
}
}
Expand Down
1 change: 0 additions & 1 deletion cykusz-rs/src/kernel/fs/ext2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use alloc::sync::{Arc, Weak};
use crate::kernel::block::BlockDev;
use spin::Once;
use uuid::Uuid;
use crate::kernel::device::Device;

use crate::kernel::fs::dirent::{DirEntry, DirEntryItem};
use crate::kernel::fs::ext2::buf_block::{BufBlock, SliceBlock};
Expand Down
12 changes: 7 additions & 5 deletions cykusz-rs/src/kernel/syscall/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,6 @@ pub fn sys_unlink(at: u64, path: u64, path_len: u64, flags: u64) -> SyscallResul
return Err(SyscallError::EBADFD);
}



let (_, name) = path.containing_dir();

let file = lookup_by_real_path(path, LookupMode::None)?;
Expand Down Expand Up @@ -1107,9 +1105,13 @@ pub fn sys_truncate(fd: u64, size: u64) -> SyscallResult {
logln4!("truncate {} to size {}", fd, size);
let task = current_task_ref();

task.filetable().get_handle(fd as usize).ok_or(SyscallError::EBADFD)?.inode.inode().truncate(size as usize).map(|_r| {
Ok(0)
})?
task.filetable()
.get_handle(fd as usize)
.ok_or(SyscallError::EBADFD)?
.inode
.inode()
.truncate(size as usize)
.map(|_r| Ok(0))?
}

pub fn sys_futex_wake(uaddr: u64) -> SyscallResult {
Expand Down
12 changes: 10 additions & 2 deletions cykusz-rs/src/kernel/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,16 @@ impl Task {
if let Some((base_addr, entry, elf_hdr, tls_vm)) = vm.load_bin(exe.clone()) {
vm.log_vm();
unsafe {
self.arch_task_mut()
.exec(base_addr, entry, &elf_hdr, vm, tls_vm, exe.full_path(), args, envs)
self.arch_task_mut().exec(
base_addr,
entry,
&elf_hdr,
vm,
tls_vm,
exe.full_path(),
args,
envs,
)
}
} else {
Err(SyscallError::EINVAL)
Expand Down

0 comments on commit e8e42a3

Please sign in to comment.