Rustfmt the common crate

This commit is contained in:
bjorn3
2024-07-20 15:13:43 +02:00
parent ca3bf0f0e6
commit 4d0008a32b
4 changed files with 21 additions and 8 deletions
+7 -3
View File
@@ -3,7 +3,7 @@ use std::ops::{Deref, DerefMut};
use std::ptr;
use libredox::call::MmapArgs;
use libredox::{flag, error::Result, Fd};
use libredox::{error::Result, flag, Fd};
use syscall::PAGE_SIZE;
use crate::MemoryType;
@@ -34,7 +34,7 @@ fn alloc_and_map(length: usize) -> Result<(usize, *mut ())> {
let fd = phys_contiguous_fd()?;
let virt = libredox::call::mmap(MmapArgs {
fd: fd.raw(),
offset: 0, // ignored
offset: 0, // ignored
addr: core::ptr::null_mut(), // ignored
length,
flags: flag::MAP_PRIVATE,
@@ -42,7 +42,11 @@ fn alloc_and_map(length: usize) -> Result<(usize, *mut ())> {
})?;
let phys = syscall::virttophys(virt as usize)?;
for i in 1..length.div_ceil(PAGE_SIZE) {
debug_assert_eq!(syscall::virttophys(virt as usize + i * PAGE_SIZE), Ok(phys + i * PAGE_SIZE), "NOT CONTIGUOUS");
debug_assert_eq!(
syscall::virttophys(virt as usize + i * PAGE_SIZE),
Ok(phys + i * PAGE_SIZE),
"NOT CONTIGUOUS"
);
}
Ok((phys, virt as *mut ()))
}
+1 -1
View File
@@ -1,8 +1,8 @@
#![feature(int_roundings)]
use libredox::call::MmapArgs;
use libredox::{Fd, error::*, errno::EINVAL};
use libredox::flag::{self, O_CLOEXEC, O_RDONLY, O_RDWR, O_WRONLY};
use libredox::{errno::EINVAL, error::*, Fd};
use syscall::PAGE_SIZE;
pub mod dma;
+11 -3
View File
@@ -35,7 +35,8 @@ impl Sgl {
offset: 0,
fd: !0,
addr: core::ptr::null_mut(),
})?.cast::<u8>();
})?
.cast::<u8>();
let mut this = Self {
virt,
@@ -51,7 +52,9 @@ impl Sgl {
let mut offset = 0;
while offset < unaligned_length.get() {
let chunk_length = (aligned_length - offset).min(MAX_ALLOC_SIZE).next_power_of_two();
let chunk_length = (aligned_length - offset)
.min(MAX_ALLOC_SIZE)
.next_power_of_two();
libredox::call::mmap(MmapArgs {
addr: virt.add(offset).cast(),
flags: MAP_PRIVATE | (MAP_FIXED.bits() as u32),
@@ -62,7 +65,12 @@ impl Sgl {
offset: 0,
})?;
let phys = syscall::virttophys(virt as usize + offset)?;
this.chunks.push(Chunk { offset, phys, length: (unaligned_length.get() - offset).min(chunk_length), virt: virt.add(offset) });
this.chunks.push(Chunk {
offset,
phys,
length: (unaligned_length.get() - offset).min(chunk_length),
virt: virt.add(offset),
});
offset += chunk_length;
}
+2 -1
View File
@@ -16,7 +16,8 @@ function fmt() {
done
}
fmt graphics/bgad \
fmt common \
graphics/bgad \
graphics/fbcond \
graphics/vesad \
graphics/virtio-gpud \