mirror of
https://github.com/wiiu-env/MemoryMappingModule.git
synced 2024-11-22 01:39:20 +01:00
Use clang-format to format the code
This commit is contained in:
parent
07259a4f01
commit
6db316c682
66
.clang-format
Normal file
66
.clang-format
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
# Generated from CLion C/C++ Code Style settings
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveAssignments: None
|
||||||
|
AlignOperands: Align
|
||||||
|
AllowAllArgumentsOnNextLine: false
|
||||||
|
AllowAllConstructorInitializersOnNextLine: false
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
|
AllowShortBlocksOnASingleLine: Always
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: All
|
||||||
|
AllowShortIfStatementsOnASingleLine: Always
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortLoopsOnASingleLine: true
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
|
BreakBeforeBraces: Custom
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: false
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: Never
|
||||||
|
AfterEnum: false
|
||||||
|
AfterFunction: false
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterUnion: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: false
|
||||||
|
SplitEmptyRecord: true
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializers: BeforeColon
|
||||||
|
BreakInheritanceList: BeforeColon
|
||||||
|
ColumnLimit: 0
|
||||||
|
CompactNamespaces: false
|
||||||
|
ContinuationIndentWidth: 8
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentWidth: 4
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
|
MaxEmptyLinesToKeep: 2
|
||||||
|
NamespaceIndentation: All
|
||||||
|
ObjCSpaceAfterProperty: false
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
PointerAlignment: Right
|
||||||
|
ReflowComments: false
|
||||||
|
SpaceAfterCStyleCast: true
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: false
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCpp11BracedList: false
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 0
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInContainerLiterals: false
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Never
|
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
@ -6,8 +6,16 @@ on:
|
|||||||
- master
|
- master
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
clang-format:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: clang-format
|
||||||
|
run: |
|
||||||
|
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source
|
||||||
build-binary:
|
build-binary:
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
|
needs: clang-format
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: build binary
|
- name: build binary
|
||||||
|
8
.github/workflows/pr.yml
vendored
8
.github/workflows/pr.yml
vendored
@ -3,8 +3,16 @@ name: CI-PR
|
|||||||
on: [pull_request]
|
on: [pull_request]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
clang-format:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: clang-format
|
||||||
|
run: |
|
||||||
|
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source
|
||||||
build-binary:
|
build-binary:
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
|
needs: clang-format
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: build binary
|
- name: build binary
|
||||||
|
@ -17,4 +17,7 @@ docker run -it --rm -v ${PWD}:/project memorymappingmodule-builder make
|
|||||||
|
|
||||||
# make clean
|
# make clean
|
||||||
docker run -it --rm -v ${PWD}:/project memorymappingmodule-builder make clean
|
docker run -it --rm -v ${PWD}:/project memorymappingmodule-builder make clean
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Format the code via docker
|
||||||
|
`docker run --rm -it -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source -i`
|
@ -16,10 +16,10 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <coreinit/thread.h>
|
||||||
|
#include <cstdint>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <cstdint>
|
|
||||||
#include <coreinit/thread.h>
|
|
||||||
|
|
||||||
class CThread {
|
class CThread {
|
||||||
public:
|
public:
|
||||||
@ -27,7 +27,7 @@ public:
|
|||||||
|
|
||||||
//! constructor
|
//! constructor
|
||||||
explicit CThread(int32_t iAttr, int32_t iPriority = 16, int32_t iStackSize = 0x8000, CThread::Callback callback = nullptr, void *callbackArg = nullptr)
|
explicit CThread(int32_t iAttr, int32_t iPriority = 16, int32_t iStackSize = 0x8000, CThread::Callback callback = nullptr, void *callbackArg = nullptr)
|
||||||
: pThread(nullptr), pThreadStack(nullptr), pCallback(callback), pCallbackArg(callbackArg) {
|
: pThread(nullptr), pThreadStack(nullptr), pCallback(callback), pCallbackArg(callbackArg) {
|
||||||
//! save attribute assignment
|
//! save attribute assignment
|
||||||
iAttributes = iAttr;
|
iAttributes = iAttr;
|
||||||
//! allocate the thread
|
//! allocate the thread
|
||||||
@ -36,7 +36,9 @@ public:
|
|||||||
pThreadStack = (uint8_t *) memalign(0x20, iStackSize);
|
pThreadStack = (uint8_t *) memalign(0x20, iStackSize);
|
||||||
//! create the thread
|
//! create the thread
|
||||||
if (pThread && pThreadStack) {
|
if (pThread && pThreadStack) {
|
||||||
OSCreateThread(pThread, (int (*)(int, const char **)) &CThread::threadCallback, 1, (char *) this, (void *) (pThreadStack + iStackSize), iStackSize, iPriority, iAttributes);
|
// clang-format off
|
||||||
|
OSCreateThread(pThread, (int(*)(int, const char **)) & CThread::threadCallback, 1, (char *) this, (void *) (pThreadStack + iStackSize), iStackSize, iPriority, iAttributes);
|
||||||
|
// clang-format on
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,6 +131,7 @@ public:
|
|||||||
eAttributeDetach = 0x08,
|
eAttributeDetach = 0x08,
|
||||||
eAttributePinnedAff = 0x10
|
eAttributePinnedAff = 0x10
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static int32_t threadCallback(int32_t argc, void *arg) {
|
static int32_t threadCallback(int32_t argc, void *arg) {
|
||||||
//! After call to start() continue with the internal function
|
//! After call to start() continue with the internal function
|
||||||
|
@ -31,7 +31,6 @@ DECL_FUNCTION(uint32_t, KiPhysicalToEffectiveUncached, uint32_t addressSpace, ui
|
|||||||
uint32_t result = real_KiPhysicalToEffectiveUncached(addressSpace, virtualAddress);
|
uint32_t result = real_KiPhysicalToEffectiveUncached(addressSpace, virtualAddress);
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
return MemoryMapping_PhysicalToEffective(virtualAddress);
|
return MemoryMapping_PhysicalToEffective(virtualAddress);
|
||||||
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -54,10 +53,12 @@ DECL_FUNCTION(uint32_t, KiIsEffectiveRangeValid, uint32_t addressSpace, uint32_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define k_memcpy ((void (*)( void*, void*,uint32_t))(0xfff09e44))
|
// clang-format off
|
||||||
|
#define k_memcpy ((void(*)(void *, void *, uint32_t))(0xfff09e44))
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
DECL_FUNCTION(uint32_t, KiGetOrPutUserData, void *src, uint32_t size, void *dst, bool isRead) {
|
DECL_FUNCTION(uint32_t, KiGetOrPutUserData, void *src, uint32_t size, void *dst, bool isRead) {
|
||||||
//
|
//
|
||||||
if (isRead && MemoryMapping_EffectiveToPhysical((uint32_t) src) > 0) {
|
if (isRead && MemoryMapping_EffectiveToPhysical((uint32_t) src) > 0) {
|
||||||
k_memcpy(dst, src, size);
|
k_memcpy(dst, src, size);
|
||||||
return 1;
|
return 1;
|
||||||
@ -70,6 +71,7 @@ DECL_FUNCTION(uint32_t, KiGetOrPutUserData, void *src, uint32_t size, void *dst,
|
|||||||
return real_KiGetOrPutUserData(src, size, dst, isRead);
|
return real_KiGetOrPutUserData(src, size, dst, isRead);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
function_replacement_data_t function_replacements[] __attribute__((section(".data"))) = {
|
function_replacement_data_t function_replacements[] __attribute__((section(".data"))) = {
|
||||||
REPLACE_FUNCTION_VIA_ADDRESS(sCheckDataRange, 0x3200cf60, 0x0100cf60),
|
REPLACE_FUNCTION_VIA_ADDRESS(sCheckDataRange, 0x3200cf60, 0x0100cf60),
|
||||||
REPLACE_FUNCTION_VIA_ADDRESS(KiEffectiveToPhysical, 0xffee0aac, 0xffee0aac),
|
REPLACE_FUNCTION_VIA_ADDRESS(KiEffectiveToPhysical, 0xffee0aac, 0xffee0aac),
|
||||||
@ -79,5 +81,6 @@ function_replacement_data_t function_replacements[] __attribute__((section(".dat
|
|||||||
REPLACE_FUNCTION_VIA_ADDRESS(IPCKDriver_ValidatePhysicalAddress, 0xfff0cb5c, 0xfff0cb5c),
|
REPLACE_FUNCTION_VIA_ADDRESS(IPCKDriver_ValidatePhysicalAddress, 0xfff0cb5c, 0xfff0cb5c),
|
||||||
REPLACE_FUNCTION_VIA_ADDRESS(KiGetOrPutUserData, 0xffee0794, 0xffee0794),
|
REPLACE_FUNCTION_VIA_ADDRESS(KiGetOrPutUserData, 0xffee0794, 0xffee0794),
|
||||||
};
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
uint32_t function_replacements_size __attribute__((section(".data"))) = sizeof(function_replacements) / sizeof(function_replacement_data_t);
|
uint32_t function_replacements_size __attribute__((section(".data"))) = sizeof(function_replacements) / sizeof(function_replacement_data_t);
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <function_patcher/function_patching.h>
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <function_patcher/function_patching.h>
|
||||||
|
|
||||||
extern function_replacement_data_t function_replacements[] __attribute__((section(".data")));
|
extern function_replacement_data_t function_replacements[] __attribute__((section(".data")));
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <whb/log_udp.h>
|
|
||||||
#include <whb/log_cafe.h>
|
#include <whb/log_cafe.h>
|
||||||
#include <whb/log_module.h>
|
#include <whb/log_module.h>
|
||||||
|
#include <whb/log_udp.h>
|
||||||
|
|
||||||
uint32_t moduleLogInit = false;
|
uint32_t moduleLogInit = false;
|
||||||
uint32_t cafeLogInit = false;
|
uint32_t cafeLogInit = false;
|
||||||
uint32_t udpLogInit = false;
|
uint32_t udpLogInit = false;
|
||||||
#endif // DEBUG
|
#endif// DEBUG
|
||||||
|
|
||||||
void initLogging() {
|
void initLogging() {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -15,7 +15,7 @@ void initLogging() {
|
|||||||
cafeLogInit = WHBLogCafeInit();
|
cafeLogInit = WHBLogCafeInit();
|
||||||
udpLogInit = WHBLogUdpInit();
|
udpLogInit = WHBLogUdpInit();
|
||||||
}
|
}
|
||||||
#endif // DEBUG
|
#endif// DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
void deinitLogging() {
|
void deinitLogging() {
|
||||||
@ -32,5 +32,5 @@ void deinitLogging() {
|
|||||||
WHBLogUdpDeinit();
|
WHBLogUdpDeinit();
|
||||||
udpLogInit = false;
|
udpLogInit = false;
|
||||||
}
|
}
|
||||||
#endif // DEBUG
|
#endif// DEBUG
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <whb/log.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <whb/log.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -14,12 +14,14 @@ extern "C" {
|
|||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
|
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) \
|
||||||
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
do { \
|
||||||
|
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \
|
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) \
|
||||||
WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
do { \
|
||||||
|
WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -39,4 +41,3 @@ void deinitLogging();
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include <wums.h>
|
|
||||||
#include "memory_mapping.h"
|
|
||||||
#include <function_patcher/function_patching.h>
|
|
||||||
#include "function_replacements.h"
|
#include "function_replacements.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "memory_mapping.h"
|
||||||
|
#include <function_patcher/function_patching.h>
|
||||||
|
#include <wums.h>
|
||||||
|
|
||||||
WUMS_MODULE_EXPORT_NAME("homebrew_memorymapping");
|
WUMS_MODULE_EXPORT_NAME("homebrew_memorymapping");
|
||||||
WUMS_MODULE_SKIP_INIT_FINI();
|
WUMS_MODULE_SKIP_INIT_FINI();
|
||||||
@ -61,10 +61,10 @@ void *MemoryMappingAllocForGX2Ex(uint32_t size, int32_t align) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t MEMAllocFromMappedMemory __attribute__((__section__ (".data"))) = (uint32_t) MemoryMappingAlloc;
|
uint32_t MEMAllocFromMappedMemory __attribute__((__section__(".data"))) = (uint32_t) MemoryMappingAlloc;
|
||||||
uint32_t MEMAllocFromMappedMemoryEx __attribute__((__section__ (".data"))) = (uint32_t) MemoryMappingAllocEx;
|
uint32_t MEMAllocFromMappedMemoryEx __attribute__((__section__(".data"))) = (uint32_t) MemoryMappingAllocEx;
|
||||||
uint32_t MEMAllocFromMappedMemoryForGX2Ex __attribute__((__section__ (".data"))) = (uint32_t) MemoryMappingAllocForGX2Ex;
|
uint32_t MEMAllocFromMappedMemoryForGX2Ex __attribute__((__section__(".data"))) = (uint32_t) MemoryMappingAllocForGX2Ex;
|
||||||
uint32_t MEMFreeToMappedMemory __attribute__((__section__ (".data"))) = (uint32_t) MemoryMappingFree;
|
uint32_t MEMFreeToMappedMemory __attribute__((__section__(".data"))) = (uint32_t) MemoryMappingFree;
|
||||||
|
|
||||||
WUMS_EXPORT_FUNCTION(MemoryMappingEffectiveToPhysical);
|
WUMS_EXPORT_FUNCTION(MemoryMappingEffectiveToPhysical);
|
||||||
WUMS_EXPORT_FUNCTION(MemoryMappingPhysicalToEffective);
|
WUMS_EXPORT_FUNCTION(MemoryMappingPhysicalToEffective);
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
#include "memory_mapping.h"
|
#include "memory_mapping.h"
|
||||||
#include <coreinit/memorymap.h>
|
|
||||||
#include <coreinit/memdefaultheap.h>
|
|
||||||
#include <coreinit/cache.h>
|
#include <coreinit/cache.h>
|
||||||
|
#include <coreinit/memdefaultheap.h>
|
||||||
#include <coreinit/memexpheap.h>
|
#include <coreinit/memexpheap.h>
|
||||||
|
#include <coreinit/memorymap.h>
|
||||||
#include <coreinit/thread.h>
|
#include <coreinit/thread.h>
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include "memory.h"
|
|
||||||
#include "logger.h"
|
|
||||||
#include "CThread.h"
|
#include "CThread.h"
|
||||||
|
#include "logger.h"
|
||||||
|
#include "memory.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
// #define DEBUG_FUNCTION_LINE(x,...)
|
// #define DEBUG_FUNCTION_LINE(x,...)
|
||||||
|
|
||||||
void runOnAllCores(CThread::Callback callback, void *callbackArg, int32_t iAttr = 0, int32_t iPriority = 16, int32_t iStackSize = 0x8000) {
|
void runOnAllCores(CThread::Callback callback, void *callbackArg, int32_t iAttr = 0, int32_t iPriority = 16, int32_t iStackSize = 0x8000) {
|
||||||
int32_t aff[] = {CThread::eAttributeAffCore2, CThread::eAttributeAffCore1, CThread::eAttributeAffCore0};
|
int32_t aff[] = {CThread::eAttributeAffCore2, CThread::eAttributeAffCore1, CThread::eAttributeAffCore0};
|
||||||
|
|
||||||
for (int i: aff) {
|
for (int i : aff) {
|
||||||
CThread thread(iAttr | i, iPriority, iStackSize, callback, callbackArg);
|
CThread thread(iAttr | i, iPriority, iStackSize, callback, callbackArg);
|
||||||
thread.resumeThread();
|
thread.resumeThread();
|
||||||
}
|
}
|
||||||
@ -159,7 +159,6 @@ void MemoryMapping_searchEmptyMemoryRegions() {
|
|||||||
if (success) {
|
if (success) {
|
||||||
DEBUG_FUNCTION_LINE("Test %d was successful!", i + 1);
|
DEBUG_FUNCTION_LINE("Test %d was successful!", i + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
DEBUG_FUNCTION_LINE("All tests done.");
|
DEBUG_FUNCTION_LINE("All tests done.");
|
||||||
}
|
}
|
||||||
@ -274,7 +273,6 @@ void MemoryMapping_readTestValuesFromMemory() {
|
|||||||
if (success) {
|
if (success) {
|
||||||
DEBUG_FUNCTION_LINE("Test %d was successful!", i + 1);
|
DEBUG_FUNCTION_LINE("Test %d was successful!", i + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
DEBUG_FUNCTION_LINE("All tests done.");
|
DEBUG_FUNCTION_LINE("All tests done.");
|
||||||
}
|
}
|
||||||
@ -524,7 +522,7 @@ uint32_t MemoryMapping_getAreaSizeFromPageTable(uint32_t start, uint32_t maxSize
|
|||||||
cur_end_addr = (segment + 1) * 0x10000000;
|
cur_end_addr = (segment + 1) * 0x10000000;
|
||||||
}
|
}
|
||||||
if (segment != sr_start) {
|
if (segment != sr_start) {
|
||||||
cur_address = (segment) * 0x10000000;
|
cur_address = (segment) *0x10000000;
|
||||||
}
|
}
|
||||||
bool success = true;
|
bool success = true;
|
||||||
for (uint32_t addr = cur_address; addr < cur_end_addr; addr += pageSize) {
|
for (uint32_t addr = cur_address; addr < cur_end_addr; addr += pageSize) {
|
||||||
@ -645,8 +643,7 @@ void MemoryMapping_printPageTableTranslation(sr_table_t srTable, uint32_t *trans
|
|||||||
current.kp == kp &&
|
current.kp == kp &&
|
||||||
current.nx == nx &&
|
current.nx == nx &&
|
||||||
current.pp == pp &&
|
current.pp == pp &&
|
||||||
current.phys == phys - current.size
|
current.phys == phys - current.size) {
|
||||||
) {
|
|
||||||
current.size += pageSize;
|
current.size += pageSize;
|
||||||
//DEBUG_FUNCTION_LINE("New size of %08X is %08X",current.addr,current.size);
|
//DEBUG_FUNCTION_LINE("New size of %08X is %08X",current.addr,current.size);
|
||||||
} else {
|
} else {
|
||||||
@ -681,7 +678,7 @@ void MemoryMapping_printPageTableTranslation(sr_table_t srTable, uint32_t *trans
|
|||||||
const char *access1[] = {"read/write", "read/write", "read/write", "read only"};
|
const char *access1[] = {"read/write", "read/write", "read/write", "read only"};
|
||||||
const char *access2[] = {"no access", "read only", "read/write", "read only"};
|
const char *access2[] = {"no access", "read only", "read/write", "read only"};
|
||||||
|
|
||||||
for (auto cur: pageInfos) {
|
for (auto cur : pageInfos) {
|
||||||
DEBUG_FUNCTION_LINE_VERBOSE("%08X %08X -> %08X %08X. user access %s. supervisor access %s. %s", cur.addr, cur.addr + cur.size, cur.phys, cur.phys + cur.size,
|
DEBUG_FUNCTION_LINE_VERBOSE("%08X %08X -> %08X %08X. user access %s. supervisor access %s. %s", cur.addr, cur.addr + cur.size, cur.phys, cur.phys + cur.size,
|
||||||
cur.kp ? access2[cur.pp] : access1[cur.pp],
|
cur.kp ? access2[cur.pp] : access1[cur.pp],
|
||||||
cur.ks ? access2[cur.pp] : access1[cur.pp], cur.nx ? "not executable" : "executable");
|
cur.ks ? access2[cur.pp] : access1[cur.pp], cur.nx ? "not executable" : "executable");
|
||||||
@ -879,5 +876,3 @@ uint32_t MemoryMapping_EffectiveToPhysical(uint32_t effectiveAddress) {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <kernel/kernel.h>
|
#include <kernel/kernel.h>
|
||||||
#include <kernel/kernel_defs.h>
|
#include <kernel/kernel_defs.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef struct pageInformation_ {
|
typedef struct pageInformation_ {
|
||||||
uint32_t addr;
|
uint32_t addr;
|
||||||
@ -31,47 +31,58 @@ typedef struct _memory_mapping_t {
|
|||||||
const memory_values_t *physical_addresses;
|
const memory_values_t *physical_addresses;
|
||||||
} memory_mapping_t;
|
} memory_mapping_t;
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
#define SEGMENT_UNIQUE_ID 0x00AABBCC // Unique ID. Chosen arbitrary.
|
#define SEGMENT_UNIQUE_ID 0x00AABBCC // Unique ID. Chosen arbitrary.
|
||||||
#define PAGE_INDEX_SHIFT (32-15)
|
#define PAGE_INDEX_SHIFT (32-15)
|
||||||
#define PAGE_INDEX_MASK ((1 << (28 - PAGE_INDEX_SHIFT)) - 1)
|
#define PAGE_INDEX_MASK ((1 << (28 - PAGE_INDEX_SHIFT)) - 1)
|
||||||
|
|
||||||
#define MEMORY_START_BASE 0x80000000
|
#define MEMORY_START_BASE 0x80000000
|
||||||
#define MEMORY_START_VIDEO_BASE (MEMORY_START_BASE + 0x08000000)
|
#define MEMORY_START_VIDEO_BASE (MEMORY_START_BASE + 0x08000000)
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
const memory_values_t mem_vals_heap_1[] = {
|
const memory_values_t mem_vals_heap_1[] = {
|
||||||
{0x28000000 + 0x06620000, 0x28000000 + 0x07F80000}, // size: 25984 kB
|
{0x28000000 + 0x06620000, 0x28000000 + 0x07F80000}, // size: 25984 kB
|
||||||
{0, 0}
|
{0, 0}
|
||||||
};
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
#define MEMORY_HEAP0_SIZE 0x1960000
|
#define MEMORY_HEAP0_SIZE 0x1960000
|
||||||
#define MEMORY_HEAP0 MEMORY_START_BASE
|
#define MEMORY_HEAP0 MEMORY_START_BASE
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
const memory_values_t mem_vals_heap_2[] = {
|
const memory_values_t mem_vals_heap_2[] = {
|
||||||
{0x28000000 + 0x09000000, 0x28000000 + 0x09E20000}, // size: 14464 kB
|
{0x28000000 + 0x09000000, 0x28000000 + 0x09E20000}, // size: 14464 kB
|
||||||
{0, 0}
|
{0, 0}
|
||||||
};
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
#define MEMORY_HEAP1_SIZE 0xE20000
|
#define MEMORY_HEAP1_SIZE 0xE20000
|
||||||
#define MEMORY_HEAP1 (MEMORY_HEAP0 + MEMORY_HEAP0_SIZE)
|
#define MEMORY_HEAP1 (MEMORY_HEAP0 + MEMORY_HEAP0_SIZE)
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
const memory_values_t mem_vals_heap_3[] = {
|
const memory_values_t mem_vals_heap_3[] = {
|
||||||
{0x28000000 + 0x058E0000, 0x28000000 + 0x06000000}, // size: 7296 kB
|
{0x28000000 + 0x058E0000, 0x28000000 + 0x06000000}, // size: 7296 kB
|
||||||
{0, 0}
|
{0, 0}
|
||||||
};
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
#define MEMORY_HEAP2_SIZE 0x720000
|
#define MEMORY_HEAP2_SIZE 0x720000
|
||||||
#define MEMORY_HEAP2 (MEMORY_HEAP1 + MEMORY_HEAP1_SIZE)
|
#define MEMORY_HEAP2 (MEMORY_HEAP1 + MEMORY_HEAP1_SIZE)
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
const memory_values_t mem_vals_heap_4[] = {
|
const memory_values_t mem_vals_heap_4[] = {
|
||||||
{0x28000000 + 0x053C0000, 0x28000000 + 0x05880000}, // size: 4864 kB
|
{0x28000000 + 0x053C0000, 0x28000000 + 0x05880000}, // size: 4864 kB
|
||||||
{0, 0}
|
{0, 0}
|
||||||
};
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
#define MEMORY_HEAP3_SIZE 0x4C0000
|
#define MEMORY_HEAP3_SIZE 0x4C0000
|
||||||
#define MEMORY_HEAP3 (MEMORY_HEAP2 + MEMORY_HEAP2_SIZE)
|
#define MEMORY_HEAP3 (MEMORY_HEAP2 + MEMORY_HEAP2_SIZE)
|
||||||
|
|
||||||
#define MEMORY_HEAP4 (MEMORY_HEAP3 + MEMORY_HEAP3_SIZE)
|
#define MEMORY_HEAP4 (MEMORY_HEAP3 + MEMORY_HEAP3_SIZE)
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
const memory_values_t mem_vals_video[] = {
|
const memory_values_t mem_vals_video[] = {
|
||||||
// The GPU doesn't have access to the 0x28000000 - 0x32000000 area, so we need memory from somewhere else.
|
// The GPU doesn't have access to the 0x28000000 - 0x32000000 area, so we need memory from somewhere else.
|
||||||
// From the SharedReadHeap of the loader.
|
// From the SharedReadHeap of the loader.
|
||||||
@ -105,10 +116,14 @@ const memory_values_t mem_vals_video[] = {
|
|||||||
//{0x18000000 , 0x18000000 +0x3000000}, // size: 3840 kB
|
//{0x18000000 , 0x18000000 +0x3000000}, // size: 3840 kB
|
||||||
{0, 0}
|
{0, 0}
|
||||||
};
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
#define MEMORY_START_VIDEO MEMORY_START_VIDEO_BASE
|
#define MEMORY_START_VIDEO MEMORY_START_VIDEO_BASE
|
||||||
#define MEMORY_END_VIDEO (MEMORY_START_VIDEO + 0xE60000)
|
#define MEMORY_END_VIDEO (MEMORY_START_VIDEO + 0xE60000)
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
const memory_mapping_t mem_mapping[] = {
|
const memory_mapping_t mem_mapping[] = {
|
||||||
{MEMORY_HEAP0, MEMORY_HEAP1, mem_vals_heap_1},
|
{MEMORY_HEAP0, MEMORY_HEAP1, mem_vals_heap_1},
|
||||||
{MEMORY_HEAP1, MEMORY_HEAP2, mem_vals_heap_2},
|
{MEMORY_HEAP1, MEMORY_HEAP2, mem_vals_heap_2},
|
||||||
@ -117,8 +132,9 @@ const memory_mapping_t mem_mapping[] = {
|
|||||||
{MEMORY_START_VIDEO, MEMORY_END_VIDEO, mem_vals_video},
|
{MEMORY_START_VIDEO, MEMORY_END_VIDEO, mem_vals_video},
|
||||||
{0, 0, nullptr}
|
{0, 0, nullptr}
|
||||||
};
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
// Values needs to be aligned to 0x20000 and size needs to be a multiple of 0x20000
|
// Values needs to be aligned to 0x20000 and size needs to be a multiple of 0x20000
|
||||||
const memory_values_t mem_vals_heap[] = {
|
const memory_values_t mem_vals_heap[] = {
|
||||||
// 5.5.2 EUR
|
// 5.5.2 EUR
|
||||||
@ -162,6 +178,7 @@ const memory_values_t mem_vals_heap[] = {
|
|||||||
|
|
||||||
{0, 0}
|
{0, 0}
|
||||||
};
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
|
||||||
uint32_t MemoryMapping_MEMGetAllocatableSize();
|
uint32_t MemoryMapping_MEMGetAllocatableSize();
|
||||||
|
Loading…
Reference in New Issue
Block a user