https://github.com/impiaaa/psx-newlib
Newlib libc on the PlayStation 1
https://github.com/impiaaa/psx-newlib
libc newlib playstation
Last synced: about 1 year ago
JSON representation
Newlib libc on the PlayStation 1
- Host: GitHub
- URL: https://github.com/impiaaa/psx-newlib
- Owner: impiaaa
- License: bsd-3-clause
- Created: 2020-06-03T03:24:44.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-10-07T03:58:32.000Z (over 2 years ago)
- Last Synced: 2025-04-23T18:05:16.940Z (about 1 year ago)
- Topics: libc, newlib, playstation
- Language: C
- Homepage:
- Size: 59.6 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This is a syscall implementation and (only slightly modified) linker script for use with **[Newlib](http://www.sourceware.org/newlib/)** on the **[Sony PlayStation](https://en.wikipedia.org/wiki/PlayStation_(console))**. Newlib is a portable libc/stdlib implementation that doesn't require a Linux or BSD kernel like most libc's, and is complete and standards-compliant unlike a custom libc.
The PlayStation includes a BIOS ROM that has a number of system support functions, which we use to implement device-specific system calls. However, it additionally includes a few libc functions itself that do not interact with peripherals. As such, Newlib can either be used for all libc functions except as necessary to interact with hardware, or Newlib can be patched to use BIOS routines whereever possible. The second option may run slower in some cases but will result in a smaller executable. Patching newlib is also **required** if you set any exception handlers, link with the legacy PsyQ libraries (which set exception handlers), or debug with the pcsx-redux emulator.
### Option 1: Using a pre-patched, pre-compiled Newlib
Download a pre-compiled bundle from the [releases page](https://github.com/impiaaa/psx-newlib/releases) and install it into your existing MIPSEL prefix. Make sure to use `-nodefaultlibs -Tpsx.ld` in the linker flags, or if using another linker script, add `-lpsxsys` manually.
### Option 2: Using plain Newlib
1. Copy `psx.c` and `psx.ld` to `libgloss/mips/`.
2. Add them to `libgloss/mips/Makefile.in`, for example with:
PSXOBJS = psx.o syscalls.o getpid.o kill.o putnum.o
libpsxsys.a: $(PSXOBJS)
${AR} ${ARFLAGS} $@ $(PSXOBJS)
${RANLIB} $@
Then continue with "Configuring and compiling Newlib" below.
### Option 3: Patching Newlib
1. Copy `psx.c`, `psx.ld`, `psx-bonus.c`, and `psx-printf.S` to `libgloss/mips/`.
2. In the top-level Newlib source, run `patch -p1