aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Li <li.davidm96@gmail.com>2016-01-09 15:35:32 -0700
committerDavid Li <li.davidm96@gmail.com>2016-01-09 15:35:32 -0700
commitc17e1ab26f4d6cdb6064241c85ff84029b3e0747 (patch)
tree60570ab85b1b627faddf4741474225b0c72cf3a9 /src
parentb85e63bc767bb382de64f54504151abbca6efeff (diff)
Add secondary cache syscalls
Diffstat (limited to 'src')
-rw-r--r--src/system.rs35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/system.rs b/src/system.rs
index faadb13..b8b928e 100644
--- a/src/system.rs
+++ b/src/system.rs
@@ -1,4 +1,6 @@
use std;
+use std::cell::RefCell;
+use std::rc::Rc;
use rustv::isa;
use rustv::memory::SharedMemory;
@@ -6,20 +8,27 @@ use rustv::register_file::RegisterFile;
use rustv::syscall;
use rustv::trap::Trap;
+use shareable_cache::ShareableCache;
+
pub struct SyscallHandler<'a> {
memory: SharedMemory<'a>,
+ caches: Vec<Rc<RefCell<ShareableCache<'a>>>>,
}
impl<'a> SyscallHandler<'a> {
- pub fn new(memory: SharedMemory<'a>) -> SyscallHandler<'a> {
+ pub fn new(memory: SharedMemory<'a>,
+ caches: Vec<Rc<RefCell<ShareableCache<'a>>>>)
+ -> SyscallHandler<'a> {
SyscallHandler {
- memory: memory
+ memory: memory,
+ caches: caches,
}
}
}
impl<'a> SyscallHandler<'a> {
- fn print(&mut self, registers: &mut RegisterFile) -> Option<Trap> {
+ fn print(&mut self, core_id: usize,
+ registers: &mut RegisterFile) -> Option<Trap> {
let mut base = registers.read_word(isa::Register::X11);
let mut string = vec![];
@@ -44,19 +53,31 @@ impl<'a> SyscallHandler<'a> {
println!("Error printing string: not valid UTF-8: {:?}", result);
}
None
+ }
+ fn enable_secondary(&mut self, core_id: usize,
+ registers: &mut RegisterFile) -> Option<Trap> {
+ self.caches[core_id].borrow_mut().enable_secondary();
+ None
+ }
+
+ fn disable_secondary(&mut self, core_id: usize,
+ registers: &mut RegisterFile) -> Option<Trap> {
+ self.caches[core_id].borrow_mut().disable_secondary();
+ None
}
}
impl<'a> syscall::SyscallHandler for SyscallHandler<'a> {
// TODO: is trap really appropriate here?
- fn syscall(&mut self, registers: &mut RegisterFile) -> Option<Trap> {
+ fn syscall(&mut self, core_id: usize,
+ registers: &mut RegisterFile) -> Option<Trap> {
let syscall_number = registers.read_word(isa::Register::X10);
match syscall_number {
- 22 => {
- self.print(registers)
- }
+ 22 => self.print(core_id, registers),
+ 23 => self.enable_secondary(core_id, registers),
+ 24 => self.disable_secondary(core_id, registers),
_ => {
// TODO: some sort of error reporting