BurritOS now read configuration file
This commit is contained in:
parent
1c4c51b0ba
commit
73ac8d3083
@ -344,10 +344,11 @@ mod test {
|
|||||||
use crate::kernel::exception::{SC_SHUTDOWN, SC_WRITE};
|
use crate::kernel::exception::{SC_SHUTDOWN, SC_WRITE};
|
||||||
use crate::kernel::system::System;
|
use crate::kernel::system::System;
|
||||||
use crate::simulator::machine::Machine;
|
use crate::simulator::machine::Machine;
|
||||||
|
use crate::utility::cfg::get_debug_configuration;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_sc_shutdown() {
|
fn test_sc_shutdown() {
|
||||||
let mut machine = Machine::new(true);
|
let mut machine = Machine::new(true, get_debug_configuration());
|
||||||
machine.write_int_register(17, SC_SHUTDOWN as i64); // Set type to shutdown
|
machine.write_int_register(17, SC_SHUTDOWN as i64); // Set type to shutdown
|
||||||
// let ecall = Instruction::new(0b000000000000_00000_000_00000_1110011);
|
// let ecall = Instruction::new(0b000000000000_00000_000_00000_1110011);
|
||||||
|
|
||||||
@ -363,7 +364,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
#[ignore]
|
#[ignore]
|
||||||
fn test_sc_print() {
|
fn test_sc_print() {
|
||||||
let mut machine = Machine::new(true);
|
let mut machine = Machine::new(true, get_debug_configuration());
|
||||||
|
|
||||||
let _address = machine.read_int_register(10);
|
let _address = machine.read_int_register(10);
|
||||||
// Write string 'HELLO' in memory
|
// Write string 'HELLO' in memory
|
||||||
|
@ -227,13 +227,13 @@ impl Condition {
|
|||||||
mod test {
|
mod test {
|
||||||
use std::{rc::Rc, cell::RefCell};
|
use std::{rc::Rc, cell::RefCell};
|
||||||
|
|
||||||
use crate::{kernel::{thread::Thread, synch::Lock, thread_manager::ThreadManager}, simulator::machine::Machine};
|
use crate::{kernel::{thread::Thread, synch::Lock, thread_manager::ThreadManager}, simulator::machine::Machine, utility::cfg::get_debug_configuration};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_lock_simple() {
|
fn test_lock_simple() {
|
||||||
let mut machine = Machine::new(true);
|
let mut machine = Machine::new(true, get_debug_configuration());
|
||||||
let mut tm = ThreadManager::new(true);
|
let mut tm = ThreadManager::new(true);
|
||||||
let thread = Rc::new(RefCell::new(Thread::new("test_lock")));
|
let thread = Rc::new(RefCell::new(Thread::new("test_lock")));
|
||||||
tm.ready_to_run(Rc::clone(&thread));
|
tm.ready_to_run(Rc::clone(&thread));
|
||||||
@ -255,7 +255,7 @@ mod test {
|
|||||||
let thread1 = Rc::new(RefCell::new(Thread::new("test_lock1")));
|
let thread1 = Rc::new(RefCell::new(Thread::new("test_lock1")));
|
||||||
let thread2 = Rc::new(RefCell::new(Thread::new("test_lock2")));
|
let thread2 = Rc::new(RefCell::new(Thread::new("test_lock2")));
|
||||||
|
|
||||||
let mut machine = Machine::new(true);
|
let mut machine = Machine::new(true, get_debug_configuration());
|
||||||
let mut tm = ThreadManager::new(true);
|
let mut tm = ThreadManager::new(true);
|
||||||
|
|
||||||
tm.ready_to_run(Rc::clone(&thread1));
|
tm.ready_to_run(Rc::clone(&thread1));
|
||||||
|
@ -371,12 +371,12 @@ impl ThreadManager {
|
|||||||
mod test {
|
mod test {
|
||||||
use std::{rc::Rc, cell::RefCell};
|
use std::{rc::Rc, cell::RefCell};
|
||||||
|
|
||||||
use crate::{simulator::{machine::Machine, loader}, kernel::{system::System, thread::Thread, process::Process, thread_manager::ThreadManager, synch::Semaphore}};
|
use crate::{simulator::{machine::Machine, loader}, kernel::{system::System, thread::Thread, process::Process, thread_manager::ThreadManager, synch::Semaphore}, utility::cfg::get_debug_configuration};
|
||||||
use crate::kernel::synch::Lock;
|
use crate::kernel::synch::Lock;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_thread_context() {
|
fn test_thread_context() {
|
||||||
let mut machine = Machine::new(true);
|
let mut machine = Machine::new(true, get_debug_configuration());
|
||||||
|
|
||||||
let (loader, ptr) = loader::Loader::new("./target/guac/halt.guac", &mut machine, 0).expect("IO Error");
|
let (loader, ptr) = loader::Loader::new("./target/guac/halt.guac", &mut machine, 0).expect("IO Error");
|
||||||
let start_pc = loader.elf_header.entrypoint;
|
let start_pc = loader.elf_header.entrypoint;
|
||||||
@ -404,7 +404,7 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_lock(){
|
fn test_lock(){
|
||||||
let mut machine = Machine::new(true);
|
let mut machine = Machine::new(true, get_debug_configuration());
|
||||||
let mut thread_manager = ThreadManager::new(true);
|
let mut thread_manager = ThreadManager::new(true);
|
||||||
let lock = Lock::new();
|
let lock = Lock::new();
|
||||||
let lock_id = thread_manager.get_obj_addrs().add_lock(lock);
|
let lock_id = thread_manager.get_obj_addrs().add_lock(lock);
|
||||||
@ -430,7 +430,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_semaphore_single() {
|
fn test_semaphore_single() {
|
||||||
// Init
|
// Init
|
||||||
let mut machine = Machine::new(true);
|
let mut machine = Machine::new(true, get_debug_configuration());
|
||||||
let mut thread_manager = ThreadManager::new(true);
|
let mut thread_manager = ThreadManager::new(true);
|
||||||
let semaphore = Semaphore::new(1);
|
let semaphore = Semaphore::new(1);
|
||||||
let sema_id = thread_manager.get_obj_addrs().add_semaphore(semaphore);
|
let sema_id = thread_manager.get_obj_addrs().add_semaphore(semaphore);
|
||||||
@ -457,7 +457,7 @@ mod test {
|
|||||||
fn test_semaphore_multiple() {
|
fn test_semaphore_multiple() {
|
||||||
// Init
|
// Init
|
||||||
let mut tm = ThreadManager::new(true);
|
let mut tm = ThreadManager::new(true);
|
||||||
let mut machine = Machine::new(true);
|
let mut machine = Machine::new(true, get_debug_configuration());
|
||||||
let semaphore = Semaphore::new(2);
|
let semaphore = Semaphore::new(2);
|
||||||
let sema_id = tm.get_obj_addrs().add_semaphore(semaphore);
|
let sema_id = tm.get_obj_addrs().add_semaphore(semaphore);
|
||||||
let thread1 = Rc::new(RefCell::new(Thread::new("test_semaphore_1")));
|
let thread1 = Rc::new(RefCell::new(Thread::new("test_semaphore_1")));
|
||||||
|
@ -20,6 +20,7 @@ use simulator::{machine::Machine, loader};
|
|||||||
|
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
use utility::cfg::{get_debug_configuration, read_settings};
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(name = "BurritOS", author, version, about = "Burritos (BurritOS Using Rust Really Improves The Operating System)
|
#[command(name = "BurritOS", author, version, about = "Burritos (BurritOS Using Rust Really Improves The Operating System)
|
||||||
@ -39,7 +40,7 @@ struct Args {
|
|||||||
fn main() {
|
fn main() {
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
|
||||||
let mut machine = Machine::new(args.debug);
|
let mut machine = Machine::new(args.debug, read_settings().unwrap());
|
||||||
let (loader, ptr) = loader::Loader::new(args.executable.as_str(), &mut machine, 0).expect("An error occured while parsing the program");
|
let (loader, ptr) = loader::Loader::new(args.executable.as_str(), &mut machine, 0).expect("An error occured while parsing the program");
|
||||||
|
|
||||||
let mut system = System::new(args.debug);
|
let mut system = System::new(args.debug);
|
||||||
|
@ -584,12 +584,12 @@ fn get_address_point(instructions: &[u8], address: usize, is_32bits: bool) -> Op
|
|||||||
/// It may not pass in the future if future gcc version modify order of the binary or something else
|
/// It may not pass in the future if future gcc version modify order of the binary or something else
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::simulator::{loader::{Loader, SectionHeader}, machine::Machine};
|
use crate::{simulator::{loader::{Loader, SectionHeader}, machine::Machine}, utility::cfg::get_debug_configuration};
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_elf() {
|
fn test_parse_elf() {
|
||||||
let mut machine = Machine::new(true);
|
let mut machine = Machine::new(true, get_debug_configuration());
|
||||||
let loader = Loader::load_and_parse("./target/guac/unsigned_addition.guac").expect("IO Error");
|
let loader = Loader::load_and_parse("./target/guac/unsigned_addition.guac").expect("IO Error");
|
||||||
loader.load_into_machine(&mut machine, 0).expect("Parsing error");
|
loader.load_into_machine(&mut machine, 0).expect("Parsing error");
|
||||||
assert!(!loader.elf_header.is_32bits);
|
assert!(!loader.elf_header.is_32bits);
|
||||||
@ -610,7 +610,7 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_section() {
|
fn test_parse_section() {
|
||||||
let mut machine = Machine::new(true);
|
let mut machine = Machine::new(true, get_debug_configuration());
|
||||||
let loader = Loader::load_and_parse("./target/guac/unsigned_addition.guac").expect("IO Error");
|
let loader = Loader::load_and_parse("./target/guac/unsigned_addition.guac").expect("IO Error");
|
||||||
loader.load_into_machine(&mut machine, 0).expect("Parsing error");
|
loader.load_into_machine(&mut machine, 0).expect("Parsing error");
|
||||||
assert_eq!(9, loader.sections.len());
|
assert_eq!(9, loader.sections.len());
|
||||||
|
@ -21,7 +21,7 @@ use crate::{simulator::{
|
|||||||
interrupt::Interrupt,
|
interrupt::Interrupt,
|
||||||
global::*,
|
global::*,
|
||||||
register::*
|
register::*
|
||||||
}, kernel::system::System};
|
}, kernel::system::System, utility::cfg::{Settings, MachineSettingKey}};
|
||||||
|
|
||||||
use crate::kernel::{
|
use crate::kernel::{
|
||||||
exception
|
exception
|
||||||
@ -71,12 +71,6 @@ pub const STACK_REG: usize = 2;
|
|||||||
pub const NUM_INT_REGS: usize = 32;
|
pub const NUM_INT_REGS: usize = 32;
|
||||||
/// Number of available Floating Point registers
|
/// Number of available Floating Point registers
|
||||||
pub const NUM_FP_REGS: usize = 32;
|
pub const NUM_FP_REGS: usize = 32;
|
||||||
/// max number of physical pages
|
|
||||||
pub const NUM_PHY_PAGE : u64 = 400;
|
|
||||||
/// Must be 2^x
|
|
||||||
pub const PAGE_SIZE : u64 = 128;
|
|
||||||
/// Must be a multiple of PAGE_SIZE
|
|
||||||
pub const MEM_SIZE : usize = (PAGE_SIZE*NUM_PHY_PAGE*100_000) as usize;
|
|
||||||
|
|
||||||
/// RISC-V Simulator
|
/// RISC-V Simulator
|
||||||
pub struct Machine {
|
pub struct Machine {
|
||||||
@ -100,7 +94,8 @@ pub struct Machine {
|
|||||||
pub interrupt: Interrupt,
|
pub interrupt: Interrupt,
|
||||||
// futur taille à calculer int memSize = g_cfg->NumPhysPages * g_cfg->PageSize;
|
// futur taille à calculer int memSize = g_cfg->NumPhysPages * g_cfg->PageSize;
|
||||||
//creer une struct cfg(configuration) qui s'initialise avec valeur dans un fichier cfg
|
//creer une struct cfg(configuration) qui s'initialise avec valeur dans un fichier cfg
|
||||||
|
num_phy_page: u64,
|
||||||
|
page_size: u64,
|
||||||
/// Current machine status
|
/// Current machine status
|
||||||
pub status: MachineStatus
|
pub status: MachineStatus
|
||||||
}
|
}
|
||||||
@ -109,27 +104,32 @@ pub struct Machine {
|
|||||||
impl Machine {
|
impl Machine {
|
||||||
|
|
||||||
/// Machine constructor
|
/// Machine constructor
|
||||||
pub fn new(debug: bool) -> Self {
|
pub fn new(debug: bool, settings: Settings) -> Self {
|
||||||
let mut shiftmask : [u64 ; 64] = [0 ; 64];
|
let mut shiftmask : [u64 ; 64] = [0 ; 64];
|
||||||
let mut value : u64 = 0xffffffff;
|
let mut value : u64 = 0xffffffff;
|
||||||
|
|
||||||
value = (value << 32) + value;
|
value = (value << 32) + value;
|
||||||
for item in &mut shiftmask {
|
for item in &mut shiftmask {
|
||||||
*item = value;
|
*item = value;
|
||||||
value >>= 1;
|
value >>= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let num_phy_page = *settings.get(&MachineSettingKey::NumPhysPages).unwrap();
|
||||||
|
let page_size = *settings.get(&MachineSettingKey::PageSize).unwrap();
|
||||||
|
let mem_size = (page_size*num_phy_page*100_000) as usize;
|
||||||
|
|
||||||
Machine {
|
Machine {
|
||||||
debug,
|
debug,
|
||||||
pc : 0,
|
pc : 0,
|
||||||
sp: 0,
|
sp: 0,
|
||||||
int_reg : { let mut r = Register::<i64>::init(); r.set_reg(10, -1); r },
|
int_reg : { let mut r = Register::<i64>::init(); r.set_reg(10, -1); r },
|
||||||
fp_reg : Register::<f32>::init(),
|
fp_reg : Register::<f32>::init(),
|
||||||
main_memory : vec![0_u8; MEM_SIZE],
|
main_memory : vec![0_u8; mem_size],
|
||||||
shiftmask,
|
shiftmask,
|
||||||
interrupt: Interrupt::new(),
|
interrupt: Interrupt::new(),
|
||||||
registers_trace : String::from(""),
|
registers_trace : String::from(""),
|
||||||
status: MachineStatus::SystemMode
|
status: MachineStatus::SystemMode,
|
||||||
|
num_phy_page,
|
||||||
|
page_size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -707,6 +707,7 @@ mod test {
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
use crate::simulator::{machine::Machine, mem_cmp};
|
use crate::simulator::{machine::Machine, mem_cmp};
|
||||||
|
use crate::utility::cfg::get_debug_configuration;
|
||||||
|
|
||||||
macro_rules! get_full_path {
|
macro_rules! get_full_path {
|
||||||
($prefix: expr, $test_name:expr) => {{
|
($prefix: expr, $test_name:expr) => {{
|
||||||
@ -720,7 +721,7 @@ mod test {
|
|||||||
|
|
||||||
macro_rules! init_test {
|
macro_rules! init_test {
|
||||||
($a:expr) => {{
|
($a:expr) => {{
|
||||||
let mut m = Machine::new(true);
|
let mut m = Machine::new(true, get_debug_configuration());
|
||||||
let end_file_name = { let mut s = String::from($a); s.push_str("End"); s };
|
let end_file_name = { let mut s = String::from($a); s.push_str("End"); s };
|
||||||
let memory_before = mem_cmp::MemChecker::from(get_full_path!("memory", $a)).unwrap();
|
let memory_before = mem_cmp::MemChecker::from(get_full_path!("memory", $a)).unwrap();
|
||||||
let memory_after = mem_cmp::MemChecker::from(get_full_path!("memory", &end_file_name)).unwrap();
|
let memory_after = mem_cmp::MemChecker::from(get_full_path!("memory", &end_file_name)).unwrap();
|
||||||
@ -735,12 +736,12 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_init_machine() {
|
fn test_init_machine() {
|
||||||
let _ = Machine::new(true);
|
let _ = Machine::new(true, get_debug_configuration());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_read_memory() {
|
fn test_read_memory() {
|
||||||
let mut m = Machine::new(true);
|
let mut m = Machine::new(true, get_debug_configuration());
|
||||||
m.main_memory[4] = 43;
|
m.main_memory[4] = 43;
|
||||||
m.main_memory[5] = 150;
|
m.main_memory[5] = 150;
|
||||||
assert_eq!((43 << 8) + 150, m.read_memory(2, 4));
|
assert_eq!((43 << 8) + 150, m.read_memory(2, 4));
|
||||||
@ -748,7 +749,7 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_write_memory() {
|
fn test_write_memory() {
|
||||||
let mut m = Machine::new(true);
|
let mut m = Machine::new(true, get_debug_configuration());
|
||||||
m.write_memory(2, 6, (43 << 8) + 150);
|
m.write_memory(2, 6, (43 << 8) + 150);
|
||||||
assert_eq!(43, m.main_memory[6]);
|
assert_eq!(43, m.main_memory[6]);
|
||||||
assert_eq!(150, m.main_memory[7]);
|
assert_eq!(150, m.main_memory[7]);
|
||||||
|
@ -206,12 +206,14 @@ impl MemChecker{
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use crate::utility::cfg::get_debug_configuration;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_fill_memory(){
|
fn test_fill_memory(){
|
||||||
let m_c = MemChecker::from("test/machine/memoryAdd.txt").unwrap();
|
let m_c = MemChecker::from("test/machine/memoryAdd.txt").unwrap();
|
||||||
let mut machine = Machine::new(true);
|
let mut machine = Machine::new(true, get_debug_configuration());
|
||||||
MemChecker::fill_memory_from_mem_checker(&m_c, &mut machine);
|
MemChecker::fill_memory_from_mem_checker(&m_c, &mut machine);
|
||||||
MemChecker::compare_print_m_c_machine(&m_c, &mut machine);
|
MemChecker::compare_print_m_c_machine(&m_c, &mut machine);
|
||||||
}
|
}
|
||||||
|
@ -6,15 +6,18 @@ pub struct MMU <'a>{
|
|||||||
* Cette table est associée au processus courant
|
* Cette table est associée au processus courant
|
||||||
* Cette référence peut etre mise a jour par exemple lors d'un switchTo
|
* Cette référence peut etre mise a jour par exemple lors d'un switchTo
|
||||||
*/
|
*/
|
||||||
translationTable : Option<&'a mut TranslationTable>
|
translationTable : Option<&'a mut TranslationTable>,
|
||||||
|
numPhyPages : u64,
|
||||||
|
pageSize : u64
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <'a>MMU <'_>{
|
impl <'a>MMU <'_>{
|
||||||
|
|
||||||
fn create() -> MMU <'a>{
|
fn create(numPhyPages: u64, pageSize: u64) -> MMU <'a>{
|
||||||
|
MMU {
|
||||||
MMU{
|
translationTable : None,
|
||||||
translationTable : None
|
numPhyPages,
|
||||||
|
pageSize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,8 +91,8 @@ impl <'a>MMU <'_>{
|
|||||||
|
|
||||||
pub fn translate(mmu : &mut MMU, virtAddr : u64, physAddr : &mut u64, writing : bool) -> ExceptionType {
|
pub fn translate(mmu : &mut MMU, virtAddr : u64, physAddr : &mut u64, writing : bool) -> ExceptionType {
|
||||||
|
|
||||||
let vpn : u64 = virtAddr/PAGE_SIZE; //virtual page index
|
let vpn : u64 = virtAddr/(mmu.pageSize); //virtual page index
|
||||||
let offset : u64 = virtAddr%PAGE_SIZE; //adresse intra page
|
let offset : u64 = virtAddr%(mmu.pageSize); //adresse intra page
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -133,7 +136,7 @@ impl <'a>MMU <'_>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Make sure that the physical adress is correct
|
//Make sure that the physical adress is correct
|
||||||
if table_ref.get_physical_page(vpn) < 0 || table_ref.get_physical_page(vpn) >= (NUM_PHY_PAGE as i32) {
|
if table_ref.get_physical_page(vpn) < 0 || table_ref.get_physical_page(vpn) >= (mmu.numPhyPages as i32) {
|
||||||
println!("Error from translate :: no valid correspondance");
|
println!("Error from translate :: no valid correspondance");
|
||||||
return ExceptionType::BusErrorException;
|
return ExceptionType::BusErrorException;
|
||||||
}
|
}
|
||||||
@ -147,7 +150,7 @@ impl <'a>MMU <'_>{
|
|||||||
|
|
||||||
//on se permet ici la conversion du champs physical_page de i32 vers u64
|
//on se permet ici la conversion du champs physical_page de i32 vers u64
|
||||||
//si cette valeur avait été signée, cela aurait été detecté juste au dessus, renvoyant une BUSERROR_EXCEPTION
|
//si cette valeur avait été signée, cela aurait été detecté juste au dessus, renvoyant une BUSERROR_EXCEPTION
|
||||||
*physAddr = (table_ref.get_physical_page(vpn) as u64)*PAGE_SIZE + offset;
|
*physAddr = (table_ref.get_physical_page(vpn) as u64)*(mmu.pageSize) + offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ use std::{
|
|||||||
|
|
||||||
/// Aliases the rather long HashMap<MachineSettingKey, i32> type
|
/// Aliases the rather long HashMap<MachineSettingKey, i32> type
|
||||||
/// to a rather simpler to understand Settings.
|
/// to a rather simpler to understand Settings.
|
||||||
pub type Settings = HashMap<MachineSettingKey, i32>;
|
pub type Settings = HashMap<MachineSettingKey, u64>;
|
||||||
|
|
||||||
/// Keys for the Settings HashMap, represented as enums for
|
/// Keys for the Settings HashMap, represented as enums for
|
||||||
/// maintainability.
|
/// maintainability.
|
||||||
@ -92,6 +92,13 @@ pub fn read_settings() -> Result<Settings, Error> {
|
|||||||
Ok(settings_map)
|
Ok(settings_map)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_debug_configuration() -> Settings {
|
||||||
|
let mut settings_map = Settings::new();
|
||||||
|
settings_map.insert(MachineSettingKey::PageSize, 128);
|
||||||
|
settings_map.insert(MachineSettingKey::NumPhysPages, 400);
|
||||||
|
settings_map
|
||||||
|
}
|
||||||
|
|
||||||
fn filter_garbage<R: std::io::Read>(reader: BufReader<R>) -> Vec<String> {
|
fn filter_garbage<R: std::io::Read>(reader: BufReader<R>) -> Vec<String> {
|
||||||
reader.lines()
|
reader.lines()
|
||||||
.map(|l| l.unwrap())
|
.map(|l| l.unwrap())
|
||||||
@ -101,7 +108,7 @@ fn filter_garbage<R: std::io::Read>(reader: BufReader<R>) -> Vec<String> {
|
|||||||
|
|
||||||
fn update_settings_map(mut settings_map: Settings, key: &str, setting: &str) -> Settings {
|
fn update_settings_map(mut settings_map: Settings, key: &str, setting: &str) -> Settings {
|
||||||
let key = MachineSettingKey::from(key);
|
let key = MachineSettingKey::from(key);
|
||||||
let setting = i32::from_str_radix(setting, 10).unwrap_or(0);
|
let setting = u64::from_str_radix(setting, 10).unwrap_or(0);
|
||||||
settings_map.insert(key, setting);
|
settings_map.insert(key, setting);
|
||||||
settings_map
|
settings_map
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user