diff options
| author | 2014-12-12 22:12:12 -0500 | |
|---|---|---|
| committer | 2014-12-12 22:12:12 -0500 | |
| commit | a6791e4fc73dda4853c8363d8ecf5094dbedd0ab (patch) | |
| tree | 279039386bc3c63f2eda6530fa325334ddadb957 /src | |
| parent | Merge pull request #261 from neobrain/boost (diff) | |
| parent | APT_U: Added GetSharedFont service function. (diff) | |
| download | yuzu-a6791e4fc73dda4853c8363d8ecf5094dbedd0ab.tar.gz yuzu-a6791e4fc73dda4853c8363d8ecf5094dbedd0ab.tar.xz yuzu-a6791e4fc73dda4853c8363d8ecf5094dbedd0ab.zip | |
Merge pull request #267 from bunnei/apt-shared-font
APT shared font loading
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/common_paths.h | 17 | ||||
| -rw-r--r-- | src/common/file_util.cpp | 14 | ||||
| -rw-r--r-- | src/common/file_util.h | 1 | ||||
| -rw-r--r-- | src/core/hle/service/apt_u.cpp | 134 | ||||
| -rw-r--r-- | src/core/hle/svc.cpp | 2 | ||||
| -rw-r--r-- | src/core/mem_map.cpp | 16 | ||||
| -rw-r--r-- | src/core/mem_map.h | 14 | ||||
| -rw-r--r-- | src/core/mem_map_funcs.cpp | 32 | ||||
| -rw-r--r-- | src/video_core/pica.h | 4 |
9 files changed, 140 insertions, 94 deletions
diff --git a/src/common/common_paths.h b/src/common/common_paths.h index ae08d082a..42e1a29c1 100644 --- a/src/common/common_paths.h +++ b/src/common/common_paths.h | |||
| @@ -29,19 +29,6 @@ | |||
| 29 | #endif | 29 | #endif |
| 30 | #endif | 30 | #endif |
| 31 | 31 | ||
| 32 | // Shared data dirs (Sys and shared User for linux) | ||
| 33 | #ifdef _WIN32 | ||
| 34 | #define SYSDATA_DIR "sys" | ||
| 35 | #else | ||
| 36 | #ifdef DATA_DIR | ||
| 37 | #define SYSDATA_DIR DATA_DIR "sys" | ||
| 38 | #define SHARED_USER_DIR DATA_DIR USERDATA_DIR DIR_SEP | ||
| 39 | #else | ||
| 40 | #define SYSDATA_DIR "sys" | ||
| 41 | #define SHARED_USER_DIR ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP | ||
| 42 | #endif | ||
| 43 | #endif | ||
| 44 | |||
| 45 | // Dirs in both User and Sys | 32 | // Dirs in both User and Sys |
| 46 | #define EUR_DIR "EUR" | 33 | #define EUR_DIR "EUR" |
| 47 | #define USA_DIR "USA" | 34 | #define USA_DIR "USA" |
| @@ -53,6 +40,7 @@ | |||
| 53 | #define MAPS_DIR "maps" | 40 | #define MAPS_DIR "maps" |
| 54 | #define CACHE_DIR "cache" | 41 | #define CACHE_DIR "cache" |
| 55 | #define SDMC_DIR "sdmc" | 42 | #define SDMC_DIR "sdmc" |
| 43 | #define SYSDATA_DIR "sysdata" | ||
| 56 | #define SHADERCACHE_DIR "shader_cache" | 44 | #define SHADERCACHE_DIR "shader_cache" |
| 57 | #define STATESAVES_DIR "state_saves" | 45 | #define STATESAVES_DIR "state_saves" |
| 58 | #define SCREENSHOTS_DIR "screenShots" | 46 | #define SCREENSHOTS_DIR "screenShots" |
| @@ -70,6 +58,9 @@ | |||
| 70 | #define DEBUGGER_CONFIG "debugger.ini" | 58 | #define DEBUGGER_CONFIG "debugger.ini" |
| 71 | #define LOGGER_CONFIG "logger.ini" | 59 | #define LOGGER_CONFIG "logger.ini" |
| 72 | 60 | ||
| 61 | // Sys files | ||
| 62 | #define SHARED_FONT "shared_font.bin" | ||
| 63 | |||
| 73 | // Files in the directory returned by GetUserPath(D_LOGS_IDX) | 64 | // Files in the directory returned by GetUserPath(D_LOGS_IDX) |
| 74 | #define MAIN_LOG "emu.log" | 65 | #define MAIN_LOG "emu.log" |
| 75 | 66 | ||
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 6c4860503..7579d8c0f 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp | |||
| @@ -676,6 +676,7 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string &new | |||
| 676 | paths[D_MAPS_IDX] = paths[D_USER_IDX] + MAPS_DIR DIR_SEP; | 676 | paths[D_MAPS_IDX] = paths[D_USER_IDX] + MAPS_DIR DIR_SEP; |
| 677 | paths[D_CACHE_IDX] = paths[D_USER_IDX] + CACHE_DIR DIR_SEP; | 677 | paths[D_CACHE_IDX] = paths[D_USER_IDX] + CACHE_DIR DIR_SEP; |
| 678 | paths[D_SDMC_IDX] = paths[D_USER_IDX] + SDMC_DIR DIR_SEP; | 678 | paths[D_SDMC_IDX] = paths[D_USER_IDX] + SDMC_DIR DIR_SEP; |
| 679 | paths[D_SYSDATA_IDX] = paths[D_USER_IDX] + SYSDATA_DIR DIR_SEP; | ||
| 679 | paths[D_SHADERCACHE_IDX] = paths[D_USER_IDX] + SHADERCACHE_DIR DIR_SEP; | 680 | paths[D_SHADERCACHE_IDX] = paths[D_USER_IDX] + SHADERCACHE_DIR DIR_SEP; |
| 680 | paths[D_SHADERS_IDX] = paths[D_USER_IDX] + SHADERS_DIR DIR_SEP; | 681 | paths[D_SHADERS_IDX] = paths[D_USER_IDX] + SHADERS_DIR DIR_SEP; |
| 681 | paths[D_STATESAVES_IDX] = paths[D_USER_IDX] + STATESAVES_DIR DIR_SEP; | 682 | paths[D_STATESAVES_IDX] = paths[D_USER_IDX] + STATESAVES_DIR DIR_SEP; |
| @@ -753,19 +754,6 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string &new | |||
| 753 | return paths[DirIDX]; | 754 | return paths[DirIDX]; |
| 754 | } | 755 | } |
| 755 | 756 | ||
| 756 | //std::string GetThemeDir(const std::string& theme_name) | ||
| 757 | //{ | ||
| 758 | // std::string dir = FileUtil::GetUserPath(D_THEMES_IDX) + theme_name + "/"; | ||
| 759 | // | ||
| 760 | //#if !defined(_WIN32) | ||
| 761 | // // If theme does not exist in user's dir load from shared directory | ||
| 762 | // if (!FileUtil::Exists(dir)) | ||
| 763 | // dir = SHARED_USER_DIR THEMES_DIR "/" + theme_name + "/"; | ||
| 764 | //#endif | ||
| 765 | // | ||
| 766 | // return dir; | ||
| 767 | //} | ||
| 768 | |||
| 769 | size_t WriteStringToFile(bool text_file, const std::string &str, const char *filename) | 757 | size_t WriteStringToFile(bool text_file, const std::string &str, const char *filename) |
| 770 | { | 758 | { |
| 771 | return FileUtil::IOFile(filename, text_file ? "w" : "wb").WriteBytes(str.data(), str.size()); | 759 | return FileUtil::IOFile(filename, text_file ? "w" : "wb").WriteBytes(str.data(), str.size()); |
diff --git a/src/common/file_util.h b/src/common/file_util.h index beaf7174a..a9d48cfe8 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h | |||
| @@ -27,6 +27,7 @@ enum { | |||
| 27 | D_STATESAVES_IDX, | 27 | D_STATESAVES_IDX, |
| 28 | D_SCREENSHOTS_IDX, | 28 | D_SCREENSHOTS_IDX, |
| 29 | D_SDMC_IDX, | 29 | D_SDMC_IDX, |
| 30 | D_SYSDATA_IDX, | ||
| 30 | D_HIRESTEXTURES_IDX, | 31 | D_HIRESTEXTURES_IDX, |
| 31 | D_DUMP_IDX, | 32 | D_DUMP_IDX, |
| 32 | D_DUMPFRAMES_IDX, | 33 | D_DUMPFRAMES_IDX, |
diff --git a/src/core/hle/service/apt_u.cpp b/src/core/hle/service/apt_u.cpp index 4bb05ce40..181763724 100644 --- a/src/core/hle/service/apt_u.cpp +++ b/src/core/hle/service/apt_u.cpp | |||
| @@ -4,10 +4,12 @@ | |||
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | #include "common/common.h" | 6 | #include "common/common.h" |
| 7 | #include "common/file_util.h" | ||
| 7 | 8 | ||
| 8 | #include "core/hle/hle.h" | 9 | #include "core/hle/hle.h" |
| 9 | #include "core/hle/kernel/event.h" | 10 | #include "core/hle/kernel/event.h" |
| 10 | #include "core/hle/kernel/mutex.h" | 11 | #include "core/hle/kernel/mutex.h" |
| 12 | #include "core/hle/kernel/shared_memory.h" | ||
| 11 | #include "apt_u.h" | 13 | #include "apt_u.h" |
| 12 | 14 | ||
| 13 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 15 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| @@ -15,7 +17,19 @@ | |||
| 15 | 17 | ||
| 16 | namespace APT_U { | 18 | namespace APT_U { |
| 17 | 19 | ||
| 20 | // Address used for shared font (as observed on HW) | ||
| 21 | // TODO(bunnei): This is the hard-coded address where we currently dump the shared font from via | ||
| 22 | // https://github.com/citra-emu/3dsutils. This is technically a hack, and will not work at any | ||
| 23 | // address other than 0x18000000 due to internal pointers in the shared font dump that would need to | ||
| 24 | // be relocated. This might be fixed by dumping the shared font @ address 0x00000000 and then | ||
| 25 | // correctly mapping it in Citra, however we still do not understand how the mapping is determined. | ||
| 26 | static const VAddr SHARED_FONT_VADDR = 0x18000000; | ||
| 27 | |||
| 28 | // Handle to shared memory region designated to for shared system font | ||
| 29 | static Handle shared_font_mem = 0; | ||
| 30 | |||
| 18 | static Handle lock_handle = 0; | 31 | static Handle lock_handle = 0; |
| 32 | static std::vector<u8> shared_font; | ||
| 19 | 33 | ||
| 20 | /// Signals used by APT functions | 34 | /// Signals used by APT functions |
| 21 | enum class SignalType : u32 { | 35 | enum class SignalType : u32 { |
| @@ -84,18 +98,18 @@ void InquireNotification(Service::Interface* self) { | |||
| 84 | * state so that this command will return an error if this command is used again if parameters were | 98 | * state so that this command will return an error if this command is used again if parameters were |
| 85 | * not set again. This is called when the second Initialize event is triggered. It returns a signal | 99 | * not set again. This is called when the second Initialize event is triggered. It returns a signal |
| 86 | * type indicating why it was triggered. | 100 | * type indicating why it was triggered. |
| 87 | * Inputs: | 101 | * Inputs: |
| 88 | * 1 : AppID | 102 | * 1 : AppID |
| 89 | * 2 : Parameter buffer size, max size is 0x1000 | 103 | * 2 : Parameter buffer size, max size is 0x1000 |
| 90 | * Outputs: | 104 | * Outputs: |
| 91 | * 1 : Result of function, 0 on success, otherwise error code | 105 | * 1 : Result of function, 0 on success, otherwise error code |
| 92 | * 2 : Unknown, for now assume AppID of the process which sent these parameters | 106 | * 2 : Unknown, for now assume AppID of the process which sent these parameters |
| 93 | * 3 : Unknown, for now assume Signal type | 107 | * 3 : Unknown, for now assume Signal type |
| 94 | * 4 : Actual parameter buffer size, this is <= to the the input size | 108 | * 4 : Actual parameter buffer size, this is <= to the the input size |
| 95 | * 5 : Value | 109 | * 5 : Value |
| 96 | * 6 : Handle from the source process which set the parameters, likely used for shared memory | 110 | * 6 : Handle from the source process which set the parameters, likely used for shared memory |
| 97 | * 7 : Size | 111 | * 7 : Size |
| 98 | * 8 : Output parameter buffer ptr | 112 | * 8 : Output parameter buffer ptr |
| 99 | */ | 113 | */ |
| 100 | void ReceiveParameter(Service::Interface* self) { | 114 | void ReceiveParameter(Service::Interface* self) { |
| 101 | u32* cmd_buff = Service::GetCommandBuffer(); | 115 | u32* cmd_buff = Service::GetCommandBuffer(); |
| @@ -115,18 +129,18 @@ void ReceiveParameter(Service::Interface* self) { | |||
| 115 | * APT_U::GlanceParameter service function. This is exactly the same as APT_U::ReceiveParameter | 129 | * APT_U::GlanceParameter service function. This is exactly the same as APT_U::ReceiveParameter |
| 116 | * (except for the word value prior to the output handle), except this will not clear the flag | 130 | * (except for the word value prior to the output handle), except this will not clear the flag |
| 117 | * (except when responseword[3]==8 || responseword[3]==9) in NS state. | 131 | * (except when responseword[3]==8 || responseword[3]==9) in NS state. |
| 118 | * Inputs: | 132 | * Inputs: |
| 119 | * 1 : AppID | 133 | * 1 : AppID |
| 120 | * 2 : Parameter buffer size, max size is 0x1000 | 134 | * 2 : Parameter buffer size, max size is 0x1000 |
| 121 | * Outputs: | 135 | * Outputs: |
| 122 | * 1 : Result of function, 0 on success, otherwise error code | 136 | * 1 : Result of function, 0 on success, otherwise error code |
| 123 | * 2 : Unknown, for now assume AppID of the process which sent these parameters | 137 | * 2 : Unknown, for now assume AppID of the process which sent these parameters |
| 124 | * 3 : Unknown, for now assume Signal type | 138 | * 3 : Unknown, for now assume Signal type |
| 125 | * 4 : Actual parameter buffer size, this is <= to the the input size | 139 | * 4 : Actual parameter buffer size, this is <= to the the input size |
| 126 | * 5 : Value | 140 | * 5 : Value |
| 127 | * 6 : Handle from the source process which set the parameters, likely used for shared memory | 141 | * 6 : Handle from the source process which set the parameters, likely used for shared memory |
| 128 | * 7 : Size | 142 | * 7 : Size |
| 129 | * 8 : Output parameter buffer ptr | 143 | * 8 : Output parameter buffer ptr |
| 130 | */ | 144 | */ |
| 131 | void GlanceParameter(Service::Interface* self) { | 145 | void GlanceParameter(Service::Interface* self) { |
| 132 | u32* cmd_buff = Service::GetCommandBuffer(); | 146 | u32* cmd_buff = Service::GetCommandBuffer(); |
| @@ -146,14 +160,14 @@ void GlanceParameter(Service::Interface* self) { | |||
| 146 | 160 | ||
| 147 | /** | 161 | /** |
| 148 | * APT_U::AppletUtility service function | 162 | * APT_U::AppletUtility service function |
| 149 | * Inputs: | 163 | * Inputs: |
| 150 | * 1 : Unknown, but clearly used for something | 164 | * 1 : Unknown, but clearly used for something |
| 151 | * 2 : Buffer 1 size (purpose is unknown) | 165 | * 2 : Buffer 1 size (purpose is unknown) |
| 152 | * 3 : Buffer 2 size (purpose is unknown) | 166 | * 3 : Buffer 2 size (purpose is unknown) |
| 153 | * 5 : Buffer 1 address (purpose is unknown) | 167 | * 5 : Buffer 1 address (purpose is unknown) |
| 154 | * 65 : Buffer 2 address (purpose is unknown) | 168 | * 65 : Buffer 2 address (purpose is unknown) |
| 155 | * Outputs: | 169 | * Outputs: |
| 156 | * 1 : Result of function, 0 on success, otherwise error code | 170 | * 1 : Result of function, 0 on success, otherwise error code |
| 157 | */ | 171 | */ |
| 158 | void AppletUtility(Service::Interface* self) { | 172 | void AppletUtility(Service::Interface* self) { |
| 159 | u32* cmd_buff = Service::GetCommandBuffer(); | 173 | u32* cmd_buff = Service::GetCommandBuffer(); |
| @@ -172,6 +186,34 @@ void AppletUtility(Service::Interface* self) { | |||
| 172 | buffer1_addr, buffer2_addr); | 186 | buffer1_addr, buffer2_addr); |
| 173 | } | 187 | } |
| 174 | 188 | ||
| 189 | /** | ||
| 190 | * APT_U::GetSharedFont service function | ||
| 191 | * Outputs: | ||
| 192 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 193 | * 2 : Virtual address of where shared font will be loaded in memory | ||
| 194 | * 4 : Handle to shared font memory | ||
| 195 | */ | ||
| 196 | void GetSharedFont(Service::Interface* self) { | ||
| 197 | DEBUG_LOG(KERNEL, "called"); | ||
| 198 | |||
| 199 | u32* cmd_buff = Service::GetCommandBuffer(); | ||
| 200 | |||
| 201 | if (!shared_font.empty()) { | ||
| 202 | // TODO(bunnei): This function shouldn't copy the shared font every time it's called. | ||
| 203 | // Instead, it should probably map the shared font as RO memory. We don't currently have | ||
| 204 | // an easy way to do this, but the copy should be sufficient for now. | ||
| 205 | memcpy(Memory::GetPointer(SHARED_FONT_VADDR), shared_font.data(), shared_font.size()); | ||
| 206 | |||
| 207 | cmd_buff[0] = 0x00440082; | ||
| 208 | cmd_buff[1] = 0; // No error | ||
| 209 | cmd_buff[2] = SHARED_FONT_VADDR; | ||
| 210 | cmd_buff[4] = shared_font_mem; | ||
| 211 | } else { | ||
| 212 | cmd_buff[1] = -1; // Generic error (not really possible to verify this on hardware) | ||
| 213 | ERROR_LOG(KERNEL, "called, but %s has not been loaded!", SHARED_FONT); | ||
| 214 | } | ||
| 215 | } | ||
| 216 | |||
| 175 | const Interface::FunctionInfo FunctionTable[] = { | 217 | const Interface::FunctionInfo FunctionTable[] = { |
| 176 | {0x00010040, GetLockHandle, "GetLockHandle"}, | 218 | {0x00010040, GetLockHandle, "GetLockHandle"}, |
| 177 | {0x00020080, Initialize, "Initialize"}, | 219 | {0x00020080, Initialize, "Initialize"}, |
| @@ -240,7 +282,7 @@ const Interface::FunctionInfo FunctionTable[] = { | |||
| 240 | {0x00410040, nullptr, "ReceiveCaptureBufferInfo"}, | 282 | {0x00410040, nullptr, "ReceiveCaptureBufferInfo"}, |
| 241 | {0x00420080, nullptr, "SleepSystem"}, | 283 | {0x00420080, nullptr, "SleepSystem"}, |
| 242 | {0x00430040, nullptr, "NotifyToWait"}, | 284 | {0x00430040, nullptr, "NotifyToWait"}, |
| 243 | {0x00440000, nullptr, "GetSharedFont"}, | 285 | {0x00440000, GetSharedFont, "GetSharedFont"}, |
| 244 | {0x00450040, nullptr, "GetWirelessRebootInfo"}, | 286 | {0x00450040, nullptr, "GetWirelessRebootInfo"}, |
| 245 | {0x00460104, nullptr, "Wrap"}, | 287 | {0x00460104, nullptr, "Wrap"}, |
| 246 | {0x00470104, nullptr, "Unwrap"}, | 288 | {0x00470104, nullptr, "Unwrap"}, |
| @@ -259,9 +301,33 @@ const Interface::FunctionInfo FunctionTable[] = { | |||
| 259 | // Interface class | 301 | // Interface class |
| 260 | 302 | ||
| 261 | Interface::Interface() { | 303 | Interface::Interface() { |
| 262 | Register(FunctionTable, ARRAY_SIZE(FunctionTable)); | 304 | // Load the shared system font (if available). |
| 305 | // The expected format is a decrypted, uncompressed BCFNT file with the 0x80 byte header | ||
| 306 | // generated by the APT:U service. The best way to get is by dumping it from RAM. We've provided | ||
| 307 | // a homebrew app to do this: https://github.com/citra-emu/3dsutils. Put the resulting file | ||
| 308 | // "shared_font.bin" in the Citra "sysdata" directory. | ||
| 309 | |||
| 310 | shared_font.clear(); | ||
| 311 | std::string filepath = FileUtil::GetUserPath(D_SYSDATA_IDX) + SHARED_FONT; | ||
| 312 | |||
| 313 | FileUtil::CreateFullPath(filepath); // Create path if not already created | ||
| 314 | FileUtil::IOFile file(filepath, "rb"); | ||
| 315 | |||
| 316 | if (file.IsOpen()) { | ||
| 317 | // Read shared font data | ||
| 318 | shared_font.resize(file.GetSize()); | ||
| 319 | file.ReadBytes(shared_font.data(), file.GetSize()); | ||
| 320 | |||
| 321 | // Create shared font memory object | ||
| 322 | shared_font_mem = Kernel::CreateSharedMemory("APT_U:shared_font_mem"); | ||
| 323 | } else { | ||
| 324 | WARN_LOG(KERNEL, "Unable to load shared font: %s", filepath.c_str()); | ||
| 325 | shared_font_mem = 0; | ||
| 326 | } | ||
| 263 | 327 | ||
| 264 | lock_handle = 0; | 328 | lock_handle = 0; |
| 329 | |||
| 330 | Register(FunctionTable, ARRAY_SIZE(FunctionTable)); | ||
| 265 | } | 331 | } |
| 266 | 332 | ||
| 267 | Interface::~Interface() { | 333 | Interface::~Interface() { |
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index a5805ed05..b99c301d4 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -43,7 +43,7 @@ static Result ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 addr1, | |||
| 43 | 43 | ||
| 44 | // Map GSP heap memory | 44 | // Map GSP heap memory |
| 45 | case MEMORY_OPERATION_GSP_HEAP: | 45 | case MEMORY_OPERATION_GSP_HEAP: |
| 46 | *out_addr = Memory::MapBlock_HeapGSP(size, operation, permissions); | 46 | *out_addr = Memory::MapBlock_HeapLinear(size, operation, permissions); |
| 47 | break; | 47 | break; |
| 48 | 48 | ||
| 49 | // Unknown ControlMemory operation | 49 | // Unknown ControlMemory operation |
diff --git a/src/core/mem_map.cpp b/src/core/mem_map.cpp index 74a93b1d9..e1c2580ff 100644 --- a/src/core/mem_map.cpp +++ b/src/core/mem_map.cpp | |||
| @@ -18,7 +18,7 @@ static MemArena arena; ///< The MemArena class | |||
| 18 | u8* g_exefs_code = nullptr; ///< ExeFS:/.code is loaded here | 18 | u8* g_exefs_code = nullptr; ///< ExeFS:/.code is loaded here |
| 19 | u8* g_system_mem = nullptr; ///< System memory | 19 | u8* g_system_mem = nullptr; ///< System memory |
| 20 | u8* g_heap = nullptr; ///< Application heap (main memory) | 20 | u8* g_heap = nullptr; ///< Application heap (main memory) |
| 21 | u8* g_heap_gsp = nullptr; ///< GSP heap (main memory) | 21 | u8* g_heap_linear = nullptr; ///< Linear heap |
| 22 | u8* g_vram = nullptr; ///< Video memory (VRAM) pointer | 22 | u8* g_vram = nullptr; ///< Video memory (VRAM) pointer |
| 23 | u8* g_shared_mem = nullptr; ///< Shared memory | 23 | u8* g_shared_mem = nullptr; ///< Shared memory |
| 24 | u8* g_kernel_mem; ///< Kernel memory | 24 | u8* g_kernel_mem; ///< Kernel memory |
| @@ -36,13 +36,13 @@ static u8* physical_kernel_mem; ///< Kernel memory | |||
| 36 | 36 | ||
| 37 | // We don't declare the IO region in here since its handled by other means. | 37 | // We don't declare the IO region in here since its handled by other means. |
| 38 | static MemoryView g_views[] = { | 38 | static MemoryView g_views[] = { |
| 39 | {&g_exefs_code, &physical_exefs_code, EXEFS_CODE_VADDR, EXEFS_CODE_SIZE, 0}, | 39 | {&g_exefs_code, &physical_exefs_code, EXEFS_CODE_VADDR, EXEFS_CODE_SIZE, 0}, |
| 40 | {&g_vram, &physical_vram, VRAM_VADDR, VRAM_SIZE, 0}, | 40 | {&g_vram, &physical_vram, VRAM_VADDR, VRAM_SIZE, 0}, |
| 41 | {&g_heap, &physical_fcram, HEAP_VADDR, HEAP_SIZE, MV_IS_PRIMARY_RAM}, | 41 | {&g_heap, &physical_fcram, HEAP_VADDR, HEAP_SIZE, MV_IS_PRIMARY_RAM}, |
| 42 | {&g_shared_mem, &physical_shared_mem, SHARED_MEMORY_VADDR, SHARED_MEMORY_SIZE, 0}, | 42 | {&g_shared_mem, &physical_shared_mem, SHARED_MEMORY_VADDR, SHARED_MEMORY_SIZE, 0}, |
| 43 | {&g_system_mem, &physical_system_mem, SYSTEM_MEMORY_VADDR, SYSTEM_MEMORY_SIZE, 0}, | 43 | {&g_system_mem, &physical_system_mem, SYSTEM_MEMORY_VADDR, SYSTEM_MEMORY_SIZE, 0}, |
| 44 | {&g_kernel_mem, &physical_kernel_mem, KERNEL_MEMORY_VADDR, KERNEL_MEMORY_SIZE, 0}, | 44 | {&g_kernel_mem, &physical_kernel_mem, KERNEL_MEMORY_VADDR, KERNEL_MEMORY_SIZE, 0}, |
| 45 | {&g_heap_gsp, &physical_heap_gsp, HEAP_GSP_VADDR, HEAP_GSP_SIZE, 0}, | 45 | {&g_heap_linear, &physical_heap_gsp, HEAP_LINEAR_VADDR, HEAP_LINEAR_SIZE, 0}, |
| 46 | }; | 46 | }; |
| 47 | 47 | ||
| 48 | /*static MemoryView views[] = | 48 | /*static MemoryView views[] = |
diff --git a/src/core/mem_map.h b/src/core/mem_map.h index f17afb60d..7b750f848 100644 --- a/src/core/mem_map.h +++ b/src/core/mem_map.h | |||
| @@ -57,11 +57,11 @@ enum : u32 { | |||
| 57 | HEAP_VADDR = 0x08000000, | 57 | HEAP_VADDR = 0x08000000, |
| 58 | HEAP_VADDR_END = (HEAP_VADDR + HEAP_SIZE), | 58 | HEAP_VADDR_END = (HEAP_VADDR + HEAP_SIZE), |
| 59 | 59 | ||
| 60 | HEAP_GSP_SIZE = 0x02000000, ///< GSP heap size... TODO: Define correctly? | 60 | HEAP_LINEAR_SIZE = 0x08000000, ///< Linear heap size... TODO: Define correctly? |
| 61 | HEAP_GSP_VADDR = 0x14000000, | 61 | HEAP_LINEAR_VADDR = 0x14000000, |
| 62 | HEAP_GSP_VADDR_END = (HEAP_GSP_VADDR + HEAP_GSP_SIZE), | 62 | HEAP_LINEAR_VADDR_END = (HEAP_LINEAR_VADDR + HEAP_LINEAR_SIZE), |
| 63 | HEAP_GSP_PADDR = 0x00000000, | 63 | HEAP_LINEAR_PADDR = 0x00000000, |
| 64 | HEAP_GSP_PADDR_END = (HEAP_GSP_PADDR + HEAP_GSP_SIZE), | 64 | HEAP_LINEAR_PADDR_END = (HEAP_LINEAR_PADDR + HEAP_LINEAR_SIZE), |
| 65 | 65 | ||
| 66 | HARDWARE_IO_SIZE = 0x01000000, | 66 | HARDWARE_IO_SIZE = 0x01000000, |
| 67 | HARDWARE_IO_PADDR = 0x10000000, ///< IO physical address start | 67 | HARDWARE_IO_PADDR = 0x10000000, ///< IO physical address start |
| @@ -112,7 +112,7 @@ extern u8 *g_base; | |||
| 112 | // These are guaranteed to point to "low memory" addresses (sub-32-bit). | 112 | // These are guaranteed to point to "low memory" addresses (sub-32-bit). |
| 113 | // 64-bit: Pointers to low-mem (sub-0x10000000) mirror | 113 | // 64-bit: Pointers to low-mem (sub-0x10000000) mirror |
| 114 | // 32-bit: Same as the corresponding physical/virtual pointers. | 114 | // 32-bit: Same as the corresponding physical/virtual pointers. |
| 115 | extern u8* g_heap_gsp; ///< GSP heap (main memory) | 115 | extern u8* g_heap_linear; ///< Linear heap (main memory) |
| 116 | extern u8* g_heap; ///< Application heap (main memory) | 116 | extern u8* g_heap; ///< Application heap (main memory) |
| 117 | extern u8* g_vram; ///< Video memory (VRAM) | 117 | extern u8* g_vram; ///< Video memory (VRAM) |
| 118 | extern u8* g_shared_mem; ///< Shared memory | 118 | extern u8* g_shared_mem; ///< Shared memory |
| @@ -159,7 +159,7 @@ u32 MapBlock_Heap(u32 size, u32 operation, u32 permissions); | |||
| 159 | * @param operation Memory map operation type | 159 | * @param operation Memory map operation type |
| 160 | * @param permissions Control memory permissions | 160 | * @param permissions Control memory permissions |
| 161 | */ | 161 | */ |
| 162 | u32 MapBlock_HeapGSP(u32 size, u32 operation, u32 permissions); | 162 | u32 MapBlock_HeapLinear(u32 size, u32 operation, u32 permissions); |
| 163 | 163 | ||
| 164 | inline const char* GetCharPointer(const VAddr address) { | 164 | inline const char* GetCharPointer(const VAddr address) { |
| 165 | return (const char *)GetPointer(address); | 165 | return (const char *)GetPointer(address); |
diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp index 1887bcedb..b78821a3b 100644 --- a/src/core/mem_map_funcs.cpp +++ b/src/core/mem_map_funcs.cpp | |||
| @@ -13,7 +13,7 @@ | |||
| 13 | namespace Memory { | 13 | namespace Memory { |
| 14 | 14 | ||
| 15 | static std::map<u32, MemoryBlock> heap_map; | 15 | static std::map<u32, MemoryBlock> heap_map; |
| 16 | static std::map<u32, MemoryBlock> heap_gsp_map; | 16 | static std::map<u32, MemoryBlock> heap_linear_map; |
| 17 | static std::map<u32, MemoryBlock> shared_map; | 17 | static std::map<u32, MemoryBlock> shared_map; |
| 18 | 18 | ||
| 19 | /// Convert a physical address to virtual address | 19 | /// Convert a physical address to virtual address |
| @@ -67,9 +67,9 @@ inline void Read(T &var, const VAddr vaddr) { | |||
| 67 | } else if ((vaddr >= EXEFS_CODE_VADDR) && (vaddr < EXEFS_CODE_VADDR_END)) { | 67 | } else if ((vaddr >= EXEFS_CODE_VADDR) && (vaddr < EXEFS_CODE_VADDR_END)) { |
| 68 | var = *((const T*)&g_exefs_code[vaddr - EXEFS_CODE_VADDR]); | 68 | var = *((const T*)&g_exefs_code[vaddr - EXEFS_CODE_VADDR]); |
| 69 | 69 | ||
| 70 | // FCRAM - GSP heap | 70 | // FCRAM - linear heap |
| 71 | } else if ((vaddr >= HEAP_GSP_VADDR) && (vaddr < HEAP_GSP_VADDR_END)) { | 71 | } else if ((vaddr >= HEAP_LINEAR_VADDR) && (vaddr < HEAP_LINEAR_VADDR_END)) { |
| 72 | var = *((const T*)&g_heap_gsp[vaddr - HEAP_GSP_VADDR]); | 72 | var = *((const T*)&g_heap_linear[vaddr - HEAP_LINEAR_VADDR]); |
| 73 | 73 | ||
| 74 | // FCRAM - application heap | 74 | // FCRAM - application heap |
| 75 | } else if ((vaddr >= HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) { | 75 | } else if ((vaddr >= HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) { |
| @@ -112,9 +112,9 @@ inline void Write(const VAddr vaddr, const T data) { | |||
| 112 | } else if ((vaddr >= EXEFS_CODE_VADDR) && (vaddr < EXEFS_CODE_VADDR_END)) { | 112 | } else if ((vaddr >= EXEFS_CODE_VADDR) && (vaddr < EXEFS_CODE_VADDR_END)) { |
| 113 | *(T*)&g_exefs_code[vaddr - EXEFS_CODE_VADDR] = data; | 113 | *(T*)&g_exefs_code[vaddr - EXEFS_CODE_VADDR] = data; |
| 114 | 114 | ||
| 115 | // FCRAM - GSP heap | 115 | // FCRAM - linear heap |
| 116 | } else if ((vaddr >= HEAP_GSP_VADDR) && (vaddr < HEAP_GSP_VADDR_END)) { | 116 | } else if ((vaddr >= HEAP_LINEAR_VADDR) && (vaddr < HEAP_LINEAR_VADDR_END)) { |
| 117 | *(T*)&g_heap_gsp[vaddr - HEAP_GSP_VADDR] = data; | 117 | *(T*)&g_heap_linear[vaddr - HEAP_LINEAR_VADDR] = data; |
| 118 | 118 | ||
| 119 | // FCRAM - application heap | 119 | // FCRAM - application heap |
| 120 | } else if ((vaddr >= HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) { | 120 | } else if ((vaddr >= HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) { |
| @@ -154,9 +154,9 @@ u8 *GetPointer(const VAddr vaddr) { | |||
| 154 | } else if ((vaddr >= EXEFS_CODE_VADDR) && (vaddr < EXEFS_CODE_VADDR_END)) { | 154 | } else if ((vaddr >= EXEFS_CODE_VADDR) && (vaddr < EXEFS_CODE_VADDR_END)) { |
| 155 | return g_exefs_code + (vaddr - EXEFS_CODE_VADDR); | 155 | return g_exefs_code + (vaddr - EXEFS_CODE_VADDR); |
| 156 | 156 | ||
| 157 | // FCRAM - GSP heap | 157 | // FCRAM - linear heap |
| 158 | } else if ((vaddr >= HEAP_GSP_VADDR) && (vaddr < HEAP_GSP_VADDR_END)) { | 158 | } else if ((vaddr >= HEAP_LINEAR_VADDR) && (vaddr < HEAP_LINEAR_VADDR_END)) { |
| 159 | return g_heap_gsp + (vaddr - HEAP_GSP_VADDR); | 159 | return g_heap_linear + (vaddr - HEAP_LINEAR_VADDR); |
| 160 | 160 | ||
| 161 | // FCRAM - application heap | 161 | // FCRAM - application heap |
| 162 | } else if ((vaddr >= HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) { | 162 | } else if ((vaddr >= HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) { |
| @@ -204,24 +204,24 @@ u32 MapBlock_Heap(u32 size, u32 operation, u32 permissions) { | |||
| 204 | } | 204 | } |
| 205 | 205 | ||
| 206 | /** | 206 | /** |
| 207 | * Maps a block of memory on the GSP heap | 207 | * Maps a block of memory on the linear heap |
| 208 | * @param size Size of block in bytes | 208 | * @param size Size of block in bytes |
| 209 | * @param operation Memory map operation type | 209 | * @param operation Memory map operation type |
| 210 | * @param flags Memory allocation flags | 210 | * @param flags Memory allocation flags |
| 211 | */ | 211 | */ |
| 212 | u32 MapBlock_HeapGSP(u32 size, u32 operation, u32 permissions) { | 212 | u32 MapBlock_HeapLinear(u32 size, u32 operation, u32 permissions) { |
| 213 | MemoryBlock block; | 213 | MemoryBlock block; |
| 214 | 214 | ||
| 215 | block.base_address = HEAP_GSP_VADDR; | 215 | block.base_address = HEAP_LINEAR_VADDR; |
| 216 | block.size = size; | 216 | block.size = size; |
| 217 | block.operation = operation; | 217 | block.operation = operation; |
| 218 | block.permissions = permissions; | 218 | block.permissions = permissions; |
| 219 | 219 | ||
| 220 | if (heap_gsp_map.size() > 0) { | 220 | if (heap_linear_map.size() > 0) { |
| 221 | const MemoryBlock last_block = heap_gsp_map.rbegin()->second; | 221 | const MemoryBlock last_block = heap_linear_map.rbegin()->second; |
| 222 | block.address = last_block.address + last_block.size; | 222 | block.address = last_block.address + last_block.size; |
| 223 | } | 223 | } |
| 224 | heap_gsp_map[block.GetVirtualAddress()] = block; | 224 | heap_linear_map[block.GetVirtualAddress()] = block; |
| 225 | 225 | ||
| 226 | return block.GetVirtualAddress(); | 226 | return block.GetVirtualAddress(); |
| 227 | } | 227 | } |
diff --git a/src/video_core/pica.h b/src/video_core/pica.h index 8bac178ca..4c3791ad9 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h | |||
| @@ -116,7 +116,7 @@ struct Regs { | |||
| 116 | u32 address; | 116 | u32 address; |
| 117 | 117 | ||
| 118 | u32 GetPhysicalAddress() const { | 118 | u32 GetPhysicalAddress() const { |
| 119 | return DecodeAddressRegister(address) - Memory::FCRAM_PADDR + Memory::HEAP_GSP_VADDR; | 119 | return DecodeAddressRegister(address) - Memory::FCRAM_PADDR + Memory::HEAP_LINEAR_VADDR; |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | // texture1 and texture2 store the texture format directly after the address | 122 | // texture1 and texture2 store the texture format directly after the address |
| @@ -312,7 +312,7 @@ struct Regs { | |||
| 312 | 312 | ||
| 313 | inline u32 GetBaseAddress() const { | 313 | inline u32 GetBaseAddress() const { |
| 314 | // TODO: Ugly, should fix PhysicalToVirtualAddress instead | 314 | // TODO: Ugly, should fix PhysicalToVirtualAddress instead |
| 315 | return DecodeAddressRegister(base_address) - Memory::FCRAM_PADDR + Memory::HEAP_GSP_VADDR; | 315 | return DecodeAddressRegister(base_address) - Memory::FCRAM_PADDR + Memory::HEAP_LINEAR_VADDR; |
| 316 | } | 316 | } |
| 317 | 317 | ||
| 318 | // Descriptor for internal vertex attributes | 318 | // Descriptor for internal vertex attributes |