Skip to content

Commit

Permalink
Merge pull request #78 from OpenOrbis/v0.5
Browse files Browse the repository at this point in the history
V0.5 Release Merge
  • Loading branch information
Cryptogenic committed Aug 8, 2020
2 parents af1619c + f35ffa4 commit 216a63c
Show file tree
Hide file tree
Showing 266 changed files with 41,300 additions and 503 deletions.
30 changes: 28 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
# Changelog



## Beta

**v0.5 - August 7th, 2020**

- The toolchain now includes stub/empty libc and libSceFios2 modules to avoid breaking non-homebrew games and applications!
- *Note: This change works in conjunction with Mira, meaning you'll want to update the version of Mira you're loading as well.*
- *Additional note: these modules can be found in /bin/data/modules/libc.prx and /bin/data/modules/libSceFios2.prx, and should be placed in `sce_module/` in your homebrew's package file.*
- SDL2 headers as well as a mini game sample have now been added (thanks znullptr for the original SDL port)!
- C++ threading (std::thread) support has been added!
- C++ locking / synchronization support has been added!
- Fixed a performance issue in create-eboot, giving it a 7858% performance boost (measured with the SDL sample)!
- Visual studio project templates now support and link with C++ by default.
- Added various macros and function definitions to libkernel, libScePad, libSceUserService, and libSceVideoOut, as well as documentation for these additions.
- Added right.prx by IDC to all samples (thanks IDC for right.prx).
- Slightly adjusted sample pkg gp4 files to use the same eboot.bin created by build scripts instead of unnecessarily using a copy.
- Fixed jagged text rendering in `/samples/_common/graphics.cpp` due to not factoring in the freetype greyscale bitmap alpha properly.
- Buffering is now disabled on stdout automatically due to it not handling buffering well.
- Updated pthread header to use PS4/BSD-specific values.
- Samples now have DWARF / debug symbols included by default (thanks sleirsgoevy).
- Reworked the threading sample to use std::thread and std::mutex now that C++ threading is supported.
- Reworked the networking sample to a TCP server instead of a TCP client.
- Fixed an issue where a really silly FreeBSD change broke any networking functions that need to use the sockaddr struct such as bind.
- Fixed an issue where GP4 project files were using non-portable windows-style path separators (thanks sleirsgoevy).
- Fixed an issue where the non-sce sleep() function didn't work due to a MUSL-related issues (thanks LM, ChendoChap).
- Fixed an issue where SPRX visual studio projects contained a typo in an include statement and an incorrect set of libraries for the build script.
- Fixed the cmath c++ header, which included `using` statements for functions that are macros on FreeBSD targets (thanks kiwidog).
- Fixed an issue where the `sockaddr_in` structure was incorrect due to a discrepancy between Linux and FreeBSD (thanks kiwidog).
- Fixed an issue where the pipe() function didn't work due to a discrepancy between Linux and FreeBSD (thanks sleirsgoevy).
- Fixed an issue where AF_INET6 was erroneously set to 10 due to a discrepancy between Linux and FreeBSD (thanks sleirsgoevy).

**v0.4 - June 23rd, 2020**

- Added C++ support via `include/c++/v1` headers and statically built libcxx.
Expand Down
42 changes: 17 additions & 25 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
# Contribution

Below is a list of issues that need some help. There are three lists; advanced issues, intermediate issues, and starter issues. Starter issues are issues that can be picked up and worked on without too much hassle or setup. Intermediate issues may require some digging. Advanced issues likely require a lot of work. Issues listed as "perpetual" are issues that don't have a clear stopping point
and will be worked on throughout the life of the toolchain.

## Starter Issues (4 perpetual)

Below is a list of issues that need some help. There are three lists; advanced issues, intermediate issues, and starter issues. Starter issues are issues that can be picked up and worked on without too much hassle or setup. Intermediate issues may require some digging. Advanced issues likely require a lot of work.
- [ ] (Perpetual) Add reversed type info for PS4 library function prototypes in `/include/orbis/*`
- [ ] (Perpetual) Submit issues for requested features
- [ ] (Perpetual) Find and submit bugs
- [ ] (Perpetual) Build some basic samples for functionality not covered by existing samples

## Intermediate Issues (1/3 remain)

- [x] Finished in v0.2: ~~Testing on `create-lib` to ensure exporting and what not works properly~~
- [x] Finished in v0.5: ~~SDL 2D sample~~
- [ ] Develop MiraLib bindings for other languages

## Starter Issues

- Add reversed type info for PS4 library function prototypes in `/include/orbis/*`
- Submit issues for requested features
- Build some basic samples for functionality not covered by existing samples



## Intermediate Issues

- Testing on `create-lib` to ensure exporting and what not works properly
- SDL 2D sample
- Develop MiraLib bindings for other languages



## Advanced Issues

- Build a standardized libc for PS4 for portability and eventually C++ support
- C++ support (see above)
- GPU 2D/3D rendering support
- DOOM port?

## Advanced Issues (3/5 remain)

- [x] Finished in v0.3: ~~Build a standardized libc for PS4 for portability and eventually C++ support~~
- [x] Finished in v0.4: ~~C++ support (see above)~~
- [ ] GPU 2D/3D rendering support
- [ ] DOOM port?
- [ ] Fix std::cout in libcxx

More issues will be added here as more are requested. If you think something should be here that isn't, feel free to file an issue!

14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OpenOrbis PS4 Toolchain

[![Release Mode](https://img.shields.io/badge/Release%20Mode-Beta-yellow.svg)](https://github.com/OpenOrbis/OpenOrbis-PS4-Toolchain) [![Version](https://img.shields.io/badge/Version-0.3-brightgreen.svg)](https://github.com/OpenOrbis/OpenOrbis-PS4-Toolchain) [![Version](https://img.shields.io/badge/license-GPL%20v3-blue)](https://github.com/OpenOrbis/OpenOrbis-PS4-Toolchain/blob/master/LICENSE)
[![Release Mode](https://img.shields.io/badge/Release%20Mode-Beta-yellow.svg)](https://github.com/OpenOrbis/OpenOrbis-PS4-Toolchain) [![Version](https://img.shields.io/badge/Version-0.5-brightgreen.svg)](https://github.com/OpenOrbis/OpenOrbis-PS4-Toolchain) [![Version](https://img.shields.io/badge/license-GPL%20v3-blue)](https://github.com/OpenOrbis/OpenOrbis-PS4-Toolchain/blob/master/LICENSE)

[![Generic badge](https://img.shields.io/badge/WINDOWS-RELEASE-GREEN.svg)](https://github.com/OpenOrbis/OpenOrbis-PS4-Toolchain/releases/latest) [![Generic badge](https://img.shields.io/badge/LINUX-RELEASE-GREEN.svg)](https://github.com/OpenOrbis/OpenOrbis-PS4-Toolchain/releases/latest) [![Generic badge](https://img.shields.io/badge/MacOS-RELEASE-GREEN.svg)](https://github.com/OpenOrbis/OpenOrbis-PS4-Toolchain/releases/latest)

Expand All @@ -10,15 +10,13 @@ This repository contains the source code and documentation for the OpenOrbis PS4

The header files as well as the library stubs may need updating to support yet undiscovered functions, so feel free to fork the repository and make pull requests to update support.

All Visual Studio solution files are assumed VS2017 *for now*. This will change when the .NET core-based projects drop, which will be VS2019 to allow usage of .NET core 3.1.

<p align="center">
<img src="logo.png" width="200px" height="200px">
</p>

## Notes

The following projects will be added to this repo within the next few days:
The following projects will be added to this repo soon:
- Debugger
- MiraLib

Expand Down Expand Up @@ -107,8 +105,8 @@ The `create-lib` tool is similar to the `create-eboot` tool, however it produces

Author: Specter + flatz (fself stuff)

### create-pkg
The `create-pkg` tool takes a set of files that applications are expected to have (`eboot.bin`, `param.sfo`, necessary modules, etc.) and creates a package file (pkg) for them to install on the PS4.
### liborbispkg
The `liborbispkg` tool takes a set of files that applications are expected to have (`eboot.bin`, `param.sfo`, necessary modules, etc.) and creates a package file (pkg) for them to install on the PS4.

Author: maxton

Expand Down Expand Up @@ -165,13 +163,15 @@ The accompanying LLVM binaries are licensed under the Apache 2.0 license and is
- Specter: Create-eboot/lib relinker, miralib, assistant suite, readelf, samples and documentation
- CrazyVoid: Stub generator, headers, samples and documentation
- maxton: Create-pkg pkg and SFO generation tools
- Kiwidog: Mira stuff, documentation
- Kiwidog: Mira, assistance, documentation
- IDC: Lots of help with libraries and other bug fixes
- flatz: Homebrew research and writeups, SELF reversing and documentation
- m0rph3us1987: Help with debugging stuff
- bigboss / psxdev: Library research and reverse engineering, used for reference by various samples
- LightningMods / LM: Testing via APP_HOME and lib loading help on the Mira side
- Lord Friky: Proper macOS support
- sleirsgoevy: Bug fixes and support
- ChendoChap: Bug fixes and support
- MrSlick: Awesome logo <3
- OpenOrbis Team
- Other anonymous contributors
Binary file added bin/data/modules/libSceFios2.prx
Binary file not shown.
Binary file added bin/data/modules/libc.prx
Binary file not shown.
37 changes: 35 additions & 2 deletions docs/MD/PS4 Libraries/Libkernel.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,40 @@ Semaphore attributes.
#define ORBIS_KERNEL_SEMA_ATTR_TH_PRIO 0x02
```

Direct memory attributes.

```c
#define ORBIS_KERNEL_MAIN_DMEM_SIZE 0x180000000u
```
Memory types.
```c
#define ORBIS_KERNEL_WB_ONION 0x0
#define ORBIS_KERNEL_WC_GARLIC 0x3 // Garlic+?
#define ORBIS_KERNEL_WB_GARLIC 0xA
```

Memory protections.

```c
// CPU
#define ORBIS_KERNEL_PROT_CPU_READ 0x01
#define ORBIS_KERNEL_PROT_CPU_WRITE 0x02
#define ORBIS_KERNEL_PROT_CPU_RW (ORBIS_KERNEL_PROT_CPU_READ | ORBIS_KERNEL_PROT_CPU_WRITE)
#define ORBIS_KERNEL_PROT_CPU_EXEC 0x04
#define ORBIS_KERNEL_PROT_CPU_ALL (ORBIS_KERNEL_PROT_CPU_RW | ORBIS_KERNEL_PROT_CPU_EXEC)

// GPU
#define ORBIS_KERNEL_PROT_GPU_READ 0x10
#define ORBIS_KERNEL_PROT_GPU_WRITE 0x20
#define ORBIS_KERNEL_PROT_GPU_RW (ORBIS_KERNEL_PROT_GPU_READ | ORBIS_KERNEL_PROT_GPU_WRITE)
#define ORBIS_KERNEL_PROT_GPU_ALL ORBIS_KERNEL_PROT_GPU_RW
```
### Known Globals
Libkernel also contains globals, among which is heap settings for libc. These are usually initialized by the CRT and are often used in homebrew because by default the PS4 heap is extremely limited (14mb or so cap).
Libkernel also contains globals, among which is heap settings for libc. ~~These are usually initialized by the CRT and are often used in homebrew because by default the PS4 heap is extremely limited (14mb or so cap).~~ This is no longer the case since MUSL has been ported; these globals are ignored.
**uint64_t sceLibcHeapSize**: Maximum heap size libc can use
**uint32_t sce_libc_heap_delayed_alloc**: Unknown?
Expand Down Expand Up @@ -168,4 +200,5 @@ int sceKernelUsleep(unsigned int usecs)
Sleeps the calling thread for `usecs` microseconds.

### Reversing Credits
- Various scene developers + BSD documentation
- Various scene developers + BSD documentation
- alexaltea
59 changes: 31 additions & 28 deletions docs/MD/PS4 Libraries/Pad.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,50 @@
The pad library is used for controller input to the Playstation 4. This includes operations such as opening a handle to a controller, reading the state, setting the light color, vibration settings, and other various actions.

### Known Macros
The state of buttons pressed after a poll is stored in an integer. By dumping this integer after pressing each button on the controller and recording it, we were able to get a listing of which buttons map to which values. Below is a set of macros defined in the header that map buttons to bits.
The state of buttons pressed after a poll is stored in an integer. Below is a set of macros defined in the header that map buttons to bits.

```c
#define PAD_BUTTON_L3 0x0002
#define PAD_BUTTON_R3 0x0004
#define PAD_BUTTON_START 0x0008
#define PAD_BUTTON_DPAD_UP 0x0010
#define PAD_BUTTON_DPAD_RIGHT 0x0020
#define PAD_BUTTON_DPAD_DOWN 0x0040
#define PAD_BUTTON_DPAD_LEFT 0x0080

#define PAD_BUTTON_L2 0x0100
#define PAD_BUTTON_R2 0x0200
#define PAD_BUTTON_L1 0x0400
#define PAD_BUTTON_R1 0x0800

#define PAD_BUTTON_TRIANGLE 0x1000
#define PAD_BUTTON_CIRCLE 0x2000
#define PAD_BUTTON_X 0x4000
#define PAD_BUTTON_SQUARE 0x8000

#define PAD_BUTTON_TOUCHPAD 0x100000
#define ORBIS_PAD_BUTTON_L3 0x0002
#define ORBIS_PAD_BUTTON_R3 0x0004
#define ORBIS_PAD_BUTTON_OPTIONS 0x0008
#define ORBIS_PAD_BUTTON_UP 0x0010
#define ORBIS_PAD_BUTTON_RIGHT 0x0020
#define ORBIS_PAD_BUTTON_DOWN 0x0040
#define ORBIS_PAD_BUTTON_LEFT 0x0080

#define ORBIS_PAD_BUTTON_L2 0x0100
#define ORBIS_PAD_BUTTON_R2 0x0200
#define ORBIS_PAD_BUTTON_L1 0x0400
#define ORBIS_PAD_BUTTON_R1 0x0800

#define ORBIS_PAD_BUTTON_TRIANGLE 0x1000
#define ORBIS_PAD_BUTTON_CIRCLE 0x2000
#define ORBIS_PAD_BUTTON_CROSS 0x4000
#define ORBIS_PAD_BUTTON_SQUARE 0x8000

#define ORBIS_PAD_BUTTON_TOUCH_PAD
```

It appears the only button on the controller not tracked through this state is the share button. Presumably this button is special and can only be handled directly by internal processes such as Shellcore.
It appears the only buttons on the controller not tracked through this state is the share button and the PS button. Presumably these buttons are special and can only be handled directly by internal processes such as Shellcore.

### Known Structures
#### OrbisPadData
The pad data structure is what the Pad library gives you when you poll for controller state. This includes the button state mentioned earlier, analogue positional data for thumbsticks, the touchpad, and gyro, and other data.

- **unsigned int buttons**: Button state
- **uint8_t lx**: Left joystick X coordinate
- **uint8_t ly**: Left joystick Y coordinate
- **uint8_t rx**: Right joystick X coordinate
- **uint8_t ry**: Right joystick Y coordinate
- **uint8_t l2**: L2 trigger pressure
- **uint8_t r2**: R2 trigger pressure
- **stick leftStick**
- **uint8_t x**: Left joystick X coordinate
- **uint8_t y**: Left joystick Y coordinate
- **stick rightStick**
- **uint8_t x**: Right joystick X coordinate
- **uint8_t y**: Right joystick Y coordinate
- **analog analogButtons**
- **uint8_t l2**: L2 trigger pressure
- **uint8_t r2**: R2 trigger pressure
- **uint16_t padding**: N/A
- **vec_float4 orientation**: Gyroscope orientation as a quaternion
- **vec_float3 acceleration**: Accelerometer reading
- **vec_float3 velocity**: Gyroscope velocity
- **vec_float3 acceleration**: Accelerometer reading
- **uint8_t touch[24]**: Touchpad data
- **uint8_t connected**: Whether the controller is on and connected or not
- **uint64_t timestamp**: Timestamp at time of poll
Expand Down
23 changes: 20 additions & 3 deletions docs/MD/PS4 Libraries/UserService.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,26 @@ One can also set priority levels on users. The lowest priority is `0x2FF` where
The service initialize parameters structure is used to initialize the user service library. The parameters only include one known parameter, being the priority.

```c
struct OrbisUserServiceInitializeParams {
typedef struct OrbisUserServiceInitializeParams {
uint32_t priority;
}
} OrbisUserServiceInitializeParams;
```

#### OrbisUserServiceLoginUserIdList
The service login user ID list structure is used as a container for a list of 4 potential user IDs currently logged in on the system.

```c
typedef struct OrbisUserServiceLoginUserIdList {
OrbisUserServiceUserId userId[4];
} OrbisUserServiceLoginUserIdList;
```

### Known Functions

**sceUserServiceInitialize(OrbisUserServiceInitializeParams \*params)**

```c
void sceUserServiceInitialize(OrbisUserServiceInitializeParams *params)
int sceUserServiceInitialize(OrbisUserServiceInitializeParams *params)
```
Initializes the user service library with the given `params`.
Expand All @@ -53,5 +62,13 @@ int sceUserServiceGetUserName(int userID, char *outName, size_t maxSize)
Gets the username of `userID` and writes it to `outName` to a maximum of `maxSize` bytes.
**sceUserServiceGetLoginUserIdList(OrbisUserServiceLoginUserIdList \*)**
```c
int sceUserServiceGetLoginUserIdList(OrbisUserServiceLoginUserIdList *);
```

Returns a listing of currently logged in users.

## Reversing Credits
- Various scene developers
39 changes: 37 additions & 2 deletions docs/MD/PS4 Libraries/VideoOut.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ The flip subsystem also takes a mode. The common one used is vsync.
#define ORBIS_VIDEO_OUT_FLIP_VSYNC 1
```
Pixel formats for frame buffers.
```c
#define ORBIS_VIDEO_OUT_PIXEL_FORMAT_A8B8G8R8_SRGB 0x80002200
```



### Known Structures
Expand All @@ -39,6 +45,18 @@ The flip status structure is an output structure used for when the flip queue is
- **int32_t currentBuffer**: Buffer index
- **uint32_t unknown**: N/A

#### OrbisVideoOutResolutionStatus
The resolution status structure is an output structure used for getting the current video settings (such as the width, height, refresh rate, and other information).

- **uint32_t width**: Width of the frame
- **uint32_t height**: Height of the frame
- **uint32_t paneWidth**: Width of the pane
- **uint32_t paneHeight**: Height of the pane
- **uint32_t refreshRate**: Current refresh rate
- **float screenSize**: Overall screen size
- **uint16_t flags**: Flags
- **uint16_t reserved[7]**: N/A

### Known Functions
**sceVideoOutOpen(userID, busType, int, void \*)**

Expand All @@ -64,7 +82,7 @@ int sceVideoOutRegisterBuffers(int handle, int index, void *addr, int num, Orbis
Registers `num` buffers at `index` from `addr` with the given `attr` attributes. Returns 0 on success, non-zero otherwise.
**sceVideoOutUnregisterBuffers(handle, int)**
**sceVideoOutUnregisterBuffers(handle, index)**
```c
int sceVideoOutUnregisterBuffers(int handle, int index)
Expand Down Expand Up @@ -104,5 +122,22 @@ int sceVideoOutGetFlipStatus(int handle, OrbisVideoOutFlipStatus *status)

Gets the flip status on the given `handle` and writes it to `outStatus`.

**sceVideooutIsFlipPending(handle)**

```c
int sceVideoOutIsFlipPending(int handle)
```
Gets whether or not a flip is pending on the given handle.
**sceVideoOutGetResolutionStatus(handle, OrbisVideoOutResolutionStatus *outStatus)**
```c
int sceVideoOutGetResolutionStatus(int handle, OrbisVideoOutResolutionStatus *status)
```

Gets the resolution status on the given `handle` and writes it to `outStatus`.

### Reversing Credits
- bigboss (psxdev)
- bigboss (psxdev)
- inori
Binary file modified extra/OpenOrbis PS4 SPRX Project.zip
Binary file not shown.
Loading

0 comments on commit 216a63c

Please sign in to comment.