common: Move common sizes to their own header for code reuse.

This commit is contained in:
bunnei 2021-03-19 23:52:47 -07:00
parent 01f04fee32
commit 28be8aec9a
3 changed files with 25 additions and 13 deletions

View file

@ -109,6 +109,7 @@ add_library(common STATIC
cityhash.h cityhash.h
common_funcs.h common_funcs.h
common_paths.h common_paths.h
common_sizes.h
common_types.h common_types.h
concepts.h concepts.h
div_ceil.h div_ceil.h

23
src/common/common_sizes.h Normal file
View file

@ -0,0 +1,23 @@
// Copyright 2021 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include "common/common_types.h"
enum : u64 {
Size_1_MB = 0x100000ULL,
Size_2_MB = 2ULL * Size_1_MB,
Size_4_MB = 4ULL * Size_1_MB,
Size_14_MB = 14ULL * Size_1_MB,
Size_32_MB = 32ULL * Size_1_MB,
Size_128_MB = 128ULL * Size_1_MB,
Size_1_GB = 0x40000000ULL,
Size_2_GB = 2ULL * Size_1_GB,
Size_4_GB = 4ULL * Size_1_GB,
Size_6_GB = 6ULL * Size_1_GB,
Size_64_GB = 64ULL * Size_1_GB,
Size_512_GB = 512ULL * Size_1_GB,
Invalid = std::numeric_limits<u64>::max(),
};

View file

@ -5,25 +5,13 @@
#include <array> #include <array>
#include "common/assert.h" #include "common/assert.h"
#include "common/common_sizes.h"
#include "core/hle/kernel/k_address_space_info.h" #include "core/hle/kernel/k_address_space_info.h"
namespace Kernel { namespace Kernel {
namespace { namespace {
enum : u64 {
Size_1_MB = 0x100000ULL,
Size_2_MB = 2ULL * Size_1_MB,
Size_128_MB = 128ULL * Size_1_MB,
Size_1_GB = 0x40000000ULL,
Size_2_GB = 2ULL * Size_1_GB,
Size_4_GB = 4ULL * Size_1_GB,
Size_6_GB = 6ULL * Size_1_GB,
Size_64_GB = 64ULL * Size_1_GB,
Size_512_GB = 512ULL * Size_1_GB,
Invalid = std::numeric_limits<u64>::max(),
};
// clang-format off // clang-format off
constexpr std::array<KAddressSpaceInfo, 13> AddressSpaceInfos{{ constexpr std::array<KAddressSpaceInfo, 13> AddressSpaceInfos{{
{ .bit_width = 32, .address = Size_2_MB , .size = Size_1_GB - Size_2_MB , .type = KAddressSpaceInfo::Type::MapSmall, }, { .bit_width = 32, .address = Size_2_MB , .size = Size_1_GB - Size_2_MB , .type = KAddressSpaceInfo::Type::MapSmall, },