diff --git a/libraries/libmesosphere/include/mesosphere.hpp b/libraries/libmesosphere/include/mesosphere.hpp index f76a09ffa..433d40770 100644 --- a/libraries/libmesosphere/include/mesosphere.hpp +++ b/libraries/libmesosphere/include/mesosphere.hpp @@ -42,7 +42,6 @@ /* Core functionality. */ #include #include -#include #include #include #include @@ -51,12 +50,32 @@ #include #include +/* Miscellaneous objects. */ +#include +#include + /* Auto Objects. */ #include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include +/* More Miscellaneous objects. */ +#include + /* Supervisor Calls. */ #include diff --git a/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_k_debug.hpp b/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_k_debug.hpp new file mode 100644 index 000000000..fccf30c88 --- /dev/null +++ b/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_k_debug.hpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * 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 . + */ +#pragma once +#include +#include +#include + +namespace ams::kern { + + class KThread; + class KProcess; + +} + +namespace ams::kern::arm64 { + + class KDebug final : public KAutoObjectWithSlabHeapAndContainer { + MESOSPHERE_AUTOOBJECT_TRAITS(KDebug, KSynchronizationObject); + public: + /* TODO: This is a placeholder definition. */ + }; + +} diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_auto_object.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_auto_object.hpp index 04198f0c7..5ce08529f 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_auto_object.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_auto_object.hpp @@ -26,7 +26,7 @@ namespace ams::kern { NON_COPYABLE(CLASS); \ NON_MOVEABLE(CLASS); \ private: \ - friend class KClassTokenGenerator; \ + friend class ::ams::kern::KClassTokenGenerator; \ static constexpr inline auto ObjectType = ::ams::kern::KClassTokenGenerator::ObjectType::CLASS; \ static constexpr inline const char * const TypeName = #CLASS; \ static constexpr inline ClassTokenType ClassToken() { return ::ams::kern::ClassToken; } \ diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_code_memory.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_code_memory.hpp new file mode 100644 index 000000000..5f3f30afa --- /dev/null +++ b/libraries/libmesosphere/include/mesosphere/kern_k_code_memory.hpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * 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 . + */ +#pragma once +#include +#include +#include + +namespace ams::kern { + + class KCodeMemory final : public KAutoObjectWithSlabHeapAndContainer { + MESOSPHERE_AUTOOBJECT_TRAITS(KCodeMemory, KAutoObject); + public: + /* TODO: This is a placeholder definition. */ + }; + +} diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_debug_base.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_debug_base.hpp new file mode 100644 index 000000000..b1515b379 --- /dev/null +++ b/libraries/libmesosphere/include/mesosphere/kern_k_debug_base.hpp @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * 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 . + */ +#pragma once +#include +#include + +namespace ams::kern { + + class KDebugBase : public KSynchronizationObject { + public: + /* TODO: This is a placeholder definition. */ + }; + +} diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_device_address_space.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_device_address_space.hpp new file mode 100644 index 000000000..7262962f7 --- /dev/null +++ b/libraries/libmesosphere/include/mesosphere/kern_k_device_address_space.hpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * 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 . + */ +#pragma once +#include +#include +#include + +namespace ams::kern { + + class KDeviceAddressSpace final : public KAutoObjectWithSlabHeapAndContainer { + MESOSPHERE_AUTOOBJECT_TRAITS(KDeviceAddressSpace, KAutoObject); + public: + /* TODO: This is a placeholder definition. */ + }; + +} diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_event.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_event.hpp new file mode 100644 index 000000000..f1db211e1 --- /dev/null +++ b/libraries/libmesosphere/include/mesosphere/kern_k_event.hpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * 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 . + */ +#pragma once +#include +#include +#include +#include + +namespace ams::kern { + + class KEvent final : public KAutoObjectWithSlabHeapAndContainer { + MESOSPHERE_AUTOOBJECT_TRAITS(KEvent, KAutoObject); + public: + /* TODO: This is a placeholder definition. */ + }; + +} diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_event_info.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_event_info.hpp new file mode 100644 index 000000000..c458da021 --- /dev/null +++ b/libraries/libmesosphere/include/mesosphere/kern_k_event_info.hpp @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * 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 . + */ +#pragma once +#include +#include + +namespace ams::kern { + + class KEventInfo : public KSlabAllocated, public util::IntrusiveListBaseNode { + public: + /* TODO: This is a placeholder definition. */ + }; + +} diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_interrupt_event.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_interrupt_event.hpp new file mode 100644 index 000000000..15f102087 --- /dev/null +++ b/libraries/libmesosphere/include/mesosphere/kern_k_interrupt_event.hpp @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * 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 . + */ +#pragma once +#include +#include +#include +#include +#include + +namespace ams::kern { + + class KInterruptEventTask; + + class KInterruptEvent final : public KAutoObjectWithSlabHeapAndContainer { + MESOSPHERE_AUTOOBJECT_TRAITS(KInterruptEvent, KReadableEvent); + public: + /* TODO: This is a placeholder definition. */ + }; + + class KInterruptEventTask : public KSlabAllocated, public KInterruptTask { + public: + /* TODO: This is a placeholder definition. */ + }; + +} diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_light_session.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_light_session.hpp new file mode 100644 index 000000000..5edd88999 --- /dev/null +++ b/libraries/libmesosphere/include/mesosphere/kern_k_light_session.hpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * 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 . + */ +#pragma once +#include +#include +#include + +namespace ams::kern { + + class KLightSession final : public KAutoObjectWithSlabHeapAndContainer { + MESOSPHERE_AUTOOBJECT_TRAITS(KLightSession, KAutoObject); + public: + /* TODO: This is a placeholder definition. */ + }; + +} diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_memory_manager.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_memory_manager.hpp index c29b479ea..a0eeaae2a 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_memory_manager.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_memory_manager.hpp @@ -17,6 +17,7 @@ #include #include #include +#include namespace ams::kern { diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_object_name.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_object_name.hpp new file mode 100644 index 000000000..87e76c8c1 --- /dev/null +++ b/libraries/libmesosphere/include/mesosphere/kern_k_object_name.hpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * 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 . + */ +#pragma once +#include +#include +#include +#include + +namespace ams::kern { + + class KObjectName : public KSlabAllocated, public util::IntrusiveListBaseNode { + public: + /* TODO: This is a placeholder definition. */ + }; + +} diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_port.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_port.hpp new file mode 100644 index 000000000..40799b14e --- /dev/null +++ b/libraries/libmesosphere/include/mesosphere/kern_k_port.hpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * 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 . + */ +#pragma once +#include +#include +#include + +namespace ams::kern { + + class KPort final : public KAutoObjectWithSlabHeapAndContainer { + MESOSPHERE_AUTOOBJECT_TRAITS(KPort, KAutoObject); + public: + /* TODO: This is a placeholder definition. */ + }; + +} diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_readable_event.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_readable_event.hpp new file mode 100644 index 000000000..0afc530d1 --- /dev/null +++ b/libraries/libmesosphere/include/mesosphere/kern_k_readable_event.hpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * 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 . + */ +#pragma once +#include +#include + +namespace ams::kern { + + class KEvent; + + class KReadableEvent : public KSynchronizationObject { + MESOSPHERE_AUTOOBJECT_TRAITS(KReadableEvent, KSynchronizationObject); + private: + bool is_signaled; + KEvent *parent_event; + public: + constexpr explicit KReadableEvent() : KSynchronizationObject(), is_signaled(), parent_event() { MESOSPHERE_ASSERT_THIS(); } + virtual ~KReadableEvent() { MESOSPHERE_ASSERT_THIS(); } + + constexpr void Initialize(KEvent *parent) { + MESOSPHERE_ASSERT_THIS(); + this->is_signaled = false; + this->parent_event = parent; + } + + constexpr KEvent *GetParent() const { return this->parent_event; } + + virtual bool IsSignaled() const override; + virtual void Destroy() override; + + virtual Result Signal(); + virtual Result Clear(); + virtual Result Reset(); + }; + +} diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_session.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_session.hpp new file mode 100644 index 000000000..ccd5bc063 --- /dev/null +++ b/libraries/libmesosphere/include/mesosphere/kern_k_session.hpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * 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 . + */ +#pragma once +#include +#include +#include + +namespace ams::kern { + + class KSession final : public KAutoObjectWithSlabHeapAndContainer { + MESOSPHERE_AUTOOBJECT_TRAITS(KSession, KAutoObject); + public: + /* TODO: This is a placeholder definition. */ + }; + +} diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_session_request.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_session_request.hpp new file mode 100644 index 000000000..95a1d0a2c --- /dev/null +++ b/libraries/libmesosphere/include/mesosphere/kern_k_session_request.hpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * 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 . + */ +#pragma once +#include +#include +#include + +namespace ams::kern { + + class KSessionRequest final : public KSlabAllocated, public KAutoObject, public util::IntrusiveListBaseNode { + MESOSPHERE_AUTOOBJECT_TRAITS(KSessionRequest, KAutoObject); + public: + /* TODO: This is a placeholder definition. */ + }; + +} diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_shared_memory.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_shared_memory.hpp new file mode 100644 index 000000000..796d264e3 --- /dev/null +++ b/libraries/libmesosphere/include/mesosphere/kern_k_shared_memory.hpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * 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 . + */ +#pragma once +#include +#include +#include + +namespace ams::kern { + + class KSharedMemory final : public KAutoObjectWithSlabHeapAndContainer { + MESOSPHERE_AUTOOBJECT_TRAITS(KSharedMemory, KAutoObject); + public: + /* TODO: This is a placeholder definition. */ + }; + +} diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_shared_memory_info.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_shared_memory_info.hpp new file mode 100644 index 000000000..519cf5aa1 --- /dev/null +++ b/libraries/libmesosphere/include/mesosphere/kern_k_shared_memory_info.hpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * 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 . + */ +#pragma once +#include +#include + +namespace ams::kern { + + class KSharedMemory; + + class KSharedMemoryInfo : public KSlabAllocated, public util::IntrusiveListBaseNode { + private: + KSharedMemory *shared_memory; + size_t reference_count; + public: + constexpr KSharedMemoryInfo() : shared_memory(), reference_count() { /* ... */ } + ~KSharedMemoryInfo() { /* ... */ } + + constexpr void Initialize(KSharedMemory *m) { + MESOSPHERE_ASSERT_THIS(); + this->shared_memory = m; + this->reference_count = 0; + } + + constexpr void Open() { + const size_t ref_count = ++this->reference_count; + MESOSPHERE_ASSERT(ref_count > 0); + } + + constexpr bool Close() { + MESOSPHERE_ASSERT(this->reference_count > 0); + return (--this->reference_count) == 0; + } + + constexpr KSharedMemory *GetSharedMemory() const { return this->shared_memory; } + constexpr size_t GetReferenceCount() const { return this->reference_count; } + }; + +} diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_transfer_memory.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_transfer_memory.hpp new file mode 100644 index 000000000..9dd0d98bc --- /dev/null +++ b/libraries/libmesosphere/include/mesosphere/kern_k_transfer_memory.hpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * 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 . + */ +#pragma once +#include +#include +#include + +namespace ams::kern { + + class KTransferMemory final : public KAutoObjectWithSlabHeapAndContainer { + MESOSPHERE_AUTOOBJECT_TRAITS(KTransferMemory, KAutoObject); + public: + /* TODO: This is a placeholder definition. */ + }; + +} diff --git a/libraries/libmesosphere/include/mesosphere/kern_select_debug.hpp b/libraries/libmesosphere/include/mesosphere/kern_select_debug.hpp new file mode 100644 index 000000000..ba18f4459 --- /dev/null +++ b/libraries/libmesosphere/include/mesosphere/kern_select_debug.hpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * 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 . + */ +#pragma once +#include + +#if defined(ATMOSPHERE_ARCH_ARM64) + + #include + namespace ams::kern { + using ams::kern::arm64::KDebug; + } + +#else + + #error "Unknown architecture for KDebug" + +#endif diff --git a/libraries/libmesosphere/source/init/kern_init_slab_setup.cpp b/libraries/libmesosphere/source/init/kern_init_slab_setup.cpp index c04409f06..db644ec1a 100644 --- a/libraries/libmesosphere/source/init/kern_init_slab_setup.cpp +++ b/libraries/libmesosphere/source/init/kern_init_slab_setup.cpp @@ -165,7 +165,7 @@ namespace ams::kern::init { /* N shuffles the slab type array with the following simple algorithm. */ for (size_t i = 0; i < util::size(slab_types); i++) { - const size_t rnd = KSystemControl::GenerateRandomRange(0, util::size(slab_types)); + const size_t rnd = KSystemControl::GenerateRandomRange(0, util::size(slab_types) - 1); std::swap(slab_types[i], slab_types[rnd]); } @@ -195,12 +195,9 @@ namespace ams::kern::init { /* Initialize the slabheap. */ switch (slab_types[i]) { - /* NOTE: This can't be used right now because we don't have all these types implemented. */ - /* Once we do, uncomment the following. */ - /* TODO: FOREACH_SLAB_TYPE(INITIALIZE_SLAB_HEAP) */ - case KSlabType_KThread: - address = InitializeSlabHeap(address, SLAB_COUNT(KThread)); - break; + /* For each of the slab types, we want to initialize that heap. */ + FOREACH_SLAB_TYPE(INITIALIZE_SLAB_HEAP) + /* If we somehow get an invalid type, abort. */ MESOSPHERE_UNREACHABLE_DEFAULT_CASE(); } } diff --git a/libraries/libmesosphere/source/kern_k_readable_event.cpp b/libraries/libmesosphere/source/kern_k_readable_event.cpp new file mode 100644 index 000000000..6b06dea6a --- /dev/null +++ b/libraries/libmesosphere/source/kern_k_readable_event.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * 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 . + */ +#include + +namespace ams::kern { + + bool KReadableEvent::IsSignaled() const { + MESOSPHERE_ASSERT_THIS(); + MESOSPHERE_ASSERT(KScheduler::IsSchedulerLockedByCurrentThread()); + + return this->is_signaled; + } + + void KReadableEvent::Destroy() { + MESOSPHERE_ASSERT_THIS(); + if (this->parent_event) { + this->parent_event->Close(); + } + } + + Result KReadableEvent::Signal() { + MESOSPHERE_ASSERT_THIS(); + + KScopedSchedulerLock lk; + + if (!this->is_signaled) { + this->is_signaled = true; + this->NotifyAvailable(); + } + + return ResultSuccess(); + } + + Result KReadableEvent::Clear() { + MESOSPHERE_ASSERT_THIS(); + + this->Reset(); + + return ResultSuccess(); + } + + Result KReadableEvent::Reset() { + MESOSPHERE_ASSERT_THIS(); + + KScopedSchedulerLock lk; + + R_UNLESS(this->is_signaled, svc::ResultInvalidState()); + + this->is_signaled = false; + return ResultSuccess(); + } + +}