软中断&定时器重构 (#223)

* 软中断&定时器重构

Co-authored-by: houmkh<houjiaying@DragonOS.org>

* 修改timer的clock()

* 删除debug信息

---------

Co-authored-by: houmkh <1119644616@qq.com>
This commit is contained in:
login
2023-04-02 17:09:33 +08:00
committed by GitHub
parent 6d345b7742
commit bacd691c9e
33 changed files with 896 additions and 672 deletions

View File

@ -0,0 +1,62 @@
use core::{ptr::null_mut, sync::atomic::{AtomicBool, Ordering}};
use alloc::sync::Arc;
use crate::{
exception::softirq::{SoftirqNumber, SoftirqVec, softirq_vectors},
include::bindings::bindings::video_refresh_framebuffer,
};
#[derive(Debug)]
pub struct VideoRefreshFramebuffer{
running: AtomicBool
}
impl SoftirqVec for VideoRefreshFramebuffer {
fn run(&self) {
if self.set_run() == false{
return;
}
unsafe {
video_refresh_framebuffer(null_mut());
}
self.clear_run();
}
}
impl VideoRefreshFramebuffer {
pub fn new() -> VideoRefreshFramebuffer {
VideoRefreshFramebuffer {
running: AtomicBool::new(false)
}
}
fn set_run(&self) -> bool {
let x = self
.running
.compare_exchange(false, true, Ordering::Acquire, Ordering::Relaxed);
if x.is_ok() {
return true;
} else {
return false;
}
}
fn clear_run(&self) {
self.running.store(false, Ordering::Release);
}
}
pub fn register_softirq_video() {
// kdebug!("register_softirq_video");
let handler = Arc::new(VideoRefreshFramebuffer::new());
softirq_vectors()
.register_softirq(SoftirqNumber::VideoRefresh, handler)
.expect("register_softirq_video run failed");
}
// ======= 以下为给C提供的接口,video重构完后请删除 =======
#[no_mangle]
pub extern "C" fn rs_register_softirq_video() {
register_softirq_video();
}