Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
xerpi committed Jan 3, 2017
0 parents commit cc5fc34
Show file tree
Hide file tree
Showing 5 changed files with 746 additions and 0 deletions.
56 changes: 56 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
cmake_minimum_required(VERSION 2.8)

set(CMAKE_SYSTEM_NAME "Generic")
set(CMAKE_C_COMPILER "arm-vita-eabi-gcc")
set(CMAKE_CXX_COMPILER "arm-vita-eabi-g++")

project(ds3vita)

set(CMAKE_C_FLAGS "-Wl,-q -Wall -O3 -std=gnu99")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -fno-rtti -fno-exceptions")

include_directories(
)

link_directories(
${CMAKE_CURRENT_BINARY_DIR}
)

if (${RELEASE} EQUAL 1)
add_definitions(-DRELEASE)
endif()

add_executable(${PROJECT_NAME}.elf
main.c
log.c
)

target_link_libraries(${PROJECT_NAME}.elf
gcc
taihenForKernel_stub
SceSysclibForDriver_stub
SceSysmemForDriver_stub
SceSysmemForKernel_stub
SceThreadmgrForKernel_stub
SceThreadmgrForDriver_stub
SceIofilemgrForDriver_stub
SceBtForDriver_stub
SceKernelSuspendForDriver_stub
SceCtrlForDriver_stub
)

set_target_properties(${PROJECT_NAME}.elf
PROPERTIES LINK_FLAGS "-nostdlib"
COMPILE_FLAGS "-D__VITA_KERNEL__"
)

add_custom_target(${PROJECT_NAME}.skprx ALL
COMMAND vita-elf-create -e ${CMAKE_SOURCE_DIR}/${PROJECT_NAME}.yml ${PROJECT_NAME}.elf ${PROJECT_NAME}.velf
COMMAND vita-make-fself ${PROJECT_NAME}.velf ${PROJECT_NAME}.skprx
)
add_dependencies(${PROJECT_NAME}.skprx ${PROJECT_NAME}.elf)

add_custom_target(send
COMMAND curl -T ${PROJECT_NAME}.skprx ftp://$(PSVITAIP):1337/ux0:/data/tai/kplugin.skprx
DEPENDS ${PROJECT_NAME}.skprx
)
8 changes: 8 additions & 0 deletions ds3vita.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ds3vita:
attributes: 0
version:
major: 1
minor: 1
main:
start: module_start
stop: module_stop
50 changes: 50 additions & 0 deletions log.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include "log.h"
#include <psp2kern/io/fcntl.h>

extern int ksceIoMkdir(const char *, int);

#ifndef RELEASE
static unsigned int log_buf_ptr = 0;
static char log_buf[16 * 1024];
#endif

void log_reset()
{
#ifndef RELEASE
SceUID fd = ksceIoOpen(LOG_FILE,
SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 6);
if (fd < 0)
return;

ksceIoClose(fd);

memset(log_buf, 0, sizeof(log_buf));
#endif
}

void log_write(const char *buffer, size_t length)
{
#ifndef RELEASE
if ((log_buf_ptr + length) >= sizeof(log_buf))
return;

memcpy(log_buf + log_buf_ptr, buffer, length);

log_buf_ptr = log_buf_ptr + length;
#endif
}

void log_flush()
{
#ifndef RELEASE
ksceIoMkdir(LOG_PATH, 6);

SceUID fd = ksceIoOpen(LOG_FILE,
SCE_O_WRONLY | SCE_O_CREAT | SCE_O_APPEND, 6);
if (fd < 0)
return;

ksceIoWrite(fd, log_buf, strlen(log_buf));
ksceIoClose(fd);
#endif
}
31 changes: 31 additions & 0 deletions log.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef LOG_H
#define LOG_H

#include <stdio.h>
#include <string.h>

#define LOG_PATH "ux0:dump/"
#define LOG_FILE LOG_PATH "ds3vita_log.txt"

void log_reset();
void log_write(const char *buffer, size_t length);
void log_flush();

#ifndef RELEASE
# define LOG(...) \
do { \
char buffer[256]; \
snprintf(buffer, sizeof(buffer), ##__VA_ARGS__); \
log_write(buffer, strlen(buffer)); \
} while (0)
#else
# define LOG(...) (void)0
#endif

#define TEST_CALL(f, ...) ({ \
int ret = f(__VA_ARGS__); \
LOG(# f " returned 0x%08X\n", ret); \
ret; \
})

#endif
Loading

1 comment on commit cc5fc34

@littlezed
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear xerpi, can you make L2 R2 to be vol- and vol+ ? And also, I need LED to be fixed. Thank you a lot xerpi! You made my dreams come true!

Please sign in to comment.