Giter VIP home page Giter VIP logo

ps4-sdk's Introduction

PS4 SDK

An open source PlayStation 4 SDK for writing userland applications which can be run with the PS4-playground.

Building and installing

You will need LLVM version 3.7 or later for compiling, and binutils for linking (from MinGW if you are on Windows).

Clone this repository locally, or download and extract a ZIP of the repository here.

Then create an environment variable called, PS4SDK which points to the base directory of the repository, using the Unix path style; for example:

/C/Users/Chris/Documents/GitHub/PS4-SDK

Build the libraries by running make on the libPS4 and libusbfatfs directories.

Finally, you can build examples by running make on them.

Design

At the moment, it is primarily focused on system calls.

However, using function pointers and the RESOLVE macro, we can call functions from other modules. For example, the socket functions from libSceNet.sprx.

Support

Whilst the SDK isn't capable of most basic functionality yet, such as displaying graphics, or receiving controller input, there are workarounds: rendering to an HTML5 canvas, and using third party USB controllers, or a DS/PSP wirelessly for example.

The SDK is currently in a state where projects like an FTP server, a mini Pong game, or GameBoy emulator could be developed.

Examples

hello - Load libc module and perform getpid system call

sockets - Send a message over a TCP socket

modules - Load and dump a module

threads - Create and wait for a thread to increment a variable

canvas - Render to an HTML5 canvas

camera - Initialise the PlayStation Camera and capture 10 frames

pad - Read controller input (not finished)

jit - Setting up JIT shared memory

Filesystem

directories - List the contents of a directory

files - Read a file's size, and its contents

USB

list_devices - List information about all USB devices connected

storage - Read raw image from a USB flash drive

usbfatfs - Read files from USB formatted with FAT

ps4-sdk's People

Contributors

bigboss-ps3dev avatar cturt avatar kr105 avatar masterzorag avatar maxton avatar patrickgill avatar psxdev avatar xerpi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ps4-sdk's Issues

Libc implementation warnings

Declaring standard C functions like memset as function pointers will give a warning:

../../include/libc.h:3:16: warning: built-in function 'memset' declared as non-function
extern void *(*memset)(void *destination, int value, size_t num);

Need to be able to suppress this warning.

Cannot use in c++ (clang++)

I'm getting following error when i try to compile using your sdk:

In file included from /home/seb5594/git/PS4-SDK//libPS4/include/ps4.h:11:
/home/seb5594/git/PS4-SDK//libPS4/include/network.h:56:78: error: expected ')'
extern int (*sceNetGetsockopt)(int s, int level, int optname, void *restrict optval, soc...
^
/home/seb5594/git/PS4-SDK//libPS4/include/network.h:56:31: note: to match this '('
extern int (*sceNetGetsockopt)(int s, int level, int optname, void *restrict optval, soc...
^
1 error generated.
Makefile:33: recipe for target 'build/main.o' failed
make: *** [build/main.o] Error 1

examples wont work with elfldr

getting "not enough memory available" error when using ps4-sdk examples with elfldr - while elfldr libps4 examples seem to work fine.

file.h

You have a ton of errors inside file.h

For example:

define O_CREAT 0x0100

This value is most certainly NOT correct. The correct value is 0x0200, I was pulling my hair out trying to figure out why I couldn't create a file, then checked the FreeBSD code and seen the value was 0x0200.

New syscall (raw) Macro does not generate proper PIC

If I compile any code with the newest SDK version (vanilla state), the following relocation error is issued:

clang -c -o build/main.o source/main.c -I/tmp/git/t/PS4-SDK/libPS4/include -I. -Iinclude -O2 -fPIC -ffreestanding -fno-builtin -Wall -masm=intel -target x86_64-scei-ps4-elf -m64 -mcmodel=large
ld.gold build/*.o -o hello.elf -L/tmp/git/t/PS4-SDK/libPS4 -L. -Llib -shared -fPIE -lPS4
ld.gold: error: /tmp/git/t/PS4-SDK/libPS4/libPS4.a(kernel.o): requires dynamic R_X86_64_PC32 reloc against 'rawSyscall' which may overflow at runtime; recompile with -fPIC
ld.gold: error: /tmp/git/t/PS4-SDK/libPS4/libPS4.a(module.o): requires dynamic R_X86_64_PC32 reloc against 'rawSyscall' which may overflow at runtime; recompile with -fPIC
Makefile:26: recipe for target 'hello.elf' failed
make: *** [hello.elf] Error 1

For an indication on the error: https://tecnocode.co.uk/2014/10/01/dynamic-relocs-runtime-overflows-and-fpic/ (though not exactly the same issue I suppose).
Basically, the way you inject the syscall isn't playing nice with generating PIC :) I think there are multiple ways to "fix" this one way or another.

I will look at it tomorrow if you don't want to invest time. I am getting frustrated with the loader, so its a more pressing issue to me right now >:(

wrong type in SceKernelEqueue

@kr105 typedef int SceKernelEqueue; has wrong type

If you try to call sceKernelDeleteEqueue with that type you will get 0x80020009 error.

SceKernelCreateEqueue call internally to syscall 362 (aka sys_kqueue) and then to syscall 557 (aka sys_namedobj_create) and then it will return in first call parameter from sceKernelCreateEqueue output from sys_kqueue plus/OR output from sys_namedobj_create left shifted 32 bits so SceKernelEqueue should be int64_t

You can check it with following code:

    SceKernelEqueue myqueue;
    int ret=sceKernelCreateEqueue(&myqueue,name);
    if(ret!=0)
    {
        debugNetPrintf(DEBUG,"Error creating event queue 0x%08X\n", ret);
        return -1;
    }
    else
    {
        debugNetPrintf(DEBUG,"Created event queue 0x%08X\n",queue);
    }
    ret=sceKernelDeleteEqueue(myqueue);
    if(ret!=0)
    {
        debugNetPrintf(DEBUG,"error sceKernelDeleteEqueue return: 0x%08X\n", ret);
    }
    else
    {
        debugNetPrintf(DEBUG,"sceKernelDeleteEqueue return: 0x%08X\n", ret);

    }

Pad input/output implemented?

@CTurt Is it possible to use this repo to receive the controllers directional input (analogue stick) whilst playing a game?

Any help is appreciated.

Thanks

Bugs in inline assembly for syscall

The inline assembly codes not in functions for syscall causes some problems.

The solution is quite a simple: Use __PIC__ macro or define syscall codes as functions.
Defining functions is the easiest way to solve the problem, but it may be a bit slower than using inline assembly code if the calling convention is different from the ordinary one.

Cannot compile under cygwin

The error is cannot perform PE operations on non PE output file when compiling examples.

Apparently it's a common issue on cygwin but i wasn't able to work around it yet.

Please pick a license

Please pick a license for your repo. Choosing a license allows others to easily and confidently know what they can and can not do with the things you've released.

I suggest choosing the ISC license. Here is a copy of the ISC license: https://gist.githubusercontent.com/eriknstr/84c5c986607f3e4245991480a40e2c45/raw/d998764c0e914964a380b74b28332ea0c7ca28e7/LICENSE, replace YYYY with the current year (2017), "John Doe" with your own name and [email protected] with your own e-mail address (keep the angle-brackets). Alternatively if you do not wish to include your e-mail you can just remove the placeholder e-mail and angle-brackets.

[not an issue] Amazing work!

Hi,

Sorry to create this bogus issue but I couldn't find another way to get in touch with you after reading your 3-part article series on getting root privileges on the PS4. I was part of the WebKit developer team on the PS4 until last year, so I was really impressed at your achievements, to be honest I didn't think it would ever be done, especially the root escalation part. I hope they have read your articles too and that lessons have been learned. Oh and I'm sure my former colleague who spent months writing and maintaining the out-of-process JIT compiler must hate you ๐Ÿ˜„ (I'll ask him next time I see him)
That said it was fun to read through it and follow you slowly digging through the various layers of what I've been working on everyday for a couple of years, it still all looks very familiar.

I'd love to share stories with you, but I prefer not doing this in the open so if you're interested feel free to send me an email at [email protected].
Thanks again for that extremely interesting read!

Regards,
kromain

Error: conflicting types for '__dev_t'

I attempted to run make in the libPS4 directory on Ubuntu 19.04, and got the following output:

gcc -c -o build/syscall.o source/syscall.c -Iinclude -O2 -std=c11 -fno-builtin  -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64-mabi=sysv -mcmodel=large
gcc -c -o build/semaphore.o source/semaphore.c -Iinclude -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
gcc -c -o build/jit.o source/jit.c -Iinclude -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
In file included from include/kernel.h:3,
                 from source/jit.c:1:
include/types.h:71:18: error: conflicting types for โ€˜__dev_tโ€™
 typedef uint32_t __dev_t;
                  ^~~~~~~
In file included from /usr/include/stdint.h:27,
                 from /usr/lib/gcc/x86_64-linux-gnu/8/include/stdint.h:9,
                 from include/types.h:3,
                 from include/kernel.h:3,
                 from source/jit.c:1:
/usr/include/x86_64-linux-gnu/bits/types.h:145:25: note: previous declaration of โ€˜__dev_tโ€™ was here
 __STD_TYPE __DEV_T_TYPE __dev_t; /* Type of device numbers.  */
                         ^~~~~~~
make: *** [Makefile:21: build/jit.o] Error 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.