示例#1
0
        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();
        }
示例#2
0
        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));
            }
        }
示例#3
0
 public void WriteWord(ulong address, ulong data) => this.devices[SystemBusController.GetDeviceId(address)].WriteWord(SystemBusController.GetAddress(address), data);
示例#4
0
 public ulong ReadWord(ulong address) => this.devices[SystemBusController.GetDeviceId(address)].ReadWord(SystemBusController.GetAddress(address));
示例#5
0
 public void Write(ulong destination, ulong[] data) => this.devices[SystemBusController.GetDeviceId(destination)].Write(SystemBusController.GetAddress(destination), data);
示例#6
0
 public ulong[] Read(ulong source, ulong length) => this.devices[SystemBusController.GetDeviceId(source)].Read(SystemBusController.GetAddress(source), length);
示例#7
0
 public void Dispose()
 {
     this.system.Dispose();
     this.system = null;
 }