mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-18 08:06:32 +00:00
feat:(riscv/intr) 实现riscv plic驱动,能处理外部中断 (#799)
* feat:(riscv/intr) 实现riscv plic驱动,能处理外部中断 - 实现riscv plic驱动,能处理外部中断 - 能收到virtio-blk的中断 - 实现fasteoi interrupt handler
This commit is contained in:
@ -20,6 +20,12 @@ impl AllocBitmap {
|
||||
core: BitMapCore::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bitand_assign(&mut self, rhs: &Self) {
|
||||
for i in 0..rhs.data.len() {
|
||||
self.data[i] &= rhs.data[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BitMapOps<usize> for AllocBitmap {
|
||||
@ -111,8 +117,8 @@ impl BitMapOps<usize> for AllocBitmap {
|
||||
}
|
||||
}
|
||||
|
||||
impl BitAnd for AllocBitmap {
|
||||
type Output = Self;
|
||||
impl BitAnd for &AllocBitmap {
|
||||
type Output = AllocBitmap;
|
||||
|
||||
fn bitand(self, rhs: Self) -> Self::Output {
|
||||
let mut result = AllocBitmap::new(self.elements);
|
||||
@ -122,3 +128,11 @@ impl BitAnd for AllocBitmap {
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
impl BitAnd for AllocBitmap {
|
||||
type Output = AllocBitmap;
|
||||
|
||||
fn bitand(self, rhs: Self) -> Self::Output {
|
||||
&self & &rhs
|
||||
}
|
||||
}
|
||||
|
@ -663,3 +663,23 @@ fn test_alloc_bitmap_bitand_128() {
|
||||
assert_eq!(bitmap3.first_false_index(), Some(2));
|
||||
assert_eq!(bitmap3.last_index(), Some(67));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_alloc_bitmap_bitand_assign_128() {
|
||||
let mut bitmap = AllocBitmap::new(128);
|
||||
bitmap.set_all(true);
|
||||
|
||||
let mut bitmap2 = AllocBitmap::new(128);
|
||||
|
||||
bitmap2.set(0, true);
|
||||
bitmap2.set(1, true);
|
||||
bitmap2.set(67, true);
|
||||
|
||||
bitmap.bitand_assign(&bitmap2);
|
||||
|
||||
assert_eq!(bitmap.len(), 128);
|
||||
assert_eq!(bitmap.size(), 16);
|
||||
assert_eq!(bitmap.first_index(), Some(0));
|
||||
assert_eq!(bitmap.first_false_index(), Some(2));
|
||||
assert_eq!(bitmap.last_index(), Some(67));
|
||||
}
|
||||
|
Reference in New Issue
Block a user