diff --git a/libmesosphere/source/board/nintendo/switch/kern_k_system_control.cpp b/libmesosphere/source/board/nintendo/switch/kern_k_system_control.cpp index 87b1ecd4..5e999a07 100644 --- a/libmesosphere/source/board/nintendo/switch/kern_k_system_control.cpp +++ b/libmesosphere/source/board/nintendo/switch/kern_k_system_control.cpp @@ -20,11 +20,6 @@ namespace ams::kern { namespace { - /* Convenience definitions. */ - constexpr size_t FourGigabytes = 0x100000000ul; - constexpr size_t SixGigabytes = 0x180000000ul; - constexpr size_t EightGigabytes = 0x200000000ul; - ALWAYS_INLINE size_t GetRealMemorySizeForInit() { /* TODO: Move this into a header for the MC in general. */ constexpr u32 MemoryControllerConfigurationRegister = 0x70019050; @@ -49,11 +44,11 @@ namespace ams::kern { switch (GetKernelConfigurationForInit().Get()) { case smc::MemorySize_4GB: default: /* All invalid modes should go to 4GB. */ - return FourGigabytes; + return 4_GB; case smc::MemorySize_6GB: - return SixGigabytes; + return 6_GB; case smc::MemorySize_8GB: - return EightGigabytes; + return 8_GB; } } diff --git a/libvapours/include/vapours.hpp b/libvapours/include/vapours.hpp index 73bb5b27..f27e558a 100644 --- a/libvapours/include/vapours.hpp +++ b/libvapours/include/vapours.hpp @@ -17,6 +17,7 @@ #pragma once #include "vapours/includes.hpp" #include "vapours/defines.hpp" +#include "vapours/literals.hpp" #include "vapours/util.hpp" #include "vapours/results.hpp" diff --git a/libvapours/include/vapours/literals.hpp b/libvapours/include/vapours/literals.hpp new file mode 100644 index 00000000..6e919461 --- /dev/null +++ b/libvapours/include/vapours/literals.hpp @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018-2019 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 "../defines.hpp" + +namespace ams { inline namespace literals { + + constexpr ALWAYS_INLINE size_t operator ""_KB(unsigned long long n) { + return static_cast(n) * size_t(1024); + } + + constexpr ALWAYS_INLINE size_t operator ""_MB(unsigned long long n) { + return operator ""_KB(n) * size_t(1024); + } + + constexpr ALWAYS_INLINE size_t operator ""_GB(unsigned long long n) { + return operator ""_MB(n) * size_t(1024); + } + +} }