F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
Cpu.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title Os/Cpu.hpp
3 // \brief common function implementations for Os::Cpu
4 // ======================================================================
5 #include "Os/Cpu.hpp"
6 #include "Fw/Types/Assert.hpp"
7 
8 namespace Os {
9 
10 Cpu::Cpu() : m_delegate(*CpuInterface::getDelegate(m_handle_storage)) {}
11 
13  m_delegate.~CpuInterface();
14 }
15 
16 void Cpu::init() {
17  (void) Cpu::getSingleton();
18 }
19 
21  static Cpu _singleton;
22  return _singleton;
23 }
24 
26  FW_ASSERT(&this->m_delegate == reinterpret_cast<CpuInterface*>(&this->m_handle_storage[0]));
27  return this->m_delegate._getCount(cpu_count);
28 }
29 
31  FW_ASSERT(&this->m_delegate == reinterpret_cast<CpuInterface*>(&this->m_handle_storage[0]));
32  return this->m_delegate._getTicks(ticks, cpu_index);
33 }
34 
36  FW_ASSERT(&this->m_delegate == reinterpret_cast<CpuInterface*>(&this->m_handle_storage[0]));
37  return this->m_delegate.getHandle();
38 }
39 
41  return Cpu::getSingleton()._getCount(cpu_count);
42 }
43 
45  return Cpu::getSingleton()._getTicks(ticks, cpu_index);
46 }
47 }
#define FW_ASSERT(...)
Definition: Assert.hpp:14
PlatformSizeType FwSizeType
Definition: FpConfig.h:35
Cpu variable handle parent.
Definition: Cpu.hpp:13
cpu implementation
Definition: Cpu.hpp:60
static void init()
initialize the singleton
Definition: Cpu.cpp:16
CpuHandle * getHandle() override
return the underlying cpu handle (implementation specific).
Definition: Cpu.cpp:35
Status _getCount(FwSizeType &cpu_count) override
Request the count of the CPUs detected by the system.
Definition: Cpu.cpp:25
Status _getTicks(Ticks &ticks, FwSizeType cpu_index) override
Get the CPU tick information for a given CPU.
Definition: Cpu.cpp:30
~Cpu() final
default virtual destructor
Definition: Cpu.cpp:12
static Status getTicks(Ticks &ticks, FwSizeType cpu_index)
Get the CPU tick information for a given CPU.
Definition: Cpu.cpp:44
static Cpu & getSingleton()
return singleton
Definition: Cpu.cpp:20
Cpu()
default constructor
Definition: Cpu.cpp:10
static Status getCount(FwSizeType &cpu_count)
Request the count of the CPUs detected by the system.
Definition: Cpu.cpp:40
interface for cpu implementation
Definition: Cpu.hpp:16
virtual Status _getCount(FwSizeType &cpu_count)=0
Request the count of the CPUs detected by the system.
virtual Status _getTicks(Ticks &ticks, FwSizeType cpu_index)=0
Get the CPU tick information for a given CPU.
virtual ~CpuInterface()=default
Default destructor.
virtual CpuHandle * getHandle()=0
return the underlying cpu handle (implementation specific).
Status
Generic OK/ERROR status.
Definition: Os.hpp:25
Generic used/total struct.
Definition: Os.hpp:31