├── .gitignore ├── CHANGELOG.md ├── CONTRIBUTORS.md ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── base ├── Makefile ├── assembler_register_parameter │ └── standard │ │ └── source │ │ └── register.s ├── assembler_system_call │ ├── rop_0x93a4FFFF8 │ │ └── source │ │ │ └── syscall.s │ └── standard │ │ └── source │ │ └── syscall.s ├── kernel_dlsym │ └── standard │ │ └── source │ │ └── dlsym.c ├── kernel_seek_elf_address │ └── standard │ │ └── source │ │ └── seek.c └── stub_resolve │ └── minimal │ └── source │ ├── adaptive.c │ ├── kern.c │ └── user.c ├── common ├── Makefile ├── generic │ └── source │ │ ├── atomic.c │ │ ├── atomic.s │ │ ├── machine_instruction.c │ │ └── third_party │ │ └── udis86 │ │ ├── decode.c │ │ ├── itab.c │ │ ├── syn-att.c │ │ ├── syn-intel.c │ │ ├── syn.c │ │ └── udis86.c ├── kernel │ └── source │ │ ├── kernel │ │ ├── base.c │ │ ├── cache.c │ │ ├── cache_global.c │ │ ├── descriptor.c │ │ ├── function.c │ │ ├── memory.c │ │ ├── privilege.c │ │ ├── protection.c │ │ ├── register.c │ │ ├── socket.c │ │ ├── symbol.c │ │ ├── system_call.c │ │ ├── thread.c │ │ └── uart.c │ │ ├── payload │ │ ├── function_hook_handler.c │ │ ├── function_hook_handler.s │ │ ├── lock.s │ │ ├── system_call_hook_handler.c │ │ ├── template.c │ │ └── template │ │ │ ├── function_hook_prologue.s │ │ │ ├── jump.s │ │ │ ├── return.s │ │ │ └── system_call_hook_prologue.s │ │ └── system_call_generic.c └── user │ └── source │ ├── file.c │ ├── memory │ ├── memory.c │ ├── protected.c │ └── shared.c │ ├── socket.c │ ├── standard_io.c │ └── stream.c ├── core ├── Makefile ├── include │ └── ps4 │ │ └── stub.h ├── kerns.mk ├── libcinternals.mk ├── libkernels.mk ├── stub.mk ├── stub │ ├── adaptive_function.stub.c │ ├── adaptive_system_call.stub.c │ ├── function.stub.c │ ├── kern_function.stub.c │ ├── module.stub.c │ └── system_call.stub.c └── systemcalls.mk ├── crt0.s ├── extension ├── Makefile ├── kernel_call │ └── standard │ │ └── source │ │ └── kernel_call.c └── kernel_execute │ ├── dynlib_prepare_dlclose │ ├── include │ │ └── ps4 │ │ │ └── exploit.h │ └── source │ │ ├── exploit.c │ │ └── kernel_execute.c │ └── in_kernel_only │ └── source │ └── kernel_execute.c ├── include ├── _ctype.h ├── aio.h ├── altq │ ├── altqconf.h │ └── if_altq.h ├── arpa │ └── inet.h ├── assert.h ├── bsm │ ├── audit.h │ └── audit_kevents.h ├── complex.h ├── cpio.h ├── ctype.h ├── db.h ├── dirent.h ├── dlfcn.h ├── elf.h ├── err.h ├── errno.h ├── fcntl.h ├── fenv.h ├── float.h ├── fmtmsg.h ├── fnmatch.h ├── ftw.h ├── glob.h ├── grp.h ├── inttypes.h ├── iso646.h ├── langinfo.h ├── libgen.h ├── limits.h ├── locale.h ├── machine │ ├── _align.h │ ├── _inttypes.h │ ├── _limits.h │ ├── _stdint.h │ ├── _types.h │ ├── atomic.h │ ├── cpu.h │ ├── cpufunc.h │ ├── elf.h │ ├── endian.h │ ├── fpu.h │ ├── frame.h │ ├── param.h │ ├── pcb.h │ ├── pcpu.h │ ├── pmap.h │ ├── proc.h │ ├── psl.h │ ├── ptrace.h │ ├── reg.h │ ├── runq.h │ ├── segments.h │ ├── setjmp.h │ ├── signal.h │ ├── specialreg.h │ ├── stdarg.h │ ├── sysarch.h │ ├── trap.h │ ├── ucontext.h │ ├── vm.h │ └── vmparam.h ├── math.h ├── monetary.h ├── mqueue.h ├── ndbm.h ├── net │ ├── if.h │ ├── if_var.h │ └── vnet.h ├── netdb.h ├── netinet │ ├── in.h │ └── tcp.h ├── netinet6 │ └── in6.h ├── nl_types.h ├── opt_compat.h ├── poll.h ├── ps4 │ ├── assembler.h │ ├── atomic.h │ ├── base.h │ ├── change.h │ ├── error.h │ ├── exception.h │ ├── expression.h │ ├── file.h │ ├── kernel.h │ ├── kernel │ │ ├── base.h │ │ ├── cache.h │ │ ├── cache_global.h │ │ ├── descriptor.h │ │ ├── function.h │ │ ├── memory.h │ │ ├── privilege.h │ │ ├── protection.h │ │ ├── register.h │ │ ├── socket.h │ │ ├── symbol.h │ │ ├── system_call.h │ │ ├── thread.h │ │ └── uart.h │ ├── limit.h │ ├── machine.h │ ├── memory.h │ ├── memory │ │ ├── memory.h │ │ ├── protected.h │ │ └── shared.h │ ├── payload.h │ ├── payload │ │ └── template.h │ ├── ps4.h │ ├── register.h │ ├── socket.h │ ├── standard_io.h │ ├── stream.h │ ├── stub_resolve.h │ ├── system_call.h │ ├── type.h │ └── util.h ├── pthread.h ├── pwd.h ├── regex.h ├── runetype.h ├── sce │ ├── camera.h │ ├── kern.h │ ├── kernel.h │ ├── libc_internal.h │ ├── net.h │ ├── pad.h │ ├── sysmodule.h │ ├── types │ │ ├── camera.h │ │ ├── kernel.h │ │ └── usbd.h │ └── usbd.h ├── sched.h ├── search.h ├── semaphore.h ├── setjmp.h ├── signal.h ├── spawn.h ├── stdarg.h ├── stdbool.h ├── stddef.h ├── stdint.h ├── stdio.h ├── stdlib.h ├── string.h ├── strings.h ├── sys │ ├── _callout.h │ ├── _cpuset.h │ ├── _iovec.h │ ├── _lock.h │ ├── _lockmgr.h │ ├── _mutex.h │ ├── _null.h │ ├── _pthreadtypes.h │ ├── _rwlock.h │ ├── _semaphore.h │ ├── _sigset.h │ ├── _sockaddr_storage.h │ ├── _stack.h │ ├── _stdint.h │ ├── _sx.h │ ├── _task.h │ ├── _termios.h │ ├── _timespec.h │ ├── _timeval.h │ ├── _types.h │ ├── _umtx.h │ ├── acl.h │ ├── buf_ring.h │ ├── bufobj.h │ ├── callout.h │ ├── capability.h │ ├── cdefs.h │ ├── condvar.h │ ├── conf.h │ ├── consio.h │ ├── cpuset.h │ ├── dirent.h │ ├── elf.h │ ├── elf32.h │ ├── elf64.h │ ├── elf_common.h │ ├── elf_generic.h │ ├── errno.h │ ├── event.h │ ├── eventhandler.h │ ├── eventvar.h │ ├── fcntl.h │ ├── file.h │ ├── filedesc.h │ ├── filio.h │ ├── imgact.h │ ├── ioccom.h │ ├── ioctl.h │ ├── ipc.h │ ├── jail.h │ ├── kbio.h │ ├── kdb.h │ ├── kernel.h │ ├── kobj.h │ ├── kthread.h │ ├── ktr.h │ ├── libkern.h │ ├── limits.h │ ├── linker.h │ ├── linker_set.h │ ├── lock.h │ ├── lock_profile.h │ ├── lockmgr.h │ ├── lockstat.h │ ├── mac.h │ ├── malloc.h │ ├── mbuf.h │ ├── mman.h │ ├── module.h │ ├── mount.h │ ├── mqueue.h │ ├── msg.h │ ├── mutex.h │ ├── namei.h │ ├── osd.h │ ├── param.h │ ├── pcpu.h │ ├── poll.h │ ├── priority.h │ ├── proc.h │ ├── protosw.h │ ├── ptrace.h │ ├── queue.h │ ├── refcount.h │ ├── resource.h │ ├── resourcevar.h │ ├── rtprio.h │ ├── runq.h │ ├── rwlock.h │ ├── sched.h │ ├── select.h │ ├── selinfo.h │ ├── sem.h │ ├── sglist.h │ ├── shm.h │ ├── sigio.h │ ├── signal.h │ ├── signalvar.h │ ├── smp.h │ ├── sockbuf.h │ ├── socket.h │ ├── socketvar.h │ ├── sockio.h │ ├── sockopt.h │ ├── sockstate.h │ ├── stat.h │ ├── statvfs.h │ ├── stdatomic.h │ ├── stdint.h │ ├── sx.h │ ├── syscall.h │ ├── syscallsubr.h │ ├── sysctl.h │ ├── sysent.h │ ├── syslimits.h │ ├── sysproto.h │ ├── systm.h │ ├── time.h │ ├── times.h │ ├── timespec.h │ ├── ttycom.h │ ├── ttydefaults.h │ ├── types.h │ ├── ucontext.h │ ├── ucred.h │ ├── uio.h │ ├── un.h │ ├── unistd.h │ ├── user.h │ ├── utsname.h │ ├── vmmeter.h │ └── wait.h ├── syslog.h ├── tar.h ├── termios.h ├── tgmath.h ├── third_party │ ├── kernel │ │ └── uthash │ │ │ └── uthash.h │ └── udis86 │ │ ├── decode.h │ │ ├── extern.h │ │ ├── itab.h │ │ ├── syn.h │ │ ├── types.h │ │ ├── udint.h │ │ └── udis86.h ├── time.h ├── ulimit.h ├── unistd.h ├── utime.h ├── utmpx.h ├── vm │ ├── pmap.h │ ├── uma.h │ ├── vm.h │ ├── vm_extern.h │ ├── vm_map.h │ ├── vm_page.h │ └── vm_param.h ├── wchar.h ├── wctype.h ├── wordexp.h └── x86 │ ├── _align.h │ └── _inttypes.h ├── linker.x └── make ├── ps4sdk.mk ├── target ├── ps4_bin.mk ├── ps4_elf.mk ├── ps4_elf_kernel.mk ├── ps4_elf_rop.mk ├── ps4_elf_sce.mk ├── ps4_elf_standard.mk ├── ps4_lib.mk ├── ps4_lib_kernel.mk ├── ps4_lib_kernel_no_all.mk ├── ps4_lib_no_all.mk ├── ps4_untargeted.mk ├── x64.mk └── x64_nostd.mk └── trait ├── adaptive.mk ├── all_and_clean.mk ├── base.mk ├── common.mk ├── freestanding.mk ├── kernel.mk ├── kernel_execute.mk ├── link.mk ├── pic.mk ├── pie.mk ├── ps4.mk ├── ps4_untargeted.mk ├── sce.mk ├── system_call_rop_0x93a4FFFF8.mk └── system_call_standard.mk /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | lib/ 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 0.1.0 4 | 5 | * Changed all function signatures to return an int error code 6 | * Unified all function names and argument order 7 | * Switched kernel sockets to non-descriptor API (descriptors are process dependent) 8 | * Promoted util functions to their own namespaces 9 | * Removed kernel userland API (use ps4KernelCall or ps4KernelExecute instead to enter) 10 | * Renamed kern API to kernel (userland takeover) 11 | * Changed hooks to accept arbitrary signatures in addition to a syscall-like generic signature 12 | * Added post-hooks 13 | * Added syscall hooking 14 | * Lock-less hooks and initial thread safety 15 | * Altered namespaces, renamed isolate to generic and mixed to adaptive 16 | * Initial automated docker builds 17 | * Minor fixes 18 | -------------------------------------------------------------------------------- /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | # Contributions 2 | 3 | BY ADDING YOURSELF TO THIS FILE, YOU AGREE THAT YOUR CONTRIBUTIONS ARE LICENSED UNDER 4 | THE UNLICENSE. 5 | YOU MUST ADD YOURSELF TO THIS FILE BEFORE ANY PULL REQUEST OR COMMIT CAN BE ACCEPTED. 6 | 7 | The following people have contributed to the SDK: 8 | 9 | 18 | 19 | ## Contributors 20 | * __Hitodama__ (@HitoChibito) 21 | * 31.05.2016, Initial contributions to version 0.1.0 22 | 23 | # Additional contributors 24 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # ps4dev/ps4sdk 2 | # 3 | # This is intended as a vm alternative (interactive container) 4 | # A volume container may be useful too (bring your own OS/compiler container) 5 | 6 | FROM voidlinux/voidlinux 7 | 8 | ENV PS4DEV=/home/ps4dev 9 | ENV PS4SDK=$PS4DEV/ps4sdk 10 | 11 | RUN \ 12 | groupadd -r ps4dev && \ 13 | useradd --create-home -d /home/ps4dev --gid ps4dev ps4dev 14 | 15 | WORKDIR $PS4DEV 16 | COPY . $PS4SDK 17 | 18 | RUN \ 19 | xbps-install -Sy xbps ; \ 20 | xbps-install -Sy make clang git socat && \ 21 | cd ps4sdk && \ 22 | make && \ 23 | chown -R ps4dev:ps4dev /home/ps4dev 24 | 25 | USER ps4dev 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | 26 | --------------------------------------------------------------------- 27 | 28 | Please note that the FreeBSD headers and third party components are 29 | licensed under the BSD and MIT licenses and must be handled as such. 30 | 31 | --------------------------------------------------------------------- 32 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .DEFAULT_GOAL := all 2 | 3 | %: 4 | $(MAKE) -C base $@ $? 5 | $(MAKE) -C common $@ $? 6 | $(MAKE) -C extension $@ $? 7 | $(MAKE) -C core $@ $? 8 | -------------------------------------------------------------------------------- /base/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_lib_no_all 14 | BuildPath := $(Ps4Sdk)/build 15 | OutPath := $(Ps4Sdk)/lib 16 | 17 | include $(Ps4Sdk)/make/ps4sdk.mk 18 | 19 | define generateCObject 20 | $(patsubst %,$(BuildPath)/%,$(patsubst %.c,%.o,$(1))): $(1) 21 | $$(dirp) 22 | $$(compile) 23 | 24 | endef 25 | 26 | define generateSObject 27 | $(patsubst %,$(BuildPath)/%,$(patsubst %.s,%.o,$(1))): $(1) 28 | $$(dirp) 29 | $$(assemble) 30 | 31 | endef 32 | 33 | define generateTarget 34 | $(foreach i,$(wildcard $(1)source/*.c),$(call generateCObject,$(i))) 35 | $(foreach i,$(wildcard $(1)source/*.s),$(call generateSObject,$(i))) 36 | 37 | $(OutPath)/libPs4_base_$(subst /,_,$(patsubst %/,%,$(1))).a: $(patsubst %,$(BuildPath)/%, $(patsubst %.c,%.o,$(wildcard $(1)source/*.c)) $(patsubst %.s,%.o,$(wildcard $(1)source/*.s))) 38 | $$(dirp) 39 | $$(archive) 40 | all:: $(OutPath)/libPs4_base_$(subst /,_,$(patsubst %/,%,$(1))).a 41 | clean:: 42 | rm -fR $(BuildPath) $(OutPath)/libPs4_base_$(subst /,_,$(patsubst %/,%,$(1))).a 43 | -rmdir -p $(BuildPath)/$(strip $(1)) 44 | 45 | endef 46 | 47 | define generateTargets 48 | $(foreach i,$(1),$(call generateTarget,$(i))) 49 | 50 | endef 51 | 52 | $(eval $(call generateTargets,$(wildcard */*/))) 53 | -------------------------------------------------------------------------------- /base/assembler_register_parameter/standard/source/register.s: -------------------------------------------------------------------------------- 1 | .pushsection .text 2 | 3 | .global ps4AssemblerRegisterParameterPush 4 | .type ps4AssemblerRegisterParameterPush, @function 5 | ps4AssemblerRegisterParameterPush: 6 | sub $192, %rsp 7 | movq %rax, 8(%rsp) 8 | movq 192(%rsp), %rax 9 | movdqu %xmm7, 176(%rsp) 10 | movdqu %xmm6, 160(%rsp) 11 | movdqu %xmm5, 144(%rsp) 12 | movdqu %xmm4, 128(%rsp) 13 | movdqu %xmm3, 112(%rsp) 14 | movdqu %xmm2, 96(%rsp) 15 | movdqu %xmm1, 80(%rsp) 16 | movdqu %xmm0, 64(%rsp) 17 | movq %r9, 56(%rsp) 18 | movq %r8, 48(%rsp) 19 | movq %rcx, 40(%rsp) 20 | movq %rdx, 32(%rsp) 21 | movq %rsi, 24(%rsp) 22 | movq %rdi, 16(%rsp) 23 | movq %rax, 0(%rsp) 24 | ret 25 | .size ps4AssemblerRegisterParameterPush, .-ps4AssemblerRegisterParameterPush 26 | 27 | .global ps4AssemblerRegisterParameterPop 28 | .type ps4AssemblerRegisterParameterPop, @function 29 | ps4AssemblerRegisterParameterPop: 30 | movq 0(%rsp), %rax 31 | movq 16(%rsp), %rdi 32 | movq 24(%rsp), %rsi 33 | movq 32(%rsp), %rdx 34 | movq 40(%rsp), %rcx 35 | movq 48(%rsp), %r8 36 | movq 56(%rsp), %r9 37 | movdqu 64(%rsp), %xmm0 38 | movdqu 80(%rsp), %xmm1 39 | movdqu 96(%rsp), %xmm2 40 | movdqu 112(%rsp), %xmm3 41 | movdqu 128(%rsp), %xmm4 42 | movdqu 144(%rsp), %xmm5 43 | movdqu 160(%rsp), %xmm6 44 | movdqu 176(%rsp), %xmm7 45 | movq %rax, 192(%rsp) 46 | movq 8(%rsp), %rax 47 | add $192, %rsp 48 | ret 49 | .size ps4AssemblerRegisterParameterPop, .-ps4AssemblerRegisterParameterPop 50 | 51 | .popsection 52 | -------------------------------------------------------------------------------- /base/assembler_system_call/rop_0x93a4FFFF8/source/syscall.s: -------------------------------------------------------------------------------- 1 | # This rop syscall is used in a exploited jit webbrowser process 2 | # The rop address is stored in a fixed location and loaded to r11 3 | 4 | .pushsection .text 5 | .global ps4AssemblerSystemCall 6 | .type ps4AssemblerSystemCall, @function 7 | ps4AssemblerSystemCall: 8 | movabs $0x93a4FFFF8, %r11 9 | movq (%r11), %r11 10 | movq %rcx, %r10 11 | call *%r11 12 | jnc .Lps4AssemblerSystemCallR 13 | # The error and return value is rax + carry (freebsd, systemv abi) 14 | # Be aware that this non-libc-syscall does not set libc's errno 15 | # as we may not even use libc at this point, or at all 16 | movq $-1, %rax 17 | .Lps4AssemblerSystemCallR: 18 | ret 19 | .size ps4AssemblerSystemCall, .-ps4AssemblerSystemCall 20 | .popsection 21 | -------------------------------------------------------------------------------- /base/assembler_system_call/standard/source/syscall.s: -------------------------------------------------------------------------------- 1 | # This syscall can be used in a normal (clean) process 2 | # SystemCall stubs and the resolvers are based on the symbol 3 | # You would normally not use non-libc-wrapped syscalls in a clean process 4 | # but you must supply the symbol for the adaptive resolvers 5 | 6 | .pushsection .text 7 | .global ps4AssemblerSystemCall 8 | .type ps4AssemblerSystemCall, @function 9 | ps4AssemblerSystemCall: 10 | movq %rcx, %r10 11 | syscall 12 | jnc .Lps4AssemblerSystemCallR 13 | movq $-1, %rax 14 | .Lps4AssemblerSystemCallR: 15 | ret 16 | .size ps4AssemblerSystemCall, .-ps4AssemblerSystemCall 17 | .popsection 18 | -------------------------------------------------------------------------------- /base/kernel_dlsym/standard/source/dlsym.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | static Elf64_Sym *ps4KernelDlSymElfSymbols; 7 | static char *ps4KernelDlSymElfStrings; 8 | 9 | static void ps4KernelDlSymInitialize(void) 10 | { 11 | void *kernelAddress = ps4KernelSeekElfAddress(); 12 | if(kernelAddress == NULL) 13 | return; 14 | 15 | // Ah, old-school/kernel C naming conventions ... terrible stuff 16 | Elf64_Ehdr *ehdr = (Elf64_Ehdr *)kernelAddress; 17 | /*for(size_t i = 0; i < ehdr->e_phnum; i++) 18 | { 19 | Elf64_Phdr *phdr = (Elf64_Phdr *)(kernelAddress + ehdr->e_phoff) + i; 20 | if (phdr->p_type == PT_PHDR) 21 | ehdr = (Elf64_Ehdr *)(phdr->p_vaddr - ehdr->e_phoff); 22 | }*/ 23 | Elf64_Phdr *phdr = (Elf64_Phdr *)((uint8_t *)ehdr + ehdr->e_phoff); 24 | for(size_t i = 0; i < ehdr->e_phnum; i++, phdr++) 25 | if (phdr->p_type == PT_DYNAMIC) 26 | { 27 | Elf64_Dyn *dyn = (Elf64_Dyn *)phdr->p_vaddr; 28 | for (Elf64_Dyn *d = dyn; d->d_tag != DT_NULL; d++) 29 | switch (d->d_tag) 30 | { 31 | case DT_SYMTAB: 32 | ps4KernelDlSymElfSymbols = (Elf64_Sym *)d->d_un.d_ptr; 33 | break; 34 | case DT_STRTAB: 35 | ps4KernelDlSymElfStrings = (char *)d->d_un.d_ptr; 36 | break; 37 | } 38 | } 39 | } 40 | 41 | void *ps4KernelDlSym(char *name) 42 | { 43 | Elf64_Sym *symbol; 44 | 45 | if(ps4KernelDlSymElfSymbols == NULL || ps4KernelDlSymElfStrings == NULL) 46 | ps4KernelDlSymInitialize(); 47 | 48 | for(symbol = ps4KernelDlSymElfSymbols; symbol + 1 < (Elf64_Sym *)ps4KernelDlSymElfStrings; ++symbol) 49 | { 50 | int j; 51 | char *n = (char *)&ps4KernelDlSymElfStrings[symbol->st_name]; 52 | for(j = 0; n[j] == name[j] && n[j] != 0; ++j); 53 | if(j > 0 && n[j] == '\0' && name[j] == '\0') 54 | return (void *)symbol->st_value; 55 | } 56 | 57 | return NULL; 58 | } 59 | -------------------------------------------------------------------------------- /base/kernel_seek_elf_address/standard/source/seek.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define PS4_KERNEL_ELF_RANGE_ADDRESS (char *)0xffffffff80000000 4 | enum{ PS4_KERNEL_ELF_RANGE_SIZE = 0x02000000 }; 5 | #define PS4_KERNEL_ELF_FIXED_ADDRESS (char *)0xffffffff80700000 6 | //enum{ PS4_KERNELEL_ELF_SIZE = 0x00EAC180 }; 7 | enum{ PS4_KERNEL_ELF_PAGE_SIZE = 16 * 1024 }; // no dependencies 8 | 9 | void *ps4KernelSeekElfAddress() 10 | { 11 | char *m; 12 | int i; 13 | unsigned char elfMagic[] = {0x7f, 'E', 'L', 'F', 0x02, 0x01, 0x01, 0x09, 0x00}; 14 | const size_t magicSize = sizeof(elfMagic) / sizeof(*elfMagic); 15 | 16 | m = PS4_KERNEL_ELF_FIXED_ADDRESS; 17 | for(i = 0; i < magicSize && m[i] == elfMagic[i]; ++i); 18 | if(i == magicSize) 19 | return m; 20 | 21 | for(m = PS4_KERNEL_ELF_RANGE_ADDRESS; 22 | m < PS4_KERNEL_ELF_RANGE_ADDRESS + PS4_KERNEL_ELF_RANGE_SIZE; 23 | m += PS4_KERNEL_ELF_PAGE_SIZE) 24 | { 25 | for(i = 0; i < magicSize && m[i] == elfMagic[i]; ++i); 26 | if(i == magicSize) 27 | return m; 28 | } 29 | 30 | return NULL; 31 | } 32 | -------------------------------------------------------------------------------- /base/stub_resolve/minimal/source/adaptive.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static inline int ps4AdaptiveStubResolveIsInKernel() 5 | { 6 | uintptr_t sp; 7 | __asm__ volatile("movq %%rsp, %0" : "=r"(sp)); 8 | return (sp >> 48) > 0; 9 | } 10 | 11 | int ps4AdaptiveStubResolve(void *stub, char *moduleName, char *functionName, int *moduleHandle, void **userAddress, void **kernelAddress) 12 | { 13 | if(ps4AdaptiveStubResolveIsInKernel()) 14 | return ps4KernelStubResolve(stub, functionName, kernelAddress); 15 | return ps4StubResolve(stub, moduleName, functionName, moduleHandle, userAddress); 16 | } 17 | -------------------------------------------------------------------------------- /base/stub_resolve/minimal/source/kern.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | int ps4KernelStubResolve(void *stub, char *functionName, void **kernelAddress) 7 | { 8 | if(stub == NULL || functionName == NULL || kernelAddress == NULL) 9 | return -1; 10 | 11 | *kernelAddress = ps4KernelDlSym(functionName); 12 | if(*kernelAddress == NULL) 13 | return -1; 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /base/stub_resolve/minimal/source/user.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | __asm__("\ 7 | .pushsection .text \n \ 8 | .global ps4StubResolveSystemCall \n \ 9 | .type ps4StubResolveSystemCall, @function \n \ 10 | ps4StubResolveSystemCall:\n \ 11 | movq $0, %rax \n \ 12 | jmp ps4AssemblerSystemCall \n \ 13 | .size ps4StubResolveSystemCall, .-ps4StubResolveSystemCall \n \ 14 | .popsection \n \ 15 | "); 16 | 17 | int ps4StubResolveSystemCall(); 18 | 19 | int ps4StubResolve(void *stub, char *moduleName, char *functionName, int *moduleHandle, void **userAddress) 20 | { 21 | static int (*ps4StubResolveLoadStartModule)(const char *name, size_t argc, const void *argv, uint32_t flags, void *a, void *b) = NULL; 22 | 23 | if(stub == NULL || moduleName == NULL || functionName == NULL || moduleHandle == NULL || userAddress == NULL) 24 | return -1; 25 | 26 | if(*moduleHandle <= 0) // for 0 (elf) we would do more then needed, but its a static null initialized value 27 | { 28 | if(!ps4StubResolveLoadStartModule) 29 | { 30 | int k = 0; 31 | ps4StubResolveSystemCall(594, "libkernel.sprx", 0, &k, 0); 32 | if(k <= 0) 33 | return -1; 34 | if(ps4StubResolveSystemCall(591, k, "sceKernelLoadStartModule", (void **)&ps4StubResolveLoadStartModule) != 0) 35 | return -1; 36 | } 37 | *moduleHandle = ps4StubResolveLoadStartModule(moduleName, 0, NULL, 0, NULL, NULL); 38 | if(*moduleHandle <= 0) 39 | return -1; 40 | } 41 | 42 | if(ps4StubResolveSystemCall(591, *moduleHandle, functionName, userAddress) != 0) 43 | return -1; 44 | 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /common/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_lib_no_all 14 | BuildPath := $(Ps4Sdk)/build 15 | OutPath := $(Ps4Sdk)/lib 16 | 17 | include $(Ps4Sdk)/make/ps4sdk.mk 18 | 19 | define generateCObject 20 | $(patsubst %,$(BuildPath)/%,$(patsubst %.c,%.c.o,$(1))): $(1) 21 | $$(dirp) 22 | $$(compile) 23 | 24 | endef 25 | 26 | define generateSObject 27 | $(patsubst %,$(BuildPath)/%,$(patsubst %.s,%.s.o,$(1))): $(1) 28 | $$(dirp) 29 | $$(assemble) 30 | 31 | endef 32 | 33 | define generateTarget 34 | $(foreach i,$(call findwildcard, $(1)source/, *.c),$(call generateCObject,$(i))) 35 | $(foreach i,$(call findwildcard, $(1)source/, *.s),$(call generateSObject,$(i))) 36 | 37 | $(OutPath)/libPs4_common_$(subst /,_,$(patsubst %/,%,$(1))).a: $(patsubst %,$(BuildPath)/%, $(patsubst %.c,%.c.o,$(call findwildcard, $(1)source/, *.c)) $(patsubst %.s,%.s.o,$(call findwildcard, $(1)source/, *.s))) 38 | $$(dirp) 39 | $$(archive) 40 | all:: $(OutPath)/libPs4_common_$(subst /,_,$(patsubst %/,%,$(1))).a 41 | clean:: 42 | rm -fR $(BuildPath)/$(subst /,,$(strip $(1))) $(OutPath)/libPs4_common_$(subst /,_,$(patsubst %/,%,$(1))).a 43 | 44 | endef 45 | 46 | define generateTargets 47 | $(foreach i,$(1),$(call generateTarget,$(i))) 48 | 49 | endef 50 | 51 | $(eval $(call generateTargets,$(wildcard */))) 52 | -------------------------------------------------------------------------------- /common/generic/source/atomic.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | int ps4AtomicSpinLock64(uint64_t *memory) 7 | { 8 | uint64_t v; 9 | 10 | if(memory == NULL) 11 | return PS4_ERROR_ARGUMENT_PRIMARY_MISSING; 12 | 13 | do 14 | { 15 | v = 1; 16 | ps4AtomicSwap64(memory, &v); 17 | } 18 | while(v != 0); 19 | 20 | return PS4_OK; 21 | } 22 | 23 | int ps4AtomicSpinUnlock64(uint64_t *memory) 24 | { 25 | uint64_t v = 0; 26 | 27 | if(memory == NULL) 28 | return PS4_ERROR_ARGUMENT_PRIMARY_MISSING; 29 | 30 | ps4AtomicSwap64(memory, &v); 31 | 32 | if(v != 1) 33 | return PS4_NOT_OK; 34 | return PS4_OK; 35 | } 36 | 37 | int ps4AtomicSpinLock32(uint32_t *memory) 38 | { 39 | uint32_t v; 40 | 41 | if(memory == NULL) 42 | return PS4_ERROR_ARGUMENT_PRIMARY_MISSING; 43 | 44 | do 45 | { 46 | v = 1; 47 | ps4AtomicSwap32(memory, &v); 48 | } 49 | while(v != 0); 50 | 51 | return PS4_OK; 52 | } 53 | 54 | int ps4AtomicSpinUnlock32(uint32_t *memory) 55 | { 56 | uint32_t v = 0; 57 | 58 | if(memory == NULL) 59 | return PS4_ERROR_ARGUMENT_PRIMARY_MISSING; 60 | 61 | ps4AtomicSwap32(memory, &v); 62 | 63 | if(v != 1) 64 | return PS4_NOT_OK; 65 | return PS4_OK; 66 | } 67 | 68 | int ps4AtomicSpinLock16(uint16_t *memory) 69 | { 70 | uint16_t v; 71 | 72 | if(memory == NULL) 73 | return PS4_ERROR_ARGUMENT_PRIMARY_MISSING; 74 | 75 | do 76 | { 77 | v = 1; 78 | ps4AtomicSwap16(memory, &v); 79 | } 80 | while(v != 0); 81 | 82 | return PS4_OK; 83 | } 84 | 85 | int ps4AtomicSpinUnlock16(uint16_t *memory) 86 | { 87 | uint16_t v = 0; 88 | 89 | if(memory == NULL) 90 | return PS4_ERROR_ARGUMENT_PRIMARY_MISSING; 91 | 92 | ps4AtomicSwap16(memory, &v); 93 | 94 | if(v != 1) 95 | return PS4_NOT_OK; 96 | return PS4_OK; 97 | } 98 | 99 | int ps4AtomicSpinLock8(uint8_t *memory) 100 | { 101 | uint8_t v; 102 | 103 | if(memory == NULL) 104 | return PS4_ERROR_ARGUMENT_PRIMARY_MISSING; 105 | 106 | do 107 | { 108 | v = 1; 109 | ps4AtomicSwap8(memory, &v); 110 | } 111 | while(v != 0); 112 | 113 | return PS4_OK; 114 | } 115 | 116 | int ps4AtomicSpinUnlock8(uint8_t *memory) 117 | { 118 | uint8_t v = 0; 119 | 120 | if(memory == NULL) 121 | return PS4_ERROR_ARGUMENT_PRIMARY_MISSING; 122 | 123 | ps4AtomicSwap8(memory, &v); 124 | 125 | if(v != 1) 126 | return PS4_NOT_OK; 127 | return PS4_OK; 128 | } 129 | -------------------------------------------------------------------------------- /common/generic/source/atomic.s: -------------------------------------------------------------------------------- 1 | .pushsection .text 2 | 3 | .global ps4AtomicSwap64 4 | .type ps4AtomicSwap64, @function 5 | ps4AtomicSwap64: 6 | movq (%rdi), %rax 7 | lock xchgq %rax, (%rsi) 8 | movq %rax, (%rdi) 9 | retq 10 | .size ps4AtomicSwap64, .-ps4AtomicSwap64 11 | 12 | .global ps4AtomicSwap32 13 | .type ps4AtomicSwap32, @function 14 | ps4AtomicSwap32: 15 | movl (%rdi), %eax 16 | lock xchgl %eax, (%rsi) 17 | movl %eax, (%rdi) 18 | retq 19 | .size ps4AtomicSwap32, .-ps4AtomicSwap32 20 | 21 | .global ps4AtomicSwap16 22 | .type ps4AtomicSwap16, @function 23 | ps4AtomicSwap16: 24 | xorl %eax, %eax 25 | movw (%rdi), %ax 26 | lock xchgw %ax, (%rsi) 27 | movw %ax, (%rdi) 28 | retq 29 | .size ps4AtomicSwap16, .-ps4AtomicSwap16 30 | 31 | .global ps4AtomicSwap8 32 | .type ps4AtomicSwap8, @function 33 | ps4AtomicSwap8: 34 | xorl %eax, %eax 35 | movb (%rdi), %al 36 | lock xchgb %al, (%rsi) 37 | movb %al, (%rdi) 38 | retq 39 | .size ps4AtomicSwap8, .-ps4AtomicSwap8 40 | 41 | .popsection 42 | -------------------------------------------------------------------------------- /common/generic/source/machine_instruction.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | 8 | int ps4MachineInstructionNext(void *current, void **next) 9 | { 10 | ud_t ud_obj; 11 | 12 | if(current == NULL) 13 | return PS4_ERROR_ARGUMENT_PRIMARY_MISSING; 14 | if(next == NULL) 15 | return PS4_ERROR_ARGUMENT_OUT_MISSING; 16 | 17 | ud_init(&ud_obj); 18 | ud_set_input_buffer(&ud_obj, current, (size_t)-1); 19 | ud_set_mode(&ud_obj, 64); 20 | ud_set_syntax(&ud_obj, UD_SYN_ATT); 21 | 22 | if(!ud_disassemble(&ud_obj)) 23 | return PS4_ERROR_ASSEMBLER_INSTRUCTION_NOT_DECODABLE; 24 | 25 | *next = (uint8_t *)current + ud_insn_len(&ud_obj); 26 | 27 | return PS4_OK; 28 | } 29 | 30 | int ps4MachineInstructionSeek(void *current, void **found, size_t offset) 31 | { 32 | ud_t ud_obj; 33 | size_t i; 34 | 35 | if(current == NULL) 36 | return PS4_ERROR_ARGUMENT_PRIMARY_MISSING; 37 | if(found == NULL) 38 | return PS4_ERROR_ARGUMENT_OUT_MISSING; 39 | 40 | ud_init(&ud_obj); 41 | ud_set_input_buffer(&ud_obj, current, (size_t)-1); 42 | ud_set_mode(&ud_obj, 64); 43 | ud_set_syntax(&ud_obj, UD_SYN_INTEL); 44 | 45 | i = 0; 46 | while(i < offset && ud_disassemble(&ud_obj)) 47 | i += ud_insn_len(&ud_obj); 48 | 49 | if(i == 0 && offset != 0) 50 | return PS4_ERROR_ASSEMBLER_INSTRUCTION_NOT_DECODABLE; 51 | 52 | current = (uint8_t *)current + i; 53 | 54 | *found = current; 55 | 56 | return PS4_OK; 57 | } 58 | -------------------------------------------------------------------------------- /common/kernel/source/kernel/base.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int ps4KernelBrewCoffee() 4 | { 5 | return PS4_ERROR_I_AM_A_TEAPOT; 6 | } 7 | 8 | int ps4KernelIsKernelAddress(void *address) 9 | { 10 | if(((uintptr_t)address >> 48) > 0) 11 | return PS4_OK; 12 | return PS4_NOT_OK; 13 | } 14 | 15 | int ps4KernelIsInKernel() 16 | { 17 | void *sp; 18 | __asm__ volatile("movq %%rsp, %0" : "=r"(sp)); 19 | return ps4KernelIsKernelAddress(sp); 20 | } 21 | -------------------------------------------------------------------------------- /common/kernel/source/kernel/descriptor.c: -------------------------------------------------------------------------------- 1 | #define _KERNEL 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | int ps4KernelDescriptorWrite(struct thread *td, int fd, const void *data, size_t size) 16 | { 17 | struct uio auio; 18 | struct iovec aiov; 19 | int r; 20 | 21 | if(size == 0) 22 | return PS4_ERROR_ARGUMENT_SIZE_NULL; 23 | 24 | aiov.iov_base = (void *)data; 25 | aiov.iov_len = size; 26 | auio.uio_iov = &aiov; 27 | auio.uio_iovcnt = 1; 28 | auio.uio_resid = size; 29 | auio.uio_segflg = UIO_SYSSPACE; 30 | 31 | r = kern_writev(td, fd, &auio); 32 | 33 | return r; 34 | } 35 | 36 | int ps4KernelDescriptorPrint(struct thread *td, int fd, const char *format, ...) 37 | { 38 | va_list args; 39 | void *msg; 40 | size_t size; 41 | int r; 42 | 43 | if(td == NULL || format == NULL) 44 | return PS4_ERROR_ARGUMENT_MISSING; 45 | 46 | va_start(args, format); 47 | //FIXME: loop-write, limit size 48 | r = ps4KernelMemoryAllocateStringWithArgumentList((char **)&msg, (size_t *)&size, 0, format, args); 49 | va_end(args); 50 | 51 | if(r != PS4_OK) 52 | return r; 53 | 54 | r = ps4KernelDescriptorWrite(td, fd, msg, size); 55 | 56 | ps4KernelMemoryFree(msg); 57 | 58 | return r; 59 | } 60 | -------------------------------------------------------------------------------- /common/kernel/source/kernel/privilege.c: -------------------------------------------------------------------------------- 1 | #define _KERNEL 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | void ps4KernelPrivilegeRoot() 17 | { 18 | struct thread *td; 19 | struct ucred *cr; 20 | 21 | ps4KernelThreadGetCurrent(&td); 22 | cr = td->td_proc->p_ucred; 23 | cr->cr_uid = cr->cr_ruid = cr->cr_rgid = 0; 24 | //cr->cr_groups[0] = 0; 25 | } 26 | 27 | int ps4KernelPrivilegeUnjail() 28 | { 29 | struct thread *td; 30 | struct filedesc *fd; 31 | struct ucred *cr; 32 | void *t; 33 | 34 | ps4KernelThreadGetCurrent(&td); 35 | 36 | ps4ExpressionReturnOnError(ps4KernelSymbolLookUp("prison0", &t)); 37 | cr = td->td_proc->p_ucred; 38 | cr->cr_prison = (struct prison *)t; 39 | 40 | ps4ExpressionReturnOnError(ps4KernelSymbolLookUp("rootvnode", &t)); 41 | fd = td->td_proc->p_fd; 42 | //fd->fd_cdir = 43 | fd->fd_rdir = fd->fd_jdir = *(struct vnode **)t; 44 | 45 | return PS4_OK; 46 | } 47 | 48 | int ps4KernelPrivilegeEscalate() 49 | { 50 | ps4KernelPrivilegeRoot(); 51 | ps4ExpressionReturnOnError(ps4KernelPrivilegeUnjail()); 52 | return PS4_OK; 53 | } 54 | -------------------------------------------------------------------------------- /common/kernel/source/kernel/protection.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | static uint64_t *pg_nx; 11 | 12 | void ps4KernelProtectionWriteDisable() 13 | { 14 | load_cr0(rcr0() & ~CR0_WP); 15 | } 16 | 17 | void ps4KernelProtectionWriteEnable() 18 | { 19 | load_cr0(rcr0() | CR0_WP); 20 | } 21 | 22 | void ps4KernelProtectionExecuteDisable() // gives you that extra tingly feeling (TM) 23 | { 24 | if(pg_nx == NULL) 25 | pg_nx = (uint64_t *)ps4KernelDlSym("pg_nx"); 26 | *pg_nx = 0; 27 | } 28 | 29 | void ps4KernelProtectionExecuteEnable() 30 | { 31 | if(pg_nx == NULL) 32 | pg_nx = (uint64_t *)ps4KernelDlSym("pg_nx"); 33 | *pg_nx = 1ull << 63; 34 | } 35 | 36 | void ps4KernelProtectionAllDisable() 37 | { 38 | ps4KernelProtectionWriteDisable(); 39 | ps4KernelProtectionExecuteDisable(); 40 | } 41 | 42 | void ps4KernelProtectionAllEnable() 43 | { 44 | ps4KernelProtectionExecuteEnable(); 45 | ps4KernelProtectionWriteEnable(); 46 | } 47 | -------------------------------------------------------------------------------- /common/kernel/source/kernel/register.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | 8 | int ps4KernelRegisterControlSet(unsigned int c, unsigned long value) 9 | { 10 | switch(c) 11 | { 12 | case 0: 13 | load_cr0(value); 14 | break; 15 | /*case 1: // look into (ab)use 16 | load_cr1(value); 17 | break;*/ 18 | /*case 2: 19 | load_cr2(value); 20 | break;*/ 21 | case 3: 22 | load_cr3(value); 23 | break; 24 | case 4: 25 | load_cr4(value); 26 | break; 27 | default: 28 | return PS4_ERROR_ARGUMENT_OUT_OF_RANGE; 29 | } 30 | 31 | return PS4_OK; 32 | } 33 | 34 | int ps4KernelRegisterControlGet(unsigned int c, unsigned long *value) 35 | { 36 | if(value == NULL) 37 | return PS4_ERROR_ARGUMENT_OUT_MISSING; 38 | 39 | switch(c) 40 | { 41 | case 0: 42 | *value = rcr0(); 43 | break; 44 | /*case 1: 45 | *value = rcr1(); 46 | break;*/ 47 | case 2: 48 | *value = rcr2(); 49 | break; 50 | case 3: 51 | *value = rcr3(); 52 | break; 53 | case 4: 54 | *value = rcr4(); 55 | break; 56 | default: 57 | return PS4_ERROR_ARGUMENT_OUT_OF_RANGE; 58 | } 59 | 60 | return PS4_OK; 61 | } 62 | 63 | void ps4KernelRegisterModelSpecificSet(unsigned int msr, uint64_t value) 64 | { 65 | wrmsr(msr, value); 66 | } 67 | 68 | int ps4KernelRegisterModelSpecificGet(unsigned int msr, uint64_t *value) 69 | { 70 | if(value == NULL) 71 | return PS4_ERROR_ARGUMENT_OUT_MISSING; 72 | *value = rdmsr(msr); 73 | return PS4_OK; 74 | } 75 | -------------------------------------------------------------------------------- /common/kernel/source/kernel/symbol.c: -------------------------------------------------------------------------------- 1 | #define _KERNEL 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | static Ps4KernelCache *cache; 13 | static struct mtx *ps4KernelSymbolLookUpMutex; // FIXME: Use RW lock or RM locks 14 | 15 | #define PS4_KERNEL_CACHE_SYMBOL_LOOKUP "ps4.kernel.symbol.lookup" 16 | #define PS4_KERNEL_CACHE_SYMBOL_LOOKUP_CACHE PS4_KERNEL_CACHE_SYMBOL_LOOKUP ".cache" 17 | #define PS4_KERNEL_CACHE_SYMBOL_LOOKUP_MUTEX PS4_KERNEL_CACHE_SYMBOL_LOOKUP ".mutex" 18 | 19 | int ps4KernelSymbolLookUp(const char *str, void **value) 20 | { 21 | int r; 22 | 23 | if(str == NULL) 24 | return PS4_ERROR_ARGUMENT_PRIMARY_MISSING; 25 | if(value == NULL) 26 | return PS4_ERROR_ARGUMENT_OUT_MISSING; 27 | 28 | if(cache == NULL) 29 | { 30 | struct mtx *giant = ps4KernelDlSym("Giant"); 31 | 32 | mtx_lock(giant); 33 | r = ps4KernelCacheGlobalGet(PS4_KERNEL_CACHE_SYMBOL_LOOKUP_CACHE, (void **)&cache); 34 | if(r != PS4_OK) 35 | { 36 | r = ps4KernelCacheCreate(&cache); 37 | if(r != PS4_OK) 38 | { 39 | mtx_unlock(giant); 40 | return r; 41 | } 42 | ps4KernelCacheGlobalSet(PS4_KERNEL_CACHE_SYMBOL_LOOKUP_CACHE, cache); 43 | 44 | ps4KernelMemoryAllocateData((void **)&ps4KernelSymbolLookUpMutex, sizeof(struct mtx)); 45 | if(ps4KernelSymbolLookUpMutex == NULL) 46 | { 47 | ps4KernelCacheDestroy(cache); 48 | mtx_unlock(giant); 49 | return PS4_ERROR_KERNEL_OUT_OF_MEMORY; 50 | } 51 | mtx_init(ps4KernelSymbolLookUpMutex, "ps4KernelSymbolLookUpMutex", NULL, MTX_DEF | MTX_RECURSE); 52 | ps4KernelCacheGlobalSet(PS4_KERNEL_CACHE_SYMBOL_LOOKUP_MUTEX, ps4KernelSymbolLookUpMutex); 53 | } 54 | else 55 | r = ps4KernelCacheGlobalGet(PS4_KERNEL_CACHE_SYMBOL_LOOKUP_MUTEX, (void **)&ps4KernelSymbolLookUpMutex); 56 | mtx_unlock(giant); 57 | } 58 | 59 | mtx_lock(ps4KernelSymbolLookUpMutex); 60 | r = ps4KernelCacheGet(cache, str, value); 61 | if(r != PS4_OK) 62 | { 63 | void *v = ps4KernelDlSym((char *)str); 64 | ps4KernelCacheSet(cache, str, v); 65 | *value = v; 66 | if(v == NULL) 67 | return PS4_ERROR_KERNEL_SYMBOL_LOOKUP_NOT_FOUND; 68 | } 69 | mtx_unlock(ps4KernelSymbolLookUpMutex); 70 | 71 | return PS4_OK; 72 | } 73 | -------------------------------------------------------------------------------- /common/kernel/source/kernel/thread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | 8 | int ps4KernelThreadGetCurrent(Ps4KernelThread **td) 9 | { 10 | Ps4KernelThread *t; 11 | if(td == NULL) 12 | return PS4_ERROR_ARGUMENT_PRIMARY_MISSING; 13 | __asm__ volatile("movq %%gs:0, %0;" : "=r"(t)); 14 | *td = t; 15 | return PS4_OK; 16 | } 17 | 18 | // FIXME: To C once td tested / fixed 19 | int ps4KernelThreadGetReturn(Ps4KernelThread *td, register_t *ret) 20 | { 21 | if(td == NULL) 22 | return PS4_ERROR_ARGUMENT_PRIMARY_MISSING; 23 | if(ret == NULL) 24 | return PS4_ERROR_ARGUMENT_OUT_MISSING; 25 | //return td->retval[0]; 26 | *ret = *((register_t *)&(((int8_t *)td)[0x380])); 27 | return PS4_OK; 28 | } 29 | 30 | int ps4KernelThreadGetPrimaryReturn(Ps4KernelThread *td, register_t *ret) 31 | { 32 | return ps4KernelThreadGetReturn(td, ret); 33 | } 34 | 35 | int ps4KernelThreadGetSecondaryReturn(Ps4KernelThread *td, register_t *ret) 36 | { 37 | //return td->retval[1]; 38 | if(td == NULL) 39 | return PS4_ERROR_ARGUMENT_PRIMARY_MISSING; 40 | if(ret == NULL) 41 | return PS4_ERROR_ARGUMENT_OUT_MISSING; 42 | *ret = *((register_t *)&(((int8_t *)td)[0x388])); 43 | return PS4_OK; 44 | } 45 | 46 | int ps4KernelThreadSetReturn(Ps4KernelThread *td, register_t ret) 47 | { 48 | //return td->retval[0]; 49 | if(td == NULL) 50 | return PS4_ERROR_ARGUMENT_PRIMARY_MISSING; 51 | *((register_t *)&(((int8_t *)td)[0x380])) = ret; 52 | return PS4_OK; 53 | } 54 | 55 | int ps4KernelThreadSetPrimaryReturn(Ps4KernelThread *td, register_t ret) 56 | { 57 | return ps4KernelThreadSetReturn(td, ret); 58 | } 59 | 60 | int ps4KernelThreadSetSecondaryReturn(Ps4KernelThread *td, register_t ret) 61 | { 62 | //return td->retval[1]; 63 | if(td == NULL) 64 | return PS4_ERROR_ARGUMENT_PRIMARY_MISSING; 65 | *((register_t *)&(((int8_t *)td)[0x388])) = ret; 66 | return PS4_OK; 67 | } 68 | -------------------------------------------------------------------------------- /common/kernel/source/kernel/uart.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | int ps4KernelUartEnable() 6 | { 7 | uint8_t *fn; 8 | uint16_t *sf; 9 | 10 | ps4ExpressionReturnOnError(ps4KernelSymbolLookUp("bootparam_disable_console_output", (void **)&fn)); 11 | 12 | sf = (uint16_t *)(0xffffffff00000000 | (uintptr_t)*(uint32_t *)(fn + 4)); 13 | *sf = *sf & ~(1 << 15); 14 | 15 | return PS4_OK; 16 | } 17 | 18 | int ps4KernelUartDisable() 19 | { 20 | uint8_t *fn; 21 | uint16_t *sf; 22 | 23 | ps4ExpressionReturnOnError(ps4KernelSymbolLookUp("bootparam_disable_console_output", (void **)&fn)); 24 | 25 | sf = (uint16_t *)(0xffffffff00000000 | (uintptr_t)*(uint32_t *)(fn + 4)); 26 | *sf = *sf | (1 << 15); 27 | 28 | return PS4_OK; 29 | } 30 | -------------------------------------------------------------------------------- /common/kernel/source/payload/function_hook_handler.c: -------------------------------------------------------------------------------- 1 | #define _KERNEL 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | 17 | inline void ps4PayloadFunctionHookMemoryCopy(void *a, void *b, size_t s) 18 | { 19 | uint8_t *old = (uint8_t *)a; 20 | uint8_t *new = (uint8_t *)b; 21 | for(size_t i = 0; i < s; ++i) 22 | new[i] = old[i]; 23 | } 24 | 25 | Ps4KernelFunctionHookArgument *ps4PayloadFunctionHookArgumentClone(Ps4KernelFunctionHookArgument *uap) 26 | { 27 | Ps4KernelFunctionHookArgument *uap2; 28 | 29 | //FIXME: should be lock and copyable 30 | //if(!uap->acquire(&(uap->mutex)->mtx_lock, MTX_UNOWNED, curthread)) 31 | // uap->lock(uap->mutex, curthread, 0, LOCK_FILE, LOCK_LINE); 32 | //mtx_lock(uap->mutex); 33 | 34 | // FIXME: Sleeping should be avoided 35 | uap2 = uap->allocate(sizeof(Ps4KernelFunctionHookArgument), uap->mt, M_ZERO | M_WAITOK); 36 | ps4PayloadFunctionHookMemoryCopy(uap, uap2, sizeof(Ps4KernelFunctionHookArgument)); 37 | 38 | uap2->hook = uap->allocate(uap->hookSize * sizeof(void *), uap->mt, M_ZERO | M_WAITOK); 39 | ps4PayloadFunctionHookMemoryCopy(uap->hook, uap2->hook, uap->hookSize * sizeof(void *)); 40 | 41 | uap2->hookType = uap->allocate(uap->hookSize * sizeof(int64_t), uap->mt, M_ZERO | M_WAITOK); 42 | ps4PayloadFunctionHookMemoryCopy(uap->hookType, uap2->hookType, uap->hookSize * sizeof(int64_t)); 43 | 44 | uap2->arguments = uap->allocate(sizeof(Ps4RegisterParameters), uap->mt, M_ZERO | M_WAITOK); 45 | //ps4PayloadFunctionHookMemoryCopy(uap->arguments, uap2->arguments, sizeof(Ps4RegisterParameters)); 46 | 47 | uap2->returns = uap->allocate(sizeof(Ps4RegisterReturns), uap->mt, M_ZERO | M_WAITOK); 48 | //ps4PayloadFunctionHookMemoryCopy(uap->returns, uap2->returns, sizeof(Ps4RegisterReturns)); 49 | 50 | //++uap->callCount; 51 | 52 | //if(!uap->release(&(uap->mutex)->mtx_lock, curthread, MTX_UNOWNED)) 53 | // uap->unlock(uap->mutex, curthread, 0, LOCK_FILE, LOCK_LINE); 54 | //mtx_unlock(uap->mutex); 55 | 56 | return uap2; 57 | } 58 | 59 | void ps4PayloadFunctionHookArgumentDestroy(Ps4KernelFunctionHookArgument *uap) 60 | { 61 | uap->free(uap->returns, uap->mt); 62 | uap->free(uap->arguments, uap->mt); 63 | uap->free(uap->hookType, uap->mt); 64 | uap->free(uap->hook, uap->mt); 65 | uap->free(uap, uap->mt); 66 | } 67 | -------------------------------------------------------------------------------- /common/kernel/source/payload/lock.s: -------------------------------------------------------------------------------- 1 | .pushsection .text 2 | 3 | .global ps4PayloadLock 4 | .type ps4PayloadLock, @function 5 | ps4PayloadLock: 6 | jmp .-2 7 | .Lps4PayloadLockEnd: 8 | .size ps4PayloadLock, .-ps4PayloadLock 9 | 10 | .popsection 11 | 12 | .pushsection .rodata 13 | 14 | .global ps4PayloadLockSize 15 | .type ps4PayloadLockSize, @object 16 | ps4PayloadLockSize: 17 | .int .Lps4PayloadLockEnd - ps4PayloadLock 18 | .size ps4PayloadLockSize, .-ps4PayloadLockSize 19 | 20 | .popsection 21 | -------------------------------------------------------------------------------- /common/kernel/source/payload/template/function_hook_prologue.s: -------------------------------------------------------------------------------- 1 | .pushsection .text 2 | 3 | # --- The lie is a condition of life. 4 | 5 | .global ps4PayloadTemplateFunctionHookPrologue 6 | .type ps4PayloadTemplateFunctionHookPrologue, @function 7 | ps4PayloadTemplateFunctionHookPrologue: 8 | 9 | # --- fix in args 10 | movabs $0, %r11 11 | 12 | # --- entry count 13 | lock incq 16(%r11) 14 | 15 | # --- spin lock 16 | push %r12 17 | .Lps4PayloadTemplateFunctionHookPrologueLoop: 18 | movq $1, %r12 19 | lock xchg %r12, 184(%r11) 20 | testq %r12, %r12 21 | jnz .Lps4PayloadTemplateFunctionHookPrologueLoop 22 | pop %r12 23 | 24 | # --- No one saves us but ourselves 25 | sub $184, %rsp 26 | movdqu %xmm7, 168(%rsp) 27 | movdqu %xmm6, 152(%rsp) 28 | movdqu %xmm5, 136(%rsp) 29 | movdqu %xmm4, 120(%rsp) 30 | movdqu %xmm3, 104(%rsp) 31 | movdqu %xmm2, 88(%rsp) 32 | movdqu %xmm1, 72(%rsp) 33 | movdqu %xmm0, 56(%rsp) 34 | movq %r9, 48(%rsp) 35 | movq %r8, 40(%rsp) 36 | movq %rcx, 32(%rsp) 37 | movq %rdx, 24(%rsp) 38 | movq %rsi, 16(%rsp) 39 | movq %rdi, 8(%rsp) 40 | movq %rax, 0(%rsp) 41 | 42 | # --- call clone 43 | movq %r11, %rdi 44 | pushq %r11 45 | call *0(%r11) 46 | popq %r11 47 | 48 | # --- inc call count 49 | lock incq 56(%r11) 50 | 51 | # --- r12 to args, fix args to r12 52 | movq %r12, 32(%rax) 53 | movq %rax, %r12 54 | 55 | # --- clean stack 56 | movq 0(%rsp), %rax 57 | movq 8(%rsp), %rdi 58 | movq 16(%rsp), %rsi 59 | movq 24(%rsp), %rdx 60 | movq 32(%rsp), %rcx 61 | movq 40(%rsp), %r8 62 | movq 48(%rsp), %r9 63 | movdqu 56(%rsp), %xmm0 64 | movdqu 72(%rsp), %xmm1 65 | movdqu 88(%rsp), %xmm2 66 | movdqu 104(%rsp), %xmm3 67 | movdqu 120(%rsp), %xmm4 68 | movdqu 136(%rsp), %xmm5 69 | movdqu 152(%rsp), %xmm6 70 | movdqu 168(%rsp), %xmm7 71 | add $184, %rsp 72 | 73 | # --- return to r12 74 | popq 24(%r12) 75 | 76 | # --- inc call count 77 | #lock incq 56(%r11) 78 | 79 | # --- call handler 80 | jmpq *8(%r11) 81 | 82 | .Lps4PayloadTemplateFunctionHookPrologueEnd: 83 | .size ps4PayloadTemplateFunctionHookPrologue, .-ps4PayloadTemplateFunctionHookPrologue 84 | 85 | .popsection 86 | 87 | .pushsection .rodata 88 | 89 | .global ps4PayloadTemplateFunctionHookPrologueSize 90 | .type ps4PayloadTemplateFunctionHookPrologueSize, @object 91 | ps4PayloadTemplateFunctionHookPrologueSize: 92 | .int .Lps4PayloadTemplateFunctionHookPrologueEnd - ps4PayloadTemplateFunctionHookPrologue 93 | .size ps4PayloadTemplateFunctionHookPrologueSize, .-ps4PayloadTemplateFunctionHookPrologueSize 94 | 95 | .popsection 96 | -------------------------------------------------------------------------------- /common/kernel/source/payload/template/jump.s: -------------------------------------------------------------------------------- 1 | .pushsection .text 2 | 3 | .global ps4PayloadTemplateJump64 4 | .type ps4PayloadTemplateJump64, @function 5 | ps4PayloadTemplateJump64: 6 | movabs $0, %r11 7 | jmp *%r11 8 | .Lps4PayloadTemplateJump64End: 9 | .size ps4PayloadTemplateJump64, .-ps4PayloadTemplateJump64 10 | 11 | .global ps4PayloadTemplateJump32 12 | .type ps4PayloadTemplateJump32, @function 13 | ps4PayloadTemplateJump32: 14 | movl $0, %r11d 15 | jmp *%r11 16 | .Lps4PayloadTemplateJump32End: 17 | .size ps4PayloadTemplateJump32, .-ps4PayloadTemplateJump32 18 | 19 | .popsection 20 | 21 | .pushsection .rodata 22 | 23 | .global ps4PayloadTemplateJump64Size 24 | .type ps4PayloadTemplateJump64Size, @object 25 | ps4PayloadTemplateJump64Size: 26 | .int .Lps4PayloadTemplateJump64End - ps4PayloadTemplateJump64 27 | .size ps4PayloadTemplateJump64Size, .-ps4PayloadTemplateJump64Size 28 | 29 | .global ps4PayloadTemplateJump32Size 30 | .type ps4PayloadTemplateJump32Size, @object 31 | ps4PayloadTemplateJump32Size: 32 | .int .Lps4PayloadTemplateJump32End - ps4PayloadTemplateJump32 33 | .size ps4PayloadTemplateJump32Size, .-ps4PayloadTemplateJump32Size 34 | 35 | .popsection 36 | -------------------------------------------------------------------------------- /common/kernel/source/payload/template/return.s: -------------------------------------------------------------------------------- 1 | .pushsection .text 2 | 3 | .global ps4PayloadTemplateReturn64 # --- int return 4 | .type ps4PayloadTemplateReturn64, @function 5 | ps4PayloadTemplateReturn64: 6 | movabs $0, %rax 7 | ret 8 | .Lps4PayloadTemplateReturn64End: 9 | .size ps4PayloadTemplateReturn64, .-ps4PayloadTemplateReturn64 10 | 11 | .global ps4PayloadTemplateReturn32 # --- smaller 12 | .type ps4PayloadTemplateReturn32, @function 13 | ps4PayloadTemplateReturn32: 14 | movl $0, %eax 15 | ret 16 | .Lps4PayloadTemplateReturn32End: 17 | .size ps4PayloadTemplateReturn32, .-ps4PayloadTemplateReturn32 18 | 19 | .global ps4PayloadTemplateReturnZero # --- smaller then return payload 20 | .type ps4PayloadTemplateReturnZero, @function 21 | ps4PayloadTemplateReturnZero: 22 | xorq %rax, %rax 23 | ret 24 | .Lps4PayloadTemplateReturnZeroEnd: 25 | .size ps4PayloadTemplateReturnZero, .-ps4PayloadTemplateReturnZero 26 | 27 | # --- FIXME: add st0? 28 | 29 | .popsection 30 | 31 | .pushsection .rodata 32 | 33 | .global ps4PayloadTemplateReturn64Size 34 | .type ps4PayloadTemplateReturn64Size, @object 35 | ps4PayloadTemplateReturn64Size: 36 | .int .Lps4PayloadTemplateReturn64End - ps4PayloadTemplateReturn64 37 | .size ps4PayloadTemplateReturn64Size, .-ps4PayloadTemplateReturn64Size 38 | 39 | .global ps4PayloadTemplateReturn32Size 40 | .type ps4PayloadTemplateReturn32Size, @object 41 | ps4PayloadTemplateReturn32Size: 42 | .int .Lps4PayloadTemplateReturn32End - ps4PayloadTemplateReturn32 43 | .size ps4PayloadTemplateReturn32Size, .-ps4PayloadTemplateReturn32Size 44 | 45 | .global ps4PayloadTemplateReturnZeroSize 46 | .type ps4PayloadTemplateReturnZeroSize, @object 47 | ps4PayloadTemplateReturnZeroSize: 48 | .int .Lps4PayloadTemplateReturnZeroEnd - ps4PayloadTemplateReturnZero 49 | .size ps4PayloadTemplateReturnZeroSize, .-ps4PayloadTemplateReturnZeroSize 50 | 51 | .popsection 52 | -------------------------------------------------------------------------------- /common/kernel/source/payload/template/system_call_hook_prologue.s: -------------------------------------------------------------------------------- 1 | .pushsection .text 2 | 3 | # --- The lie is a condition of life. 4 | 5 | .global ps4PayloadTemplateSystemCallHookPrologue 6 | .type ps4PayloadTemplateSystemCallHookPrologue, @function 7 | ps4PayloadTemplateSystemCallHookPrologue: 8 | 9 | # --- fix in args 10 | movabs $0, %r11 11 | 12 | # --- entry count 13 | lock incq 24(%r11) 14 | 15 | # --- spin lock 16 | push %r12 17 | .Lps4PayloadTemplateSystemCallHookPrologueLoop: 18 | movq $1, %r12 19 | lock xchg %r12, 40(%r11) 20 | testq %r12, %r12 21 | jnz .Lps4PayloadTemplateSystemCallHookPrologueLoop 22 | pop %r12 23 | 24 | # --- call clone 25 | movq %rsi, %rdx 26 | movq %r11, %rsi 27 | pushq %r11 28 | call *0(%r11) 29 | popq %r11 30 | 31 | # --- call handler args 32 | movq 16(%rax), %rdi 33 | movq %rax, %rsi 34 | 35 | # --- inc call count 36 | lock incq 32(%r11) 37 | 38 | # --- entry count - FIXME: should be in handler -> races free 39 | push %r12 40 | lock decq 24(%r11) # --- decrease entry count 41 | movq $0, %r12 42 | lock xchg %r12, 40(%r11) # --- unlock 43 | pop %r12 44 | 45 | # --- call handler 46 | jmpq *8(%rax) 47 | 48 | .Lps4PayloadTemplateSystemCallHookPrologueEnd: 49 | .size ps4PayloadTemplateSystemCallHookPrologue, .-ps4PayloadTemplateSystemCallHookPrologue 50 | 51 | .popsection 52 | 53 | .pushsection .rodata 54 | 55 | .global ps4PayloadTemplateSystemCallHookPrologueSize 56 | .type ps4PayloadTemplateSystemCallHookPrologueSize, @object 57 | ps4PayloadTemplateSystemCallHookPrologueSize: 58 | .int .Lps4PayloadTemplateSystemCallHookPrologueEnd - ps4PayloadTemplateSystemCallHookPrologue 59 | .size ps4PayloadTemplateSystemCallHookPrologueSize, .-ps4PayloadTemplateSystemCallHookPrologueSize 60 | 61 | .popsection 62 | -------------------------------------------------------------------------------- /common/kernel/source/system_call_generic.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // Self-contained -> copy-able 5 | static inline register_t ps4SystemCallGenericThreadGetReturn0(struct thread *td) 6 | { 7 | return *((register_t *)&(((int8_t *)td)[0x380])); 8 | } 9 | 10 | static inline register_t ps4SystemCallGenericThreadGetReturn1(struct thread *td) 11 | { 12 | return *((register_t *)&(((int8_t *)td)[0x388])); 13 | } 14 | 15 | static inline void ps4SystemCallGenericThreadSetReturn0(struct thread *td, register_t ret) 16 | { 17 | *((register_t *)&(((int8_t *)td)[0x380])) = ret; 18 | } 19 | 20 | /* 21 | static inline void ps4SystemCallGenericThreadSetReturn1(struct thread *td, register_t ret) 22 | { 23 | *((register_t *)&(((int8_t *)td)[0x388])) = ret; 24 | } 25 | */ 26 | 27 | int ps4SystemCallGenericExecute(struct thread *td, Ps4SystemCallGenericExecuteArgument *uap) 28 | { 29 | int r; 30 | 31 | // We hold these truths to be self-evident, but checking 'em is probably good too. O´´* <(^^<) 32 | if(uap == NULL) 33 | return PS4_ERROR_ARGUMENT_MISSING; 34 | 35 | if(uap->function == NULL) // installed syscall arg 1 36 | return PS4_OK; // This is an intended OK nop 37 | 38 | r = ((int (*)())uap->function)(td, uap->uap); 39 | if(r == PS4_OK) 40 | { 41 | if(uap->returns[0] != NULL) 42 | *uap->returns[0] = ps4SystemCallGenericThreadGetReturn0(td); 43 | if(uap->returns[1] != NULL) 44 | *uap->returns[1] = ps4SystemCallGenericThreadGetReturn1(td); 45 | } 46 | 47 | return r; 48 | } 49 | 50 | int ps4SystemCallGenericCall(struct thread *td, Ps4SystemCallGenericCallArgument *uap) 51 | { 52 | if(uap == NULL) 53 | return PS4_ERROR_ARGUMENT_MISSING; 54 | 55 | if(uap->function == NULL) // Let's Ok this one too ... for symmetry 56 | return PS4_OK; 57 | 58 | uap->returns = ((register_t (*)())uap->function)(uap->rdi, uap->rsi, uap->rdx, uap->rcx, uap->r8, uap->r9); 59 | ps4SystemCallGenericThreadSetReturn0(td, uap->returns); 60 | //ps4SystemCallGenericThreadSetReturn1(td, 0); 61 | 62 | return PS4_OK; 63 | } 64 | -------------------------------------------------------------------------------- /common/user/source/file.c: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /common/user/source/socket.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | int ps4SocketTCPServerCreate(int *oserver, int port, int backlog) 16 | { 17 | int server; 18 | struct sockaddr_in address; 19 | int r; 20 | 21 | if(oserver == NULL) 22 | return PS4_ERROR_ARGUMENT_PRIMARY_MISSING; 23 | 24 | memset(&address, 0, sizeof(address)); 25 | address.sin_len = sizeof(address); 26 | address.sin_family = AF_INET; 27 | address.sin_addr.s_addr = htonl(INADDR_ANY); 28 | address.sin_port = htons(port); 29 | 30 | server = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); 31 | if(server < 0) 32 | return -1; 33 | 34 | setsockopt(server, SOL_SOCKET, SO_REUSEADDR, (char *)&(int){ 1 }, sizeof(int)); 35 | setsockopt(server, SOL_SOCKET, SO_REUSEPORT, (char *)&(int){ 1 }, sizeof(int)); 36 | 37 | if((r = bind(server, (struct sockaddr *)&address, sizeof(address))) < 0) 38 | { 39 | close(server); 40 | return -2; 41 | } 42 | 43 | if((r = listen(server, backlog)) < 0) 44 | { 45 | close(server); 46 | return -3; 47 | } 48 | 49 | *oserver = server; 50 | 51 | return PS4_OK; 52 | } 53 | 54 | int ps4SocketTCPServerCreateAcceptThenDestroy(int *oclient, int port) 55 | { 56 | int server, client, r; 57 | 58 | if(oclient == NULL) 59 | return PS4_ERROR_ARGUMENT_PRIMARY_MISSING; 60 | 61 | r = ps4SocketTCPServerCreate(&server, port, 1); 62 | if(r != PS4_OK) 63 | return r; 64 | client = accept(server, NULL, NULL); 65 | close(server); 66 | 67 | *oclient = client; 68 | 69 | if(client < 0) 70 | return client; 71 | return PS4_OK; 72 | } 73 | -------------------------------------------------------------------------------- /common/user/source/standard_io.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | void ps4StandardIoRedirect(int to) 12 | { 13 | int i; 14 | for(i = 0; i < 3; ++i) 15 | { 16 | if(i == to) 17 | continue; 18 | 19 | close(i); 20 | if(to > 0) 21 | dup(to); 22 | else 23 | open("/dev/null", O_RDWR, 0); 24 | } 25 | } 26 | 27 | int ps4StandardIoPrintHexDump(const void *data, size_t size) 28 | { 29 | uint8_t *d = (uint8_t *)data; 30 | size_t consoleSize = 16; 31 | uint8_t b[consoleSize + 3]; 32 | size_t i; 33 | 34 | if(data == NULL) 35 | return PS4_ERROR_ARGUMENT_PRIMARY_MISSING; 36 | 37 | b[0] = '|'; 38 | b[consoleSize + 1] = '|'; 39 | b[consoleSize + 2] = '\0'; 40 | for (i = 0; i < size; i++) 41 | { 42 | if ((i % consoleSize) == 0) 43 | { 44 | if (i != 0) 45 | printf(" %s\n", b); 46 | printf("%016lx ", (uint8_t *)data + i); 47 | } 48 | 49 | if(i % consoleSize == 8) 50 | printf(" "); 51 | printf(" %02x", d[i]); 52 | 53 | if (d[i] >= ' ' && d[i] <= '~') 54 | b[i % consoleSize + 1] = d[i]; 55 | else 56 | b[i % consoleSize + 1] = '.'; 57 | } 58 | 59 | while((i % consoleSize) != 0) 60 | { 61 | if(i % consoleSize == 8) 62 | printf(" "); 63 | else 64 | printf(" "); 65 | b[i % consoleSize + 1] = '.'; 66 | i++; 67 | } 68 | 69 | printf(" %s\n", b); 70 | 71 | return PS4_OK; 72 | } 73 | -------------------------------------------------------------------------------- /common/user/source/stream.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | int ps4StreamOpenFileDuplicate(FILE **file, int fd, const char *mode) //fddupopen 7 | { 8 | int t; 9 | FILE *r = NULL; 10 | 11 | if(file == NULL) 12 | return PS4_ERROR_ARGUMENT_PRIMARY_MISSING; 13 | if(mode == NULL) 14 | return PS4_ERROR_ARGUMENT_MISSING; 15 | 16 | if((t = dup(fd)) < 0) 17 | return PS4_ERROR_INTERNAL_ERROR; 18 | 19 | if((r = fdopen(t, mode)) == NULL) 20 | close(t); 21 | 22 | *file = r; 23 | 24 | return PS4_OK; 25 | } 26 | -------------------------------------------------------------------------------- /core/Makefile: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | Ps4Sdk ?= $(CURDIR)/.. 4 | 5 | target := ps4_lib_no_all 6 | BuildPath := $(Ps4Sdk)/build 7 | OutPath := $(Ps4Sdk)/lib 8 | 9 | ################################### 10 | 11 | ifndef Ps4SdkFlags 12 | ifdef ps4sdkflags 13 | Ps4SdkFlags := $(ps4sdkflags) 14 | endif 15 | ifdef PS4SDKCFLAGS 16 | Ps4SdkFlags := $(PS4SDKCFLAGS) 17 | endif 18 | endif 19 | 20 | ################################### 21 | 22 | include $(Ps4Sdk)/make/ps4sdk.mk 23 | 24 | archive2 = $(Archiver) $(ArchiverFlags) 25 | 26 | #dirp = @mkdir -p $(@D) 27 | #archive := $(Archiver) $(ArchiverFlags) 28 | 29 | #generateObject 30 | define generateObject 31 | $(BuildPath)/$(strip $(2))/$(strip $(4)).stub.o: stub/$(strip $(1)).stub.c 32 | ifeq ("$(wildcard $$@)", "") 33 | @mkdir -p $$@ 34 | @rmdir $$@ 35 | endif 36 | @$$(compile) -DPS4_STUB_MODULE="$(strip $(3))" -DPS4_STUB_SYMBOL="$(strip $(4))" 37 | 38 | endef 39 | 40 | #generateLibrary 41 | define generateLibrary 42 | $(foreach i, $(4), $(call generateObject, $(1), $(2), $(3), $(i))) 43 | $(OutPath)/$(strip $(2))_stub.a: $(5) $(patsubst %,$(BuildPath)/$(strip $(2))/%.stub.o,$(strip $(4))) 44 | $$(dirp) 45 | $$(archive) 46 | all:: $(OutPath)/$(strip $(2))_stub.a 47 | clean:: 48 | rm -fR $(BuildPath)/$(strip $(2)) $(OutPath)/$(strip $(2))_stub.a 49 | 50 | endef 51 | 52 | #generateLibrary 53 | define generateLibraryLarge 54 | $(foreach i, $(4), $(call generateObject, $(1), $(2), $(3), $(i))) 55 | $(OutPath)/$(strip $(2))_stub.a: $(5) $(patsubst %,$(BuildPath)/$(strip $(2))/%.stub.o,$(strip $(4))) 56 | $$(dirp) 57 | find $$(BuildPath)/$$(strip $(2)) -name *.o > /tmp/ps4sdk_$$(strip $(2))_object.tmp 58 | xargs $$(archive2) $$(OutPath)/$$(strip $(2))_stub.a < /tmp/ps4sdk_$$(strip $(2))_object.tmp 59 | rm -rf /tmp/ps4sdk_$$(strip $(2))_object.tmp 60 | all:: $(OutPath)/$(strip $(2))_stub.a 61 | clean:: 62 | rm -fR $(BuildPath)/$(strip $(2)) $(OutPath)/$(strip $(2))_stub.a 63 | 64 | endef 65 | 66 | #generateModule 67 | define generateModule 68 | $(call generateObject, module, $(1), $(1), $(1)) 69 | $(call generateLibrary, function, $(1), $(1), $(2), $(BuildPath)/$(strip $(1))/$(strip $(1)).stub.o) 70 | 71 | endef 72 | 73 | include $(CURDIR)/stub.mk 74 | 75 | ################################### 76 | -------------------------------------------------------------------------------- /core/stub/adaptive_function.stub.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | Ps4StubAdaptiveFunction(PS4_STUB_MODULE, PS4_STUB_SYMBOL) 4 | -------------------------------------------------------------------------------- /core/stub/adaptive_system_call.stub.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | Ps4StubAdaptiveSystemCall(PS4_STUB_SYMBOL) 4 | -------------------------------------------------------------------------------- /core/stub/function.stub.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | Ps4StubFunction(PS4_STUB_MODULE, PS4_STUB_SYMBOL) 4 | -------------------------------------------------------------------------------- /core/stub/kern_function.stub.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | Ps4StubKernFunction(PS4_STUB_SYMBOL) 4 | -------------------------------------------------------------------------------- /core/stub/module.stub.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | Ps4StubModule(PS4_STUB_MODULE) 4 | -------------------------------------------------------------------------------- /core/stub/system_call.stub.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | Ps4StubSystemCall(PS4_STUB_SYMBOL) 4 | -------------------------------------------------------------------------------- /crt0.s: -------------------------------------------------------------------------------- 1 | .pushsection .text 2 | .global _start 3 | .type _start, @function 4 | _start: 5 | jmp main 6 | .size _start, .-_start 7 | .popsection 8 | -------------------------------------------------------------------------------- /extension/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_lib_no_all 14 | BuildPath := $(Ps4Sdk)/build 15 | OutPath := $(Ps4Sdk)/lib 16 | IncludePath := -I$(wildcard */*/include) #FIXME: Need to gen correctly 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | define generateCObject 21 | $(patsubst %,$(BuildPath)/%,$(patsubst %.c,%.o,$(1))): $(1) 22 | $$(dirp) 23 | $$(compile) 24 | 25 | endef 26 | 27 | define generateSObject 28 | $(patsubst %,$(BuildPath)/%,$(patsubst %.s,%.o,$(1))): $(1) 29 | $$(dirp) 30 | $$(assemble) 31 | 32 | endef 33 | 34 | define generateTarget 35 | $(foreach i,$(wildcard $(1)source/*.c),$(call generateCObject,$(i))) 36 | $(foreach i,$(wildcard $(1)source/*.s),$(call generateSObject,$(i))) 37 | 38 | $(OutPath)/libPs4_extension_$(subst /,_,$(patsubst %/,%,$(1))).a: $(patsubst %,$(BuildPath)/%, $(patsubst %.c,%.o,$(wildcard $(1)source/*.c)) $(patsubst %.s,%.o,$(wildcard $(1)source/*.s))) 39 | $$(dirp) 40 | $$(archive) 41 | all:: $(OutPath)/libPs4_extension_$(subst /,_,$(patsubst %/,%,$(1))).a 42 | clean:: 43 | rm -fR $(BuildPath)/$(strip $(1)) $(OutPath)/libPs4_extension_$(subst /,_,$(patsubst %/,%,$(1))).a 44 | 45 | endef 46 | 47 | define generateTargets 48 | $(foreach i,$(1),$(call generateTarget,$(i))) 49 | 50 | endef 51 | 52 | $(eval $(call generateTargets,$(wildcard */*/))) 53 | -------------------------------------------------------------------------------- /extension/kernel_call/standard/source/kernel_call.c: -------------------------------------------------------------------------------- 1 | #define _KERNEL 2 | 3 | #include 4 | #include 5 | 6 | int64_t ps4KernelCallPrivate(void *call, int64_t rdi, int64_t rsi, int64_t rdx, int64_t rcx, int64_t r8, int64_t r9) 7 | { 8 | Ps4SystemCallGenericCallArgument uap; 9 | int64_t ret; 10 | 11 | if(ps4KernelIsInKernel() == PS4_OK) 12 | return ((int64_t (*)())call)(rdi, rsi, rdx, rcx, r8, r9); 13 | 14 | uap.function = (void *)call; 15 | uap.rdi = (register_t)rdi; 16 | uap.rsi = (register_t)rsi; 17 | uap.rdx = (register_t)rdx; 18 | uap.rcx = (register_t)rcx; 19 | uap.r8 = (register_t)r8; 20 | uap.r9 = (register_t)r9; 21 | uap.returns = 0; 22 | ps4KernelExecute((void *)ps4SystemCallGenericCall, &uap, &ret, NULL); 23 | 24 | return ret; 25 | } 26 | 27 | __asm__("\ 28 | .pushsection .text \n \ 29 | .global ps4KernelCall \n \ 30 | .type ps4KernelCall, @function \n \ 31 | ps4KernelCall:\n \ 32 | jmp ps4KernelCallPrivate \n \ 33 | .size ps4KernelCall, .-ps4KernelCall \n \ 34 | .popsection \n \ 35 | "); 36 | -------------------------------------------------------------------------------- /extension/kernel_execute/dynlib_prepare_dlclose/include/ps4/exploit.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // exploit is not a vital namespace 6 | // it can be used freely instead of PS4_KERNELEL_EXECUTE_EXPLOIT_ ... 7 | 8 | typedef enum 9 | { 10 | PS4_EXPLOIT_STATUS_SUCCESS = 0, 11 | PS4_EXPLOIT_STATUS_FILE_DESCRIPTOR_RAISE_ERROR = -1, 12 | PS4_EXPLOIT_STATUS_INTERMEDIATE_ALLOCATION_ERROR = -2, 13 | PS4_EXPLOIT_STATUS_BUFFER_ALLOCATION_ERROR = -3, 14 | PS4_EXPLOIT_STATUS_OVERFLOW_ALLOCATION_ERROR = -4, 15 | PS4_EXPLOIT_STATUS_BUFFER_FREE_ERROR = -5, 16 | PS4_EXPLOIT_STATUS_MAP_ERROR = -6, 17 | PS4_EXPLOIT_STATUS_MUNMAP_SLOT_ERROR = -7, 18 | PS4_EXPLOIT_STATUS_INTERMEDIATE_FREE_ERROR = -8, 19 | PS4_EXPLOIT_STATUS_DLCLOSE_ERROR = -9, 20 | PS4_EXPLOIT_STATUS_OVERFLOW_FREE_ERROR = -10, 21 | PS4_EXPLOIT_STATUS_OVERFLOW_TRIGGER_ERROR = -11, 22 | PS4_EXPLOIT_STATUS_CLOSE_ERROR = -12, 23 | PS4_EXPLOIT_STATUS_MUNMAP_CLEAN_ERROR = -13, 24 | } 25 | Ps4ExploitStatus; 26 | 27 | int ps4ExploitExecute(sy_call_t *call, void *uap, int64_t *ret0, int64_t *ret1, Ps4ExploitStatus *status); 28 | -------------------------------------------------------------------------------- /extension/kernel_execute/dynlib_prepare_dlclose/source/kernel_execute.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | int ps4KernelExecute(void *fn, void *uap, int64_t *ret0, int64_t *ret1) 11 | { 12 | // kernel namespace should be agnostic to kern types 13 | sy_call_t *f = (sy_call_t *)fn; 14 | 15 | if(ps4KernelIsInKernel() == PS4_OK) 16 | { 17 | struct thread *td; 18 | ps4KernelThreadGetCurrent(&td); 19 | int r = f(td, uap); 20 | if(ret0 != NULL) 21 | ps4KernelThreadGetReturn(td, ret0); 22 | if(ret1 != NULL) 23 | ps4KernelThreadGetSecondaryReturn(td, ret1); 24 | return r; 25 | } 26 | 27 | if(syscall(SYS_ps4_callback, NULL) == -1) 28 | { 29 | Ps4SystemCallGenericCallArgument u = {0}; 30 | u.function = (void *)ps4KernelSystemCallCopyInAndPatch; 31 | u.rdi = SYS_ps4_callback; 32 | u.rsi = (register_t)ps4SystemCallGenericExecute; 33 | u.rdx = 128; // Ah, getting function sizes in C ... (-_-)' 34 | u.rcx = 4; 35 | ps4ExploitExecute((sy_call_t *)ps4SystemCallGenericCall, &u, NULL, NULL, NULL); 36 | if(syscall(SYS_ps4_callback, NULL) == -1) 37 | { 38 | //*errno = EAGAIN; 39 | return -1; 40 | } 41 | } 42 | 43 | return syscall(SYS_ps4_callback, fn, uap, ret0, ret1); 44 | } 45 | -------------------------------------------------------------------------------- /extension/kernel_execute/in_kernel_only/source/kernel_execute.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // Self-contained 5 | static int ps4KernelExecuteIsInKernel() 6 | { 7 | long long unsigned sp; 8 | __asm__ volatile("movq %%rsp, %0" : "=r"(sp)); 9 | return (sp >> 48) > 0; 10 | } 11 | 12 | static void *ps4KernelExecuteCurrentThread() 13 | { 14 | struct thread *td; 15 | __asm__ volatile("movq %%gs:0, %0;" : "=r"(td)); 16 | return td; 17 | } 18 | 19 | static inline register_t ps4KernelExecuteThreadGetReturn0(struct thread *td) 20 | { 21 | return *((register_t *)&(((int8_t *)td)[0x380])); 22 | } 23 | 24 | static inline register_t ps4KernelExecuteThreadGetReturn1(struct thread *td) 25 | { 26 | return *((register_t *)&(((int8_t *)td)[0x388])); 27 | } 28 | 29 | int ps4KernelExecute(void *fn, void *uap, int64_t *ret0, int64_t *ret1) 30 | { 31 | sy_call_t *f = (sy_call_t *)fn; 32 | 33 | if(ps4KernelExecuteIsInKernel() == PS4_OK) 34 | { 35 | void *td = ps4KernelExecuteCurrentThread(); 36 | int r = f(td, uap); 37 | if(ret0 != NULL) 38 | *ret0 = ps4KernelExecuteThreadGetReturn0(td); 39 | if(ret1 != NULL) 40 | *ret1 = ps4KernelExecuteThreadGetReturn1(td); 41 | return r; 42 | } 43 | 44 | return PS4_ERROR_NOT_IMPLEMENTED; 45 | } 46 | -------------------------------------------------------------------------------- /include/altq/altqconf.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: altqconf.h,v 1.1 2001/06/27 05:28:36 kjc Exp $ */ 2 | /* $NetBSD: altqconf.h,v 1.2 2001/05/30 11:57:16 mrg Exp $ */ 3 | 4 | #if defined(_KERNEL_OPT) || defined(__OpenBSD__) 5 | 6 | #if defined(_KERNEL_OPT) 7 | #include "opt_altq_enabled.h" 8 | #endif 9 | 10 | #include 11 | 12 | #ifdef ALTQ 13 | #define NALTQ 1 14 | #else 15 | #define NALTQ 0 16 | #endif 17 | 18 | cdev_decl(altq); 19 | 20 | #ifdef __OpenBSD__ 21 | #define cdev_altq_init(c,n) { \ 22 | dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \ 23 | (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \ 24 | (dev_type_stop((*))) enodev, 0, (dev_type_select((*))) enodev, \ 25 | (dev_type_mmap((*))) enodev } 26 | #else 27 | #define cdev_altq_init(x,y) cdev__oci_init(x,y) 28 | #endif 29 | #endif /* defined(_KERNEL_OPT) || defined(__OpenBSD__) */ 30 | -------------------------------------------------------------------------------- /include/cpio.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2002 Mike Barcroft 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: release/9.0.0/include/cpio.h 101138 2002-08-01 07:18:38Z mike $ 27 | */ 28 | 29 | #ifndef _CPIO_H_ 30 | #define _CPIO_H_ 31 | 32 | #define C_ISSOCK 0140000 /* Socket. */ 33 | #define C_ISLNK 0120000 /* Symbolic link. */ 34 | #define C_ISCTG 0110000 /* Reserved. */ 35 | #define C_ISREG 0100000 /* Regular file. */ 36 | #define C_ISBLK 0060000 /* Block special. */ 37 | #define C_ISDIR 0040000 /* Directory. */ 38 | #define C_ISCHR 0020000 /* Character special. */ 39 | #define C_ISFIFO 0010000 /* FIFO. */ 40 | #define C_ISUID 0004000 /* Set user ID. */ 41 | #define C_ISGID 0002000 /* Set group ID. */ 42 | #define C_ISVTX 0001000 /* On directories, restricted deletion flag. */ 43 | #define C_IRUSR 0000400 /* Read by owner. */ 44 | #define C_IWUSR 0000200 /* Write by owner. */ 45 | #define C_IXUSR 0000100 /* Execute by owner. */ 46 | #define C_IRGRP 0000040 /* Read by group. */ 47 | #define C_IWGRP 0000020 /* Write by group. */ 48 | #define C_IXGRP 0000010 /* Execute by group. */ 49 | #define C_IROTH 0000004 /* Read by others. */ 50 | #define C_IWOTH 0000002 /* Write by others. */ 51 | #define C_IXOTH 0000001 /* Execute by others. */ 52 | 53 | #define MAGIC "070707" 54 | 55 | #endif /* _CPIO_H_ */ 56 | -------------------------------------------------------------------------------- /include/elf.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2001 David E. O'Brien. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: release/9.0.0/include/elf.h 174044 2007-11-28 22:09:12Z jb $ 27 | */ 28 | 29 | /* 30 | * This is a Solaris compatibility header 31 | */ 32 | 33 | #ifndef _ELF_H_ 34 | #define _ELF_H_ 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #endif /* !_ELF_H_ */ 42 | -------------------------------------------------------------------------------- /include/fnmatch.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1992, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * $FreeBSD: release/9.0.0/include/fnmatch.h 203964 2010-02-16 19:39:50Z imp $ 30 | * @(#)fnmatch.h 8.1 (Berkeley) 6/2/93 31 | */ 32 | 33 | #ifndef _FNMATCH_H_ 34 | #define _FNMATCH_H_ 35 | 36 | #include 37 | 38 | #define FNM_NOMATCH 1 /* Match failed. */ 39 | 40 | #define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ 41 | #define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ 42 | #define FNM_PERIOD 0x04 /* Period must be matched by period. */ 43 | 44 | #if __XSI_VISIBLE 45 | #define FNM_NOSYS (-1) /* Reserved. */ 46 | #endif 47 | 48 | #if __BSD_VISIBLE 49 | #define FNM_LEADING_DIR 0x08 /* Ignore / after Imatch. */ 50 | #define FNM_CASEFOLD 0x10 /* Case insensitive search. */ 51 | #define FNM_IGNORECASE FNM_CASEFOLD 52 | #define FNM_FILE_NAME FNM_PATHNAME 53 | #endif 54 | 55 | __BEGIN_DECLS 56 | int fnmatch(const char *, const char *, int); 57 | __END_DECLS 58 | 59 | #endif /* !_FNMATCH_H_ */ 60 | -------------------------------------------------------------------------------- /include/ftw.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: ftw.h,v 1.1 2003/07/21 21:13:18 millert Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2003 Todd C. Miller 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | * 18 | * Sponsored in part by the Defense Advanced Research Projects 19 | * Agency (DARPA) and Air Force Research Laboratory, Air Force 20 | * Materiel Command, USAF, under agreement number F39502-99-1-0512. 21 | * 22 | * $FreeBSD: release/9.0.0/include/ftw.h 134244 2004-08-24 13:00:55Z tjr $ 23 | */ 24 | 25 | #ifndef _FTW_H 26 | #define _FTW_H 27 | 28 | #include 29 | #include 30 | 31 | /* 32 | * Valid flags for the 3rd argument to the function that is passed as the 33 | * second argument to ftw(3) and nftw(3). Say it three times fast! 34 | */ 35 | #define FTW_F 0 /* File. */ 36 | #define FTW_D 1 /* Directory. */ 37 | #define FTW_DNR 2 /* Directory without read permission. */ 38 | #define FTW_DP 3 /* Directory with subdirectories visited. */ 39 | #define FTW_NS 4 /* Unknown type; stat() failed. */ 40 | #define FTW_SL 5 /* Symbolic link. */ 41 | #define FTW_SLN 6 /* Sym link that names a nonexistent file. */ 42 | 43 | /* 44 | * Flags for use as the 4th argument to nftw(3). These may be ORed together. 45 | */ 46 | #define FTW_PHYS 0x01 /* Physical walk, don't follow sym links. */ 47 | #define FTW_MOUNT 0x02 /* The walk does not cross a mount point. */ 48 | #define FTW_DEPTH 0x04 /* Subdirs visited before the dir itself. */ 49 | #define FTW_CHDIR 0x08 /* Change to a directory before reading it. */ 50 | 51 | struct FTW { 52 | int base; 53 | int level; 54 | }; 55 | 56 | __BEGIN_DECLS 57 | int ftw(const char *, int (*)(const char *, const struct stat *, int), int); 58 | int nftw(const char *, int (*)(const char *, const struct stat *, int, 59 | struct FTW *), int, int); 60 | __END_DECLS 61 | 62 | #endif /* !_FTW_H */ 63 | -------------------------------------------------------------------------------- /include/inttypes.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2001 Mike Barcroft 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: release/9.0.0/include/inttypes.h 205954 2010-03-31 02:12:24Z jmallett $ 27 | */ 28 | 29 | #ifndef _INTTYPES_H_ 30 | #define _INTTYPES_H_ 31 | 32 | #include 33 | #include 34 | 35 | #ifndef __cplusplus 36 | #ifndef _WCHAR_T_DECLARED 37 | typedef __wchar_t wchar_t; 38 | #define _WCHAR_T_DECLARED 39 | #endif 40 | #endif 41 | 42 | typedef struct { 43 | intmax_t quot; /* Quotient. */ 44 | intmax_t rem; /* Remainder. */ 45 | } imaxdiv_t; 46 | 47 | __BEGIN_DECLS 48 | intmax_t imaxabs(intmax_t) __pure2; 49 | imaxdiv_t imaxdiv(intmax_t, intmax_t) __pure2; 50 | 51 | intmax_t strtoimax(const char * __restrict, char ** __restrict, int); 52 | uintmax_t strtoumax(const char * __restrict, char ** __restrict, int); 53 | intmax_t wcstoimax(const wchar_t * __restrict, 54 | wchar_t ** __restrict, int); 55 | uintmax_t wcstoumax(const wchar_t * __restrict, 56 | wchar_t ** __restrict, int); 57 | __END_DECLS 58 | 59 | #endif /* !_INTTYPES_H_ */ 60 | -------------------------------------------------------------------------------- /include/iso646.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1998 Alex Nash 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: release/9.0.0/include/iso646.h 226036 2011-10-05 15:50:05Z jkim $ 27 | */ 28 | 29 | #ifndef _ISO646_H_ 30 | #define _ISO646_H_ 31 | 32 | #ifndef __cplusplus 33 | 34 | #define and && 35 | #define and_eq &= 36 | #define bitand & 37 | #define bitor | 38 | #define compl ~ 39 | #define not ! 40 | #define not_eq != 41 | #define or || 42 | #define or_eq |= 43 | #define xor ^ 44 | #define xor_eq ^= 45 | 46 | #endif /* !__cplusplus */ 47 | 48 | #endif /* !_ISO646_H_ */ 49 | -------------------------------------------------------------------------------- /include/libgen.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: libgen.h,v 1.4 1999/05/28 22:00:22 espie Exp $ */ 2 | /* $FreeBSD: release/9.0.0/include/libgen.h 197804 2009-10-06 14:05:57Z rwatson $ */ 3 | 4 | /* 5 | * Copyright (c) 1997 Todd C. Miller 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 3. The name of the author may not be used to endorse or promote products 17 | * derived from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 21 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 22 | * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _LIBGEN_H_ 32 | #define _LIBGEN_H_ 33 | 34 | #include 35 | 36 | __BEGIN_DECLS 37 | 38 | char *basename(const char *); 39 | char *basename_r(const char *, char *); 40 | char *dirname(const char *); 41 | #if 0 42 | char *regcmp(const char *, ...); 43 | char *regex(const char *, const char *, ...); 44 | 45 | extern char *__loc1; 46 | #endif 47 | 48 | __END_DECLS 49 | 50 | #endif /* _LIBGEN_H_ */ 51 | -------------------------------------------------------------------------------- /include/machine/_align.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * This file is in the public domain. 3 | */ 4 | /* $FreeBSD: release/9.0.0/sys/amd64/include/_align.h 215856 2010-11-26 10:59:20Z tijl $ */ 5 | 6 | #include 7 | -------------------------------------------------------------------------------- /include/machine/_inttypes.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * This file is in the public domain. 3 | */ 4 | /* $FreeBSD: release/9.0.0/sys/amd64/include/_inttypes.h 217157 2011-01-08 18:09:48Z tijl $ */ 5 | 6 | #include 7 | -------------------------------------------------------------------------------- /include/machine/ptrace.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1992, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 4. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * @(#)ptrace.h 8.1 (Berkeley) 6/11/93 30 | * $FreeBSD: release/9.0.0/sys/amd64/include/ptrace.h 139731 2005-01-05 20:17:21Z imp $ 31 | */ 32 | 33 | #ifndef _MACHINE_PTRACE_H_ 34 | #define _MACHINE_PTRACE_H_ 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /include/machine/runq.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2001 Jake Burkholder 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: release/9.0.0/sys/amd64/include/runq.h 139731 2005-01-05 20:17:21Z imp $ 27 | */ 28 | 29 | #ifndef _MACHINE_RUNQ_H_ 30 | #define _MACHINE_RUNQ_H_ 31 | 32 | #define RQB_LEN (1) /* Number of priority status words. */ 33 | #define RQB_L2BPW (6) /* Log2(sizeof(rqb_word_t) * NBBY)). */ 34 | #define RQB_BPW (1<> RQB_L2BPW) 38 | 39 | #define RQB_FFS(word) (bsfq(word)) 40 | 41 | /* 42 | * Type of run queue status word. 43 | */ 44 | typedef u_int64_t rqb_word_t; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /include/machine/setjmp.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1998 John Birrell . 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the author nor the names of any co-contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * $FreeBSD: release/9.0.0/sys/amd64/include/setjmp.h 165967 2007-01-12 07:26:21Z imp $ 30 | */ 31 | 32 | #ifndef _MACHINE_SETJMP_H_ 33 | #define _MACHINE_SETJMP_H_ 34 | 35 | #include 36 | 37 | #define _JBLEN 12 /* Size of the jmp_buf on AMD64. */ 38 | 39 | /* 40 | * jmp_buf and sigjmp_buf are encapsulated in different structs to force 41 | * compile-time diagnostics for mismatches. The structs are the same 42 | * internally to avoid some run-time errors for mismatches. 43 | */ 44 | #if __BSD_VISIBLE || __POSIX_VISIBLE || __XSI_VISIBLE 45 | typedef struct _sigjmp_buf { long _sjb[_JBLEN]; } sigjmp_buf[1]; 46 | #endif 47 | 48 | typedef struct _jmp_buf { long _jb[_JBLEN]; } jmp_buf[1]; 49 | 50 | #endif /* !_MACHINE_SETJMP_H_ */ 51 | -------------------------------------------------------------------------------- /include/machine/vm.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2009 Advanced Computing Technologies LLC 3 | * Written by: John H. Baldwin 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | * SUCH DAMAGE. 26 | * 27 | * $FreeBSD: release/9.0.0/sys/amd64/include/vm.h 195649 2009-07-12 23:31:20Z alc $ 28 | */ 29 | 30 | #ifndef _MACHINE_VM_H_ 31 | #define _MACHINE_VM_H_ 32 | 33 | #include 34 | 35 | /* Memory attributes. */ 36 | #define VM_MEMATTR_UNCACHEABLE ((vm_memattr_t)PAT_UNCACHEABLE) 37 | #define VM_MEMATTR_WRITE_COMBINING ((vm_memattr_t)PAT_WRITE_COMBINING) 38 | #define VM_MEMATTR_WRITE_THROUGH ((vm_memattr_t)PAT_WRITE_THROUGH) 39 | #define VM_MEMATTR_WRITE_PROTECTED ((vm_memattr_t)PAT_WRITE_PROTECTED) 40 | #define VM_MEMATTR_WRITE_BACK ((vm_memattr_t)PAT_WRITE_BACK) 41 | #define VM_MEMATTR_UNCACHED ((vm_memattr_t)PAT_UNCACHED) 42 | 43 | #define VM_MEMATTR_DEFAULT VM_MEMATTR_WRITE_BACK 44 | 45 | #endif /* !_MACHINE_VM_H_ */ 46 | -------------------------------------------------------------------------------- /include/monetary.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2001 Alexey Zelkin 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: release/9.0.0/include/monetary.h 103667 2002-09-20 08:22:48Z mike $ 27 | */ 28 | 29 | #ifndef _MONETARY_H_ 30 | #define _MONETARY_H_ 31 | 32 | #include 33 | #include 34 | 35 | #ifndef _SIZE_T_DECLARED 36 | typedef __size_t size_t; 37 | #define _SIZE_T_DECLARED 38 | #endif 39 | 40 | #ifndef _SSIZE_T_DECLARED 41 | typedef __ssize_t ssize_t; 42 | #define _SSIZE_T_DECLARED 43 | #endif 44 | 45 | __BEGIN_DECLS 46 | ssize_t strfmon(char * __restrict, size_t, const char * __restrict, ...); 47 | __END_DECLS 48 | 49 | #endif /* !_MONETARY_H_ */ 50 | -------------------------------------------------------------------------------- /include/mqueue.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2005 David Xu 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: release/9.0.0/include/mqueue.h 165828 2007-01-06 11:30:04Z davidxu $ 27 | */ 28 | 29 | #ifndef _MQUEUE_H_ 30 | #define _MQUEUE_H_ 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | struct sigevent; 37 | struct timespec; 38 | 39 | __BEGIN_DECLS 40 | int mq_close(mqd_t); 41 | int mq_getattr(mqd_t, struct mq_attr *); 42 | int mq_notify(mqd_t, const struct sigevent *); 43 | mqd_t mq_open(const char *, int, ...); 44 | ssize_t mq_receive(mqd_t, char *, size_t, unsigned *); 45 | int mq_send(mqd_t, const char *, size_t, unsigned); 46 | int mq_setattr(mqd_t, const struct mq_attr *__restrict, 47 | struct mq_attr *__restrict); 48 | ssize_t mq_timedreceive(mqd_t, char *__restrict, size_t, 49 | unsigned *__restrict, const struct timespec *__restrict); 50 | int mq_timedsend(mqd_t, const char *, size_t, unsigned, 51 | const struct timespec *); 52 | int mq_unlink(const char *); 53 | int __mq_oshandle(mqd_t mqd); 54 | 55 | __END_DECLS 56 | #endif 57 | -------------------------------------------------------------------------------- /include/opt_compat.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /include/ps4/assembler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | int64_t ps4AssemblerSystemCall(); 7 | 8 | void ps4AssemblerRegisterParameterPush(); 9 | void ps4AssemblerRegisterParameterPop(); 10 | -------------------------------------------------------------------------------- /include/ps4/atomic.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | void ps4AtomicSwap64(uint64_t *atomic, uint64_t *swap); 6 | void ps4AtomicSwap32(uint32_t *atomic, uint32_t *swap); 7 | void ps4AtomicSwap16(uint16_t *atomic, uint16_t *swap); 8 | void ps4AtomicSwap8(uint8_t *atomic, uint8_t *swap); 9 | 10 | int ps4AtomicSpinLock64(uint64_t *atomic); 11 | int ps4AtomicSpinUnlock64(uint64_t *atomic); 12 | int ps4AtomicSpinLock32(uint32_t *atomic); 13 | int ps4AtomicSpinUnlock32(uint32_t *atomic); 14 | int ps4AtomicSpinLock16(uint16_t *atomic); 15 | int ps4AtomicSpinUnlock16(uint16_t *atomic); 16 | int ps4AtomicSpinLock8(uint8_t *atomic); 17 | int ps4AtomicSpinUnlock8(uint8_t *atomic); 18 | -------------------------------------------------------------------------------- /include/ps4/base.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /include/ps4/change.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /include/ps4/expression.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define Ps4ArgumentFirst(x, ...) x 4 | #define Ps4ArgumentRest(x, ...) __VA_ARGS__ 5 | 6 | #ifndef ps4ExpressionDoIf 7 | #define ps4ExpressionDoIf(expr, condition) \ 8 | if(condition) { expr; } 9 | #endif 10 | 11 | #ifndef ps4ExpressionReturnOnError 12 | #define ps4ExpressionReturnOnError(val) \ 13 | if(val) { return val; } 14 | #endif 15 | 16 | #ifndef ps4ExpressionReturnIf 17 | #define ps4ExpressionReturnIf(val, condition) \ 18 | if(condition) { return val; } 19 | #endif 20 | 21 | #ifndef ps4FunctionExecuteIf 22 | #define ps4FunctionExecuteIf(expr, condition) \ 23 | if(condition) { expr(); } 24 | #endif 25 | 26 | #ifndef ps4FunctionCallIf 27 | #define ps4FunctionCallIf(fn, condition, ...) \ 28 | if(condition) { fn(__VA_ARGS__); } 29 | #endif 30 | 31 | #ifndef ps4FunctionCallIfNotNull 32 | #define ps4FunctionCallIfNotNull(fn, arg) \ 33 | if(arg) { fn(arg); } 34 | #endif 35 | 36 | #ifndef ps4FunctionCallIfPrimaryNotNull 37 | #define ps4FunctionCallIfPrimaryNotNull(fn, ...) \ 38 | if(Ps4ArgumentFirst(__VA_ARGS__)) { fn(__VA_ARGS__); } 39 | #endif 40 | -------------------------------------------------------------------------------- /include/ps4/file.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /include/ps4/kernel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define _KERNEL 4 | #define _STANDALONE 5 | #define __BSD_VISIBLE 1 6 | 7 | #include 8 | #undef offsetof 9 | #include 10 | #include 11 | #include 12 | 13 | // these are not to be included directly, for now 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | -------------------------------------------------------------------------------- /include/ps4/kernel/base.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // base 4 | //{ 5 | void *ps4KernelSeekElfAddress(); 6 | void *ps4KernelDlSym(char *name); 7 | //} 8 | 9 | int ps4KernelBrewCoffee(); 10 | 11 | int ps4KernelIsKernelAddress(void *address); 12 | int ps4KernelIsInKernel(); 13 | 14 | extern int ps4KernelExecute(void *fn, void *uap, int64_t *ret0, int64_t *ret1); 15 | int64_t ps4KernelCall(); 16 | -------------------------------------------------------------------------------- /include/ps4/kernel/cache.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct Ps4KernelCache Ps4KernelCache; 4 | 5 | int ps4KernelCacheCreate(Ps4KernelCache **cache); 6 | int ps4KernelCacheDestroy(Ps4KernelCache *cache); 7 | 8 | int ps4KernelCacheGet(Ps4KernelCache *cache, const char *name, void **value); 9 | int ps4KernelCacheSet(Ps4KernelCache *cache, const char *name, void *value); 10 | int ps4KernelCacheDelete(Ps4KernelCache *cache, const char *name); 11 | -------------------------------------------------------------------------------- /include/ps4/kernel/cache_global.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | int ps4KernelCacheGlobalGet(char *name, void **value); 6 | int ps4KernelCacheGlobalSet(char *name, void *value); 7 | int ps4KernelCacheGlobalDelete(char *name); 8 | -------------------------------------------------------------------------------- /include/ps4/kernel/descriptor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int ps4KernelDescriptorWrite(struct thread *td, int fd, const void *data, size_t size); 4 | int ps4KernelDescriptorPrint(struct thread *td, int fd, const char *format, ...); 5 | -------------------------------------------------------------------------------- /include/ps4/kernel/memory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | int ps4KernelMemoryAllocate(void **memory, size_t size); 6 | int ps4KernelMemoryAllocateData(void **memory, size_t size); 7 | int ps4KernelMemoryReallocateData(void **memory, size_t size); 8 | void *ps4KernelMemoryMalloc(size_t size); 9 | void *ps4KernelMemoryMallocData(size_t size); 10 | int ps4KernelMemoryAllocateString(char **string, size_t *size, size_t sizeMax, const char *format, ...); 11 | int ps4KernelMemoryAllocateStringWithArgumentList(char **string, size_t *size, size_t sizeMax, const char *format, va_list args); 12 | int ps4KernelMemoryFree(void *memory); 13 | int ps4KernelMemoryCopy(void *from, void *to, size_t size); 14 | int ps4KernelMemorySwap(void *a, void *b, size_t size); 15 | int ps4KernelMemoryFill(void *memory, uint8_t byte, size_t size); 16 | int ps4KernelMemoryCompareNonZeros(void *a, void *b, size_t size); 17 | -------------------------------------------------------------------------------- /include/ps4/kernel/privilege.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void ps4KernelPrivilegeRoot(); 4 | int ps4KernelPrivilegeUnjail(); 5 | int ps4KernelPrivilegeEscalate(); 6 | -------------------------------------------------------------------------------- /include/ps4/kernel/protection.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void ps4KernelProtectionWriteDisable(); 4 | void ps4KernelProtectionWriteEnable(); 5 | void ps4KernelProtectionExecuteDisable(); 6 | void ps4KernelProtectionExecuteEnable(); 7 | void ps4KernelProtectionAllDisable(); 8 | void ps4KernelProtectionAllEnable(); 9 | -------------------------------------------------------------------------------- /include/ps4/kernel/register.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int ps4KernelRegisterControlSet(unsigned int c, unsigned long value); 4 | int ps4KernelRegisterControlGet(unsigned int c, unsigned long *value); 5 | 6 | void ps4KernelRegisterModelSpecificSet(unsigned int msr, uint64_t value); 7 | int ps4KernelRegisterModelSpecificGet(unsigned int msr, uint64_t *value); 8 | -------------------------------------------------------------------------------- /include/ps4/kernel/socket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | typedef struct socket Ps4KernelSocket; 8 | 9 | int ps4KernelSocketCreate(struct thread *td, Ps4KernelSocket **sock, int domain, int type, int protocol); 10 | int ps4KernelSocketTCPCreate(struct thread *td, Ps4KernelSocket **sock); 11 | int ps4KernelSocketTCPServerCreate(struct thread *td, Ps4KernelSocket **oserver, int port, int backlog); 12 | int ps4KernelSocketTCPServerCreateAcceptThenDestroy(struct thread *td, Ps4KernelSocket **client, int port); 13 | int ps4KernelSocketClose(Ps4KernelSocket *sock); 14 | int ps4KernelSocketDestroy(Ps4KernelSocket *sock); 15 | 16 | int ps4KernelSocketBind(struct thread *td, Ps4KernelSocket *sock, struct sockaddr *address); 17 | int ps4KernelSocketAddressGet(Ps4KernelSocket *sock, struct sockaddr **address, socklen_t *address_len); 18 | int ps4KernelSocketOptionSet(Ps4KernelSocket *sock, int level, int name, void *value, socklen_t valueSize); 19 | int ps4KernelSocketAccept(Ps4KernelSocket *server, Ps4KernelSocket **client); 20 | int ps4KernelSocketListen(struct thread *td, Ps4KernelSocket *fd, int backlog); 21 | 22 | int ps4KernelSocketPrintSizedWithArgumentList(struct thread *td, Ps4KernelSocket *sock, size_t sz, const char *format, va_list args); 23 | int ps4KernelSocketPrintWithArgumentList(struct thread *td, Ps4KernelSocket *sock, const char *format, va_list args); 24 | int ps4KernelSocketPrint(struct thread *td, Ps4KernelSocket *sock, const char *format, ...); 25 | int ps4KernelSocketPrintHexDump(struct thread *td, Ps4KernelSocket *sock, const void *data, size_t size); 26 | int ps4KernelSocketSend(struct thread *td, Ps4KernelSocket *sock, const void *data, size_t size); 27 | 28 | int ps4KernelSocketReceiveString(struct thread *td, Ps4KernelSocket *sock, void **data, size_t *size, size_t sizeMax); 29 | 30 | int ps4KernelSocketScanSizedWithArgumentList(struct thread *td, Ps4KernelSocket *sock, size_t size, int *match, const char *format, va_list args); 31 | int ps4KernelSocketScanWithArgumentList(struct thread *td, Ps4KernelSocket *sock, int *match, const char *format, va_list args); 32 | int ps4KernelSocketScan(struct thread *td, Ps4KernelSocket *sock, int *match, const char *format, ...); 33 | int ps4KernelSocketReceive(Ps4KernelThread *td, Ps4KernelSocket *sock, const void *data, size_t *size, size_t sizeMax, int flags); 34 | -------------------------------------------------------------------------------- /include/ps4/kernel/symbol.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int ps4KernelSymbolLookUp(const char *str, void **value); 4 | -------------------------------------------------------------------------------- /include/ps4/kernel/system_call.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #undef offsetof 4 | #include 5 | 6 | typedef enum Ps4KernelSystemCallHookType 7 | { 8 | PS4_KERNEL_SYSTEM_CALL_HOOK_TYPE_PRE = -1, 9 | PS4_KERNEL_SYSTEM_CALL_HOOK_TYPE_DISABLED = 0, 10 | PS4_KERNEL_SYSTEM_CALL_HOOK_TYPE_GENERIC_PRE = 1, 11 | PS4_KERNEL_SYSTEM_CALL_HOOK_TYPE_GENERIC_POST = 2, 12 | PS4_KERNEL_SYSTEM_CALL_HOOK_TYPE_GENERIC_BOTH = 3 13 | } 14 | Ps4KernelSystemCallHookType; 15 | 16 | typedef enum Ps4KernelSystemCallHookControl 17 | { 18 | PS4_KERNEL_SYSTEM_CALL_HOOK_CONTROL_BREAK = 1, 19 | PS4_KERNEL_SYSTEM_CALL_HOOK_CONTROL_CONTINUE = 0, 20 | PS4_KERNEL_SYSTEM_CALL_HOOK_CONTROL_RETURN = -1, 21 | } 22 | Ps4KernelSystemCallHookControl; 23 | 24 | #define PS4_KERNEL_SYSTEM_CALL_HOOK_CONTROL_PERFORM_CALL PS4_KERNEL_SYSTEM_CALL_HOOK_CONTROL_BREAK 25 | #define PS4_KERNEL_SYSTEM_CALL_HOOK_CONTROL_NEXT_HOOK PS4_KERNEL_SYSTEM_CALL_HOOK_CONTROL_CONTINUE 26 | #define PS4_KERNEL_SYSTEM_CALL_HOOK_CONTROL_INTERCEPT_CALL PS4_KERNEL_SYSTEM_CALL_HOOK_CONTROL_RETURN 27 | 28 | typedef void *Ps4SystemCallHookAllocate(size_t, void *, int); 29 | typedef void Ps4SystemCallHookFree(void *, void *); 30 | 31 | typedef struct Ps4KernelSystemCallHookArgument 32 | { 33 | // asm begin 34 | void *clone; 35 | sy_call_t *handler; 36 | void *thread; 37 | int64_t entryCount; 38 | int64_t callCount; 39 | uint64_t lock; 40 | // asm end 41 | 42 | sy_call_t *prologue; 43 | 44 | void *uap; 45 | int sysret; 46 | register_t returns[2]; 47 | sy_call_t *originalCall; 48 | struct sysent *systemCalls; 49 | int64_t number; 50 | 51 | sy_call_t **hook; 52 | int64_t *hookType; 53 | int64_t hookCount; 54 | int64_t hookSize; 55 | int64_t hookTypeCurrent; 56 | 57 | void *userArgument; 58 | 59 | Ps4SystemCallHookAllocate *allocate; 60 | Ps4SystemCallHookFree *free; 61 | void *mt; 62 | } 63 | Ps4KernelSystemCallHookArgument; 64 | 65 | typedef struct Ps4KernelSystemCallHook Ps4KernelSystemCallHook; 66 | 67 | int ps4KernelSystemCallPatch(int number, sy_call_t *call, int argumentCount); 68 | int ps4KernelSystemCallPatchUnsafe(int number, sy_call_t *call, int argumentCount); 69 | int ps4KernelSystemCallCopyInAndPatch(int number, sy_call_t *call, size_t size, int argumentCount); 70 | 71 | int ps4KernelSystemCallHook(int number, sy_call_t *hook); 72 | int ps4KernelSystemCallUnhook(int number); 73 | 74 | int ps4KernelSystemCallHookCreate(Ps4KernelSystemCallHook **hookh, int number); 75 | int ps4KernelSystemCallHookDestroy(Ps4KernelSystemCallHook *hookh); 76 | int ps4KernelSystemCallHookAdd(Ps4KernelSystemCallHook *hookh, void *hook, Ps4KernelSystemCallHookType type); 77 | -------------------------------------------------------------------------------- /include/ps4/kernel/thread.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct thread Ps4KernelThread; 4 | 5 | int ps4KernelThreadGetCurrent(Ps4KernelThread **td); 6 | 7 | int ps4KernelThreadGetReturn(Ps4KernelThread *td, register_t *ret); 8 | int ps4KernelThreadGetPrimaryReturn(Ps4KernelThread *td, register_t *ret); 9 | int ps4KernelThreadGetSecondaryReturn(Ps4KernelThread *td, register_t *ret); 10 | 11 | int ps4KernelThreadSetReturn(Ps4KernelThread *td, register_t ret); 12 | int ps4KernelThreadSetPrimaryReturn(Ps4KernelThread *td, register_t ret); 13 | int ps4KernelThreadSetSecondaryReturn(Ps4KernelThread *td, register_t ret); 14 | -------------------------------------------------------------------------------- /include/ps4/kernel/uart.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int ps4KernelUartEnable(); 4 | int ps4KernelUartDisable(); 5 | -------------------------------------------------------------------------------- /include/ps4/limit.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define PS4_LIMIT_STRING_LENGTH_MAXIMUM 4096 4 | -------------------------------------------------------------------------------- /include/ps4/machine.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | int ps4MachineInstructionNext(void *current, void **next); 6 | int ps4MachineInstructionSeek(void *current, void **found, size_t offset); 7 | -------------------------------------------------------------------------------- /include/ps4/memory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | -------------------------------------------------------------------------------- /include/ps4/memory/memory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | typedef struct Ps4Memory Ps4Memory; 8 | 9 | int ps4UserMemoryAllocate(void **memory, size_t size); 10 | void *ps4UserMemoryMalloc(size_t size); 11 | int ps4UserMemoryFree(void *memory); 12 | 13 | int ps4MemoryAllocate(void **memory, size_t size); 14 | int ps4MemoryAllocateData(void **memory, size_t size); 15 | void *ps4MemoryMalloc(size_t size); 16 | int ps4MemoryFree(void *memory); 17 | 18 | /* 19 | int ps4MemoryCreate(Ps4Memory **memory, size_t size); 20 | int ps4MemoryDestroy(Ps4Memory *memory); 21 | int ps4MemoryGetAddress(Ps4Memory *memory, void **address); 22 | int ps4MemoryGetSize(Ps4Memory *memory, size_t *size); 23 | */ 24 | 25 | int ps4MemoryAllocateFromFileWithoutSize(void **memory, size_t *size, int fd); 26 | int ps4MemoryAllocateFileFromPathAligned(void **memory, size_t *size, char *file, size_t alignment); 27 | -------------------------------------------------------------------------------- /include/ps4/memory/protected.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | typedef struct Ps4MemoryProtected Ps4MemoryProtected; 8 | 9 | int ps4MemoryProtectedCreate(Ps4MemoryProtected **memory, size_t size); 10 | int ps4MemoryProtectedDestroy(Ps4MemoryProtected *memory); 11 | int ps4MemoryProtectedGetWritableAddress(Ps4MemoryProtected *memory, void **address); 12 | int ps4MemoryProtectedGetExecutableAddress(Ps4MemoryProtected *memory, void **address); 13 | int ps4MemoryProtectedGetSize(Ps4MemoryProtected *memory, size_t *size); 14 | -------------------------------------------------------------------------------- /include/ps4/memory/shared.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | typedef struct Ps4MemoryShared Ps4MemoryShared; 8 | 9 | int ps4MemorySharedOpen(Ps4MemoryShared **memory, size_t size, const char *path); 10 | int ps4MemorySharedClose(Ps4MemoryShared *memory); 11 | int ps4MemorySharedUnlink(Ps4MemoryShared *memory); 12 | int ps4MemorySharedGetAddress(Ps4MemoryShared *memory, void **address); 13 | int ps4MemorySharedGetSize(Ps4MemoryShared *memory, size_t *size); 14 | -------------------------------------------------------------------------------- /include/ps4/payload.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | extern int ps4PayloadFunctionHookHandlerSize; 6 | void ps4PayloadFunctionHookHandler(); 7 | 8 | extern int ps4PayloadLockSize; 9 | void ps4PayloadLock(); 10 | 11 | Ps4KernelSystemCallHookArgument *ps4PayloadSystemCallHookArgumentClone(struct thread *td, Ps4KernelSystemCallHookArgument *uap, void *sysuap); 12 | int ps4PayloadSystemCallHookHandler(struct thread *td, Ps4KernelSystemCallHookArgument *uap); 13 | 14 | Ps4KernelFunctionHookArgument *ps4PayloadFunctionHookArgumentClone(Ps4KernelFunctionHookArgument *uap, Ps4RegisterParameters *args); 15 | void ps4PayloadFunctionHookArgumentDestroy(Ps4KernelFunctionHookArgument *uap); 16 | -------------------------------------------------------------------------------- /include/ps4/payload/template.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | extern int ps4PayloadTemplateReturn64Size; 6 | register_t ps4PayloadTemplateReturn64(); 7 | extern int ps4PayloadTemplateReturn32Size; 8 | register_t ps4PayloadTemplateReturn32(); 9 | extern int ps4PayloadTemplateReturnZeroSize; 10 | register_t ps4PayloadTemplateReturnZero(); 11 | 12 | extern int ps4PayloadTemplateJump64Size; 13 | register_t ps4PayloadTemplateJump64(); 14 | extern int ps4PayloadTemplateJump32Size; 15 | register_t ps4PayloadTemplateJump32(); 16 | 17 | extern int ps4PayloadTemplateFunctionHookPrologueSize; 18 | register_t ps4PayloadTemplateFunctionHookPrologue(); 19 | 20 | extern int ps4PayloadTemplateSystemCallHookPrologueSize; 21 | register_t ps4PayloadTemplateSystemCallHookPrologue(); 22 | 23 | int ps4PayloadReturnExtractValue(uint8_t *memory, int64_t *value); 24 | int ps4PayloadReturnIsPatched(uint8_t *memory); 25 | int ps4PayloadReturnPatch(uint8_t *memory, int64_t value); 26 | int ps4PayloadReturnDeterminePatchSize(int64_t value, size_t *size); 27 | 28 | int ps4PayloadJumpExtractTarget(uint8_t *memory, void **to); 29 | int ps4PayloadJumpIsPatched(uint8_t *memory); 30 | int ps4PayloadJumpPatch(uint8_t *memory, void *to); 31 | int ps4PayloadJumpDeterminePatchSize(void *to, size_t *size); 32 | 33 | int ps4PayloadFunctionHookPrologueExtractArgument(uint8_t *memory, Ps4KernelFunctionHookArgument **argument); 34 | int ps4PayloadFunctionHookPrologueIsPatched(uint8_t *memory); 35 | int ps4PayloadFunctionHookProloguePatch(uint8_t *memory, Ps4KernelFunctionHookArgument *argument); 36 | int ps4PayloadFunctionHookPrologueDeterminePatchSize(size_t *size); 37 | 38 | int ps4PayloadSystemCallHookPrologueExtractArgument(uint8_t *memory, Ps4KernelSystemCallHookArgument **argument); 39 | int ps4PayloadSystemCallHookPrologueIsPatched(uint8_t *memory); 40 | int ps4PayloadSystemCallHookProloguePatch(uint8_t *memory, Ps4KernelSystemCallHookArgument *argument); 41 | int ps4PayloadSystemCallHookPrologueDeterminePatchSize(size_t *size); 42 | 43 | int ps4PayloadHiddenInformationExtractData(uint8_t *memory, void **data, size_t *size); 44 | int ps4PayloadHiddenInformationIsPatched(uint8_t *memory); 45 | int ps4PayloadHiddenInformationPatch(uint8_t *memory, void *data, uint8_t size); 46 | int ps4PayloadHiddenInformationDeterminePatchSize(size_t *size); 47 | -------------------------------------------------------------------------------- /include/ps4/ps4.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /include/ps4/socket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int ps4SocketTCPServerCreate(int *server, int port, int backlog); 4 | int ps4SocketTCPServerCreateAcceptThenDestroy(int *client, int port); 5 | -------------------------------------------------------------------------------- /include/ps4/standard_io.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void ps4StandardIoRedirect(int to); 4 | int ps4StandardIoPrintHexDump(const void *data, size_t size); 5 | -------------------------------------------------------------------------------- /include/ps4/stream.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | int ps4StreamOpenFileDuplicate(FILE **file, int fd, const char *mode); 7 | -------------------------------------------------------------------------------- /include/ps4/stub_resolve.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | int ps4KernelStubResolve(void *stub, char *functionName, void **kernelAddress); 6 | int ps4StubResolve(void *stub, char *moduleName, char *functionName, int *moduleHandle, void **userAddress); 7 | int ps4AdaptiveStubResolve(void *stub, char *moduleName, char *functionName, int *moduleHandle, void **userAddress, void **kernelAddress); 8 | -------------------------------------------------------------------------------- /include/ps4/system_call.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef struct Ps4SystemCallGenericCallArgument 6 | { 7 | void *function; 8 | union 9 | { 10 | struct 11 | { 12 | register_t rdi; 13 | register_t rsi; 14 | register_t rdx; 15 | register_t rcx; 16 | register_t r8; 17 | register_t r9; 18 | }; 19 | register_t argument[6]; 20 | }; 21 | register_t returns; 22 | } 23 | Ps4SystemCallGenericCallArgument; 24 | 25 | typedef struct Ps4SystemCallGenericExecuteArgument 26 | { 27 | void *function; 28 | void *uap; 29 | register_t *returns[2]; 30 | } 31 | Ps4SystemCallGenericExecuteArgument; 32 | 33 | typedef struct Ps4SystemCallHookArgument Ps4SystemCallGenericHookArgument; 34 | 35 | int ps4SystemCallGenericExecute(struct thread *td, Ps4SystemCallGenericExecuteArgument *uap); 36 | int ps4SystemCallGenericCall(struct thread *td, Ps4SystemCallGenericCallArgument *uap); 37 | int ps4SystemCallGenericHook(struct thread *td, Ps4SystemCallGenericHookArgument *uap); 38 | -------------------------------------------------------------------------------- /include/ps4/type.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef int8_t Ps4Integer8; 4 | typedef int16_t Ps4Integer16; 5 | typedef int32_t Ps4Integer32; 6 | typedef int64_t Ps4Integer64; 7 | 8 | typedef uint8_t Ps4UnsignedInteger8; 9 | typedef uint16_t Ps4UnsignedInteger16; 10 | typedef uint32_t Ps4UnsignedInteger32; 11 | typedef uint64_t Ps4UnsignedInteger64; 12 | -------------------------------------------------------------------------------- /include/ps4/util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | int ps4MemoryAllocateFileWithoutSize(void **memory, size_t *size, int fd); 7 | int ps4MemoryAllocateFileFromPathAligned(void **memory, size_t *size, char *file, size_t alignment); 8 | -------------------------------------------------------------------------------- /include/sce/camera.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | /* psxdev reversal */ 7 | int sceCameraClose(int handle); 8 | int sceCameraGetConfig(int handle, SceCameraConfig *config); 9 | int sceCameraGetDeviceConfig(int handle, SceCameraConfig *config); 10 | int sceCameraGetDeviceInfo(int handle, SceCameraDeviceInfo *info); 11 | int sceCameraGetFrameData(int handle, SceCameraFrameData *frame); 12 | int sceCameraIsAttached(int index); 13 | int sceCameraOpen(int userid, int type, int index, void *); 14 | int sceCameraSetConfig(int handle, SceCameraConfig *config); 15 | int sceCameraStart(int handle, SceCameraStartParameter *param); 16 | int sceCameraStop(int handle); 17 | 18 | /* released debug output */ 19 | int64_t sceCameraProcConfigStop(); 20 | int64_t sceCameraDevStop(); 21 | 22 | /* guessed from sceCameraSetCalibData */ 23 | int64_t sceCameraGetCalibrationData(); 24 | 25 | /* psxdev unreversed */ 26 | int64_t sceCameraAudioOpen(); 27 | int64_t sceCameraCloseByHandle(); 28 | int64_t sceCameraGetAttribute(); 29 | int64_t sceCameraGetAutoExposureGain(); 30 | int64_t sceCameraGetAutoWhiteBalance(); 31 | int64_t sceCameraGetContrast(); 32 | int64_t sceCameraGetDefectivePixelCancellation(); 33 | int64_t sceCameraGetExposureGain(); 34 | int64_t sceCameraGetGamma(); 35 | int64_t sceCameraGetHue(); 36 | int64_t sceCameraGetLensCorrection(); 37 | int64_t sceCameraGetSaturation(); 38 | int64_t sceCameraGetSharpness(); 39 | int64_t sceCameraGetWhiteBalance(); 40 | int64_t sceCameraIsValidFrameData(); 41 | int64_t sceCameraOpenByModuleId(); 42 | int64_t sceCameraSetAttribute(); 43 | int64_t sceCameraSetAutoExposureGain(); 44 | int64_t sceCameraSetAutoWhiteBalance(); 45 | int64_t sceCameraSetCalibData(); 46 | int64_t sceCameraSetConfigInternal(); 47 | int64_t sceCameraSetContrast(); 48 | int64_t sceCameraSetDefectivePixelCancellation(); 49 | int64_t sceCameraSetExposureGain(); 50 | int64_t sceCameraSetGamma(); 51 | int64_t sceCameraSetHue(); 52 | int64_t sceCameraSetLensCorrection(); 53 | int64_t sceCameraSetSaturation(); 54 | int64_t sceCameraSetSharpness(); 55 | int64_t sceCameraSetWhiteBalance(); 56 | int64_t sceCameraStartByHandle(); 57 | int64_t sceCameraStopByHandle(); 58 | -------------------------------------------------------------------------------- /include/sce/kern.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // lets put kern functions here and in the subfolder (see ps4 folder structure) 4 | -------------------------------------------------------------------------------- /include/sce/kernel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | /* useless C / POSIX wrappers */ 8 | int sceKernelGetCurrentCpu(void); 9 | int sceKernelGettimeofday(SceKernelTimeval *tp); 10 | int sceKernelUsleep(unsigned int microseconds); 11 | int scePthreadCancel(ScePthread thread); 12 | int scePthreadCreate(ScePthread *thread, const ScePthreadAttr *attr, void *(*entry)(void *), void *arg, const char *name); 13 | int scePthreadDetach(ScePthread thread); 14 | int scePthreadJoin(ScePthread thread, void **value_ptr); 15 | int scePthreadMutexDestroy(ScePthreadMutex *mutex); 16 | int scePthreadMutexInit(ScePthreadMutex *mutex, const ScePthreadMutexattr *attr, const char *name); 17 | int scePthreadMutexLock(ScePthreadMutex *mutex); 18 | int scePthreadMutexTimedlock(ScePthreadMutex *mutex, SceKernelUseconds usec); 19 | int scePthreadMutexTrylock(ScePthreadMutex *mutex); 20 | int scePthreadMutexUnlock(ScePthreadMutex *mutex); 21 | ScePthread scePthreadSelf(void); 22 | uint64_t sceKernelGetProcessTime(void); 23 | unsigned int sceKernelSleep(unsigned int seconds); 24 | void scePthreadExit(void *value); 25 | void scePthreadYield(void); 26 | 27 | int sceKernelCreateEqueue(SceKernelEqueue *eq, const char *name); 28 | int sceKernelDeleteEqueue(SceKernelEqueue eq); 29 | int sceKernelAddUserEvent(SceKernelEqueue eq, int id); 30 | int sceKernelAddReadEvent(SceKernelEqueue eq, int fd, size_t size, void *data); 31 | 32 | /* more interresting wrappers */ 33 | int sceKernelAllocateDirectMemory(off_t searchStart, off_t searchEnd, size_t length, size_t alignment, int type, off_t *physicalAddressDestination); 34 | int sceKernelMapDirectMemory(void **addr, size_t length, int protection, int flags, off_t start, size_t alignment); 35 | 36 | /* sce own syscall wrappers (usefull) */ 37 | int sceKernelLoadStartModule(const char *name, size_t argc, const void *argv, uint32_t flags, void *, int *result); 38 | int sceKernelDlsym(SceKernelModule handle, const char *symbol, void **address); 39 | int sceKernelGetModuleList(SceKernelModule *array, size_t size, size_t *available); 40 | int sceKernelGetModuleInfo(SceKernelModule handle, SceKernelModuleInfo *info); 41 | int sceKernelStopUnloadModule(SceKernelModule handle, size_t argc, const void *argv, uint32_t flags, void *, int *result); 42 | 43 | int sceKernelJitCreateSharedMemory(int flags, size_t size, int protection, int *destinationHandle); 44 | int sceKernelJitCreateAliasOfSharedMemory(int handle, int protection, int *destinationHandle); 45 | int sceKernelJitMapSharedMemory(int handle, int protection, void **destination); 46 | -------------------------------------------------------------------------------- /include/sce/libc_internal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /include/sce/net.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | /* useless C / POSIX wrappers */ 7 | const char sceNetInetNtop(int af, const void *src, char *dst, int size); 8 | int sceNetAccept(int, struct sockaddr *, unsigned int *); 9 | int sceNetBind(int, struct sockaddr *, int); 10 | int sceNetConnect(int, struct sockaddr *, int); 11 | int sceNetGetsockname(int, struct sockaddr *, unsigned int *); 12 | int sceNetGetsockopt(int s, int level, int optname, void *restrict optval, socklen_t *restrict optlen); 13 | int sceNetInetPton(int af, const char *src, void *dst); 14 | int sceNetListen(int, int); 15 | int sceNetRecv(int, void *, size_t, int); 16 | int sceNetSend(int, const void *, size_t, int); 17 | int sceNetSetsockopt(int s, int level, int optname, const void *optval, socklen_t optlen); 18 | int sceNetSocket(const char *, int, int, int); 19 | int sceNetSocketAbort(int , int ); 20 | int sceNetSocketClose(int); 21 | uint16_t sceNetHtons(uint16_t host16); 22 | uint16_t sceNetNtohs(uint16_t net16); 23 | uint32_t sceNetHtonl(uint32_t host32); 24 | uint32_t sceNetNtohl(uint32_t net32); 25 | uint64_t sceNetHtonll(uint64_t host64); 26 | uint64_t sceNetNtohll(uint64_t net64); 27 | -------------------------------------------------------------------------------- /include/sce/pad.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | int scePadInit(void); 7 | int scePadOpen(int userID, int, int, void *); 8 | int scePadClose(int handle); 9 | int scePadRead(int handle, void *data, int count); 10 | int scePadReadState(int handle, void *data); 11 | 12 | /* unreversed */ 13 | int64_t scePadResetOrientation(); 14 | int64_t scePadSetAngularVelocityDeadbandState(); 15 | int64_t scePadSetLightBar(); 16 | int64_t scePadSetMotionSensorState(); 17 | int64_t scePadSetTiltCorrectionState(); 18 | int64_t scePadSetVibration(); 19 | -------------------------------------------------------------------------------- /include/sce/sysmodule.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | int sceSysmoduleIsLoaded(uint16_t id); 6 | int sceSysmoduleLoadModule(uint16_t id); 7 | int sceSysmoduleUnloadModule(uint16_t id); 8 | -------------------------------------------------------------------------------- /include/sce/types/camera.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | //from libSceCamera.sprx firmware 1.76. Other can change 6 | typedef struct SceCameraStartParameter 7 | { 8 | uint32_t size; //0x0 <- set to 0x18 before call 24 bytes it is a check hardcoded in libSceCamera.sprx 9 | uint32_t unknown1;//0x4 10 | uint32_t unknown2;//0x8 11 | void * unknown3;//0xc 12 | } 13 | SceCameraStartParameter; 14 | 15 | typedef struct SceCameraFrameData 16 | { 17 | uint32_t size; //0x0 <- set to size< 0xb1+0x158=0x209 (521) it is a check hardcoded in libSceCamera.sprx.I suppose size 520 it's the worst case to pass the check 18 | uint32_t unknown1;//0x4 19 | uint32_t unknown2[32];//0x8 20 | void* pleft[4];//0x88 video frame pointers for left camera 4 resolution modes 21 | void* pright[4];//0xa8 video frame pointers for right camera 4 resolution modes 22 | uint32_t sizeleft[4]; //0xc8 video frame size for left camera 4 resolution modes 23 | uint32_t sizeright[4];//0xd8 video frame size for right camera 4 resolution modes 24 | uint32_t statusleft;//0xe8 25 | uint32_t statusright;//0xec 26 | uint32_t unknown3[70];//0xf0 27 | } 28 | SceCameraFrameData; 29 | 30 | typedef struct SceCameraDeviceInfo 31 | { 32 | uint32_t size; //0x0 <- set to 0x10 before call 24 bytes it is a check hardcoded in libSceCamera.sprx 33 | uint32_t revision;//0x4 <- check set to 0x1 before call 34 | uint32_t unknown1;//0x8 35 | uint32_t unknown2;//0xc 36 | } 37 | SceCameraDeviceInfo; 38 | 39 | typedef struct SceCameraConfig 40 | { 41 | uint32_t size; //0x0 <- set to 0x68 it is a check hardcoded in libSceCamera.sprx 42 | uint32_t unknown[100]; //0x4 43 | } 44 | SceCameraConfig; 45 | -------------------------------------------------------------------------------- /include/sce/types/kernel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #ifndef MAP_TYPE 7 | #define MAP_TYPE 0x0f 8 | #endif 9 | 10 | typedef struct SceKernelModuleSegmentInfo 11 | { 12 | void *address; 13 | uint32_t size; 14 | int32_t prot; 15 | } 16 | SceKernelModuleSegmentInfo; 17 | 18 | typedef struct SceKernelModuleInfo 19 | { 20 | size_t size; 21 | char name[256]; 22 | SceKernelModuleSegmentInfo segmentInfo[4]; 23 | uint32_t segmentCount; 24 | uint8_t fingerprint[20]; 25 | } 26 | SceKernelModuleInfo; 27 | 28 | typedef struct timeval SceKernelTimeval; 29 | typedef unsigned int SceKernelUseconds; 30 | typedef void *ScePthread; 31 | typedef void *ScePthreadAttr; 32 | typedef void *ScePthreadMutex; 33 | typedef void *ScePthreadMutexattr; 34 | typedef uint32_t SceKernelModule; 35 | 36 | typedef uint64_t SceKernelEqueue; 37 | -------------------------------------------------------------------------------- /include/sce/usbd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | int sceUsbdInit(void); 7 | void sceUsbdExit(void); 8 | 9 | ssize_t sceUsbdGetDeviceList(libusb_device ***list); 10 | void sceUsbdFreeDeviceList(libusb_device **list, int unrefDevices); 11 | 12 | int sceUsbdGetDeviceDescriptor(libusb_device *device, libusb_device_descriptor *desc); 13 | 14 | int sceUsbdOpen(libusb_device *dev, libusb_device_handle **devh); 15 | libusb_device_handle *sceUsbdOpenDeviceWithVidPid(unsigned short vendorId, unsigned short productId); 16 | void sceUsbdClose(libusb_device_handle *devh); 17 | 18 | int sceUsbdSetInterfaceAltSetting(libusb_device_handle *dev, int interface_number, int alternate_setting); 19 | int sceUsbdClearHalt(libusb_device_handle *devh, unsigned char endpoint); 20 | int sceUsbdResetDevice(libusb_device_handle *devh); 21 | int sceUsbdCheckConnected(libusb_device_handle *devh); 22 | 23 | int sceUsbdControlTransfer(libusb_device_handle *devh, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, unsigned char *data, uint16_t wLength, unsigned int timeout); 24 | int sceUsbdBulkTransfer(struct libusb_device_handle *devh, unsigned char endpoint, unsigned char *data, int length, int *transferred, unsigned int timeout); 25 | int sceUsbdInterruptTransfer(struct libusb_device_handle *devh, unsigned char endpoint, unsigned char *data, int length, int *transferred, unsigned int timeout); 26 | 27 | int sceUsbdGetActiveConfigDescriptor(libusb_device *dev, struct libusb_config_descriptor **config); 28 | int sceUsbdGetConfigDescriptor(libusb_device *dev, uint8_t config_index, struct libusb_config_descriptor **config); 29 | int sceUsbdGetConfigDescriptorByValue(libusb_device *dev, uint8_t bConfigurationValue, struct libusb_config_descriptor **config); 30 | void sceUsbdFreeConfigDescriptor(struct libusb_config_descriptor *config); 31 | -------------------------------------------------------------------------------- /include/search.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Written by J.T. Conklin 3 | * Public domain. 4 | * 5 | * $NetBSD: search.h,v 1.12 1999/02/22 10:34:28 christos Exp $ 6 | * $FreeBSD: release/9.0.0/include/search.h 105250 2002-10-16 14:29:23Z robert $ 7 | */ 8 | 9 | #ifndef _SEARCH_H_ 10 | #define _SEARCH_H_ 11 | 12 | #include 13 | #include 14 | 15 | #ifndef _SIZE_T_DECLARED 16 | typedef __size_t size_t; 17 | #define _SIZE_T_DECLARED 18 | #endif 19 | 20 | typedef struct entry { 21 | char *key; 22 | void *data; 23 | } ENTRY; 24 | 25 | typedef enum { 26 | FIND, ENTER 27 | } ACTION; 28 | 29 | typedef enum { 30 | preorder, 31 | postorder, 32 | endorder, 33 | leaf 34 | } VISIT; 35 | 36 | #ifdef _SEARCH_PRIVATE 37 | typedef struct node { 38 | char *key; 39 | struct node *llink, *rlink; 40 | } node_t; 41 | 42 | struct que_elem { 43 | struct que_elem *next; 44 | struct que_elem *prev; 45 | }; 46 | #endif 47 | 48 | __BEGIN_DECLS 49 | int hcreate(size_t); 50 | void hdestroy(void); 51 | ENTRY *hsearch(ENTRY, ACTION); 52 | void insque(void *, void *); 53 | void *lfind(const void *, const void *, size_t *, size_t, 54 | int (*)(const void *, const void *)); 55 | void *lsearch(const void *, void *, size_t *, size_t, 56 | int (*)(const void *, const void *)); 57 | void remque(void *); 58 | void *tdelete(const void * __restrict, void ** __restrict, 59 | int (*)(const void *, const void *)); 60 | void *tfind(const void *, void * const *, 61 | int (*)(const void *, const void *)); 62 | void *tsearch(const void *, void **, int (*)(const void *, const void *)); 63 | void twalk(const void *, void (*)(const void *, VISIT, int)); 64 | __END_DECLS 65 | 66 | #endif /* !_SEARCH_H_ */ 67 | -------------------------------------------------------------------------------- /include/semaphore.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 David Xu 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice unmodified, this list of conditions, and the following 11 | * disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * $FreeBSD: release/9.0.0/include/semaphore.h 201546 2010-01-05 02:37:59Z davidxu $ 28 | */ 29 | 30 | /* semaphore.h: POSIX 1003.1b semaphores */ 31 | 32 | #ifndef _SEMAPHORE_H_ 33 | #define _SEMAPHORE_H_ 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | struct _sem { 40 | __uint32_t _magic; 41 | struct _usem _kern; 42 | }; 43 | 44 | typedef struct _sem sem_t; 45 | 46 | #define SEM_FAILED ((sem_t *)0) 47 | #define SEM_VALUE_MAX __INT_MAX 48 | 49 | struct timespec; 50 | 51 | __BEGIN_DECLS 52 | int sem_close(sem_t *); 53 | int sem_destroy(sem_t *); 54 | int sem_getvalue(sem_t * __restrict, int * __restrict); 55 | int sem_init(sem_t *, int, unsigned int); 56 | sem_t *sem_open(const char *, int, ...); 57 | int sem_post(sem_t *); 58 | int sem_timedwait(sem_t * __restrict, const struct timespec * __restrict); 59 | int sem_trywait(sem_t *); 60 | int sem_unlink(const char *); 61 | int sem_wait(sem_t *); 62 | __END_DECLS 63 | 64 | #endif /* !_SEMAPHORE_H_ */ 65 | -------------------------------------------------------------------------------- /include/stdbool.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000 Jeroen Ruigrok van der Werven 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: release/9.0.0/include/stdbool.h 142088 2005-02-19 13:47:33Z marius $ 27 | */ 28 | 29 | #ifndef _STDBOOL_H_ 30 | #define _STDBOOL_H_ 31 | 32 | #define __bool_true_false_are_defined 1 33 | 34 | #ifndef __cplusplus 35 | 36 | #define false 0 37 | #define true 1 38 | 39 | #define bool _Bool 40 | #if __STDC_VERSION__ < 199901L && __GNUC__ < 3 && !defined(__INTEL_COMPILER) 41 | typedef int _Bool; 42 | #endif 43 | 44 | #endif /* !__cplusplus */ 45 | 46 | #endif /* !_STDBOOL_H_ */ 47 | -------------------------------------------------------------------------------- /include/stddef.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1990, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * @(#)stddef.h 8.1 (Berkeley) 6/2/93 30 | * 31 | * $FreeBSD: release/9.0.0/include/stddef.h 203964 2010-02-16 19:39:50Z imp $ 32 | */ 33 | 34 | #ifndef _STDDEF_H_ 35 | #define _STDDEF_H_ 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | typedef __ptrdiff_t ptrdiff_t; 42 | 43 | #if __BSD_VISIBLE 44 | #ifndef _RUNE_T_DECLARED 45 | typedef __rune_t rune_t; 46 | #define _RUNE_T_DECLARED 47 | #endif 48 | #endif 49 | 50 | #ifndef _SIZE_T_DECLARED 51 | typedef __size_t size_t; 52 | #define _SIZE_T_DECLARED 53 | #endif 54 | 55 | #ifndef __cplusplus 56 | #ifndef _WCHAR_T_DECLARED 57 | typedef __wchar_t wchar_t; 58 | #define _WCHAR_T_DECLARED 59 | #endif 60 | #endif 61 | 62 | #define offsetof(type, member) __offsetof(type, member) 63 | 64 | #endif /* _STDDEF_H_ */ 65 | -------------------------------------------------------------------------------- /include/stdint.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2001 Mike Barcroft 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: release/9.0.0/sys/sys/stdint.h 221502 2011-05-05 14:45:24Z obrien $ 27 | */ 28 | 29 | #ifndef _SYS_STDINT_H_ 30 | #define _SYS_STDINT_H_ 31 | 32 | #include 33 | #include 34 | 35 | #include 36 | #include 37 | 38 | typedef __int_least8_t int_least8_t; 39 | typedef __int_least16_t int_least16_t; 40 | typedef __int_least32_t int_least32_t; 41 | typedef __int_least64_t int_least64_t; 42 | 43 | typedef __uint_least8_t uint_least8_t; 44 | typedef __uint_least16_t uint_least16_t; 45 | typedef __uint_least32_t uint_least32_t; 46 | typedef __uint_least64_t uint_least64_t; 47 | 48 | typedef __int_fast8_t int_fast8_t; 49 | typedef __int_fast16_t int_fast16_t; 50 | typedef __int_fast32_t int_fast32_t; 51 | typedef __int_fast64_t int_fast64_t; 52 | 53 | typedef __uint_fast8_t uint_fast8_t; 54 | typedef __uint_fast16_t uint_fast16_t; 55 | typedef __uint_fast32_t uint_fast32_t; 56 | typedef __uint_fast64_t uint_fast64_t; 57 | 58 | #ifndef _INTMAX_T_DECLARED 59 | typedef __intmax_t intmax_t; 60 | #define _INTMAX_T_DECLARED 61 | #endif 62 | #ifndef _UINTMAX_T_DECLARED 63 | typedef __uintmax_t uintmax_t; 64 | #define _UINTMAX_T_DECLARED 65 | #endif 66 | 67 | #endif /* !_SYS_STDINT_H_ */ 68 | -------------------------------------------------------------------------------- /include/strings.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2002 Mike Barcroft 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: release/9.0.0/include/strings.h 201525 2010-01-04 18:46:54Z ed $ 27 | */ 28 | 29 | #ifndef _STRINGS_H_ 30 | #define _STRINGS_H_ 31 | 32 | #include 33 | #include 34 | 35 | #ifndef _SIZE_T_DECLARED 36 | typedef __size_t size_t; 37 | #define _SIZE_T_DECLARED 38 | #endif 39 | 40 | __BEGIN_DECLS 41 | #if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112 42 | int bcmp(const void *, const void *, size_t) __pure; /* LEGACY */ 43 | void bcopy(const void *, void *, size_t); /* LEGACY */ 44 | void bzero(void *, size_t); /* LEGACY */ 45 | #endif 46 | #if __XSI_VISIBLE 47 | int ffs(int) __pure2; 48 | #endif 49 | #if __BSD_VISIBLE 50 | int ffsl(long) __pure2; 51 | int ffsll(long long) __pure2; 52 | int fls(int) __pure2; 53 | int flsl(long) __pure2; 54 | int flsll(long long) __pure2; 55 | #endif 56 | #if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112 57 | char *index(const char *, int) __pure; /* LEGACY */ 58 | char *rindex(const char *, int) __pure; /* LEGACY */ 59 | #endif 60 | int strcasecmp(const char *, const char *) __pure; 61 | int strncasecmp(const char *, const char *, size_t) __pure; 62 | __END_DECLS 63 | 64 | #endif /* _STRINGS_H_ */ 65 | -------------------------------------------------------------------------------- /include/sys/_cpuset.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2008, Jeffrey Roberson 3 | * All rights reserved. 4 | * 5 | * Copyright (c) 2008 Nokia Corporation 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice unmodified, this list of conditions, and the following 13 | * disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | * $FreeBSD: release/9.0.0/sys/sys/_cpuset.h 222813 2011-06-07 08:46:13Z attilio $ 30 | */ 31 | 32 | #ifndef _SYS__CPUSET_H_ 33 | #define _SYS__CPUSET_H_ 34 | 35 | #ifdef _KERNEL 36 | #define CPU_SETSIZE MAXCPU 37 | #endif 38 | 39 | #define CPU_MAXSIZE 128 40 | 41 | #ifndef CPU_SETSIZE 42 | #define CPU_SETSIZE CPU_MAXSIZE 43 | #endif 44 | 45 | #define _NCPUBITS (sizeof(long) * NBBY) /* bits per mask */ 46 | #define _NCPUWORDS howmany(CPU_SETSIZE, _NCPUBITS) 47 | 48 | typedef struct _cpuset { 49 | long __bits[howmany(CPU_SETSIZE, _NCPUBITS)]; 50 | } cpuset_t; 51 | 52 | #endif /* !_SYS__CPUSET_H_ */ 53 | -------------------------------------------------------------------------------- /include/sys/_iovec.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1982, 1986, 1993, 1994 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 4. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * @(#)uio.h 8.5 (Berkeley) 2/22/94 30 | * $FreeBSD: release/9.0.0/sys/sys/_iovec.h 139825 2005-01-07 02:29:27Z imp $ 31 | */ 32 | 33 | #ifndef _SYS__IOVEC_H_ 34 | #define _SYS__IOVEC_H_ 35 | 36 | #include 37 | 38 | #ifndef _SIZE_T_DECLARED 39 | typedef __size_t size_t; 40 | #define _SIZE_T_DECLARED 41 | #endif 42 | 43 | struct iovec { 44 | void *iov_base; /* Base address. */ 45 | size_t iov_len; /* Length. */ 46 | }; 47 | 48 | #endif /* !_SYS__IOVEC_H_ */ 49 | -------------------------------------------------------------------------------- /include/sys/_lock.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Berkeley Software Design Inc's name may not be used to endorse or 13 | * promote products derived from this software without specific prior 14 | * written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | * 28 | * $FreeBSD: release/9.0.0/sys/sys/_lock.h 179025 2008-05-15 20:10:06Z attilio $ 29 | */ 30 | 31 | #ifndef _SYS__LOCK_H_ 32 | #define _SYS__LOCK_H_ 33 | 34 | struct lock_object { 35 | const char *lo_name; /* Individual lock name. */ 36 | u_int lo_flags; 37 | u_int lo_data; /* General class specific data. */ 38 | struct witness *lo_witness; /* Data for witness. */ 39 | }; 40 | 41 | #endif /* !_SYS__LOCK_H_ */ 42 | -------------------------------------------------------------------------------- /include/sys/_lockmgr.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2008 Attilio Rao 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice(s), this list of conditions and the following disclaimer as 10 | * the first lines of this file unmodified other than the possible 11 | * addition of one or more copyright notices. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice(s), this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 26 | * DAMAGE. 27 | * 28 | * $FreeBSD: release/9.0.0/sys/sys/_lockmgr.h 200447 2009-12-12 21:31:07Z attilio $ 29 | */ 30 | 31 | #ifndef _SYS__LOCKMGR_H_ 32 | #define _SYS__LOCKMGR_H_ 33 | 34 | #ifdef DEBUG_LOCKS 35 | #include 36 | #endif 37 | 38 | struct lock { 39 | struct lock_object lock_object; 40 | volatile uintptr_t lk_lock; 41 | u_int lk_exslpfail; 42 | int lk_timo; 43 | int lk_pri; 44 | #ifdef DEBUG_LOCKS 45 | struct stack lk_stack; 46 | #endif 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /include/sys/_mutex.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Berkeley Software Design Inc's name may not be used to endorse or 13 | * promote products derived from this software without specific prior 14 | * written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | * 28 | * $FreeBSD: release/9.0.0/sys/sys/_mutex.h 179025 2008-05-15 20:10:06Z attilio $ 29 | */ 30 | 31 | #ifndef _SYS__MUTEX_H_ 32 | #define _SYS__MUTEX_H_ 33 | 34 | /* 35 | * Sleep/spin mutex. 36 | */ 37 | struct mtx { 38 | struct lock_object lock_object; /* Common lock properties. */ 39 | volatile uintptr_t mtx_lock; /* Owner and flags. */ 40 | }; 41 | 42 | #endif /* !_SYS__MUTEX_H_ */ 43 | -------------------------------------------------------------------------------- /include/sys/_null.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2003 Marcel Moolenaar 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | * 26 | * $FreeBSD: release/9.0.0/sys/sys/_null.h 192002 2009-05-11 21:13:00Z jhb $ 27 | */ 28 | 29 | #ifndef NULL 30 | 31 | #if !defined(__cplusplus) 32 | #define NULL ((void *)0) 33 | #else 34 | #if defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 4 35 | #define NULL __null 36 | #else 37 | #if defined(__LP64__) 38 | #define NULL (0L) 39 | #else 40 | #define NULL 0 41 | #endif /* __LP64__ */ 42 | #endif /* __GNUG__ */ 43 | #endif /* !__cplusplus */ 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /include/sys/_rwlock.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2006 John Baldwin 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the author nor the names of any co-contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * $FreeBSD: release/9.0.0/sys/sys/_rwlock.h 179025 2008-05-15 20:10:06Z attilio $ 30 | */ 31 | 32 | #ifndef _SYS__RWLOCK_H_ 33 | #define _SYS__RWLOCK_H_ 34 | 35 | /* 36 | * Reader/writer lock. 37 | */ 38 | struct rwlock { 39 | struct lock_object lock_object; 40 | volatile uintptr_t rw_lock; 41 | }; 42 | 43 | #endif /* !_SYS__RWLOCK_H_ */ 44 | -------------------------------------------------------------------------------- /include/sys/_semaphore.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2002 Alfred Perlstein 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: release/9.0.0/sys/sys/_semaphore.h 201546 2010-01-05 02:37:59Z davidxu $ 27 | */ 28 | #ifndef __SEMAPHORE_H_ 29 | #define __SEMAPHORE_H_ 30 | 31 | typedef intptr_t semid_t; 32 | struct timespec; 33 | 34 | #define SEM_VALUE_MAX __INT_MAX 35 | 36 | #ifndef _KERNEL 37 | 38 | __BEGIN_DECLS 39 | 40 | int ksem_close(semid_t id); 41 | int ksem_post(semid_t id); 42 | int ksem_wait(semid_t id); 43 | int ksem_trywait(semid_t id); 44 | int ksem_timedwait(semid_t id, const struct timespec *abstime); 45 | int ksem_init(semid_t *idp, unsigned int value); 46 | int ksem_open(semid_t *idp, const char *name, int oflag, mode_t mode, 47 | unsigned int value); 48 | int ksem_unlink(const char *name); 49 | int ksem_getvalue(semid_t id, int *val); 50 | int ksem_destroy(semid_t id); 51 | 52 | __END_DECLS 53 | 54 | #endif /* !_KERNEL */ 55 | 56 | #endif /* __SEMAPHORE_H_ */ 57 | -------------------------------------------------------------------------------- /include/sys/_sigset.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1982, 1986, 1989, 1991, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * (c) UNIX System Laboratories, Inc. 5 | * All or some portions of this file are derived from material licensed 6 | * to the University of California by American Telephone and Telegraph 7 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 | * the permission of UNIX System Laboratories, Inc. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 4. Neither the name of the University nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | * 34 | * @(#)signal.h 8.4 (Berkeley) 5/4/95 35 | * $FreeBSD: release/9.0.0/sys/sys/_sigset.h 139825 2005-01-07 02:29:27Z imp $ 36 | */ 37 | 38 | #ifndef _SYS__SIGSET_H_ 39 | #define _SYS__SIGSET_H_ 40 | 41 | /* 42 | * sigset_t macros. 43 | */ 44 | #define _SIG_WORDS 4 45 | #define _SIG_MAXSIG 128 46 | #define _SIG_IDX(sig) ((sig) - 1) 47 | #define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5) 48 | #define _SIG_BIT(sig) (1 << (_SIG_IDX(sig) & 31)) 49 | #define _SIG_VALID(sig) ((sig) <= _SIG_MAXSIG && (sig) > 0) 50 | 51 | typedef struct __sigset { 52 | __uint32_t __bits[_SIG_WORDS]; 53 | } __sigset_t; 54 | 55 | #if defined(_KERNEL) && defined(COMPAT_43) 56 | typedef unsigned int osigset_t; 57 | #endif 58 | 59 | #endif /* !_SYS__SIGSET_H_ */ 60 | -------------------------------------------------------------------------------- /include/sys/_sockaddr_storage.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 4. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * @(#)socket.h 8.4 (Berkeley) 2/21/94 30 | * $FreeBSD: release/9.0.0/sys/sys/_sockaddr_storage.h 196967 2009-09-08 10:39:38Z phk $ 31 | */ 32 | 33 | #ifndef _SYS__SOCKADDR_STORAGE_H_ 34 | #define _SYS__SOCKADDR_STORAGE_H_ 35 | 36 | /* 37 | * RFC 2553: protocol-independent placeholder for socket addresses 38 | */ 39 | #define _SS_MAXSIZE 128U 40 | #define _SS_ALIGNSIZE (sizeof(__int64_t)) 41 | #define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) - \ 42 | sizeof(sa_family_t)) 43 | #define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) - \ 44 | sizeof(sa_family_t) - _SS_PAD1SIZE - _SS_ALIGNSIZE) 45 | 46 | struct sockaddr_storage { 47 | unsigned char ss_len; /* address length */ 48 | sa_family_t ss_family; /* address family */ 49 | char __ss_pad1[_SS_PAD1SIZE]; 50 | __int64_t __ss_align; /* force desired struct alignment */ 51 | char __ss_pad2[_SS_PAD2SIZE]; 52 | }; 53 | 54 | #endif /* !_SYS__SOCKADDR_STORAGE_H_ */ 55 | -------------------------------------------------------------------------------- /include/sys/_stack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005 Antoine Brodin 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: release/9.0.0/sys/sys/_stack.h 177957 2008-04-06 20:08:51Z attilio $ 27 | */ 28 | 29 | #ifndef _SYS__STACK_H_ 30 | #define _SYS__STACK_H_ 31 | 32 | #define STACK_MAX 18 /* Don't change, stack_ktr relies on this. */ 33 | 34 | struct stack { 35 | int depth; 36 | vm_offset_t pcs[STACK_MAX]; 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /include/sys/_sx.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2007 Attilio Rao 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice(s), this list of conditions and the following disclaimer as 10 | * the first lines of this file unmodified other than the possible 11 | * addition of one or more copyright notices. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice(s), this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 26 | * DAMAGE. 27 | * 28 | * $FreeBSD: release/9.0.0/sys/sys/_sx.h 179025 2008-05-15 20:10:06Z attilio $ 29 | */ 30 | 31 | #ifndef _SYS__SX_H_ 32 | #define _SYS__SX_H_ 33 | 34 | /* 35 | * Shared/exclusive lock main structure definition. 36 | */ 37 | struct sx { 38 | struct lock_object lock_object; 39 | volatile uintptr_t sx_lock; 40 | }; 41 | 42 | #endif /* !_SYS__SX_H_ */ 43 | -------------------------------------------------------------------------------- /include/sys/_task.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2000 Doug Rabson 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: release/9.0.0/sys/sys/_task.h 213813 2010-10-13 22:59:04Z mdf $ 27 | */ 28 | 29 | #ifndef _SYS__TASK_H_ 30 | #define _SYS__TASK_H_ 31 | 32 | #include 33 | 34 | /* 35 | * Each task includes a function which is called from 36 | * taskqueue_run(). The first argument is taken from the 'ta_context' 37 | * field of struct task and the second argument is a count of how many 38 | * times the task was enqueued before the call to taskqueue_run(). 39 | * 40 | * List of locks 41 | * (c) const after init 42 | * (q) taskqueue lock 43 | */ 44 | typedef void task_fn_t(void *context, int pending); 45 | 46 | struct task { 47 | STAILQ_ENTRY(task) ta_link; /* (q) link for queue */ 48 | u_short ta_pending; /* (q) count times queued */ 49 | u_short ta_priority; /* (c) Priority */ 50 | task_fn_t *ta_func; /* (c) task handler */ 51 | void *ta_context; /* (c) argument for handler */ 52 | }; 53 | 54 | #endif /* !_SYS__TASK_H_ */ 55 | -------------------------------------------------------------------------------- /include/sys/_timespec.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1982, 1986, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 4. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * @(#)time.h 8.5 (Berkeley) 5/4/95 30 | * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp 31 | * $FreeBSD: release/9.0.0/sys/sys/_timespec.h 205792 2010-03-28 13:13:22Z ed $ 32 | */ 33 | 34 | #ifndef _SYS__TIMESPEC_H_ 35 | #define _SYS__TIMESPEC_H_ 36 | 37 | #include 38 | 39 | #ifndef _TIME_T_DECLARED 40 | typedef __time_t time_t; 41 | #define _TIME_T_DECLARED 42 | #endif 43 | 44 | struct timespec { 45 | time_t tv_sec; /* seconds */ 46 | long tv_nsec; /* and nanoseconds */ 47 | }; 48 | 49 | #endif /* !_SYS__TIMESPEC_H_ */ 50 | -------------------------------------------------------------------------------- /include/sys/_timeval.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2002 Mike Barcroft 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: release/9.0.0/sys/sys/_timeval.h 158471 2006-05-12 05:04:46Z jhb $ 27 | */ 28 | 29 | #ifndef _SYS__TIMEVAL_H_ 30 | #define _SYS__TIMEVAL_H_ 31 | 32 | #include 33 | 34 | #ifndef _SUSECONDS_T_DECLARED 35 | typedef __suseconds_t suseconds_t; 36 | #define _SUSECONDS_T_DECLARED 37 | #endif 38 | 39 | #ifndef _TIME_T_DECLARED 40 | typedef __time_t time_t; 41 | #define _TIME_T_DECLARED 42 | #endif 43 | 44 | /* 45 | * Structure returned by gettimeofday(2) system call, and used in other calls. 46 | */ 47 | struct timeval { 48 | time_t tv_sec; /* seconds */ 49 | suseconds_t tv_usec; /* and microseconds */ 50 | }; 51 | 52 | #endif /* !_SYS__TIMEVAL_H_ */ 53 | -------------------------------------------------------------------------------- /include/sys/_umtx.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2010, David Xu 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice unmodified, this list of conditions, and the following 10 | * disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | * 26 | * $FreeBSD: release/9.0.0/sys/sys/_umtx.h 216641 2010-12-22 05:01:52Z davidxu $ 27 | * 28 | */ 29 | 30 | #ifndef _SYS__UMTX_H_ 31 | #define _SYS__UMTX_H_ 32 | 33 | #include 34 | 35 | struct umtx { 36 | volatile unsigned long u_owner; /* Owner of the mutex. */ 37 | }; 38 | 39 | struct umutex { 40 | volatile __lwpid_t m_owner; /* Owner of the mutex */ 41 | __uint32_t m_flags; /* Flags of the mutex */ 42 | __uint32_t m_ceilings[2]; /* Priority protect ceiling */ 43 | __uint32_t m_spare[4]; 44 | }; 45 | 46 | struct ucond { 47 | volatile __uint32_t c_has_waiters; /* Has waiters in kernel */ 48 | __uint32_t c_flags; /* Flags of the condition variable */ 49 | __uint32_t c_clockid; /* Clock id */ 50 | __uint32_t c_spare[1]; /* Spare space */ 51 | }; 52 | 53 | struct urwlock { 54 | volatile __int32_t rw_state; 55 | __uint32_t rw_flags; 56 | __uint32_t rw_blocked_readers; 57 | __uint32_t rw_blocked_writers; 58 | __uint32_t rw_spare[4]; 59 | }; 60 | 61 | struct _usem { 62 | volatile __uint32_t _has_waiters; 63 | volatile __uint32_t _count; 64 | __uint32_t _flags; 65 | }; 66 | 67 | #endif /* !_SYS__UMTX_H_ */ 68 | -------------------------------------------------------------------------------- /include/sys/elf.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2001 David E. O'Brien. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: release/9.0.0/sys/sys/elf.h 174043 2007-11-28 21:54:46Z jb $ 27 | */ 28 | 29 | /* 30 | * This is a Solaris compatibility header 31 | */ 32 | 33 | #ifndef _SYS_ELF_H_ 34 | #define _SYS_ELF_H_ 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #endif /* !_SYS_ELF_H_ */ 42 | -------------------------------------------------------------------------------- /include/sys/eventvar.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1999,2000 Jonathan Lemon 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: release/9.0.0/sys/sys/eventvar.h 133741 2004-08-15 06:24:42Z jmg $ 27 | */ 28 | 29 | #ifndef _SYS_EVENTVAR_H_ 30 | #define _SYS_EVENTVAR_H_ 31 | 32 | #ifndef _KERNEL 33 | #error "no user-servicable parts inside" 34 | #endif 35 | 36 | #include 37 | 38 | #define KQ_NEVENTS 8 /* minimize copy{in,out} calls */ 39 | #define KQEXTENT 256 /* linear growth by this amount */ 40 | 41 | struct kqueue { 42 | struct mtx kq_lock; 43 | int kq_refcnt; 44 | SLIST_ENTRY(kqueue) kq_list; 45 | TAILQ_HEAD(, knote) kq_head; /* list of pending event */ 46 | int kq_count; /* number of pending events */ 47 | struct selinfo kq_sel; 48 | struct sigio *kq_sigio; 49 | struct filedesc *kq_fdp; 50 | int kq_state; 51 | #define KQ_SEL 0x01 52 | #define KQ_SLEEP 0x02 53 | #define KQ_FLUXWAIT 0x04 /* waiting for a in flux kn */ 54 | #define KQ_ASYNC 0x08 55 | #define KQ_CLOSING 0x10 56 | #define KQ_TASKSCHED 0x20 /* task scheduled */ 57 | #define KQ_TASKDRAIN 0x40 /* waiting for task to drain */ 58 | int kq_knlistsize; /* size of knlist */ 59 | struct klist *kq_knlist; /* list of knotes */ 60 | u_long kq_knhashmask; /* size of knhash */ 61 | struct klist *kq_knhash; /* hash table for knotes */ 62 | struct task kq_task; 63 | }; 64 | 65 | #endif /* !_SYS_EVENTVAR_H_ */ 66 | -------------------------------------------------------------------------------- /include/sys/ioctl.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1982, 1986, 1990, 1993, 1994 3 | * The Regents of the University of California. All rights reserved. 4 | * (c) UNIX System Laboratories, Inc. 5 | * All or some portions of this file are derived from material licensed 6 | * to the University of California by American Telephone and Telegraph 7 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 | * the permission of UNIX System Laboratories, Inc. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 4. Neither the name of the University nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | * 34 | * @(#)ioctl.h 8.6 (Berkeley) 3/28/94 35 | * $FreeBSD: release/9.0.0/sys/sys/ioctl.h 191947 2009-05-09 19:01:24Z ed $ 36 | */ 37 | 38 | #ifndef _SYS_IOCTL_H_ 39 | #define _SYS_IOCTL_H_ 40 | 41 | #ifdef _KERNEL 42 | #error "Don't #include ioctl.h in the kernel. Include xxxio.h instead." 43 | #endif /* _KERNEL */ 44 | 45 | #include 46 | 47 | #include 48 | #include 49 | #include 50 | 51 | #endif /* !_SYS_IOCTL_H_ */ 52 | -------------------------------------------------------------------------------- /include/sys/mqueue.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2005 David Xu 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: release/9.0.0/sys/sys/mqueue.h 152948 2005-11-30 05:12:03Z davidxu $ 27 | */ 28 | 29 | #ifndef _SYS_MQUEUE_H_ 30 | #define _SYS_MQUEUE_H_ 31 | 32 | struct mq_attr { 33 | long mq_flags; /* Message queue flags. */ 34 | long mq_maxmsg; /* Maximum number of messages. */ 35 | long mq_msgsize; /* Maximum message size. */ 36 | long mq_curmsgs; /* Number of messages currently queued. */ 37 | long __reserved[4]; /* Ignored for input, zeroed for output */ 38 | }; 39 | 40 | #ifdef _KERNEL 41 | struct thread; 42 | struct file; 43 | extern void (*mq_fdclose)(struct thread *td, int fd, struct file *fp); 44 | #endif 45 | #endif 46 | -------------------------------------------------------------------------------- /include/sys/refcount.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2005 John Baldwin 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the author nor the names of any co-contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * $FreeBSD: release/9.0.0/sys/sys/refcount.h 180763 2008-07-23 16:44:20Z des $ 30 | */ 31 | 32 | #ifndef __SYS_REFCOUNT_H__ 33 | #define __SYS_REFCOUNT_H__ 34 | 35 | #include 36 | 37 | #ifdef _KERNEL 38 | #include 39 | #else 40 | #define KASSERT(exp, msg) /* */ 41 | #endif 42 | 43 | static __inline void 44 | refcount_init(volatile u_int *count, u_int value) 45 | { 46 | 47 | *count = value; 48 | } 49 | 50 | static __inline void 51 | refcount_acquire(volatile u_int *count) 52 | { 53 | 54 | atomic_add_acq_int(count, 1); 55 | } 56 | 57 | static __inline int 58 | refcount_release(volatile u_int *count) 59 | { 60 | u_int old; 61 | 62 | /* XXX: Should this have a rel membar? */ 63 | old = atomic_fetchadd_int(count, -1); 64 | KASSERT(old > 0, ("negative refcount %p", count)); 65 | return (old == 1); 66 | } 67 | 68 | #endif /* ! __SYS_REFCOUNT_H__ */ 69 | -------------------------------------------------------------------------------- /include/sys/selinfo.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1992, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 4. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * @(#)select.h 8.2 (Berkeley) 1/4/94 30 | * $FreeBSD: release/9.0.0/sys/sys/selinfo.h 225177 2011-08-25 15:51:54Z attilio $ 31 | */ 32 | 33 | #ifndef _SYS_SELINFO_H_ 34 | #define _SYS_SELINFO_H_ 35 | 36 | #include /* for struct klist */ 37 | 38 | struct selfd; 39 | TAILQ_HEAD(selfdlist, selfd); 40 | 41 | /* 42 | * Used to maintain information about processes that wish to be 43 | * notified when I/O becomes possible. 44 | */ 45 | struct selinfo { 46 | struct selfdlist si_tdlist; /* List of sleeping threads. */ 47 | struct knlist si_note; /* kernel note list */ 48 | struct mtx *si_mtx; /* Lock for tdlist. */ 49 | }; 50 | 51 | #define SEL_WAITING(si) (!TAILQ_EMPTY(&(si)->si_tdlist)) 52 | 53 | #ifdef _KERNEL 54 | void seldrain(struct selinfo *sip); 55 | void selrecord(struct thread *selector, struct selinfo *sip); 56 | void selwakeup(struct selinfo *sip); 57 | void selwakeuppri(struct selinfo *sip, int pri); 58 | void seltdfini(struct thread *td); 59 | #endif 60 | 61 | #endif /* !_SYS_SELINFO_H_ */ 62 | -------------------------------------------------------------------------------- /include/sys/stdint.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2001 Mike Barcroft 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: release/9.0.0/sys/sys/stdint.h 221502 2011-05-05 14:45:24Z obrien $ 27 | */ 28 | 29 | #ifndef _SYS_STDINT_H_ 30 | #define _SYS_STDINT_H_ 31 | 32 | #include 33 | #include 34 | 35 | #include 36 | #include 37 | 38 | typedef __int_least8_t int_least8_t; 39 | typedef __int_least16_t int_least16_t; 40 | typedef __int_least32_t int_least32_t; 41 | typedef __int_least64_t int_least64_t; 42 | 43 | typedef __uint_least8_t uint_least8_t; 44 | typedef __uint_least16_t uint_least16_t; 45 | typedef __uint_least32_t uint_least32_t; 46 | typedef __uint_least64_t uint_least64_t; 47 | 48 | typedef __int_fast8_t int_fast8_t; 49 | typedef __int_fast16_t int_fast16_t; 50 | typedef __int_fast32_t int_fast32_t; 51 | typedef __int_fast64_t int_fast64_t; 52 | 53 | typedef __uint_fast8_t uint_fast8_t; 54 | typedef __uint_fast16_t uint_fast16_t; 55 | typedef __uint_fast32_t uint_fast32_t; 56 | typedef __uint_fast64_t uint_fast64_t; 57 | 58 | #ifndef _INTMAX_T_DECLARED 59 | typedef __intmax_t intmax_t; 60 | #define _INTMAX_T_DECLARED 61 | #endif 62 | #ifndef _UINTMAX_T_DECLARED 63 | typedef __uintmax_t uintmax_t; 64 | #define _UINTMAX_T_DECLARED 65 | #endif 66 | 67 | #endif /* !_SYS_STDINT_H_ */ 68 | -------------------------------------------------------------------------------- /include/sys/timespec.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1982, 1986, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 4. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * @(#)time.h 8.5 (Berkeley) 5/4/95 30 | * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp 31 | * $FreeBSD: release/9.0.0/sys/sys/timespec.h 205792 2010-03-28 13:13:22Z ed $ 32 | */ 33 | 34 | #ifndef _SYS_TIMESPEC_H_ 35 | #define _SYS_TIMESPEC_H_ 36 | 37 | #include 38 | #include 39 | 40 | #if __BSD_VISIBLE 41 | #define TIMEVAL_TO_TIMESPEC(tv, ts) \ 42 | do { \ 43 | (ts)->tv_sec = (tv)->tv_sec; \ 44 | (ts)->tv_nsec = (tv)->tv_usec * 1000; \ 45 | } while (0) 46 | #define TIMESPEC_TO_TIMEVAL(tv, ts) \ 47 | do { \ 48 | (tv)->tv_sec = (ts)->tv_sec; \ 49 | (tv)->tv_usec = (ts)->tv_nsec / 1000; \ 50 | } while (0) 51 | 52 | #endif /* __BSD_VISIBLE */ 53 | 54 | /* 55 | * Structure defined by POSIX.1b to be like a itimerval, but with 56 | * timespecs. Used in the timer_*() system calls. 57 | */ 58 | struct itimerspec { 59 | struct timespec it_interval; 60 | struct timespec it_value; 61 | }; 62 | 63 | #endif /* _SYS_TIMESPEC_H_ */ 64 | -------------------------------------------------------------------------------- /include/third_party/udis86/syn.h: -------------------------------------------------------------------------------- 1 | /* udis86 - libudis86/syn.h 2 | * 3 | * Copyright (c) 2002-2009 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 22 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | #ifndef UD_SYN_H 27 | #define UD_SYN_H 28 | 29 | #include "types.h" 30 | #ifndef __UD_STANDALONE__ 31 | # include 32 | #endif /* __UD_STANDALONE__ */ 33 | 34 | extern const char* ud_reg_tab[]; 35 | 36 | uint64_t ud_syn_rel_target(struct ud*, struct ud_operand*); 37 | 38 | #ifdef __GNUC__ 39 | int ud_asmprintf(struct ud *u, const char *fmt, ...) 40 | __attribute__ ((format (printf, 2, 3))); 41 | #else 42 | int ud_asmprintf(struct ud *u, const char *fmt, ...); 43 | #endif 44 | 45 | void ud_syn_print_addr(struct ud *u, uint64_t addr); 46 | void ud_syn_print_imm(struct ud* u, const struct ud_operand *op); 47 | void ud_syn_print_mem_disp(struct ud* u, const struct ud_operand *, int sign); 48 | 49 | #endif /* UD_SYN_H */ 50 | 51 | /* 52 | vim: set ts=2 sw=2 expandtab 53 | */ 54 | -------------------------------------------------------------------------------- /include/third_party/udis86/udis86.h: -------------------------------------------------------------------------------- 1 | /* udis86 - udis86.h 2 | * 3 | * Copyright (c) 2002-2009 Vivek Thampi 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 22 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | #ifndef UDIS86_H 27 | #define UDIS86_H 28 | 29 | #include "types.h" 30 | #include "extern.h" 31 | #include "itab.h" 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /include/ulimit.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2002 Kyle Martin 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: release/9.0.0/include/ulimit.h 108910 2003-01-08 01:18:13Z tjr $ 27 | */ 28 | 29 | #ifndef _ULIMIT_H_ 30 | #define _ULIMIT_H_ 31 | 32 | #include 33 | 34 | #define UL_GETFSIZE 1 35 | #define UL_SETFSIZE 2 36 | 37 | __BEGIN_DECLS 38 | long ulimit(int, ...); 39 | __END_DECLS 40 | 41 | #endif /* !_ULIMIT_H_ */ 42 | -------------------------------------------------------------------------------- /include/utime.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1990, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * @(#)utime.h 8.1 (Berkeley) 6/2/93 30 | * $FreeBSD: release/9.0.0/include/utime.h 203964 2010-02-16 19:39:50Z imp $ 31 | */ 32 | 33 | #ifndef _UTIME_H_ 34 | #define _UTIME_H_ 35 | 36 | #include 37 | #include 38 | 39 | #ifndef _TIME_T_DECLARED 40 | typedef __time_t time_t; 41 | #define _TIME_T_DECLARED 42 | #endif 43 | 44 | struct utimbuf { 45 | time_t actime; /* Access time */ 46 | time_t modtime; /* Modification time */ 47 | }; 48 | 49 | __BEGIN_DECLS 50 | int utime(const char *, const struct utimbuf *); 51 | __END_DECLS 52 | 53 | #endif /* !_UTIME_H_ */ 54 | -------------------------------------------------------------------------------- /include/x86/_align.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2001 David E. O'Brien 3 | * Copyright (c) 1990 The Regents of the University of California. 4 | * All rights reserved. 5 | * 6 | * This code is derived from software contributed to Berkeley by 7 | * William Jolitz. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 3. All advertising materials mentioning features or use of this software 18 | * must display the following acknowledgement: 19 | * This product includes software developed by the University of 20 | * California, Berkeley and its contributors. 21 | * 4. Neither the name of the University nor the names of its contributors 22 | * may be used to endorse or promote products derived from this software 23 | * without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 | * SUCH DAMAGE. 36 | * 37 | * from: @(#)param.h 5.8 (Berkeley) 6/28/91 38 | * $FreeBSD: release/9.0.0/sys/x86/include/_align.h 215856 2010-11-26 10:59:20Z tijl $ 39 | */ 40 | 41 | #ifndef _X86_INCLUDE__ALIGN_H_ 42 | #define _X86_INCLUDE__ALIGN_H_ 43 | 44 | /* 45 | * Round p (pointer or byte index) up to a correctly-aligned value 46 | * for all data types (int, long, ...). The result is unsigned int 47 | * and must be cast to any desired pointer type. 48 | */ 49 | #define _ALIGNBYTES (sizeof(register_t) - 1) 50 | #define _ALIGN(p) (((uintptr_t)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) 51 | 52 | #endif /* !_X86_INCLUDE__ALIGN_H_ */ 53 | -------------------------------------------------------------------------------- /linker.x: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") 2 | OUTPUT_ARCH(i386:x86-64) 3 | 4 | ENTRY(_start) 5 | 6 | PHDRS 7 | { 8 | code_seg PT_LOAD; 9 | data_seg PT_LOAD; 10 | } 11 | 12 | SECTIONS 13 | { 14 | /* Code segment */ 15 | . = 0x93a300000; 16 | .text : { *(.text.start) *(.text*) } : code_seg 17 | .rodata : { *(.rodata) *(.rodata*) } : code_seg 18 | 19 | /* Data segment */ 20 | . = 0x93a400000; 21 | .data : { *(.data) } : data_seg 22 | .bss : { *(.bss) } : data_seg 23 | } 24 | -------------------------------------------------------------------------------- /make/target/ps4_bin.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | include $(MakePath)/trait/freestanding.mk 4 | include $(MakePath)/trait/ps4.mk 5 | 6 | ################################### 7 | 8 | include $(MakePath)/trait/kernel_execute.mk 9 | include $(MakePath)/trait/common.mk 10 | include $(MakePath)/trait/adaptive.mk 11 | include $(MakePath)/trait/sce.mk 12 | include $(MakePath)/trait/kernel.mk 13 | include $(MakePath)/trait/base.mk 14 | include $(MakePath)/trait/system_call_rop_0x93a4FFFF8.mk 15 | 16 | ################################### 17 | 18 | ifndef KeepElf 19 | ifdef keepelf 20 | KeepElf := $(keepelf) 21 | endif 22 | ifdef KEEPELF 23 | KeepElf := $(KEEPELF) 24 | endif 25 | endif 26 | 27 | ################################### 28 | 29 | LinkerFlags += -Xlinker -T $(Ps4Sdk)/linker.x -Wl,--build-id=none 30 | 31 | ################################### 32 | 33 | bincopy = $(ObjectCopy) $@ -O binary $@ 34 | copy = cp $@ $@.elf 35 | 36 | ################################### 37 | 38 | $(OutPath)/$(TargetFile):: $(ObjectFiles) 39 | $(dirp) 40 | $(link) 41 | ifdef KeepElf 42 | $(copy) 43 | endif 44 | $(bincopy) 45 | 46 | ################################### 47 | 48 | include $(MakePath)/trait/all_and_clean.mk 49 | 50 | ################################### 51 | -------------------------------------------------------------------------------- /make/target/ps4_elf.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | include $(MakePath)/trait/freestanding.mk 4 | include $(MakePath)/trait/ps4.mk 5 | include $(MakePath)/trait/pie.mk 6 | include $(MakePath)/trait/link.mk 7 | 8 | ################################### 9 | 10 | include $(MakePath)/trait/kernel_execute.mk 11 | include $(MakePath)/trait/common.mk 12 | include $(MakePath)/trait/adaptive.mk 13 | include $(MakePath)/trait/sce.mk 14 | include $(MakePath)/trait/kernel.mk 15 | include $(MakePath)/trait/base.mk 16 | include $(MakePath)/trait/system_call_rop_0x93a4FFFF8.mk 17 | 18 | ################################### 19 | 20 | include $(MakePath)/trait/all_and_clean.mk 21 | 22 | ################################### 23 | -------------------------------------------------------------------------------- /make/target/ps4_elf_kernel.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | include $(MakePath)/trait/freestanding.mk 4 | include $(MakePath)/trait/ps4.mk 5 | include $(MakePath)/trait/pie.mk 6 | include $(MakePath)/trait/link.mk 7 | 8 | ################################### 9 | 10 | include $(MakePath)/trait/common.mk 11 | include $(MakePath)/trait/kernel.mk 12 | include $(MakePath)/trait/base.mk 13 | 14 | ################################### 15 | 16 | include $(MakePath)/trait/all_and_clean.mk 17 | 18 | ################################### 19 | -------------------------------------------------------------------------------- /make/target/ps4_elf_rop.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | include $(MakePath)/trait/freestanding.mk 4 | include $(MakePath)/trait/ps4.mk 5 | include $(MakePath)/trait/pie.mk 6 | include $(MakePath)/trait/link.mk 7 | 8 | ################################### 9 | 10 | include $(MakePath)/trait/kernel_execute.mk 11 | include $(MakePath)/trait/common.mk 12 | include $(MakePath)/trait/adaptive.mk 13 | include $(MakePath)/trait/sce.mk 14 | include $(MakePath)/trait/kernel.mk 15 | include $(MakePath)/trait/base.mk 16 | include $(MakePath)/trait/system_call_rop_0x93a4FFFF8.mk 17 | 18 | ################################### 19 | 20 | include $(MakePath)/trait/all_and_clean.mk 21 | 22 | ################################### 23 | -------------------------------------------------------------------------------- /make/target/ps4_elf_sce.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | include $(MakePath)/trait/freestanding.mk 4 | include $(MakePath)/trait/ps4.mk 5 | include $(MakePath)/trait/pie.mk 6 | include $(MakePath)/trait/link.mk 7 | 8 | ################################### 9 | 10 | include $(MakePath)/trait/sce.mk 11 | include $(MakePath)/trait/base.mk 12 | include $(MakePath)/trait/system_call_standard.mk 13 | 14 | ################################### 15 | 16 | include $(MakePath)/trait/all_and_clean.mk 17 | 18 | ################################### 19 | -------------------------------------------------------------------------------- /make/target/ps4_elf_standard.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | include $(MakePath)/trait/freestanding.mk 4 | include $(MakePath)/trait/ps4.mk 5 | include $(MakePath)/trait/pie.mk 6 | include $(MakePath)/trait/link.mk 7 | 8 | ################################### 9 | 10 | include $(MakePath)/trait/kernel_execute.mk 11 | include $(MakePath)/trait/common.mk 12 | include $(MakePath)/trait/adaptive.mk 13 | include $(MakePath)/trait/sce.mk 14 | include $(MakePath)/trait/kernel.mk 15 | include $(MakePath)/trait/base.mk 16 | include $(MakePath)/trait/system_call_standard.mk 17 | 18 | ################################### 19 | 20 | include $(MakePath)/trait/all_and_clean.mk 21 | 22 | ################################### 23 | -------------------------------------------------------------------------------- /make/target/ps4_lib.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | include $(MakePath)/trait/freestanding.mk 4 | include $(MakePath)/trait/ps4.mk 5 | include $(MakePath)/trait/pic.mk 6 | 7 | ################################### 8 | 9 | include $(MakePath)/trait/all_and_clean.mk 10 | 11 | ################################### 12 | -------------------------------------------------------------------------------- /make/target/ps4_lib_kernel.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | include $(MakePath)/trait/freestanding.mk 4 | include $(MakePath)/trait/ps4.mk 5 | include $(MakePath)/trait/pic.mk 6 | 7 | ################################### 8 | 9 | include $(MakePath)/trait/common.mk 10 | include $(MakePath)/trait/kernel.mk 11 | include $(MakePath)/trait/base.mk 12 | 13 | ################################### 14 | 15 | AllTarget := $(OutPath)/$(TargetFile).a 16 | include $(MakePath)/trait/all_and_clean.mk 17 | 18 | ################################### 19 | -------------------------------------------------------------------------------- /make/target/ps4_lib_kernel_no_all.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | include $(MakePath)/trait/freestanding.mk 4 | include $(MakePath)/trait/ps4.mk 5 | include $(MakePath)/trait/pic.mk 6 | 7 | ################################### 8 | 9 | include $(MakePath)/trait/common.mk 10 | include $(MakePath)/trait/kernel.mk 11 | include $(MakePath)/trait/base.mk 12 | 13 | ################################### 14 | 15 | #include $(MakePath)/trait/all_and_clean.mk 16 | 17 | ################################### 18 | -------------------------------------------------------------------------------- /make/target/ps4_lib_no_all.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | include $(MakePath)/trait/freestanding.mk 4 | include $(MakePath)/trait/ps4.mk 5 | include $(MakePath)/trait/pic.mk 6 | 7 | ################################### 8 | -------------------------------------------------------------------------------- /make/target/ps4_untargeted.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | include $(MakePath)/trait/freestanding.mk 4 | include $(MakePath)/trait/ps4_untargeted.mk 5 | include $(MakePath)/trait/pie.mk 6 | include $(MakePath)/trait/link.mk 7 | 8 | ################################### 9 | 10 | include $(MakePath)/trait/all_and_clean.mk 11 | 12 | ################################### 13 | -------------------------------------------------------------------------------- /make/target/x64.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | include $(MakePath)/trait/pie.mk 4 | include $(MakePath)/trait/link.mk 5 | 6 | ################################### 7 | 8 | include $(MakePath)/trait/all_and_clean.mk 9 | 10 | ################################### 11 | -------------------------------------------------------------------------------- /make/target/x64_nostd.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | include $(MakePath)/trait/freestanding.mk 4 | include $(MakePath)/trait/pie.mk 5 | include $(MakePath)/trait/link.mk 6 | 7 | ################################### 8 | 9 | CrtFile ?= $(Ps4Sdk)/crt0.s 10 | #CrtFile ?= crt0/crt0.s 11 | #link = $(Linker) $? $(LinkerFlags) $(Libraries) -o $@ 12 | 13 | ################################### 14 | 15 | include $(MakePath)/trait/all_and_clean.mk 16 | 17 | ################################### 18 | -------------------------------------------------------------------------------- /make/trait/adaptive.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | #Link in all libC and libkernel symbols that have a kernel alter-ego 4 | #Magically switch their meaning and resolve them dependent on 5 | #which space the code runs in. This overrides prior lib symbols! 6 | #Allows us to write and execute kernel payloads compiled in with userland code 7 | Libraries += -lPs4LibCInternalAdaptive_stub 8 | Libraries += -lPs4LibKernelAdaptive_stub 9 | 10 | ################################### 11 | -------------------------------------------------------------------------------- /make/trait/all_and_clean.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | all:: $(AllTarget) 4 | clean:: 5 | $(CleanTarget) 6 | 7 | ################################### 8 | -------------------------------------------------------------------------------- /make/trait/base.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | #Use minimal resolver to get the stubs auto-resolved. 4 | Libraries += -lPs4_base_stub_resolve_minimal 5 | 6 | #Be able to find kernel elf and by extension to ps4KernelelDlSym 7 | Libraries += -lPs4_base_kernel_dlsym_standard 8 | Libraries += -lPs4_base_kernel_seek_elf_address_standard 9 | 10 | #Ability to push / pop all arguments in registers from assembler 11 | #Used in stub relove 12 | Libraries += -lPs4_base_assembler_register_parameter_standard 13 | 14 | ################################### 15 | -------------------------------------------------------------------------------- /make/trait/common.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | #Link in core 4 | # Stuff that adapts to space 5 | #Libraries += -lPs4_common_adaptive 6 | Libraries += -lPs4_common_kernel 7 | Libraries += -lPs4_common_user 8 | #Third party and stand alone (user + kernel) stuff 9 | Libraries += -lPs4_common_generic 10 | 11 | ################################### 12 | -------------------------------------------------------------------------------- /make/trait/freestanding.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | CompilerFlags += -ffreestanding -nostdlib -nostdinc -fno-builtin -fno-stack-protector 4 | LinkerFlags += -nostartfiles -nostdlib 5 | 6 | ################################### 7 | -------------------------------------------------------------------------------- /make/trait/kernel.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | #Link in kernel stubs to resolve calls through ps4KernelelExecute 4 | Libraries += -lps4Kernel_stub 5 | 6 | ################################### 7 | -------------------------------------------------------------------------------- /make/trait/kernel_execute.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | #Link in kernel exploit by default 4 | #This makes the executable firmware dependent 5 | Libraries += -lPs4_extension_kernel_execute_dynlib_prepare_dlclose 6 | Libraries += -lPs4_extension_kernel_call_standard 7 | 8 | ################################### 9 | -------------------------------------------------------------------------------- /make/trait/link.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | $(OutPath)/$(TargetFile):: $(ObjectFiles) 4 | $(dirp) 5 | $(link) 6 | 7 | ################################### 8 | -------------------------------------------------------------------------------- /make/trait/pic.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | CompilerFlags += $(Ps4SdkFlags) -fPIC 4 | 5 | ################################### 6 | -------------------------------------------------------------------------------- /make/trait/pie.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | AssemblerFlags += -fPIE 4 | CompilerFlags += -fPIE 5 | LinkerFlags += -pie 6 | 7 | ################################### 8 | -------------------------------------------------------------------------------- /make/trait/ps4.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | include $(MakePath)/trait/ps4_untargeted.mk # Look here for more 4 | 5 | ################################### 6 | 7 | AssemblerFlags += -target x86_64-scei-ps4-elf 8 | CompilerFlags += -target x86_64-scei-ps4-elf 9 | 10 | ################################### 11 | -------------------------------------------------------------------------------- /make/trait/ps4_untargeted.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | ifndef Ps4Sdk 4 | ifdef ps4sdk 5 | Ps4Sdk := $(ps4sdk) 6 | endif 7 | ifdef PS4SDK 8 | Ps4Sdk := $(PS4SDK) 9 | endif 10 | ifndef Ps4Sdk 11 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 12 | endif 13 | endif 14 | 15 | ################################### 16 | 17 | AssemblerFlags += -I$(Ps4Sdk)/include 18 | CompilerFlags += -D__PS4__ -I$(Ps4Sdk)/include -I $(Ps4Sdk)/include/sce 19 | LinkerFlags += -L$(Ps4Sdk)/lib 20 | 21 | ################################### 22 | 23 | CrtFile ?= $(Ps4Sdk)/crt0.s 24 | #link = $(Linker) $(Ps4Sdk)/crt0.s $? $(LinkerFlags) $(Libraries) -o $@ 25 | 26 | ################################### 27 | -------------------------------------------------------------------------------- /make/trait/sce.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | #Include standard libc, posix and common process management stuff 4 | Libraries += -lSceLibcInternal_stub 5 | Libraries += -lkernel_stub 6 | 7 | ################################### 8 | -------------------------------------------------------------------------------- /make/trait/system_call_rop_0x93a4FFFF8.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | #Assembler syscalls are performed using the rop address stored at 0x... 4 | #Needed for resolving stubs. 5 | #This makes the elf dependant on a specific in-process setup. 6 | Libraries += -lPs4_base_assembler_system_call_rop_0x93a4FFFF8 7 | 8 | ################################### 9 | -------------------------------------------------------------------------------- /make/trait/system_call_standard.mk: -------------------------------------------------------------------------------- 1 | ################################### 2 | 3 | #Needed for resolving stubs. 4 | #This makes the elf dependant on a specific out-ot-process setup. 5 | Libraries += -lPs4_base_assembler_system_call_standard 6 | 7 | ################################### 8 | --------------------------------------------------------------------------------