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.
#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_u.h"
#include "core/hle/service/service.h"
@ -11,15 +10,11 @@
namespace Service {
namespace NEWS {
void Init() {
using namespace Kernel;
AddService(new NEWS_S_Interface);
AddService(new NEWS_U_Interface);
void InstallInterfaces(SM::ServiceManager& service_manager) {
std::make_shared<NEWS_S>()->InstallAsService(service_manager);
std::make_shared<NEWS_U>()->InstallAsService(service_manager);
}
void Shutdown() {}
} // namespace NEWS
} // namespace Service

View File

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

View File

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

View File

@ -4,18 +4,27 @@
#pragma once
#include <memory>
#include "core/hle/service/service.h"
namespace Service {
namespace NEWS {
class NEWS_S_Interface : public Service::Interface {
class NEWS_S final : public ServiceFramework<NEWS_S> {
public:
NEWS_S_Interface();
NEWS_S();
std::string GetPortName() const override {
return "news:s";
}
private:
/**
* 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

View File

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

View File

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

View File

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