public Bus(RedBus redBus, int size) { RedBus = redBus; devices = new List <Device>(size); boundaries = new int[0]; BusCapacity = size; }
public void Down() { //56mb this.cpu.Dispose(); this.bios = null; this.redBus = null; this.bus = null; this.cpu = null; GC.Collect(); //55mb (-2.3kb) }
public Device findDevice(int address) { if (RedBus.inRange(address)) { return(RedBus); } var idx = Array.BinarySearch(boundaries, address); if (idx < 0) { idx = -idx - 2; } if (idx < 0) { return(new CorruptedDevice()); } return(devices[idx]); }
/// <summary> /// Constructs the machine with the given RAM size and load a bootloader into memory. /// The bootloader is loaded at address 0x400 to 0x500. /// </summary> /// <param name="bootloader"> /// The path to the bootloader file /// </param> /// <param name="coreRamSize"> /// The size of RAM in bytes /// </param> public Machine(string bootloader, string os, int coreRamSize) { try { bios = new Bios(this, 0x0100, "PGX"); cpu = new CPU(IsLight); redBus = new RedBus(cpu); bus = new Bus(redBus); cpu.Bus = (bus); var deb = new Debugger(cpu); cpu.linkDebugger(deb); var ram = new Memory(0x0000, coreRamSize - 1, cpu); if (bootloader != null) { ram.loadFromFile(bootloader, 0x0300, 0x4268, "bootloader"); } if (os != null) { ram.loadFromFile(os, 0x0300, 0x4268, "os"); } bus.AddDevice(ram); //bus.AddDevice(new Acia6850(0x8800, cpu)); // invalid instruction page bus.AddDevice(new Acia6551(0x8800, cpu)); bus.AddDevice(new CRTC(0x9000, cpu, ram)); //bus.AddDevice(new WIFICard(0x10000, cpu)); // wtf, hault on divide by zero bus.AddDevice(new WirelessTerminal(0x9500, cpu)); // in address 0x10k, wsod on register overflow } catch (Exception e) { cpu.Hault(e); Down(); } reset(); coldUpCPU(); }
public void update() => RedBus.updatePeripheral();
public Bus(RedBus redBus) : this(redBus, 0x10) { }
public Bus initBus() { redBus = new RedBus(cpu); return(new Bus(redBus)); }