Embedded Artistry Framework
Embedded Systems C++ Framework
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
UnitTestHWPlatform Class Reference

Unit Test (Simulated) hardware platform. More...

#include <unittest_hw_platform.hpp>

Inheritance diagram for UnitTestHWPlatform:
Inheritance graph

Public Member Functions

 UnitTestHWPlatform () noexcept
 Default Constructor. More...
 
 ~UnitTestHWPlatform ()=default
 Default Destructor. More...
 
void init_ () noexcept
 
void initProcessor_ () noexcept
 
void soft_reset_ () noexcept
 
void hard_reset_ () noexcept
 
void shutdown_ () noexcept
 
constexpr const std::string_view & name () const noexcept
 Returns the Virtual HW Platform's name. More...
 
constexpr const char * name_cstr () const noexcept
 Returns the platform name as a cstring for C API compatibility. More...
 
void initProcessor () noexcept
 Initialize the processor. More...
 
void init () noexcept
 Initialize the hardware platform. More...
 
void soft_reset () noexcept
 Perform a soft reset of the system (chip reset) More...
 
void hard_reset () noexcept
 Perform a hard reset of the system (power cycle) More...
 
void shutdown () noexcept
 Shutdown the system. More...
 

Static Public Member Functions

static void earlyInitHook_ () noexcept
 
static void earlyInitHook () noexcept
 Perform any special initialization steps. More...
 

Private Attributes

test::TestDriverBase driver_ = test::TestDriverBase("Undefined test driver")
 We declare a single test driver to exercise the framework. More...
 

Detailed Description

Unit Test (Simulated) hardware platform.

This hardware platform exists to exercise the framework during the unit testing process. This class should not be used directly for any other purpose.

Constructor & Destructor Documentation

◆ UnitTestHWPlatform()

UnitTestHWPlatform::UnitTestHWPlatform ( )
inlinenoexcept

Default Constructor.

◆ ~UnitTestHWPlatform()

UnitTestHWPlatform::~UnitTestHWPlatform ( )
default

Default Destructor.

Member Function Documentation

◆ earlyInitHook()

static void embvm::VirtualHwPlatformBase< UnitTestHWPlatform >::earlyInitHook ( )
inlinestaticnoexceptinherited

Perform any special initialization steps.

The earlyInitHook_() function must be implemented by the derived class as a static function.

These functions run before the C Run-time setup functions are called, and normal functionality (e.g. OS concepts) are not available.

Early initialization steps represent any super early code that needs to execute. For example, DRAM might need to be initialized before the boot process can relocate memory to its proper location in memory.

These functions are declared static to prevent you from easily using drivers within their confines

◆ earlyInitHook_()

static void UnitTestHWPlatform::earlyInitHook_ ( )
inlinestaticnoexcept

◆ hard_reset()

void embvm::VirtualHwPlatformBase< UnitTestHWPlatform >::hard_reset ( )
inlinenoexceptinherited

Perform a hard reset of the system (power cycle)

The hard_reset_() function must be implemented by the derived class.

A hard reset is intended to perform a full power cycle of the system.

Platforms which do not support a hard reset should default to calling soft_reset().

◆ hard_reset_()

void UnitTestHWPlatform::hard_reset_ ( )
inlinenoexcept

References soft_reset_().

◆ init()

void embvm::VirtualHwPlatformBase< UnitTestHWPlatform >::init ( )
inlinenoexceptinherited

Initialize the hardware platform.

The init_() function must be implemented by the derived class.

Perform any hardware platform initialization steps, such as preparing peripherals for use, setting up callbacks, etc.

◆ init_()

void UnitTestHWPlatform::init_ ( )
inlinenoexcept

◆ initProcessor()

void embvm::VirtualHwPlatformBase< UnitTestHWPlatform >::initProcessor ( )
inlinenoexceptinherited

Initialize the processor.

The initProcessor_() function must be implemented by the derived class.

Perform any steps necessary for initializing the processor & processor peripheral devices for use.

Note that this is only intended to be processor initialization. Platform initialization nis handled by the init() function.

This function will likely invoke the VirtualProcessor::init() function, but the order and actual initialization process is left to the derived class.

◆ initProcessor_()

void UnitTestHWPlatform::initProcessor_ ( )
inlinenoexcept

◆ name()

constexpr const std::string_view& embvm::VirtualHwPlatformBase< UnitTestHWPlatform >::name ( ) const
inlinenoexceptinherited

Returns the Virtual HW Platform's name.

◆ name_cstr()

constexpr const char* embvm::VirtualHwPlatformBase< UnitTestHWPlatform >::name_cstr ( ) const
inlinenoexceptinherited

Returns the platform name as a cstring for C API compatibility.

◆ shutdown()

void embvm::VirtualHwPlatformBase< UnitTestHWPlatform >::shutdown ( )
inlinenoexceptinherited

Shutdown the system.

The shutdown_() function must be implemented by the derived class.

If your platform supports shutdown capability, take the proper steps to initiate a shutdown.

If the platform does not support shutdown capability, implement your shutdown_() function as an assert to notify users trying to call this API. You could also leave the shutdown_() function undefined. Anyone who calls the shutdown() function on a platform with an undefined shutdown_() function will encounter a compiler error.

The shutdown function is not expected to return.

◆ shutdown_()

void UnitTestHWPlatform::shutdown_ ( )
inlinenoexcept

References assert.

◆ soft_reset()

void embvm::VirtualHwPlatformBase< UnitTestHWPlatform >::soft_reset ( )
inlinenoexceptinherited

Perform a soft reset of the system (chip reset)

The soft_reset_() function must be implemnted by the derived class.

A soft reset is intended to reset the program to the beginning without performing a full power cycle.

A good strategy is to just call virtual processor's reset() function, if one is provided.

◆ soft_reset_()

void UnitTestHWPlatform::soft_reset_ ( )
inlinenoexcept

Referenced by hard_reset_().

Member Data Documentation

◆ driver_

test::TestDriverBase UnitTestHWPlatform::driver_ = test::TestDriverBase("Undefined test driver")
private

We declare a single test driver to exercise the framework.


The documentation for this class was generated from the following file: