aboutsummaryrefslogtreecommitdiff
path: root/riscv/sim.cc
AgeCommit message (Collapse)AuthorFilesLines
2022-10-17Merge branch 'master' into plic_uart_v1plic_uart_v1Andrew Waterman1-5/+2
2022-10-14Support command-line configuration of number of pmpregionsJerry Zhao1-1/+1
2022-09-20detects the loading of isa-incompatible (i.e. 32 bit code to 64bit HART) ↵Iman Hosseini1-0/+1
code and emits an error message to help avoid unintentionally loading wrong elf.
2022-07-17remove unnecessary ifdef for RISCV_ENABLE_DUAL_ENDIANWeiwei Li1-4/+0
the default target endian is always little endian: - mmu::is_target_big_endian() return false - sim_t::get_target_endianness() return memif_endianness_little when RISCV_ENABLE_DUAL_ENDIAN macro is undefined
2022-04-20Add ns16550 serial device emulationAnup Patel1-0/+16
The ns16550 is a widely use serial device so we add a simplified ns16550 device emulation which is good enough for Linux, OpenSBI, and hypervisors to use as console. Signed-off-by: Anup Patel <anup@brainfault.org>
2022-04-20Add PLIC emulationAnup Patel1-0/+8
We need an interrupt controller in Spike which will allow us to emulate more real-world devices such as UART, VirtIO net, VirtIO block, etc. The RISC-V PLIC (or SiFive PLIC) is the commonly used interrupt controller in existing RISC-V platforms so this patch adds PLIC emulation for Spike. Signed-off-by: Anup Patel <anup@brainfault.org>
2022-04-12Move real_time_clint into cfg_tRupert Swarbrick1-2/+2
2022-04-12Move varch into cfg_tRupert Swarbrick1-2/+2
2022-04-12Remove nprocs from cfg_tRupert Swarbrick1-2/+0
Now we have hartids, we can remove nprocs so that we have a single source of truth.
2022-04-12Move hartids into cfg_tRupert Swarbrick1-4/+3
The only slightly difficult thing here is that hartids will always be considered "overridden" by the time we get to sim_t::sim_t (either overridden by a command line argument, or overridden when we set default hartids just before the constructor). To allow downstream code to distinguish between "I picked IDs 0, 1, 2, 3 because the user asked for 4 processors" and "The user explicitly asked for IDs 0, 1, 2, 3", we have an extra explicit_hartids field.
2022-04-12Move the "default hartids" logic from sim.cc into spike.ccRupert Swarbrick1-10/+3
This moves another part of the "configuration" out of the generic sim.cc code.
2022-04-12Move start_pc into cfg_tRupert Swarbrick1-3/+2
2022-04-12Fix debug messages about invalid pmpregions/mmu-typesRupert Swarbrick1-2/+2
This was using the number of CPUs in total, rather than the CPU whose PMP regions / MMU type it was actually parsing.
2022-04-11Change processor_t to hold a pointer to an isa_parser_t (#973)Rupert Swarbrick1-1/+1
Before, it had another copy, which is a little unnecessary.
2022-03-30Implement Sv57 and Sv57x4 translation modesAndrew Waterman1-0/+2
2022-03-18Fold priv parameter into cfg_tRupert Swarbrick1-3/+2
2022-03-18Fold isa parameter into cfg_tRupert Swarbrick1-3/+2
2022-03-18Fold nprocs parameter into cfg_tRupert Swarbrick1-8/+8
2022-03-18Fold bootargs parameter in the new cfg_t typeRupert Swarbrick1-3/+2
2022-03-18Initial step towards factoring out command line configurationRupert Swarbrick1-6/+8
This commit defines a "cfg_t" structure, which currently just holds the initrd address range. It will be augmented in future commits to hold other configuration arguments as well. To represent a configuration argument, we define an arg_t base class. This holds a current value, together with a flag that tells us whether the value has been updated from the default. The idea is that in future we're going to use that flag when reading a DTB file: if an argument has actually been specified on the command line, we need to take it into account; if not, we can ignore the default and use the DTB file's supplied value.
2022-03-12Construct an isa_parser_t and pass it to processor_t constructorRupert Swarbrick1-2/+3
This is a minor change, turning processor_t from a child class of isa_parser_t into a class that contains an isa_parser_t as a field. The point is that it is a step toward separating out "configuration" (and ISA string parsing) from processor state. This should be helpful for rejigging things so that we construct more from a supplied device tree.
2022-02-23pmp: dts: handle the absence of mmu and pmp in dtsChih-Min Chao1-1/+13
If there is no 'mmu-type', we treat it as no mmu implementation If there is no 'riscv,pmpregions', we treat it as no pmp implementation Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
2022-02-21Avoid an unnecessary strcpy (#925)Rupert Swarbrick1-3/+3
We don't actually know that the field in the DTB points at a string that's less than 256 bytes long, I don't think, so this could probably cause a buffer overflow on the stack. Anyway, it turns out that there's no need to copy anything anyway, so let's just update a char** instead.
2022-02-18Don't instantiate a CLINT if there is none in the device config (#921)Rupert Swarbrick1-6/+11
This change makes it possible to faithfully simulate systems which don't have a CLINT (without adding yet another command line argument to pass through!). Without a change like this, lowRISC has been using a local hack in its Spike fork, where we've just commented out the internals of clint_t::increment(). This approach is rather cleaner and is hopefully general enough to use upstream.
2022-02-18Add simple error checking to DTB parsing codeRupert Swarbrick1-0/+13
This catches silly mistakes like accidentally passing a DTS file when it should have been a DTB. Now, you get something like this: $ /opt/spike/latest/bin/spike --dtb=bogus.dtb -l obj.o Failed to read DTB from `bogus.dtb': FDT_ERR_BADMAGIC.
2022-02-18Remove duplicate DTB load stepRupert Swarbrick1-17/+0
This code is identical to make_dtb() which is called in the class constructor, so I don't think we have to generate/load/parse things again: we can just use the stuff we made earlier.
2021-09-17Don't use "using"Andrew Waterman1-2/+2
2021-09-17Use RIAA pattern in manipulating ostream flagsAndrew Waterman1-3/+3
sout is renamed to sout_ to reduce likelihood programmers accidentally use it.
2021-09-14add option --cmd to read commands from file (#772)Elmar Melcher1-3/+4
2021-09-01remove io_service_ptr_ctor and acceptor_ptr_ctoremelcher1-5/+5
2021-08-03activate socket comunication in simulatorElmar Melcher1-0/+5
2021-08-03declare socket properties in processor_tElmar Melcher1-1/+1
2021-08-03declare socket properties in sim_tElmar Melcher1-1/+7
2021-06-04encoding: udpate and move platform-related define outChih-Min Chao1-0/+1
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
2021-02-04Fix --kernel and --initrd options w.r.t. sparse mem_t implementationAndrew Waterman1-1/+1
For some reason, the old accessors for the non-sparse version were left dangling. These methods are used by the --kernel and --initrd options, and so those options were just broken. This also fixes a memory leak and refactors the implementation a bit.
2021-01-20add support to page on demand (#634)Chih-Min Chao1-1/+1
This patch splites the target-requested memory regions into pages and only allocates host memory when it is accessed to reduce larget memory sceniaro in 64 bit target system Co-authored-by: Dave.Wen <dave.wen@sifive.com>
2020-12-14dts: mmu: replace 'riscv,bare' by 'riscv,sbare'Chih-Min Chao1-2/+2
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
2020-12-01Fix Issue #609 (#610)Will Hawkins1-5/+1
Fix Issue #609 where extraneous debugging output was added when the user invoked any simulation operation that involved addr_to_mem.
2020-11-29Fix #607: Add a core parameter to the interactive str command (#608)Will Hawkins1-1/+5
Add a core parameter to the interactive str command. This makes it possible for the spike user to specify the device whose memory contains the NUL-terminated string to be printed.
2020-11-15dts: config pmp attribute by each core's settingChih-Min Chao1-12/+13
The original implementation only uses the value in first core and apply it to other core. The patch makes the configuration hetergeneous for differenct cores. Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
2020-11-11dts: mmu: parse mmu-type in dtsChih-Min Chao1-0/+48
1. setup allowed mmu-type from dts 2. change default mmu-type in dts from sv39 to sv48 Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
2020-11-07Allow fixed endianness to be observed through MBE/SBE/UBEMarcus Comstedt1-0/+1
2020-11-07Tag target endian values to help guide conversion codeMarcus Comstedt1-1/+1
2020-11-07Implement support for big-endian targetsMarcus Comstedt1-4/+42
2020-09-29Adding symbol lookup when --enable-commitlog is enabled (#558)sthiruva1-0/+5
* Adding symbol lookup when --enable-commitlog is enabled * Removed the #ifdef RISCV_ENABLE_COMMITLOG for all get_symbol related function Only retained the in processor.cc where it is called. Co-authored-by: Shajid Thiruvathodi <sthiruva@valtrix.in>
2020-07-09Add bootargs command-line option to SpikeAnup Patel1-3/+4
We add bootargs command-line option to Spike which allows us to provide custom kernel parameters to Linux and Xvisor. Signed-off-by: Anup Patel <anup.patel@wdc.com>
2020-05-09Support consuming PMP number and granularity from DTBAndrew Waterman1-0/+9
The feature itself isn't implemented yet.
2020-04-27fdt: restructure dtb create and config flowChih-Min Chao1-8/+45
1. pass dtb option from constructor 2. separate dtb generation from rom initialization 3. setup clint base from dtb Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
2020-04-27fdt: option: add --dtb option to specify dtb binary fileChih-Min Chao1-2/+17
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
2020-03-29Fix debug segfault by partially reverting #409Andrew Waterman1-2/+3