fixed random hang due to inline assembly

This commit is contained in:
dimok789 2016-10-27 17:48:19 +02:00
parent e33c9894f1
commit 1602ad7f7d
5 changed files with 13 additions and 8 deletions

View File

@ -20,6 +20,7 @@
#include "fs/DirList.h"
#include "fs/fs_utils.h"
#include "utils/HomebrewXML.h"
#include "utils/utils.h"
#include "Application.h"
HomebrewLaunchWindow::HomebrewLaunchWindow(const std::string & launchPath, GuiImageData * iconImgData)
@ -166,8 +167,7 @@ void HomebrewLaunchWindow::OnFileLoadFinish(GuiElement *element, const std::stri
if(result > 0)
{
u32 ApplicationMemoryEnd;
asm volatile("lis %0, __CODE_END@h; ori %0, %0, __CODE_END@l" : "=r" (ApplicationMemoryEnd));
u32 ApplicationMemoryEnd = getApplicationEndAddr();
ELF_DATA_ADDR = ApplicationMemoryEnd;
ELF_DATA_SIZE = result;
@ -181,8 +181,7 @@ void HomebrewLaunchWindow::OnLoadButtonClick(GuiButton *button, const GuiControl
backBtn.setState(GuiElement::STATE_DISABLED);
loadBtn.setState(GuiElement::STATE_DISABLED);
u32 ApplicationMemoryEnd;
asm volatile("lis %0, __CODE_END@h; ori %0, %0, __CODE_END@l" : "=r" (ApplicationMemoryEnd));
u32 ApplicationMemoryEnd = getApplicationEndAddr();
HomebrewLoader * loader = HomebrewLoader::loadToMemoryAsync(homebrewLaunchPath, (unsigned char*)ApplicationMemoryEnd);
loader->setEffect(EFFECT_FADE, 15, 255);

View File

@ -21,6 +21,7 @@
#include "fs/fs_utils.h"
#include "system/AsyncDeleter.h"
#include "utils/HomebrewXML.h"
#include "utils/utils.h"
#include "HomebrewLaunchWindow.h"
#define DEFAULT_WIILOAD_PORT 4299
@ -328,8 +329,7 @@ void HomebrewWindow::OnTcpReceiveFinish(GuiElement *element, u32 ip, int result)
if(result > 0)
{
u32 ApplicationMemoryEnd;
asm volatile("lis %0, __CODE_END@h; ori %0, %0, __CODE_END@l" : "=r" (ApplicationMemoryEnd));
u32 ApplicationMemoryEnd = getApplicationEndAddr();
ELF_DATA_ADDR = ApplicationMemoryEnd;
ELF_DATA_SIZE = result;

View File

@ -24,8 +24,7 @@ TcpReceiver::TcpReceiver(int port)
height = progressWindow.getHeight();
append(&progressWindow);
u32 ApplicationMemoryEnd;
asm volatile("lis %0, __CODE_END@h; ori %0, %0, __CODE_END@l" : "=r" (ApplicationMemoryEnd));
u32 ApplicationMemoryEnd = getApplicationEndAddr();
loadAddress = (unsigned char*)ApplicationMemoryEnd;
resumeThread();

5
src/utils/utils.S Normal file
View File

@ -0,0 +1,5 @@
.globl getApplicationEndAddr
getApplicationEndAddr:
lis r3, __CODE_END@h
ori r3, r3, __CODE_END@l
blr

View File

@ -40,6 +40,8 @@ extern "C" {
#define le32(i) ((((u32)le16((i) & 0xFFFF)) << 16) | ((u32)le16(((i) & 0xFFFF0000) >> 16)))
#define le64(i) ((((u64)le32((i) & 0xFFFFFFFFLL)) << 32) | ((u64)le32(((i) & 0xFFFFFFFF00000000LL) >> 32)))
unsigned int getApplicationEndAddr(void);
#ifdef __cplusplus
}
#endif