public SystemHost(Stream bootImage, Stream applicationImage, ulong displayWidth, ulong displayHeight) { var interruptController = new Hdw.InterruptController(); var ram = new Hdw.RandomAccessMemoryController(1 * 1024 * 1024); var bootManager = new Hdw.BootManager(bootImage); this.Processor = new Hdw.Processor(); this.system = new Hdw.SystemBusController() { Processor = this.Processor, InterruptController = interruptController }; this.system.AddDevice(ram); this.system.AddDevice(bootManager); this.system.AddDevice(this.Processor); this.system.AddDevice(interruptController); applicationImage.SetLength(8 * 1024 * 1024); this.system.AddDevice(new Hdw.DiskDrive(applicationImage)); this.Keyboard = new Hdw.Keyboard(); this.system.AddDevice(this.Keyboard); this.Display = new Hdw.Display(displayWidth, displayHeight); this.system.AddDevice(this.Display); this.Processor.DebugHandler = (a, b, c) => a.Value = (ulong)DateTime.UtcNow.Ticks; this.system.Reset(); }
public void Copy(ulong source, ulong destination, ulong length) { var sourceDevice = this.devices[SystemBusController.GetDeviceId(source)]; var destinationDevice = this.devices[SystemBusController.GetDeviceId(destination)]; if (sourceDevice.Id == destinationDevice.Id) { sourceDevice.Copy(SystemBusController.GetAddress(source), SystemBusController.GetAddress(destination), length); } else { destinationDevice.Write(SystemBusController.GetAddress(destination), sourceDevice.Read(SystemBusController.GetAddress(source), length)); } }
public void WriteWord(ulong address, ulong data) => this.devices[SystemBusController.GetDeviceId(address)].WriteWord(SystemBusController.GetAddress(address), data);
public ulong ReadWord(ulong address) => this.devices[SystemBusController.GetDeviceId(address)].ReadWord(SystemBusController.GetAddress(address));
public void Write(ulong destination, ulong[] data) => this.devices[SystemBusController.GetDeviceId(destination)].Write(SystemBusController.GetAddress(destination), data);
public ulong[] Read(ulong source, ulong length) => this.devices[SystemBusController.GetDeviceId(source)].Read(SystemBusController.GetAddress(source), length);
public void Dispose() { this.system.Dispose(); this.system = null; }