mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
kern: correct KClassToken generation
This commit is contained in:
parent
d2a888d9e8
commit
5055bdb23e
2 changed files with 53 additions and 6 deletions
|
@ -64,10 +64,10 @@ namespace ams::kern {
|
|||
static constexpr inline TokenBaseType GetClassToken() {
|
||||
static_assert(std::is_base_of<KAutoObject, T>::value);
|
||||
if constexpr (std::is_same<T, KAutoObject>::value) {
|
||||
static_assert(T::ObjectType == ObjectType::BaseClassesStart);
|
||||
return BaseClassToken<0>;
|
||||
static_assert(T::ObjectType == ObjectType::KAutoObject);
|
||||
return 0;
|
||||
} else if constexpr (!std::is_final<T>::value) {
|
||||
static_assert(ObjectType::BaseClassesStart < T::ObjectType && T::ObjectType < ObjectType::BaseClassesEnd);
|
||||
static_assert(ObjectType::BaseClassesStart <= T::ObjectType && T::ObjectType < ObjectType::BaseClassesEnd);
|
||||
constexpr auto ClassIndex = static_cast<TokenBaseType>(T::ObjectType) - static_cast<TokenBaseType>(ObjectType::BaseClassesStart);
|
||||
return BaseClassToken<ClassIndex> | GetClassToken<typename T::BaseClass>();
|
||||
} else if constexpr (ObjectType::FinalClassesStart <= T::ObjectType && T::ObjectType < ObjectType::FinalClassesEnd) {
|
||||
|
@ -79,10 +79,11 @@ namespace ams::kern {
|
|||
};
|
||||
public:
|
||||
enum class ObjectType {
|
||||
BaseClassesStart = 0,
|
||||
KAutoObject,
|
||||
|
||||
KAutoObject = BaseClassesStart,
|
||||
KSynchronizationObject,
|
||||
BaseClassesStart,
|
||||
|
||||
KSynchronizationObject = BaseClassesStart,
|
||||
KReadableEvent,
|
||||
|
||||
BaseClassesEnd,
|
||||
|
|
46
libraries/libmesosphere/source/kern_k_class_token.cpp
Normal file
46
libraries/libmesosphere/source/kern_k_class_token.cpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <mesosphere.hpp>
|
||||
|
||||
namespace ams::kern {
|
||||
|
||||
/* Ensure that we generate correct class tokens for all types. */
|
||||
static_assert(ClassToken<KAutoObject> == 0b00000000'00000000);
|
||||
static_assert(ClassToken<KSynchronizationObject> == 0b00000000'00000001);
|
||||
static_assert(ClassToken<KReadableEvent> == 0b00000000'00000011);
|
||||
static_assert(ClassToken<KInterruptEvent> == 0b00000111'00000011);
|
||||
static_assert(ClassToken<KDebug> == 0b00001011'00000001);
|
||||
static_assert(ClassToken<KThread> == 0b00010011'00000001);
|
||||
/* TODO: static_assert(ClassToken<KServerPort> == 0b00100011'00000001); */
|
||||
/* TODO: static_assert(ClassToken<KServerSession> == 0b01000011'00000001); */
|
||||
/* TODO: static_assert(ClassToken<KClientPort> == 0b10000011'00000001); */
|
||||
/* TODO: static_assert(ClassToken<KClientSession> == 0b00001101'00000000); */
|
||||
static_assert(ClassToken<KProcess> == 0b00010101'00000001);
|
||||
static_assert(ClassToken<KResourceLimit> == 0b00100101'00000000);
|
||||
static_assert(ClassToken<KLightSession> == 0b01000101'00000000);
|
||||
static_assert(ClassToken<KPort> == 0b10000101'00000000);
|
||||
static_assert(ClassToken<KSession> == 0b00011001'00000000);
|
||||
static_assert(ClassToken<KSharedMemory> == 0b00101001'00000000);
|
||||
static_assert(ClassToken<KEvent> == 0b01001001'00000000);
|
||||
/* TODO: static_assert(ClassToken<KWritableEvent> == 0b10001001'00000000); */
|
||||
/* TODO: static_assert(ClassToken<KLightClientSession> == 0b00110001'00000000); */
|
||||
/* TODO: static_assert(ClassToken<KLightServerSession> == 0b01010001'00000000); */
|
||||
static_assert(ClassToken<KTransferMemory> == 0b10010001'00000000);
|
||||
static_assert(ClassToken<KDeviceAddressSpace> == 0b01100001'00000000);
|
||||
static_assert(ClassToken<KSessionRequest> == 0b10100001'00000000);
|
||||
static_assert(ClassToken<KCodeMemory> == 0b11000001'00000000);
|
||||
|
||||
}
|
Loading…
Reference in a new issue