Fix compilation for merge and update vga buffer address

master
Jiajie Chen 6 years ago
parent 53bb55b971
commit c5acdb67e6

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 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 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 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 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 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>" "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 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 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.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 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 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" "checksum zero 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5f1bc8a6b2005884962297587045002d8cfb8dcec9db332f4ca216ddc5de82c5"

@ -98,6 +98,7 @@ export DTB = $(dtb)
qemu_opts := \ qemu_opts := \
-smp cores=$(smp) -smp cores=$(smp)
qemu_net_opts := qemu_net_opts :=
qemu_ui_opts :=
ifeq ($(arch), x86_64) ifeq ($(arch), x86_64)
qemu_opts += \ qemu_opts += \
@ -120,6 +121,8 @@ qemu_opts += \
-machine accel=kvm -machine accel=kvm
qemu_net_opts += \ qemu_net_opts += \
-device vfio-pci,host=$(pci_passthru) -device vfio-pci,host=$(pci_passthru)
qemu_ui_opts += \
-vga std
endif endif
ifeq ($(extra_nic), on) ifeq ($(extra_nic), on)
qemu_net_opts += \ qemu_net_opts += \
@ -138,6 +141,9 @@ qemu_opts += \
qemu_net_opts += \ qemu_net_opts += \
-netdev type=tap,id=net0,script=no,downscript=no \ -netdev type=tap,id=net0,script=no,downscript=no \
-device virtio-net-device,netdev=net0 -device virtio-net-device,netdev=net0
qemu_ui_opts += \
-device virtio-gpu-device \
-device virtio-mouse-device
else ifeq ($(arch), riscv64) else ifeq ($(arch), riscv64)
ifeq ($(board), u540) ifeq ($(board), u540)
@ -158,6 +164,9 @@ endif
qemu_net_opts += \ qemu_net_opts += \
-netdev type=tap,id=net0,script=no,downscript=no \ -netdev type=tap,id=net0,script=no,downscript=no \
-device virtio-net-device,netdev=net0 -device virtio-net-device,netdev=net0
qemu_ui_opts += \
-device virtio-gpu-device \
-device virtio-mouse-device
else ifeq ($(arch), aarch64) else ifeq ($(arch), aarch64)
qemu_opts += \ qemu_opts += \
@ -271,9 +280,7 @@ justrunnet: build
@sudo qemu-system-$(arch) $(qemu_opts) $(qemu_net_opts) @sudo qemu-system-$(arch) $(qemu_opts) $(qemu_net_opts)
justrunui: build justrunui: build
@qemu-system-$(arch) $(qemu_opts) \ @qemu-system-$(arch) $(qemu_opts) $(qemu_ui_opts)
-device virtio-gpu-device \
-device virtio-mouse-device
justruntest: build justruntest: build
@qemu-system-$(arch) $(filter-out -serial mon:stdio, $(qemu_opts)) --append $(init) -serial file:../tests/stdout -monitor null @qemu-system-$(arch) $(filter-out -serial mon:stdio, $(qemu_opts)) --append $(init) -serial file:../tests/stdout -monitor null

@ -1,8 +1,9 @@
#[path = "../../../drivers/gpu/fb.rs"] #[path = "../../../drivers/gpu/fb.rs"]
pub mod fb; pub mod fb;
use fb::{ColorConfig, FramebufferInfo, FramebufferResult, FRAME_BUFFER};
use crate::consts::KERNEL_OFFSET; use crate::consts::KERNEL_OFFSET;
use crate::memory::phys_to_virt;
use fb::{ColorConfig, FramebufferInfo, FramebufferResult, FRAME_BUFFER};
pub fn init_driver() { pub fn init_driver() {
#[cfg(not(feature = "nographic"))] #[cfg(not(feature = "nographic"))]
@ -22,5 +23,9 @@ pub fn probe_fb_info(width : u32, height : u32, depth : u32) -> FramebufferResul
bus_addr: 0xfd00_0000, bus_addr: 0xfd00_0000,
screen_size: 1024 * 768 * 3, 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 super::driver::serial::*;
use core::fmt::{Arguments, Write}; use core::fmt::{Arguments, Write};
use super::driver::console::CONSOLE;
pub fn getchar() -> char { pub fn getchar() -> char {
unsafe { unsafe {

@ -2,6 +2,7 @@ use bootloader::bootinfo::{BootInfo, MemoryRegionType};
use core::sync::atomic::*; use core::sync::atomic::*;
use log::*; use log::*;
pub mod board;
pub mod consts; pub mod consts;
pub mod cpu; pub mod cpu;
pub mod driver; pub mod driver;
@ -15,8 +16,6 @@ pub mod paging;
pub mod rand; pub mod rand;
pub mod syscall; pub mod syscall;
pub mod timer; pub mod timer;
pub mod ipi;
pub mod board;
static AP_CAN_INIT: AtomicBool = AtomicBool::new(false); static AP_CAN_INIT: AtomicBool = AtomicBool::new(false);

@ -73,11 +73,11 @@ impl Write for SerialPort {
self.putchar(8); self.putchar(8);
self.putchar(b' '); self.putchar(b' ');
self.putchar(8); self.putchar(8);
}, }
b'\n' => { b'\n' => {
self.putchar(b'\r'); self.putchar(b'\r');
self.putchar(b'\n'); self.putchar(b'\n');
}, }
c => { c => {
self.putchar(c); self.putchar(c);
} }

@ -64,11 +64,11 @@ impl Write for SerialPort {
self.putchar(8); self.putchar(8);
self.putchar(b' '); self.putchar(b' ');
self.putchar(8); self.putchar(8);
}, }
b'\n' => { b'\n' => {
self.putchar(b'\r'); self.putchar(b'\r');
self.putchar(b'\n'); self.putchar(b'\n');
}, }
c => { c => {
self.putchar(c); self.putchar(c);
} }

@ -73,11 +73,11 @@ impl Write for SerialPort {
self.putchar(8); self.putchar(8);
self.putchar(b' '); self.putchar(b' ');
self.putchar(8); self.putchar(8);
}, }
b'\n' => { b'\n' => {
self.putchar(b'\r'); self.putchar(b'\r');
self.putchar(b'\n'); self.putchar(b'\n');
}, }
c => { c => {
self.putchar(c); self.putchar(c);
} }

@ -50,7 +50,8 @@ impl FileHandle {
return Err(FsError::InvalidParam); // FIXME: => EBADF return Err(FsError::InvalidParam); // FIXME: => EBADF
} }
let mut len: usize = 0; let mut len: usize = 0;
if !self.options.nonblock { // block if !self.options.nonblock {
// block
loop { loop {
len = self.inode.read_at(offset, buf)?; len = self.inode.read_at(offset, buf)?;
if len > 0 { if len > 0 {

@ -1,8 +1,9 @@
use rcore_fs::vfs::*; 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 alloc::{string::String, sync::Arc, vec::Vec};
use core::any::Any; use core::any::Any;
use crate::arch::board::fb::FRAME_BUFFER;
#[derive(Default)] #[derive(Default)]
pub struct Vga; pub struct Vga;
@ -31,15 +32,19 @@ 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 crate::consts::KERNEL_OFFSET;
use core::slice; use core::slice;
let frame_buffer_data = let frame_buffer_data = unsafe {
unsafe { slice::from_raw_parts_mut((KERNEL_OFFSET + 0xf000_0000) as *mut u8, ( 1024 * 768 * 3) as usize) }; 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); frame_buffer_data.copy_from_slice(&_buf);
return Ok(1024 * 768 * 3); return Ok(1024 * 768 * 3);
} }
fn poll(&self) -> Result<PollStatus> { fn poll(&self) -> Result<PollStatus> {
Ok(PollStatus { // TOKNOW and TODO Ok(PollStatus {
// TOKNOW and TODO
read: true, read: true,
write: false, write: false,
error: false, error: false,

@ -837,10 +837,7 @@ impl Syscall<'_> {
} }
pub fn sys_fcntl(&mut self, fd: usize, cmd: usize, arg: usize) -> SysResult { pub fn sys_fcntl(&mut self, fd: usize, cmd: usize, arg: usize) -> SysResult {
info!( info!("fcntl: fd: {}, cmd: {:x}, arg: {}", fd, cmd, arg);
"fcntl: fd: {}, cmd: {:x}, arg: {}",
fd, cmd, arg
);
let mut proc = self.process(); let mut proc = self.process();
let file_like = proc.get_file_like(fd)?; let file_like = proc.get_file_like(fd)?;
file_like.fcntl(cmd, arg) file_like.fcntl(cmd, arg)
@ -888,11 +885,11 @@ impl Process {
match path { match path {
"/proc/self/exe" => { "/proc/self/exe" => {
return Ok(Arc::new(Pseudo::new(&self.exec_path, FileType::SymLink))); return Ok(Arc::new(Pseudo::new(&self.exec_path, FileType::SymLink)));
}, }
"/dev/fb0" => { "/dev/fb0" => {
info!("/dev/fb0 will be opened"); info!("/dev/fb0 will be opened");
return Ok(Arc::new(Vga::default())); return Ok(Arc::new(Vga::default()));
}, }
_ => {} _ => {}
} }
let (fd_dir_path, fd_name) = split_path(&path); let (fd_dir_path, fd_name) = split_path(&path);

@ -51,7 +51,6 @@ impl Syscall<'_> {
); );
return Ok(addr); return Ok(addr);
} else { } else {
let file = proc.get_file(fd)?; let file = proc.get_file(fd)?;
info!("mmap path is {} ", &*file.path); info!("mmap path is {} ", &*file.path);
match &*file.path { match &*file.path {
@ -62,15 +61,15 @@ impl Syscall<'_> {
addr, addr,
addr + len, addr + len,
prot.to_attr(), prot.to_attr(),
Linear::new( Linear::new((fb.bus_addr() - addr) as isize),
( fb.bus_addr() - addr ) as isize,
),
"mmap_file", "mmap_file",
); );
info!("mmap for /dev/fb0"); info!("mmap for /dev/fb0");
}
return Ok(addr); return Ok(addr);
}, } else {
return Err(SysError::ENOENT);
}
}
_ => { _ => {
let inode = file.inode(); let inode = file.inode();
self.vm().push( self.vm().push(
@ -87,7 +86,7 @@ impl Syscall<'_> {
"mmap_file", "mmap_file",
); );
return Ok(addr); return Ok(addr);
}, }
}; };
} }
} }

@ -102,9 +102,12 @@ impl Syscall<'_> {
SYS_WRITEV => self.sys_writev(args[0], args[1] as *const IoVec, args[2]), 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_SENDFILE => self.sys_sendfile(args[0], args[1], args[2] as *mut usize, args[3]),
SYS_FCNTL => { 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]) self.sys_fcntl(args[0], args[1], args[2])
}, }
SYS_FLOCK => self.unimplemented("flock", Ok(0)), SYS_FLOCK => self.unimplemented("flock", Ok(0)),
SYS_FSYNC => self.sys_fsync(args[0]), SYS_FSYNC => self.sys_fsync(args[0]),
SYS_FDATASYNC => self.sys_fdatasync(args[0]), SYS_FDATASYNC => self.sys_fdatasync(args[0]),
@ -292,7 +295,7 @@ impl Syscall<'_> {
), ),
SYS_GETRANDOM => { SYS_GETRANDOM => {
self.sys_getrandom(args[0] as *mut u8, args[1] as usize, args[2] as u32) 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)), SYS_RT_SIGQUEUEINFO => self.unimplemented("rt_sigqueueinfo", Ok(0)),
// custom // custom

Loading…
Cancel
Save