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() {
|
2021-10-10 07:14:06 +00:00
|
|
|
m_heap_handle = lmem::CreateExpHeap(m_heap_buffer, sizeof(m_heap_buffer), lmem::CreateOption_None);
|
|
|
|
m_allocator.Attach(m_heap_handle);
|
2020-11-02 07:04:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ManagerImpl::~ManagerImpl() {
|
2021-10-10 07:14:06 +00:00
|
|
|
lmem::DestroyExpHeap(m_heap_handle);
|
2020-11-02 07:04:19 +00:00
|
|
|
}
|
|
|
|
|
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 */
|
2021-10-06 22:20:48 +00:00
|
|
|
AMS_UNUSED(out, channel);
|
2020-11-02 07:04:19 +00:00
|
|
|
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) {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(this->OpenSession2(out, ConvertToDeviceCode(channel_name)));
|
2020-11-02 07:04:19 +00:00
|
|
|
}
|
|
|
|
|
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-10-10 07:14:06 +00:00
|
|
|
auto session = Factory::CreateSharedEmplaced<pwm::sf::IChannelSession, ChannelSessionImpl>(std::addressof(m_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);
|
2022-03-26 07:14:36 +00:00
|
|
|
R_SUCCEED();
|
2020-11-02 07:04:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|