实现了rtc的抽象,并且把x86的cmos rtc接入到设备驱动模型 (#674)

* 实现了rtc的抽象,并且把x86的cmos rtc接入到设备驱动模型。
This commit is contained in:
LoGin
2024-03-28 00:28:13 +08:00
committed by GitHub
parent 597ecc08c2
commit da15231979
28 changed files with 1441 additions and 156 deletions

View File

@ -0,0 +1,8 @@
[package]
name = "driver_base_macros"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View File

@ -0,0 +1,20 @@
#![no_std]
/// 获取指定字段
///
/// 当weak指针的strong count为0的时候清除弱引用
#[macro_export]
macro_rules! get_weak_or_clear {
($field:expr) => {{
if let Some(x) = $field.clone() {
if x.strong_count() == 0 {
$field = None;
None
} else {
Some(x)
}
} else {
None
}
}};
}