strat: use m_ for member variables

This commit is contained in:
Michael Scire
2021-10-10 00:14:06 -07:00
parent ce28591ab2
commit a595c232b9
425 changed files with 8531 additions and 8484 deletions

View File

@@ -21,30 +21,30 @@ namespace ams::gpio::driver::board::nintendo::nx::impl {
void InterruptEventHandler::Initialize(DriverImpl *drv, os::InterruptName intr, int ctlr) {
/* Set fields. */
this->driver = drv;
this->interrupt_name = intr;
this->controller_number = ctlr;
m_driver = drv;
m_interrupt_name = intr;
m_controller_number = ctlr;
/* Initialize interrupt event. */
os::InitializeInterruptEvent(std::addressof(this->interrupt_event), intr, os::EventClearMode_ManualClear);
os::InitializeInterruptEvent(std::addressof(m_interrupt_event), intr, os::EventClearMode_ManualClear);
/* Initialize base. */
IEventHandler::Initialize(std::addressof(this->interrupt_event));
IEventHandler::Initialize(std::addressof(m_interrupt_event));
}
void InterruptEventHandler::HandleEvent() {
/* Lock the driver's interrupt mutex. */
std::scoped_lock lk(this->driver->interrupt_control_mutex);
std::scoped_lock lk(m_driver->m_interrupt_control_mutex);
/* Check each pad. */
bool found = false;
for (auto it = this->driver->interrupt_pad_list.begin(); !found && it != this->driver->interrupt_pad_list.end(); ++it) {
for (auto it = m_driver->m_interrupt_pad_list.begin(); !found && it != m_driver->m_interrupt_pad_list.end(); ++it) {
found = this->CheckAndHandleInterrupt(*it);
}
/* If we didn't find a pad, clear the interrupt event. */
if (!found) {
os::ClearInterruptEvent(std::addressof(this->interrupt_event));
os::ClearInterruptEvent(std::addressof(m_interrupt_event));
}
}
@@ -53,13 +53,13 @@ namespace ams::gpio::driver::board::nintendo::nx::impl {
const InternalGpioPadNumber pad_number = static_cast<InternalGpioPadNumber>(pad.GetPadNumber());
/* Check if the pad matches our controller number. */
if (this->controller_number != ConvertInternalGpioPadNumberToController(pad_number)) {
if (m_controller_number != ConvertInternalGpioPadNumberToController(pad_number)) {
return false;
}
/* Get the addresses of INT_STA, INT_ENB. */
const uintptr_t sta_address = GetGpioRegisterAddress(this->driver->gpio_virtual_address, GpioRegisterType_GPIO_INT_STA, pad_number);
const uintptr_t enb_address = GetGpioRegisterAddress(this->driver->gpio_virtual_address, GpioRegisterType_GPIO_INT_STA, pad_number);
const uintptr_t sta_address = GetGpioRegisterAddress(m_driver->m_gpio_virtual_address, GpioRegisterType_GPIO_INT_STA, pad_number);
const uintptr_t enb_address = GetGpioRegisterAddress(m_driver->m_gpio_virtual_address, GpioRegisterType_GPIO_INT_STA, pad_number);
const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number);
/* Check if both STA and ENB are set. */
@@ -73,10 +73,10 @@ namespace ams::gpio::driver::board::nintendo::nx::impl {
/* Disable the interrupt on the pad. */
pad.SetInterruptEnabled(false);
this->driver->RemoveInterruptPad(std::addressof(pad));
m_driver->RemoveInterruptPad(std::addressof(pad));
/* Clear the interrupt event. */
os::ClearInterruptEvent(std::addressof(this->interrupt_event));
os::ClearInterruptEvent(std::addressof(m_interrupt_event));
/* Signal the pad's bound event. */
pad.SignalInterruptBoundEvent();
@@ -84,15 +84,15 @@ namespace ams::gpio::driver::board::nintendo::nx::impl {
return true;
}
DriverImpl::DriverImpl(dd::PhysicalAddress reg_paddr, size_t size) : gpio_physical_address(reg_paddr), gpio_virtual_address(), suspend_handler(this), interrupt_pad_list(), interrupt_control_mutex() {
DriverImpl::DriverImpl(dd::PhysicalAddress reg_paddr, size_t size) : m_gpio_physical_address(reg_paddr), m_gpio_virtual_address(), m_suspend_handler(this), m_interrupt_pad_list(), m_interrupt_control_mutex() {
/* Get the corresponding virtual address for our physical address. */
this->gpio_virtual_address = dd::QueryIoMapping(reg_paddr, size);
AMS_ABORT_UNLESS(this->gpio_virtual_address != 0);
m_gpio_virtual_address = dd::QueryIoMapping(reg_paddr, size);
AMS_ABORT_UNLESS(m_gpio_virtual_address != 0);
}
void DriverImpl::InitializeDriver() {
/* Initialize our suspend handler. */
this->suspend_handler.Initialize(this->gpio_virtual_address);
m_suspend_handler.Initialize(m_gpio_virtual_address);
}
void DriverImpl::FinalizeDriver() {
@@ -107,7 +107,7 @@ namespace ams::gpio::driver::board::nintendo::nx::impl {
const InternalGpioPadNumber pad_number = pad->GetPadNumber();
/* Configure the pad as GPIO by modifying the appropriate bit in CNF. */
const uintptr_t pad_address = GetGpioRegisterAddress(this->gpio_virtual_address, GpioRegisterType_GPIO_CNF, pad_number);
const uintptr_t pad_address = GetGpioRegisterAddress(m_gpio_virtual_address, GpioRegisterType_GPIO_CNF, pad_number);
const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number);
SetMaskedBit(pad_address, pad_index, 1);
@@ -134,7 +134,7 @@ namespace ams::gpio::driver::board::nintendo::nx::impl {
const InternalGpioPadNumber pad_number = pad->GetPadNumber();
/* Get the pad direction by reading the appropriate bit in OE */
const uintptr_t pad_address = GetGpioRegisterAddress(this->gpio_virtual_address, GpioRegisterType_GPIO_OE, pad_number);
const uintptr_t pad_address = GetGpioRegisterAddress(m_gpio_virtual_address, GpioRegisterType_GPIO_OE, pad_number);
const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number);
if (reg::Read(pad_address, 1u << pad_index) != 0) {
@@ -155,7 +155,7 @@ namespace ams::gpio::driver::board::nintendo::nx::impl {
const InternalGpioPadNumber pad_number = pad->GetPadNumber();
/* Configure the pad direction by modifying the appropriate bit in OE */
const uintptr_t pad_address = GetGpioRegisterAddress(this->gpio_virtual_address, GpioRegisterType_GPIO_OE, pad_number);
const uintptr_t pad_address = GetGpioRegisterAddress(m_gpio_virtual_address, GpioRegisterType_GPIO_OE, pad_number);
const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number);
SetMaskedBit(pad_address, pad_index, direction);
@@ -174,7 +174,7 @@ namespace ams::gpio::driver::board::nintendo::nx::impl {
const InternalGpioPadNumber pad_number = pad->GetPadNumber();
/* Get the pad value by reading the appropriate bit in IN */
const uintptr_t pad_address = GetGpioRegisterAddress(this->gpio_virtual_address, GpioRegisterType_GPIO_IN, pad_number);
const uintptr_t pad_address = GetGpioRegisterAddress(m_gpio_virtual_address, GpioRegisterType_GPIO_IN, pad_number);
const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number);
if (reg::Read(pad_address, 1u << pad_index) != 0) {
@@ -194,7 +194,7 @@ namespace ams::gpio::driver::board::nintendo::nx::impl {
const InternalGpioPadNumber pad_number = pad->GetPadNumber();
/* Configure the pad value by modifying the appropriate bit in IN */
const uintptr_t pad_address = GetGpioRegisterAddress(this->gpio_virtual_address, GpioRegisterType_GPIO_IN, pad_number);
const uintptr_t pad_address = GetGpioRegisterAddress(m_gpio_virtual_address, GpioRegisterType_GPIO_IN, pad_number);
const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number);
SetMaskedBit(pad_address, pad_index, value);
@@ -213,7 +213,7 @@ namespace ams::gpio::driver::board::nintendo::nx::impl {
const InternalGpioPadNumber pad_number = pad->GetPadNumber();
/* Get the pad mode by reading the appropriate bits in INT_LVL */
const uintptr_t pad_address = GetGpioRegisterAddress(this->gpio_virtual_address, GpioRegisterType_GPIO_INT_LVL, pad_number);
const uintptr_t pad_address = GetGpioRegisterAddress(m_gpio_virtual_address, GpioRegisterType_GPIO_INT_LVL, pad_number);
const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number);
switch ((reg::Read(pad_address) >> pad_index) & InternalInterruptMode_Mask) {
@@ -236,7 +236,7 @@ namespace ams::gpio::driver::board::nintendo::nx::impl {
const InternalGpioPadNumber pad_number = pad->GetPadNumber();
/* Configure the pad mode by modifying the appropriate bits in INT_LVL */
const uintptr_t pad_address = GetGpioRegisterAddress(this->gpio_virtual_address, GpioRegisterType_GPIO_INT_LVL, pad_number);
const uintptr_t pad_address = GetGpioRegisterAddress(m_gpio_virtual_address, GpioRegisterType_GPIO_INT_LVL, pad_number);
const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number);
switch (mode) {

View File

@@ -26,14 +26,14 @@ namespace ams::gpio::driver::board::nintendo::nx::impl {
class InterruptEventHandler : public ddsf::IEventHandler {
private:
DriverImpl *driver;
os::InterruptName interrupt_name;
os::InterruptEventType interrupt_event;
int controller_number;
DriverImpl *m_driver;
os::InterruptName m_interrupt_name;
os::InterruptEventType m_interrupt_event;
int m_controller_number;
private:
bool CheckAndHandleInterrupt(TegraPad &pad);
public:
InterruptEventHandler() : IEventHandler(), driver(nullptr), interrupt_name(), interrupt_event(), controller_number() { /* ... */ }
InterruptEventHandler() : IEventHandler(), m_driver(nullptr), m_interrupt_name(), m_interrupt_event(), m_controller_number() { /* ... */ }
void Initialize(DriverImpl *drv, os::InterruptName intr, int ctlr);
@@ -46,11 +46,11 @@ namespace ams::gpio::driver::board::nintendo::nx::impl {
AMS_DDSF_CASTABLE_TRAITS(ams::gpio::driver::board::nintendo::nx::impl::DriverImpl, ::ams::gpio::driver::IGpioDriver);
friend class InterruptEventHandler;
private:
dd::PhysicalAddress gpio_physical_address;
uintptr_t gpio_virtual_address;
SuspendHandler suspend_handler;
TegraPad::InterruptList interrupt_pad_list;
mutable os::SdkMutex interrupt_control_mutex;
dd::PhysicalAddress m_gpio_physical_address;
uintptr_t m_gpio_virtual_address;
SuspendHandler m_suspend_handler;
TegraPad::InterruptList m_interrupt_pad_list;
mutable os::SdkMutex m_interrupt_control_mutex;
public:
DriverImpl(dd::PhysicalAddress reg_paddr, size_t size);
@@ -76,7 +76,7 @@ namespace ams::gpio::driver::board::nintendo::nx::impl {
virtual os::SdkMutex &GetInterruptControlMutex(const Pad &pad) const override {
AMS_UNUSED(pad);
return this->interrupt_control_mutex;
return m_interrupt_control_mutex;
}
virtual Result GetDebounceEnabled(bool *out, Pad *pad) const override;
@@ -114,14 +114,14 @@ namespace ams::gpio::driver::board::nintendo::nx::impl {
void AddInterruptPad(TegraPad *pad) {
AMS_ASSERT(pad != nullptr);
if (!pad->IsLinkedToInterruptBoundPadList()) {
this->interrupt_pad_list.push_back(*pad);
m_interrupt_pad_list.push_back(*pad);
}
}
void RemoveInterruptPad(TegraPad *pad) {
AMS_ASSERT(pad != nullptr);
if (pad->IsLinkedToInterruptBoundPadList()) {
this->interrupt_pad_list.erase(this->interrupt_pad_list.iterator_to(*pad));
m_interrupt_pad_list.erase(m_interrupt_pad_list.iterator_to(*pad));
}
}
};

View File

@@ -20,7 +20,7 @@ namespace ams::gpio::driver::board::nintendo::nx::impl {
void SuspendHandler::Initialize(uintptr_t gpio_vaddr) {
/* Set our gpio virtual address. */
this->gpio_virtual_address = gpio_vaddr;
m_gpio_virtual_address = gpio_vaddr;
/* Ensure that we can use the wec library. */
ams::wec::Initialize();

View File

@@ -54,21 +54,21 @@ namespace ams::gpio::driver::board::nintendo::nx::impl {
}
};
private:
ddsf::IDriver &driver;
uintptr_t gpio_virtual_address;
RegisterValues register_values[GpioPadPort_Count];
ValuesForSleepState values_for_sleep_state[GpioPadPort_Count];
ddsf::IDriver &m_driver;
uintptr_t m_gpio_virtual_address;
RegisterValues m_register_values[GpioPadPort_Count];
ValuesForSleepState m_values_for_sleep_state[GpioPadPort_Count];
private:
uintptr_t GetGpioVirtualAddress() const {
AMS_ASSERT(this->gpio_virtual_address != 0);
return this->gpio_virtual_address;
AMS_ASSERT(m_gpio_virtual_address != 0);
return m_gpio_virtual_address;
}
public:
explicit SuspendHandler(ddsf::IDriver *drv) : driver(*drv), gpio_virtual_address(0) {
for (auto &rv : this->register_values) {
explicit SuspendHandler(ddsf::IDriver *drv) : m_driver(*drv), m_gpio_virtual_address(0) {
for (auto &rv : m_register_values) {
rv.Reset();
}
for (auto &v : this->values_for_sleep_state) {
for (auto &v : m_values_for_sleep_state) {
v.Reset();
}
}

View File

@@ -351,26 +351,26 @@ namespace ams::gpio::driver::board::nintendo::nx::impl {
private:
using Base = ::ams::gpio::driver::Pad;
private:
util::IntrusiveListNode interrupt_list_node;
PadInfo info;
PadStatus status;
util::IntrusiveListNode m_interrupt_list_node;
PadInfo m_info;
PadStatus m_status;
public:
using InterruptListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&TegraPad::interrupt_list_node>;
using InterruptListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&TegraPad::m_interrupt_list_node>;
using InterruptList = typename InterruptListTraits::ListType;
friend class util::IntrusiveList<TegraPad, util::IntrusiveListMemberTraitsDeferredAssert<&TegraPad::interrupt_list_node>>;
friend class util::IntrusiveList<TegraPad, util::IntrusiveListMemberTraitsDeferredAssert<&TegraPad::m_interrupt_list_node>>;
public:
TegraPad() : Pad(), interrupt_list_node(), info(), status() { /* ... */ }
TegraPad() : Pad(), m_interrupt_list_node(), m_info(), m_status() { /* ... */ }
const PadInfo &GetInfo() const { return this->info; }
PadStatus &GetStatus() { return this->status; }
const PadInfo &GetInfo() const { return m_info; }
PadStatus &GetStatus() { return m_status; }
void SetParameters(int pad, const PadInfo &i) {
Base::SetPadNumber(pad);
this->info = i;
m_info = i;
}
bool IsLinkedToInterruptBoundPadList() const {
return this->interrupt_list_node.IsLinked();
return m_interrupt_list_node.IsLinked();
}
};

View File

@@ -73,8 +73,8 @@ namespace ams::gpio::driver::impl {
auto ev_guard = SCOPE_GUARD { os::DestroySystemEvent(event); };
/* Attach the event to our holder. */
this->event_holder.AttachEvent(event);
auto hl_guard = SCOPE_GUARD { this->event_holder.DetachEvent(); };
m_event_holder.AttachEvent(event);
auto hl_guard = SCOPE_GUARD { m_event_holder.DetachEvent(); };
/* Update interrupt needed. */
R_TRY(this->UpdateDriverInterruptEnabled());
@@ -97,7 +97,7 @@ namespace ams::gpio::driver::impl {
}
/* Detach and destroy the event */
os::DestroySystemEvent(this->event_holder.DetachEvent());
os::DestroySystemEvent(m_event_holder.DetachEvent());
/* Update interrupt needed. */
R_ABORT_UNLESS(this->UpdateDriverInterruptEnabled());
@@ -143,7 +143,7 @@ namespace ams::gpio::driver::impl {
AMS_ASSERT(driver.GetInterruptControlMutex(pad).IsLockedByCurrentThread());
AMS_UNUSED(pad, driver);
if (auto *event = this->event_holder.GetSystemEvent(); event != nullptr) {
if (auto *event = m_event_holder.GetSystemEvent(); event != nullptr) {
os::SignalSystemEvent(event);
}
}

View File

@@ -20,82 +20,82 @@ namespace ams::gpio {
class RemotePadSessionImpl {
private:
::GpioPadSession srv;
::GpioPadSession m_srv;
public:
RemotePadSessionImpl(::GpioPadSession &p) : srv(p) { /* ... */ }
RemotePadSessionImpl(::GpioPadSession &p) : m_srv(p) { /* ... */ }
~RemotePadSessionImpl() { ::gpioPadClose(std::addressof(this->srv)); }
~RemotePadSessionImpl() { ::gpioPadClose(std::addressof(m_srv)); }
public:
/* Actual commands. */
Result SetDirection(gpio::Direction direction) {
return ::gpioPadSetDirection(std::addressof(this->srv), static_cast<::GpioDirection>(static_cast<u32>(direction)));
return ::gpioPadSetDirection(std::addressof(m_srv), static_cast<::GpioDirection>(static_cast<u32>(direction)));
}
Result GetDirection(ams::sf::Out<gpio::Direction> out) {
static_assert(sizeof(gpio::Direction) == sizeof(::GpioDirection));
return ::gpioPadGetDirection(std::addressof(this->srv), reinterpret_cast<::GpioDirection *>(out.GetPointer()));
return ::gpioPadGetDirection(std::addressof(m_srv), reinterpret_cast<::GpioDirection *>(out.GetPointer()));
}
Result SetInterruptMode(gpio::InterruptMode mode) {
return ::gpioPadSetInterruptMode(std::addressof(this->srv), static_cast<::GpioInterruptMode>(static_cast<u32>(mode)));
return ::gpioPadSetInterruptMode(std::addressof(m_srv), static_cast<::GpioInterruptMode>(static_cast<u32>(mode)));
}
Result GetInterruptMode(ams::sf::Out<gpio::InterruptMode> out) {
static_assert(sizeof(gpio::InterruptMode) == sizeof(::GpioInterruptMode));
return ::gpioPadGetInterruptMode(std::addressof(this->srv), reinterpret_cast<::GpioInterruptMode *>(out.GetPointer()));
return ::gpioPadGetInterruptMode(std::addressof(m_srv), reinterpret_cast<::GpioInterruptMode *>(out.GetPointer()));
}
Result SetInterruptEnable(bool enable) {
return ::gpioPadSetInterruptEnable(std::addressof(this->srv), enable);
return ::gpioPadSetInterruptEnable(std::addressof(m_srv), enable);
}
Result GetInterruptEnable(ams::sf::Out<bool> out) {
return ::gpioPadGetInterruptEnable(std::addressof(this->srv), out.GetPointer());
return ::gpioPadGetInterruptEnable(std::addressof(m_srv), out.GetPointer());
}
Result GetInterruptStatus(ams::sf::Out<gpio::InterruptStatus> out) {
static_assert(sizeof(gpio::InterruptStatus) == sizeof(::GpioInterruptStatus));
return ::gpioPadGetInterruptStatus(std::addressof(this->srv), reinterpret_cast<::GpioInterruptStatus *>(out.GetPointer()));
return ::gpioPadGetInterruptStatus(std::addressof(m_srv), reinterpret_cast<::GpioInterruptStatus *>(out.GetPointer()));
}
Result ClearInterruptStatus() {
return ::gpioPadClearInterruptStatus(std::addressof(this->srv));
return ::gpioPadClearInterruptStatus(std::addressof(m_srv));
}
Result SetValue(gpio::GpioValue value) {
return ::gpioPadSetValue(std::addressof(this->srv), static_cast<::GpioValue>(static_cast<u32>(value)));
return ::gpioPadSetValue(std::addressof(m_srv), static_cast<::GpioValue>(static_cast<u32>(value)));
}
Result GetValue(ams::sf::Out<gpio::GpioValue> out) {
static_assert(sizeof(gpio::GpioValue) == sizeof(::GpioValue));
return ::gpioPadGetValue(std::addressof(this->srv), reinterpret_cast<::GpioValue *>(out.GetPointer()));
return ::gpioPadGetValue(std::addressof(m_srv), reinterpret_cast<::GpioValue *>(out.GetPointer()));
}
Result BindInterrupt(ams::sf::OutCopyHandle out) {
::Event ev;
R_TRY(::gpioPadBindInterrupt(std::addressof(this->srv), std::addressof(ev)));
R_TRY(::gpioPadBindInterrupt(std::addressof(m_srv), std::addressof(ev)));
out.SetValue(ev.revent, true);
return ResultSuccess();
}
Result UnbindInterrupt() {
return ::gpioPadUnbindInterrupt(std::addressof(this->srv));
return ::gpioPadUnbindInterrupt(std::addressof(m_srv));
}
Result SetDebounceEnabled(bool enable) {
return ::gpioPadSetDebounceEnabled(std::addressof(this->srv), enable);
return ::gpioPadSetDebounceEnabled(std::addressof(m_srv), enable);
}
Result GetDebounceEnabled(ams::sf::Out<bool> out) {
return ::gpioPadGetDebounceEnabled(std::addressof(this->srv), out.GetPointer());
return ::gpioPadGetDebounceEnabled(std::addressof(m_srv), out.GetPointer());
}
Result SetDebounceTime(s32 ms) {
return ::gpioPadSetDebounceTime(std::addressof(this->srv), ms);
return ::gpioPadSetDebounceTime(std::addressof(m_srv), ms);
}
Result GetDebounceTime(ams::sf::Out<s32> out) {
return ::gpioPadGetDebounceTime(std::addressof(this->srv), out.GetPointer());
return ::gpioPadGetDebounceTime(std::addressof(m_srv), out.GetPointer());
}
Result SetValueForSleepState(gpio::GpioValue value) {

View File

@@ -19,12 +19,12 @@
namespace ams::gpio::server {
ManagerImpl::ManagerImpl() {
this->heap_handle = lmem::CreateExpHeap(this->heap_buffer, sizeof(this->heap_buffer), lmem::CreateOption_None);
this->pad_allocator.Attach(this->heap_handle);
m_heap_handle = lmem::CreateExpHeap(m_heap_buffer, sizeof(m_heap_buffer), lmem::CreateOption_None);
m_pad_allocator.Attach(m_heap_handle);
}
ManagerImpl::~ManagerImpl() {
lmem::DestroyExpHeap(this->heap_handle);
lmem::DestroyExpHeap(m_heap_handle);
}
Result ManagerImpl::OpenSessionForDev(ams::sf::Out<ams::sf::SharedPointer<gpio::sf::IPadSession>> out, s32 pad_descriptor) {
@@ -69,7 +69,7 @@ namespace ams::gpio::server {
Result ManagerImpl::OpenSession2(ams::sf::Out<ams::sf::SharedPointer<gpio::sf::IPadSession>> out, DeviceCode device_code, ddsf::AccessMode access_mode) {
/* Allocate a session. */
auto session = Factory::CreateSharedEmplaced<gpio::sf::IPadSession, PadSessionImpl>(std::addressof(this->pad_allocator), this);
auto session = Factory::CreateSharedEmplaced<gpio::sf::IPadSession, PadSessionImpl>(std::addressof(m_pad_allocator), this);
/* Open the session. */
R_TRY(session.GetImpl().OpenSession(device_code, access_mode));

View File

@@ -24,9 +24,9 @@ namespace ams::gpio::server {
using Allocator = ams::sf::ExpHeapAllocator;
using Factory = ams::sf::ObjectFactory<Allocator::Policy>;
private:
lmem::HeapHandle heap_handle;
Allocator pad_allocator;
u8 heap_buffer[12_KB];
lmem::HeapHandle m_heap_handle;
Allocator m_pad_allocator;
u8 m_heap_buffer[12_KB];
public:
ManagerImpl();

View File

@@ -22,54 +22,54 @@ namespace ams::gpio::server {
class PadSessionImpl {
private:
ManagerImpl *parent; /* NOTE: this is an sf::SharedPointer<> in Nintendo's code. */
gpio::driver::GpioPadSession internal_pad_session;
bool has_session;
os::SystemEvent system_event;
ManagerImpl *m_parent; /* NOTE: this is an sf::SharedPointer<> in Nintendo's code. */
gpio::driver::GpioPadSession m_internal_pad_session;
bool m_has_session;
os::SystemEvent m_system_event;
public:
explicit PadSessionImpl(ManagerImpl *p) : parent(p), has_session(false) { /* ... */ }
explicit PadSessionImpl(ManagerImpl *p) : m_parent(p), m_has_session(false) { /* ... */ }
~PadSessionImpl() {
if (this->has_session) {
gpio::driver::CloseSession(std::addressof(this->internal_pad_session));
if (m_has_session) {
gpio::driver::CloseSession(std::addressof(m_internal_pad_session));
}
}
Result OpenSession(DeviceCode device_code, ddsf::AccessMode access_mode) {
AMS_ABORT_UNLESS(!this->has_session);
AMS_ABORT_UNLESS(!m_has_session);
R_TRY(gpio::driver::OpenSession(std::addressof(this->internal_pad_session), device_code, access_mode));
this->has_session = true;
R_TRY(gpio::driver::OpenSession(std::addressof(m_internal_pad_session), device_code, access_mode));
m_has_session = true;
return ResultSuccess();
}
public:
/* Actual commands. */
Result SetDirection(gpio::Direction direction) {
/* Validate our state. */
AMS_ASSERT(this->has_session);
AMS_ASSERT(m_has_session);
/* Validate the direction. */
R_UNLESS((direction == Direction_Input || direction == Direction_Output), gpio::ResultInvalidArgument());
/* Invoke the driver library. */
R_TRY(gpio::driver::SetDirection(std::addressof(this->internal_pad_session), direction));
R_TRY(gpio::driver::SetDirection(std::addressof(m_internal_pad_session), direction));
return ResultSuccess();
}
Result GetDirection(ams::sf::Out<gpio::Direction> out) {
/* Validate our state. */
AMS_ASSERT(this->has_session);
AMS_ASSERT(m_has_session);
/* Invoke the driver library. */
R_TRY(gpio::driver::GetDirection(out.GetPointer(), std::addressof(this->internal_pad_session)));
R_TRY(gpio::driver::GetDirection(out.GetPointer(), std::addressof(m_internal_pad_session)));
return ResultSuccess();
}
Result SetInterruptMode(gpio::InterruptMode mode) {
/* Validate our state. */
AMS_ASSERT(this->has_session);
AMS_ASSERT(m_has_session);
/* TODO */
AMS_UNUSED(mode);
@@ -78,7 +78,7 @@ namespace ams::gpio::server {
Result GetInterruptMode(ams::sf::Out<gpio::InterruptMode> out) {
/* Validate our state. */
AMS_ASSERT(this->has_session);
AMS_ASSERT(m_has_session);
/* TODO */
AMS_UNUSED(out);
@@ -87,7 +87,7 @@ namespace ams::gpio::server {
Result SetInterruptEnable(bool enable) {
/* Validate our state. */
AMS_ASSERT(this->has_session);
AMS_ASSERT(m_has_session);
/* TODO */
AMS_UNUSED(enable);
@@ -96,7 +96,7 @@ namespace ams::gpio::server {
Result GetInterruptEnable(ams::sf::Out<bool> out) {
/* Validate our state. */
AMS_ASSERT(this->has_session);
AMS_ASSERT(m_has_session);
/* TODO */
AMS_UNUSED(out);
@@ -105,7 +105,7 @@ namespace ams::gpio::server {
Result GetInterruptStatus(ams::sf::Out<gpio::InterruptStatus> out) {
/* Validate our state. */
AMS_ASSERT(this->has_session);
AMS_ASSERT(m_has_session);
/* TODO */
AMS_UNUSED(out);
@@ -114,7 +114,7 @@ namespace ams::gpio::server {
Result ClearInterruptStatus() {
/* Validate our state. */
AMS_ASSERT(this->has_session);
AMS_ASSERT(m_has_session);
/* TODO */
AMS_ABORT();
@@ -122,30 +122,30 @@ namespace ams::gpio::server {
Result SetValue(gpio::GpioValue value) {
/* Validate our state. */
AMS_ASSERT(this->has_session);
AMS_ASSERT(m_has_session);
/* Validate the value. */
R_UNLESS((value == GpioValue_Low || value == GpioValue_High), gpio::ResultInvalidArgument());
/* Invoke the driver library. */
R_TRY(gpio::driver::SetValue(std::addressof(this->internal_pad_session), value));
R_TRY(gpio::driver::SetValue(std::addressof(m_internal_pad_session), value));
return ResultSuccess();
}
Result GetValue(ams::sf::Out<gpio::GpioValue> out) {
/* Validate our state. */
AMS_ASSERT(this->has_session);
AMS_ASSERT(m_has_session);
/* Invoke the driver library. */
R_TRY(gpio::driver::GetValue(out.GetPointer(), std::addressof(this->internal_pad_session)));
R_TRY(gpio::driver::GetValue(out.GetPointer(), std::addressof(m_internal_pad_session)));
return ResultSuccess();
}
Result BindInterrupt(ams::sf::OutCopyHandle out) {
/* Validate our state. */
AMS_ASSERT(this->has_session);
AMS_ASSERT(m_has_session);
/* TODO */
AMS_UNUSED(out);
@@ -154,7 +154,7 @@ namespace ams::gpio::server {
Result UnbindInterrupt() {
/* Validate our state. */
AMS_ASSERT(this->has_session);
AMS_ASSERT(m_has_session);
/* TODO */
AMS_ABORT();
@@ -162,7 +162,7 @@ namespace ams::gpio::server {
Result SetDebounceEnabled(bool enable) {
/* Validate our state. */
AMS_ASSERT(this->has_session);
AMS_ASSERT(m_has_session);
/* TODO */
AMS_UNUSED(enable);
@@ -171,7 +171,7 @@ namespace ams::gpio::server {
Result GetDebounceEnabled(ams::sf::Out<bool> out) {
/* Validate our state. */
AMS_ASSERT(this->has_session);
AMS_ASSERT(m_has_session);
/* TODO */
AMS_UNUSED(out);
@@ -180,7 +180,7 @@ namespace ams::gpio::server {
Result SetDebounceTime(s32 ms) {
/* Validate our state. */
AMS_ASSERT(this->has_session);
AMS_ASSERT(m_has_session);
/* TODO */
AMS_UNUSED(ms);
@@ -189,7 +189,7 @@ namespace ams::gpio::server {
Result GetDebounceTime(ams::sf::Out<s32> out) {
/* Validate our state. */
AMS_ASSERT(this->has_session);
AMS_ASSERT(m_has_session);
/* TODO */
AMS_UNUSED(out);
@@ -198,7 +198,7 @@ namespace ams::gpio::server {
Result SetValueForSleepState(gpio::GpioValue value) {
/* Validate our state. */
AMS_ASSERT(this->has_session);
AMS_ASSERT(m_has_session);
/* TODO */
AMS_UNUSED(value);
@@ -207,7 +207,7 @@ namespace ams::gpio::server {
Result GetValueForSleepState(ams::sf::Out<gpio::GpioValue> out) {
/* Validate our state. */
AMS_ASSERT(this->has_session);
AMS_ASSERT(m_has_session);
/* TODO */
AMS_UNUSED(out);