-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f35d492
Showing
6 changed files
with
869 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
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(vitastick) | ||
|
||
set(CMAKE_C_FLAGS "-Wl,-q -Wall -O2") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -fno-rtti -fno-exceptions") | ||
|
||
option(RELEASE "Release build" OFF) | ||
|
||
if (RELEASE) | ||
add_definitions(-DRELEASE) | ||
endif(RELEASE) | ||
|
||
link_directories( | ||
${CMAKE_BINARY_DIR} | ||
) | ||
|
||
set(SOURCES | ||
main.c | ||
log.c | ||
) | ||
|
||
add_executable(${PROJECT_NAME}.elf | ||
${SOURCES} | ||
) | ||
|
||
target_link_libraries(${PROJECT_NAME}.elf | ||
SceSysclibForDriver_stub | ||
SceThreadmgrForDriver_stub | ||
SceCpuForDriver_stub | ||
SceCtrlForDriver_stub | ||
SceUdcdForDriver_stub | ||
SceIofilemgrForDriver_stub | ||
) | ||
|
||
set_target_properties(${PROJECT_NAME}.elf | ||
PROPERTIES LINK_FLAGS "-nostdlib" | ||
COMPILE_FLAGS "-D__VITA_KERNEL__" | ||
) | ||
|
||
add_custom_command(OUTPUT ${PROJECT_NAME}.velf | ||
COMMAND vita-elf-create -e ${CMAKE_SOURCE_DIR}/${PROJECT_NAME}.yml ${PROJECT_NAME}.elf ${PROJECT_NAME}.velf | ||
DEPENDS ${PROJECT_NAME}.elf | ||
) | ||
|
||
add_custom_command(OUTPUT ${PROJECT_NAME}.skprx | ||
COMMAND vita-make-fself ${PROJECT_NAME}.velf ${PROJECT_NAME}.skprx | ||
DEPENDS ${PROJECT_NAME}.velf | ||
) | ||
|
||
add_custom_target(skprx | ||
DEPENDS ${PROJECT_NAME}.skprx | ||
) | ||
|
||
add_custom_target(send | ||
COMMAND curl -T ${PROJECT_NAME}.skprx ftp://$(PSVITAIP):1337/ux0:/data/tai/kplugin.skprx | ||
DEPENDS ${PROJECT_NAME}.skprx | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "vitastick.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.