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 } unsafe { self.buf.base_addr }
} }
#[inline]
pub fn framebuffer_size(&self) -> usize {
self.fb_info.screen_size as usize
}
#[inline] #[inline]
pub fn bus_addr(&self) -> usize { pub fn bus_addr(&self) -> usize {
self.fb_info.bus_addr as usize self.fb_info.bus_addr as usize

View File

@ -1,8 +1,8 @@
//! File handle for process //! File handle for process
use crate::thread;
use alloc::{string::String, sync::Arc}; use alloc::{string::String, sync::Arc};
use core::fmt; use core::fmt;
use crate::thread;
use rcore_fs::vfs::{FsError, INode, Metadata, PollStatus, Result}; 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> { fn write_at(&self, _offset: usize, _buf: &[u8]) -> Result<usize> {
info!("the _offset is {} {}", _offset, _buf[0]); info!("the _offset is {} {}", _offset, _buf[0]);
use core::slice; let lock = FRAME_BUFFER.lock();
let frame_buffer_data = unsafe { if let Some(ref frame_buffer) = *lock {
slice::from_raw_parts_mut( use core::slice;
phys_to_virt(0xfd00_0000) as *mut u8, let frame_buffer_data = unsafe {
(1024 * 768 * 3) as usize, slice::from_raw_parts_mut(
) frame_buffer.base_addr() as *mut u8,
}; frame_buffer.framebuffer_size(),
frame_buffer_data.copy_from_slice(&_buf); )
return Ok(1024 * 768 * 3); };
frame_buffer_data.copy_from_slice(&_buf);
Ok(frame_buffer.framebuffer_size())
} else {
Err(FsError::EntryNotFound)
}
} }
fn poll(&self) -> Result<PollStatus> { fn poll(&self) -> Result<PollStatus> {
Ok(PollStatus { Ok(PollStatus {