From 9d9473645b0b3ed98ec78d28b24639e7bd5cbccd Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Fri, 23 Apr 2021 13:56:48 +0800 Subject: [PATCH 1/6] emulation: update betrusted platform file This updates the memory addresses and attaches the keyboard interrupt. Signed-off-by: Sean Cross --- emulation/betrusted.repl | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/emulation/betrusted.repl b/emulation/betrusted.repl index 5129b75a1..db09043ff 100644 --- a/emulation/betrusted.repl +++ b/emulation/betrusted.repl @@ -4,26 +4,22 @@ cpu: CPU.VexRiscv @ sysbus privilegeArchitecture: PrivilegeArchitecture.Priv1_10 uart: UART.LiteX_UART @ { - sysbus 0x60007000; - sysbus 0xF0007000 // shadow + sysbus 0xF0004000 // shadow } -> cpu@1002 -uartconsole: UART.LiteX_UART @ { - sysbus 0x60009000; - sysbus 0xF0009000 // shadow +console: UART.LiteX_UART @ { + sysbus 0xF0006000 } -> cpu@1003 -uartserver0: UART.LiteX_UART @ { - sysbus 0x6000B000; - sysbus 0xF000B000 // shadow +app_uart: UART.LiteX_UART @ { + sysbus 0xF0008000 } -> cpu@1004 timer0: Timers.LiteX_Timer_32 @ { - sysbus 0x60002000; - sysbus 0xF0002000 // shadow + sysbus 0xF0021000 } frequency: 100000000 -> cpu@1001 @@ -43,26 +39,26 @@ sram: Memory.MappedMemory @ { fbmem: Memory.MappedMemory @ sysbus 0xB0000000 size: 0x6000 -memlcd: Video.BetrustedLCD @ sysbus 0xF000E000 +memlcd: Video.BetrustedLCD @ sysbus 0xF000B000 -keyboard: Input.BetrustedKbd @ sysbus 0xF0017000 +keyboard: Input.BetrustedKbd @ sysbus 0xF0014000 + -> cpu @ 1010 -trng_kernel: Miscellaneous.BetrustedRNGKernel @ sysbus 0xF001B000 +trng_kernel: Miscellaneous.BetrustedRNGKernel @ sysbus 0xF0019000 -trng_server: Miscellaneous.BetrustedRNGServer @ sysbus 0xF001C000 +trng_server: Miscellaneous.BetrustedRNGServer @ sysbus 0xF001A000 +// This peripheral doesn't actually exist, but is required +// in order to keep the CPU running. cpu_timer: Timers.LiteX_CPUTimer @ sysbus 0xf0000800 frequency: 100000000 // IRQ #100 is Machine Timer Interrupt -> cpu@100 -ticktimer: Timers.TickTimer @ sysbus 0xF0014000 +ticktimer: Timers.TickTimer @ sysbus 0xF0011000 periodInMs: 1 -> cpu @ 1008 -//flash: SPI.Micron_MT25Q @ spi -// underlyingMemory: flash_mem - flash_mem: Memory.MappedMemory @ { sysbus 0x20000000; sysbus 0xA0000000 // shadow From 560cd696ab12082cdbe7a48180b9b5ae2501d5bc Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Fri, 23 Apr 2021 13:57:33 +0800 Subject: [PATCH 2/6] emulation: keyboard: implement keyboard driver This implements a keyboard driver based on the current understanding of the keyboard server. Signed-off-by: Sean Cross --- emulation/peripherals/keyboard.cs | 302 +++++++++++++++++++++++++----- 1 file changed, 256 insertions(+), 46 deletions(-) diff --git a/emulation/peripherals/keyboard.cs b/emulation/peripherals/keyboard.cs index 7e302c9c1..dafbea6a8 100644 --- a/emulation/peripherals/keyboard.cs +++ b/emulation/peripherals/keyboard.cs @@ -11,22 +11,111 @@ using Antmicro.Renode.Core; using Antmicro.Renode.Core.Structure.Registers; using Antmicro.Renode.Logging; using Antmicro.Renode.Peripherals.Bus; -using Antmicro.Renode.Peripherals.Memory; -using Antmicro.Renode.Utilities; namespace Antmicro.Renode.Peripherals.Input { + class KeyMap + { + public UInt32[] rows; + public KeyMap(UInt32 row0, UInt32 row1, UInt32 row2, UInt32 row3, UInt32 row4, UInt32 row5, UInt32 row6, UInt32 row7, UInt32 row8) + { + this.rows = new uint[9]; + this.rows[0] = row0; + this.rows[1] = row1; + this.rows[2] = row2; + this.rows[3] = row3; + this.rows[4] = row4; + this.rows[5] = row5; + this.rows[6] = row6; + this.rows[7] = row7; + this.rows[8] = row8; + } + } + public class BetrustedKbd : IKeyboard, IDoubleWordPeripheral, IProvidesRegisterCollection, IKnownSize { public BetrustedKbd(Machine machine) { + this.rows = new uint[9]; this.machine = machine; RegistersCollection = new DoubleWordRegisterCollection(this); - data = new Queue(); + this.IRQ = new GPIO(); Reset(); - data.Enqueue((byte)Command.SelfTestPassed); + DefineRegisters(); } + private void DefineRegisters() + { + Registers.UART_CHAR.Define(this) + .WithValueField(0, 8, + valueProviderCallback: _ => { return this.injectedKey; }, + writeCallback: (_, value) => + { + this.injectedKey = value; + this.irqInjectStatus = true; + UpdateInterrupts(); + this.irqInjectStatus = false; + } + ); + Registers.ROW0DAT.Define(this) + .WithValueField(0, 32, valueProviderCallback: _ => { return this.rows[0]; }) + ; + Registers.ROW1DAT.Define(this) + .WithValueField(0, 32, valueProviderCallback: _ => { return this.rows[1]; }) + ; + Registers.ROW2DAT.Define(this) + .WithValueField(0, 32, valueProviderCallback: _ => { return this.rows[2]; }) + ; + Registers.ROW3DAT.Define(this) + .WithValueField(0, 32, valueProviderCallback: _ => { return this.rows[3]; }) + ; + Registers.ROW4DAT.Define(this) + .WithValueField(0, 32, valueProviderCallback: _ => { return this.rows[4]; }) + ; + Registers.ROW5DAT.Define(this) + .WithValueField(0, 32, valueProviderCallback: _ => { return this.rows[5]; }) + ; + Registers.ROW6DAT.Define(this) + .WithValueField(0, 32, valueProviderCallback: _ => { return this.rows[6]; }) + ; + Registers.ROW7DAT.Define(this) + .WithValueField(0, 32, valueProviderCallback: _ => { return this.rows[7]; }) + ; + Registers.ROW8DAT.Define(this) + .WithValueField(0, 32, valueProviderCallback: _ => { return this.rows[8]; }) + ; + Registers.EV_STATUS.Define32(this) + .WithFlag(0, FieldMode.Read, name: "KEYPRESSED", valueProviderCallback: _ => irqKeyPressedStatus) + .WithFlag(1, FieldMode.Read, name: "INJECT", valueProviderCallback: _ => irqInjectStatus) + ; + + Registers.EV_PENDING.Define32(this) + .WithFlag(0, out irqKeyPressedPending, FieldMode.Read | FieldMode.WriteOneToClear, name: "KEYPRESSED", changeCallback: (_, __) => UpdateInterrupts()) + .WithFlag(1, out irqInjectPending, FieldMode.Read | FieldMode.WriteOneToClear, name: "INJECT", changeCallback: (_, __) => UpdateInterrupts()) + ; + + Registers.EV_ENABLE.Define32(this) + .WithFlag(0, out irqKeyPressedEnabled, name: "KEYPRESSED", changeCallback: (_, __) => UpdateInterrupts()) + .WithFlag(1, out irqKeyPressedEnabled, name: "INJECT", changeCallback: (_, __) => UpdateInterrupts()) + ; + Registers.ROWCHANGE.Define(this) + .WithValueField(0, 32, valueProviderCallback: _ => { return this.rowChange; }) + ; + } + + private void UpdateInterrupts() + { + if (this.irqKeyPressedStatus && this.irqKeyPressedEnabled.Value) + { + this.irqKeyPressedPending.Value = true; + } + if (this.irqInjectStatus && this.irqInjectEnabled.Value) + { + this.irqInjectPending.Value = true; + } + IRQ.Set((this.irqKeyPressedPending.Value && this.irqKeyPressedEnabled.Value) + || (this.irqInjectPending.Value && this.irqInjectEnabled.Value)); + } public void WriteDoubleWord(long address, uint value) { @@ -38,66 +127,187 @@ namespace Antmicro.Renode.Peripherals.Input return RegistersCollection.Read(offset); } - public long Size { get { return 4096; }} + public long Size { get { return 4096; } } public DoubleWordRegisterCollection RegistersCollection { get; private set; } + private void UpdateKeyList(KeyScanCode scanCode, bool isPress) + { + // Ignore duplicate events which happen due to key repeat. + if ((isPress && this.PressedKeys.ContainsKey(scanCode)) + || (!isPress && !this.PressedKeys.ContainsKey(scanCode))) + { + return; + } + + // If we can't handle this key, don't process it. + if (!MatrixMapping.ContainsKey(scanCode)) + { + this.Log(LogLevel.Debug, "No key mapping found for {0}", scanCode); + return; + } + + // Add or remove this key from the list of currently-active keys + this.Log(LogLevel.Debug, "Got new key -- press? {0} : {1}", isPress, scanCode); + if (isPress) + { + this.PressedKeys.Add(scanCode, true); + } + else + { + this.PressedKeys.Remove(scanCode); + } + + // Reconstruct the keyboard matrix press state + for (var i = 0; i < this.rows.Length; i++) + { + this.rows[i] = 0; + } + + // Simulate the keyboard matrix by ORing all pressed keys. + foreach (var key in this.PressedKeys) + { + KeyMap result; + MatrixMapping.TryGetValue(key.Key, out result); + for (var i = 0; i < this.rows.Length; i++) + { + this.rows[i] |= result.rows[i]; + } + } + // for (var i = 0; i <= 8; i++) + // { + // this.Log(LogLevel.Debug, " rows[{0}] = {1}", i, rows[i]); + // } + + // Update the `rowChange` field if no interrupt is pending. + if (!this.irqInjectPending.Value) + { + for (var i = 0; i <= 8; i++) + { + if (this.rows[i] != 0) + { + this.rowChange |= (1u << i); + } + } + } + this.irqKeyPressedStatus = true; + this.UpdateInterrupts(); + this.irqKeyPressedStatus = false; + return; + } + public void Press(KeyScanCode scanCode) { - this.Log(LogLevel.Error, "Pressed key {0}", scanCode); - var key = PS2ScanCodeTranslator.Instance.GetCode(scanCode); - data.Enqueue((byte)(key & 0x7f)); - NotifyParent(); + this.UpdateKeyList(scanCode, true); } public void Release(KeyScanCode scanCode) { - this.Log(LogLevel.Noisy, "Released key {0}", scanCode); - var key = PS2ScanCodeTranslator.Instance.GetCode(scanCode); - data.Enqueue((byte)Command.Release); - data.Enqueue((byte)(key & 0x7f)); - NotifyParent(); + this.UpdateKeyList(scanCode, false); } public void Reset() { - data.Clear(); - } - - public IPS2Controller Controller { get; set; } - - private void SendAck() - { - data.Enqueue((byte)Command.Acknowledge); - NotifyParent(); - } - - private void NotifyParent() - { - if(Controller != null) - { - if(data.Count > 0) - { - Controller.Notify(); - } - } - else - { - this.Log(LogLevel.Noisy, "PS2 device not connected to any controller issued an update."); + for (var i = 0; i < this.rows.Length; i++) { + this.rows[i] = 0; } + irqKeyPressedStatus = false; + irqInjectStatus = false; + this.PressedKeys.Clear(); } - private readonly Queue data; + private Dictionary PressedKeys = new Dictionary { }; + + private readonly Dictionary MatrixMapping = new Dictionary { + {KeyScanCode.Number1, new KeyMap(1<<0, 0, 0, 0, 0, 0, 0, 0, 0)}, + {KeyScanCode.Number2, new KeyMap(1<<1, 0, 0, 0, 0, 0, 0, 0, 0)}, + {KeyScanCode.Number3, new KeyMap(1<<2, 0, 0, 0, 0, 0, 0, 0, 0)}, + {KeyScanCode.Number4, new KeyMap(1<<3, 0, 0, 0, 0, 0, 0, 0, 0)}, + {KeyScanCode.Number5, new KeyMap(1<<4, 0, 0, 0, 0, 0, 0, 0, 0)}, + {KeyScanCode.Number6, new KeyMap(0, 0, 0, 0, 1<<5, 0, 0, 0, 0)}, + {KeyScanCode.Number7, new KeyMap(0, 0, 0, 0, 1<<6, 0, 0, 0, 0)}, + {KeyScanCode.Number8, new KeyMap(0, 0, 0, 0, 1<<7, 0, 0, 0, 0)}, + {KeyScanCode.Number9, new KeyMap(0, 0, 0, 0, 1<<8, 0, 0, 0, 0)}, + {KeyScanCode.Number0, new KeyMap(0, 0, 0, 0, 1<<9, 0, 0, 0, 0)}, + + {KeyScanCode.Q, new KeyMap(0, 1<<0, 0, 0, 0, 0, 0, 0, 0)}, + {KeyScanCode.W, new KeyMap(0, 1<<1, 0, 0, 0, 0, 0, 0, 0)}, + {KeyScanCode.E, new KeyMap(0, 1<<2, 0, 0, 0, 0, 0, 0, 0)}, + {KeyScanCode.R, new KeyMap(0, 1<<3, 0, 0, 0, 0, 0, 0, 0)}, + {KeyScanCode.T, new KeyMap(0, 1<<4, 0, 0, 0, 0, 0, 0, 0)}, + {KeyScanCode.Y, new KeyMap(0, 0, 0, 0, 0, 1<<5, 0, 0, 0)}, + {KeyScanCode.U, new KeyMap(0, 0, 0, 0, 0, 1<<6, 0, 0, 0)}, + {KeyScanCode.I, new KeyMap(0, 0, 0, 0, 0, 1<<7, 0, 0, 0)}, + {KeyScanCode.O, new KeyMap(0, 0, 0, 0, 0, 1<<8, 0, 0, 0)}, + {KeyScanCode.P, new KeyMap(0, 0, 0, 0, 0, 1<<9, 0, 0, 0)}, + + {KeyScanCode.A, new KeyMap(0, 0, 1<<0, 0, 0, 0, 0, 0, 0)}, + {KeyScanCode.S, new KeyMap(0, 0, 1<<1, 0, 0, 0, 0, 0, 0)}, + {KeyScanCode.D, new KeyMap(0, 0, 1<<2, 0, 0, 0, 0, 0, 0)}, + {KeyScanCode.F, new KeyMap(0, 0, 1<<3, 0, 0, 0, 0, 0, 0)}, + {KeyScanCode.G, new KeyMap(0, 0, 1<<4, 0, 0, 0, 0, 0, 0)}, + {KeyScanCode.H, new KeyMap(0, 0, 0, 0, 0, 0, 1<<5, 0, 0)}, + {KeyScanCode.J, new KeyMap(0, 0, 0, 0, 0, 0, 1<<6, 0, 0)}, + {KeyScanCode.K, new KeyMap(0, 0, 0, 0, 0, 0, 1<<7, 0, 0)}, + {KeyScanCode.L, new KeyMap(0, 0, 0, 0, 0, 0, 1<<8, 0, 0)}, + {KeyScanCode.BackSpace, new KeyMap(0, 0, 0, 0, 0, 0, 1<<9, 0, 0)}, + + {KeyScanCode.Tilde, new KeyMap(0, 0, 0, 1<<0, 0, 0, 0, 0, 0)}, + {KeyScanCode.Z, new KeyMap(0, 0, 0, 1<<1, 0, 0, 0, 0, 0)}, + {KeyScanCode.X, new KeyMap(0, 0, 0, 1<<2, 0, 0, 0, 0, 0)}, + {KeyScanCode.C, new KeyMap(0, 0, 0, 1<<3, 0, 0, 0, 0, 0)}, + {KeyScanCode.V, new KeyMap(0, 0, 0, 1<<4, 0, 0, 0, 0, 0)}, + {KeyScanCode.B, new KeyMap(0, 0, 0, 0, 0, 0, 0, 1<<5, 0)}, + {KeyScanCode.N, new KeyMap(0, 0, 0, 0, 0, 0, 0, 1<<6, 0)}, + {KeyScanCode.M, new KeyMap(0, 0, 0, 0, 0, 0, 0, 1<<7, 0)}, + {KeyScanCode.OemQuestion, new KeyMap(0, 0, 0, 0, 0, 0, 0, 1<<8, 0)}, + {KeyScanCode.Enter, new KeyMap(0, 0, 0, 0, 0, 0, 0, 1<<9, 0)}, + + {KeyScanCode.ShiftL, new KeyMap(0, 0, 0, 0, 0, 0, 0, 0, 1<<5)}, + {KeyScanCode.OemComma, new KeyMap(0, 0, 0, 0, 0, 0, 0, 0, 1<<6)}, + {KeyScanCode.Space, new KeyMap(0, 0, 0, 0, 0, 0, 0, 0, 1<<7)}, + {KeyScanCode.OemPeriod, new KeyMap(0, 0, 0, 0, 0, 0, 0, 0, 1<<8)}, + {KeyScanCode.ShiftR, new KeyMap(0, 0, 0, 0, 0, 0, 0, 0, 1<<9)}, + + {KeyScanCode.F1, new KeyMap(0, 0, 0, 0, 0, 0, 0, 0, 1<<0)}, + {KeyScanCode.F2, new KeyMap(0, 0, 0, 0, 0, 0, 0, 0, 1<<1)}, + {KeyScanCode.F3, new KeyMap(0, 0, 0, 1<<8, 0, 0, 0, 0, 0)}, + {KeyScanCode.F4, new KeyMap(0, 0, 0, 1<<9, 0, 0, 0, 0, 0)}, + {KeyScanCode.Up, new KeyMap(0, 0, 0, 0, 0, 0, 1<<4, 0, 0)}, + {KeyScanCode.Down, new KeyMap(0, 0, 0, 0, 0, 0, 0, 1<<2, 0)}, + {KeyScanCode.Left, new KeyMap(0, 0, 0, 0, 0, 0, 0, 1<<2, 0)}, + {KeyScanCode.Right, new KeyMap(0, 0, 0, 1<<6, 0, 0, 0, 0, 0)}, + + {KeyScanCode.KeypadEnter, new KeyMap(0, 0, 0, 0, 0, 1<<2, 0, 0, 0)}, + }; + private readonly Machine machine; - private const ushort deviceId = 0xABBA; + private UInt32[] rows; - private enum Command + public GPIO IRQ { get; private set; } + private IFlagRegisterField irqKeyPressedEnabled; + private IFlagRegisterField irqKeyPressedPending; + private bool irqKeyPressedStatus; + private IFlagRegisterField irqInjectEnabled; + private IFlagRegisterField irqInjectPending; + private bool irqInjectStatus; + private UInt32 rowChange; + private UInt32 injectedKey; + private enum Registers { - Reset = 0xFF, - Acknowledge = 0xFA, - ReadId = 0xF2, - SetResetLeds = 0xED, - Release = 0xF0, - SelfTestPassed = 0xAA, + UART_CHAR = 0x0, + ROW0DAT = 0x04, + ROW1DAT = 0x08, + ROW2DAT = 0x0C, + ROW3DAT = 0x10, + ROW4DAT = 0x14, + ROW5DAT = 0x18, + ROW6DAT = 0x1C, + ROW7DAT = 0x20, + ROW8DAT = 0x24, + EV_STATUS = 0x28, + EV_PENDING = 0x2C, + EV_ENABLE = 0x30, + ROWCHANGE = 0x34, } } } From b19dadd1c60c2497bc87dcf2c8d35abf82afa97b Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Fri, 23 Apr 2021 13:58:01 +0800 Subject: [PATCH 3/6] emulation: trng_server: fix trng register addresses This swaps the STATUS and DATA registers, which were incorrectly created. Signed-off-by: Sean Cross --- emulation/peripherals/trng_server.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emulation/peripherals/trng_server.cs b/emulation/peripherals/trng_server.cs index 43892a27d..24bacb043 100644 --- a/emulation/peripherals/trng_server.cs +++ b/emulation/peripherals/trng_server.cs @@ -39,8 +39,8 @@ namespace Antmicro.Renode.Peripherals.Miscellaneous private enum Registers { CONTROL = 0x0, - STATUS = 0x4, - DATA = 0x8, + STATUS = 0x8, + DATA = 0x4, AV_CONFIG = 0xc, RO_CONFIG = 0x10, ERRORS = 0x14, From d1b6ad0eb769a1d55007b998dbb7ade43488e920 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Fri, 23 Apr 2021 13:58:40 +0800 Subject: [PATCH 4/6] emulation: xous-release: silence unimplemented blocks Signed-off-by: Sean Cross --- emulation/xous-release.resc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/emulation/xous-release.resc b/emulation/xous-release.resc index 5699b2c58..5bd5ec4c9 100644 --- a/emulation/xous-release.resc +++ b/emulation/xous-release.resc @@ -21,11 +21,22 @@ machine LoadPlatformDescription @betrusted.repl machine StartGdbServer 3333 true showAnalyzer uart -showAnalyzer uartconsole -# showAnalyzer uartserver0 -# showAnalyzer memlcd +showAnalyzer console +# showAnalyzer app_uart +showAnalyzer memlcd -logLevel -1 kbd +sysbus Tag <0xB0000000, 0xB0006000> "Framebuffer" + +# Silence COM messages +sysbus SilenceRange <0xF000C000, 0xF000CFFF> + +# Silence WDT +sysbus SilenceRange <0xF001F000, 0xF001FFFF> + +# Silence I2C +sysbus SilenceRange <0xF000D000, 0xF000DFFF> + +# logLevel -1 keyboard # logLevel -1 ticktimer # The macro `reset` gets called implicitly when running `machine Reset` From 4ce311d1660b477ddd7cecb38de7e2067d2934de Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Fri, 23 Apr 2021 14:15:11 +0800 Subject: [PATCH 5/6] emulation: trng_server: physically reorder the enum Signed-off-by: Sean Cross --- emulation/peripherals/trng_server.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emulation/peripherals/trng_server.cs b/emulation/peripherals/trng_server.cs index 24bacb043..b05e03df7 100644 --- a/emulation/peripherals/trng_server.cs +++ b/emulation/peripherals/trng_server.cs @@ -39,8 +39,8 @@ namespace Antmicro.Renode.Peripherals.Miscellaneous private enum Registers { CONTROL = 0x0, - STATUS = 0x8, DATA = 0x4, + STATUS = 0x8, AV_CONFIG = 0xc, RO_CONFIG = 0x10, ERRORS = 0x14, From 428ccd2e0fb6fa246c2d81d94e5bf1e82e005a66 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Fri, 23 Apr 2021 17:04:59 +0800 Subject: [PATCH 6/6] emulation: memlcd: add PRESCALER register This register is not wired to anything. Signed-off-by: Sean Cross --- emulation/peripherals/memlcd.cs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/emulation/peripherals/memlcd.cs b/emulation/peripherals/memlcd.cs index 23dd44ea2..f386857a8 100644 --- a/emulation/peripherals/memlcd.cs +++ b/emulation/peripherals/memlcd.cs @@ -22,7 +22,10 @@ namespace Antmicro.Renode.Peripherals.Video RegistersCollection = new DoubleWordRegisterCollection(this); Reconfigure(336, 536, PixelFormat.RGB565, true); - for (int i = 0; i < buffer.Length; i++) buffer[i] = 0; + for (int i = 0; i < buffer.Length; i++) + { + buffer[i] = 0; + } DoRepaint(); DefineRegisters(); Reset(); @@ -43,7 +46,7 @@ namespace Antmicro.Renode.Peripherals.Video RegistersCollection.Reset(); } - public long Size { get { return 0x800; } } + public long Size { get { return 0x1000; } } public DoubleWordRegisterCollection RegistersCollection { get; private set; } protected override void Repaint() @@ -56,11 +59,14 @@ namespace Antmicro.Renode.Peripherals.Video // 1) The `updateDirty` bit is set and the current line is dirty, or // 2) The `updateAll` bit is set. bool shouldRedrawLine = updateAll; - foreach (int i in Enumerable.Range(41, 22)) { - if (shouldRedrawLine) { + foreach (int i in Enumerable.Range(41, 22)) + { + if (shouldRedrawLine) + { break; } - if (updateDirty && (newbuf[y * 44 + i] != 0)) { + if (updateDirty && (newbuf[y * 44 + i] != 0)) + { shouldRedrawLine = true; } } @@ -96,6 +102,9 @@ namespace Antmicro.Renode.Peripherals.Video Registers.BUSY.Define(this) .WithValueField(0, 32, valueProviderCallback: _ => { return 0; }) ; + Registers.PRESCALER.Define(this) + .WithValueField(0, 32, valueProviderCallback: _ => { return 0; }) + ; } private bool updateDirty = false; @@ -108,7 +117,8 @@ namespace Antmicro.Renode.Peripherals.Video private enum Registers { COMMAND = 0x0, - BUSY = 0x04 + BUSY = 0x04, + PRESCALER = 0x08, } } }