mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
Merge branch 'master' of github.com:betrusted-io/xous-core
This commit is contained in:
commit
e0f3450b26
6 changed files with 965 additions and 368 deletions
|
|
@ -4,23 +4,29 @@ cpu: CPU.VexRiscv @ sysbus
|
|||
privilegeArchitecture: PrivilegeArchitecture.Priv1_10
|
||||
|
||||
uart: UART.LiteX_UART @ {
|
||||
sysbus 0x60001000;
|
||||
sysbus 0xF0001000 // shadow
|
||||
sysbus 0x60008000;
|
||||
sysbus 0xF0008000 // shadow
|
||||
}
|
||||
-> cpu@1002
|
||||
|
||||
uartkernel: UART.LiteX_UART @ {
|
||||
sysbus 0x60002000;
|
||||
sysbus 0xF0002000 // shadow
|
||||
uartconsole: UART.LiteX_UART @ {
|
||||
sysbus 0x6000A000;
|
||||
sysbus 0xF000A000 // shadow
|
||||
}
|
||||
-> cpu@1003
|
||||
|
||||
uartlog: UART.LiteX_UART @ {
|
||||
sysbus 0x60004000;
|
||||
sysbus 0xF0004000 // shadow
|
||||
uartserver0: UART.LiteX_UART @ {
|
||||
sysbus 0x6000C000;
|
||||
sysbus 0xF000C000 // shadow
|
||||
}
|
||||
-> cpu@1004
|
||||
|
||||
uartserver1: UART.LiteX_UART @ {
|
||||
sysbus 0x6000E000;
|
||||
sysbus 0xF000E000 // shadow
|
||||
}
|
||||
-> cpu@1005
|
||||
|
||||
timer0: Timers.LiteX_Timer_32 @ {
|
||||
sysbus 0x60003000;
|
||||
sysbus 0xF0003000 // shadow
|
||||
|
|
@ -48,15 +54,18 @@ sram: Memory.MappedMemory @ {
|
|||
fbmem: Memory.MappedMemory @ sysbus 0xB0000000
|
||||
size: 0x6000
|
||||
|
||||
memlcd: Video.BetrustedLCD @ sysbus 0xF0005000
|
||||
memlcd: Video.BetrustedLCD @ sysbus 0xF0011000
|
||||
|
||||
kbd: Input.BetrustedKbd @ sysbus 0xF0006000
|
||||
|
||||
cpu_timer: Timers.LiteX_CPUTimer @ sysbus 0xf0000800
|
||||
frequency: 66000000
|
||||
frequency: 100000000
|
||||
// IRQ #100 is Machine Timer Interrupt
|
||||
-> cpu@100
|
||||
|
||||
ticktimer: Timers.TickTimer @ sysbus 0xf0016000
|
||||
periodInMs: 1
|
||||
|
||||
//flash: SPI.Micron_MT25Q @ spi
|
||||
// underlyingMemory: flash_mem
|
||||
|
||||
|
|
|
|||
|
|
@ -12,14 +12,16 @@ mach create
|
|||
i @peripherals/LiteX_Timer_32.cs
|
||||
i @peripherals/memlcd.cs
|
||||
i @peripherals/keyboard.cs
|
||||
i @peripherals/ticktimer.cs
|
||||
|
||||
# Load the Betrusted Renode Platform file
|
||||
machine LoadPlatformDescription @betrusted.repl
|
||||
|
||||
machine StartGdbServer 3333 true
|
||||
showAnalyzer uart
|
||||
showAnalyzer uartlog
|
||||
showAnalyzer uartkernel
|
||||
showAnalyzer uartconsole
|
||||
showAnalyzer uartserver0
|
||||
showAnalyzer uartserver1
|
||||
showAnalyzer memlcd
|
||||
|
||||
logLevel -1 kbd
|
||||
|
|
|
|||
83
emulation/peripherals/ticktimer.cs
Normal file
83
emulation/peripherals/ticktimer.cs
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
//
|
||||
// Copyright (c) 2010-2019 Antmicro
|
||||
//
|
||||
// This file is licensed under the MIT License.
|
||||
// Full license text is available in 'licenses/MIT.txt'.
|
||||
//
|
||||
using System;
|
||||
using Antmicro.Renode.Core;
|
||||
using Antmicro.Renode.Core.Structure.Registers;
|
||||
using Antmicro.Renode.Utilities;
|
||||
using Antmicro.Renode.Logging;
|
||||
using Antmicro.Renode.Time;
|
||||
using Antmicro.Renode.Peripherals.Bus;
|
||||
using System.Threading;
|
||||
|
||||
namespace Antmicro.Renode.Peripherals.Timers
|
||||
{
|
||||
// this is a model of LiteX timer in the Betrusted configuration:
|
||||
// * width: 32 bits
|
||||
// * csr data width: 32 bit
|
||||
[AllowedTranslations(AllowedTranslation.ByteToDoubleWord)]
|
||||
public class TickTimer : BasicDoubleWordPeripheral, IKnownSize
|
||||
{
|
||||
public TickTimer(Machine machine, ulong periodInMs) : base(machine)
|
||||
{
|
||||
machine.ClockSource.AddClockEntry(new ClockEntry(periodInMs, ClockEntry.FrequencyToRatio(this, 1000), OnTick, this, "TickTimer"));
|
||||
DefineRegisters();
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
tickValue = 0;
|
||||
paused = true;
|
||||
}
|
||||
|
||||
private void OnTick()
|
||||
{
|
||||
if (!paused) {
|
||||
Interlocked.Increment(ref tickValue);
|
||||
}
|
||||
}
|
||||
|
||||
public long Size { get { return 0x20; }}
|
||||
|
||||
private void DefineRegisters()
|
||||
{
|
||||
Registers.Control.Define32(this)
|
||||
.WithValueField(0, 32, name: "CONTROL", writeCallback: (_, val) =>
|
||||
{
|
||||
if ((val & 1) != 0) {
|
||||
tickValue = 0;
|
||||
}
|
||||
paused = (val & 2) != 0;
|
||||
});
|
||||
;
|
||||
|
||||
Registers.Time1.Define32(this)
|
||||
.WithValueField(0, 32, FieldMode.Read, name: "Time1", valueProviderCallback: _ =>
|
||||
{
|
||||
return (uint) (tickValue >> 32);
|
||||
})
|
||||
;
|
||||
|
||||
Registers.Time0.Define32(this)
|
||||
.WithValueField(0, 32, FieldMode.Read, name: "Time0", valueProviderCallback: _ =>
|
||||
{
|
||||
return (uint) (tickValue >> 0);
|
||||
})
|
||||
;
|
||||
}
|
||||
|
||||
bool paused;
|
||||
long tickValue;
|
||||
|
||||
private enum Registers
|
||||
{
|
||||
Control = 0x00,
|
||||
Time1 = 0x04,
|
||||
Time0 = 0x08,
|
||||
}
|
||||
}
|
||||
}
|
||||
1184
emulation/renode.svd
1184
emulation/renode.svd
File diff suppressed because it is too large
Load diff
|
|
@ -17,13 +17,22 @@ impl<'a> LogStr<'a> {
|
|||
)
|
||||
.expect("couldn't allocate memory");
|
||||
|
||||
let raw_slice = unsafe { slice::from_raw_parts_mut(mem.as_ptr() as *mut u8, 4096) };
|
||||
// Zero out the buffer. This is required to avoid UB when accessing
|
||||
// "uninitialized" memory.
|
||||
unsafe {
|
||||
let ptr = mem.as_mut_ptr();
|
||||
for off in 0..mem.len() {
|
||||
ptr.add(off).write_volatile(0);
|
||||
}
|
||||
}
|
||||
|
||||
let raw_slice = unsafe { slice::from_raw_parts_mut(mem.as_mut_ptr(), mem.len()) };
|
||||
|
||||
LogStr {
|
||||
raw_slice,
|
||||
len: 0,
|
||||
string: unsafe {
|
||||
core::str::from_utf8_unchecked(slice::from_raw_parts(mem.as_ptr() as *mut u8, 0))
|
||||
core::str::from_utf8_unchecked(slice::from_raw_parts(mem.as_ptr(), 0))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -40,13 +49,6 @@ impl<'a> LogStr<'a> {
|
|||
}
|
||||
|
||||
pub fn as_memory_message(&self, id: xous::MessageId) -> Result<xous::MemoryMessage, xous::Error> {
|
||||
|
||||
print!("SHELL: String @ {:08x}:", self.raw_slice.as_ptr() as usize);
|
||||
for offset in 0..self.len {
|
||||
print!(" {:02x}", self.raw_slice[offset]);
|
||||
}
|
||||
println!(" (length: {})", self.len);
|
||||
|
||||
Ok(xous::MemoryMessage {
|
||||
id,
|
||||
buf: xous::MemoryRange::new(self.raw_slice.as_ptr() as usize, self.raw_slice.len()).unwrap(),
|
||||
|
|
@ -67,8 +69,8 @@ impl<'a> LogStr<'a> {
|
|||
|
||||
impl<'a> Write for LogStr<'a> {
|
||||
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
||||
for c in s.bytes() {
|
||||
self.raw_slice[self.len] = c;
|
||||
for (dest, src) in self.raw_slice.iter_mut().skip(self.len).zip(s.bytes()) {
|
||||
*dest = src;
|
||||
self.len += 1;
|
||||
}
|
||||
self.string = unsafe { core::str::from_utf8_unchecked(slice::from_raw_parts(self.raw_slice.as_ptr(), self.len)) };
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ const TARGET: &str = "riscv32imac-unknown-none-elf";
|
|||
|
||||
enum MemorySpec {
|
||||
SvdFile(String),
|
||||
CsvFile(String),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -155,7 +154,7 @@ fn renode_image(debug: bool) -> Result<(), DynError> {
|
|||
&kernel,
|
||||
&init,
|
||||
debug,
|
||||
MemorySpec::CsvFile("emulation/csr.csv".into()),
|
||||
MemorySpec::SvdFile("emulation/renode.svd".into()),
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
|
|
@ -281,10 +280,6 @@ fn create_image(
|
|||
}
|
||||
|
||||
match memory_spec {
|
||||
MemorySpec::CsvFile(ref s) => {
|
||||
args.push("--csv");
|
||||
args.push(s);
|
||||
}
|
||||
MemorySpec::SvdFile(ref s) => {
|
||||
args.push("--svd");
|
||||
args.push(s);
|
||||
|
|
|
|||
Loading…
Reference in a new issue