mirror of
https://github.com/sgmarz/osblog.git
synced 2024-11-27 11:53:32 +04:00
Remove testing code, change comments
This commit is contained in:
parent
40977c2e45
commit
d6bf3d2685
@ -146,49 +146,8 @@ extern "C" fn kinit() {
|
|||||||
}
|
}
|
||||||
// Set up virtio. This requires a working heap and page-grained allocator.
|
// Set up virtio. This requires a working heap and page-grained allocator.
|
||||||
virtio::probe();
|
virtio::probe();
|
||||||
// This just tests the block device. We know that it connects backwards (8, 7, ..., 1).
|
|
||||||
let buffer = kmem::kmalloc(1024);
|
|
||||||
// Offset 1024 is the first block, which is the superblock. In the minix 3 file system, the first
|
|
||||||
// block is the "boot block", which in our case will be 0.
|
|
||||||
block::read(8, buffer, 512, 1024);
|
|
||||||
let mut i = 0;
|
|
||||||
loop {
|
|
||||||
if i > 100_000_000 {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i += 1;
|
|
||||||
}
|
|
||||||
println!("Test hdd.dsk:");
|
|
||||||
unsafe {
|
|
||||||
print!(" ");
|
|
||||||
for i in 0..16 {
|
|
||||||
print!("{:02x} ", buffer.add(i).read());
|
|
||||||
}
|
|
||||||
println!();
|
|
||||||
print!(" ");
|
|
||||||
for i in 0..16 {
|
|
||||||
print!("{:02x} ", buffer.add(16+i).read());
|
|
||||||
}
|
|
||||||
println!();
|
|
||||||
print!(" ");
|
|
||||||
for i in 0..16 {
|
|
||||||
print!("{:02x} ", buffer.add(32+i).read());
|
|
||||||
}
|
|
||||||
println!();
|
|
||||||
print!(" ");
|
|
||||||
for i in 0..16 {
|
|
||||||
print!("{:02x} ", buffer.add(48+i).read());
|
|
||||||
}
|
|
||||||
println!();
|
|
||||||
buffer.add(0).write(0xaa);
|
|
||||||
buffer.add(1).write(0xbb);
|
|
||||||
buffer.add(2).write(0x7a);
|
|
||||||
|
|
||||||
}
|
|
||||||
block::write(8, buffer, 512, 0);
|
|
||||||
// Free the testing buffer.
|
|
||||||
kmem::kfree(buffer);
|
|
||||||
// We schedule the next context switch using a multiplier of 1
|
// We schedule the next context switch using a multiplier of 1
|
||||||
|
// Block testing code removed.
|
||||||
trap::schedule_next_context_switch(1);
|
trap::schedule_next_context_switch(1);
|
||||||
rust_switch_to_user(sched::schedule());
|
rust_switch_to_user(sched::schedule());
|
||||||
// switch_to_user will not return, so we should never get here
|
// switch_to_user will not return, so we should never get here
|
||||||
|
@ -151,9 +151,8 @@ pub fn handle_interrupt() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
// Non-UART interrupts go here and do nothing.
|
|
||||||
_ => {
|
_ => {
|
||||||
println!("Non-UART external interrupt: {}", interrupt);
|
println!("Unknown external interrupt: {}", interrupt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// We've claimed it, so now say that we've handled it. This resets the interrupt pending
|
// We've claimed it, so now say that we've handled it. This resets the interrupt pending
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
// Stephen Marz
|
// Stephen Marz
|
||||||
// 10 October 2019
|
// 10 October 2019
|
||||||
|
|
||||||
use crate::cpu::{CONTEXT_SWITCH_TIME, TrapFrame};
|
use crate::{cpu::{TrapFrame, CONTEXT_SWITCH_TIME},
|
||||||
use crate::plic;
|
plic,
|
||||||
use crate::syscall::do_syscall;
|
rust_switch_to_user,
|
||||||
use crate::sched::schedule;
|
sched::schedule,
|
||||||
use crate::rust_switch_to_user;
|
syscall::do_syscall};
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
/// The m_trap stands for "machine trap". Right now, we are handling
|
/// The m_trap stands for "machine trap". Right now, we are handling
|
||||||
@ -65,7 +65,7 @@ extern "C" fn m_trap(epc: usize,
|
|||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
panic!("Unhandled async trap CPU#{} -> {}\n", hart, cause_num);
|
panic!("Unhandled async trap CPU#{} -> {}\n", hart, cause_num);
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -118,7 +118,7 @@ extern "C" fn m_trap(epc: usize,
|
|||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
panic!("Unhandled sync trap CPU#{} -> {}\n", hart, cause_num);
|
panic!("Unhandled sync trap CPU#{} -> {}\n", hart, cause_num);
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// Finally, return the updated program counter
|
// Finally, return the updated program counter
|
||||||
@ -129,8 +129,6 @@ pub const MMIO_MTIMECMP: *mut u64 = 0x0200_4000usize as *mut u64;
|
|||||||
pub const MMIO_MTIME: *const u64 = 0x0200_BFF8 as *const u64;
|
pub const MMIO_MTIME: *const u64 = 0x0200_BFF8 as *const u64;
|
||||||
|
|
||||||
pub fn schedule_next_context_switch(qm: u16) {
|
pub fn schedule_next_context_switch(qm: u16) {
|
||||||
// This is much too slow for normal operations, but it gives us
|
|
||||||
// a visual of what's happening behind the scenes.
|
|
||||||
unsafe {
|
unsafe {
|
||||||
MMIO_MTIMECMP.write_volatile(MMIO_MTIME.read_volatile().wrapping_add(CONTEXT_SWITCH_TIME * qm as u64));
|
MMIO_MTIMECMP.write_volatile(MMIO_MTIME.read_volatile().wrapping_add(CONTEXT_SWITCH_TIME * qm as u64));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user