FeatMgr

FeatMgr is a configuration dataclass for Riescue. It contains all configuration needed for RiescueD to generate a test. It specifies the enabled features, environment, and generation options.

Note

Generally, users will not need to construct a FeatMgr directly. Instead, they will use the FeatMgrBuilder to construct a FeatMgr.

from riescue import FeatMgr

featmgr = FeatMgr() # build default FeatMgr
class riescue.FeatMgr

Configuration manager; aata structure containing configuration for test generation.

FeatMgrBuilder class provides interface for constructing FeatMgr objects. Users can choose to override any fields after construction.

duplicate() FeatMgr

Duplicate / deepcopy a FeatMgr instance.

get_summary() dict[str, bool | int]

Returns an array representation of feature presence.

is_feature_supported(feature: str) bool

Check if a feature is supported - delegate to FeatureDiscovery

is_feature_enabled(feature: str) bool

Check if a feature is enabled - delegate to FeatureDiscovery

get_feature_randomize(feature: str) int

Get the randomization probability for a feature - delegate to FeatureDiscovery

get_misa_bits() int

Get MISA bits based on enabled features

get_compiler_march_string() str

Generate a compiler march string from enabled features

register_hook(hook_point: HookPoint, hook: Callable[[FeatMgr], str])

Register a hook for a given hook point

Parameters:
  • hook_point – The riescue.lib.enums.HookPoint enum value to register the hook.

  • hook – Callable hook function to register; returns a string of assembly code

def hook(featmgr: FeatMgr) -> str:
    return "nop"
featmgr.register_hook(RV.HookPoint.PRE_PASS, hook)
call_hook(hook_point: HookPoint) str

Get a hook for a given hook point

Hooks

Hooks are available for inserting additional code at different points in the code. Hooks take an instance of the riescue.FeatMgr class as an argument and return a string of assembly code. This can be used to add additional code at different points in the Runtime.

E.g.

def hook(featmgr: FeatMgr) -> str:
    return "nop"
featmgr.register_hook(RV.HookPoint.PRE_PASS, hook)

The available hooks are defined in the riescue.lib.enums.HookPoint enum.

class riescue.lib.enums.HookPoint(value)

Bases: MyEnum

Enumerated hooks for runtime code.

These are all the available hooks, they allow for inserting code at specific points in the Runtime. They append or replace code at the hook point.

This describes the name of the hook; behavior of the hook is defined where the hook is used.

PRE_LOADER = 'pre_loader'

Insert code before the loader. Can be used to insert code for custom CSRs, platform intialization code. GPRs, and changes to tvec, status, and satp will be overwritten by loader.

POST_LOADER = 'post_loader'

Insert code after the loader but before the test jumps to the scheduler, inside loader__done label.

PRE_DISPATCH = 'pre_dispatch'

Insert code before the scheduler loads the next test into a0.

POST_DISPATCH = 'post_dispatch'

Insert code after the scheduler loads the next test into a0. Should not modify a0

POST_TRAP = 'post_trap'

Insert code after a trap is taken. Useful for logging/bookkeeping traps. Code should resume to return code after to continue execution. tp is initialized here - push and pop any registers used by post-trap code.

PRE_FAIL = 'pre_fail'

Insert code before the test is marked as failed.

POST_FAIL = 'post_fail'

Insert code after the test is marked as failed.

PRE_PASS = 'pre_pass'

Insert code before the test is marked as passed.

POST_PASS = 'post_pass'

Insert code after the test is marked as passed.

PRE_HALT = 'pre_halt'

Insert code before the test is halted.

Hooks can be added using the riescue.FeatMgr.register_hook() method with a valid enum value.

Hooks can also be added using the riescue.dtest_framework.config.Conf class. See the Conf reference for more information on how to use the Conf class.