unicorn/bindings
Martin Atkins 7d8fe2ab11
riscv: Expose privilege level as pseudo-register PRIV (#1989)
Unlike some other architectures, RISC-V does not expose the current
privilege mode in any architecturally-defined register. That is intentional
to make it easier to implement virtualization in software, but a Unicorn
caller operates outside of the emulated hart and so it can and should be
able to observe and change the current privilege mode in order to properly
emulate certain behaviors of a real CPU.

The current privilege level is therefore now exposed as a new
pseudo-register using the name "priv", which matches the name of the
virtual register used by RISC-V's debug extension to allow the debugger
to read and change the privilege mode while the hart is halted. Unicorn's
use of it is conceptually similar to a debugger.

The bit encoding of this register is the same as specified in RISC-V Debug
Specification v1.0-rc3 Section 4.10.1. It's defined as a "virtual"
register exposing a subset of fields from the dcsr register, although here
it's implemented directly inside the Unicorn code because QEMU doesn't
currently have explicit support for the CSRs from the debug specification.
If it supports "dcsr" in a future release then this implementation could
change to wrap reading and writing that CSR and then projecting the "prv"
and "v" bitfields into the correct locations for the virtual register.
2024-11-11 21:09:45 +08:00
..
dotnet riscv: Expose privilege level as pseudo-register PRIV (#1989) 2024-11-11 21:09:45 +08:00
go riscv: Expose privilege level as pseudo-register PRIV (#1989) 2024-11-11 21:09:45 +08:00
haskell Haskell bindings: use ExceptT instead of deprecated EitherT (#1034) 2018-10-25 12:54:35 -03:00
java riscv: Expose privilege level as pseudo-register PRIV (#1989) 2024-11-11 21:09:45 +08:00
pascal riscv: Expose privilege level as pseudo-register PRIV (#1989) 2024-11-11 21:09:45 +08:00
python riscv: Expose privilege level as pseudo-register PRIV (#1989) 2024-11-11 21:09:45 +08:00
ruby riscv: Expose privilege level as pseudo-register PRIV (#1989) 2024-11-11 21:09:45 +08:00
rust riscv: Expose privilege level as pseudo-register PRIV (#1989) 2024-11-11 21:09:45 +08:00
vb6 vb6 bindings: clarify Apache license as v2.0 (#1563) 2022-03-03 09:35:02 +08:00
zig riscv: Expose privilege level as pseudo-register PRIV (#1989) 2024-11-11 21:09:45 +08:00
const_generator.py Replace javah by javac -h, only write new constant files if something changes. 2023-07-06 20:12:36 -07:00
Makefile zig consts 2023-03-23 10:09:41 -03:00
README Update binding list (#1349) 2021-10-11 11:17:49 +08:00

This directory contains bindings & test code for Python, Java, Go and .NET.
See <language>/README or <language>/README.TXT or <language>/README.md for how to install each binding.

The following bindings are contributed by community.

- Java binding: by Chris Eagle.
- Go binding: by Ryan Hileman.
- .NET binding: by Antonio Parata.
- Ruby binding: by Sascha Schirra
- Haskell binding: by Adrian Herrera.
- VB6 binding: David Zimmer.
- FreePascal/Delphi binding: Mohamed Osama.

More bindings created & maintained externally by community are available as follows.

- UnicornPascal: Delphi/Free Pascal binding (by Stievie).
    https://github.com/stievie/UnicornPascal

- Unicorn-Rs: Rust binding (by Sébastien Duquette)
    https://github.com/ekse/unicorn-rs

- UnicornEngine: Perl binding (by Vikas Naresh Kumar)
    https://metacpan.org/pod/UnicornEngine

- Unicorn.CR: Crystal binding (by Benoit Côté-Jodoin)
    https://github.com/Becojo/unicorn.cr

- Deimos/unicorn: D binding (by Vladimir Panteleev)
    https://github.com/D-Programming-Deimos/unicorn

- Unicorn-Lua: Lua binding (by Diego Argueta)
    https://github.com/dargueta/unicorn-lua

- pharo-unicorn: Pharo binding (by Guille Polito)
    https://github.com/guillep/pharo-unicorn

- Unicorn.js: JavaScript binding (by Alexandro Sanchez)
    https://github.com/AlexAltea/unicorn.js