feature: virtio console support (#1113)

feat(virtio): add virtio console driver support

- Implement virtio console driver with TTY interface
- Add HVC device support for console output
- Update devfs to handle HVC devices
- Fix virtio driver registration and initialization
- Improve virtio net driver interrupt handling
- Clean up block device naming implementation
- Add clippy lint checks to multiple crates
- Fix slab allocator alignment issues
- Update QEMU run script for virtio consoleagonOS.org>

---------

Signed-off-by: longjin <longjin@DragonOS.org>
This commit is contained in:
LoGin
2025-03-27 20:48:40 +08:00
committed by GitHub
parent 3d663af8a2
commit b6db20c072
31 changed files with 974 additions and 141 deletions

View File

@ -7,6 +7,12 @@ pub struct BitMapCore<T: BitOps> {
phantom: PhantomData<T>,
}
impl<T: BitOps> Default for BitMapCore<T> {
fn default() -> Self {
Self::new()
}
}
impl<T: BitOps> BitMapCore<T> {
pub const fn new() -> Self {
Self {

View File

@ -2,6 +2,7 @@
#![feature(core_intrinsics)]
#![allow(incomplete_features)] // for const generics
#![feature(generic_const_exprs)]
#![deny(clippy::all)]
#![allow(internal_features)]
#![allow(clippy::needless_return)]

View File

@ -23,7 +23,8 @@
#![crate_name = "slabmalloc"]
#![crate_type = "lib"]
#![feature(maybe_uninit_as_bytes)]
#![deny(clippy::all)]
#![allow(clippy::needless_return)]
extern crate alloc;
mod pages;

View File

@ -33,7 +33,7 @@ impl Bitfield for [AtomicU64] {
fn initialize(&mut self, for_size: usize, capacity: usize) {
// Set everything to allocated
for bitmap in self.iter_mut() {
*bitmap = AtomicU64::new(u64::max_value());
*bitmap = AtomicU64::new(u64::MAX);
}
// Mark actual slots as free
@ -56,7 +56,7 @@ impl Bitfield for [AtomicU64] {
) -> Option<(usize, usize)> {
for (base_idx, b) in self.iter().enumerate() {
let bitval = b.load(Ordering::Relaxed);
if bitval == u64::max_value() {
if bitval == u64::MAX {
continue;
} else {
let negated = !bitval;
@ -117,7 +117,7 @@ impl Bitfield for [AtomicU64] {
#[inline(always)]
fn is_full(&self) -> bool {
self.iter()
.filter(|&x| x.load(Ordering::Relaxed) != u64::max_value())
.filter(|&x| x.load(Ordering::Relaxed) != u64::MAX)
.count()
== 0
}
@ -268,10 +268,10 @@ impl<'a> ObjectPage<'a> {
}
// These needs some more work to be really safe...
unsafe impl<'a> Send for ObjectPage<'a> {}
unsafe impl<'a> Sync for ObjectPage<'a> {}
unsafe impl Send for ObjectPage<'_> {}
unsafe impl Sync for ObjectPage<'_> {}
impl<'a> AllocablePage for ObjectPage<'a> {
impl AllocablePage for ObjectPage<'_> {
const SIZE: usize = OBJECT_PAGE_SIZE;
fn bitfield(&self) -> &[AtomicU64; 8] {
@ -296,7 +296,7 @@ impl<'a> Default for ObjectPage<'a> {
}
}
impl<'a> fmt::Debug for ObjectPage<'a> {
impl fmt::Debug for ObjectPage<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "ObjectPage")
}
@ -401,6 +401,8 @@ impl<'a, T: AllocablePage> PageList<'a, T> {
});
self.elements -= 1;
#[allow(clippy::manual_inspect)]
new_head.map(|node| {
*node.prev() = Rawlink::none();
*node.next() = Rawlink::none();
@ -434,6 +436,7 @@ impl<'a, P: AllocablePage + 'a> Iterator for ObjectPageIterMut<'a, P> {
#[inline]
fn next(&mut self) -> Option<&'a mut P> {
unsafe {
#[allow(clippy::manual_inspect)]
self.head.resolve_mut().map(|next| {
self.head = match next.next().resolve_mut() {
None => Rawlink::none(),

View File

@ -71,7 +71,7 @@ macro_rules! new_sc_allocator {
SCAllocator {
size: $size,
allocation_count: 0,
obj_per_page: obj_per_page,
obj_per_page,
empty_slabs: PageList::new(),
slabs: PageList::new(),
full_slabs: PageList::new(),