Fix types

This commit is contained in:
Maschell 2018-06-20 16:15:23 +02:00
parent 25c3488c3c
commit 6e6c727b12
51 changed files with 539 additions and 536 deletions

View File

@ -40,6 +40,7 @@ cat <<EOF > $outFile
* Any manual modification of this file will be overwriten by the generation.
*****************************************************************************/
#include <resources/filelist.h>
#include <stdint.h>
EOF
@ -47,8 +48,8 @@ for i in ${files[@]}
do
filename=${i%.*}
extension=${i##*.}
echo 'extern const u8 '$filename'_'$extension'[];' >> $outFile
echo 'extern const u32 '$filename'_'$extension'_size;' >> $outFile
echo 'extern const uint8_t '$filename'_'$extension'[];' >> $outFile
echo 'extern const uint32_t '$filename'_'$extension'_size;' >> $outFile
echo '' >> $outFile
done

View File

@ -60,7 +60,7 @@ Application::~Application() {
DEBUG_FUNCTION_LINE("Destroy controller\n");
for(s32 i = 0; i < 5; i++)
for(int32_t i = 0; i < 5; i++)
delete controller[i];
//We may have to handle Asyncdelete in the Destructors.
@ -82,7 +82,7 @@ Application::~Application() {
SoundHandler::DestroyInstance();
}
s32 Application::exec() {
int32_t Application::exec() {
//! start main GX2 thread
resumeThread();
//! now wait for thread to finish
@ -99,7 +99,7 @@ void Application::fadeOut() {
0, 0, 0, 255
});
for(s32 i = 0; i < 255; i += 10) {
for(int32_t i = 0; i < 255; i += 10) {
if(i > 255)
i = 255;
@ -177,7 +177,7 @@ void Application::executeThread(void) {
DEBUG_FUNCTION_LINE("Entering main loop\n");
while(!exitApplication && !reloadUIflag) {
//! Read out inputs
for(s32 i = 0; i < 5; i++) {
for(int32_t i = 0; i < 5; i++) {
if(controller[i]->update(video->getTvWidth(), video->getTvHeight()) == false)
continue;

View File

@ -52,12 +52,12 @@ public:
return bgMusic;
}
s32 exec(void);
int32_t exec(void);
void fadeOut(void);
void reloadUI(void);
void quit(s32 code) {
void quit(int32_t code) {
exitCode = code;
exitApplication = true;
}
@ -79,7 +79,7 @@ private:
CVideo *video;
MainWindow *mainWindow;
GuiController *controller[5];
s32 exitCode;
int32_t exitCode;
};
#endif //_APPLICATION_H

View File

@ -15,9 +15,9 @@ extern "C" {
#define NAME_PREFIX_SD "sd: "
#define NAME_PREFIX_USB "usb:"
#define ELF_DATA_ADDR (*(volatile unsigned int*)(MEM_BASE + 0x1300 + 0x00))
#define ELF_DATA_SIZE (*(volatile unsigned int*)(MEM_BASE + 0x1300 + 0x04))
#define MAIN_ENTRY_ADDR (*(volatile unsigned int*)(MEM_BASE + 0x1400 + 0x00))
#define ELF_DATA_ADDR (*(volatile uint32_t*)(MEM_BASE + 0x1300 + 0x00))
#define ELF_DATA_SIZE (*(volatile uint32_t*)(MEM_BASE + 0x1300 + 0x04))
#define MAIN_ENTRY_ADDR (*(volatile uint32_t*)(MEM_BASE + 0x1400 + 0x00))
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0

View File

@ -3,12 +3,12 @@
replacement_data_t gbl_replacement_data __attribute__((section(".data")));
dyn_linking_relocation_data_t gbl_dyn_linking_data __attribute__((section(".data")));
u8 gAppStatus __attribute__((section(".data"))) = 0;
u64 gGameTitleID __attribute__((section(".data"))) = 0;
volatile u8 gSDInitDone __attribute__((section(".data"))) = 0;
uint8_t gAppStatus __attribute__((section(".data"))) = 0;
uint64_t gGameTitleID __attribute__((section(".data"))) = 0;
volatile uint8_t gSDInitDone __attribute__((section(".data"))) = 0;
void * ntfs_mounts __attribute__((section(".data"))) = NULL;
int ntfs_mount_count __attribute__((section(".data"))) = 0;
int32_t ntfs_mount_count __attribute__((section(".data"))) = 0;
struct buffer_store drc_store __attribute__((section(".data")));
struct buffer_store tv_store __attribute__((section(".data")));

View File

@ -6,13 +6,13 @@
extern replacement_data_t gbl_replacement_data;
extern dyn_linking_relocation_data_t gbl_dyn_linking_data;
extern u8 gAppStatus;
extern u64 gGameTitleID;
extern volatile u8 gSDInitDone;
extern uint8_t gAppStatus;
extern uint64_t gGameTitleID;
extern volatile uint8_t gSDInitDone;
extern void * ntfs_mounts;
extern int ntfs_mount_count;
extern int32_t ntfs_mount_count;
extern struct buffer_store drc_store;
extern struct buffer_store tv_store;

View File

@ -1,7 +1,7 @@
#include <string.h>
#include "main.h"
int __entry_menu(int argc, char **argv) {
int32_t __entry_menu(int32_t argc, char **argv) {
//! *******************************************************************
//! * Jump to our application *
//! *******************************************************************

View File

@ -62,11 +62,11 @@
static void ApplyPatchesAndCallHookStartingApp();
static void RestorePatches();
s32 isInMiiMakerHBL();
int32_t isInMiiMakerHBL();
void readAndPrintSegmentRegister(CThread *thread, void *arg);
extern "C" int Menu_Main(int argc, char **argv) {
extern "C" int32_t Menu_Main(int32_t argc, char **argv) {
if(gAppStatus == 2) {
//"No, we don't want to patch stuff again.");
return EXIT_RELAUNCH_ON_LOAD;
@ -86,7 +86,7 @@ extern "C" int Menu_Main(int argc, char **argv) {
log_init();
DEBUG_FUNCTION_LINE("We have %d kb for plugins.\n",(PLUGIN_LOCATION_END_ADDRESS-getApplicationEndAddr())/1024);
setup_os_exceptions();
//setup_os_exceptions();
DEBUG_FUNCTION_LINE("Wii U Plugin System Loader %s\n",APP_VERSION);
DEBUG_FUNCTION_LINE("Sizeof dyn_linking_relocation_data_t %d\n",sizeof(dyn_linking_relocation_data_t));
@ -97,7 +97,7 @@ extern "C" int Menu_Main(int argc, char **argv) {
gGameTitleID = OSGetTitleID();
s32 result = 0;
int32_t result = 0;
//Reset everything when were going back to the Mii Maker
if(isInMiiMakerHBL()) {
@ -191,7 +191,7 @@ extern "C" int Menu_Main(int argc, char **argv) {
void ApplyPatchesAndCallHookStartingApp() {
PatchInvidualMethodHooks(method_hooks_hooks, method_hooks_size_hooks, method_calls_hooks);
for(int plugin_index=0; plugin_index<gbl_replacement_data.number_used_plugins; plugin_index++) {
for(int32_t plugin_index=0; plugin_index<gbl_replacement_data.number_used_plugins; plugin_index++) {
CallHookEx(WUPS_LOADER_HOOK_STARTING_APPLICATION,plugin_index);
new_PatchInvidualMethodHooks(&gbl_replacement_data.plugin_data[plugin_index]);
CallHookEx(WUPS_LOADER_HOOK_FUNCTIONS_PATCHED,plugin_index);
@ -203,14 +203,14 @@ void DeInit() {
}
void RestorePatches() {
for(int plugin_index=gbl_replacement_data.number_used_plugins-1; plugin_index>=0; plugin_index--) {
for(int32_t plugin_index=gbl_replacement_data.number_used_plugins-1; plugin_index>=0; plugin_index--) {
DEBUG_FUNCTION_LINE("Restoring function for plugin: %d\n",plugin_index);
new_RestoreInvidualInstructions(&gbl_replacement_data.plugin_data[plugin_index]);
}
RestoreInvidualInstructions(method_hooks_hooks, method_hooks_size_hooks);
}
s32 isInMiiMakerHBL() {
int32_t isInMiiMakerHBL() {
if (OSGetTitleID != 0 && (
OSGetTitleID() == 0x000500101004A200 || // mii maker eur
OSGetTitleID() == 0x000500101004A100 || // mii maker usa
@ -229,7 +229,7 @@ void Init() {
}
void Init_SD_USB() {
int res = IOSUHAX_Open(NULL);
int32_t res = IOSUHAX_Open(NULL);
if(res < 0) {
ExecuteIOSExploitWithDefaultConfig();
}
@ -248,7 +248,7 @@ void Init_SD_USB() {
} else {
DEBUG_FUNCTION_LINE("Using IOSUHAX for SD/USB access\n");
gSDInitDone |= WUPS_SDUSB_LIBIOSU_LOADED;
int ntfs_mounts = mountAllNTFS();
int32_t ntfs_mounts = mountAllNTFS();
if(ntfs_mounts > 0) {
gSDInitDone |= WUPS_USB_MOUNTED_LIBNTFS;
}

View File

@ -29,7 +29,7 @@ extern "C" {
#include <libelf.h>
//! C wrapper for our C++ functions
int Menu_Main(int argc, char **argv);
int32_t Menu_Main(int32_t argc, char **argv);
void Init_SD_USB();

View File

@ -27,10 +27,10 @@
MainWindow * MainWindow::instance = NULL;
MainWindow::MainWindow(s32 w, s32 h)
MainWindow::MainWindow(int32_t w, int32_t h)
: width(w)
, height(h) {
for(s32 i = 0; i < 4; i++) {
for(int32_t i = 0; i < 4; i++) {
std::string filename = StringTools::strfmt("player%i_point.png", i+1);
pointerImgData[i] = Resources::GetImageData(filename.c_str());
pointerImg[i] = new GuiImage(pointerImgData[i]);
@ -51,7 +51,7 @@ MainWindow::~MainWindow() {
delete drcElements[0];
remove(drcElements[0]);
}
for(s32 i = 0; i < 4; i++) {
for(int32_t i = 0; i < 4; i++) {
delete pointerImg[i];
Resources::RemoveImageData(pointerImgData[i]);
}
@ -59,16 +59,16 @@ MainWindow::~MainWindow() {
void MainWindow::updateEffects() {
//! dont read behind the initial elements in case one was added
u32 tvSize = tvElements.size();
u32 drcSize = drcElements.size();
uint32_t tvSize = tvElements.size();
uint32_t drcSize = drcElements.size();
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
for(uint32_t i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
drcElements[i]->updateEffects();
}
//! only update TV elements that are not updated yet because they are on DRC
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
u32 n;
for(uint32_t i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
uint32_t n;
for(n = 0; (n < drcSize) && (n < drcElements.size()); n++) {
if(tvElements[i] == drcElements[n])
break;
@ -81,16 +81,16 @@ void MainWindow::updateEffects() {
void MainWindow::process() {
//! dont read behind the initial elements in case one was added
u32 tvSize = tvElements.size();
u32 drcSize = drcElements.size();
uint32_t tvSize = tvElements.size();
uint32_t drcSize = drcElements.size();
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
for(uint32_t i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
drcElements[i]->process();
}
//! only update TV elements that are not updated yet because they are on DRC
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
u32 n;
for(uint32_t i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
uint32_t n;
for(n = 0; (n < drcSize) && (n < drcElements.size()); n++) {
if(tvElements[i] == drcElements[n])
break;
@ -103,26 +103,26 @@ void MainWindow::process() {
void MainWindow::update(GuiController *controller) {
//! dont read behind the initial elements in case one was added
//u32 tvSize = tvElements.size();
//uint32_t tvSize = tvElements.size();
if(controller->chan & GuiTrigger::CHANNEL_1) {
u32 drcSize = drcElements.size();
uint32_t drcSize = drcElements.size();
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
for(uint32_t i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
drcElements[i]->update(controller);
}
} else {
u32 tvSize = tvElements.size();
uint32_t tvSize = tvElements.size();
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
for(uint32_t i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
tvElements[i]->update(controller);
}
}
// //! only update TV elements that are not updated yet because they are on DRC
// for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i)
// for(uint32_t i = 0; (i < tvSize) && (i < tvElements.size()); ++i)
// {
// u32 n;
// uint32_t n;
// for(n = 0; (n < drcSize) && (n < drcElements.size()); n++)
// {
// if(tvElements[i] == drcElements[n])
@ -135,9 +135,9 @@ void MainWindow::update(GuiController *controller) {
// }
if(controller->chanIdx >= 1 && controller->chanIdx <= 4 && controller->data.validPointer) {
s32 wpadIdx = controller->chanIdx - 1;
f32 posX = controller->data.x;
f32 posY = controller->data.y;
int32_t wpadIdx = controller->chanIdx - 1;
float posX = controller->data.x;
float posY = controller->data.y;
pointerImg[wpadIdx]->setPosition(posX, posY);
pointerImg[wpadIdx]->setAngle(controller->data.pointerAngle);
pointerValid[wpadIdx] = true;
@ -145,11 +145,11 @@ void MainWindow::update(GuiController *controller) {
}
void MainWindow::drawDrc(CVideo *video) {
for(u32 i = 0; i < drcElements.size(); ++i) {
for(uint32_t i = 0; i < drcElements.size(); ++i) {
drcElements[i]->draw(video);
}
for(s32 i = 0; i < 4; i++) {
for(int32_t i = 0; i < 4; i++) {
if(pointerValid[i]) {
pointerImg[i]->setAlpha(0.5f);
pointerImg[i]->draw(video);
@ -159,11 +159,11 @@ void MainWindow::drawDrc(CVideo *video) {
}
void MainWindow::drawTv(CVideo *video) {
for(u32 i = 0; i < tvElements.size(); ++i) {
for(uint32_t i = 0; i < tvElements.size(); ++i) {
tvElements[i]->draw(video);
}
for(s32 i = 0; i < 4; i++) {
for(int32_t i = 0; i < 4; i++) {
if(pointerValid[i]) {
pointerImg[i]->draw(video);
pointerValid[i] = false;
@ -185,16 +185,16 @@ void MainWindow::OnOpenEffectFinish(GuiElement *element) {
}
void MainWindow::appendToAllElements(GuiElement * element) {
u32 drcSize = drcElements.size();
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
uint32_t drcSize = drcElements.size();
for(uint32_t i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
GuiFrame * realElement = dynamic_cast<GuiFrame*>(drcElements[i]);
if(realElement != NULL) {
realElement->append(element);
}
}
u32 tvSize = tvElements.size();
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
uint32_t tvSize = tvElements.size();
for(uint32_t i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
GuiFrame * realElement = dynamic_cast<GuiFrame*>(tvElements[i]);
if(realElement != NULL) {
realElement->append(element);
@ -203,16 +203,16 @@ void MainWindow::appendToAllElements(GuiElement * element) {
}
void MainWindow::removeFromAllElements(GuiElement * element) {
u32 drcSize = drcElements.size();
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
uint32_t drcSize = drcElements.size();
for(uint32_t i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
GuiFrame * realElement = dynamic_cast<GuiFrame*>(drcElements[i]);
if(realElement != NULL) {
realElement->remove(element);
}
}
u32 tvSize = tvElements.size();
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
uint32_t tvSize = tvElements.size();
for(uint32_t i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
GuiFrame * realElement = dynamic_cast<GuiFrame*>(tvElements[i]);
if(realElement != NULL) {
realElement->remove(element);
@ -221,26 +221,26 @@ void MainWindow::removeFromAllElements(GuiElement * element) {
}
void MainWindow::setState(s32 val, s32 c) {
u32 drcSize = drcElements.size();
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
void MainWindow::setState(int32_t val, int32_t c) {
uint32_t drcSize = drcElements.size();
for(uint32_t i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
drcElements[i]->setState(val,c);
}
u32 tvSize = tvElements.size();
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
uint32_t tvSize = tvElements.size();
for(uint32_t i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
tvElements[i]->setState(val,c);
}
}
void MainWindow::clearState(s32 val, s32 c) {
u32 drcSize = drcElements.size();
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
void MainWindow::clearState(int32_t val, int32_t c) {
uint32_t drcSize = drcElements.size();
for(uint32_t i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
drcElements[i]->clearState(val,c);
}
u32 tvSize = tvElements.size();
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
uint32_t tvSize = tvElements.size();
for(uint32_t i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
tvElements[i]->clearState(val,c);
}
}

View File

@ -30,7 +30,7 @@ public:
static MainWindow *instance;
static MainWindow *getInstance(s32 w,s32 h) {
static MainWindow *getInstance(int32_t w,int32_t h) {
if(!instance) {
instance = new MainWindow(w, h);
}
@ -68,14 +68,14 @@ public:
appendDrc(e);
}
void insertTv(u32 pos, GuiElement *e) {
void insertTv(uint32_t pos, GuiElement *e) {
if(!e)
return;
removeTv(e);
tvElements.insert(tvElements.begin() + pos, e);
}
void insertDrc(u32 pos, GuiElement *e) {
void insertDrc(uint32_t pos, GuiElement *e) {
if(!e)
return;
@ -83,13 +83,13 @@ public:
drcElements.insert(drcElements.begin() + pos, e);
}
void insert(u32 pos, GuiElement *e) {
void insert(uint32_t pos, GuiElement *e) {
insertTv(pos, e);
insertDrc(pos, e);
}
void removeTv(GuiElement *e) {
for(u32 i = 0; i < tvElements.size(); ++i) {
for(uint32_t i = 0; i < tvElements.size(); ++i) {
if(e == tvElements[i]) {
tvElements.erase(tvElements.begin() + i);
break;
@ -97,7 +97,7 @@ public:
}
}
void removeDrc(GuiElement *e) {
for(u32 i = 0; i < drcElements.size(); ++i) {
for(uint32_t i = 0; i < drcElements.size(); ++i) {
if(e == drcElements[i]) {
drcElements.erase(drcElements.begin() + i);
break;
@ -122,8 +122,8 @@ public:
void appendToAllElements(GuiElement * element);
void removeFromAllElements(GuiElement * element);
void setState(s32 i, s32 c = -1 );
void clearState(s32 i, s32 c = -1);
void setState(int32_t i, int32_t c = -1 );
void clearState(int32_t i, int32_t c = -1);
void lockGUI() {
guiMutex.lock();
@ -133,13 +133,13 @@ public:
}
private:
MainWindow(s32 w, s32 h);
MainWindow(int32_t w, int32_t h);
void SetupMainView(void);
void OnOpenEffectFinish(GuiElement *element);
void OnCloseEffectFinish(GuiElement *element);
s32 width, height;
int32_t width, height;
std::vector<GuiElement *> drcElements;
std::vector<GuiElement *> tvElements;

View File

@ -16,7 +16,7 @@
****************************************************************************/
#include "MainWindowContent.h"
MainWindowContent::MainWindowContent(s32 w, s32 h)
MainWindowContent::MainWindowContent(int32_t w, int32_t h)
: GuiFrame(w, h)
, width(w)
, height(h)

View File

@ -31,7 +31,7 @@ public:
CONTENT_HOME,
};
MainWindowContent(s32 w, s32 h);
MainWindowContent(int32_t w, int32_t h);
virtual ~MainWindowContent();
void SetScreen(ContentTemplate * new_content);
@ -51,7 +51,7 @@ public:
}
private:
s32 width, height;
int32_t width, height;
GuiImage bgImageColor;
ContentTemplate * content = NULL;

View File

@ -17,7 +17,7 @@
#include "MainWindowGUI.h"
#include "MenuCommon.h"
MainWindowGUI::MainWindowGUI(s32 w, s32 h)
MainWindowGUI::MainWindowGUI(int32_t w, int32_t h)
: GuiFrame(w, h)
, width(w)
, height(h)
@ -27,7 +27,7 @@ MainWindowGUI::MainWindowGUI(s32 w, s32 h)
append(&content);
}
void MainWindowGUI::setState(s32 i, s32 c) {
void MainWindowGUI::setState(int32_t i, int32_t c) {
GuiFrame::setState(i,c);
}

View File

@ -25,13 +25,13 @@
class MainWindowGUI : public GuiFrame, public sigslot::has_slots<> {
public:
MainWindowGUI(s32 w, s32 h);
MainWindowGUI(int32_t w, int32_t h);
virtual ~MainWindowGUI();
private:
s32 width, height;
int32_t width, height;
MainWindowContent content;
void setState(s32 i, s32 c);
void setState(int32_t i, int32_t c);
void process();
};

View File

@ -10,14 +10,14 @@ extern "C" {
typedef struct _sr_table_t
{
u32 value[16];
u32 sdr1;
uint32_t value[16];
uint32_t sdr1;
} sr_table_t;
typedef struct _bat_t
{
u32 h;
u32 l;
uint32_t h;
uint32_t l;
} bat_t;
typedef struct _bat_table_t

View File

@ -4,7 +4,7 @@
#include <kernel/syscalls.h>
static void KernelReadSRs(sr_table_t * table) {
u32 i = 0;
uint32_t i = 0;
// calculate PT_size ((end-start)*8/4096)*4 or (end-start)/128
// Minimum page table size is 64Kbytes.
@ -50,7 +50,7 @@ static void KernelReadSRs(sr_table_t * table) {
}
static void KernelWriteSRs(sr_table_t * table) {
u32 i = 0;
uint32_t i = 0;
asm volatile("eieio; isync");
@ -79,17 +79,17 @@ static void KernelWriteSRs(sr_table_t * table) {
asm volatile("isync");
}
void KernelReadPTE(u32* dest, u32 size) {
u32 msr = 0;
u32 oldmsr = 0;
void KernelReadPTE(uint32_t* dest, uint32_t size) {
uint32_t msr = 0;
uint32_t oldmsr = 0;
//TODO: Calculate from SDR1
u32 addr_base = 0xFFE20000;
uint32_t addr_base = 0xFFE20000;
asm volatile("mfmsr %0" : "=r" (msr));
oldmsr = msr;
msr &= ~0x10;
for(int i = 0;i<size/0x04;i++){
u32 value_read = 0;
u32 addr = addr_base + (i*4);
for(uint32_t i = 0;i<size/0x04;i++){
uint32_t value_read = 0;
uint32_t addr = addr_base + (i*4);
// Disable Data address translation
asm volatile("mtmsr %0" : : "r" (msr));
__asm __volatile("lwz %0,0(%1)" : "=r"(value_read) : "r"(addr));
@ -99,17 +99,17 @@ void KernelReadPTE(u32* dest, u32 size) {
}
}
void KernelWritePTE(u32 * in_addr, u32 size) {
u32 msr = 0;
u32 oldmsr = 0;
void KernelWritePTE(uint32_t * in_addr, uint32_t size) {
uint32_t msr = 0;
uint32_t oldmsr = 0;
//TODO: Calculate from SDR1
u32 addr_base = 0xFFE20000;
uint32_t addr_base = 0xFFE20000;
asm volatile("mfmsr %0" : "=r" (msr));
oldmsr = msr;
msr &= ~0x10;
for(int i = 0;i<size/0x04;i++){
u32 addr = addr_base + (i*4);
u32 value = in_addr[i];
for(uint32_t i = 0;i<size/0x04;i++){
uint32_t addr = addr_base + (i*4);
uint32_t value = in_addr[i];
// Disable Data address translation
asm volatile("mtmsr %0" : : "r" (msr));
__asm __volatile("stw %0,0(%1)" : : "r"(value),"r"(addr));
@ -118,11 +118,11 @@ void KernelWritePTE(u32 * in_addr, u32 size) {
}
}
void KernelWriteWitoutDAT(u32 addr, u32 value) {
u32 msr = 0;
u32 oldmsr = 0;
void KernelWriteWitoutDAT(uint32_t addr, uint32_t value) {
uint32_t msr = 0;
uint32_t oldmsr = 0;
//TODO: Calculate from SDR1
u32 addr_base = 0xFFE20000;
//uint32_t addr_base = 0xFFE20000;
asm volatile("mfmsr %0" : "=r" (msr));
oldmsr = msr;
msr &= ~0x10;
@ -133,7 +133,7 @@ void KernelWriteWitoutDAT(u32 addr, u32 value) {
asm volatile("mtmsr %0" : : "r" (oldmsr));
}
void SC0x0A_KernelWriteWitoutDAT(u32 addr,u32 value);
void SC0x0A_KernelWriteWitoutDAT(uint32_t addr,uint32_t value);
void wups_init_kernel_syscalls(){
//! assign 1 so that this variable gets into the retained .data section
@ -143,39 +143,38 @@ void wups_init_kernel_syscalls(){
ucSyscallsSetupRequired = 0;
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x0A * 4)), (unsigned int)KernelWriteWitoutDAT);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x0A * 4)), (unsigned int)KernelWriteWitoutDAT);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x0A * 4)), (unsigned int)KernelWriteWitoutDAT);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x0A * 4)), (unsigned int)KernelWriteWitoutDAT);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x0A * 4)), (unsigned int)KernelWriteWitoutDAT);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x0A * 4)), (uint32_t)KernelWriteWitoutDAT);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x0A * 4)), (uint32_t)KernelWriteWitoutDAT);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x0A * 4)), (uint32_t)KernelWriteWitoutDAT);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x0A * 4)), (uint32_t)KernelWriteWitoutDAT);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x0A * 4)), (uint32_t)KernelWriteWitoutDAT);
// Override all writes to SR8 with nops.
SC0x0A_KernelWriteWitoutDAT(0xFFF1D754,0x60000000);
SC0x0A_KernelWriteWitoutDAT(0xFFF1D64C,0x60000000);
SC0x0A_KernelWriteWitoutDAT(0xFFE00638,0x60000000);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x36 * 4)), (unsigned int)KernelReadSRs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x36 * 4)), (unsigned int)KernelReadSRs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x36 * 4)), (unsigned int)KernelReadSRs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x36 * 4)), (unsigned int)KernelReadSRs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x36 * 4)), (unsigned int)KernelReadSRs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x36 * 4)), (uint32_t)KernelReadSRs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x36 * 4)), (uint32_t)KernelReadSRs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x36 * 4)), (uint32_t)KernelReadSRs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x36 * 4)), (uint32_t)KernelReadSRs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x36 * 4)), (uint32_t)KernelReadSRs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x37 * 4)), (unsigned int)KernelReadPTE);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x37 * 4)), (unsigned int)KernelReadPTE);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x37 * 4)), (unsigned int)KernelReadPTE);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x37 * 4)), (unsigned int)KernelReadPTE);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x37 * 4)), (unsigned int)KernelReadPTE);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x37 * 4)), (uint32_t)KernelReadPTE);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x37 * 4)), (uint32_t)KernelReadPTE);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x37 * 4)), (uint32_t)KernelReadPTE);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x37 * 4)), (uint32_t)KernelReadPTE);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x37 * 4)), (uint32_t)KernelReadPTE);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x09 * 4)), (unsigned int)KernelWritePTE);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x09 * 4)), (unsigned int)KernelWritePTE);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x09 * 4)), (unsigned int)KernelWritePTE);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x09 * 4)), (unsigned int)KernelWritePTE);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x09 * 4)), (unsigned int)KernelWritePTE);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x09 * 4)), (uint32_t)KernelWritePTE);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x09 * 4)), (uint32_t)KernelWritePTE);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x09 * 4)), (uint32_t)KernelWritePTE);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x09 * 4)), (uint32_t)KernelWritePTE);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x09 * 4)), (uint32_t)KernelWritePTE);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x0A * 4)), (unsigned int)KernelWriteSRs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x0A * 4)), (unsigned int)KernelWriteSRs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x0A * 4)), (unsigned int)KernelWriteSRs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x0A * 4)), (unsigned int)KernelWriteSRs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x0A * 4)), (unsigned int)KernelWriteSRs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x0A * 4)), (uint32_t)KernelWriteSRs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x0A * 4)), (uint32_t)KernelWriteSRs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x0A * 4)), (uint32_t)KernelWriteSRs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x0A * 4)), (uint32_t)KernelWriteSRs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x0A * 4)), (uint32_t)KernelWriteSRs);
}

View File

@ -9,8 +9,8 @@ extern "C" {
void SC0x0A_KernelWriteSRs(sr_table_t * table);
void SC0x36_KernelReadSRs(sr_table_t * table);
void SC0x37_KernelReadPTE(u32* dest, u32 size);
void SC0x09_KernelWritePTE(u32* addr,u32 size);
void SC0x37_KernelReadPTE(uint32_t* dest, uint32_t size);
void SC0x09_KernelWritePTE(uint32_t* addr,uint32_t size);
void KernelTest();
#ifdef __cplusplus

View File

@ -11,10 +11,10 @@
#include <stdio.h>
#include <string.h>
void runOnAllCores(CThread::Callback callback, void *callbackArg, s32 iAttr = 0, s32 iPriority = 16, s32 iStackSize = 0x8000) {
int aff[] = {CThread::eAttributeAffCore2,CThread::eAttributeAffCore1,CThread::eAttributeAffCore0};
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};
for(u32 i = 0; i <(sizeof(aff)/sizeof(aff[0])); i++) {
for(uint32_t i = 0; i <(sizeof(aff)/sizeof(aff[0])); i++) {
CThread * thread = CThread::create(callback, callbackArg, iAttr | aff[i],iPriority,iStackSize);
thread->resumeThread();
delete thread;
@ -23,7 +23,7 @@ void runOnAllCores(CThread::Callback callback, void *callbackArg, s32 iAttr = 0,
void writeSegmentRegister(CThread *thread, void *arg) {
sr_table_t * table = (sr_table_t *) arg;
u16 core = OSGetThreadAffinity(OSGetCurrentThread());
uint16_t core = OSGetThreadAffinity(OSGetCurrentThread());
DEBUG_FUNCTION_LINE("Writing segment register to core %d\n",core);
DCFlushRange(table,sizeof(sr_table_t));
@ -31,7 +31,7 @@ void writeSegmentRegister(CThread *thread, void *arg) {
}
void readAndPrintSegmentRegister(CThread *thread, void *arg) {
u16 core = OSGetThreadAffinity(OSGetCurrentThread());
uint16_t core = OSGetThreadAffinity(OSGetCurrentThread());
DEBUG_FUNCTION_LINE("Reading segment register and page table from core %d\n",core);
sr_table_t srTable;
memset(&srTable,0,sizeof(srTable));
@ -39,11 +39,11 @@ void readAndPrintSegmentRegister(CThread *thread, void *arg) {
SC0x36_KernelReadSRs(&srTable);
DCFlushRange(&srTable,sizeof(srTable));
for(int i = 0; i < 16; i++) {
for(int32_t i = 0; i < 16; i++) {
DEBUG_FUNCTION_LINE("[%d] SR[%d]=%08X\n",core,i,srTable.value[i]);
}
u32 pageTable[0x8000];
uint32_t pageTable[0x8000];
memset(pageTable,0,sizeof(pageTable));
DEBUG_FUNCTION_LINE("Reading pageTable now.\n");
@ -68,61 +68,61 @@ bool MemoryMapping::isMemoryMapped() {
return false;
}
u32 MemoryMapping::getHeapAddress() {
uint32_t MemoryMapping::getHeapAddress() {
return MEMORY_START_PLUGIN_HEAP;
}
u32 MemoryMapping::getHeapSize() {
uint32_t MemoryMapping::getHeapSize() {
return getAreaSizeFromPageTable(MEMORY_START_PLUGIN_HEAP,MEMORY_START_PLUGIN_HEAP_END - MEMORY_START_PLUGIN_HEAP);
}
void MemoryMapping::searchEmptyMemoryRegions() {
DEBUG_FUNCTION_LINE("Searching for empty memory.\n");
for(int i = 0;; i++) {
for(int32_t i = 0;; i++) {
if(mem_mapping[i].physical_addresses == NULL) {
break;
}
u32 ea_start_address = mem_mapping[i].effective_start_address;
uint32_t ea_start_address = mem_mapping[i].effective_start_address;
const memory_values_t * mem_vals = mem_mapping[i].physical_addresses;
u32 ea_size = 0;
for(u32 j = 0;; j++) {
u32 pa_start_address = mem_vals[j].start_address;
u32 pa_end_address = mem_vals[j].end_address;
uint32_t ea_size = 0;
for(uint32_t j = 0;; j++) {
uint32_t pa_start_address = mem_vals[j].start_address;
uint32_t pa_end_address = mem_vals[j].end_address;
if(pa_end_address == 0 && pa_start_address == 0) {
break;
}
ea_size += pa_end_address - pa_start_address;
}
u32* flush_start = (u32*)ea_start_address;
u32 flush_size = ea_size;
uint32_t* flush_start = (uint32_t*)ea_start_address;
uint32_t flush_size = ea_size;
DEBUG_FUNCTION_LINE("Flushing %08X (%d kB) at %08X.\n",flush_size,flush_size/1024, flush_start);
DCFlushRange(flush_start,flush_size);
DEBUG_FUNCTION_LINE("Searching in memory region %d. 0x%08X - 0x%08X. Size 0x%08X (%d KBytes).\n",i+1,ea_start_address,ea_start_address+ea_size,ea_size,ea_size/1024);
bool success = true;
u32 * memory_ptr = (u32*) ea_start_address;
uint32_t * memory_ptr = (uint32_t*) ea_start_address;
bool inFailRange = false;
u32 startFailing = 0;
u32 startGood = ea_start_address;
for(u32 j=0; j < ea_size/4; j++) {
uint32_t startFailing = 0;
uint32_t startGood = ea_start_address;
for(uint32_t j=0; j < ea_size/4; j++) {
if(memory_ptr[j] != 0) {
success = false;
if(!success && !inFailRange) {
if((((u32)&memory_ptr[j])-(u32)startGood)/1024 > 512) {
u32 start_addr = startGood & 0xFFFE0000;
if((((uint32_t)&memory_ptr[j])-(uint32_t)startGood)/1024 > 512) {
uint32_t start_addr = startGood & 0xFFFE0000;
if(start_addr != startGood) {
start_addr += 0x20000;
}
u32 end_addr = ((u32)&memory_ptr[j]) - MEMORY_START_BASE;
uint32_t end_addr = ((uint32_t)&memory_ptr[j]) - MEMORY_START_BASE;
end_addr = (end_addr & 0xFFFE0000);
DEBUG_FUNCTION_LINE("+ Free between 0x%08X and 0x%08X size: %u kB\n",start_addr - MEMORY_START_BASE,end_addr,(((u32)end_addr)-((u32)startGood - MEMORY_START_BASE))/1024);
DEBUG_FUNCTION_LINE("+ Free between 0x%08X and 0x%08X size: %u kB\n",start_addr - MEMORY_START_BASE,end_addr,(((uint32_t)end_addr)-((uint32_t)startGood - MEMORY_START_BASE))/1024);
}
startFailing = (u32)&memory_ptr[j];
startFailing = (uint32_t)&memory_ptr[j];
inFailRange = true;
startGood = 0;
j = ((j & 0xFFFF8000) + 0x00008000)-1;
@ -130,17 +130,17 @@ void MemoryMapping::searchEmptyMemoryRegions() {
//break;
} else {
if(inFailRange) {
//DEBUG_FUNCTION_LINE("- Error between 0x%08X and 0x%08X size: %u kB\n",startFailing,&memory_ptr[j],(((u32)&memory_ptr[j])-(u32)startFailing)/1024);
//DEBUG_FUNCTION_LINE("- Error between 0x%08X and 0x%08X size: %u kB\n",startFailing,&memory_ptr[j],(((uint32_t)&memory_ptr[j])-(uint32_t)startFailing)/1024);
startFailing = 0;
startGood = (u32) &memory_ptr[j];
startGood = (uint32_t) &memory_ptr[j];
inFailRange = false;
}
}
}
if(startGood != 0 && (startGood != ea_start_address + ea_size)) {
DEBUG_FUNCTION_LINE("+ Good between 0x%08X and 0x%08X size: %u kB\n",startGood - MEMORY_START_BASE,((u32)(ea_start_address + ea_size) - (u32)MEMORY_START_BASE),((u32)(ea_start_address + ea_size) - (u32)startGood)/1024);
DEBUG_FUNCTION_LINE("+ Good between 0x%08X and 0x%08X size: %u kB\n",startGood - MEMORY_START_BASE,((uint32_t)(ea_start_address + ea_size) - (uint32_t)MEMORY_START_BASE),((uint32_t)(ea_start_address + ea_size) - (uint32_t)startGood)/1024);
} else if(inFailRange) {
DEBUG_FUNCTION_LINE("- Used between 0x%08X and 0x%08X size: %u kB\n",startFailing,ea_start_address + ea_size,((u32)(ea_start_address + ea_size) - (u32)startFailing)/1024);
DEBUG_FUNCTION_LINE("- Used between 0x%08X and 0x%08X size: %u kB\n",startFailing,ea_start_address + ea_size,((uint32_t)(ea_start_address + ea_size) - (uint32_t)startFailing)/1024);
}
if(success) {
DEBUG_FUNCTION_LINE("Test %d was successful!\n",i+1);
@ -152,33 +152,33 @@ void MemoryMapping::searchEmptyMemoryRegions() {
void MemoryMapping::writeTestValuesToMemory() {
//don't smash the stack.
u32 chunk_size = 0x1000;
u32 testBuffer[chunk_size];
uint32_t chunk_size = 0x1000;
uint32_t testBuffer[chunk_size];
for(int i = 0;; i++) {
for(int32_t i = 0;; i++) {
if(mem_mapping[i].physical_addresses == NULL) {
break;
}
u32 cur_ea_start_address = mem_mapping[i].effective_start_address;
uint32_t cur_ea_start_address = mem_mapping[i].effective_start_address;
DEBUG_FUNCTION_LINE("Preparing memory test for region %d. Region start at effective address %08X.\n",i+1,cur_ea_start_address);
const memory_values_t * mem_vals = mem_mapping[i].physical_addresses;
u32 counter = 0;
for(u32 j = 0;; j++) {
u32 pa_start_address = mem_vals[j].start_address;
u32 pa_end_address = mem_vals[j].end_address;
uint32_t counter = 0;
for(uint32_t j = 0;; j++) {
uint32_t pa_start_address = mem_vals[j].start_address;
uint32_t pa_end_address = mem_vals[j].end_address;
if(pa_end_address == 0 && pa_start_address == 0) {
break;
}
u32 pa_size = pa_end_address - pa_start_address;
uint32_t pa_size = pa_end_address - pa_start_address;
DEBUG_FUNCTION_LINE("Writing region %d of mapping %d. From %08X to %08X Size: %d KBytes...\n",j+1,i+1,pa_start_address,pa_end_address,pa_size/1024);
for(u32 k=0; k<=pa_size/4; k++) {
for(uint32_t k=0; k<=pa_size/4; k++) {
if(k > 0 && (k % chunk_size) == 0) {
DCFlushRange(&testBuffer,sizeof(testBuffer));
DCInvalidateRange(&testBuffer,sizeof(testBuffer));
u32 destination = pa_start_address + ((k*4) - sizeof(testBuffer));
SC0x25_KernelCopyData(destination,(u32)OSEffectiveToPhysical(testBuffer),sizeof(testBuffer));
uint32_t destination = pa_start_address + ((k*4) - sizeof(testBuffer));
SC0x25_KernelCopyData(destination,(uint32_t)OSEffectiveToPhysical(testBuffer),sizeof(testBuffer));
//DEBUG_FUNCTION_LINE("Copy testBuffer into %08X\n",destination);
}
if(k != pa_size/4) {
@ -186,8 +186,8 @@ void MemoryMapping::writeTestValuesToMemory() {
}
//DEBUG_FUNCTION_LINE("testBuffer[%d] = %d\n",i % chunk_size,i);
}
u32* flush_start = (u32*)cur_ea_start_address;
u32 flush_size = pa_size;
uint32_t* flush_start = (uint32_t*)cur_ea_start_address;
uint32_t flush_size = pa_size;
cur_ea_start_address += pa_size;
@ -202,42 +202,42 @@ void MemoryMapping::writeTestValuesToMemory() {
void MemoryMapping::readTestValuesFromMemory() {
DEBUG_FUNCTION_LINE("Testing reading the written values.\n");
for(int i = 0;; i++) {
for(int32_t i = 0;; i++) {
if(mem_mapping[i].physical_addresses == NULL) {
break;
}
u32 ea_start_address = mem_mapping[i].effective_start_address;
uint32_t ea_start_address = mem_mapping[i].effective_start_address;
const memory_values_t * mem_vals = mem_mapping[i].physical_addresses;
//u32 counter = 0;
u32 ea_size = 0;
for(u32 j = 0;; j++) {
u32 pa_start_address = mem_vals[j].start_address;
u32 pa_end_address = mem_vals[j].end_address;
//uint32_t counter = 0;
uint32_t ea_size = 0;
for(uint32_t j = 0;; j++) {
uint32_t pa_start_address = mem_vals[j].start_address;
uint32_t pa_end_address = mem_vals[j].end_address;
if(pa_end_address == 0 && pa_start_address == 0) {
break;
}
ea_size += pa_end_address - pa_start_address;
}
u32* flush_start = (u32*)ea_start_address;
u32 flush_size = ea_size;
uint32_t* flush_start = (uint32_t*)ea_start_address;
uint32_t flush_size = ea_size;
DEBUG_FUNCTION_LINE("Flushing %08X (%d kB) at %08X to map memory.\n",flush_size,flush_size/1024, flush_start);
DCFlushRange(flush_start,flush_size);
DEBUG_FUNCTION_LINE("Testing memory region %d. 0x%08X - 0x%08X. Size 0x%08X (%d KBytes).\n",i+1,ea_start_address,ea_start_address+ea_size,ea_size,ea_size/1024);
bool success = true;
u32 * memory_ptr = (u32*) ea_start_address;
uint32_t * memory_ptr = (uint32_t*) ea_start_address;
bool inFailRange = false;
u32 startFailing = 0;
u32 startGood = ea_start_address;
for(u32 j=0; j < ea_size/4; j++) {
uint32_t startFailing = 0;
uint32_t startGood = ea_start_address;
for(uint32_t j=0; j < ea_size/4; j++) {
if(memory_ptr[j] != j) {
success = false;
if(!success && !inFailRange) {
DEBUG_FUNCTION_LINE("+ Good between 0x%08X and 0x%08X size: %u kB\n",startGood,&memory_ptr[j],(((u32)&memory_ptr[j])-(u32)startGood)/1024);
startFailing = (u32)&memory_ptr[j];
DEBUG_FUNCTION_LINE("+ Good between 0x%08X and 0x%08X size: %u kB\n",startGood,&memory_ptr[j],(((uint32_t)&memory_ptr[j])-(uint32_t)startGood)/1024);
startFailing = (uint32_t)&memory_ptr[j];
inFailRange = true;
startGood = 0;
j = ((j & 0xFFFF8000) + 0x00008000)-1;
@ -245,17 +245,17 @@ void MemoryMapping::readTestValuesFromMemory() {
//break;
} else {
if(inFailRange) {
DEBUG_FUNCTION_LINE("- Error between 0x%08X and 0x%08X size: %u kB\n",startFailing,&memory_ptr[j],(((u32)&memory_ptr[j])-(u32)startFailing)/1024);
DEBUG_FUNCTION_LINE("- Error between 0x%08X and 0x%08X size: %u kB\n",startFailing,&memory_ptr[j],(((uint32_t)&memory_ptr[j])-(uint32_t)startFailing)/1024);
startFailing = 0;
startGood = (u32) &memory_ptr[j];
startGood = (uint32_t) &memory_ptr[j];
inFailRange = false;
}
}
}
if(startGood != 0 && (startGood != ea_start_address + ea_size)) {
DEBUG_FUNCTION_LINE("+ Good between 0x%08X and 0x%08X size: %u kB\n",startGood,ea_start_address + ea_size,((u32)(ea_start_address + ea_size) - (u32)startGood)/1024);
DEBUG_FUNCTION_LINE("+ Good between 0x%08X and 0x%08X size: %u kB\n",startGood,ea_start_address + ea_size,((uint32_t)(ea_start_address + ea_size) - (uint32_t)startGood)/1024);
} else if(inFailRange) {
DEBUG_FUNCTION_LINE("- Error between 0x%08X and 0x%08X size: %u kB\n",startFailing,ea_start_address + ea_size,((u32)(ea_start_address + ea_size) - (u32)startFailing)/1024);
DEBUG_FUNCTION_LINE("- Error between 0x%08X and 0x%08X size: %u kB\n",startFailing,ea_start_address + ea_size,((uint32_t)(ea_start_address + ea_size) - (uint32_t)startFailing)/1024);
}
if(success) {
DEBUG_FUNCTION_LINE("Test %d was successful!\n",i+1);
@ -265,28 +265,28 @@ void MemoryMapping::readTestValuesFromMemory() {
DEBUG_FUNCTION_LINE("All tests done.\n");
}
void MemoryMapping::memoryMappingForRegions(const memory_mapping_t * memory_mapping, sr_table_t SRTable, u32 * translation_table) {
for(int i = 0; /* waiting for a break */; i++) {
void MemoryMapping::memoryMappingForRegions(const memory_mapping_t * memory_mapping, sr_table_t SRTable, uint32_t * translation_table) {
for(int32_t i = 0; /* waiting for a break */; i++) {
DEBUG_FUNCTION_LINE("In loop %d\n",i);
if(memory_mapping[i].physical_addresses == NULL) {
DEBUG_FUNCTION_LINE("break %d\n",i);
break;
}
u32 cur_ea_start_address = memory_mapping[i].effective_start_address;
uint32_t cur_ea_start_address = memory_mapping[i].effective_start_address;
DEBUG_FUNCTION_LINE("Mapping area %d. effective address %08X...\n",i+1,cur_ea_start_address);
const memory_values_t * mem_vals = memory_mapping[i].physical_addresses;
for(u32 j = 0;; j++) {
for(uint32_t j = 0;; j++) {
DEBUG_FUNCTION_LINE("In inner loop %d\n",j);
u32 pa_start_address = mem_vals[j].start_address;
u32 pa_end_address = mem_vals[j].end_address;
uint32_t pa_start_address = mem_vals[j].start_address;
uint32_t pa_end_address = mem_vals[j].end_address;
if(pa_end_address == 0 && pa_start_address == 0) {
DEBUG_FUNCTION_LINE("inner break %d\n",j);
// Break if entry was empty.
break;
}
u32 pa_size = pa_end_address - pa_start_address;
uint32_t pa_size = pa_end_address - pa_start_address;
DEBUG_FUNCTION_LINE("Adding page table entry %d for mapping area %d. %08X-%08X => %08X-%08X...\n",j+1,i+1,cur_ea_start_address,memory_mapping[i].effective_start_address+pa_size,pa_start_address,pa_end_address);
if(!mapMemory(pa_start_address,pa_end_address,cur_ea_start_address,SRTable,translation_table)) {
log_print("error =(\n");
@ -305,7 +305,7 @@ void MemoryMapping::setupMemoryMapping() {
//runOnAllCores(readAndPrintSegmentRegister,NULL,0,16,0x20000);
sr_table_t srTableCpy;
u32 pageTableCpy[0x8000];
uint32_t pageTableCpy[0x8000];
SC0x36_KernelReadSRs(&srTableCpy);
SC0x37_KernelReadPTE(pageTableCpy,sizeof(pageTableCpy));
@ -313,7 +313,7 @@ void MemoryMapping::setupMemoryMapping() {
DCFlushRange(&srTableCpy,sizeof(srTableCpy));
DCFlushRange(pageTableCpy,sizeof(pageTableCpy));
for(int i = 0; i < 16; i++) {
for(int32_t i = 0; i < 16; i++) {
DEBUG_FUNCTION_LINE("SR[%d]=%08X\n",i,srTableCpy.value[i]);
}
@ -324,8 +324,8 @@ void MemoryMapping::setupMemoryMapping() {
// is currently unmapped.
// This is nice because it leads to SR[8] which also seems to be unused (was set to 0x30FFFFFF)
// The content of the segment was chosen randomly.
u32 segment_index = MEMORY_START_BASE >> 28;
u32 segment_content = 0x20000000 | SEGMENT_UNIQUE_ID;
uint32_t segment_index = MEMORY_START_BASE >> 28;
uint32_t segment_content = 0x20000000 | SEGMENT_UNIQUE_ID;
DEBUG_FUNCTION_LINE("Setting SR[%d] to %08X\n",segment_index,segment_content);
srTableCpy.value[segment_index] = segment_content;
@ -356,34 +356,34 @@ void MemoryMapping::setupMemoryMapping() {
}
u32 MemoryMapping::getAreaSizeFromPageTable(u32 start, u32 maxSize) {
uint32_t MemoryMapping::getAreaSizeFromPageTable(uint32_t start, uint32_t maxSize) {
sr_table_t srTable;
u32 pageTable[0x8000];
uint32_t pageTable[0x8000];
SC0x36_KernelReadSRs(&srTable);
SC0x37_KernelReadPTE(pageTable,sizeof(pageTable));
u32 sr_start = start >> 28;
u32 sr_end = (start + maxSize) >> 28;
uint32_t sr_start = start >> 28;
uint32_t sr_end = (start + maxSize) >> 28;
if(sr_end < sr_start) {
return 0;
}
u32 cur_address = start;
u32 end_address = start + maxSize;
uint32_t cur_address = start;
uint32_t end_address = start + maxSize;
u32 memSize = 0;
uint32_t memSize = 0;
for(u32 segment = sr_start; segment <= sr_end ; segment++) {
u32 sr = srTable.value[segment];
for(uint32_t segment = sr_start; segment <= sr_end ; segment++) {
uint32_t sr = srTable.value[segment];
if(sr >> 31) {
DEBUG_FUNCTION_LINE("Direct access not supported\n");
} else {
u32 vsid = sr & 0xFFFFFF;
uint32_t vsid = sr & 0xFFFFFF;
u32 pageSize = 1 << PAGE_INDEX_SHIFT;
u32 cur_end_addr = 0;
uint32_t pageSize = 1 << PAGE_INDEX_SHIFT;
uint32_t cur_end_addr = 0;
if(segment == sr_end) {
cur_end_addr = end_address;
} else {
@ -393,9 +393,9 @@ u32 MemoryMapping::getAreaSizeFromPageTable(u32 start, u32 maxSize) {
cur_address = (segment) * 0x10000000;
}
bool success = true;
for(u32 addr = cur_address; addr < cur_end_addr; addr += pageSize) {
u32 PTEH = 0;
u32 PTEL = 0;
for(uint32_t addr = cur_address; addr < cur_end_addr; addr += pageSize) {
uint32_t PTEH = 0;
uint32_t PTEL = 0;
if(getPageEntryForAddress(srTable.sdr1, addr, vsid, pageTable, &PTEH, &PTEL, false)) {
memSize += pageSize;
} else {
@ -411,10 +411,10 @@ u32 MemoryMapping::getAreaSizeFromPageTable(u32 start, u32 maxSize) {
return memSize;
}
bool MemoryMapping::getPageEntryForAddress(u32 SDR1,u32 addr, u32 vsid, u32 * translation_table,u32* oPTEH, u32* oPTEL, bool checkSecondHash) {
u32 pageMask = SDR1 & 0x1FF;
u32 pageIndex = (addr >> PAGE_INDEX_SHIFT) & PAGE_INDEX_MASK;
u32 primaryHash = (vsid & 0x7FFFF) ^ pageIndex;
bool MemoryMapping::getPageEntryForAddress(uint32_t SDR1,uint32_t addr, uint32_t vsid, uint32_t * translation_table,uint32_t* oPTEH, uint32_t* oPTEL, bool checkSecondHash) {
uint32_t pageMask = SDR1 & 0x1FF;
uint32_t pageIndex = (addr >> PAGE_INDEX_SHIFT) & PAGE_INDEX_MASK;
uint32_t primaryHash = (vsid & 0x7FFFF) ^ pageIndex;
if(getPageEntryForAddressEx(SDR1, addr, vsid, primaryHash, translation_table, oPTEH, oPTEL, 0)) {
return true;
@ -429,18 +429,18 @@ bool MemoryMapping::getPageEntryForAddress(u32 SDR1,u32 addr, u32 vsid, u32 * tr
return false;
}
bool MemoryMapping::getPageEntryForAddressEx(u32 pageMask, u32 addr, u32 vsid, u32 primaryHash, u32 * translation_table,u32* oPTEH, u32* oPTEL,u32 H) {
bool MemoryMapping::getPageEntryForAddressEx(uint32_t pageMask, uint32_t addr, uint32_t vsid, uint32_t primaryHash, uint32_t * translation_table,uint32_t* oPTEH, uint32_t* oPTEL,uint32_t H) {
uint32_t maskedHash = primaryHash & ((pageMask << 10) | 0x3FF);
uint32_t api = (addr >> 22) & 0x3F;
uint32_t pteAddrOffset = (maskedHash << 6);
for (int j = 0; j < 8; j++, pteAddrOffset += 8) {
for (int32_t j = 0; j < 8; j++, pteAddrOffset += 8) {
uint32_t PTEH = 0;
uint32_t PTEL = 0;
u32 pteh_index = pteAddrOffset / 4;
u32 ptel_index = pteh_index + 1;
uint32_t pteh_index = pteAddrOffset / 4;
uint32_t ptel_index = pteh_index + 1;
PTEH = translation_table[pteh_index];
PTEL = translation_table[ptel_index];
@ -478,29 +478,29 @@ bool MemoryMapping::getPageEntryForAddressEx(u32 pageMask, u32 addr, u32 vsid, u
return false;
}
void MemoryMapping::printPageTableTranslation(sr_table_t srTable, u32 * translation_table) {
u32 SDR1 = srTable.sdr1;
void MemoryMapping::printPageTableTranslation(sr_table_t srTable, uint32_t * translation_table) {
uint32_t SDR1 = srTable.sdr1;
pageInformation current;
memset(&current,0,sizeof(current));
std::vector<pageInformation> pageInfos;
for(u32 segment = 0; segment < 16 ; segment++) {
u32 sr = srTable.value[segment];
for(uint32_t segment = 0; segment < 16 ; segment++) {
uint32_t sr = srTable.value[segment];
if(sr >> 31) {
DEBUG_FUNCTION_LINE("Direct access not supported\n");
} else {
u32 ks = (sr >> 30) & 1;
u32 kp = (sr >> 29) & 1;
u32 nx = (sr >> 28) & 1;
u32 vsid = sr & 0xFFFFFF;
uint32_t ks = (sr >> 30) & 1;
uint32_t kp = (sr >> 29) & 1;
uint32_t nx = (sr >> 28) & 1;
uint32_t vsid = sr & 0xFFFFFF;
DEBUG_FUNCTION_LINE("ks %08X kp %08X nx %08X vsid %08X\n",ks,kp,nx,vsid);
u32 pageSize = 1 << PAGE_INDEX_SHIFT;
for(u32 addr = segment * 0x10000000; addr < (segment + 1) * 0x10000000; addr += pageSize) {
u32 PTEH = 0;
u32 PTEL = 0;
uint32_t pageSize = 1 << PAGE_INDEX_SHIFT;
for(uint32_t addr = segment * 0x10000000; addr < (segment + 1) * 0x10000000; addr += pageSize) {
uint32_t PTEH = 0;
uint32_t PTEL = 0;
if(getPageEntryForAddress(SDR1, addr, vsid, translation_table, &PTEH, &PTEL, false)) {
uint32_t pp = PTEL & 3;
uint32_t phys = PTEL & 0xFFFFF000;
@ -556,11 +556,11 @@ void MemoryMapping::printPageTableTranslation(sr_table_t srTable, u32 * translat
}
bool MemoryMapping::mapMemory(uint32_t pa_start_address,uint32_t pa_end_address,uint32_t ea_start_address, sr_table_t SRTable, u32 * translation_table) {
bool MemoryMapping::mapMemory(uint32_t pa_start_address,uint32_t pa_end_address,uint32_t ea_start_address, sr_table_t SRTable, uint32_t * translation_table) {
// Based on code from dimok. Thanks!
//u32 byteOffsetMask = (1 << PAGE_INDEX_SHIFT) - 1;
//u32 apiShift = 22 - PAGE_INDEX_SHIFT;
//uint32_t byteOffsetMask = (1 << PAGE_INDEX_SHIFT) - 1;
//uint32_t apiShift = 22 - PAGE_INDEX_SHIFT;
// Information on page 5.
// https://www.nxp.com/docs/en/application-note/AN2794.pdf
@ -570,7 +570,7 @@ bool MemoryMapping::mapMemory(uint32_t pa_start_address,uint32_t pa_end_address,
// Iterate to all possible pages. Each page is 1<<(PAGE_INDEX_SHIFT) big.
uint32_t pageSize = 1<<(PAGE_INDEX_SHIFT);
for(u32 i = 0; i < pa_end_address - pa_start_address; i += pageSize) {
for(uint32_t i = 0; i < pa_end_address - pa_start_address; i += pageSize) {
// Calculate the current effective address.
uint32_t ea_addr = ea_start_address + i;
// Calculate the segement.
@ -622,8 +622,8 @@ bool MemoryMapping::mapMemory(uint32_t pa_start_address,uint32_t pa_end_address,
bool setSuccessfully = false;
PTEGoffset += 7*8;
// Lets iterate through the PTE group where out PTE should be saved.
for(int j = 7; j>0; PTEGoffset -= 8) {
int index = (PTEGoffset/4);
for(int32_t j = 7; j>0; PTEGoffset -= 8) {
int32_t index = (PTEGoffset/4);
uint32_t pteh = translation_table[index];
// Check if it's already taken. The first bit indicates if the PTE-slot inside
@ -651,8 +651,8 @@ bool MemoryMapping::mapMemory(uint32_t pa_start_address,uint32_t pa_end_address,
PTEGoffset = PTEGaddr2 - (HTABORG << 16);
PTEGoffset += 7*8;
// Same as before.
for(int j = 7; j>0; PTEGoffset -= 8) {
int index = (PTEGoffset/4);
for(int32_t j = 7; j>0; PTEGoffset -= 8) {
int32_t index = (PTEGoffset/4);
uint32_t pteh = translation_table[index];
//Check if it's already taken.
if ((pteh == 0)) {

View File

@ -19,12 +19,12 @@ typedef struct pageInformation_ {
} pageInformation;
typedef struct _memory_values_t {
unsigned int start_address;
unsigned int end_address;
uint32_t start_address;
uint32_t end_address;
} memory_values_t;
typedef struct _memory_mapping_t {
unsigned int effective_start_address;
uint32_t effective_start_address;
const memory_values_t* physical_addresses;
} memory_mapping_t;
@ -115,7 +115,7 @@ public:
static void setupMemoryMapping();
static void printPageTableTranslation(sr_table_t srTable, u32 * translation_table);
static void printPageTableTranslation(sr_table_t srTable, uint32_t * translation_table);
static void writeTestValuesToMemory();
@ -123,22 +123,22 @@ public:
static void searchEmptyMemoryRegions();
static u32 getHeapAddress();
static uint32_t getHeapAddress();
static u32 getHeapSize();
static uint32_t getHeapSize();
static u32 getAreaSizeFromPageTable(u32 start, u32 maxSize);
static uint32_t getAreaSizeFromPageTable(uint32_t start, uint32_t maxSize);
private:
static void memoryMappingForRegions(const memory_mapping_t * memory_mapping, sr_table_t SRTable, u32 * translation_table);
static void memoryMappingForRegions(const memory_mapping_t * memory_mapping, sr_table_t SRTable, uint32_t * translation_table);
static bool mapMemory(u32 pa_start_address,u32 pa_end_address,u32 ea_start_address, sr_table_t SRTable, u32 * translation_table);
static bool mapMemory(uint32_t pa_start_address,uint32_t pa_end_address,uint32_t ea_start_address, sr_table_t SRTable, uint32_t * translation_table);
static bool getPageEntryForAddress(u32 SDR1, u32 addr, u32 vsid, u32 * translation_table,u32* oPTEH, u32* oPTEL, bool checkSecondHash);
static bool getPageEntryForAddress(uint32_t SDR1, uint32_t addr, uint32_t vsid, uint32_t * translation_table,uint32_t* oPTEH, uint32_t* oPTEL, bool checkSecondHash);
static bool getPageEntryForAddressEx(u32 pageMask, u32 addr, u32 vsid, u32 primaryHash, u32 * translation_table,u32* oPTEH, u32* oPTEL,u32 H) ;
static bool getPageEntryForAddressEx(uint32_t pageMask, uint32_t addr, uint32_t vsid, uint32_t primaryHash, uint32_t * translation_table,uint32_t* oPTEH, uint32_t* oPTEL,uint32_t H) ;
};

View File

@ -18,7 +18,7 @@
#include "plugin/PluginLoader.h"
#include "plugin/PluginInformation.h"
TcpReceiver::TcpReceiver(int port)
TcpReceiver::TcpReceiver(int32_t port)
: CThread(CThread::eAttributeAffCore0 | CThread::eAttributePinnedAff)
, exitRequested(false)
, serverPort(port)
@ -40,7 +40,7 @@ void TcpReceiver::executeThread() {
if (serverSocket < 0)
return;
u32 enable = 1;
uint32_t enable = 1;
setsockopt(serverSocket, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable));
struct sockaddr_in bindAddress;
@ -49,7 +49,7 @@ void TcpReceiver::executeThread() {
bindAddress.sin_port = serverPort;
bindAddress.sin_addr.s_addr = INADDR_ANY;
s32 ret;
int32_t ret;
if ((ret = bind(serverSocket, (struct sockaddr *)&bindAddress, sizeof(bindAddress))) < 0) {
socketclose(serverSocket);
return;
@ -61,14 +61,14 @@ void TcpReceiver::executeThread() {
}
struct sockaddr_in clientAddr;
s32 addrlen = sizeof(struct sockaddr);
int32_t addrlen = sizeof(struct sockaddr);
while(!exitRequested) {
s32 clientSocket = accept(serverSocket, (struct sockaddr*)&clientAddr, &addrlen);
int32_t clientSocket = accept(serverSocket, (struct sockaddr*)&clientAddr, &addrlen);
if(clientSocket >= 0) {
u32 ipAddress = clientAddr.sin_addr.s_addr;
uint32_t ipAddress = clientAddr.sin_addr.s_addr;
//serverReceiveStart(this, ipAddress);
int result = loadToMemory(clientSocket, ipAddress);
int32_t result = loadToMemory(clientSocket, ipAddress);
//serverReceiveFinished(this, ipAddress, result);
socketclose(clientSocket);
@ -82,11 +82,11 @@ void TcpReceiver::executeThread() {
socketclose(serverSocket);
}
int TcpReceiver::loadToMemory(s32 clientSocket, u32 ipAddress) {
int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
DEBUG_FUNCTION_LINE("Loading file from ip %08X\n", ipAddress);
u32 fileSize = 0;
u32 fileSizeUnc = 0;
uint32_t fileSize = 0;
uint32_t fileSizeUnc = 0;
unsigned char haxx[8];
memset(haxx, 0, sizeof(haxx));
//skip haxx
@ -97,8 +97,8 @@ int TcpReceiver::loadToMemory(s32 clientSocket, u32 ipAddress) {
recvwait(clientSocket, (unsigned char*)&fileSizeUnc, sizeof(fileSizeUnc)); // Compressed protocol, read another 4 bytes
}
u32 bytesRead = 0;
struct in_addr in;
uint32_t bytesRead = 0;
in.s_addr = ipAddress;
DEBUG_FUNCTION_LINE("transfer start\n");
@ -112,11 +112,11 @@ int TcpReceiver::loadToMemory(s32 clientSocket, u32 ipAddress) {
// Copy rpl in memory
while(bytesRead < fileSize) {
u32 blockSize = 0x1000;
uint32_t blockSize = 0x1000;
if(blockSize > (fileSize - bytesRead))
blockSize = fileSize - bytesRead;
int ret = recv(clientSocket, loadAddress + bytesRead, blockSize, 0);
int32_t ret = recv(clientSocket, loadAddress + bytesRead, blockSize, 0);
if(ret <= 0) {
DEBUG_FUNCTION_LINE("Failure on reading file\n");
break;
@ -151,7 +151,7 @@ int TcpReceiver::loadToMemory(s32 clientSocket, u32 ipAddress) {
return NOT_ENOUGH_MEMORY;
}
int ret = 0;
int32_t ret = 0;
z_stream s;
memset(&s, 0, sizeof(s));
@ -193,7 +193,7 @@ int TcpReceiver::loadToMemory(s32 clientSocket, u32 ipAddress) {
}
uLongf f = fileSizeUnc;
int result = uncompress((Bytef*)&inflatedData[0], &f, (Bytef*)loadAddress, fileSize);
int32_t result = uncompress((Bytef*)&inflatedData[0], &f, (Bytef*)loadAddress, fileSize);
if(result != Z_OK) {
DEBUG_FUNCTION_LINE("uncompress failed %i\n", result);
os_sleep(1);

View File

@ -20,21 +20,21 @@ public:
NOT_A_VALID_PLUGIN = -5,
};
TcpReceiver(int port);
TcpReceiver(int32_t port);
~TcpReceiver();
sigslot::signal2<GuiElement *, u32> serverReceiveStart;
sigslot::signal3<GuiElement *, u32, int> serverReceiveFinished;
sigslot::signal2<GuiElement *, uint32_t> serverReceiveStart;
sigslot::signal3<GuiElement *, uint32_t, int32_t> serverReceiveFinished;
private:
void executeThread();
int loadToMemory(s32 clientSocket, u32 ipAddress);
bool saveFileToSDCard(const char * path, void * buffer,u32 size);
int32_t loadToMemory(int32_t clientSocket, uint32_t ipAddress);
bool saveFileToSDCard(const char * path, void * buffer,uint32_t size);
bool exitRequested;
s32 serverPort;
s32 serverSocket;
int32_t serverPort;
int32_t serverSocket;
};

View File

@ -4,8 +4,8 @@
#include <fat.h>
#include "common/retain_vars.h"
int mount_libfatAll() {
int res = -1;
int32_t mount_libfatAll() {
int32_t res = -1;
if((res = fatInitDefault()) >= 0) {
DEBUG_FUNCTION_LINE("fatInitDefault success\n");
return 0;

View File

@ -5,7 +5,9 @@
extern "C" {
#endif
int mount_libfatAll();
#include <stdint.h>
int32_t mount_libfatAll();
void unmount_libfat(const char * path);
#ifdef __cplusplus

View File

@ -7,8 +7,8 @@
#include <ntfs.h>
#include "common/retain_vars.h"
int mountAllNTFS() {
int i;
int32_t mountAllNTFS() {
int32_t i;
// Mount all NTFS volumes on all inserted block devices
ntfs_mount_count = ntfsMountAll((ntfs_md **) &ntfs_mounts, NTFS_DEFAULT | NTFS_RECOVER);
if (ntfs_mount_count == -1) {
@ -25,9 +25,9 @@ int mountAllNTFS() {
return ntfs_mount_count;
}
int unmountAllNTFS(void) {
int32_t unmountAllNTFS(void) {
if (ntfs_mounts) {
int i = 0;
int32_t i = 0;
for (i = 0; i < ntfs_mount_count; i++) {
ntfsUnmount(((ntfs_md *)ntfs_mounts)[i].name, true);
}

View File

@ -1,7 +1,7 @@
#ifndef __LIBNTFS_MOUNT_H_
#define __LIBNTFS_MOUNT_H_
int mountAllNTFS(void);
int unmountAllNTFS();
int32_t mountAllNTFS(void);
int32_t unmountAllNTFS();
#endif

View File

@ -19,20 +19,20 @@ https://raw.githubusercontent.com/dimok789/mocha/
#define ARM_CODE_BASE 0x08135000
#define REPLACE_SYSCALL 0x081298BC
//extern const u8 launch_image_tga[];
//extern const u32 launch_image_tga_size;
//extern const uint8_t launch_image_tga[];
//extern const uint32_t launch_image_tga_size;
static void uhs_exploit_init(int uhs_handle, cfw_config_t * config);
static int uhs_write32(int uhs_handle, int arm_addr, int val);
static void uhs_exploit_init(int32_t uhs_handle, cfw_config_t * config);
static int32_t uhs_write32(int32_t uhs_handle, int32_t arm_addr, int32_t val);
//!------Variables used in exploit------
static int *pretend_root_hub = (int*)0xF5003ABC;
static int *ayylmao = (int*)0xF4500000;
static int32_t *pretend_root_hub = (int32_t*)0xF5003ABC;
static int32_t *ayylmao = (int32_t*)0xF4500000;
//!-------------------------------------
typedef struct {
u32 size;
u8 data[0];
uint32_t size;
uint8_t data[0];
} payload_info_t;
/* YOUR ARM CODE HERE (starts at ARM_CODE_BASE) */
@ -45,7 +45,7 @@ typedef struct {
/* ROP CHAIN STARTS HERE (0x1015BD78) */
static const unsigned int final_chain[] = {
static const uint32_t final_chain[] = {
0x101236f3, // 0x00 POP {R1-R7,PC}
0x0, // 0x04 arg
0x0812974C, // 0x08 stackptr CMP R3, #1; STREQ R1, [R12]; BX LR
@ -236,7 +236,7 @@ static const unsigned int final_chain[] = {
REPLACE_SYSCALL, // 0x1DC start of syscall IOS_GetUpTime64
0x4001, // 0x1E0 on > 0x4000 it flushes all data caches
0x0, // 0x1E0
0x1012ED4C, // 0x1E4 IOS_FlushDCache(void *ptr, unsigned int len)
0x1012ED4C, // 0x1E4 IOS_FlushDCache(void *ptr, uint32_t len)
0x0, // 0x1DC
0x0, // 0x1E0
0x10123a9f, // 0x1E4 POP {R0,R1,R4,PC}
@ -258,7 +258,7 @@ static const unsigned int final_chain[] = {
0x101312D0,
};
static const int second_chain[] = {
static const int32_t second_chain[] = {
0x10123a9f, // 0x00 POP {R0,R1,R4,PC}
CHAIN_START + 0x14 + 0x4 + 0x20 - 0xF000, // 0x04 destination
0x0, // 0x08
@ -311,7 +311,7 @@ static const int second_chain[] = {
0x1012EA68, // 0xAC stack pivot
};
static void uhs_exploit_init(int dev_uhs_0_handle, cfw_config_t * config) {
static void uhs_exploit_init(int32_t dev_uhs_0_handle, cfw_config_t * config) {
ayylmao[5] = 1;
ayylmao[8] = 0x500000;
@ -370,23 +370,23 @@ static void uhs_exploit_init(int dev_uhs_0_handle, cfw_config_t * config) {
DCStoreRange((void*)0xF4120000, sizeof(second_chain));
DCStoreRange((void*)0xF4130000, sizeof(final_chain));
DCStoreRange((void*)0xF4140000, sizeof(ios_kernel_bin));
DCStoreRange((void*)0xF4148000, ((u32)payloads) - 0xF4148000);
DCStoreRange((void*)0xF4148000, ((uint32_t)payloads) - 0xF4148000);
}
static int uhs_write32(int dev_uhs_0_handle, int arm_addr, int val) {
static int32_t uhs_write32(int32_t dev_uhs_0_handle, int32_t arm_addr, int32_t val) {
ayylmao[520] = arm_addr - 24; //! The address to be overwritten, minus 24 bytes
DCStoreRange(ayylmao, 521 * 4); //! Make CPU fetch new data (with updated adress)
OSSleepTicks(0x200000); //! Improves stability
int request_buffer[] = { -(0xBEA2C), val }; //! -(0xBEA2C) gets IOS_USB to read from the middle of MEM1
int output_buffer[32];
int32_t request_buffer[] = { -(0xBEA2C), val }; //! -(0xBEA2C) gets IOS_USB to read from the middle of MEM1
int32_t output_buffer[32];
return IOS_Ioctl(dev_uhs_0_handle, 0x15, request_buffer, sizeof(request_buffer), output_buffer, sizeof(output_buffer));
}
int ExecuteIOSExploit(cfw_config_t * config) {
int32_t ExecuteIOSExploit(cfw_config_t * config) {
DEBUG_FUNCTION_LINE("Running ExecuteIOSExploit\n");
int iosuhaxFd = IOS_Open("/dev/iosuhax", 0);
int32_t iosuhaxFd = IOS_Open("/dev/iosuhax", 0);
if(iosuhaxFd >= 0) {
int dummy = 0;
int32_t dummy = 0;
IOS_Ioctl(iosuhaxFd, 0x03, &dummy, sizeof(dummy), &dummy, sizeof(dummy));
@ -397,7 +397,7 @@ int ExecuteIOSExploit(cfw_config_t * config) {
}
//! execute exploit
int dev_uhs_0_handle = IOS_Open("/dev/uhs/0", 0);
int32_t dev_uhs_0_handle = IOS_Open("/dev/uhs/0", 0);
if(dev_uhs_0_handle < 0) {
DEBUG_FUNCTION_LINE("Failed to open \"/dev/uhs/0\"\n");
return dev_uhs_0_handle;

View File

@ -12,13 +12,13 @@
extern "C" {
#endif
u32 * getFromGX2Buffer(struct buffer_store store, u32 size) {
uint32_t * getFromGX2Buffer(struct buffer_store store, uint32_t size) {
if(store.buffer != NULL) {
DEBUG_FUNCTION_LINE("We try to use the GX2 buffer. Needed space %08X (%d kb), available %08X (%d kb).\n",size,size/1024,store.buffer_size,store.buffer_size/1024);
if(store.buffer_size >= size) {
memset(store.buffer,0,store.buffer_size);
GX2Invalidate(GX2_INVALIDATE_CPU, store.buffer, store.buffer_size);
return (u32*) store.buffer;
return (uint32_t*) store.buffer;
}
}
return NULL;
@ -32,18 +32,18 @@ void overlay_helper(wups_overlay_options_type_t screen, overlay_callback callbac
OSScreenInit();
u32 * screenbuffer0 = NULL;
u32 * screenbuffer1 = NULL;
uint32_t * screenbuffer0 = NULL;
uint32_t * screenbuffer1 = NULL;
bool allocated_tv = false;
bool allocated_drc = false;
if(screen == WUPS_OVERLAY_DRC_ONLY) {
u32 screen_buf1_size = OSScreenGetBufferSizeEx(1);
uint32_t screen_buf1_size = OSScreenGetBufferSizeEx(1);
screenbuffer1 = getFromGX2Buffer(tv_store,screen_buf1_size);
if(screenbuffer1 == NULL) {
DEBUG_FUNCTION_LINE("We need to try to allocate buffer for the DRC.\n");
screenbuffer1 = (u32*)memalign(0x100, screen_buf1_size);
screenbuffer1 = (uint32_t*)memalign(0x100, screen_buf1_size);
if(screenbuffer1 != NULL) {
memset(screenbuffer1,0,screen_buf1_size);
DEBUG_FUNCTION_LINE("Successfully allocated DRC buffer!.\n");
@ -51,25 +51,25 @@ void overlay_helper(wups_overlay_options_type_t screen, overlay_callback callbac
}
}
} else if(screen == WUPS_OVERLAY_TV_ONLY) {
u32 screen_buf0_size = OSScreenGetBufferSizeEx(0);
uint32_t screen_buf0_size = OSScreenGetBufferSizeEx(0);
screenbuffer0 = getFromGX2Buffer(tv_store,screen_buf0_size);
if(screenbuffer0 == NULL) {
DEBUG_FUNCTION_LINE("We need to try to allocate buffer for the TV.\n");
screenbuffer0 = (u32*)memalign(0x100, screen_buf0_size);
screenbuffer0 = (uint32_t*)memalign(0x100, screen_buf0_size);
if(screenbuffer0 != NULL) {
memset(screenbuffer0,0,screen_buf0_size);
DEBUG_FUNCTION_LINE("Successfully allocated TV buffer!.\n");
allocated_tv = true;
}
}
} else if( screen == WUPS_OVERLAY_DRC_AND_TV || WUPS_OVERLAY_DRC_AND_TV_WITH_DRC_PRIO) {
} else if( screen == WUPS_OVERLAY_DRC_AND_TV || screen == WUPS_OVERLAY_DRC_AND_TV_WITH_DRC_PRIO) {
// TV Buffer init.
u32 screen_buf0_size = OSScreenGetBufferSizeEx(0);
uint32_t screen_buf0_size = OSScreenGetBufferSizeEx(0);
screenbuffer0 = getFromGX2Buffer(tv_store,screen_buf0_size);
if(screenbuffer0 == NULL) {
DEBUG_FUNCTION_LINE("We need to try to allocate buffer for the TV.\n");
screenbuffer0 = (u32*)memalign(0x100, screen_buf0_size);
screenbuffer0 = (uint32_t*)memalign(0x100, screen_buf0_size);
if(screenbuffer0 != NULL) {
memset(screenbuffer0,0,screen_buf0_size);
DEBUG_FUNCTION_LINE("Successfully allocated TV buffer!.\n");
@ -78,11 +78,11 @@ void overlay_helper(wups_overlay_options_type_t screen, overlay_callback callbac
}
// DRC Buffer init.
u32 screen_buf1_size = OSScreenGetBufferSizeEx(1);
uint32_t screen_buf1_size = OSScreenGetBufferSizeEx(1);
// Doesn't fit in the GX2 DRC buffer, we don't need to check it.
DEBUG_FUNCTION_LINE("We need to try to allocate buffer for the DRC.\n");
screenbuffer1 = (u32*)memalign(0x100, screen_buf1_size);
screenbuffer1 = (uint32_t*)memalign(0x100, screen_buf1_size);
if(screenbuffer1 != NULL) {
DEBUG_FUNCTION_LINE("Successfully allocated DRC buffer!.\n");
allocated_drc = true;

View File

@ -9,10 +9,10 @@ extern "C" {
struct buffer_store {
void * buffer;
s32 buffer_size;
s32 mode;
s32 surface_format;
vs32 buffering_mode;
uint32_t buffer_size;
int32_t mode;
int32_t surface_format;
volatile int32_t buffering_mode;
};
void overlay_helper(wups_overlay_options_type_t screen, overlay_callback callback);

View File

@ -105,20 +105,20 @@ void new_PatchInvidualMethodHooks(replacement_data_plugin_t * plugin_data) {
DEBUG_FUNCTION_LINE("Patching %d given functions\n",plugin_data->number_used_functions);
s32 method_hooks_count = plugin_data->number_used_functions;
int32_t method_hooks_count = plugin_data->number_used_functions;
u32 skip_instr = 1;
u32 my_instr_len = 6;
u32 instr_len = my_instr_len + skip_instr + 6;
u32 flush_len = 4*instr_len;
for(s32 i = 0; i < method_hooks_count; i++) {
uint32_t skip_instr = 1;
uint32_t my_instr_len = 6;
uint32_t instr_len = my_instr_len + skip_instr + 6;
uint32_t flush_len = 4*instr_len;
for(int32_t i = 0; i < method_hooks_count; i++) {
replacement_data_function_t * function_data = &plugin_data->functions[i];
/* Patch branches to it. */
volatile u32 *space = function_data->replace_data;
volatile uint32_t *space = function_data->replace_data;
DEBUG_FUNCTION_LINE("Patching %s ...\n",function_data->function_name);
if(function_data->functionType == STATIC_FUNCTION && function_data->alreadyPatched == 1) {
if(new_isDynamicFunction((u32)OSEffectiveToPhysical((void*)function_data->realAddr))) {
if(new_isDynamicFunction((uint32_t)OSEffectiveToPhysical((void*)function_data->realAddr))) {
DEBUG_FUNCTION_LINE("INFO: The function %s is a dynamic function.\n", function_data->function_name);
function_data->functionType = DYNAMIC_FUNCTION;
} else {
@ -127,11 +127,11 @@ void new_PatchInvidualMethodHooks(replacement_data_plugin_t * plugin_data) {
}
}
u32 physical = 0;
u32 repl_addr = (u32)function_data->replaceAddr;
u32 call_addr = (u32)function_data->replaceCall;
uint32_t physical = 0;
uint32_t repl_addr = (uint32_t)function_data->replaceAddr;
uint32_t call_addr = (uint32_t)function_data->replaceCall;
u32 real_addr = new_GetAddressOfFunction(function_data->function_name,function_data->library);
uint32_t real_addr = new_GetAddressOfFunction(function_data->function_name,function_data->library);
if(!real_addr) {
log_printf("\n");
@ -143,7 +143,7 @@ void new_PatchInvidualMethodHooks(replacement_data_plugin_t * plugin_data) {
DEBUG_FUNCTION_LINE("%s is located at %08X!\n", function_data->function_name,real_addr);
}
physical = (u32)OSEffectiveToPhysical((void*)real_addr);
physical = (uint32_t)OSEffectiveToPhysical((void*)real_addr);
if(!physical) {
log_printf("Error. Something is wrong with the physical address\n");
continue;
@ -153,10 +153,10 @@ void new_PatchInvidualMethodHooks(replacement_data_plugin_t * plugin_data) {
DEBUG_FUNCTION_LINE("%s physical is located at %08X!\n", function_data->function_name,physical);
}
*(volatile u32 *)(call_addr) = (u32)(space);
*(volatile uint32_t *)(call_addr) = (uint32_t)(space);
SC0x25_KernelCopyData((u32)space, physical, 4);
SC0x25_KernelCopyData((uint32_t)space, physical, 4);
space++;
//Only works if skip_instr == 1
@ -196,7 +196,7 @@ void new_PatchInvidualMethodHooks(replacement_data_plugin_t * plugin_data) {
space++;
u32 repl_addr_test = (u32) space;
uint32_t repl_addr_test = (uint32_t) space;
*space = 0x9061FFE0;
space++;
*space = 0x3C600000 | (((repl_addr) >> 16) & 0x0000FFFF); // lis r3, repl_addr@h
@ -213,11 +213,11 @@ void new_PatchInvidualMethodHooks(replacement_data_plugin_t * plugin_data) {
ICInvalidateRange((unsigned char*)(space - instr_len), flush_len);
//setting jump back
u32 replace_instr = 0x48000002 | (repl_addr_test & 0x03fffffc);
uint32_t replace_instr = 0x48000002 | (repl_addr_test & 0x03fffffc);
ICInvalidateRange(&replace_instr, 4);
DCFlushRange(&replace_instr, 4);
SC0x25_KernelCopyData(physical, (u32)OSEffectiveToPhysical(&replace_instr), 4);
SC0x25_KernelCopyData(physical, (uint32_t)OSEffectiveToPhysical(&replace_instr), 4);
ICInvalidateRange((void*)(real_addr), 4);
DCFlushRange((void*)(real_addr), 4);
@ -236,9 +236,9 @@ void new_RestoreInvidualInstructions(replacement_data_plugin_t * plugin_data) {
new_resetLibs();
DEBUG_FUNCTION_LINE("Restoring given functions!\n");
s32 method_hooks_count = plugin_data->number_used_functions;
int32_t method_hooks_count = plugin_data->number_used_functions;
for(s32 i = 0; i < method_hooks_count; i++) {
for(int32_t i = 0; i < method_hooks_count; i++) {
replacement_data_function_t * function_data = &plugin_data->functions[i];
DEBUG_FUNCTION_LINE("Restoring %s... ",function_data->function_name);
@ -247,14 +247,14 @@ void new_RestoreInvidualInstructions(replacement_data_plugin_t * plugin_data) {
continue;
}
u32 real_addr = new_GetAddressOfFunction(function_data->function_name,function_data->library);
uint32_t real_addr = new_GetAddressOfFunction(function_data->function_name,function_data->library);
if(!real_addr) {
log_printf("OSDynLoad_FindExport failed for %s\n", function_data->function_name);
continue;
}
u32 physical = (u32)OSEffectiveToPhysical((void*)real_addr);
uint32_t physical = (uint32_t)OSEffectiveToPhysical((void*)real_addr);
if(!physical) {
log_printf("Something is wrong with the physical address\n");
continue;
@ -263,11 +263,11 @@ void new_RestoreInvidualInstructions(replacement_data_plugin_t * plugin_data) {
if(new_isDynamicFunction(physical)) {
log_printf("Its a dynamic function. We don't need to restore it!\n",function_data->function_name);
} else {
physical = (u32)OSEffectiveToPhysical((void*)function_data->realAddr); //When its an static function, we need to use the old location
physical = (uint32_t)OSEffectiveToPhysical((void*)function_data->realAddr); //When its an static function, we need to use the old location
if(DEBUG_LOG_DYN) {
DEBUG_FUNCTION_LINE("Restoring %08X to %08X\n",(u32)function_data->restoreInstruction,physical);
DEBUG_FUNCTION_LINE("Restoring %08X to %08X\n",(uint32_t)function_data->restoreInstruction,physical);
}
SC0x25_KernelCopyData(physical,(u32)&function_data->restoreInstruction, 4);
SC0x25_KernelCopyData(physical,(uint32_t)&function_data->restoreInstruction, 4);
if(DEBUG_LOG_DYN) {
DEBUG_FUNCTION_LINE("ICInvalidateRange %08X\n",(void*)function_data->realAddr);
}
@ -281,37 +281,37 @@ void new_RestoreInvidualInstructions(replacement_data_plugin_t * plugin_data) {
DEBUG_FUNCTION_LINE("Done with restoring given functions!\n");
}
s32 new_isDynamicFunction(u32 physicalAddress) {
int32_t new_isDynamicFunction(uint32_t physicalAddress) {
if((physicalAddress & 0x80000000) == 0x80000000) {
return 1;
}
return 0;
}
u32 new_GetAddressOfFunction(const char * functionName,wups_loader_library_type_t library) {
u32 real_addr = 0;
uint32_t new_GetAddressOfFunction(const char * functionName,wups_loader_library_type_t library) {
uint32_t real_addr = 0;
if(strcmp(functionName, "OSDynLoad_Acquire") == 0) {
memcpy(&real_addr, &OSDynLoad_Acquire, 4);
return real_addr;
} else if(strcmp(functionName, "LiWaitOneChunk") == 0) {
real_addr = (u32)addr_LiWaitOneChunk;
real_addr = (uint32_t)addr_LiWaitOneChunk;
return real_addr;
} else if(strcmp(functionName, "LiBounceOneChunk") == 0) {
//! not required on firmwares above 3.1.0
if(OS_FIRMWARE >= 400)
return 0;
u32 addr_LiBounceOneChunk = 0x010003A0;
real_addr = (u32)addr_LiBounceOneChunk;
uint32_t addr_LiBounceOneChunk = 0x010003A0;
real_addr = (uint32_t)addr_LiBounceOneChunk;
return real_addr;
}
u32 rpl_handle = 0;
uint32_t rpl_handle = 0;
int rpl_handles_size = sizeof rpl_handles / sizeof rpl_handles[0];
int32_t rpl_handles_size = sizeof rpl_handles / sizeof rpl_handles[0];
for(int i = 0; i< rpl_handles_size; i++) {
for(int32_t i = 0; i< rpl_handles_size; i++) {
if(rpl_handles[i].library == library) {
if(rpl_handles[i].handle == 0) {
DEBUG_FUNCTION_LINE("Lets acquire handle for rpl: %s\n",rpl_handles[i].rplname);
@ -338,13 +338,13 @@ u32 new_GetAddressOfFunction(const char * functionName,wups_loader_library_type_
return 0;
}
if((library == WUPS_LOADER_LIBRARY_NN_ACP) && (u32)(*(volatile u32*)(real_addr) & 0x48000002) == 0x48000000) {
u32 address_diff = (u32)(*(volatile u32*)(real_addr) & 0x03FFFFFC);
if((library == WUPS_LOADER_LIBRARY_NN_ACP) && (uint32_t)(*(volatile uint32_t*)(real_addr) & 0x48000002) == 0x48000000) {
uint32_t address_diff = (uint32_t)(*(volatile uint32_t*)(real_addr) & 0x03FFFFFC);
if((address_diff & 0x03000000) == 0x03000000) {
address_diff |= 0xFC000000;
}
real_addr += (s32)address_diff;
if((u32)(*(volatile u32*)(real_addr) & 0x48000002) == 0x48000000) {
real_addr += (int32_t)address_diff;
if((uint32_t)(*(volatile uint32_t*)(real_addr) & 0x48000002) == 0x48000000) {
return 0;
}
}
@ -353,9 +353,9 @@ u32 new_GetAddressOfFunction(const char * functionName,wups_loader_library_type_
}
void new_resetLibs() {
int rpl_handles_size = sizeof rpl_handles / sizeof rpl_handles[0];
int32_t rpl_handles_size = sizeof rpl_handles / sizeof rpl_handles[0];
for(int i = 0; i< rpl_handles_size; i++) {
for(int32_t i = 0; i< rpl_handles_size; i++) {
if(rpl_handles[i].handle != 0) {
DEBUG_FUNCTION_LINE("Resetting handle for rpl: %s\n",rpl_handles[i].rplname);
}

View File

@ -29,7 +29,7 @@ extern "C" {
struct rpl_handling {
wups_loader_library_type_t library;
const char rplname[15];
u32 handle;
uint32_t handle;
};
#define STATIC_FUNCTION 0
#define DYNAMIC_FUNCTION 1
@ -40,15 +40,15 @@ struct rpl_handling {
#define MAXIMUM_FUNCTION_NAME_LENGTH 61
struct replacement_data_function_t {
u32 replaceAddr; /* [needs to be filled] Address of our replacement function */
u32 replaceCall; /* [needs to be filled] Address to access the real_function */
uint32_t replaceAddr; /* [needs to be filled] Address of our replacement function */
uint32_t replaceCall; /* [needs to be filled] Address to access the real_function */
wups_loader_library_type_t library; /* [needs to be filled] rpl where the function we want to replace is. */
char function_name[MAXIMUM_FUNCTION_NAME_LENGTH]; /* [needs to be filled] name of the function we want to replace */
u32 realAddr; /* [will be filled] Address of the real function we want to replace. */
volatile u32 replace_data [FUNCTION_PATCHER_METHOD_STORE_SIZE]; /* [will be filled] Space for us to store some jump instructions */
u32 restoreInstruction; /* [will be filled] Copy of the instruction we replaced to jump to our code. */
u8 functionType; /* [will be filled] */
u8 alreadyPatched; /* [will be filled] */
uint32_t realAddr; /* [will be filled] Address of the real function we want to replace. */
volatile uint32_t replace_data [FUNCTION_PATCHER_METHOD_STORE_SIZE]; /* [will be filled] Space for us to store some jump instructions */
uint32_t restoreInstruction; /* [will be filled] Copy of the instruction we replaced to jump to our code. */
uint8_t functionType; /* [will be filled] */
uint8_t alreadyPatched; /* [will be filled] */
};
struct replacement_data_hook_t {
@ -62,25 +62,25 @@ struct replacement_data_hook_t {
struct replacement_data_plugin_t {
char path[MAXIMUM_PLUGIN_PATH_NAME_LENGTH] = ""; // Path where the plugin is stored
char plugin_name[MAXIMUM_PLUGIN_NAME_LENGTH] = ""; // Name of this plugin
int priority; // Priority of this plugin
int number_used_functions; // Number of used function. Maximum is MAXIMUM_FUNCTION_PER_PLUGIN
int32_t priority; // Priority of this plugin
int32_t number_used_functions; // Number of used function. Maximum is MAXIMUM_FUNCTION_PER_PLUGIN
replacement_data_function_t functions[MAXIMUM_FUNCTION_PER_PLUGIN]; // Replacement information for each function.
int number_used_hooks; // Number of used hooks. Maximum is MAXIMUM_HOOKS_PER_PLUGIN
int32_t number_used_hooks; // Number of used hooks. Maximum is MAXIMUM_HOOKS_PER_PLUGIN
replacement_data_hook_t hooks[MAXIMUM_HOOKS_PER_PLUGIN]; // Replacement information for each function.
};
#define MAXIMUM_PLUGINS 32
struct replacement_data_t {
int number_used_plugins = 0; // Number of used function. Maximum is MAXIMUM_FUNCTION_PER_PLUGIN
int32_t number_used_plugins = 0; // Number of used function. Maximum is MAXIMUM_FUNCTION_PER_PLUGIN
replacement_data_plugin_t plugin_data[MAXIMUM_PLUGINS];
};
void new_PatchInvidualMethodHooks(replacement_data_plugin_t * data);
void new_RestoreInvidualInstructions(replacement_data_plugin_t * plugin_data);
u32 new_GetAddressOfFunction(const char * functionName,wups_loader_library_type_t library);
s32 new_isDynamicFunction(u32 physicalAddress);
uint32_t new_GetAddressOfFunction(const char * functionName,wups_loader_library_type_t library);
int32_t new_isDynamicFunction(uint32_t physicalAddress);
void new_resetLibs();
#ifdef __cplusplus

View File

@ -19,8 +19,8 @@ DECL(void, __PPCExit, void) {
real___PPCExit();
}
DECL(u32, ProcUIProcessMessages, u32 u) {
u32 res = real_ProcUIProcessMessages(u);
DECL(uint32_t, ProcUIProcessMessages, uint32_t u) {
uint32_t res = real_ProcUIProcessMessages(u);
// Only continue if we are in the "right" application.
if(res != gAppStatus && OSGetTitleID() == gGameTitleID) {
DEBUG_FUNCTION_LINE("App status changed from %d to %d \n",gAppStatus,res);
@ -35,7 +35,7 @@ DECL(u32, ProcUIProcessMessages, u32 u) {
return res;
}
DECL(void, GX2SetTVBuffer, void *buffer, u32 buffer_size, s32 tv_render_mode, s32 format, s32 buffering_mode) {
DECL(void, GX2SetTVBuffer, void *buffer, uint32_t buffer_size, int32_t tv_render_mode, int32_t format, int32_t buffering_mode) {
tv_store.buffer = buffer;
tv_store.buffer_size = buffer_size;
tv_store.mode = tv_render_mode;
@ -45,7 +45,7 @@ DECL(void, GX2SetTVBuffer, void *buffer, u32 buffer_size, s32 tv_render_mode, s3
return real_GX2SetTVBuffer(buffer,buffer_size,tv_render_mode,format,buffering_mode);
}
DECL(void, GX2SetDRCBuffer, void *buffer, u32 buffer_size, s32 drc_mode, s32 surface_format, s32 buffering_mode) {
DECL(void, GX2SetDRCBuffer, void *buffer, uint32_t buffer_size, int32_t drc_mode, int32_t surface_format, int32_t buffering_mode) {
drc_store.buffer = buffer;
drc_store.buffer_size = buffer_size;
drc_store.mode = drc_mode;
@ -60,9 +60,9 @@ DECL(void, GX2WaitForVsync, void) {
real_GX2WaitForVsync();
}
u8 vpadPressCooldown = 0xFF;
DECL(int, VPADRead, int chan, VPADData *buffer, u32 buffer_size, s32 *error) {
int result = real_VPADRead(chan, buffer, buffer_size, error);
uint8_t vpadPressCooldown = 0xFF;
DECL(int32_t, VPADRead, int32_t chan, VPADData *buffer, uint32_t buffer_size, int32_t *error) {
int32_t result = real_VPADRead(chan, buffer, buffer_size, error);
if(result > 0 && (buffer[0].btns_h == (VPAD_BUTTON_PLUS | VPAD_BUTTON_R | VPAD_BUTTON_L)) && vpadPressCooldown == 0 && OSIsHomeButtonMenuEnabled()) {
if(MemoryMapping::isMemoryMapped()) {
@ -89,8 +89,8 @@ hooks_magic_t method_hooks_hooks[] __attribute__((section(".data"))) = {
};
u32 method_hooks_size_hooks __attribute__((section(".data"))) = sizeof(method_hooks_hooks) / sizeof(hooks_magic_t);
uint32_t method_hooks_size_hooks __attribute__((section(".data"))) = sizeof(method_hooks_hooks) / sizeof(hooks_magic_t);
//! buffer to store our instructions needed for our replacements
volatile u32 method_calls_hooks[sizeof(method_hooks_hooks) / sizeof(hooks_magic_t) * FUNCTION_PATCHER_METHOD_STORE_SIZE] __attribute__((section(".data")));
volatile uint32_t method_calls_hooks[sizeof(method_hooks_hooks) / sizeof(hooks_magic_t) * FUNCTION_PATCHER_METHOD_STORE_SIZE] __attribute__((section(".data")));

View File

@ -8,8 +8,8 @@ extern "C" {
#endif
extern hooks_magic_t method_hooks_hooks[];
extern u32 method_hooks_size_hooks;
extern volatile u32 method_calls_hooks[];
extern uint32_t method_hooks_size_hooks;
extern volatile uint32_t method_calls_hooks[];
#ifdef __cplusplus
}

View File

@ -13,7 +13,7 @@ dyn_linking_function_t * DynamicLinkingHelper::getOrAddFunctionEntryByName(const
return NULL;
}
dyn_linking_function_t * result = NULL;
for(int i = 0; i < DYN_LINK_FUNCTION_LIST_LENGTH; i++) {
for(int32_t i = 0; i < DYN_LINK_FUNCTION_LIST_LENGTH; i++) {
dyn_linking_function_t * curEntry = &gbl_dyn_linking_data.functions[i];
if(strlen(curEntry->functionName) == 0) {
strncpy(curEntry->functionName,functionName,DYN_LINK_FUNCTION_NAME_LENGTH);
@ -43,7 +43,7 @@ dyn_linking_import_t * DynamicLinkingHelper::getOrAddImport(const char* importNa
return NULL;
}
dyn_linking_import_t * result = NULL;
for(int i = 0; i < DYN_LINK_IMPORT_LIST_LENGTH; i++) {
for(int32_t i = 0; i < DYN_LINK_IMPORT_LIST_LENGTH; i++) {
dyn_linking_import_t * curEntry = &gbl_dyn_linking_data.imports[i];
if(strlen(curEntry->importName) == 0) {
strncpy(curEntry->importName,importName,DYN_LINK_IMPORT_NAME_LENGTH);
@ -62,7 +62,7 @@ bool DynamicLinkingHelper::addReloationEntry(RelocationData * relocationData) {
return addReloationEntry(relocationData->getType(), relocationData->getOffset(), relocationData->getAddend(), relocationData->getDestination(), relocationData->getName(), relocationData->getImportRPLInformation());
}
bool DynamicLinkingHelper::addReloationEntry(char type, size_t offset, int addend, void *destination, std::string name, ImportRPLInformation * rplInfo) {
bool DynamicLinkingHelper::addReloationEntry(char type, size_t offset, int32_t addend, void *destination, std::string name, ImportRPLInformation * rplInfo) {
dyn_linking_import_t * importInfoGbl = DynamicLinkingHelper::getOrAddImport(rplInfo->getName().c_str(),rplInfo->isData());
if(importInfoGbl == NULL) {
DEBUG_FUNCTION_LINE("Getting import info failed. Probably maximum of %d rpl files to import reached.\n",DYN_LINK_IMPORT_LIST_LENGTH);
@ -78,8 +78,8 @@ bool DynamicLinkingHelper::addReloationEntry(char type, size_t offset, int adden
return addReloationEntry(type, offset, addend, destination, functionInfo, importInfoGbl);
}
bool DynamicLinkingHelper::addReloationEntry(char type, size_t offset, int addend, void *destination, dyn_linking_function_t * functionName, dyn_linking_import_t * importInfo) {
for(int i = 0; i < DYN_LINK_RELOCATION_LIST_LENGTH; i++) {
bool DynamicLinkingHelper::addReloationEntry(char type, size_t offset, int32_t addend, void *destination, dyn_linking_function_t * functionName, dyn_linking_import_t * importInfo) {
for(int32_t i = 0; i < DYN_LINK_RELOCATION_LIST_LENGTH; i++) {
dyn_linking_relocation_entry_t * curEntry = &gbl_dyn_linking_data.entries[i];
if(curEntry->functionEntry != NULL) {
continue;
@ -98,7 +98,7 @@ bool DynamicLinkingHelper::addReloationEntry(char type, size_t offset, int adden
std::vector<dyn_linking_relocation_entry_t *> DynamicLinkingHelper::getAllValidDynamicLinkingRelocations() {
std::vector<dyn_linking_relocation_entry_t *> result;
for(int i = 0; i < DYN_LINK_RELOCATION_LIST_LENGTH; i++) {
for(int32_t i = 0; i < DYN_LINK_RELOCATION_LIST_LENGTH; i++) {
if(gbl_dyn_linking_data.entries[i].functionEntry == NULL) {
break;
}
@ -133,7 +133,7 @@ bool DynamicLinkingHelper::fillRelocations(std::vector<dyn_linking_relocation_en
} else {
OSDynLoad_Acquire(importEntry->importName, &importEntry->handle);
}
int isData = 0;
int32_t isData = 0;
if(importEntry->isData) {
isData = 1;
//DEBUG_FUNCTION_LINE("isData\n");
@ -154,8 +154,8 @@ bool DynamicLinkingHelper::fillRelocations(std::vector<dyn_linking_relocation_en
80 61 ff e0 lwz r3,-32(r1)
4e 80 04 20 bctr*/
functionEntry->big_jump[0] = 0x9061FFE0;
functionEntry->big_jump[1] = 0x3C600000 | ((((u32) functionEntry->address) >> 16) & 0x0000FFFF); // lis r3, real_addr@h
functionEntry->big_jump[2] = 0x60630000 | (((u32) functionEntry->address) & 0x0000ffff); // ori r3, r3, real_addr@l
functionEntry->big_jump[1] = 0x3C600000 | ((((uint32_t) functionEntry->address) >> 16) & 0x0000FFFF); // lis r3, real_addr@h
functionEntry->big_jump[2] = 0x60630000 | (((uint32_t) functionEntry->address) & 0x0000ffff); // ori r3, r3, real_addr@l
functionEntry->big_jump[3] = 0x7C6903A6; // mtctr r3
functionEntry->big_jump[4] = 0x8061FFE0; // lwz r3,-32(r1)
functionEntry->big_jump[5] = 0x4E800420; // bctr
@ -169,14 +169,14 @@ bool DynamicLinkingHelper::fillRelocations(std::vector<dyn_linking_relocation_en
//DEBUG_FUNCTION_LINE("We cached the address of function %s :%08X\n",functionEntry->functionName,functionEntry->address);
}
//DEBUG_FUNCTION_LINE("Linking: t: %02X o: %08X a: %d dest: %08X tar: %08X big_j: %08X\n",curEntry->type, curEntry->offset, curEntry->addend, curEntry->destination, functionEntry->address, (u32) functionEntry->big_jump);
//DEBUG_FUNCTION_LINE("Linking: t: %02X o: %08X a: %d dest: %08X tar: %08X big_j: %08X\n",curEntry->type, curEntry->offset, curEntry->addend, curEntry->destination, functionEntry->address, (uint32_t) functionEntry->big_jump);
DEBUG_FUNCTION_LINE("Resolving relocation to %s\n",functionEntry->functionName);
if(!curEntry->importEntry->isData && (u32) functionEntry->address > 0x04000000) {
ElfTools::elfLinkOne(curEntry->type, curEntry->offset, curEntry->addend, curEntry->destination, (u32) functionEntry->big_jump);
if(!curEntry->importEntry->isData && (uint32_t) functionEntry->address > 0x04000000) {
ElfTools::elfLinkOne(curEntry->type, curEntry->offset, curEntry->addend, curEntry->destination, (uint32_t) functionEntry->big_jump);
} else {
ElfTools::elfLinkOne(curEntry->type, curEntry->offset, curEntry->addend, curEntry->destination, (u32) functionEntry->address);
ElfTools::elfLinkOne(curEntry->type, curEntry->offset, curEntry->addend, curEntry->destination, (uint32_t) functionEntry->address);
}
}

View File

@ -67,9 +67,9 @@ public:
bool addReloationEntry(RelocationData * relocationData);
bool addReloationEntry(char type, size_t offset, int addend, void *destination, std::string name, ImportRPLInformation * rplInfo);
bool addReloationEntry(char type, size_t offset, int32_t addend, void *destination, std::string name, ImportRPLInformation * rplInfo);
bool addReloationEntry(char type, size_t offset, int addend, void *destination, dyn_linking_function_t * functionName, dyn_linking_import_t * importInfo);
bool addReloationEntry(char type, size_t offset, int32_t addend, void *destination, dyn_linking_function_t * functionName, dyn_linking_import_t * importInfo);
std::vector<dyn_linking_relocation_entry_t *> getAllValidDynamicLinkingRelocations();

View File

@ -208,7 +208,7 @@ bool ElfTools::elfLink(Elf *elf, size_t shndx, void *destination, Elf32_Sym *sym
reloc->address = destination;
reloc->offset = rel[i].r_offset;
reloc->type = ELF32_R_TYPE(rel[i].r_info);
reloc->addend = *(int *)((char *)destination + rel[i].r_offset);
reloc->addend = *(int32_t *)((char *)destination + rel[i].r_offset);
continue;
*/
@ -230,7 +230,7 @@ bool ElfTools::elfLink(Elf *elf, size_t shndx, void *destination, Elf32_Sym *sym
}
}
if (!ElfTools::elfLinkOne(ELF32_R_TYPE(rel[i].r_info), rel[i].r_offset, *(int *)((char *)destination + rel[i].r_offset), destination, symbol_addr)) {
if (!ElfTools::elfLinkOne(ELF32_R_TYPE(rel[i].r_info), rel[i].r_offset, *(int32_t *)((char *)destination + rel[i].r_offset), destination, symbol_addr)) {
DEBUG_FUNCTION_LINE("elfLinkOne failed\n");
return false;
}
@ -268,11 +268,11 @@ bool ElfTools::elfLink(Elf *elf, size_t shndx, void *destination, Elf32_Sym *sym
break;
}
case SHN_COMMON: {
u32 align = symtab[symbol].st_value;
u32 size = symtab[symbol].st_size;
uint32_t align = symtab[symbol].st_value;
uint32_t size = symtab[symbol].st_size;
uint32_t address = pluginData->getMemoryForCommonBySymbol(symbol, align, size);
if(address == NULL){
if(address == 0){
DEBUG_FUNCTION_LINE("Failed to get memory for common relocation\n");
return false;
}
@ -372,8 +372,8 @@ bool ElfTools::elfLink(Elf *elf, size_t shndx, void *destination, Elf32_Sym *sym
return true;
}
bool ElfTools::elfLinkOne(char type, size_t offset, int addend, void *destination, uint32_t symbol_addr) {
int value;
bool ElfTools::elfLinkOne(char type, size_t offset, int32_t addend, void *destination, uint32_t symbol_addr) {
int32_t value;
char *target = (char *)destination + offset;
bool result = false;
@ -389,7 +389,7 @@ bool ElfTools::elfLinkOne(char type, size_t offset, int addend, void *destinatio
case R_PPC_ADDR14_BRNTAKEN:
case R_PPC_UADDR32:
case R_PPC_UADDR16: {
value = (int)symbol_addr + addend;
value = (int32_t)symbol_addr + addend;
break;
}
case R_PPC_REL24:
@ -400,7 +400,7 @@ bool ElfTools::elfLinkOne(char type, size_t offset, int addend, void *destinatio
case R_PPC_REL14_BRNTAKEN:
case R_PPC_REL32:
case R_PPC_ADDR30: {
value = (int)symbol_addr + addend - (int)target;
value = (int32_t)symbol_addr + addend - (int32_t)target;
break;
}
case R_PPC_SECTOFF:
@ -415,7 +415,7 @@ bool ElfTools::elfLinkOne(char type, size_t offset, int addend, void *destinatio
case R_PPC_EMB_NADDR16_LO:
case R_PPC_EMB_NADDR16_HI:
case R_PPC_EMB_NADDR16_HA: {
value = addend - (int)symbol_addr;
value = addend - (int32_t)symbol_addr;
break;
}
default:
@ -429,15 +429,15 @@ bool ElfTools::elfLinkOne(char type, size_t offset, int addend, void *destinatio
case R_PPC_REL32:
case R_PPC_SECTOFF:
case R_PPC_EMB_NADDR32: {
*(int *)target = value;
*(int32_t *)target = value;
break;
}
case R_PPC_ADDR24:
case R_PPC_PLTREL24:
case R_PPC_LOCAL24PC:
case R_PPC_REL24: {
*(int *)target =
(*(int *)target & 0xfc000003) | (value & 0x03fffffc);
*(int32_t *)target =
(*(int32_t *)target & 0xfc000003) | (value & 0x03fffffc);
break;
}
case R_PPC_ADDR16:
@ -466,26 +466,26 @@ bool ElfTools::elfLinkOne(char type, size_t offset, int addend, void *destinatio
}
case R_PPC_ADDR14:
case R_PPC_REL14: {
*(int *)target =
(*(int *)target & 0xffff0003) | (value & 0x0000fffc);
*(int32_t *)target =
(*(int32_t *)target & 0xffff0003) | (value & 0x0000fffc);
break;
}
case R_PPC_ADDR14_BRTAKEN:
case R_PPC_REL14_BRTAKEN: {
*(int *)target =
(*(int *)target & 0xffdf0003) | (value & 0x0000fffc) |
*(int32_t *)target =
(*(int32_t *)target & 0xffdf0003) | (value & 0x0000fffc) |
0x00200000;
break;
}
case R_PPC_ADDR14_BRNTAKEN:
case R_PPC_REL14_BRNTAKEN: {
*(int *)target =
(*(int *)target & 0xffdf0003) | (value & 0x0000fffc);
*(int32_t *)target =
(*(int32_t *)target & 0xffdf0003) | (value & 0x0000fffc);
break;
}
case R_PPC_ADDR30: {
*(int *)target =
(*(int *)target & 0x00000003) | (value & 0xfffffffc);
*(int32_t *)target =
(*(int32_t *)target & 0x00000003) | (value & 0xfffffffc);
break;
}
default:

View File

@ -46,7 +46,7 @@ public:
static bool loadElfSymtab(Elf *elf, Elf32_Sym **symtab, size_t *symtab_count, size_t *symtab_strndx);
static void elfLoadSymbols(size_t shndx, const void *destination, Elf32_Sym *symtab, size_t symtab_count);
static bool elfLink(Elf *elf, size_t shndx, void *destination, Elf32_Sym *symtab, size_t symtab_count, size_t symtab_strndx, bool allow_globals, PluginData * pluginData = NULL);
static bool elfLinkOne(char type, size_t offset, int addend, void *destination, uint32_t symbol_addr);
static bool elfLinkOne(char type, size_t offset, int32_t addend, void *destination, uint32_t symbol_addr);
};
#endif

View File

@ -24,7 +24,7 @@
class ImportRPLInformation {
public:
ImportRPLInformation(int section_header_index, std::string name, bool isData = false) {
ImportRPLInformation(int32_t section_header_index, std::string name, bool isData = false) {
this->name = name;
this->section_header_index = section_header_index;
this->_isData = isData;
@ -34,7 +34,7 @@ public:
}
static ImportRPLInformation * createImportRPLInformation(int section_header_index, std::string rawSectionName) {
static ImportRPLInformation * createImportRPLInformation(int32_t section_header_index, std::string rawSectionName) {
std::string fimport = ".fimport_";
std::string dimport = ".dimport_";
@ -61,7 +61,7 @@ public:
return name;
}
int getSectionHeaderIndex() {
int32_t getSectionHeaderIndex() {
return section_header_index;
}
@ -72,7 +72,7 @@ public:
private:
std::string name;
bool _isData = false;
int section_header_index = 0;
int32_t section_header_index = 0;
};

View File

@ -21,7 +21,7 @@
#include "PluginData.h"
#include "PluginLoader.h"
ImportRPLInformation * PluginData::getImportRPLInformationBySectionHeaderIndex(int section_header_index) {
ImportRPLInformation * PluginData::getImportRPLInformationBySectionHeaderIndex(int32_t section_header_index) {
for(size_t i = 0; i< importRPLInformation_list.size(); i++) {
if(importRPLInformation_list[i] != NULL && importRPLInformation_list[i]->getSectionHeaderIndex() == section_header_index) {
return importRPLInformation_list[i];

View File

@ -109,7 +109,7 @@ public:
\return A pointer to the corresponding ImportRPLInformation, return NULL if no corresponding information was found.
**/
ImportRPLInformation * getImportRPLInformationBySectionHeaderIndex(int section_header_index);
ImportRPLInformation * getImportRPLInformationBySectionHeaderIndex(int32_t section_header_index);
PluginInformation * getPluginInformation() {

View File

@ -65,7 +65,7 @@ bool PluginInformation::checkFileExtenstion(const char * path) {
bool PluginInformation::openAndParseElf() {
bool result = false;
int fd = -1;
int32_t fd = -1;
Elf *elf = NULL;
/* check for compile errors */

View File

@ -81,7 +81,7 @@ std::vector<PluginInformation *> PluginLoader::getPluginInformation(const char *
std::vector<PluginInformation *> PluginLoader::getPluginsLoadedInMemory() {
std::vector<PluginInformation *> pluginInformation;
for(s32 i = 0; i < gbl_replacement_data.number_used_plugins; i++) {
for(int32_t i = 0; i < gbl_replacement_data.number_used_plugins; i++) {
replacement_data_plugin_t * pluginInfo = &gbl_replacement_data.plugin_data[i];
PluginInformation * curPlugin = PluginInformation::loadPluginInformation(pluginInfo->path);
if(curPlugin != NULL) {
@ -134,7 +134,7 @@ void PluginLoader::clearPluginInformation(std::vector<PluginInformation *> plugi
PluginData * PluginLoader::loadAndLinkPlugin(PluginInformation * pluginInformation) {
PluginData * result = NULL;
int fd = -1;
int32_t fd = -1;
Elf *elf = NULL;
if(pluginInformation == NULL) {
@ -142,7 +142,7 @@ PluginData * PluginLoader::loadAndLinkPlugin(PluginInformation * pluginInformati
goto exit_error;
}
if(pluginInformation->getSize() > ((u32) getAvailableSpace())) {
if(pluginInformation->getSize() > ((uint32_t) getAvailableSpace())) {
DEBUG_FUNCTION_LINE("Not enough space left to loader the plugin into memory %08X %08X\n",pluginInformation->getSize(),getAvailableSpace());
goto exit_error;
}
@ -192,7 +192,7 @@ bool PluginLoader::loadAndLinkElf(PluginData * pluginData, Elf *elf, void * endA
return false;
}
u32 curAddress = (u32) endAddress;
uint32_t curAddress = (uint32_t) endAddress;
Elf_Scn *scn;
size_t symtab_count, section_count, shstrndx, symtab_strndx, entries_count, hooks_count;
@ -202,7 +202,7 @@ bool PluginLoader::loadAndLinkElf(PluginData * pluginData, Elf *elf, void * endA
wups_loader_hook_t *hooks = NULL;
bool result = false;
int i = 1;
int32_t i = 1;
std::vector<wups_loader_entry_t *> entry_t_list;
std::vector<wups_loader_hook_t *> hook_t_list;
@ -304,13 +304,13 @@ bool PluginLoader::loadAndLinkElf(PluginData * pluginData, Elf *elf, void * endA
curAddress -= shdr->sh_size;
if (shdr->sh_addralign > 3) {
curAddress = (u32)((int)curAddress & ~(shdr->sh_addralign - 1));
curAddress = (uint32_t)((int32_t)curAddress & ~(shdr->sh_addralign - 1));
} else {
curAddress = (u32)((int)curAddress & ~3);
curAddress = (uint32_t)((int32_t)curAddress & ~3);
}
destinations[elf_ndxscn(scn)] = (uint8_t *) curAddress;
if((u32) curAddress < (u32) this->startAddress) {
if((uint32_t) curAddress < (uint32_t) this->startAddress) {
DEBUG_FUNCTION_LINE("Not enough space to load function %s into memory at %08X.\n",name,curAddress);
goto exit_error;
}
@ -406,7 +406,7 @@ void PluginLoader::copyPluginDataIntoGlobalStruct(std::vector<PluginData *> plug
// Reset data
memset((void*)&gbl_replacement_data,0,sizeof(gbl_replacement_data));
DynamicLinkingHelper::getInstance()->clearAll();
int plugin_index = 0;
int32_t plugin_index = 0;
// Copy data to global struct.
for(size_t i = 0; i< plugins.size(); i++) {
PluginData * cur_plugin = plugins.at(i);
@ -462,8 +462,8 @@ void PluginLoader::copyPluginDataIntoGlobalStruct(std::vector<PluginData *> plug
strncpy(function_data->function_name,cur_function->getName().c_str(),MAXIMUM_FUNCTION_NAME_LENGTH-1);
function_data->library = cur_function->getLibrary();
function_data->replaceAddr = (u32) cur_function->getReplaceAddress();
function_data->replaceCall = (u32) cur_function->getReplaceCall();
function_data->replaceAddr = (uint32_t) cur_function->getReplaceAddress();
function_data->replaceCall = (uint32_t) cur_function->getReplaceCall();
plugin_data->number_used_functions++;
}
@ -491,7 +491,7 @@ void PluginLoader::copyPluginDataIntoGlobalStruct(std::vector<PluginData *> plug
}
uint32_t PluginLoader::getMemoryFromDataSection(size_t align, size_t size) {
uint32_t ptr = (u32)gbl_common_data_ptr;
uint32_t ptr = (uint32_t)gbl_common_data_ptr;
ptr = (ptr + (align - 1)) & -align; // Round up to align boundary
uint32_t result = ptr;

View File

@ -95,11 +95,11 @@ public:
static void flushCache() {
u32 startAddress = getApplicationEndAddr();
u32 endAddress = PLUGIN_LOCATION_END_ADDRESS;
uint32_t startAddress = getApplicationEndAddr();
uint32_t endAddress = PLUGIN_LOCATION_END_ADDRESS;
DCFlushRange((void*)startAddress,(u32)endAddress - (u32)startAddress);
ICInvalidateRange((void*)startAddress,(u32)endAddress - (u32)startAddress);
DCFlushRange((void*)startAddress,(uint32_t)endAddress - (uint32_t)startAddress);
ICInvalidateRange((void*)startAddress,(uint32_t)endAddress - (uint32_t)startAddress);
}
/**
@ -110,11 +110,11 @@ public:
void clearPluginInformation(std::vector<PluginInformation*> PluginInformation);
size_t getTotalSpace() {
return ((u32) this->endAddress - (u32) this->startAddress);
return ((uint32_t) this->endAddress - (uint32_t) this->startAddress);
}
size_t getAvailableSpace() {
return ((u32) this->currentStoreAddress - (u32) this->startAddress);
return ((uint32_t) this->currentStoreAddress - (uint32_t) this->startAddress);
}
size_t getUsedSpace() {

View File

@ -25,7 +25,7 @@
class RelocationData {
public:
RelocationData(char type, size_t offset, int addend, void *destination, std::string name, ImportRPLInformation * rplInfo) {
RelocationData(char type, size_t offset, int32_t addend, void *destination, std::string name, ImportRPLInformation * rplInfo) {
this->type = type;
this->offset = offset;
this->addend = addend;
@ -46,7 +46,7 @@ public:
return offset;
}
int getAddend() {
int32_t getAddend() {
return addend;
}
@ -69,7 +69,7 @@ public:
private:
char type;
size_t offset;
int addend;
int32_t addend;
void *destination;
std::string name;
ImportRPLInformation * rplInfo;

View File

@ -35,13 +35,13 @@ extern "C" {
typedef struct _dyn_linking_function_t {
char functionName[DYN_LINK_FUNCTION_NAME_LENGTH+1];
void * address;
u32 big_jump[6];
uint32_t big_jump[6];
} dyn_linking_function_t;
typedef struct _dyn_linking_import_t {
char importName[DYN_LINK_IMPORT_NAME_LENGTH+1];
bool isData = false;
u32 handle = 0;
uint32_t handle = 0;
} dyn_linking_import_t;
typedef struct _dyn_linking_relocation_entry_t {
@ -50,7 +50,7 @@ typedef struct _dyn_linking_relocation_entry_t {
void * destination = NULL;
char type;
size_t offset;
int addend;
int32_t addend;
} dyn_linking_relocation_entry_t;
typedef struct _dyn_linking_relocation_data_t {

View File

@ -7,21 +7,22 @@
* Any manual modification of this file will be overwriten by the generation.
*****************************************************************************/
#include <resources/filelist.h>
#include <stdint.h>
extern const u8 font_ttf[];
extern const u32 font_ttf_size;
extern const uint8_t font_ttf[];
extern const uint32_t font_ttf_size;
extern const u8 GithubIcon_png[];
extern const u32 GithubIcon_png_size;
extern const uint8_t GithubIcon_png[];
extern const uint32_t GithubIcon_png_size;
extern const u8 HomeButtonIcon_png[];
extern const u32 HomeButtonIcon_png_size;
extern const uint8_t HomeButtonIcon_png[];
extern const uint32_t HomeButtonIcon_png_size;
extern const u8 PlusButtonIcon_png[];
extern const u32 PlusButtonIcon_png_size;
extern const uint8_t PlusButtonIcon_png[];
extern const uint32_t PlusButtonIcon_png_size;
extern const u8 TwitterIcon_png[];
extern const u32 TwitterIcon_png_size;
extern const uint8_t TwitterIcon_png[];
extern const uint32_t TwitterIcon_png_size;
static ResourceFile ResourceList[] =
{

View File

@ -42,7 +42,7 @@ CSettings::CSettings() {
}
CSettings::~CSettings() {
for(u32 i = 0; i < settingsValues.size(); i++) {
for(uint32_t i = 0; i < settingsValues.size(); i++) {
if(settingsValues[i].dataType == TypeString)
delete settingsValues[i].strValue;
}
@ -50,7 +50,7 @@ CSettings::~CSettings() {
}
void CSettings::SetDefault() {
for(u32 i = 0; i < settingsValues.size(); i++) {
for(uint32_t i = 0; i < settingsValues.size(); i++) {
if(settingsValues[i].dataType == TypeString)
delete settingsValues[i].strValue;
}
@ -80,7 +80,7 @@ bool CSettings::Load() {
std::string strBuffer;
strBuffer.resize(file.size());
file.read((u8 *) &strBuffer[0], strBuffer.size());
file.read((uint8_t *) &strBuffer[0], strBuffer.size());
file.close();
@ -100,7 +100,7 @@ bool CSettings::Load() {
if(lines.empty() || !ValidVersion(lines[0]))
return false;
for(u32 i = 0; i < lines.size(); ++i) {
for(uint32_t i = 0; i < lines.size(); ++i) {
std::vector<std::string> valueSplit = StringTools::stringSplit(lines[i], "=");
if(valueSplit.size() != 2)
continue;
@ -111,7 +111,7 @@ bool CSettings::Load() {
while((valueSplit[1].size() > 0) && valueSplit[1][ valueSplit[1].size() - 1 ] == ' ')
valueSplit[1].resize(valueSplit[1].size() - 1);
for(u32 n = 0; n < settingsNames.size(); n++) {
for(uint32_t n = 0; n < settingsNames.size(); n++) {
if(!settingsNames[n])
continue;
@ -158,7 +158,7 @@ bool CSettings::Load() {
}
bool CSettings::ValidVersion(const std::string & versionString) {
int version = 0;
int32_t version = 0;
if(versionString.find(VERSION_LINE) != 0)
return false;
@ -193,7 +193,7 @@ bool CSettings::Save() {
file.fwrite("%s%i\n", VERSION_LINE, VALID_VERSION);
for(u32 i = 0; i < settingsValues.size(); i++) {
for(uint32_t i = 0; i < settingsValues.size(); i++) {
switch(settingsValues[i].dataType) {
case TypeBool:
file.fwrite("%s=%i\n", settingsNames[i], settingsValues[i].bValue);

View File

@ -70,117 +70,117 @@ public:
MAX_VALUE
};
static const u8 & getDataType(int idx) {
static const uint8_t & getDataType(int32_t idx) {
if(idx > INVALID && idx < MAX_VALUE)
return instance()->settingsValues[idx].dataType;
return instance()->nullValue.dataType;
}
static const bool & getValueAsBool(int idx) {
static const bool & getValueAsBool(int32_t idx) {
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeBool)
return instance()->settingsValues[idx].bValue;
return instance()->nullValue.bValue;
}
static const s8 & getValueAsS8(int idx) {
static const int8_t & getValueAsS8(int32_t idx) {
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeS8)
return instance()->settingsValues[idx].cValue;
return instance()->nullValue.cValue;
}
static const u8 & getValueAsU8(int idx) {
static const uint8_t & getValueAsU8(int32_t idx) {
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeU8)
return instance()->settingsValues[idx].ucValue;
return instance()->nullValue.ucValue;
}
static const s16 & getValueAsS16(int idx) {
static const int16_t & getValueAsS16(int32_t idx) {
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeS16)
return instance()->settingsValues[idx].sValue;
return instance()->nullValue.sValue;
}
static const u16 & getValueAsU16(int idx) {
static const uint16_t & getValueAsU16(int32_t idx) {
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeU16)
return instance()->settingsValues[idx].usValue;
return instance()->nullValue.usValue;
}
static const s32 & getValueAsS32(int idx) {
static const int32_t & getValueAsS32(int32_t idx) {
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeS32)
return instance()->settingsValues[idx].iValue;
return instance()->nullValue.iValue;
}
static const u32 & getValueAsU32(int idx) {
static const uint32_t & getValueAsU32(int32_t idx) {
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeU32)
return instance()->settingsValues[idx].uiValue;
return instance()->nullValue.uiValue;
}
static const f32 & getValueAsF32(int idx) {
static const float & getValueAsF32(int32_t idx) {
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeF32)
return instance()->settingsValues[idx].fValue;
return instance()->nullValue.fValue;
}
static const std::string & getValueAsString(int idx) {
static const std::string & getValueAsString(int32_t idx) {
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeString && instance()->settingsValues[idx].strValue)
return *(instance()->settingsValues[idx].strValue);
return *(instance()->nullValue.strValue);
}
static void setValueAsBool(int idx, const bool & val) {
static void setValueAsBool(int32_t idx, const bool & val) {
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeBool) {
instance()->settingsValues[idx].bValue = val;
instance()->bChanged = true;
}
}
static void setValueAsS8(int idx, const s8 & val) {
static void setValueAsS8(int32_t idx, const int8_t & val) {
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeS8) {
instance()->settingsValues[idx].cValue = val;
instance()->bChanged = true;
}
}
static void setValueAsU8(int idx, const u8 & val) {
static void setValueAsU8(int32_t idx, const uint8_t & val) {
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeU8) {
instance()->settingsValues[idx].ucValue = val;
instance()->bChanged = true;
}
}
static void setValueAsS16(int idx, const s16 & val) {
static void setValueAsS16(int32_t idx, const int16_t & val) {
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeS16) {
instance()->settingsValues[idx].sValue = val;
instance()->bChanged = true;
}
}
static void setValueAsU16(int idx, const u16 & val) {
static void setValueAsU16(int32_t idx, const uint16_t & val) {
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeU16) {
instance()->settingsValues[idx].usValue = val;
instance()->bChanged = true;
}
}
static void setValueAsS32(int idx, const s32 & val) {
static void setValueAsS32(int32_t idx, const int32_t & val) {
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeS32) {
instance()->settingsValues[idx].iValue = val;
instance()->bChanged = true;
}
}
static void setValueAsU32(int idx, const u32 & val) {
static void setValueAsU32(int32_t idx, const uint32_t & val) {
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeU32) {
instance()->settingsValues[idx].uiValue = val;
instance()->bChanged = true;
}
}
static void setValueAsF32(int idx, const f32 & val) {
static void setValueAsF32(int32_t idx, const float & val) {
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeF32) {
instance()->settingsValues[idx].fValue = val;
instance()->bChanged = true;
}
}
static void setValueAsString(int idx, const std::string & val) {
static void setValueAsString(int32_t idx, const std::string & val) {
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeString && instance()->settingsValues[idx].strValue) {
*(instance()->settingsValues[idx].strValue) = val;
instance()->bChanged = true;
@ -197,17 +197,17 @@ protected:
static CSettings *settingsInstance;
typedef struct {
u8 dataType;
uint8_t dataType;
union {
bool bValue;
s8 cValue;
u8 ucValue;
s16 sValue;
u16 usValue;
s32 iValue;
u32 uiValue;
f32 fValue;
int8_t cValue;
uint8_t ucValue;
int16_t sValue;
uint16_t usValue;
int32_t iValue;
uint32_t uiValue;
float fValue;
std::string *strValue;
};
} SettingValue;

View File

@ -20,15 +20,15 @@
#define __SETTINGS_DEFS_
typedef struct {
int value;
int32_t value;
const char *name;
} ValueString;
typedef struct {
const char *name;
const ValueString *valueStrings;
int type;
int index;
int32_t type;
int32_t index;
} SettingType;
#endif // __SETTINGS_DEFS_

View File

@ -19,15 +19,15 @@ void CallHook(wups_loader_hook_type_t hook_type) {
CallHookEx(hook_type,-1);
}
void CallHookEx(wups_loader_hook_type_t hook_type, s32 plugin_index_needed) {
for(int plugin_index=0; plugin_index<gbl_replacement_data.number_used_plugins; plugin_index++) {
void CallHookEx(wups_loader_hook_type_t hook_type, int32_t plugin_index_needed) {
for(int32_t plugin_index=0; plugin_index<gbl_replacement_data.number_used_plugins; plugin_index++) {
replacement_data_plugin_t * plugin_data = &gbl_replacement_data.plugin_data[plugin_index];
if(plugin_index_needed != -1 && plugin_index_needed != plugin_index) {
continue;
}
//DEBUG_FUNCTION_LINE("Checking hook functions for %s.\n",plugin_data->plugin_name);
//DEBUG_FUNCTION_LINE("Found hooks: %d\n",plugin_data->number_used_hooks);
for(int j=0; j<plugin_data->number_used_hooks; j++) {
for(int32_t j=0; j<plugin_data->number_used_hooks; j++) {
replacement_data_hook_t * hook_data = &plugin_data->hooks[j];
if(hook_data->type == hook_type) {
DEBUG_FUNCTION_LINE("Calling hook of type %d for plugin %s\n",hook_data->type,plugin_data->plugin_name);
@ -50,16 +50,16 @@ void CallHookEx(wups_loader_hook_type_t hook_type, s32 plugin_index_needed) {
args.readdir_repl = (const void*)&readdir;
args.mkdir_repl = (const void*)&mkdir;
((void (*)(wups_loader_init_fs_args_t))((unsigned int*)func_ptr) )(args);
((void (*)(wups_loader_init_fs_args_t))((uint32_t*)func_ptr) )(args);
} else if(hook_type == WUPS_LOADER_HOOK_INIT_OVERLAY) {
wups_loader_init_overlay_args_t args;
args.overlayfunction_ptr = (const void*)&overlay_helper;
((void (*)(wups_loader_init_overlay_args_t))((unsigned int*)func_ptr) )(args);
((void (*)(wups_loader_init_overlay_args_t))((uint32_t*)func_ptr) )(args);
} else if(hook_type == WUPS_LOADER_HOOK_INIT_PLUGIN) {
((void (*)(void))((unsigned int*)func_ptr) )();
((void (*)(void))((uint32_t*)func_ptr) )();
} else if(hook_type == WUPS_LOADER_HOOK_DEINIT_PLUGIN) {
((void (*)(void))((unsigned int*)func_ptr) )();
((void (*)(void))((uint32_t*)func_ptr) )();
} else if(hook_type == WUPS_LOADER_HOOK_STARTING_APPLICATION) {
wups_loader_app_started_args_t args;
memset(&args,0,sizeof(args));
@ -69,13 +69,13 @@ void CallHookEx(wups_loader_hook_type_t hook_type, s32 plugin_index_needed) {
if(gSDInitDone & WUPS_USB_MOUNTED) {
args.usb_mounted = true;
}
((void (*)(wups_loader_app_started_args_t))((unsigned int*)func_ptr) )(args);
((void (*)(wups_loader_app_started_args_t))((uint32_t*)func_ptr) )(args);
} else if(hook_type == WUPS_LOADER_HOOK_FUNCTIONS_PATCHED) {
((void (*)(void))((unsigned int*)func_ptr))();
((void (*)(void))((uint32_t*)func_ptr))();
} else if(hook_type == WUPS_LOADER_HOOK_ENDING_APPLICATION) {
((void (*)(void))((unsigned int*)func_ptr))();
((void (*)(void))((uint32_t*)func_ptr))();
} else if(hook_type == WUPS_LOADER_HOOK_VSYNC) {
((void (*)(void))((unsigned int*)func_ptr))();
((void (*)(void))((uint32_t*)func_ptr))();
} else if(hook_type == WUPS_LOADER_HOOK_APP_STATUS_CHANGED) {
wups_loader_app_status_t status;
if(gAppStatus == 0) {
@ -87,7 +87,7 @@ void CallHookEx(wups_loader_hook_type_t hook_type, s32 plugin_index_needed) {
} else {
status = WUPS_APP_STATUS_UNKNOWN;
}
((void (*)(wups_loader_app_status_t))((unsigned int*)func_ptr))(status);
((void (*)(wups_loader_app_status_t))((uint32_t*)func_ptr))(status);
} else {
DEBUG_FUNCTION_LINE("ERROR: HOOK TYPE WAS NOT IMPLEMENTED %08X \n",hook_type);
}

View File

@ -11,7 +11,7 @@ extern "C" {
void CallHook(wups_loader_hook_type_t hook_type);
void CallHookEx(wups_loader_hook_type_t hook_type, s32 plugin_index_needed);
void CallHookEx(wups_loader_hook_type_t hook_type, int32_t plugin_index_needed);
#ifdef __cplusplus
}