• Fawaz's avatar
    Added features to select privilege level (#5) · 6e355849
    Fawaz authored
    Currently, the library attempts to execute some semihosting operations
    in a completely interrupt-free context. It does this by using
    `riscv::interrupt::free`, which saves and restores the `mie` field of
    `mstatus`. As a result, attempts to initiate semihosting calls outside
    of M mode cause illegal instruction exceptions.
    
    This commit provides a solution, by requiring users to choose one of two
    features, "machine-mode" or "user-mode", which will compile different
    versions of the functions in src/export.rs that do and do not suspend
    interrupts, respectively. Failure to do so will throw a compiler error,
    unless the "no-semihosting" feature was enabled.
    
    A "supervisor-mode" feature was left out as the `riscv` crate does not
    yet have an equivalent of `interrupt::free` for supervisor mode.
    
    CI now also checks builds with both of these features.
    6e355849