Merge pull request #3470 from wwylele/news-framework

Service/NEWS: convert to ServiceFramework
This commit is contained in:
Ben 2018-03-09 17:52:21 +01:00 committed by GitHub
commit 42d68d6ea4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 46 additions and 62 deletions

View file

@ -3,7 +3,6 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/hle/service/news/news.h"
#include "core/hle/service/news/news_s.h" #include "core/hle/service/news/news_s.h"
#include "core/hle/service/news/news_u.h" #include "core/hle/service/news/news_u.h"
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
@ -11,15 +10,11 @@
namespace Service { namespace Service {
namespace NEWS { namespace NEWS {
void Init() { void InstallInterfaces(SM::ServiceManager& service_manager) {
using namespace Kernel; std::make_shared<NEWS_S>()->InstallAsService(service_manager);
std::make_shared<NEWS_U>()->InstallAsService(service_manager);
AddService(new NEWS_S_Interface);
AddService(new NEWS_U_Interface);
} }
void Shutdown() {}
} // namespace NEWS } // namespace NEWS
} // namespace Service } // namespace Service

View file

@ -7,11 +7,7 @@
namespace Service { namespace Service {
namespace NEWS { namespace NEWS {
/// Initialize NEWS service(s) void InstallInterfaces(SM::ServiceManager& service_manager);
void Init();
/// Shutdown NEWS service(s)
void Shutdown();
} // namespace NEWS } // namespace NEWS
} // namespace Service } // namespace Service

View file

@ -3,23 +3,13 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "core/hle/ipc_helpers.h" #include "core/hle/ipc_helpers.h"
#include "core/hle/service/news/news.h"
#include "core/hle/service/news/news_s.h" #include "core/hle/service/news/news_s.h"
namespace Service { namespace Service {
namespace NEWS { namespace NEWS {
/** void NEWS_S::GetTotalNotifications(Kernel::HLERequestContext& ctx) {
* GetTotalNotifications service function. IPC::RequestParser rp(ctx, 0x5, 0, 0);
* Inputs:
* 0 : 0x00050000
* Outputs:
* 0 : 0x00050080
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Number of notifications
*/
static void GetTotalNotifications(Service::Interface* self) {
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x5, 0, 0);
LOG_WARNING(Service, "(STUBBED) called"); LOG_WARNING(Service, "(STUBBED) called");
@ -29,24 +19,23 @@ static void GetTotalNotifications(Service::Interface* self) {
rb.Push<u32>(0); rb.Push<u32>(0);
} }
const Interface::FunctionInfo FunctionTable[] = { NEWS_S::NEWS_S() : ServiceFramework("news:s", 2) {
{0x000100C6, nullptr, "AddNotification"}, const FunctionInfo functions[] = {
{0x00050000, GetTotalNotifications, "GetTotalNotifications"}, {0x000100C6, nullptr, "AddNotification"},
{0x00060042, nullptr, "SetNewsDBHeader"}, {0x00050000, &NEWS_S::GetTotalNotifications, "GetTotalNotifications"},
{0x00070082, nullptr, "SetNotificationHeader"}, {0x00060042, nullptr, "SetNewsDBHeader"},
{0x00080082, nullptr, "SetNotificationMessage"}, {0x00070082, nullptr, "SetNotificationHeader"},
{0x00090082, nullptr, "SetNotificationImage"}, {0x00080082, nullptr, "SetNotificationMessage"},
{0x000A0042, nullptr, "GetNewsDBHeader"}, {0x00090082, nullptr, "SetNotificationImage"},
{0x000B0082, nullptr, "GetNotificationHeader"}, {0x000A0042, nullptr, "GetNewsDBHeader"},
{0x000C0082, nullptr, "GetNotificationMessage"}, {0x000B0082, nullptr, "GetNotificationHeader"},
{0x000D0082, nullptr, "GetNotificationImage"}, {0x000C0082, nullptr, "GetNotificationMessage"},
{0x000E0040, nullptr, "SetInfoLEDPattern"}, {0x000D0082, nullptr, "GetNotificationImage"},
{0x00120082, nullptr, "GetNotificationHeaderOther"}, {0x000E0040, nullptr, "SetInfoLEDPattern"},
{0x00130000, nullptr, "WriteNewsDBSavedata"}, {0x00120082, nullptr, "GetNotificationHeaderOther"},
}; {0x00130000, nullptr, "WriteNewsDBSavedata"},
};
NEWS_S_Interface::NEWS_S_Interface() { RegisterHandlers(functions);
Register(FunctionTable);
} }
} // namespace NEWS } // namespace NEWS

View file

@ -4,18 +4,27 @@
#pragma once #pragma once
#include <memory>
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
namespace Service { namespace Service {
namespace NEWS { namespace NEWS {
class NEWS_S_Interface : public Service::Interface { class NEWS_S final : public ServiceFramework<NEWS_S> {
public: public:
NEWS_S_Interface(); NEWS_S();
std::string GetPortName() const override { private:
return "news:s"; /**
} * GetTotalNotifications service function.
* Inputs:
* 0 : 0x00050000
* Outputs:
* 0 : 0x00050080
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Number of notifications
*/
void GetTotalNotifications(Kernel::HLERequestContext& ctx);
}; };
} // namespace NEWS } // namespace NEWS

View file

@ -7,12 +7,11 @@
namespace Service { namespace Service {
namespace NEWS { namespace NEWS {
const Interface::FunctionInfo FunctionTable[] = { NEWS_U::NEWS_U() : ServiceFramework("news:u", 1) {
{0x000100C6, nullptr, "AddNotification"}, const FunctionInfo functions[] = {
}; {0x000100C8, nullptr, "AddNotification"},
};
NEWS_U_Interface::NEWS_U_Interface() { RegisterHandlers(functions);
Register(FunctionTable);
} }
} // namespace NEWS } // namespace NEWS

View file

@ -4,18 +4,15 @@
#pragma once #pragma once
#include <memory>
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
namespace Service { namespace Service {
namespace NEWS { namespace NEWS {
class NEWS_U_Interface : public Service::Interface { class NEWS_U final : public ServiceFramework<NEWS_U> {
public: public:
NEWS_U_Interface(); NEWS_U();
std::string GetPortName() const override {
return "news:u";
}
}; };
} // namespace NEWS } // namespace NEWS

View file

@ -250,7 +250,7 @@ void Init() {
IR::InstallInterfaces(*SM::g_service_manager); IR::InstallInterfaces(*SM::g_service_manager);
MVD::Init(); MVD::Init();
NDM::Init(); NDM::Init();
NEWS::Init(); NEWS::InstallInterfaces(*SM::g_service_manager);
NFC::Init(); NFC::Init();
NIM::InstallInterfaces(*SM::g_service_manager); NIM::InstallInterfaces(*SM::g_service_manager);
NWM::Init(); NWM::Init();
@ -272,7 +272,6 @@ void Init() {
/// Shutdown ServiceManager /// Shutdown ServiceManager
void Shutdown() { void Shutdown() {
NFC::Shutdown(); NFC::Shutdown();
NEWS::Shutdown();
NDM::Shutdown(); NDM::Shutdown();
DLP::Shutdown(); DLP::Shutdown();
CFG::Shutdown(); CFG::Shutdown();