Files
MuditaOS/source/main.cpp
Lucjan Bryndza 3780b4844c [EGD-5074] Add native fscore for emulator
This is a first commit when the emulator uses
the new filesystem core.

libiosyscall library read environment variable

IOSYSCALS_REDIRECT_TO_IMAGE

When  IOSYSCALS_REDIRECT_TO_IMAGE=1 all syscalls
are redirected to the image. If env is not defined
or set to 0 only paths are translated and redirected
to the native linux syscalls

[EGD-5074] Remove free rtox library

Remove unneeded fat library from the freertos

[EGD-5074] Fix freertos mutex as unique

Add freertos mutex in the unique_ptr for avoid inclusion of the
freertos.h

[EGD-5074] Remove frertos-fat submodule

Remove uneeded fat freertos submodule

[EGD-5074] Add handle types in the vfs_subsystem

Add handle types in the vfs subsystem

[EGD-5074] Add submodule for hashmap

Add submodule for hashmap

[EGD-5074] Add support for dirent

Add support for dirent for new filesystem

[EGD-5074] Fix mutex class

Remove mutex in header

[EGD-5074] Remove old vfs from file indexer

File indexer should be fixed for use new vfs

[EGD-5074] Fix unit test vfs

Remove unit tests vfs for clas

[EGD-5074] Add Posix implementation with new fs

Add posix implementation with new fs core

[EGD-5074] Fix stdio syscalls

Fix all stdio syscalls

[EGD-5074] Fix iosyscalls scan family

Fix iosyscalls scan family

[EGD-5074] Fix native API

Fix native api

Work in progress some minor fixes

[EGD-5074] Fix lib stdio

Fix lib stdio

[EGD-5074] fix lseek return value in fat driver

Fix lseek return value in the fat driver

[EGD-5074]  Unit test fix

Unittest fixes

[EGD-5074] Emulator syscalls

Signed-off-by: Lucjan Bryndza <lucjan.bryndza@mudita.com>
2021-01-04 16:04:33 +01:00

174 lines
7.0 KiB
C++

// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "config.h"
// applications
#include <application-antenna/ApplicationAntenna.hpp>
#include <application-call/ApplicationCall.hpp>
#include <application-calllog/ApplicationCallLog.hpp>
#include <application-desktop/ApplicationDesktop.hpp>
#include <application-messages/ApplicationMessages.hpp>
#include <application-notes/ApplicationNotes.hpp>
#include <application-phonebook/ApplicationPhonebook.hpp>
#include <application-settings/ApplicationSettings.hpp>
#include <application-settings-new/ApplicationSettings.hpp>
#include <application-special-input/ApplicationSpecialInput.hpp>
#include <application-calendar/ApplicationCalendar.hpp>
#include <application-music-player/ApplicationMusicPlayer.hpp>
#include <application-meditation/ApplicationMeditation.hpp>
#include <application-calculator/ApplicationCalculator.hpp>
#include <application-alarm-clock/ApplicationAlarmClock.hpp>
// services
#include <service-appmgr/model/ApplicationManager.hpp>
#include <service-audio/ServiceAudio.hpp>
#include <service-bluetooth/ServiceBluetooth.hpp>
#include <service-db/ServiceDB.hpp>
#include <service-evtmgr/Constants.hpp>
#include <service-evtmgr/EventManager.hpp>
#include <service-lwip/ServiceLwIP.hpp>
#include <service-time/ServiceTime.hpp>
#include <service-fileindexer/Constants.hpp>
#include <service-fileindexer/ServiceFileIndexer.hpp>
#if ENABLE_GSM == 1
#include <service-fota/ServiceFota.hpp>
#include <service-cellular/ServiceCellular.hpp>
#include <service-antenna/ServiceAntenna.hpp>
#endif
#include <bsp/bsp.hpp>
#include <Application.hpp>
#include <ApplicationLauncher.hpp>
#include <log/log.hpp>
#include <phonenumbers/phonenumberutil.h>
#include <source/version.hpp>
#include <SystemManager/SystemManager.hpp>
#include <thread.hpp>
#include <vfs.hpp>
#include <purefs/vfs_subsystem.hpp>
#include <memory>
#include <vector>
class vfs vfs;
int main()
{
#if SYSTEM_VIEW_ENABLED
SEGGER_SYSVIEW_Conf();
SEGGER_SYSVIEW_DisableEvents(SYSVIEW_EVTMASK_ISR_ENTER);
SEGGER_SYSVIEW_DisableEvents(SYSVIEW_EVTMASK_ISR_EXIT);
SEGGER_SYSVIEW_DisableEvents(SYSVIEW_EVTMASK_ISR_TO_SCHEDULER);
SEGGER_SYSVIEW_WaitForConnection();
SEGGER_SYSVIEW_Start();
#endif
bsp::BoardInit();
auto sysmgr = std::make_shared<sys::SystemManager>(5000);
purefs::subsystem::vfs_handle_t vfs;
sysmgr->StartSystem([sysmgr, &vfs]() {
/// force initialization of PhonenumberUtil because of its stack usage
/// otherwise we would end up with an init race and PhonenumberUtil could
/// be initiated in a task with stack not big enough to handle it
i18n::phonenumbers::PhoneNumberUtil::GetInstance();
vfs = purefs::subsystem::initialize();
int err = purefs::subsystem::mount_defaults();
if (err) {
LOG_FATAL("VFS subystem fatal error %i", err);
std::abort();
}
auto ret = true;
ret &=
sys::SystemManager::CreateService(std::make_shared<EventManager>(service::name::evt_manager), sysmgr.get());
#if ENABLE_FILEINDEXER_SERVICE
ret &= sys::SystemManager::CreateService(
std::make_shared<service::ServiceFileIndexer>(service::name::file_indexer), sysmgr.get());
#endif
ret &= sys::SystemManager::CreateService(std::make_shared<ServiceDB>(), sysmgr.get());
#if ENABLE_GSM == 0
// For now disable pernamenlty Service cellular when there is no GSM configured
LOG_INFO("ServiceCellular (GSM) - Disabled");
#else
LOG_INFO("ServiceCellular (GSM) - Enabling");
ret &= sys::SystemManager::CreateService(std::make_shared<ServiceAntenna>(), sysmgr.get());
ret &= sys::SystemManager::CreateService(std::make_shared<ServiceCellular>(), sysmgr.get());
ret &= sys::SystemManager::CreateService(std::make_shared<FotaService::Service>(), sysmgr.get());
#endif
ret &= sys::SystemManager::CreateService(std::make_shared<ServiceAudio>(), sysmgr.get());
ret &= sys::SystemManager::CreateService(std::make_shared<ServiceBluetooth>(), sysmgr.get());
ret &= sys::SystemManager::CreateService(std::make_shared<ServiceLwIP>(), sysmgr.get());
ret &= sys::SystemManager::CreateService(std::make_shared<ServiceDesktop>(), sysmgr.get());
ret &= sys::SystemManager::CreateService(std::make_shared<stm::ServiceTime>(), sysmgr.get());
// vector with launchers to applications
std::vector<std::unique_ptr<app::ApplicationLauncher>> applications;
#ifdef ENABLE_APP_DESKTOP
applications.push_back(app::CreateLauncher<app::ApplicationDesktop>(app::name_desktop, false));
#endif
#ifdef ENABLE_APP_CALL
applications.push_back(app::CreateLauncher<app::ApplicationCall>(app::name_call, false));
#endif
#ifdef ENABLE_APP_SETTINGS
applications.push_back(app::CreateLauncher<app::ApplicationSettings>(app::name_settings));
#endif
#ifdef ENABLE_APP_SETTINGS_NEW
applications.push_back(app::CreateLauncher<app::ApplicationSettingsNew>(app::name_settings_new));
#endif
#ifdef ENABLE_APP_NOTES
applications.push_back(app::CreateLauncher<app::ApplicationNotes>(app::name_notes));
#endif
#ifdef ENABLE_APP_CALLLOG
applications.push_back(app::CreateLauncher<app::ApplicationCallLog>(app::CallLogAppStr));
#endif
#ifdef ENABLE_APP_PHONEBOOK
applications.push_back(app::CreateLauncher<app::ApplicationPhonebook>(app::name_phonebook));
#endif
#ifdef ENABLE_APP_MESSAGES
applications.push_back(app::CreateLauncher<app::ApplicationMessages>(app::name_messages));
#endif
#ifdef ENABLE_APP_SPECIAL_INPUT
applications.push_back(app::CreateLauncher<app::ApplicationSpecialInput>(app::special_input, false));
#endif
#ifdef ENABLE_APP_ANTENNA
applications.push_back(app::CreateLauncher<app::ApplicationAntenna>(app::name_antenna));
#endif
#ifdef ENABLE_APP_CALENDAR
applications.push_back(app::CreateLauncher<app::ApplicationCalendar>(app::name_calendar));
#endif
#ifdef ENABLE_APP_MUSIC_PLAYER
applications.push_back(app::CreateLauncher<app::ApplicationMusicPlayer>(app::name_music_player));
#endif
#ifdef ENABLE_APP_MEDITATION
applications.push_back(app::CreateLauncher<app::ApplicationMeditation>(app::name_meditation));
#endif
#ifdef ENABLE_APP_CALCULATOR
applications.push_back(app::CreateLauncher<app::ApplicationCalculator>(app::name_calculator));
#endif
#ifdef ENABLE_APP_ALARM_CLOCK
applications.push_back(app::CreateLauncher<app::ApplicationAlarmClock>(app::name_alarm_clock));
#endif
// start application manager
ret &= sysmgr->CreateService(
std::make_shared<app::manager::ApplicationManager>(
app::manager::ApplicationManager::ServiceName, std::move(applications), app::name_desktop),
sysmgr.get());
return ret;
});
LOG_PRINTF("Launching PurePhone \n");
LOG_PRINTF("commit: %s tag: %s branch: %s\n", GIT_REV, GIT_TAG, GIT_BRANCH);
cpp_freertos::Thread::StartScheduler();
return 1;
}