fault_injection.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef __FAULT_INJECTION_H
  2. #define __FAULT_INJECTION_H
  3. #include "fixed_types.h"
  4. #include "core.h"
  5. class FaultInjector;
  6. class FaultinjectionManager
  7. {
  8. private:
  9. enum fault_type_t {
  10. FAULT_TYPE_TOGGLE,
  11. FAULT_TYPE_SET0,
  12. FAULT_TYPE_SET1,
  13. };
  14. fault_type_t m_type;
  15. enum fault_injector_t {
  16. FAULT_INJECTOR_NONE,
  17. FAULT_INJECTOR_RANDOM,
  18. };
  19. fault_injector_t m_injector;
  20. public:
  21. static FaultinjectionManager* create();
  22. FaultinjectionManager(fault_type_t type, fault_injector_t injector);
  23. FaultInjector* getFaultInjector(UInt32 core_id, MemComponent::component_t mem_component);
  24. void applyFault(Core *core, IntPtr read_address, UInt32 data_size, MemoryResult &memres, Byte *data, const Byte *fault);
  25. };
  26. class FaultInjector
  27. {
  28. protected:
  29. UInt32 m_core_id;
  30. MemComponent::component_t m_mem_component;
  31. public:
  32. FaultInjector(UInt32 core_id, MemComponent::component_t mem_component);
  33. virtual void preRead(IntPtr addr, IntPtr location, UInt32 data_size, Byte *fault, SubsecondTime time);
  34. virtual void postWrite(IntPtr addr, IntPtr location, UInt32 data_size, Byte *fault, SubsecondTime time);
  35. };
  36. #endif // __FAULT_INJECTION_H