Permalink
Browse files

First commit

  • Loading branch information...
0 parents commit cc5fc348809ed6936e44bdcca5d51065f5e09ca8 @xerpi committed Jan 3, 2017
Showing with 746 additions and 0 deletions.
  1. +56 −0 CMakeLists.txt
  2. +8 −0 ds3vita.yml
  3. +50 −0 log.c
  4. +31 −0 log.h
  5. +601 −0 main.c
@@ -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
+)
@@ -0,0 +1,8 @@
+ds3vita:
+ attributes: 0
+ version:
+ major: 1
+ minor: 1
+ main:
+ start: module_start
+ stop: module_stop
@@ -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
+}
@@ -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
Oops, something went wrong.

0 comments on commit cc5fc34

Please sign in to comment.