2021-09-28 23:09:38 +00:00
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
mod error;
|
|
|
|
mod memory;
|
2021-10-04 03:45:50 +00:00
|
|
|
mod timers;
|
2021-10-09 06:11:52 +00:00
|
|
|
mod devices;
|
|
|
|
mod interrupts;
|
2021-10-17 03:30:50 +00:00
|
|
|
mod system;
|
|
|
|
|
|
|
|
mod host;
|
2021-09-30 00:11:48 +00:00
|
|
|
mod cpus;
|
2021-10-06 23:14:56 +00:00
|
|
|
mod peripherals;
|
2021-09-28 23:09:38 +00:00
|
|
|
|
2021-10-09 06:11:52 +00:00
|
|
|
use crate::system::System;
|
2021-10-06 23:14:56 +00:00
|
|
|
use crate::memory::MemoryBlock;
|
|
|
|
use crate::peripherals::ata::AtaDevice;
|
2021-10-10 21:26:54 +00:00
|
|
|
use crate::cpus::m68k::{M68k, M68kType};
|
2021-10-06 23:14:56 +00:00
|
|
|
use crate::peripherals::mc68681::MC68681;
|
2021-10-17 17:39:43 +00:00
|
|
|
use crate::devices::wrap_transmutable;
|
2021-09-28 23:09:38 +00:00
|
|
|
|
|
|
|
fn main() {
|
2021-10-19 18:33:51 +00:00
|
|
|
run_computie();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn run_computie() {
|
2021-10-06 23:14:56 +00:00
|
|
|
let mut system = System::new();
|
|
|
|
|
2021-10-03 16:55:20 +00:00
|
|
|
let monitor = MemoryBlock::load("binaries/monitor.bin").unwrap();
|
2021-10-19 18:33:51 +00:00
|
|
|
//let monitor = MemoryBlock::load("binaries/monitor-68030.bin").unwrap();
|
2021-09-28 23:09:38 +00:00
|
|
|
for byte in monitor.contents.iter() {
|
|
|
|
print!("{:02x} ", byte);
|
|
|
|
}
|
2021-10-17 17:39:43 +00:00
|
|
|
system.add_addressable_device(0x00000000, wrap_transmutable(monitor)).unwrap();
|
2021-09-28 23:09:38 +00:00
|
|
|
|
2021-10-03 16:55:20 +00:00
|
|
|
let mut ram = MemoryBlock::new(vec![0; 0x00100000]);
|
|
|
|
ram.load_at(0, "binaries/kernel.bin").unwrap();
|
2021-10-19 18:33:51 +00:00
|
|
|
//ram.load_at(0, "binaries/kernel-68030.bin").unwrap();
|
2021-10-17 17:39:43 +00:00
|
|
|
system.add_addressable_device(0x00100000, wrap_transmutable(ram)).unwrap();
|
2021-09-28 23:09:38 +00:00
|
|
|
|
2021-10-04 20:02:58 +00:00
|
|
|
let mut ata = AtaDevice::new();
|
2021-10-05 23:22:21 +00:00
|
|
|
ata.load("binaries/disk-with-partition-table.img").unwrap();
|
2021-10-17 17:39:43 +00:00
|
|
|
system.add_addressable_device(0x00600000, wrap_transmutable(ata)).unwrap();
|
2021-10-04 20:02:58 +00:00
|
|
|
|
2021-10-01 03:27:01 +00:00
|
|
|
let mut serial = MC68681::new();
|
2021-10-10 00:35:23 +00:00
|
|
|
launch_terminal_emulator(serial.port_a.open().unwrap());
|
2021-10-19 18:33:51 +00:00
|
|
|
launch_slip_connection(serial.port_b.open().unwrap());
|
2021-10-17 17:39:43 +00:00
|
|
|
system.add_addressable_device(0x00700000, wrap_transmutable(serial)).unwrap();
|
2021-10-06 23:14:56 +00:00
|
|
|
|
2021-09-30 04:52:38 +00:00
|
|
|
|
2021-10-10 21:26:54 +00:00
|
|
|
let mut cpu = M68k::new(M68kType::MC68010);
|
2021-10-15 21:37:31 +00:00
|
|
|
//let mut cpu = M68k::new(M68kType::MC68030);
|
Added MUL, DIV, NEG, DBcc, and Scc instructions, and fixed issue with ADD/SUB flags
With ADDA, SUBA, and ADDQ/SUBQ when the target is an address register, the condition
flags should not be changed, but the code was changing them, which caused problems.
I've fixed it by making the ADD/SUB executions check for an address target and
will not update flags in that case. This should only occur when the actual instruction
was an ADDA or ADDQ with an address register target
2021-10-03 04:59:28 +00:00
|
|
|
|
2021-10-06 02:58:22 +00:00
|
|
|
//cpu.enable_tracing();
|
2021-10-08 17:52:15 +00:00
|
|
|
//cpu.add_breakpoint(0x10781a);
|
|
|
|
//cpu.add_breakpoint(0x10bc9c);
|
|
|
|
//cpu.add_breakpoint(0x106a94);
|
2021-10-19 18:33:51 +00:00
|
|
|
//cpu.add_breakpoint(0x1015b2);
|
|
|
|
//cpu.add_breakpoint(0x103332);
|
2021-10-15 18:12:47 +00:00
|
|
|
//cpu.decoder.dump_disassembly(&mut system, 0x100000, 0x2000);
|
2021-10-15 21:37:31 +00:00
|
|
|
//cpu.decoder.dump_disassembly(&mut system, 0x2ac, 0x200);
|
2021-10-02 05:06:53 +00:00
|
|
|
|
2021-10-17 17:39:43 +00:00
|
|
|
system.add_interruptable_device(wrap_transmutable(cpu)).unwrap();
|
2021-10-19 18:33:51 +00:00
|
|
|
system.run_loop();
|
2021-09-28 23:09:38 +00:00
|
|
|
}
|
|
|
|
|
2021-10-10 00:35:23 +00:00
|
|
|
pub fn launch_terminal_emulator(name: String) {
|
2021-10-19 18:33:51 +00:00
|
|
|
use std::thread;
|
|
|
|
use std::time::Duration;
|
2021-10-10 00:35:23 +00:00
|
|
|
use std::process::Command;
|
|
|
|
|
|
|
|
Command::new("x-terminal-emulator").arg("-e").arg(&format!("pyserial-miniterm {}", name)).spawn().unwrap();
|
2021-10-19 18:33:51 +00:00
|
|
|
thread::sleep(Duration::from_secs(1));
|
2021-10-10 00:35:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn launch_slip_connection(name: String) {
|
|
|
|
use std::process::Command;
|
|
|
|
|
|
|
|
Command::new("sudo").args(["slattach", "-s", "38400", "-p", "slip", &name]).spawn().unwrap();
|
|
|
|
Command::new("sudo").args(["ifconfig", "sl0", "192.168.1.2", "pointopoint", "192.168.1.200", "up"]).status().unwrap();
|
|
|
|
Command::new("sudo").args(["arp", "-Ds", "192.168.1.200", "enp4s0", "pub"]).status().unwrap();
|
|
|
|
Command::new("sudo").args(["iptables", "-A", "FORWARD", "-i", "sl0", "-j", "ACCEPT"]).status().unwrap();
|
|
|
|
Command::new("sudo").args(["iptables", "-A", "FORWARD", "-o", "sl0", "-j", "ACCEPT"]).status().unwrap();
|
|
|
|
Command::new("sudo").args(["sh", "-c", "echo 1 > /proc/sys/net/ipv4/ip_forward"]).status().unwrap();
|
|
|
|
}
|
|
|
|
|
2021-10-19 18:33:51 +00:00
|
|
|
|