fwft.rs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //! Chapter 18. SBI Firmware Features Extension (EID #0x46574654 "FWFT").
  2. use crate::binary::{sbi_call_1, sbi_call_3};
  3. use sbi_spec::{
  4. binary::SbiRet,
  5. fwft::{EID_FWFT, GET, SET},
  6. };
  7. /// Set the configuration value of a specific firmware feature.
  8. ///
  9. /// # Parameters
  10. ///
  11. /// - `feature`: The identifier of the feature to set.
  12. /// - `value`: The value to set for the feature.
  13. /// - `flags`: Flags to modify the behavior of the set operation.
  14. ///
  15. /// # Return value
  16. ///
  17. /// A successful return results in the requested firmware feature to be set according to the `value` and `flags` parameters. In case of failure, `feature` value is not modified and the possible error codes returned in `SbiRet.error` are shown in the table below:
  18. ///
  19. /// | Error code | Description
  20. /// |:----------------------------|:---------------------------------
  21. /// | `SbiRet::success()` | `feature` was set successfully.
  22. /// | `SbiRet::not_supported()` | `feature` is not reserved and valid, but the platform does not support it due to one or more missing dependencies (Hardware or SBI implementation).
  23. /// | `SbiRet::invalid_param()` | Provided `value` or `flags` parameter is invalid.
  24. /// | `SbiRet::denied()` | `feature` set operation failed because either it was denied by the SBI implementation, or`feature` is reserved or is platform-specific and unimplemented.
  25. /// | `SbiRet::denied_locked()` | `feature` set operation failed because the `feature` is locked.
  26. /// | `SbiRet::failed()` | The set operation failed for unspecified or unknown other reasons.
  27. ///
  28. /// This function is defined in RISC-V SBI Specification chapter 18.1.
  29. #[inline]
  30. pub fn fwft_set(feature: u32, value: usize, flags: usize) -> SbiRet {
  31. sbi_call_3(EID_FWFT, SET, feature as _, value, flags)
  32. }
  33. /// Get the configuration value of a specific firmware feature.
  34. ///
  35. /// # Parameters
  36. ///
  37. /// - `feature`: The identifier of the feature to get.
  38. ///
  39. /// # Return value
  40. ///
  41. /// A successful return results in the firmware feature configuration value to be returned in `SbiRet.value`. In case of failure, the content of `SbiRet.value` is zero and the possible error codes returned in `SbiRet.error` are shown in the table below:
  42. ///
  43. /// | Error code | Description
  44. /// |:----------------------------|:---------------------------------
  45. /// | `SbiRet::success()` | Feature status was retrieved successfully.
  46. /// | `SbiRet::not_supported()` | `feature` is not reserved and valid, but the platform does not support it due to one or more missing dependencies (Hardware or SBI implementation).
  47. /// | `SbiRet::denied()` | `feature` is reserved or is platform-specific and unimplemented.
  48. /// | `SbiRet::failed()` | The get operation failed for unspecified or unknown other reasons.
  49. ///
  50. /// This function is defined in RISC-V SBI Specification chapter 18.2.
  51. #[inline]
  52. pub fn fwft_get(feature: u32) -> SbiRet {
  53. sbi_call_1(EID_FWFT, GET, feature as _)
  54. }