mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-23 00:16:17 +04:00
Do not hardcode fb addr in Vga
This commit is contained in:
parent
30f94238b8
commit
235005608d
@ -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
|
||||||
|
@ -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};
|
||||||
|
|
||||||
|
@ -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]);
|
||||||
|
let lock = FRAME_BUFFER.lock();
|
||||||
|
if let Some(ref frame_buffer) = *lock {
|
||||||
use core::slice;
|
use core::slice;
|
||||||
let frame_buffer_data = unsafe {
|
let frame_buffer_data = unsafe {
|
||||||
slice::from_raw_parts_mut(
|
slice::from_raw_parts_mut(
|
||||||
phys_to_virt(0xfd00_0000) as *mut u8,
|
frame_buffer.base_addr() as *mut u8,
|
||||||
(1024 * 768 * 3) as usize,
|
frame_buffer.framebuffer_size(),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
frame_buffer_data.copy_from_slice(&_buf);
|
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> {
|
fn poll(&self) -> Result<PollStatus> {
|
||||||
Ok(PollStatus {
|
Ok(PollStatus {
|
||||||
|
Loading…
Reference in New Issue
Block a user