Service/NEWS: convert to ServiceFramework

This commit is contained in:
wwylele 2018-03-04 20:47:18 +02:00
parent 3566987ecc
commit 61069d2b67
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,9 +19,10 @@ 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) {
const FunctionInfo functions[] = {
{0x000100C6, nullptr, "AddNotification"}, {0x000100C6, nullptr, "AddNotification"},
{0x00050000, GetTotalNotifications, "GetTotalNotifications"}, {0x00050000, &NEWS_S::GetTotalNotifications, "GetTotalNotifications"},
{0x00060042, nullptr, "SetNewsDBHeader"}, {0x00060042, nullptr, "SetNewsDBHeader"},
{0x00070082, nullptr, "SetNotificationHeader"}, {0x00070082, nullptr, "SetNotificationHeader"},
{0x00080082, nullptr, "SetNotificationMessage"}, {0x00080082, nullptr, "SetNotificationMessage"},
@ -43,10 +34,8 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x000E0040, nullptr, "SetInfoLEDPattern"}, {0x000E0040, nullptr, "SetInfoLEDPattern"},
{0x00120082, nullptr, "GetNotificationHeaderOther"}, {0x00120082, nullptr, "GetNotificationHeaderOther"},
{0x00130000, nullptr, "WriteNewsDBSavedata"}, {0x00130000, nullptr, "WriteNewsDBSavedata"},
}; };
RegisterHandlers(functions);
NEWS_S_Interface::NEWS_S_Interface() {
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) {
const FunctionInfo functions[] = {
{0x000100C8, nullptr, "AddNotification"}, {0x000100C8, nullptr, "AddNotification"},
}; };
RegisterHandlers(functions);
NEWS_U_Interface::NEWS_U_Interface() {
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();
FRD::Shutdown(); FRD::Shutdown();
DLP::Shutdown(); DLP::Shutdown();