Some changes

This commit is contained in:
TheFloW 2016-01-26 20:34:06 +01:00
parent d49254aa2d
commit 6c43d353e1
8 changed files with 56 additions and 70 deletions

4
file.c
View File

@ -30,11 +30,13 @@ typedef struct {
static char *mount_points[] = {
"app0:",
"cache0:",
#ifdef USE_HOST0
HOST0,
#endif
"music0:",
"photo0:",
"sa0:",
"savedata0:",
// "savedata0:",
NULL,
NULL,

9
hex.c
View File

@ -67,10 +67,6 @@ HexListEntry *hexListGetNthEntry(HexList *list, int n) {
return entry;
}
/*
Page skip
*/
int hexViewer(char *file) {
int text_viewer = 0;
@ -167,7 +163,8 @@ int hexViewer(char *file) {
}
}
}
/*
TODO: page skip
if (hold_buttons & SCE_CTRL_LTRIGGER) {
if ((base_pos + rel_pos) != 0) {
if ((base_pos - 0x10 * 0x10) >= 0) {
@ -214,7 +211,7 @@ int hexViewer(char *file) {
}
}
}
*/
uint8_t max_nibble = (2 * 0x10) - 1;
// Last line

View File

@ -17,6 +17,7 @@
*/
#include "main.h"
#include "io_wrapper.h"
#include "init.h"
#include "homebrew.h"
#include "file.h"
@ -278,12 +279,9 @@ void signalDeleteSema() {
int i;
for (i = 0; i < MAX_UIDS; i++) {
if (hb_semaids[i] >= 0) {
int res = sceKernelSignalSema(hb_semaids[i], 1);
debugPrintf("Signal sema 0x%08X: 0x%08X\n", hb_semaids[i], res);
sceKernelSignalSema(hb_semaids[i], 1);
res = sceKernelDeleteSema(hb_semaids[i]);
debugPrintf("Delete sema 0x%08X: 0x%08X\n", hb_semaids[i], res);
if (res >= 0)
if (sceKernelDeleteSema(hb_semaids[i]) >= 0)
hb_semaids[i] = INVALID_UID;
}
}
@ -293,12 +291,9 @@ void unlockDeleteMutex() {
int i;
for (i = 0; i < MAX_UIDS; i++) {
if (hb_mutexids[i] >= 0) {
int res = sceKernelUnlockMutex(hb_mutexids[i], 1);
debugPrintf("Unlock mutex 0x%08X: 0x%08X\n", hb_mutexids[i], res);
sceKernelUnlockMutex(hb_mutexids[i], 1);
res = sceKernelDeleteMutex(hb_mutexids[i]);
debugPrintf("Delete mutex 0x%08X: 0x%08X\n", hb_mutexids[i], res);
if (res >= 0)
if (sceKernelDeleteMutex(hb_mutexids[i]) >= 0)
hb_mutexids[i] = INVALID_UID;
}
}
@ -308,9 +303,7 @@ void deleteLwMutex() {
int i;
for (i = 0; i < MAX_LW_MUTEXES; i++) {
if (hb_lw_mutex_works[i]) {
int res = sceKernelDeleteLwMutex(hb_lw_mutex_works[i]);
debugPrintf("Delete lw mutex 0x%08X: 0x%08X\n", hb_lw_mutex_works[i], res);
if (res >= 0)
if (sceKernelDeleteLwMutex(hb_lw_mutex_works[i]) >= 0)
hb_lw_mutex_works[i] = NULL;
}
}
@ -320,8 +313,7 @@ void closeSockets() {
int i;
for (i = 0; i < MAX_UIDS; i++) {
if (hb_sockids[i] >= 0) {
int res = sceNetSocketClose(hb_sockids[i]);
if (res >= 0)
if (sceNetSocketClose(hb_sockids[i]) >= 0)
hb_sockids[i] = INVALID_UID;
}
}
@ -331,23 +323,18 @@ void waitThreadEnd() {
int i;
for (i = 0; i < MAX_UIDS; i++) {
if (hb_thids[i] >= 0) {
//debugPrintf("Wait for 0x%08X\n", hb_thids[i]);
int res = sceKernelWaitThreadEnd(hb_thids[i], NULL, NULL);
if (res >= 0)
if (sceKernelWaitThreadEnd(hb_thids[i], NULL, NULL) >= 0)
hb_thids[i] = INVALID_UID;
}
}
}
int exitThread() {
debugPrintf("Exiting 0x%08X...\n", sceKernelGetThreadId());
signalDeleteSema();
unlockDeleteMutex();
deleteLwMutex();
closeSockets();
debugPrintf("Wait for threads...\n");
waitThreadEnd();
sceKernelDelayThread(50 * 1000);
@ -406,7 +393,6 @@ int exit_thread(SceSize args, void *argp) {
}
int sceKernelExitProcessPatchedHB(int res) {
// debugPrintf("%s\n", __FUNCTION__);
return 0;
}
@ -522,8 +508,6 @@ int sceKernelExitDeleteThreadPatchedHB(int status) {
SceUID sceKernelCreateThreadPatchedHB(const char *name, SceKernelThreadEntry entry, int initPriority, int stackSize, SceUInt attr, int cpuAffinityMask, const SceKernelThreadOptParam *option) {
SceUID thid = sceKernelCreateThread(name, entry, initPriority, stackSize, attr, cpuAffinityMask, option);
debugPrintf("%s %s 0x%08X: 0x%08X\n", __FUNCTION__, name, stackSize, thid);
if (thid >= 0)
INSERT_UID(hb_thids, thid);
@ -533,10 +517,6 @@ SceUID sceKernelCreateThreadPatchedHB(const char *name, SceKernelThreadEntry ent
SceUID sceKernelAllocMemBlockPatchedHB(const char *name, SceKernelMemBlockType type, int size, void *optp) {
SceUID blockid = sceKernelAllocMemBlock(name, type, size, optp);
void *mem = NULL;
sceKernelGetMemBlockBase(blockid, &mem);
debugPrintf("%s %s 0x%08X 0x%08X: 0x%08X, 0x%08X\n", __FUNCTION__, name, type, size, blockid, mem);
if (blockid >= 0)
INSERT_UID(hb_blockids, blockid);
@ -731,10 +711,6 @@ int sceKernelWaitThreadEndPatchedUVL(SceUID thid, int *stat, SceUInt *timeout) {
SceUID sceKernelAllocMemBlockPatchedUVL(const char *name, SceKernelMemBlockType type, int size, void *optp) {
SceUID blockid = sceKernelAllocMemBlock(name, type, size, optp);
void *mem = NULL;
sceKernelGetMemBlockBase(blockid, &mem);
debugPrintf("%s %s 0x%08X 0x%08X: 0x%08X, 0x%08X\n", __FUNCTION__, name, type, size, blockid, mem);
// UVLTemp buffer contains the elf data, get its blockid
if (strcmp(name, "UVLTemp") == 0) {
UVLTemp_id = blockid;
@ -744,8 +720,6 @@ SceUID sceKernelAllocMemBlockPatchedUVL(const char *name, SceKernelMemBlockType
}
SceUID sceKernelFindMemBlockByAddrPatchedUVL(const void *addr, SceSize size) {
debugPrintf("%s 0x%08X 0x%08X\n", __FUNCTION__, addr, size);
// uvl_alloc_code_mem is patched to always return NULL
if (addr == NULL) {
// Now it is the moment we need to know the SceModuleInfo of this elf
@ -763,8 +737,6 @@ SceUID sceKernelFindMemBlockByAddrPatchedUVL(const void *addr, SceSize size) {
return code_blockid;
}
debugPrintf("VitaShell reloading...\n");
// Free newlib
_free_vita_newlib();
@ -792,8 +764,6 @@ SceUID sceKernelFindMemBlockByAddrPatchedUVL(const void *addr, SceSize size) {
}
int sceKernelFreeMemBlockPatchedUVL(SceUID uid) {
debugPrintf("%s 0x%08X\n", __FUNCTION__, uid);
// Never free the code memory
if (uid == code_blockid) {
return 0;

View File

@ -20,6 +20,8 @@
#include "file.h"
#include "psp2link/psp2link.h"
#ifdef USE_HOST0
int verifyFd(SceUID fd) {
SceIoStat stat;
return sceIoGetstatByFd(fd, &stat);
@ -34,116 +36,130 @@ void tempFixForPsp2Link(char *path, const char *file) {
}
}
#endif
int fileIoOpen(const char *file, int flags, SceMode mode) {
#ifdef USE_HOST0
if (strncmp(file, HOST0, sizeof(HOST0) - 1) == 0) {
char path[MAX_PATH_LENGTH];
tempFixForPsp2Link(path, file);
return psp2LinkIoOpen(path, flags, mode);
}
#endif
return sceIoOpen(file, flags, mode);
}
int fileIoClose(SceUID fd) {
#ifdef USE_HOST0
int res = verifyFd(fd);
if (res < 0) {
return psp2LinkIoClose(fd);
}
#endif
return sceIoClose(fd);
}
int fileIoRead(SceUID fd, void *data, SceSize size) {
#ifdef USE_HOST0
int res = verifyFd(fd);
if (res < 0) {
return psp2LinkIoRead(fd, data, size);
}
#endif
return sceIoRead(fd, data, size);
}
int fileIoWrite(SceUID fd, const void *data, SceSize size) {
#ifdef USE_HOST0
int res = verifyFd(fd);
if (res < 0) {
return psp2LinkIoWrite(fd, data, size);
}
#endif
return sceIoWrite(fd, data, size);
}
SceOff fileIoLseek(SceUID fd, SceOff offset, int whence) {
#ifdef USE_HOST0
int res = verifyFd(fd);
if (res < 0) {
return (SceOff)psp2LinkIoLseek(fd, offset, whence);
}
#endif
return sceIoLseek(fd, offset, whence);
}
int fileIoRemove(const char *file) {
#ifdef USE_HOST0
if (strncmp(file, HOST0, sizeof(HOST0) - 1) == 0) {
char path[MAX_PATH_LENGTH];
tempFixForPsp2Link(path, file);
return psp2LinkIoRemove(path);
}
#endif
return sceIoRemove(file);
}
int fileIoMkdir(const char *dirname, SceMode mode) {
#ifdef USE_HOST0
if (strncmp(dirname, HOST0, sizeof(HOST0) - 1) == 0) {
char path[MAX_PATH_LENGTH];
tempFixForPsp2Link(path, dirname);
return psp2LinkIoMkdir(path, mode);
}
#endif
return sceIoMkdir(dirname, mode);
}
int fileIoRmdir(const char *dirname) {
#ifdef USE_HOST0
if (strncmp(dirname, HOST0, sizeof(HOST0) - 1) == 0) {
char path[MAX_PATH_LENGTH];
tempFixForPsp2Link(path, dirname);
return psp2LinkIoRmdir(path);
}
#endif
return sceIoRmdir(dirname);
}
int fileIoRename(const char *oldname, const char *newname) {
#ifdef USE_HOST0
if (strncmp(oldname, HOST0, sizeof(HOST0) - 1) == 0) {
// return psp2LinkRename(oldname, newname);
return 0;
}
#endif
return sceIoRename(oldname, newname);
}
int fileIoDopen(const char *dirname) {
#ifdef USE_HOST0
if (strncmp(dirname, HOST0, sizeof(HOST0) - 1) == 0) {
char path[MAX_PATH_LENGTH];
tempFixForPsp2Link(path, dirname);
return psp2LinkIoDopen(path);
}
#endif
return sceIoDopen(dirname);
}
int fileIoDread(SceUID fd, SceIoDirent *dir) {
#ifdef USE_HOST0
int res = verifyFd(fd);
if (res < 0) {
return psp2LinkIoDread(fd, dir);
}
#endif
return sceIoDread(fd, dir);
}
int fileIoDclose(SceUID fd) {
#ifdef USE_HOST0
int res = verifyFd(fd);
if (res < 0) {
return psp2LinkIoDclose(fd);
}
#endif
return sceIoDclose(fd);
}

19
main.c
View File

@ -18,9 +18,9 @@
/*
TODO:
- Add shader compiler feature
- NEARLY DONE: Terminate thread / free stack of previous VitaShell when reloading
- Redirecting .data segment when reloading
- Nethost. Patch UVL to be able to launch from host0
- Page skip for hex and text viewer
- Add UTF8/UTF16 to vita2dlib's pgf
- Maybe switch to libarchive
@ -907,11 +907,11 @@ void fileBrowserMenuCtrl() {
dialog_step = DIALOG_STEP_SYSTEM;
}
*/
/*
if (pressed_buttons & SCE_CTRL_LTRIGGER) {
listMemBlocks(0x60000000, 0xD0000000);
}
*/
if (pressed_buttons & SCE_CTRL_SELECT) {
if (!ftpvita_is_initialized()) {
int res = ftpvita_init(vita_ip, &vita_port);
@ -995,15 +995,14 @@ void fileBrowserMenuCtrl() {
if (strcmp(file_entry->name, DIR_UP) == 0) {
dirUp();
} else if (strcmp(file_entry->name, HOST0) == 0) {
int ret=psp2LinkInit("192.168.178.20",0x4711,0x4712,0x4712,3);
if(!ret)
{
#ifdef USE_HOST0
int res = psp2LinkInit("192.168.178.20", 0x4711, 0x4712, 0x4712, 3);
if (!res) {
psp2LinkFinish();
return;
}
while(!psp2LinkRequestsIsConnected())
{
while (!psp2LinkRequestsIsConnected()) {
sceKernelDelayThread(1 * 1000 * 1000);
}
@ -1012,6 +1011,7 @@ void fileBrowserMenuCtrl() {
fileIoGetstat(file_entry->name, &mount_point_stat);
dirLevelUp();
#endif
} else {
if (dir_level == 0) {
strcpy(cur_path, file_entry->name);
@ -1294,8 +1294,7 @@ int main(int argc, const char *argv[]) {
// Free previous data
if (shared_memory->data_blockid >= 0) {
int res = sceKernelFreeMemBlock(shared_memory->data_blockid);
debugPrintf("sceKernelFreeMemBlock: 0x%08X\n", res);
sceKernelFreeMemBlock(shared_memory->data_blockid);
}
// Init code memory

1
main.h
View File

@ -62,6 +62,7 @@
#include "functions.h"
//#define RELEASE 1
#define USE_HOST0 1
#define VITASHELL_VERSION_MAJOR 0
#define VITASHELL_VERSION_MINOR 5

View File

@ -17,6 +17,7 @@
*/
#include "../main.h"
#include "../io_wrapper.h"
#include "pboot.h"
#include "../elf_types.h"

View File

@ -177,15 +177,15 @@ void getSizeString(char *string, uint64_t size) {
void getDateString(char *string, int date_format, SceRtcTime *time) {
switch (date_format) {
case SCE_SYSTEM_PARAM_DATE_FORMAT_YYYYMMDD:
sprintf(string, "%02d/%02d/%02d", time->year, time->month, time->day);
sprintf(string, "%04d/%02d/%02d", time->year, time->month, time->day);
break;
case SCE_SYSTEM_PARAM_DATE_FORMAT_DDMMYYYY:
sprintf(string, "%02d/%02d/%02d", time->day, time->month, time->year);
sprintf(string, "%02d/%02d/%04d", time->day, time->month, time->year);
break;
case SCE_SYSTEM_PARAM_DATE_FORMAT_MMDDYYYY:
sprintf(string, "%02d/%02d/%02d", time->month, time->day, time->year);
sprintf(string, "%02d/%02d/%04d", time->month, time->day, time->year);
break;
}
}