Editing Syscalls

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
<!--// todo : needs to be tabled like the PS3 one
== PS4 custom system calls ==
http://fxr.watson.org/fxr/source/sys/syscall.h?v=FREEBSD-9-1
//-->
 
The PS4 kernel is based on FreeBSD 9, hence why PS4 has many syscalls in common with standard FreeBSD. However, some syscalls from FreeBSD are missing or disabled, and some custom syscalls have been added. A list of standard FreeBSD 9.1 syscalls can be found on[http://fxr.watson.org/fxr/source/sys/syscall.h?v=FREEBSD-9-1 watson.org FreeBSD headers].
 
Compatibility (for 32-bit on 64-bit) syscalls, and some others, have been disabled. The first custom Sony syscall comes at number 99. But PS4 specific syscalls come after the last FreeBSD 9.1 syscall, posix_fadvise, syscall 531. Currently, the last custom Sony syscall ID is 677 (as of FW 6.51). Calling any syscall with ID higher than 677 gives the same result as calling a compatibility or unimplemented syscall: a "There is not enough free system memory" error/segfault.
 
As of FW 1.76, of the 85 explored sony syscalls (532 - 617):
* Two will not be implemented in retail units (possibly in DevKits though) and return 0x4E ENOSYS, being sys_dynlib_dlopen and sys_dl_notify_event
* Eight will return 0x4E ENOSYS should the caller be lacking credentials (td->td_proc->p_ucred)
* Four will return 0x4E ENOSYS should the caller have insufficient privileges (uid0)
* Three will return 0x01 EPERM should the caller have insufficient privileges (uid0)
* One explicitly requires to run a PS4 DevKit (sys_set_gpo), as it sets output to debug LEDs that only development kit units have.
 
== Reverse engineering ==
 
Syscalls are mostly called by libkernel.sprx that exports wrappers to application. For example libkernel exports sceIoOpen function that is a wrapper to sys_open syscall.
 
https://i.gyazo.com/aa2bceacf5e5f45a15495fcdb79585cb.png
 
You can find an IDA Pro .idc script made by Cloverleafswag3 to label syscalls in libkernel [http://pastebin.com/xch7pb2H here]
An updated, janky, hacky version by X41 can be found [https://pastebin.com/2UWVj1N3 here]
 
== Functions of PS4 custom syscalls ==
 
# Modules
# Memory
# Process sandbox
# Semaphores, ?mutexes?
 
Other operations, such as file I/O and networking are handled through the standard FreeBSD 9.0 syscalls.
 
== PS4 custom syscalls ==
 
* Syscalls prototypes in the following table are for usermode interface. If it was kernel interface, the prototypes would have a thread pointer and a uap pointer:
<source>sys_xxx(struct thread* td, struct xxx_args* uap);</source>


{| class="wikitable sortable"
{| class="wikitable sortable"
|-
|-
! Syscall ID !! <abbr title="Firmware Version">PS4 FW Version</abbr> !! Syscall name !! Syscall usermode prototype !! Notes
! #syscall ID !! <abbr title="Firmware Version">FW Ver</abbr> !! Name !! Prototype !! Notes
|-
|-
| 99 || <=1.01? || sys_netcontrol || int sys_netcontrol(int fd, uint op, void *buf, uint nbuf) || -
| 99 || <=1.01? || sys_netcontrol || int sys_netcontrol(int fd, uint op, void *buf, uint nbuf) || -
Line 281: Line 245:
| 643 || >1.76? || sys_set_chicken_switches || - ||  
| 643 || >1.76? || sys_set_chicken_switches || - ||  
|-
|-
| 644 || ?>4.05>3.55? || sys_extend_page_table_pool || int sys_extend_page_table_pool(void) ||  
| 644 || >4.05>3.55? || sys_extend_page_table_pool || - ||  
|-
|-
| 645 || ?>4.05>3.55?? || sys_extend_page_table_pool2 || int sys_extend_page_table_pool2(void) || Duplicate of sys_extend_page_table_pool.
| 645 || >1.76? || sys_#645 || - ||  
|-
|-
| 646 || >1.76? || sys_get_kernel_mem_statistics || - ||  
| 646 || >1.76? || sys_get_kernel_mem_statistics || - ||  
Line 347: Line 311:
| 676 || ?> 5.07? || sys_cpumode_yield || - ||  
| 676 || ?> 5.07? || sys_cpumode_yield || - ||  
|-
|-
| 677 || ?>= 6.50? (not present on 6.20) || sys_get_phys_page_size || - || Not present in PS5 PS4EMU on PS5 FW 2.20.
| 677 || ?>= 6.50? (not present on 6.20) || sys_get_phys_page_size || - ||  
|}
|}


<nowiki>*</nowiki> Since FW 1.76, Sony has removed key information from sys_dynlib_get_info() (syscall 593), eg. it does not return the module's code base address, data base address, code size, nor the data size.
<nowiki>*</nowiki> Since 1.76, Sony has removed key information from sys_dynlib_get_info() (syscall 593), eg. it does not return the module's code base address, data base address, code size, or the data size.


<b>Note:</b> All system calls actually have the thread pointer as the first argument (struct thread *td), however since it's common among all system calls it's been omitted for readability.


{{Reverse Engineering}}
{{Reverse Engineering}}
<noinclude>[[Category:Main]]</noinclude>
<noinclude>[[Category:Main]]</noinclude>
Please note that all contributions to PS4 Developer wiki are considered to be released under the GNU Free Documentation License 1.2 (see PS4 Developer wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following hCaptcha:

Cancel Editing help (opens in new window)