.githooks/
riscv/
test/
.clang-format
570 B
.gitignore
5 B
.gitsigners
112 B
AGENTS.md
227 B
LICENSE
1.1 KiB
Makefile
3.5 KiB
README
12.5 KiB
STYLE
781 B
abi_host.c
12.2 KiB
abi_linux.c
3.7 KiB
bitmanip.h
5.8 KiB
color.h
567 B
debug_map.c
5.1 KiB
debug_map.h
1.3 KiB
emulator.c
87.3 KiB
host.h
5.5 KiB
host_posix.c
11.2 KiB
hosted.h
5.7 KiB
image_native.c
4.6 KiB
image_rad0.c
2.7 KiB
image_raw.c
2.6 KiB
io.c
1.1 KiB
io.h
444 B
jit.c
99.2 KiB
jit.h
7.8 KiB
machine.c
4.4 KiB
machine.h
2.1 KiB
machine_cpu.c
13.6 KiB
machine_csr.c
4.6 KiB
machine_devices.c
10.8 KiB
machine_fdt.c
8.7 KiB
machine_internal.h
7.4 KiB
muldiv.h
1.0 KiB
profile.c
17.5 KiB
profile.h
1.4 KiB
riscv.c
755 B
riscv.h
4.3 KiB
types.h
1019 B
vector.c
54.0 KiB
vector.h
1.3 KiB
machine.h
raw
| 1 | /* Deterministic RV64IMA machine with CLINT, PLIC, UART and finish devices. */ |
| 2 | #ifndef MACHINE_H |
| 3 | #define MACHINE_H |
| 4 | |
| 5 | #include "types.h" |
| 6 | |
| 7 | /* Platform limits and the physical base of RAM, also published in the FDT. */ |
| 8 | #define MACHINE_MAX_HARTS 8U |
| 9 | #define MACHINE_RAM_BASE 0x80000000ULL |
| 10 | #define MACHINE_UART_IRQ 10U |
| 11 | #define MACHINE_IRQ_COUNT 31U |
| 12 | |
| 13 | /* A loaded physical section. Empty sections need not reserve any memory. */ |
| 14 | struct machine_section { |
| 15 | u64 base; /* Inclusive physical start address. */ |
| 16 | u32 size; /* Total reserved bytes, including the zero-filled tail. */ |
| 17 | }; |
| 18 | |
| 19 | /* Immutable run configuration. The caller owns RAM. */ |
| 20 | struct machine_config { |
| 21 | u8 *ram; /* Loaded RAM at MACHINE_RAM_BASE. */ |
| 22 | u32 memory_size; /* RAM byte count. */ |
| 23 | u64 entry; /* Initial PC for every hart. */ |
| 24 | struct machine_section text; /* Loaded executable section. */ |
| 25 | struct machine_section rodata; /* Loaded immutable data section. */ |
| 26 | struct machine_section rwdata; /* Loaded initialized writable section. */ |
| 27 | u32 stack_size; /* Bytes reserved per hart; multiple of 16. */ |
| 28 | u32 hart_count; /* Number of enabled harts, 1 through 8. */ |
| 29 | u64 max_steps; /* Virtual ticks, including skipped idle time. */ |
| 30 | u32 irq_source; /* One-shot PLIC edge source, 0 disables. */ |
| 31 | u64 irq_at; /* Virtual tick of the one-shot edge. */ |
| 32 | bool trace; /* Print hart-tagged instructions and traps. */ |
| 33 | bool count_instructions; /* Report actual retired instructions. */ |
| 34 | bool *timed_out; /* Optional out: set when the tick limit ended the run. */ |
| 35 | }; |
| 36 | |
| 37 | /* Run the machine until a finish write or the tick limit. Returns 0 when the |
| 38 | * guest writes the success value to the finish register, 1 when it writes a |
| 39 | * failure value, and 2 for an invalid layout, UART output failure or timeout. |
| 40 | * A timeout is also reported through `timed_out`, when it is not NULL. |
| 41 | * Machine execution never enters the hosted JIT, debugger, or syscall |
| 42 | * runtime. */ |
| 43 | int machine_run(const struct machine_config *config); |
| 44 | |
| 45 | #endif /* MACHINE_H */ |