Add graphic=console option and fix vga on x86_64

master
Jiajie Chen 6 years ago
parent e22cfd9b30
commit e9c0bcadf7

6
kernel/Cargo.lock generated

@ -88,7 +88,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "bootloader" name = "bootloader"
version = "0.4.0" version = "0.4.0"
source = "git+https://github.com/rcore-os/bootloader?branch=linear#a535573bf83d5b916b5424a6b64e85e9197db40b" source = "git+https://github.com/rcore-os/bootloader?branch=vga#472731f974eb9cddbee030d5bda11fd1ee6959db"
dependencies = [ dependencies = [
"apic 0.1.0 (git+https://github.com/rcore-os/apic-rs)", "apic 0.1.0 (git+https://github.com/rcore-os/apic-rs)",
"fixedvec 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "fixedvec 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -378,7 +378,7 @@ dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"bitmap-allocator 0.1.0 (git+https://github.com/rcore-os/bitmap-allocator)", "bitmap-allocator 0.1.0 (git+https://github.com/rcore-os/bitmap-allocator)",
"bitvec 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "bitvec 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bootloader 0.4.0 (git+https://github.com/rcore-os/bootloader?branch=linear)", "bootloader 0.4.0 (git+https://github.com/rcore-os/bootloader?branch=vga)",
"buddy_system_allocator 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "buddy_system_allocator 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)",
"console-traits 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "console-traits 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -693,7 +693,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum bitmap-allocator 0.1.0 (git+https://github.com/rcore-os/bitmap-allocator)" = "<none>" "checksum bitmap-allocator 0.1.0 (git+https://github.com/rcore-os/bitmap-allocator)" = "<none>"
"checksum bitvec 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c28d4291b516ccfbb897d45de3c468c135e6af7c4f1f1aacfaae0a5bc2e6ea2c" "checksum bitvec 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c28d4291b516ccfbb897d45de3c468c135e6af7c4f1f1aacfaae0a5bc2e6ea2c"
"checksum bitvec 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cfadef5c4e2c2e64067b9ecc061179f12ac7ec65ba613b1f60f3972bbada1f5b" "checksum bitvec 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cfadef5c4e2c2e64067b9ecc061179f12ac7ec65ba613b1f60f3972bbada1f5b"
"checksum bootloader 0.4.0 (git+https://github.com/rcore-os/bootloader?branch=linear)" = "<none>" "checksum bootloader 0.4.0 (git+https://github.com/rcore-os/bootloader?branch=vga)" = "<none>"
"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"

@ -25,6 +25,7 @@ board_k210 = ["link_user"]
board_rocket_chip = ["link_user"] board_rocket_chip = ["link_user"]
# (for aarch64 RaspberryPi3) # (for aarch64 RaspberryPi3)
nographic = [] nographic = []
consolegraphic = []
board_raspi3 = ["bcm2837", "link_user"] board_raspi3 = ["bcm2837", "link_user"]
raspi3_use_generic_timer = ["bcm2837/use_generic_timer"] raspi3_use_generic_timer = ["bcm2837/use_generic_timer"]
# for qemu machine # for qemu machine
@ -68,7 +69,7 @@ rcore-fs = { git = "https://github.com/rcore-os/rcore-fs" }
rcore-fs-sfs = { git = "https://github.com/rcore-os/rcore-fs" } rcore-fs-sfs = { git = "https://github.com/rcore-os/rcore-fs" }
[target.'cfg(target_arch = "x86_64")'.dependencies] [target.'cfg(target_arch = "x86_64")'.dependencies]
bootloader = { git = "https://github.com/rcore-os/bootloader", branch = "linear" } bootloader = { git = "https://github.com/rcore-os/bootloader", branch = "vga" }
apic = { git = "https://github.com/rcore-os/apic-rs" } apic = { git = "https://github.com/rcore-os/apic-rs" }
x86_64 = "0.6" x86_64 = "0.6"
raw-cpuid = "6.0" raw-cpuid = "6.0"

@ -21,7 +21,7 @@
# LOG = off | error | warn | info | debug | trace # LOG = off | error | warn | info | debug | trace
# SFSIMG = <sfsimg> SFS image path of user programs # SFSIMG = <sfsimg> SFS image path of user programs
# smp = 1 | 2 | ... SMP core number # smp = 1 | 2 | ... SMP core number
# graphic = on | off Enable/disable qemu graphical output # graphic = on | off | console Enable/disable qemu graphical output, or print console to graphic output
# board = none Running on QEMU # board = none Running on QEMU
# | pc Only available on x86_64, run on real pc # | pc Only available on x86_64, run on real pc
# | u540 Only available on riscv64, run on HiFive U540, use Sv39 # | u540 Only available on riscv64, run on HiFive U540, use Sv39
@ -202,10 +202,14 @@ qemu_opts += -nographic
endif endif
### build args ### ### build args ###
ifneq ($(graphic), on) ifeq ($(graphic), off)
features += nographic features += nographic
endif endif
ifeq ($(graphic), console)
features += consolegraphic
endif
ifneq ($(init), ) ifneq ($(init), )
features += run_cmdline features += run_cmdline
endif endif

@ -10,23 +10,19 @@ pub fn getchar() -> char {
} }
pub fn putfmt(fmt: Arguments) { pub fn putfmt(fmt: Arguments) {
#[cfg(feature = "nographic")] // print to console
{
unsafe { unsafe {
COM1.force_unlock(); COM1.force_unlock();
} }
COM1.lock().write_fmt(fmt).unwrap(); COM1.lock().write_fmt(fmt).unwrap();
}
#[cfg(not(feature = "nographic"))] // print to graphic
#[cfg(feature = "consolegraphic")]
{ {
use super::driver::vga::VGA_WRITER; use super::driver::vga::VGA_WRITER;
unsafe { unsafe { CONSOLE.force_unlock() }
COM1.force_unlock(); if let Some(console) = CONSOLE.lock().as_mut() {
console.write_fmt(fmt).unwrap();
} }
COM1.lock().write_fmt(fmt).unwrap();
//unsafe { CONSOLE.force_unlock() }
//if let Some(console) = CONSOLE.lock().as_mut() {
//console.write_fmt(fmt).unwrap();
//}
} }
} }

@ -157,8 +157,9 @@ pub fn init_driver(dev: &PCIDevice) {
); );
} }
} }
(0x8086, 0x2922) | (0x8086, 0x8d02) => { (0x8086, 0x2922) | (0x8086, 0xa282) | (0x8086, 0x8d02) => {
// 82801IR/IO/IH (ICH9R/DO/DH) 6 port SATA Controller [AHCI mode] // 82801IR/IO/IH (ICH9R/DO/DH) 6 port SATA Controller [AHCI mode]
// 200 Series PCH SATA controller [AHCI mode]
// C610/X99 series chipset 6-Port SATA Controller [AHCI mode] // C610/X99 series chipset 6-Port SATA Controller [AHCI mode]
if let Some(BAR::Memory(addr, len, _, _)) = dev.bars[5] { if let Some(BAR::Memory(addr, len, _, _)) = dev.bars[5] {
let irq = unsafe { enable(dev.loc) }; let irq = unsafe { enable(dev.loc) };

@ -50,6 +50,7 @@ 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 { if !self.options.nonblock {
// block // block
loop { loop {
@ -61,6 +62,9 @@ impl FileHandle {
} else { } else {
len = self.inode.read_at(offset, buf)?; len = self.inode.read_at(offset, buf)?;
} }
*/
// TODO: handle block/nonblock correctly
len = self.inode.read_at(offset, buf)?;
Ok(len) Ok(len)
} }

Loading…
Cancel
Save