4
1
mirror of https://github.com/DragonOS-Community/DragonOS.git synced 2025-07-10 14:23:43 +00:00

pci重构+pcie支持 (#235)

* pci重构+pcie支持

* pci重构测试完成

* 修正makefile的问题

* 小修改

* 修改函数名字
This commit is contained in:
YJwu2023
2023-04-09 12:30:02 +08:00
committed by GitHub
parent 5c9a63df83
commit 78bf93f02f
56 changed files with 1478 additions and 501 deletions

@ -1,9 +1,6 @@
#![allow(dead_code)]
use super::spinlock::RawSpinlock;
use crate::{
arch::asm::cmpxchg::try_cmpxchg_q,
syscall::SystemError,
};
use crate::{arch::asm::cmpxchg::try_cmpxchg_q, syscall::SystemError};
use core::{fmt::Debug, intrinsics::size_of};
#[cfg(target_arch = "x86_64")]
@ -53,7 +50,7 @@ impl LockRef {
fn cmpxchg_loop(&mut self, mode: CmpxchgMode) -> Result<i32, i32> {
use core::ptr::read_volatile;
use crate::{arch::cpu::cpu_relax};
use crate::arch::cpu::cpu_relax;
let mut old: LockRef = LockRef::INIT;
old.count = unsafe { read_volatile(&self.count) };
@ -265,7 +262,7 @@ impl LockRef {
let cmpxchg_result = self.cmpxchg_loop(CmpxchgMode::DecreaseNotZero);
if cmpxchg_result.is_ok() {
return Ok(cmpxchg_result.unwrap());
} else if cmpxchg_result.unwrap_err() == 1{
} else if cmpxchg_result.unwrap_err() == 1 {
return Err(SystemError::EPERM);
}
}

@ -8,9 +8,10 @@ use alloc::collections::LinkedList;
use crate::{
arch::{asm::current::current_pcb, sched::sched},
include::bindings::bindings::{
pid_t, process_control_block, process_wakeup, PROC_INTERRUPTIBLE, PROC_RUNNING,
pid_t, process_control_block, process_wakeup, PROC_INTERRUPTIBLE, PROC_RUNNING,
},
libs::spinlock::SpinLockGuard, syscall::SystemError,
libs::spinlock::SpinLockGuard,
syscall::SystemError,
};
use super::spinlock::SpinLock;

@ -12,13 +12,13 @@
#![allow(dead_code)]
use core::cmp::Ord;
use core::fmt::{self, Debug};
use core::cmp::Ordering;
use core::ptr;
use core::iter::{IntoIterator, FromIterator};
use core::fmt::{self, Debug};
use core::iter::{FromIterator, IntoIterator};
use core::marker;
use core::mem;
use core::ops::Index;
use core::ptr;
use alloc::boxed::Box;
@ -234,7 +234,6 @@ impl<K: Ord, V> NodePtr<K, V> {
unsafe { (*self.0).right = right }
}
#[inline]
fn parent(&self) -> NodePtr<K, V> {
if self.is_null() {
@ -421,9 +420,8 @@ where
return false;
}
self.iter().all(|(key, value)| {
other.get(key).map_or(false, |v| *value == *v)
})
self.iter()
.all(|(key, value)| other.get(key).map_or(false, |v| *value == *v))
}
}
@ -446,7 +444,6 @@ where
}
}
impl<K: Ord, V> FromIterator<(K, V)> for RBTree<K, V> {
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> RBTree<K, V> {
let mut tree = RBTree::new();
@ -483,7 +480,9 @@ pub struct Keys<'a, K: Ord + 'a, V: 'a> {
impl<'a, K: Ord, V> Clone for Keys<'a, K, V> {
fn clone(&self) -> Keys<'a, K, V> {
Keys { inner: self.inner.clone() }
Keys {
inner: self.inner.clone(),
}
}
}
@ -526,7 +525,9 @@ pub struct Values<'a, K: 'a + Ord, V: 'a> {
impl<'a, K: Ord, V> Clone for Values<'a, K, V> {
fn clone(&self) -> Values<'a, K, V> {
Values { inner: self.inner.clone() }
Values {
inner: self.inner.clone(),
}
}
}
@ -536,7 +537,6 @@ impl<'a, K: Ord + Debug, V: Debug> fmt::Debug for Values<'a, K, V> {
}
}
impl<'a, K: Ord, V> Iterator for Values<'a, K, V> {
type Item = &'a V;
@ -573,7 +573,9 @@ pub struct ValuesMut<'a, K: 'a + Ord, V: 'a> {
impl<'a, K: Ord, V> Clone for ValuesMut<'a, K, V> {
fn clone(&self) -> ValuesMut<'a, K, V> {
ValuesMut { inner: self.inner.clone() }
ValuesMut {
inner: self.inner.clone(),
}
}
}
@ -812,7 +814,6 @@ impl<'a, K: Ord + 'a, V: 'a> DoubleEndedIterator for IterMut<'a, K, V> {
}
}
impl<K: Ord, V> IntoIterator for RBTree<K, V> {
type Item = (K, V);
type IntoIter = IntoIter<K, V>;
@ -1387,7 +1388,9 @@ impl<K: Ord, V> RBTree<K, V> {
/// Return the value iter mut
#[inline]
pub fn values_mut(&mut self) -> ValuesMut<K, V> {
ValuesMut { inner: self.iter_mut() }
ValuesMut {
inner: self.iter_mut(),
}
}
/// Return the key and value iter
@ -1441,7 +1444,6 @@ mod tests {
assert_eq!(*m.get(&2).unwrap(), 6);
}
#[test]
fn test_clone() {
let mut m = RBTree::new();
@ -1788,4 +1790,4 @@ mod tests {
assert_eq!(a[&2], "two");
assert_eq!(a[&3], "three");
}
}
}

@ -7,7 +7,7 @@ use core::{
sync::atomic::{AtomicU32, Ordering},
};
use crate::{syscall::SystemError};
use crate::syscall::SystemError;
///RwLock读写锁

@ -59,10 +59,10 @@ macro_rules! volatile_write_bit {
/// queue_driver: Volatile<u64>,
/// queue_device: Volatile<u64>,
/// }
///
///
/// 对CommonCfg里面的某个寄存器进行读写
/// volwrite!(self.common_cfg, queue_enable, 0);
///
///
/// 这样做不仅使代码的可读性提高了,也避免了对只读寄存器进行写入的误操作
/// 只读寄存器