1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-22 16:16:16 +04:00

Do not hardcode fb addr in Vga

This commit is contained in:
Jiajie Chen 2019-05-25 08:29:54 +08:00
parent 30f94238b8
commit 235005608d
3 changed files with 20 additions and 10 deletions

View File

@ -173,6 +173,11 @@ impl Framebuffer {
unsafe { self.buf.base_addr }
}
#[inline]
pub fn framebuffer_size(&self) -> usize {
self.fb_info.screen_size as usize
}
#[inline]
pub fn bus_addr(&self) -> usize {
self.fb_info.bus_addr as usize

View File

@ -1,8 +1,8 @@
//! File handle for process
use crate::thread;
use alloc::{string::String, sync::Arc};
use core::fmt;
use crate::thread;
use rcore_fs::vfs::{FsError, INode, Metadata, PollStatus, Result};

View File

@ -31,15 +31,20 @@ impl INode for Vga {
}
fn write_at(&self, _offset: usize, _buf: &[u8]) -> Result<usize> {
info!("the _offset is {} {}", _offset, _buf[0]);
let lock = FRAME_BUFFER.lock();
if let Some(ref frame_buffer) = *lock {
use core::slice;
let frame_buffer_data = unsafe {
slice::from_raw_parts_mut(
phys_to_virt(0xfd00_0000) as *mut u8,
(1024 * 768 * 3) as usize,
frame_buffer.base_addr() as *mut u8,
frame_buffer.framebuffer_size(),
)
};
frame_buffer_data.copy_from_slice(&_buf);
return Ok(1024 * 768 * 3);
Ok(frame_buffer.framebuffer_size())
} else {
Err(FsError::EntryNotFound)
}
}
fn poll(&self) -> Result<PollStatus> {
Ok(PollStatus {