Numworks Epsilon  1.4.1
Graphing Calculator Operating System
platform_info.cpp
Go to the documentation of this file.
1 #include <ion.h>
2 #include <assert.h>
3 
4 #ifndef PATCH_LEVEL
5 #error This file expects PATCH_LEVEL to be defined
6 #endif
7 
8 #ifndef EPSILON_VERSION
9 #error This file expects EPSILON_VERSION to be defined
10 #endif
11 
12 #ifndef HEADER_SECTION
13 #define HEADER_SECTION
14 #endif
15 
16 namespace Ion {
17 extern char staticStorageArea[];
18 }
19 constexpr void * storageAddress = &(Ion::staticStorageArea);
20 
21 class PlatformInfo {
22 public:
23  constexpr PlatformInfo() :
24  m_header(Magic),
25  m_version{EPSILON_VERSION},
26  m_patchLevel{PATCH_LEVEL},
27  m_storageAddress(storageAddress),
28  m_footer(Magic) { }
29  const char * version() const {
30  assert(m_storageAddress != nullptr);
31  assert(m_header == Magic);
32  assert(m_footer == Magic);
33  return m_version;
34  }
35  const char * patchLevel() const {
36  assert(m_storageAddress != nullptr);
37  assert(m_header == Magic);
38  assert(m_footer == Magic);
39  return m_patchLevel;
40  }
41 private:
42  constexpr static uint32_t Magic = 0xDEC00DF0;
43  uint32_t m_header;
44  const char m_version[8];
45  const char m_patchLevel[8];
46  void * m_storageAddress;
47  uint32_t m_footer;
48 };
49 
51 
52 const char * Ion::softwareVersion() {
53  return platform_infos.version();
54 }
55 
56 const char * Ion::patchLevel() {
57  return platform_infos.patchLevel();
58 }
char staticStorageArea[]
Definition: storage.cpp:20
#define assert(e)
Definition: assert.h:9
const char * patchLevel()
#define HEADER_SECTION
const char * version() const
unsigned int uint32_t
Definition: stdint.h:6
constexpr PlatformInfo()
const char * patchLevel() const
constexpr void * storageAddress
constexpr PlatformInfo HEADER_SECTION platform_infos
const char * softwareVersion()
Definition: backlight.h:6