MCPcopy Index your code
hub / github.com/Alignof/carron

github.com/Alignof/carron @v1.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.1.0 ↗ · + Follow
392 symbols 840 edges 59 files 22 documented · 6%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

carron

Rust riscv_tests
RV64IMAC emulator in rust

Feature

This emulator parses an ELF file that supports rv32imac/rv64imac and emulate execution environment of it.
The emulator passed riscv-tests shown below.

  • [x] rv32mi-p
  • [x] rv32si-p
  • [x] rv32ui-p
  • [x] rv32ui-v
  • [x] rv32um-p
  • [x] rv32um-v
  • [x] rv32uc-p
  • [x] rv32uc-v
  • [x] rv32ua-p
  • [x] rv32ua-v
  • [x] rv64mi-p
  • [x] rv64si-p
  • [x] rv64ui-p
  • [x] rv64ui-v
  • [x] rv64um-p
  • [x] rv64um-v
  • [x] rv64uc-p
  • [x] rv64uc-v
  • [x] rv64ua-p
  • [x] rv64ua-v

This emulator can also run self-hosted binaries of cc_sakura, my handmade C compiler.

Install

git clone https://github.com/Alignof/carron.git
cd carron
cargo build --release

Usage

$ ./carron --help
carron 1.1.0
n.takana <Alignof@outlook.com>
RV64IMAC emulator

USAGE:
    carron [OPTIONS] <filename> [main_args]...

ARGS:
    <filename>        ELF file path
    <main_args>...

OPTIONS:
    -e, --elfhead                         Show ELF header
    -p, --program                         Show all segments
    -s, --section                         Show all sections
    -d, --disasem                         Disassemble ELF
    -a, --all                             Show all ELF data
        --pk <proxy_kernel>               Run with proxy kernel
        --pc <init_pc>                    Set entry address as hex
        --break_point <address>           Set break point as hex
        --result_reg <register_number>    Set result register
        --loglv <log_level>               Set log level
    -h, --help                            Print help information
    -V, --version                         Print version information
$ ./carron --pk $RISCV/riscv32-unknown-elf/bin/pk ./HelloWorld

In file HelloWorld
elfcheck: OK

bbl loader
hello world!
$ git clone https://github.com/buildroot/buildroot
$ cd buildroot
$ make spike_riscv64_defconfig
$ make menuconfig # disable F extension
$ make -j $(nproc)
$ ./carron --release -- --kernel /path/to/Image --initrd /path/to/rootfs.cpio /path/to/fw_jump.elf
In file /home/takana/riscv-toolchain/buildroot/output/images/fw_jump.elf
elfcheck: OK


OpenSBI v1.2
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

......

[    0.091080] Freeing unused kernel image (initmem) memory: 2144K
[    0.097300] Run /init as init process
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
Saving 256 bits of non-creditable seed for next boot
Starting network: OK

Welcome to Buildroot
buildroot login:

Extension points exported contracts — how you extend this code

Device (Interface)
(no doc) [5 implementers]
src/bus.rs
ElfHeader (Interface)
(no doc) [2 implementers]
src/elfload.rs
Decode (Interface)
(no doc) [2 implementers]
src/cpu/decode.rs
CrossIsaUtil (Interface)
(no doc) [1 implementers]
src/cpu.rs
ProgramHeader (Interface)
(no doc) [2 implementers]
src/elfload.rs
DecodeUtil (Interface)
(no doc) [2 implementers]
src/cpu/decode.rs
SectionHeader (Interface)
(no doc) [2 implementers]
src/elfload.rs
Execution (Interface)
(no doc) [1 implementers]
src/cpu/execution.rs

Core symbols most depended-on inside this repo

read
called by 176
src/cpu/reg.rs
write
called by 112
src/cpu/reg.rs
slice
called by 85
src/cpu/decode/inst_16.rs
in_range
called by 55
src/bus/dram.rs
get_u32
called by 37
src/elfload.rs
wrap
called by 37
src/cpu/csr.rs
only_rv64
called by 34
src/cpu/decode.rs
set
called by 31
src/cpu/decode/inst_16.rs

Shape

Method 253
Function 82
Class 29
Enum 20
Interface 8

Languages

Rust100%

Modules by API surface

src/bus/plic.rs27 symbols
src/bus/uart.rs24 symbols
src/elfload.rs21 symbols
src/bus/dram.rs20 symbols
src/cpu/csr.rs19 symbols
src/bus/mrom.rs16 symbols
src/bus/clint.rs16 symbols
src/fesvr/syscall.rs14 symbols
src/cpu.rs14 symbols
src/bus.rs14 symbols
src/elfload/elf_64/section_header.rs10 symbols
src/elfload/elf_32/section_header.rs10 symbols

For agents

$ claude mcp add carron \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact