2020-11-02 07:04:19 +00:00
|
|
|
/*
|
2021-10-04 19:59:10 +00:00
|
|
|
* Copyright (c) Atmosphère-NX
|
2020-11-02 07:04:19 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#include <stratosphere.hpp>
|
|
|
|
#include "pwm_server_manager_impl.hpp"
|
|
|
|
|
|
|
|
namespace ams::pwm::server {
|
|
|
|
|
2021-01-17 15:55:32 +00:00
|
|
|
ManagerImpl::ManagerImpl() {
|
2020-11-02 07:04:19 +00:00
|
|
|
this->heap_handle = lmem::CreateExpHeap(this->heap_buffer, sizeof(this->heap_buffer), lmem::CreateOption_None);
|
2021-01-17 15:55:32 +00:00
|
|
|
this->allocator.Attach(this->heap_handle);
|
2020-11-02 07:04:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ManagerImpl::~ManagerImpl() {
|
|
|
|
lmem::DestroyExpHeap(this->heap_handle);
|
|
|
|
}
|
|
|
|
|
2021-01-17 15:55:32 +00:00
|
|
|
Result ManagerImpl::OpenSessionForDev(ams::sf::Out<ams::sf::SharedPointer<pwm::sf::IChannelSession>> out, int channel) {
|
2020-11-02 07:04:19 +00:00
|
|
|
/* TODO */
|
|
|
|
AMS_ABORT();
|
|
|
|
}
|
|
|
|
|
2021-01-17 15:55:32 +00:00
|
|
|
Result ManagerImpl::OpenSession(ams::sf::Out<ams::sf::SharedPointer<pwm::sf::IChannelSession>> out, pwm::ChannelName channel_name) {
|
2020-11-02 07:04:19 +00:00
|
|
|
return this->OpenSession2(out, ConvertToDeviceCode(channel_name));
|
|
|
|
}
|
|
|
|
|
2021-01-17 15:55:32 +00:00
|
|
|
Result ManagerImpl::OpenSession2(ams::sf::Out<ams::sf::SharedPointer<pwm::sf::IChannelSession>> out, DeviceCode device_code) {
|
2020-11-02 07:04:19 +00:00
|
|
|
/* Allocate a session. */
|
2021-01-17 15:55:32 +00:00
|
|
|
auto session = Factory::CreateSharedEmplaced<pwm::sf::IChannelSession, ChannelSessionImpl>(std::addressof(this->allocator), this);
|
2020-11-02 07:04:19 +00:00
|
|
|
|
|
|
|
/* Open the session. */
|
2021-01-17 15:55:32 +00:00
|
|
|
R_TRY(session.GetImpl().OpenSession(device_code));
|
2020-11-02 07:04:19 +00:00
|
|
|
|
|
|
|
/* We succeeded. */
|
2021-01-17 15:55:32 +00:00
|
|
|
*out = std::move(session);
|
2020-11-02 07:04:19 +00:00
|
|
|
return ResultSuccess();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|