Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OSAL singleton initialization to Os::init() #2947

Merged
merged 4 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Os/Cpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Cpu final : public CpuInterface {
//-----------------------------------------------------------------------------

//! \brief initialize the singleton
void init();
static void init();

//! \brief return singleton
static Cpu& getSingleton();
Expand Down
2 changes: 1 addition & 1 deletion Os/Memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Memory final : public MemoryInterface {
public:

//! \brief initialize the singleton
void init();
static void init();

//! \brief return singleton
static Memory& getSingleton();
Expand Down
10 changes: 7 additions & 3 deletions Os/Os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
#include "Os/Os.hpp"
#include "FpConfig.h"
#include "Os/Console.hpp"
#include "Os/Cpu.hpp"
#include "Os/FileSystem.hpp"
#include "Os/Memory.hpp"

namespace Os {

void init() {
// Console and FileSystem are singletons and must be initialized
(void)Os::Console::init();
(void)Os::FileSystem::init();
// Initialize all OSAL singletons
Os::Console::init();
Os::FileSystem::init();
Os::Cpu::init();
Os::Memory::init();
}

} // namespace Os
4 changes: 3 additions & 1 deletion Os/Os.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ struct UsedTotal {

}

//! \brief Initialization function for the OSAL layer
//! \brief Initialize the OS Abstraction Layer (OSAL)
//!
//! - Initialize all singletons for the OSAL modules that use the singleton pattern
void init();

} // namespace Os
Expand Down
Loading