x86_64 back to normal.

* Fix kernel stack P4E
* User programs: disk0 -> disk1
* IDE IRQ appears ??
master
WangRunji 6 years ago
parent 7f00001fd1
commit 7a9b746c68

6
kernel/Cargo.lock generated

@ -42,7 +42,7 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.23" version = "1.0.25"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
@ -215,7 +215,7 @@ dependencies = [
"bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"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)",
"bootloader 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "bootloader 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cc 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"linked_list_allocator 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "linked_list_allocator 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
@ -318,7 +318,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed8765909f9009617974ab6b7d332625b320b33c326b1e9321382ef1999b5d56" "checksum bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed8765909f9009617974ab6b7d332625b320b33c326b1e9321382ef1999b5d56"
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
"checksum bootloader 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f1721ced9efc102309bc218c7934d642f60567858faf8d5dd90c0cc6722d97b9" "checksum bootloader 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f1721ced9efc102309bc218c7934d642f60567858faf8d5dd90c0cc6722d97b9"
"checksum cc 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)" = "c37f0efaa4b9b001fa6f02d4b644dee4af97d3414df07c51e3e4f015f3a3e131" "checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16"
"checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3" "checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3"
"checksum fixedvec 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7c6c16d316ccdac21a4dd648e314e76facbbaf316e83ca137d0857a9c07419d0" "checksum fixedvec 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7c6c16d316ccdac21a4dd648e314e76facbbaf316e83ca137d0857a9c07419d0"
"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"

@ -43,13 +43,16 @@ bbl = { path = "../crate/bbl" }
[package.metadata.bootimage] [package.metadata.bootimage]
default-target = "x86_64-blog_os.json" default-target = "x86_64-blog_os.json"
output = "bootimage.bin" # The output file name output = "target/x86_64-blog_os/bootimage.bin"
minimum-image-size = 0 # The minimum output file size (in MiB) minimum-image-size = 0 # The minimum output file size (in MiB)
# The command invoked on `bootimage run` # The command invoked on `bootimage run`
# (the "{}" will be replaced with the path to the bootable disk image) # (the "{}" will be replaced with the path to the bootable disk image)
run-command = ["qemu-system-x86_64", run-command = ["qemu-system-x86_64",
"-drive", "format=raw,file={}", "-drive", "format=raw,file={}",
"-serial", "mon:stdio" "-drive", "format=raw,file=../user/ucore32.img,media=disk,cache=writeback",
"-serial", "mon:stdio",
"-device", "isa-debug-exit",
"-smp", "4"
] ]
[build-dependencies] [build-dependencies]

@ -6,6 +6,7 @@ use spin::Mutex;
lazy_static! { lazy_static! {
pub static ref DISK0: LockedIde = LockedIde(Mutex::new(DmaController::new(0))); pub static ref DISK0: LockedIde = LockedIde(Mutex::new(DmaController::new(0)));
pub static ref DISK1: LockedIde = LockedIde(Mutex::new(DmaController::new(1)));
} }
pub const BLOCK_SIZE: usize = 512; pub const BLOCK_SIZE: usize = 512;

@ -85,7 +85,8 @@ pub extern fn rust_trap(tf: &mut TrapFrame) {
IRQ_KBD => keyboard(), IRQ_KBD => keyboard(),
IRQ_COM1 => com1(), IRQ_COM1 => com1(),
IRQ_COM2 => com2(), IRQ_COM2 => com2(),
_ => panic!("Invalid IRQ number."), IRQ_IDE => ide(),
_ => panic!("Invalid IRQ number: {}", irq),
} }
#[cfg(feature = "use_apic")] #[cfg(feature = "use_apic")]
use arch::driver::apic::ack; use arch::driver::apic::ack;
@ -143,6 +144,10 @@ fn com2() {
COM2.lock().receive(); COM2.lock().receive();
} }
fn ide() {
trace!("\nInterupt: IDE");
}
fn to_user(tf: &mut TrapFrame) { fn to_user(tf: &mut TrapFrame) {
use arch::gdt; use arch::gdt;
info!("\nInterupt: To User"); info!("\nInterupt: To User");

@ -231,11 +231,13 @@ impl InactivePageTable for InactivePageTable0 {
impl InactivePageTable0 { impl InactivePageTable0 {
fn map_kernel(&mut self) { fn map_kernel(&mut self) {
let mut table = unsafe { &mut *(0xffffffff_fffff000 as *mut x86PageTable) }; let mut table = unsafe { &mut *(0xffffffff_fffff000 as *mut x86PageTable) };
// Kernel at 0xffff_ff00_0000_0000
// Kernel stack at 0x0000_57ac_0000_0000 (defined in bootloader crate)
let e510 = table[510].clone(); let e510 = table[510].clone();
let e509 = table[509].clone(); let estack = table[175].clone();
self.edit(|_| { self.edit(|_| {
table[510].set_addr(e510.addr(), e510.flags() | EF::GLOBAL); table[510].set_addr(e510.addr(), e510.flags() | EF::GLOBAL);
table[509].set_addr(e509.addr(), e509.flags() | EF::GLOBAL); table[175].set_addr(estack.addr(), estack.flags() | EF::GLOBAL);
}); });
} }
} }

@ -24,8 +24,8 @@ pub fn shell() {
Box::new(unsafe { MemBuf::new(_binary_user_riscv_img_start, _binary_user_riscv_img_end) }) Box::new(unsafe { MemBuf::new(_binary_user_riscv_img_start, _binary_user_riscv_img_end) })
}; };
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
let device = Box::new(&ide::DISK0); let device = Box::new(&ide::DISK1);
let sfs = SimpleFileSystem::open(device).unwrap(); let sfs = SimpleFileSystem::open(device).expect("failed to open SFS");
let root = sfs.root_inode(); let root = sfs.root_inode();
let files = root.borrow().list().unwrap(); let files = root.borrow().list().unwrap();
println!("Available programs: {:?}", files); println!("Available programs: {:?}", files);
@ -79,7 +79,7 @@ impl Device for MemBuf {
use core::slice; use core::slice;
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
impl BlockedDevice for &'static ide::DISK0 { impl BlockedDevice for &'static ide::DISK1 {
const BLOCK_SIZE_LOG2: u8 = 9; const BLOCK_SIZE_LOG2: u8 = 9;
fn read_at(&mut self, block_id: usize, buf: &mut [u8]) -> bool { fn read_at(&mut self, block_id: usize, buf: &mut [u8]) -> bool {
assert!(buf.len() >= ide::BLOCK_SIZE); assert!(buf.len() >= ide::BLOCK_SIZE);

Loading…
Cancel
Save