mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-22 16:16:16 +04:00
Fix compilation for merge and update vga buffer address
This commit is contained in:
parent
53bb55b971
commit
c5acdb67e6
4
kernel/Cargo.lock
generated
4
kernel/Cargo.lock
generated
@ -697,7 +697,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum buddy_system_allocator 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "59da15ef556589ee78370281d75b67f2d69ed26465ec0e0f3961e2021502426f"
|
||||
"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb"
|
||||
"checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427"
|
||||
"checksum cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)" = "c9ce8bb087aacff865633f0bd5aeaed910fe2fe55b55f4739527f2e023a2e53d"
|
||||
"checksum cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)" = "a0c56216487bb80eec9c4516337b2588a4f2a2290d72a1416d930e4dcdb0c90d"
|
||||
"checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4"
|
||||
"checksum console-traits 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f711b3d1d5c3f7ae7d6428901c0f3e5d5f5c800fcfac86bf0252e96373a2cec6"
|
||||
"checksum deque 0.3.2 (git+https://github.com/rcore-os/deque.git?branch=no_std)" = "<none>"
|
||||
@ -762,7 +762,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
"checksum x86 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "841e1ca5a87068718a2a26f2473c6f93cf3b8119f9778fa0ae4b39b664d9e66a"
|
||||
"checksum x86_64 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f9258d7e2dd25008d69e8c9e9ee37865887a5e1e3d06a62f1cb3f6c209e6f177"
|
||||
"checksum x86_64 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1d0a8201f52d2c7b373c7243dcdfb27c0dd5012f221ef6a126f507ee82005204"
|
||||
"checksum x86_64 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bb8f09c32a991cc758ebcb9b7984f530095d32578a4e7b85db6ee1f0bbe4c9c6"
|
||||
"checksum x86_64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d69bf2d256c74df90fcc68aaf99862dd205310609e9d56247a5c82ead2f28a93"
|
||||
"checksum xmas-elf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "22678df5df766e8d1e5d609da69f0c3132d794edf6ab5e75e7abcd2270d4cf58"
|
||||
"checksum zero 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5f1bc8a6b2005884962297587045002d8cfb8dcec9db332f4ca216ddc5de82c5"
|
||||
|
@ -98,6 +98,7 @@ export DTB = $(dtb)
|
||||
qemu_opts := \
|
||||
-smp cores=$(smp)
|
||||
qemu_net_opts :=
|
||||
qemu_ui_opts :=
|
||||
|
||||
ifeq ($(arch), x86_64)
|
||||
qemu_opts += \
|
||||
@ -120,6 +121,8 @@ qemu_opts += \
|
||||
-machine accel=kvm
|
||||
qemu_net_opts += \
|
||||
-device vfio-pci,host=$(pci_passthru)
|
||||
qemu_ui_opts += \
|
||||
-vga std
|
||||
endif
|
||||
ifeq ($(extra_nic), on)
|
||||
qemu_net_opts += \
|
||||
@ -138,6 +141,9 @@ qemu_opts += \
|
||||
qemu_net_opts += \
|
||||
-netdev type=tap,id=net0,script=no,downscript=no \
|
||||
-device virtio-net-device,netdev=net0
|
||||
qemu_ui_opts += \
|
||||
-device virtio-gpu-device \
|
||||
-device virtio-mouse-device
|
||||
|
||||
else ifeq ($(arch), riscv64)
|
||||
ifeq ($(board), u540)
|
||||
@ -158,6 +164,9 @@ endif
|
||||
qemu_net_opts += \
|
||||
-netdev type=tap,id=net0,script=no,downscript=no \
|
||||
-device virtio-net-device,netdev=net0
|
||||
qemu_ui_opts += \
|
||||
-device virtio-gpu-device \
|
||||
-device virtio-mouse-device
|
||||
|
||||
else ifeq ($(arch), aarch64)
|
||||
qemu_opts += \
|
||||
@ -271,9 +280,7 @@ justrunnet: build
|
||||
@sudo qemu-system-$(arch) $(qemu_opts) $(qemu_net_opts)
|
||||
|
||||
justrunui: build
|
||||
@qemu-system-$(arch) $(qemu_opts) \
|
||||
-device virtio-gpu-device \
|
||||
-device virtio-mouse-device
|
||||
@qemu-system-$(arch) $(qemu_opts) $(qemu_ui_opts)
|
||||
|
||||
justruntest: build
|
||||
@qemu-system-$(arch) $(filter-out -serial mon:stdio, $(qemu_opts)) --append $(init) -serial file:../tests/stdout -monitor null
|
||||
|
@ -1,15 +1,16 @@
|
||||
#[path = "../../../drivers/gpu/fb.rs"]
|
||||
pub mod fb;
|
||||
|
||||
use fb::{ColorConfig, FramebufferInfo, FramebufferResult, FRAME_BUFFER};
|
||||
use crate::consts::KERNEL_OFFSET;
|
||||
use crate::memory::phys_to_virt;
|
||||
use fb::{ColorConfig, FramebufferInfo, FramebufferResult, FRAME_BUFFER};
|
||||
|
||||
pub fn init_driver() {
|
||||
#[cfg(not(feature = "nographic"))]
|
||||
fb::init();
|
||||
}
|
||||
|
||||
pub fn probe_fb_info(width : u32, height : u32, depth : u32) -> FramebufferResult {
|
||||
pub fn probe_fb_info(width: u32, height: u32, depth: u32) -> FramebufferResult {
|
||||
let fb_info = FramebufferInfo {
|
||||
xres: 1024,
|
||||
yres: 768,
|
||||
@ -22,5 +23,9 @@ pub fn probe_fb_info(width : u32, height : u32, depth : u32) -> FramebufferResul
|
||||
bus_addr: 0xfd00_0000,
|
||||
screen_size: 1024 * 768 * 3,
|
||||
};
|
||||
Ok((fb_info, fb::ColorConfig::BGRA8888, KERNEL_OFFSET + 0xf000_0000))
|
||||
Ok((
|
||||
fb_info,
|
||||
fb::ColorConfig::BGRA8888,
|
||||
phys_to_virt(0xfd00_0000),
|
||||
))
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use super::driver::console::CONSOLE;
|
||||
use super::driver::serial::*;
|
||||
use core::fmt::{Arguments, Write};
|
||||
use super::driver::console::CONSOLE;
|
||||
|
||||
pub fn getchar() -> char {
|
||||
unsafe {
|
||||
@ -26,7 +26,7 @@ pub fn putfmt(fmt: Arguments) {
|
||||
COM1.lock().write_fmt(fmt).unwrap();
|
||||
//unsafe { CONSOLE.force_unlock() }
|
||||
//if let Some(console) = CONSOLE.lock().as_mut() {
|
||||
//console.write_fmt(fmt).unwrap();
|
||||
//console.write_fmt(fmt).unwrap();
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ use bootloader::bootinfo::{BootInfo, MemoryRegionType};
|
||||
use core::sync::atomic::*;
|
||||
use log::*;
|
||||
|
||||
pub mod board;
|
||||
pub mod consts;
|
||||
pub mod cpu;
|
||||
pub mod driver;
|
||||
@ -15,8 +16,6 @@ pub mod paging;
|
||||
pub mod rand;
|
||||
pub mod syscall;
|
||||
pub mod timer;
|
||||
pub mod ipi;
|
||||
pub mod board;
|
||||
|
||||
static AP_CAN_INIT: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
|
@ -153,7 +153,7 @@ impl Framebuffer {
|
||||
8 => ColorDepth8,
|
||||
16 => ColorDepth16,
|
||||
32 => ColorDepth32,
|
||||
24=> ColorDepth24,
|
||||
24 => ColorDepth24,
|
||||
_ => Err(format!("unsupported color depth {}", info.depth))?,
|
||||
};
|
||||
Ok(Framebuffer {
|
||||
|
@ -73,11 +73,11 @@ impl Write for SerialPort {
|
||||
self.putchar(8);
|
||||
self.putchar(b' ');
|
||||
self.putchar(8);
|
||||
},
|
||||
}
|
||||
b'\n' => {
|
||||
self.putchar(b'\r');
|
||||
self.putchar(b'\n');
|
||||
},
|
||||
}
|
||||
c => {
|
||||
self.putchar(c);
|
||||
}
|
||||
|
@ -64,11 +64,11 @@ impl Write for SerialPort {
|
||||
self.putchar(8);
|
||||
self.putchar(b' ');
|
||||
self.putchar(8);
|
||||
},
|
||||
}
|
||||
b'\n' => {
|
||||
self.putchar(b'\r');
|
||||
self.putchar(b'\n');
|
||||
},
|
||||
}
|
||||
c => {
|
||||
self.putchar(c);
|
||||
}
|
||||
|
@ -73,11 +73,11 @@ impl Write for SerialPort {
|
||||
self.putchar(8);
|
||||
self.putchar(b' ');
|
||||
self.putchar(8);
|
||||
},
|
||||
}
|
||||
b'\n' => {
|
||||
self.putchar(b'\r');
|
||||
self.putchar(b'\n');
|
||||
},
|
||||
}
|
||||
c => {
|
||||
self.putchar(c);
|
||||
}
|
||||
|
@ -49,15 +49,16 @@ impl FileHandle {
|
||||
if !self.options.read {
|
||||
return Err(FsError::InvalidParam); // FIXME: => EBADF
|
||||
}
|
||||
let mut len : usize = 0;
|
||||
if !self.options.nonblock { // block
|
||||
let mut len: usize = 0;
|
||||
if !self.options.nonblock {
|
||||
// block
|
||||
loop {
|
||||
len = self.inode.read_at(offset, buf)?;
|
||||
if len > 0 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
len = self.inode.read_at(offset, buf)?;
|
||||
}
|
||||
Ok(len)
|
||||
|
@ -94,7 +94,7 @@ impl INode for Stdin {
|
||||
if self.can_read() {
|
||||
buf[0] = self.pop() as u8;
|
||||
Ok(1)
|
||||
}else{
|
||||
} else {
|
||||
Ok(0)
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
use rcore_fs::vfs::*;
|
||||
|
||||
use crate::arch::board::fb::FRAME_BUFFER;
|
||||
use crate::memory::phys_to_virt;
|
||||
use alloc::{string::String, sync::Arc, vec::Vec};
|
||||
use core::any::Any;
|
||||
use crate::arch::board::fb::FRAME_BUFFER;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Vga;
|
||||
@ -31,15 +32,19 @@ impl INode for Vga {
|
||||
}
|
||||
fn write_at(&self, _offset: usize, _buf: &[u8]) -> Result<usize> {
|
||||
info!("the _offset is {} {}", _offset, _buf[0]);
|
||||
use crate::consts::KERNEL_OFFSET;
|
||||
use core::slice;
|
||||
let frame_buffer_data =
|
||||
unsafe { slice::from_raw_parts_mut((KERNEL_OFFSET + 0xf000_0000) as *mut u8, ( 1024 * 768 * 3) as usize) };
|
||||
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_data.copy_from_slice(&_buf);
|
||||
return Ok(1024 * 768 * 3);
|
||||
}
|
||||
fn poll(&self) -> Result<PollStatus> {
|
||||
Ok(PollStatus { // TOKNOW and TODO
|
||||
Ok(PollStatus {
|
||||
// TOKNOW and TODO
|
||||
read: true,
|
||||
write: false,
|
||||
error: false,
|
||||
|
@ -836,11 +836,8 @@ impl Syscall<'_> {
|
||||
return Ok(total_written);
|
||||
}
|
||||
|
||||
pub fn sys_fcntl(&mut self, fd : usize, cmd : usize, arg : usize) -> SysResult{
|
||||
info!(
|
||||
"fcntl: fd: {}, cmd: {:x}, arg: {}",
|
||||
fd, cmd, arg
|
||||
);
|
||||
pub fn sys_fcntl(&mut self, fd: usize, cmd: usize, arg: usize) -> SysResult {
|
||||
info!("fcntl: fd: {}, cmd: {:x}, arg: {}", fd, cmd, arg);
|
||||
let mut proc = self.process();
|
||||
let file_like = proc.get_file_like(fd)?;
|
||||
file_like.fcntl(cmd, arg)
|
||||
@ -888,11 +885,11 @@ impl Process {
|
||||
match path {
|
||||
"/proc/self/exe" => {
|
||||
return Ok(Arc::new(Pseudo::new(&self.exec_path, FileType::SymLink)));
|
||||
},
|
||||
}
|
||||
"/dev/fb0" => {
|
||||
info!("/dev/fb0 will be opened");
|
||||
return Ok(Arc::new(Vga::default()));
|
||||
},
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
let (fd_dir_path, fd_name) = split_path(&path);
|
||||
|
@ -51,7 +51,6 @@ impl Syscall<'_> {
|
||||
);
|
||||
return Ok(addr);
|
||||
} else {
|
||||
|
||||
let file = proc.get_file(fd)?;
|
||||
info!("mmap path is {} ", &*file.path);
|
||||
match &*file.path {
|
||||
@ -62,15 +61,15 @@ impl Syscall<'_> {
|
||||
addr,
|
||||
addr + len,
|
||||
prot.to_attr(),
|
||||
Linear::new(
|
||||
( fb.bus_addr() - addr ) as isize,
|
||||
),
|
||||
Linear::new((fb.bus_addr() - addr) as isize),
|
||||
"mmap_file",
|
||||
);
|
||||
info!("mmap for /dev/fb0");
|
||||
return Ok(addr);
|
||||
} else {
|
||||
return Err(SysError::ENOENT);
|
||||
}
|
||||
return Ok(addr);
|
||||
},
|
||||
}
|
||||
_ => {
|
||||
let inode = file.inode();
|
||||
self.vm().push(
|
||||
@ -87,7 +86,7 @@ impl Syscall<'_> {
|
||||
"mmap_file",
|
||||
);
|
||||
return Ok(addr);
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -102,9 +102,12 @@ impl Syscall<'_> {
|
||||
SYS_WRITEV => self.sys_writev(args[0], args[1] as *const IoVec, args[2]),
|
||||
SYS_SENDFILE => self.sys_sendfile(args[0], args[1], args[2] as *mut usize, args[3]),
|
||||
SYS_FCNTL => {
|
||||
info!("SYS_FCNTL : {} {} {} {}", args[0], args[1], args[2], args[3]);
|
||||
info!(
|
||||
"SYS_FCNTL : {} {} {} {}",
|
||||
args[0], args[1], args[2], args[3]
|
||||
);
|
||||
self.sys_fcntl(args[0], args[1], args[2])
|
||||
},
|
||||
}
|
||||
SYS_FLOCK => self.unimplemented("flock", Ok(0)),
|
||||
SYS_FSYNC => self.sys_fsync(args[0]),
|
||||
SYS_FDATASYNC => self.sys_fdatasync(args[0]),
|
||||
@ -292,7 +295,7 @@ impl Syscall<'_> {
|
||||
),
|
||||
SYS_GETRANDOM => {
|
||||
self.sys_getrandom(args[0] as *mut u8, args[1] as usize, args[2] as u32)
|
||||
},
|
||||
}
|
||||
SYS_RT_SIGQUEUEINFO => self.unimplemented("rt_sigqueueinfo", Ok(0)),
|
||||
|
||||
// custom
|
||||
|
Loading…
Reference in New Issue
Block a user