mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
update emulation files
This commit is contained in:
parent
07c20f6285
commit
8192c68a63
5 changed files with 293 additions and 76 deletions
|
|
@ -4,26 +4,22 @@ cpu: CPU.VexRiscv @ sysbus
|
||||||
privilegeArchitecture: PrivilegeArchitecture.Priv1_10
|
privilegeArchitecture: PrivilegeArchitecture.Priv1_10
|
||||||
|
|
||||||
uart: UART.LiteX_UART @ {
|
uart: UART.LiteX_UART @ {
|
||||||
sysbus 0x60007000;
|
sysbus 0xF0004000 // shadow
|
||||||
sysbus 0xF0007000 // shadow
|
|
||||||
}
|
}
|
||||||
-> cpu@1002
|
-> cpu@1002
|
||||||
|
|
||||||
uartconsole: UART.LiteX_UART @ {
|
console: UART.LiteX_UART @ {
|
||||||
sysbus 0x60009000;
|
sysbus 0xF0006000
|
||||||
sysbus 0xF0009000 // shadow
|
|
||||||
}
|
}
|
||||||
-> cpu@1003
|
-> cpu@1003
|
||||||
|
|
||||||
uartserver0: UART.LiteX_UART @ {
|
app_uart: UART.LiteX_UART @ {
|
||||||
sysbus 0x6000B000;
|
sysbus 0xF0008000
|
||||||
sysbus 0xF000B000 // shadow
|
|
||||||
}
|
}
|
||||||
-> cpu@1004
|
-> cpu@1004
|
||||||
|
|
||||||
timer0: Timers.LiteX_Timer_32 @ {
|
timer0: Timers.LiteX_Timer_32 @ {
|
||||||
sysbus 0x60002000;
|
sysbus 0xF0021000
|
||||||
sysbus 0xF0002000 // shadow
|
|
||||||
}
|
}
|
||||||
frequency: 100000000
|
frequency: 100000000
|
||||||
-> cpu@1001
|
-> cpu@1001
|
||||||
|
|
@ -43,26 +39,26 @@ sram: Memory.MappedMemory @ {
|
||||||
fbmem: Memory.MappedMemory @ sysbus 0xB0000000
|
fbmem: Memory.MappedMemory @ sysbus 0xB0000000
|
||||||
size: 0x6000
|
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
|
cpu_timer: Timers.LiteX_CPUTimer @ sysbus 0xf0000800
|
||||||
frequency: 100000000
|
frequency: 100000000
|
||||||
// IRQ #100 is Machine Timer Interrupt
|
// IRQ #100 is Machine Timer Interrupt
|
||||||
-> cpu@100
|
-> cpu@100
|
||||||
|
|
||||||
ticktimer: Timers.TickTimer @ sysbus 0xF0014000
|
ticktimer: Timers.TickTimer @ sysbus 0xF0011000
|
||||||
periodInMs: 1
|
periodInMs: 1
|
||||||
-> cpu @ 1008
|
-> cpu @ 1008
|
||||||
|
|
||||||
//flash: SPI.Micron_MT25Q @ spi
|
|
||||||
// underlyingMemory: flash_mem
|
|
||||||
|
|
||||||
flash_mem: Memory.MappedMemory @ {
|
flash_mem: Memory.MappedMemory @ {
|
||||||
sysbus 0x20000000;
|
sysbus 0x20000000;
|
||||||
sysbus 0xA0000000 // shadow
|
sysbus 0xA0000000 // shadow
|
||||||
|
|
|
||||||
|
|
@ -11,22 +11,111 @@ using Antmicro.Renode.Core;
|
||||||
using Antmicro.Renode.Core.Structure.Registers;
|
using Antmicro.Renode.Core.Structure.Registers;
|
||||||
using Antmicro.Renode.Logging;
|
using Antmicro.Renode.Logging;
|
||||||
using Antmicro.Renode.Peripherals.Bus;
|
using Antmicro.Renode.Peripherals.Bus;
|
||||||
using Antmicro.Renode.Peripherals.Memory;
|
|
||||||
using Antmicro.Renode.Utilities;
|
|
||||||
|
|
||||||
namespace Antmicro.Renode.Peripherals.Input
|
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<DoubleWordRegisterCollection>, IKnownSize
|
public class BetrustedKbd : IKeyboard, IDoubleWordPeripheral, IProvidesRegisterCollection<DoubleWordRegisterCollection>, IKnownSize
|
||||||
{
|
{
|
||||||
public BetrustedKbd(Machine machine)
|
public BetrustedKbd(Machine machine)
|
||||||
{
|
{
|
||||||
|
this.rows = new uint[9];
|
||||||
this.machine = machine;
|
this.machine = machine;
|
||||||
RegistersCollection = new DoubleWordRegisterCollection(this);
|
RegistersCollection = new DoubleWordRegisterCollection(this);
|
||||||
data = new Queue<byte>();
|
this.IRQ = new GPIO();
|
||||||
Reset();
|
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)
|
public void WriteDoubleWord(long address, uint value)
|
||||||
{
|
{
|
||||||
|
|
@ -38,66 +127,187 @@ namespace Antmicro.Renode.Peripherals.Input
|
||||||
return RegistersCollection.Read(offset);
|
return RegistersCollection.Read(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long Size { get { return 4096; }}
|
public long Size { get { return 4096; } }
|
||||||
public DoubleWordRegisterCollection RegistersCollection { get; private set; }
|
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)
|
public void Press(KeyScanCode scanCode)
|
||||||
{
|
{
|
||||||
this.Log(LogLevel.Error, "Pressed key {0}", scanCode);
|
this.UpdateKeyList(scanCode, true);
|
||||||
var key = PS2ScanCodeTranslator.Instance.GetCode(scanCode);
|
|
||||||
data.Enqueue((byte)(key & 0x7f));
|
|
||||||
NotifyParent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Release(KeyScanCode scanCode)
|
public void Release(KeyScanCode scanCode)
|
||||||
{
|
{
|
||||||
this.Log(LogLevel.Noisy, "Released key {0}", scanCode);
|
this.UpdateKeyList(scanCode, false);
|
||||||
var key = PS2ScanCodeTranslator.Instance.GetCode(scanCode);
|
|
||||||
data.Enqueue((byte)Command.Release);
|
|
||||||
data.Enqueue((byte)(key & 0x7f));
|
|
||||||
NotifyParent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Reset()
|
public void Reset()
|
||||||
{
|
{
|
||||||
data.Clear();
|
for (var i = 0; i < this.rows.Length; i++) {
|
||||||
}
|
this.rows[i] = 0;
|
||||||
|
|
||||||
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.");
|
|
||||||
}
|
}
|
||||||
|
irqKeyPressedStatus = false;
|
||||||
|
irqInjectStatus = false;
|
||||||
|
this.PressedKeys.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Queue<byte> data;
|
private Dictionary<KeyScanCode, bool> PressedKeys = new Dictionary<KeyScanCode, bool> { };
|
||||||
|
|
||||||
|
private readonly Dictionary<KeyScanCode, KeyMap> MatrixMapping = new Dictionary<KeyScanCode, KeyMap> {
|
||||||
|
{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 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,
|
UART_CHAR = 0x0,
|
||||||
Acknowledge = 0xFA,
|
ROW0DAT = 0x04,
|
||||||
ReadId = 0xF2,
|
ROW1DAT = 0x08,
|
||||||
SetResetLeds = 0xED,
|
ROW2DAT = 0x0C,
|
||||||
Release = 0xF0,
|
ROW3DAT = 0x10,
|
||||||
SelfTestPassed = 0xAA,
|
ROW4DAT = 0x14,
|
||||||
|
ROW5DAT = 0x18,
|
||||||
|
ROW6DAT = 0x1C,
|
||||||
|
ROW7DAT = 0x20,
|
||||||
|
ROW8DAT = 0x24,
|
||||||
|
EV_STATUS = 0x28,
|
||||||
|
EV_PENDING = 0x2C,
|
||||||
|
EV_ENABLE = 0x30,
|
||||||
|
ROWCHANGE = 0x34,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,8 @@ namespace Antmicro.Renode.Peripherals.Miscellaneous
|
||||||
private enum Registers
|
private enum Registers
|
||||||
{
|
{
|
||||||
CONTROL = 0x0,
|
CONTROL = 0x0,
|
||||||
STATUS = 0x4,
|
STATUS = 0x8,
|
||||||
DATA = 0x8,
|
DATA = 0x4,
|
||||||
AV_CONFIG = 0xc,
|
AV_CONFIG = 0xc,
|
||||||
RO_CONFIG = 0x10,
|
RO_CONFIG = 0x10,
|
||||||
ERRORS = 0x14,
|
ERRORS = 0x14,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<device schemaVersion="1.1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="CMSIS-SVD.xsd" >
|
<device schemaVersion="1.1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="CMSIS-SVD.xsd" >
|
||||||
<vendor>litex</vendor>
|
<vendor>litex</vendor>
|
||||||
<name>SOC</name>
|
<name>SOC</name>
|
||||||
<description><![CDATA[Litex SoC 2021-04-22 23:47:54]]></description>
|
<description><![CDATA[Litex SoC 2021-04-23 13:47:43]]></description>
|
||||||
|
|
||||||
<addressUnitBits>8</addressUnitBits>
|
<addressUnitBits>8</addressUnitBits>
|
||||||
<width>32</width>
|
<width>32</width>
|
||||||
|
|
@ -1070,10 +1070,10 @@ register to disable individual events.]]></description>
|
||||||
<register>
|
<register>
|
||||||
<name>GIT_GITREV</name>
|
<name>GIT_GITREV</name>
|
||||||
<description><![CDATA[First 32-bits of the git revision. This documentation was built from git rev
|
<description><![CDATA[First 32-bits of the git revision. This documentation was built from git rev
|
||||||
``b9a1ecab``, so this value is 3114396843, which should be enough to check out
|
``4878d3c3``, so this value is 1215878083, which should be enough to check out
|
||||||
the exact git version used to build this firmware.]]></description>
|
the exact git version used to build this firmware.]]></description>
|
||||||
<addressOffset>0x0014</addressOffset>
|
<addressOffset>0x0014</addressOffset>
|
||||||
<resetValue>0xb9a1ecab</resetValue>
|
<resetValue>0x4878d3c3</resetValue>
|
||||||
<size>32</size>
|
<size>32</size>
|
||||||
<fields>
|
<fields>
|
||||||
<field>
|
<field>
|
||||||
|
|
@ -1090,7 +1090,7 @@ the exact git version used to build this firmware.]]></description>
|
||||||
is ``1``, then the repository this was built from has one additional commit
|
is ``1``, then the repository this was built from has one additional commit
|
||||||
beyond the tag indicated in `MAJOR`, `MINOR`, and `REVISION`.]]></description>
|
beyond the tag indicated in `MAJOR`, `MINOR`, and `REVISION`.]]></description>
|
||||||
<addressOffset>0x0018</addressOffset>
|
<addressOffset>0x0018</addressOffset>
|
||||||
<resetValue>0x1d</resetValue>
|
<resetValue>0x1f</resetValue>
|
||||||
<size>32</size>
|
<size>32</size>
|
||||||
<fields>
|
<fields>
|
||||||
<field>
|
<field>
|
||||||
|
|
@ -3086,7 +3086,7 @@ inject too fast.]]></description>
|
||||||
<name>SEED1</name>
|
<name>SEED1</name>
|
||||||
<description><![CDATA[Bits 32-63 of `SEED_SEED`. Seed used for the build]]></description>
|
<description><![CDATA[Bits 32-63 of `SEED_SEED`. Seed used for the build]]></description>
|
||||||
<addressOffset>0x0000</addressOffset>
|
<addressOffset>0x0000</addressOffset>
|
||||||
<resetValue>0x1976d1a8</resetValue>
|
<resetValue>0x5073fcc9</resetValue>
|
||||||
<size>32</size>
|
<size>32</size>
|
||||||
<fields>
|
<fields>
|
||||||
<field>
|
<field>
|
||||||
|
|
@ -3101,7 +3101,7 @@ inject too fast.]]></description>
|
||||||
<name>SEED0</name>
|
<name>SEED0</name>
|
||||||
<description><![CDATA[Bits 0-31 of `SEED_SEED`.]]></description>
|
<description><![CDATA[Bits 0-31 of `SEED_SEED`.]]></description>
|
||||||
<addressOffset>0x0004</addressOffset>
|
<addressOffset>0x0004</addressOffset>
|
||||||
<resetValue>0x8576398</resetValue>
|
<resetValue>0x627a019a</resetValue>
|
||||||
<size>32</size>
|
<size>32</size>
|
||||||
<fields>
|
<fields>
|
||||||
<field>
|
<field>
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,22 @@ machine LoadPlatformDescription @betrusted.repl
|
||||||
|
|
||||||
machine StartGdbServer 3333 true
|
machine StartGdbServer 3333 true
|
||||||
showAnalyzer uart
|
showAnalyzer uart
|
||||||
showAnalyzer uartconsole
|
showAnalyzer console
|
||||||
# showAnalyzer uartserver0
|
# showAnalyzer app_uart
|
||||||
# showAnalyzer memlcd
|
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
|
# logLevel -1 ticktimer
|
||||||
|
|
||||||
# The macro `reset` gets called implicitly when running `machine Reset`
|
# The macro `reset` gets called implicitly when running `machine Reset`
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue