├── .github └── workflows │ └── dockerpublish.yml ├── .gitignore ├── Dockerfile ├── LICENSE.md ├── Makefile ├── README.md ├── aarch64-none-darwin ├── README.md ├── darwin.patch ├── include │ ├── _ansi.h │ ├── _newlib_version.h │ ├── _syslist.h │ ├── alloca.h │ ├── ar.h │ ├── argz.h │ ├── assert.h │ ├── complex.h │ ├── cpio.h │ ├── ctype.h │ ├── devctl.h │ ├── dirent.h │ ├── elf.h │ ├── envlock.h │ ├── envz.h │ ├── errno.h │ ├── fastmath.h │ ├── fcntl.h │ ├── fenv.h │ ├── fnmatch.h │ ├── getopt.h │ ├── glob.h │ ├── grp.h │ ├── iconv.h │ ├── ieeefp.h │ ├── inttypes.h │ ├── langinfo.h │ ├── libgen.h │ ├── limits.h │ ├── locale.h │ ├── machine │ │ ├── _arc4random.h │ │ ├── _default_types.h │ │ ├── _endian.h │ │ ├── _time.h │ │ ├── _types.h │ │ ├── ansi.h │ │ ├── endian.h │ │ ├── fastmath.h │ │ ├── ieeefp.h │ │ ├── malloc.h │ │ ├── param.h │ │ ├── setjmp-dj.h │ │ ├── setjmp.h │ │ ├── stdlib.h │ │ ├── termios.h │ │ ├── time.h │ │ └── types.h │ ├── malloc.h │ ├── math.h │ ├── memory.h │ ├── ndbm.h │ ├── newlib.h │ ├── paths.h │ ├── pthread.h │ ├── pwd.h │ ├── reent.h │ ├── regdef.h │ ├── regex.h │ ├── sched.h │ ├── search.h │ ├── setjmp.h │ ├── signal.h │ ├── spawn.h │ ├── ssp │ │ ├── ssp.h │ │ ├── stdio.h │ │ ├── stdlib.h │ │ ├── string.h │ │ ├── strings.h │ │ ├── unistd.h │ │ └── wchar.h │ ├── stdatomic.h │ ├── stdint.h │ ├── stdio.h │ ├── stdio_ext.h │ ├── stdlib.h │ ├── string.h │ ├── strings.h │ ├── sys │ │ ├── _default_fcntl.h │ │ ├── _intsup.h │ │ ├── _locale.h │ │ ├── _pthreadtypes.h │ │ ├── _sigset.h │ │ ├── _stdint.h │ │ ├── _timespec.h │ │ ├── _timeval.h │ │ ├── _types.h │ │ ├── cdefs.h │ │ ├── config.h │ │ ├── custom_file.h │ │ ├── dir.h │ │ ├── dirent.h │ │ ├── errno.h │ │ ├── fcntl.h │ │ ├── features.h │ │ ├── fenv.h │ │ ├── file.h │ │ ├── iconvnls.h │ │ ├── lock.h │ │ ├── param.h │ │ ├── queue.h │ │ ├── reent.h │ │ ├── resource.h │ │ ├── sched.h │ │ ├── select.h │ │ ├── signal.h │ │ ├── stat.h │ │ ├── stdio.h │ │ ├── string.h │ │ ├── syslimits.h │ │ ├── time.h │ │ ├── timeb.h │ │ ├── times.h │ │ ├── timespec.h │ │ ├── tree.h │ │ ├── types.h │ │ ├── unistd.h │ │ ├── utime.h │ │ └── wait.h │ ├── tar.h │ ├── termios.h │ ├── tgmath.h │ ├── threads.h │ ├── time.h │ ├── unctrl.h │ ├── unistd.h │ ├── utime.h │ ├── utmp.h │ ├── wchar.h │ ├── wctype.h │ └── wordexp.h └── lib │ ├── libc.a │ ├── libg.a │ └── libm.a ├── apple-include ├── Availability.h ├── AvailabilityInternal.h ├── AvailabilityMacros.h ├── architecture │ └── byte_order.h ├── arm │ └── _types.h ├── libkern │ ├── OSByteOrder.h │ ├── _OSByteOrder.h │ └── arm │ │ └── OSByteOrder.h ├── mach-o │ ├── loader.h │ ├── nlist.h │ └── reloc.h ├── mach │ ├── arm │ │ ├── boolean.h │ │ ├── thread_state.h │ │ └── vm_types.h │ ├── boolean.h │ ├── machine.h │ ├── machine │ │ ├── boolean.h │ │ ├── thread_state.h │ │ ├── thread_status.h │ │ └── vm_types.h │ └── vm_prot.h └── sys │ └── _types │ └── _os_inline.h ├── checkra1n ├── kpf-test │ ├── .gitignore │ ├── Makefile │ ├── ent.plist │ └── main.c └── kpf │ ├── main.c │ ├── not_strip.txt │ ├── sep │ ├── sep.c │ ├── sep.h │ └── sep_racer.S │ └── shellcode.S ├── include ├── archive.h ├── archive_entry.h ├── font8x8_basic.h ├── iokit.h ├── kerninfo.h ├── key.h ├── loader_xpc_service.h ├── lzma │ ├── lzmadec.h │ └── types.h ├── mac.h └── xpc.h ├── scripts ├── .gitignore ├── Makefile ├── arm64-apple-ios12.0.0-clang ├── boot-checkra1n.py ├── fetch_stdout.py ├── issue_cmd.py ├── module_load.py ├── module_load_boot.py ├── pongoterm.m └── upload_data.py ├── src ├── boot │ ├── clearhook.S │ ├── demote_patch.S │ ├── entry.S │ ├── jump_to_image.S │ ├── libc_workarounds.h │ ├── mac.h │ ├── main.c │ ├── patches.S │ └── stage3.c ├── drivers │ ├── aes │ │ ├── aes.c │ │ ├── aes.h │ │ ├── aes_a7.c │ │ ├── aes_a9.c │ │ └── aes_private.h │ ├── framebuffer │ │ ├── fb.c │ │ └── fb.h │ ├── gpio │ │ ├── gpio.c │ │ └── gpio.h │ ├── hal │ │ ├── hal.c │ │ └── hal.h │ ├── mipi │ │ ├── mipi.c │ │ └── mipi.h │ ├── plat │ │ ├── s5l8960.c │ │ ├── s8000.c │ │ ├── s8001.c │ │ ├── s8003.c │ │ ├── t7000.c │ │ ├── t7001.c │ │ ├── t8010.c │ │ ├── t8011.c │ │ ├── t8012.c │ │ └── t8015.c │ ├── timer │ │ ├── timer.c │ │ └── timer.h │ ├── tz │ │ ├── tz.c │ │ └── tz.h │ ├── uart │ │ ├── uart.c │ │ └── uart.h │ ├── usb │ │ ├── synopsys_otg.c │ │ ├── synopsys_otg_regs.h │ │ └── usb.h │ └── xnu │ │ ├── xnu.S │ │ ├── xnu.c │ │ └── xnu.h ├── dynamic │ ├── modload.c │ └── modload_macho.c ├── kernel │ ├── dtree.c │ ├── dtree_getprop.c │ ├── entry.c │ ├── int.S │ ├── legacy.c │ ├── locks.c │ ├── lowlevel.c │ ├── main_task.c │ ├── mm.c │ ├── panic.c │ ├── pongo.h │ ├── support │ │ ├── exit.c │ │ ├── io.c │ │ ├── malloc.c │ │ ├── process.c │ │ └── sbrk.c │ ├── syscall.c │ ├── task.c │ ├── task.h │ ├── vfs.c │ └── vfs.h ├── lib │ ├── img4 │ │ ├── img4.c │ │ └── img4.h │ ├── libDER │ │ ├── DER_Decode.c │ │ ├── DER_Decode.h │ │ ├── DER_Encode.c │ │ ├── DER_Encode.h │ │ ├── asn1Types.h │ │ ├── libDER.h │ │ ├── libDER_config.h │ │ ├── oids.c │ │ └── oids.h │ └── lzma │ │ └── lzmadec.c ├── modules │ └── linux │ │ ├── libfdt │ │ ├── Makefile.libfdt │ │ ├── README.license │ │ ├── TODO │ │ ├── fdt.c │ │ ├── fdt.h │ │ ├── fdt_addresses.c │ │ ├── fdt_empty_tree.c │ │ ├── fdt_overlay.c │ │ ├── fdt_ro.c │ │ ├── fdt_rw.c │ │ ├── fdt_strerror.c │ │ ├── fdt_sw.c │ │ ├── fdt_wip.c │ │ ├── libfdt.h │ │ ├── libfdt_env.h │ │ ├── libfdt_internal.h │ │ └── version.lds │ │ └── linux.c ├── shell │ ├── autoboot.c │ ├── aux.c │ ├── command.c │ ├── linux.c │ ├── main.c │ └── usbloader.c └── sym_order.txt └── tools └── vmacho.c /.github/workflows/dockerpublish.yml: -------------------------------------------------------------------------------- 1 | name: Docker 2 | 3 | on: 4 | push: 5 | # Publish `master` as Docker `latest` image. 6 | branches: 7 | - master 8 | 9 | paths: 10 | - Dockerfile 11 | - 'scripts/**' 12 | 13 | # Publish `v1.2.3` tags as releases. 14 | tags: 15 | - v* 16 | 17 | # Run tests for any PRs. 18 | pull_request: 19 | 20 | env: 21 | # TODO: Change variable to your image's name. 22 | IMAGE_NAME: build-pongo 23 | 24 | jobs: 25 | # Run tests. 26 | # See also https://docs.docker.com/docker-hub/builds/automated-testing/ 27 | test: 28 | runs-on: ubuntu-latest 29 | 30 | steps: 31 | - uses: actions/checkout@v2 32 | 33 | - name: Run tests 34 | run: | 35 | docker build . --file Dockerfile 36 | 37 | # Push image to GitHub Packages. 38 | # See also https://docs.docker.com/docker-hub/builds/ 39 | push: 40 | # Ensure test job passes before pushing image. 41 | needs: test 42 | 43 | runs-on: ubuntu-latest 44 | if: github.event_name == 'push' 45 | 46 | steps: 47 | - uses: actions/checkout@v2 48 | 49 | - name: Build image 50 | run: docker build . --file Dockerfile --tag image 51 | 52 | - name: Log into registry 53 | run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin 54 | 55 | - name: Push image 56 | run: | 57 | IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME 58 | 59 | # Change all uppercase to lowercase 60 | IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') 61 | 62 | # Strip git ref prefix from version 63 | VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') 64 | 65 | # Strip "v" prefix from tag name 66 | [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') 67 | 68 | # Use Docker `latest` tag convention 69 | [ "$VERSION" == "master" ] && VERSION=latest 70 | 71 | echo IMAGE_ID=$IMAGE_ID 72 | echo VERSION=$VERSION 73 | 74 | docker tag image $IMAGE_ID:$VERSION 75 | docker push $IMAGE_ID:$VERSION 76 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | build/ 3 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian 2 | 3 | RUN apt -y update; apt -y upgrade 4 | RUN apt -y install automake make autoconf git wget tar xz-utils lzma libtinfo5 xxd 5 | 6 | RUN mkdir -p /opt 7 | RUN cd /opt; wget https://github.com/sbingner/llvm-project/releases/download/v10.0.0-1/linux-ios-arm64e-clang-toolchain.tar.lzma; mv linux-ios-arm64e-clang-toolchain.tar.lzma linux-ios-arm64e-clang-toolchain.tar.xz; xz -d linux-ios-arm64e-clang-toolchain.tar.xz; tar xvf linux-ios-arm64e-clang-toolchain.tar 8 | 9 | ENV PATH="/opt/ios-arm64e-clang-toolchain/bin:${PATH}" 10 | 11 | RUN mkdir -p /opt/sdks; cd /opt/sdks; \ 12 | git clone https://github.com/xybp888/iOS-SDKs.git; \ 13 | mkdir -p /opt/ios-arm64e-clang-toolchain/sdks; \ 14 | ln -s /opt/sdks/iOS-SDKs/iPhoneOS12.1.2.sdk /opt/ios-arm64e-clang-toolchain/sdks/iPhoneOS.sdk 15 | 16 | RUN ln -s /opt/ios-arm64e-clang-toolchain/bin/strip /usr/local/bin/cctools-strip 17 | 18 | RUN mkdir -p /pongo 19 | 20 | ENV OBF no 21 | ENV PATH "/pongo/scripts:$PATH" 22 | 23 | CMD ["bash", "-c", "cd /pongo; make"] 24 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2020 checkra1n team 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | pongoOS 2 | ======= 3 | 4 | A pre-boot execution environment for Apple boards built on top of checkra1n. 5 | 6 | Building on macOS 7 | ----------- 8 | 9 | - Install Xcode + command-line utilities 10 | - `make clean all` 11 | 12 | Building on Linux 13 | ----------- 14 | 15 | - Download [Sam Bingner's iOS Toolchain](https://github.com/sbingner/llvm-project/releases/download/v10.0.0-1/linux-ios-arm64e-clang-toolchain.tar.lzma) 16 | - Copy `scripts/arm64-apple-ios12.0.0-clang` to a directory in `$PATH` 17 | - Adjust the `TOOLCHAIN` variable to point to the downloaded toolchain 18 | - `make clean all` 19 | 20 | Contributions 21 | ------------- 22 | 23 | By submitting a pull request, you certify that this contribution is coming from you and no one else. If you want to import third-party code, that shall be noted prominently for us to evaluate it appropriately. 24 | 25 | Module 26 | ------ 27 | You can build the module at example/ with an iOS cross-compiler on Linux or a Mac. Refer to scripts/ to see how to load modules. 28 | 29 | Kernel patchfinder 30 | ------------------ 31 | 32 | Note that the checkra1n patchfinder is not currently open-source. However, the KPF JIT that will ship on checkra1n 0.10.0 onwards is part of this repository. That means that pongoOS builds from this repository will always boot to the shell by default instead of XNU. 33 | -------------------------------------------------------------------------------- /aarch64-none-darwin/README.md: -------------------------------------------------------------------------------- 1 | # Newlib 2 | 3 | This folder contains [Newlib](https://sourceware.org/newlib/) headers and static libraries built for arm64 with the Darwin ABI. This provides the runtime standard library for PongoOS. 4 | 5 | ### Building 6 | 7 | The current build is based on Newlib 3.3.0 and requires a [custom patch](darwin.patch) to work with Apple's toolchain / the Darwin ABI. 8 | It can be built as follows (where `/path/to/PongoOS` should be replaced with the path to this repository): 9 | 10 | curl -O -J ftp://sourceware.org/pub/newlib/newlib-3.3.0.tar.gz 11 | tar -xf newlib-3.3.0.tar.gz 12 | cd newlib-3.3.0/newlib 13 | git apply /path/to/PongoOS/aarch64-none-darwin/darwin.patch 14 | ./configure --prefix=/tmp/build --host=aarch64-none-darwin --enable-newlib-io-c99-formats --enable-newlib-io-long-long --disable-newlib-io-float --disable-newlib-supplied-syscalls --disable-shared --enable-static CC='xcrun -sdk iphoneos clang' CFLAGS='-arch arm64 -Wall -O3 -nostdlib -nostdlibinc -fno-blocks -U__nonnull' LDFLAGS='-Wl,-preload,-e,_main' 15 | make 16 | make install 17 | 18 | The headers and static libraries will be placed in `/tmp/build/aarch64-none-darwin`. If you'd like to use them with PongoOS, simply move them from there to this directory. 19 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/_ansi.h: -------------------------------------------------------------------------------- 1 | /* Provide support for both ANSI and non-ANSI environments. */ 2 | 3 | /* To get a strict ANSI C environment, define macro __STRICT_ANSI__. This will 4 | "comment out" the non-ANSI parts of the ANSI header files (non-ANSI header 5 | files aren't affected). */ 6 | 7 | #ifndef _ANSIDECL_H_ 8 | #define _ANSIDECL_H_ 9 | 10 | #include 11 | #include 12 | 13 | /* ISO C++. */ 14 | 15 | #ifdef __cplusplus 16 | #if !(defined(_BEGIN_STD_C) && defined(_END_STD_C)) 17 | #ifdef _HAVE_STD_CXX 18 | #define _BEGIN_STD_C namespace std { extern "C" { 19 | #define _END_STD_C } } 20 | #else 21 | #define _BEGIN_STD_C extern "C" { 22 | #define _END_STD_C } 23 | #endif 24 | #if __GNUC_PREREQ (3, 3) 25 | #define _NOTHROW __attribute__ ((__nothrow__)) 26 | #else 27 | #define _NOTHROW throw() 28 | #endif 29 | #endif 30 | #else 31 | #define _BEGIN_STD_C 32 | #define _END_STD_C 33 | #define _NOTHROW 34 | #endif 35 | 36 | #ifndef _LONG_DOUBLE 37 | #define _LONG_DOUBLE long double 38 | #endif 39 | 40 | /* Support gcc's __attribute__ facility. */ 41 | 42 | #ifdef __GNUC__ 43 | #define _ATTRIBUTE(attrs) __attribute__ (attrs) 44 | #else 45 | #define _ATTRIBUTE(attrs) 46 | #endif 47 | 48 | /* The traditional meaning of 'extern inline' for GCC is not 49 | to emit the function body unless the address is explicitly 50 | taken. However this behaviour is changing to match the C99 51 | standard, which uses 'extern inline' to indicate that the 52 | function body *must* be emitted. Likewise, a function declared 53 | without either 'extern' or 'static' defaults to extern linkage 54 | (C99 6.2.2p5), and the compiler may choose whether to use the 55 | inline version or call the extern linkage version (6.7.4p6). 56 | If we are using GCC, but do not have the new behaviour, we need 57 | to use extern inline; if we are using a new GCC with the 58 | C99-compatible behaviour, or a non-GCC compiler (which we will 59 | have to hope is C99, since there is no other way to achieve the 60 | effect of omitting the function if it isn't referenced) we use 61 | 'static inline', which c99 defines to mean more-or-less the same 62 | as the Gnu C 'extern inline'. */ 63 | #if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__) 64 | /* We're using GCC, but without the new C99-compatible behaviour. */ 65 | #define _ELIDABLE_INLINE extern __inline__ _ATTRIBUTE ((__always_inline__)) 66 | #else 67 | /* We're using GCC in C99 mode, or an unknown compiler which 68 | we just have to hope obeys the C99 semantics of inline. */ 69 | #define _ELIDABLE_INLINE static __inline__ 70 | #endif 71 | 72 | #if __GNUC_PREREQ (3, 1) 73 | #define _NOINLINE __attribute__ ((__noinline__)) 74 | #define _NOINLINE_STATIC _NOINLINE static 75 | #else 76 | /* On non-GNU compilers and GCC prior to version 3.1 the compiler can't be 77 | trusted not to inline if it is static. */ 78 | #define _NOINLINE 79 | #define _NOINLINE_STATIC 80 | #endif 81 | 82 | #endif /* _ANSIDECL_H_ */ 83 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/_newlib_version.h: -------------------------------------------------------------------------------- 1 | /* _newlib_version.h. Generated from _newlib_version.hin by configure. */ 2 | /* Version macros for internal and downstream use. */ 3 | #ifndef _NEWLIB_VERSION_H__ 4 | #define _NEWLIB_VERSION_H__ 1 5 | 6 | #define _NEWLIB_VERSION "3.3.0" 7 | #define __NEWLIB__ 3 8 | #define __NEWLIB_MINOR__ 3 9 | #define __NEWLIB_PATCHLEVEL__ 0 10 | 11 | #endif /* !_NEWLIB_VERSION_H__ */ 12 | 13 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/_syslist.h: -------------------------------------------------------------------------------- 1 | /* internal use only -- mapping of "system calls" for libraries that lose 2 | and only provide C names, so that we end up in violation of ANSI */ 3 | #ifndef __SYSLIST_H 4 | #define __SYSLIST_H 5 | 6 | #ifdef MISSING_SYSCALL_NAMES 7 | #define _close close 8 | #define _execve execve 9 | #define _fcntl fcntl 10 | #define _fork fork 11 | #define _fstat fstat 12 | #define _getpid getpid 13 | #define _gettimeofday gettimeofday 14 | #define _isatty isatty 15 | #define _kill kill 16 | #define _link link 17 | #define _lseek lseek 18 | #define _mkdir mkdir 19 | #define _open open 20 | #define _read read 21 | #define _sbrk sbrk 22 | #define _stat stat 23 | #define _times times 24 | #define _unlink unlink 25 | #define _wait wait 26 | #define _write write 27 | #endif /* MISSING_SYSCALL_NAMES */ 28 | 29 | #if defined MISSING_SYSCALL_NAMES || !defined HAVE_OPENDIR 30 | /* If the system call interface is missing opendir, readdir, and 31 | closedir, there is an implementation of these functions in 32 | libc/posix that is implemented using open, getdents, and close. 33 | Note, these functions are currently not in the libc/syscalls 34 | directory. */ 35 | #define _opendir opendir 36 | #define _readdir readdir 37 | #define _closedir closedir 38 | #endif /* MISSING_SYSCALL_NAMES || !HAVE_OPENDIR */ 39 | 40 | #endif /* !__SYSLIST_H_ */ 41 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/alloca.h: -------------------------------------------------------------------------------- 1 | /* libc/include/alloca.h - Allocate memory on stack */ 2 | 3 | /* Written 2000 by Werner Almesberger */ 4 | /* Rearranged for general inclusion by stdlib.h. 5 | 2001, Corinna Vinschen */ 6 | 7 | #ifndef _NEWLIB_ALLOCA_H 8 | #define _NEWLIB_ALLOCA_H 9 | 10 | #include "_ansi.h" 11 | #include 12 | 13 | #undef alloca 14 | 15 | #ifdef __GNUC__ 16 | #define alloca(size) __builtin_alloca(size) 17 | #else 18 | void * alloca (size_t); 19 | #endif 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/argz.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. 2 | * 3 | * Permission to use, copy, modify, and distribute this software 4 | * is freely granted, provided that this notice is preserved. 5 | */ 6 | 7 | #ifndef _ARGZ_H_ 8 | #define _ARGZ_H_ 9 | 10 | #include 11 | #include 12 | 13 | #include "_ansi.h" 14 | 15 | _BEGIN_STD_C 16 | 17 | /* The newlib implementation of these functions assumes that sizeof(char) == 1. */ 18 | error_t argz_create (char *const argv[], char **argz, size_t *argz_len); 19 | error_t argz_create_sep (const char *string, int sep, char **argz, size_t *argz_len); 20 | size_t argz_count (const char *argz, size_t argz_len); 21 | void argz_extract (char *argz, size_t argz_len, char **argv); 22 | void argz_stringify (char *argz, size_t argz_len, int sep); 23 | error_t argz_add (char **argz, size_t *argz_len, const char *str); 24 | error_t argz_add_sep (char **argz, size_t *argz_len, const char *str, int sep); 25 | error_t argz_append (char **argz, size_t *argz_len, const char *buf, size_t buf_len); 26 | error_t argz_delete (char **argz, size_t *argz_len, char *entry); 27 | error_t argz_insert (char **argz, size_t *argz_len, char *before, const char *entry); 28 | char * argz_next (char *argz, size_t argz_len, const char *entry); 29 | error_t argz_replace (char **argz, size_t *argz_len, const char *str, const char *with, unsigned *replace_count); 30 | 31 | _END_STD_C 32 | 33 | #endif /* _ARGZ_H_ */ 34 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | assert.h 3 | */ 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | #include "_ansi.h" 10 | 11 | #undef assert 12 | 13 | #ifdef NDEBUG /* required by ANSI standard */ 14 | # define assert(__e) ((void)0) 15 | #else 16 | # define assert(__e) ((__e) ? (void)0 : __assert_func (__FILE__, __LINE__, \ 17 | __ASSERT_FUNC, #__e)) 18 | 19 | # ifndef __ASSERT_FUNC 20 | /* Use g++'s demangled names in C++. */ 21 | # if defined __cplusplus && defined __GNUC__ 22 | # define __ASSERT_FUNC __PRETTY_FUNCTION__ 23 | 24 | /* C99 requires the use of __func__. */ 25 | # elif __STDC_VERSION__ >= 199901L 26 | # define __ASSERT_FUNC __func__ 27 | 28 | /* Older versions of gcc don't have __func__ but can use __FUNCTION__. */ 29 | # elif __GNUC__ >= 2 30 | # define __ASSERT_FUNC __FUNCTION__ 31 | 32 | /* failed to detect __func__ support. */ 33 | # else 34 | # define __ASSERT_FUNC ((char *) 0) 35 | # endif 36 | # endif /* !__ASSERT_FUNC */ 37 | #endif /* !NDEBUG */ 38 | 39 | void __assert (const char *, int, const char *) 40 | _ATTRIBUTE ((__noreturn__)); 41 | void __assert_func (const char *, int, const char *, const char *) 42 | _ATTRIBUTE ((__noreturn__)); 43 | 44 | #if __STDC_VERSION__ >= 201112L && !defined __cplusplus 45 | # define static_assert _Static_assert 46 | #endif 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/cpio.h: -------------------------------------------------------------------------------- 1 | /* POSIX.1 symbolic constants for c_mode field of cpio archive format */ 2 | 3 | #ifndef _CPIO_H 4 | #define _CPIO_H 5 | 6 | #define C_IRUSR 0000400 /* Read by owner */ 7 | #define C_IWUSR 0000200 /* Write by owner */ 8 | #define C_IXUSR 0000100 /* Execute by owner */ 9 | #define C_IRGRP 0000040 /* Read by group */ 10 | #define C_IWGRP 0000020 /* Write by group */ 11 | #define C_IXGRP 0000010 /* Execute by group */ 12 | #define C_IROTH 0000004 /* Read by others */ 13 | #define C_IWOTH 0000002 /* Write by others */ 14 | #define C_IXOTH 0000001 /* Execute by others */ 15 | #define C_ISUID 0004000 /* Set user ID */ 16 | #define C_ISGID 0002000 /* Set group ID */ 17 | #define C_ISVTX 0001000 /* On directories, restricted deletion flag */ 18 | 19 | #define C_ISDIR 0040000 /* Directory */ 20 | #define C_ISFIFO 0010000 /* FIFO */ 21 | #define C_ISREG 0100000 /* Regular file */ 22 | #define C_ISBLK 0060000 /* Block special */ 23 | #define C_ISCHR 0020000 /* Character special */ 24 | #define C_ISCTG 0110000 /* Reserved */ 25 | #define C_ISLNK 0120000 /* Symbolic link */ 26 | #define C_ISSOCK 0140000 /* Socket */ 27 | 28 | #define MAGIC "070707" 29 | 30 | #endif /* _CPIO_H */ 31 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/devctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016,2019 Joel Sherrill . 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 | 27 | #ifndef _POSIX_DEVCTL_h_ 28 | #define _POSIX_DEVCTL_h_ 29 | 30 | /* 31 | * Nothing in this file should be visible unless _POSIX_26_C_SOURCE is 32 | * defined. 33 | */ 34 | #ifdef _POSIX_26_C_SOURCE 35 | 36 | #include 37 | 38 | #if defined(__rtems__) 39 | /* 40 | * The FACE Technical Standard, Edition 3.0 and later require the 41 | * definition of the subcommand SOCKCLOSE in . 42 | * 43 | * Reference: https://www.opengroup.org/face 44 | * 45 | * Using 'D' should avoid the letters used by other users of 46 | */ 47 | #include 48 | 49 | #define SOCKCLOSE _IO('D', 1) /* socket close */ 50 | #endif 51 | 52 | /* 53 | * The posix_devctl() method is defined by POSIX 1003.26-2003. Aside 54 | * from the single method, it adds the following requirements: 55 | * 56 | * + define _POSIX_26_VERSION to 200312L 57 | * + add _SC_POSIX_26_VERSION in . Return _POSIX_26_VERSION 58 | * + application must define _POSIX_26_C_SOURCE to use posix_devctl(). 59 | * + posix_devctl() is prototyped in 60 | */ 61 | int posix_devctl( 62 | int fd, 63 | int dcmd, 64 | void *__restrict dev_data_ptr, 65 | size_t nbyte, 66 | int *__restrict dev_info_ptr 67 | ); 68 | #endif 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/envlock.h: -------------------------------------------------------------------------------- 1 | /* envlock.h -- header file for env routines. */ 2 | 3 | #ifndef _INCLUDE_ENVLOCK_H_ 4 | #define _INCLUDE_ENVLOCK_H_ 5 | 6 | #include <_ansi.h> 7 | #include 8 | 9 | #define ENV_LOCK __env_lock(reent_ptr) 10 | #define ENV_UNLOCK __env_unlock(reent_ptr) 11 | 12 | void __env_lock (struct _reent *reent); 13 | void __env_unlock (struct _reent *reent); 14 | 15 | #endif /* _INCLUDE_ENVLOCK_H_ */ 16 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/envz.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. 2 | * 3 | * Permission to use, copy, modify, and distribute this software 4 | * is freely granted, provided that this notice is preserved. 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | /* The newlib implementation of these functions assumes that sizeof(char) == 1. */ 11 | char * envz_entry (const char *envz, size_t envz_len, const char *name); 12 | char * envz_get (const char *envz, size_t envz_len, const char *name); 13 | error_t envz_add (char **envz, size_t *envz_len, const char *name, const char *value); 14 | error_t envz_merge (char **envz, size_t *envz_len, const char *envz2, size_t envz2_len, int override); 15 | void envz_remove(char **envz, size_t *envz_len, const char *name); 16 | void envz_strip (char **envz, size_t *envz_len); 17 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/errno.h: -------------------------------------------------------------------------------- 1 | #ifndef __ERRNO_H__ 2 | #define __ERRNO_H__ 3 | 4 | #ifndef __error_t_defined 5 | typedef int error_t; 6 | #define __error_t_defined 1 7 | #endif 8 | 9 | #include 10 | 11 | #endif /* !__ERRNO_H__ */ 12 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/fastmath.h: -------------------------------------------------------------------------------- 1 | #ifndef _FASTMATH_H_ 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | #define _FASTMATH_H_ 6 | 7 | #include 8 | #include 9 | 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | #endif /* _FASTMATH_H_ */ 14 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/fcntl.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/fenv.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017 SiFive Inc. All rights reserved. 2 | 3 | This copyrighted material is made available to anyone wishing to use, 4 | modify, copy, or redistribute it subject to the terms and conditions 5 | of the FreeBSD License. This program is distributed in the hope that 6 | it will be useful, but WITHOUT ANY WARRANTY expressed or implied, 7 | including the implied warranties of MERCHANTABILITY or FITNESS FOR 8 | A PARTICULAR PURPOSE. A copy of this license is available at 9 | http://www.opensource.org/licenses. 10 | */ 11 | 12 | #ifndef _FENV_H 13 | #define _FENV_H 14 | 15 | #include 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | /* Exception */ 22 | int feclearexcept(int excepts); 23 | int fegetexceptflag(fexcept_t *flagp, int excepts); 24 | int feraiseexcept(int excepts); 25 | int fesetexceptflag(const fexcept_t *flagp, int excepts); 26 | int fetestexcept(int excepts); 27 | 28 | /* Rounding mode */ 29 | int fegetround(void); 30 | int fesetround(int rounding_mode); 31 | 32 | /* Float environment */ 33 | int fegetenv(fenv_t *envp); 34 | int feholdexcept(fenv_t *envp); 35 | int fesetenv(const fenv_t *envp); 36 | int feupdateenv(const fenv_t *envp); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /aarch64-none-darwin/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 | * 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 | * $FreeBSD: src/include/fnmatch.h,v 1.10 2002/03/23 17:24:53 imp Exp $ 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 __GNU_VISIBLE 45 | #define FNM_LEADING_DIR 0x08 /* Ignore / after Imatch. */ 46 | #define FNM_CASEFOLD 0x10 /* Case insensitive search. */ 47 | #define FNM_IGNORECASE FNM_CASEFOLD 48 | #define FNM_FILE_NAME FNM_PATHNAME 49 | #endif 50 | 51 | __BEGIN_DECLS 52 | int fnmatch(const char *, const char *, int); 53 | __END_DECLS 54 | 55 | #endif /* !_FNMATCH_H_ */ 56 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/iconv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003-2004, Artem B. Bityuckiy, SoftMine Corporation. 3 | * Rights transferred to Franklin Electronic Publishers. 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 | #ifndef _ICONV_H_ 27 | #define _ICONV_H_ 28 | 29 | #include <_ansi.h> 30 | #include 31 | #include 32 | #include 33 | 34 | /* iconv_t: charset conversion descriptor type */ 35 | typedef _iconv_t iconv_t; 36 | 37 | _BEGIN_STD_C 38 | 39 | #ifndef _REENT_ONLY 40 | iconv_t 41 | iconv_open (const char *, const char *); 42 | 43 | size_t 44 | iconv (iconv_t, char **__restrict, size_t *__restrict, 45 | char **__restrict, size_t *__restrict); 46 | 47 | int 48 | iconv_close (iconv_t); 49 | #endif 50 | 51 | iconv_t 52 | _iconv_open_r (struct _reent *, const char *, const char *); 53 | 54 | size_t 55 | _iconv_r (struct _reent *, iconv_t, const char **, 56 | size_t *, char **, size_t *); 57 | 58 | int 59 | _iconv_close_r (struct _reent *, iconv_t); 60 | 61 | _END_STD_C 62 | 63 | #endif /* #ifndef _ICONV_H_ */ 64 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/libgen.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libgen.h - defined by XPG4 3 | */ 4 | 5 | #ifndef _LIBGEN_H_ 6 | #define _LIBGEN_H_ 7 | 8 | #include "_ansi.h" 9 | #include 10 | #include 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /* There are two common basename variants. If you do NOT #include 17 | and you do 18 | 19 | #define _GNU_SOURCE 20 | #include 21 | 22 | you get the GNU version. Otherwise you get the POSIX versionfor which you 23 | should #include i for the function prototype. POSIX requires that 24 | #undef basename will still let you invoke the underlying function. However, 25 | this also implies that the POSIX version is used in this case. That's made 26 | sure here. */ 27 | #undef basename 28 | #define basename __xpg_basename 29 | char *basename (char *) __asm__(__ASMNAME("basename")); 30 | char *dirname (char *); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif /* _LIBGEN_H_ */ 37 | 38 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/locale.h: -------------------------------------------------------------------------------- 1 | /* 2 | locale.h 3 | Values appropriate for the formatting of monetary and other 4 | numberic quantities. 5 | */ 6 | 7 | #ifndef _LOCALE_H_ 8 | #define _LOCALE_H_ 9 | 10 | #include "_ansi.h" 11 | #include 12 | 13 | #define __need_NULL 14 | #include 15 | 16 | #define LC_ALL 0 17 | #define LC_COLLATE 1 18 | #define LC_CTYPE 2 19 | #define LC_MONETARY 3 20 | #define LC_NUMERIC 4 21 | #define LC_TIME 5 22 | #define LC_MESSAGES 6 23 | 24 | #if __POSIX_VISIBLE >= 200809 || defined (_COMPILING_NEWLIB) 25 | 26 | #include 27 | 28 | #define LC_ALL_MASK (1 << LC_ALL) 29 | #define LC_COLLATE_MASK (1 << LC_COLLATE) 30 | #define LC_CTYPE_MASK (1 << LC_CTYPE) 31 | #define LC_MONETARY_MASK (1 << LC_MONETARY) 32 | #define LC_NUMERIC_MASK (1 << LC_NUMERIC) 33 | #define LC_TIME_MASK (1 << LC_TIME) 34 | #define LC_MESSAGES_MASK (1 << LC_MESSAGES) 35 | 36 | #define LC_GLOBAL_LOCALE ((struct __locale_t *) -1) 37 | 38 | #endif /* __POSIX_VISIBLE >= 200809 */ 39 | 40 | _BEGIN_STD_C 41 | 42 | struct lconv 43 | { 44 | char *decimal_point; 45 | char *thousands_sep; 46 | char *grouping; 47 | char *int_curr_symbol; 48 | char *currency_symbol; 49 | char *mon_decimal_point; 50 | char *mon_thousands_sep; 51 | char *mon_grouping; 52 | char *positive_sign; 53 | char *negative_sign; 54 | char int_frac_digits; 55 | char frac_digits; 56 | char p_cs_precedes; 57 | char p_sep_by_space; 58 | char n_cs_precedes; 59 | char n_sep_by_space; 60 | char p_sign_posn; 61 | char n_sign_posn; 62 | char int_n_cs_precedes; 63 | char int_n_sep_by_space; 64 | char int_n_sign_posn; 65 | char int_p_cs_precedes; 66 | char int_p_sep_by_space; 67 | char int_p_sign_posn; 68 | }; 69 | 70 | struct _reent; 71 | char *_setlocale_r (struct _reent *, int, const char *); 72 | struct lconv *_localeconv_r (struct _reent *); 73 | 74 | struct __locale_t *_newlocale_r (struct _reent *, int, const char *, 75 | struct __locale_t *); 76 | void _freelocale_r (struct _reent *, struct __locale_t *); 77 | struct __locale_t *_duplocale_r (struct _reent *, struct __locale_t *); 78 | struct __locale_t *_uselocale_r (struct _reent *, struct __locale_t *); 79 | 80 | #ifndef _REENT_ONLY 81 | 82 | char *setlocale (int, const char *); 83 | struct lconv *localeconv (void); 84 | 85 | #if __POSIX_VISIBLE >= 200809 86 | locale_t newlocale (int, const char *, locale_t); 87 | void freelocale (locale_t); 88 | locale_t duplocale (locale_t); 89 | locale_t uselocale (locale_t); 90 | #endif /* __POSIX_VISIBLE >= 200809 */ 91 | 92 | #endif /* _REENT_ONLY */ 93 | 94 | _END_STD_C 95 | 96 | #endif /* _LOCALE_H_ */ 97 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/machine/_arc4random.h: -------------------------------------------------------------------------------- 1 | /* Use default implementation, see arc4random.h */ 2 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/machine/_endian.h: -------------------------------------------------------------------------------- 1 | #ifndef __MACHINE_ENDIAN_H__ 2 | #error "must be included via " 3 | #endif /* !__MACHINE_ENDIAN_H__ */ 4 | 5 | #include 6 | 7 | #ifdef __PPC__ 8 | /* Get rid of GCC builtin defines on PowerPC */ 9 | #ifdef _BIG_ENDIAN 10 | #undef _BIG_ENDIAN 11 | #endif 12 | #ifdef _LITTLE_ENDIAN 13 | #undef _LITTLE_ENDIAN 14 | #endif 15 | #endif /* __PPC__ */ 16 | 17 | #ifndef _LITTLE_ENDIAN 18 | #define _LITTLE_ENDIAN 1234 19 | #endif 20 | 21 | #ifndef _BIG_ENDIAN 22 | #define _BIG_ENDIAN 4321 23 | #endif 24 | 25 | #ifndef _PDP_ENDIAN 26 | #define _PDP_ENDIAN 3412 27 | #endif 28 | 29 | #ifndef _BYTE_ORDER 30 | #if defined(__IEEE_LITTLE_ENDIAN) || defined(__IEEE_BYTES_LITTLE_ENDIAN) 31 | #define _BYTE_ORDER _LITTLE_ENDIAN 32 | #else 33 | #define _BYTE_ORDER _BIG_ENDIAN 34 | #endif 35 | #endif 36 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/machine/_time.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_TIME_H_ 2 | #error "must be included via " 3 | #endif /* !_SYS_TIME_H_ */ 4 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/machine/_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012 ARM Ltd 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. The name of the company may not be used to endorse or promote 14 | products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED 18 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 22 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef _MACHINE__TYPES_H 30 | #define _MACHINE__TYPES_H 31 | 32 | #include 33 | 34 | #define __machine_ssize_t_defined 35 | typedef long signed int _ssize_t; 36 | 37 | #endif /* _MACHINE__TYPES_H */ 38 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/machine/ansi.h: -------------------------------------------------------------------------------- 1 | /* dummy header file to support BSD compiler */ 2 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/machine/endian.h: -------------------------------------------------------------------------------- 1 | #ifndef __MACHINE_ENDIAN_H__ 2 | #define __MACHINE_ENDIAN_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #if _BYTE_ORDER == _LITTLE_ENDIAN 9 | #define _QUAD_HIGHWORD 1 10 | #define _QUAD_LOWWORD 0 11 | #else 12 | #define _QUAD_HIGHWORD 0 13 | #define _QUAD_LOWWORD 1 14 | #endif 15 | 16 | #if __BSD_VISIBLE 17 | #define LITTLE_ENDIAN _LITTLE_ENDIAN 18 | #define BIG_ENDIAN _BIG_ENDIAN 19 | #define PDP_ENDIAN _PDP_ENDIAN 20 | #define BYTE_ORDER _BYTE_ORDER 21 | #endif 22 | 23 | #ifdef __GNUC__ 24 | #define __bswap16(_x) __builtin_bswap16(_x) 25 | #define __bswap32(_x) __builtin_bswap32(_x) 26 | #define __bswap64(_x) __builtin_bswap64(_x) 27 | #else /* __GNUC__ */ 28 | static __inline __uint16_t 29 | __bswap16(__uint16_t _x) 30 | { 31 | 32 | return ((__uint16_t)((_x >> 8) | ((_x << 8) & 0xff00))); 33 | } 34 | 35 | static __inline __uint32_t 36 | __bswap32(__uint32_t _x) 37 | { 38 | 39 | return ((__uint32_t)((_x >> 24) | ((_x >> 8) & 0xff00) | 40 | ((_x << 8) & 0xff0000) | ((_x << 24) & 0xff000000))); 41 | } 42 | 43 | static __inline __uint64_t 44 | __bswap64(__uint64_t _x) 45 | { 46 | 47 | return ((__uint64_t)((_x >> 56) | ((_x >> 40) & 0xff00) | 48 | ((_x >> 24) & 0xff0000) | ((_x >> 8) & 0xff000000) | 49 | ((_x << 8) & ((__uint64_t)0xff << 32)) | 50 | ((_x << 24) & ((__uint64_t)0xff << 40)) | 51 | ((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56)))); 52 | } 53 | #endif /* !__GNUC__ */ 54 | 55 | #ifndef __machine_host_to_from_network_defined 56 | #if _BYTE_ORDER == _LITTLE_ENDIAN 57 | #define __htonl(_x) __bswap32(_x) 58 | #define __htons(_x) __bswap16(_x) 59 | #define __ntohl(_x) __bswap32(_x) 60 | #define __ntohs(_x) __bswap16(_x) 61 | #else 62 | #define __htonl(_x) ((__uint32_t)(_x)) 63 | #define __htons(_x) ((__uint16_t)(_x)) 64 | #define __ntohl(_x) ((__uint32_t)(_x)) 65 | #define __ntohs(_x) ((__uint16_t)(_x)) 66 | #endif 67 | #endif /* __machine_host_to_from_network_defined */ 68 | 69 | #endif /* __MACHINE_ENDIAN_H__ */ 70 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/machine/malloc.h: -------------------------------------------------------------------------------- 1 | #ifndef _MACHMALLOC_H_ 2 | #define _MACHMALLOC_H_ 3 | 4 | /* place holder so platforms may add malloc.h extensions */ 5 | 6 | #endif /* _MACHMALLOC_H_ */ 7 | 8 | 9 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/machine/param.h: -------------------------------------------------------------------------------- 1 | /* Place holder for machine-specific param.h. */ 2 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/machine/setjmp-dj.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1991 DJ Delorie 3 | * All rights reserved. 4 | * 5 | * Redistribution, modification, and use in source and binary forms is permitted 6 | * provided that the above copyright notice and following paragraph are 7 | * duplicated in all such forms. 8 | * 9 | * This file is distributed WITHOUT ANY WARRANTY; without even the implied 10 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | /* Modified to use SETJMP_DJ_H rather than SETJMP_H to avoid 14 | conflicting with setjmp.h. Ian Taylor, Cygnus support, April, 15 | 1993. */ 16 | 17 | #ifndef _SETJMP_DJ_H_ 18 | #define _SETJMP_DJ_H_ 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef struct { 25 | unsigned long eax; 26 | unsigned long ebx; 27 | unsigned long ecx; 28 | unsigned long edx; 29 | unsigned long esi; 30 | unsigned long edi; 31 | unsigned long ebp; 32 | unsigned long esp; 33 | unsigned long eip; 34 | } jmp_buf[1]; 35 | 36 | extern int setjmp(jmp_buf); 37 | extern void longjmp(jmp_buf, int); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/machine/stdlib.h: -------------------------------------------------------------------------------- 1 | #ifndef _MACHSTDLIB_H_ 2 | #define _MACHSTDLIB_H_ 3 | 4 | /* place holder so platforms may add stdlib.h extensions */ 5 | 6 | #endif /* _MACHSTDLIB_H_ */ 7 | 8 | 9 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/machine/termios.h: -------------------------------------------------------------------------------- 1 | #define __MAX_BAUD B4000000 2 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/machine/time.h: -------------------------------------------------------------------------------- 1 | #ifndef _MACHTIME_H_ 2 | #define _MACHTIME_H_ 3 | 4 | #if defined(__rtems__) || defined(__VISIUM__) || defined(__riscv) 5 | #define _CLOCKS_PER_SEC_ 1000000 6 | #elif defined(__aarch64__) || defined(__arm__) || defined(__thumb__) 7 | #define _CLOCKS_PER_SEC_ 100 8 | #endif 9 | 10 | #ifdef __SPU__ 11 | #include 12 | int nanosleep (const struct timespec *, struct timespec *); 13 | #endif 14 | 15 | #endif /* _MACHTIME_H_ */ 16 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/machine/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Newlib targets may provide an own version of this file in their machine 3 | * directory to add custom user types for . 4 | */ 5 | #ifndef _SYS_TYPES_H 6 | #error "must be included via " 7 | #endif /* !_SYS_TYPES_H */ 8 | 9 | #if defined(__XMK__) && defined(___int64_t_defined) 10 | typedef __uint64_t u_quad_t; 11 | typedef __int64_t quad_t; 12 | typedef quad_t * qaddr_t; 13 | #endif 14 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/memory.h: -------------------------------------------------------------------------------- 1 | #ifndef _MEMORY_H 2 | #define _MEMORY_H 3 | #include 4 | #endif /* !_MEMORY_H */ 5 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/paths.h: -------------------------------------------------------------------------------- 1 | #ifndef _PATHS_H_ 2 | #define _PATHS_H_ 3 | 4 | #define _PATH_DEV "/dev/" 5 | #define _PATH_DEVNULL "/dev/null" 6 | #define _PATH_DEVZERO "/dev/zero" 7 | #define _PATH_BSHELL "/bin/sh" 8 | 9 | #endif /* _PATHS_H_ */ 10 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/regdef.h: -------------------------------------------------------------------------------- 1 | /* regdef.h -- define register names. */ 2 | 3 | /* This is a standard include file for MIPS targets. Other target 4 | probably don't define it, and attempts to include this file will 5 | fail. */ 6 | 7 | #include 8 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/search.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: search.h,v 1.12 1999/02/22 10:34:28 christos Exp $ */ 2 | /* $FreeBSD: src/include/search.h,v 1.4 2002/03/23 17:24:53 imp Exp $ */ 3 | 4 | /* 5 | * Written by J.T. Conklin 6 | * Public domain. 7 | */ 8 | 9 | #ifndef _SEARCH_H_ 10 | #define _SEARCH_H_ 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | typedef struct entry { 17 | char *key; 18 | void *data; 19 | } ENTRY; 20 | 21 | typedef enum { 22 | FIND, ENTER 23 | } ACTION; 24 | 25 | typedef enum { 26 | preorder, 27 | postorder, 28 | endorder, 29 | leaf 30 | } VISIT; 31 | 32 | #ifdef _SEARCH_PRIVATE 33 | typedef struct node { 34 | char *key; 35 | struct node *llink, *rlink; 36 | } node_t; 37 | #endif 38 | 39 | struct hsearch_data 40 | { 41 | struct internal_head *htable; 42 | size_t htablesize; 43 | }; 44 | 45 | #ifndef __compar_fn_t_defined 46 | #define __compar_fn_t_defined 47 | typedef int (*__compar_fn_t) (const void *, const void *); 48 | #endif 49 | 50 | __BEGIN_DECLS 51 | int hcreate(size_t); 52 | void hdestroy(void); 53 | ENTRY *hsearch(ENTRY, ACTION); 54 | int hcreate_r(size_t, struct hsearch_data *); 55 | void hdestroy_r(struct hsearch_data *); 56 | int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *); 57 | void *tdelete(const void *__restrict, void **__restrict, __compar_fn_t); 58 | void tdestroy (void *, void (*)(void *)); 59 | void *tfind(const void *, void **, __compar_fn_t); 60 | void *tsearch(const void *, void **, __compar_fn_t); 61 | void twalk(const void *, void (*)(const void *, VISIT, int)); 62 | __END_DECLS 63 | 64 | #endif /* !_SEARCH_H_ */ 65 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/setjmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | setjmp.h 3 | stubs for future use. 4 | */ 5 | 6 | #ifndef _SETJMP_H_ 7 | #define _SETJMP_H_ 8 | 9 | #include "_ansi.h" 10 | #include 11 | 12 | _BEGIN_STD_C 13 | 14 | #ifdef __GNUC__ 15 | void longjmp (jmp_buf __jmpb, int __retval) 16 | __attribute__ ((__noreturn__)); 17 | #else 18 | void longjmp (jmp_buf __jmpb, int __retval); 19 | #endif 20 | int setjmp (jmp_buf __jmpb); 21 | 22 | _END_STD_C 23 | 24 | #endif /* _SETJMP_H_ */ 25 | 26 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/signal.h: -------------------------------------------------------------------------------- 1 | #ifndef _SIGNAL_H_ 2 | #define _SIGNAL_H_ 3 | 4 | #include "_ansi.h" 5 | #include 6 | #include 7 | 8 | _BEGIN_STD_C 9 | 10 | typedef int sig_atomic_t; /* Atomic entity type (ANSI) */ 11 | #if __BSD_VISIBLE 12 | typedef _sig_func_ptr sig_t; /* BSD naming */ 13 | #endif 14 | #if __GNU_VISIBLE 15 | typedef _sig_func_ptr sighandler_t; /* glibc naming */ 16 | #endif 17 | 18 | #define SIG_DFL ((_sig_func_ptr)0) /* Default action */ 19 | #define SIG_IGN ((_sig_func_ptr)1) /* Ignore action */ 20 | #define SIG_ERR ((_sig_func_ptr)-1) /* Error return */ 21 | 22 | struct _reent; 23 | 24 | _sig_func_ptr _signal_r (struct _reent *, int, _sig_func_ptr); 25 | int _raise_r (struct _reent *, int); 26 | 27 | #ifndef _REENT_ONLY 28 | _sig_func_ptr signal (int, _sig_func_ptr); 29 | int raise (int); 30 | void psignal (int, const char *); 31 | #endif 32 | 33 | _END_STD_C 34 | 35 | #endif /* _SIGNAL_H_ */ 36 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/ssp/stdlib.h: -------------------------------------------------------------------------------- 1 | #ifndef _SSP_STDLIB_H_ 2 | #define _SSP_STDLIB_H_ 3 | 4 | #include 5 | 6 | #if __SSP_FORTIFY_LEVEL > 0 7 | __BEGIN_DECLS 8 | 9 | __ssp_decl(size_t, mbstowcs, (wchar_t *__buf, const char *__src, size_t __n)) 10 | { 11 | if (__buf != NULL) 12 | __ssp_check(__buf, __n * sizeof(wchar_t), __ssp_bos); 13 | return __ssp_real_mbstowcs (__buf, __src, __n); 14 | } 15 | 16 | __ssp_redirect_raw(size_t, wcstombs, \ 17 | (char *__buf, const wchar_t *__src, size_t __len), \ 18 | (__buf, __src, __len), __buf != NULL, __ssp_bos); 19 | 20 | __ssp_decl(int, wctomb, (char *__buf, wchar_t __wc)) 21 | { 22 | if (__buf != NULL) 23 | __ssp_check(__buf, MB_CUR_MAX, __ssp_bos); 24 | return __ssp_real_wctomb (__buf, __wc); 25 | } 26 | 27 | __END_DECLS 28 | 29 | #endif /* __SSP_FORTIFY_LEVEL > 0 */ 30 | #endif /* _SSP_STDLIB_H_ */ 31 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/ssp/strings.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: strings.h,v 1.3 2008/04/28 20:22:54 martin Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. 5 | * All rights reserved. 6 | * 7 | * This code is derived from software contributed to The NetBSD Foundation 8 | * by Christos Zoulas. 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 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | * POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | #ifndef _SSP_STRINGS_H_ 32 | #define _SSP_STRINGS_H_ 33 | 34 | #include 35 | 36 | #if __SSP_FORTIFY_LEVEL > 0 37 | 38 | #if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112 39 | #define bcopy(src, dst, len) \ 40 | ((__ssp_bos0(dst) != (size_t)-1) ? \ 41 | __builtin___memmove_chk(dst, src, len, __ssp_bos0(dst)) : \ 42 | __memmove_ichk(dst, src, len)) 43 | #define bzero(dst, len) \ 44 | ((__ssp_bos0(dst) != (size_t)-1) ? \ 45 | __builtin___memset_chk(dst, 0, len, __ssp_bos0(dst)) : \ 46 | __memset_ichk(dst, 0, len)) 47 | #endif 48 | 49 | #if __BSD_VISIBLE 50 | __ssp_redirect0(void, explicit_bzero, (void *__buf, size_t __len), \ 51 | (__buf, __len)); 52 | #endif 53 | 54 | #endif /* __SSP_FORTIFY_LEVEL > 0 */ 55 | #endif /* _SSP_STRINGS_H_ */ 56 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/stdio_ext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * stdio_ext.h 3 | * 4 | * Definitions for I/O internal operations, originally from Solaris. 5 | */ 6 | 7 | #ifndef _STDIO_EXT_H_ 8 | #define _STDIO_EXT_H_ 9 | 10 | #ifdef __rtems__ 11 | #error " not supported" 12 | #endif 13 | 14 | #include 15 | 16 | #define FSETLOCKING_QUERY 0 17 | #define FSETLOCKING_INTERNAL 1 18 | #define FSETLOCKING_BYCALLER 2 19 | 20 | _BEGIN_STD_C 21 | 22 | void __fpurge (FILE *); 23 | int __fsetlocking (FILE *, int); 24 | 25 | /* TODO: 26 | 27 | void _flushlbf (void); 28 | */ 29 | 30 | #ifdef __GNUC__ 31 | 32 | _ELIDABLE_INLINE size_t 33 | __fbufsize (FILE *__fp) { return (size_t) __fp->_bf._size; } 34 | 35 | _ELIDABLE_INLINE int 36 | __freading (FILE *__fp) { return (__fp->_flags & __SRD) != 0; } 37 | 38 | _ELIDABLE_INLINE int 39 | __fwriting (FILE *__fp) { return (__fp->_flags & __SWR) != 0; } 40 | 41 | _ELIDABLE_INLINE int 42 | __freadable (FILE *__fp) { return (__fp->_flags & (__SRD | __SRW)) != 0; } 43 | 44 | _ELIDABLE_INLINE int 45 | __fwritable (FILE *__fp) { return (__fp->_flags & (__SWR | __SRW)) != 0; } 46 | 47 | _ELIDABLE_INLINE int 48 | __flbf (FILE *__fp) { return (__fp->_flags & __SLBF) != 0; } 49 | 50 | _ELIDABLE_INLINE size_t 51 | __fpending (FILE *__fp) { return __fp->_p - __fp->_bf._base; } 52 | 53 | #else 54 | 55 | size_t __fbufsize (FILE *); 56 | int __freading (FILE *); 57 | int __fwriting (FILE *); 58 | int __freadable (FILE *); 59 | int __fwritable (FILE *); 60 | int __flbf (FILE *); 61 | size_t __fpending (FILE *); 62 | 63 | #ifndef __cplusplus 64 | 65 | #define __fbufsize(__fp) ((size_t) (__fp)->_bf._size) 66 | #define __freading(__fp) (((__fp)->_flags & __SRD) != 0) 67 | #define __fwriting(__fp) (((__fp)->_flags & __SWR) != 0) 68 | #define __freadable(__fp) (((__fp)->_flags & (__SRD | __SRW)) != 0) 69 | #define __fwritable(__fp) (((__fp)->_flags & (__SWR | __SRW)) != 0) 70 | #define __flbf(__fp) (((__fp)->_flags & __SLBF) != 0) 71 | #define __fpending(__fp) ((size_t) ((__fp)->_p - (__fp)->_bf._base)) 72 | 73 | #endif /* __cplusplus */ 74 | 75 | #endif /* __GNUC__ */ 76 | 77 | _END_STD_C 78 | 79 | #endif /* _STDIO_EXT_H_ */ 80 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/sys/_locale.h: -------------------------------------------------------------------------------- 1 | /* Definition of opaque POSIX-1.2008 type locale_t for userspace. */ 2 | 3 | #ifndef _SYS__LOCALE_H 4 | #define _SYS__LOCALE_H 5 | 6 | #include 7 | #include 8 | 9 | struct __locale_t; 10 | typedef struct __locale_t *locale_t; 11 | 12 | #endif /* _SYS__LOCALE_H */ 13 | -------------------------------------------------------------------------------- /aarch64-none-darwin/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$ 36 | */ 37 | 38 | #ifndef _SYS__SIGSET_H_ 39 | #define _SYS__SIGSET_H_ 40 | 41 | typedef unsigned long __sigset_t; 42 | 43 | #endif /* !_SYS__SIGSET_H_ */ 44 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/sys/_stdint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2005 by 3 | * Ralf Corsepius, Ulm/Germany. All rights reserved. 4 | * 5 | * Permission to use, copy, modify, and distribute this software 6 | * is freely granted, provided that this notice is preserved. 7 | */ 8 | 9 | #ifndef _SYS__STDINT_H 10 | #define _SYS__STDINT_H 11 | 12 | #include 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #ifdef ___int8_t_defined 19 | #ifndef _INT8_T_DECLARED 20 | typedef __int8_t int8_t ; 21 | #define _INT8_T_DECLARED 22 | #endif 23 | #ifndef _UINT8_T_DECLARED 24 | typedef __uint8_t uint8_t ; 25 | #define _UINT8_T_DECLARED 26 | #endif 27 | #define __int8_t_defined 1 28 | #endif /* ___int8_t_defined */ 29 | 30 | #ifdef ___int16_t_defined 31 | #ifndef _INT16_T_DECLARED 32 | typedef __int16_t int16_t ; 33 | #define _INT16_T_DECLARED 34 | #endif 35 | #ifndef _UINT16_T_DECLARED 36 | typedef __uint16_t uint16_t ; 37 | #define _UINT16_T_DECLARED 38 | #endif 39 | #define __int16_t_defined 1 40 | #endif /* ___int16_t_defined */ 41 | 42 | #ifdef ___int32_t_defined 43 | #ifndef _INT32_T_DECLARED 44 | typedef __int32_t int32_t ; 45 | #define _INT32_T_DECLARED 46 | #endif 47 | #ifndef _UINT32_T_DECLARED 48 | typedef __uint32_t uint32_t ; 49 | #define _UINT32_T_DECLARED 50 | #endif 51 | #define __int32_t_defined 1 52 | #endif /* ___int32_t_defined */ 53 | 54 | #ifdef ___int64_t_defined 55 | #ifndef _INT64_T_DECLARED 56 | typedef __int64_t int64_t ; 57 | #define _INT64_T_DECLARED 58 | #endif 59 | #ifndef _UINT64_T_DECLARED 60 | typedef __uint64_t uint64_t ; 61 | #define _UINT64_T_DECLARED 62 | #endif 63 | #define __int64_t_defined 1 64 | #endif /* ___int64_t_defined */ 65 | 66 | #ifndef _INTMAX_T_DECLARED 67 | typedef __intmax_t intmax_t; 68 | #define _INTMAX_T_DECLARED 69 | #endif 70 | 71 | #ifndef _UINTMAX_T_DECLARED 72 | typedef __uintmax_t uintmax_t; 73 | #define _UINTMAX_T_DECLARED 74 | #endif 75 | 76 | #ifndef _INTPTR_T_DECLARED 77 | typedef __intptr_t intptr_t; 78 | #define _INTPTR_T_DECLARED 79 | #endif 80 | 81 | #ifndef _UINTPTR_T_DECLARED 82 | typedef __uintptr_t uintptr_t; 83 | #define _UINTPTR_T_DECLARED 84 | #endif 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif /* _SYS__STDINT_H */ 91 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/sys/_timespec.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1982, 1986, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following 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 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | * 31 | * @(#)time.h 8.5 (Berkeley) 5/4/95 32 | * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp 33 | * $FreeBSD: head/sys/sys/_timespec.h 326023 2017-11-20 19:43:44Z pfg $ 34 | */ 35 | 36 | #ifndef _SYS__TIMESPEC_H_ 37 | #define _SYS__TIMESPEC_H_ 38 | 39 | #include 40 | 41 | #if !defined(__time_t_defined) && !defined(_TIME_T_DECLARED) 42 | typedef _TIME_T_ time_t; 43 | #define __time_t_defined 44 | #define _TIME_T_DECLARED 45 | #endif 46 | 47 | struct timespec { 48 | time_t tv_sec; /* seconds */ 49 | long tv_nsec; /* and nanoseconds */ 50 | }; 51 | 52 | #endif /* !_SYS__TIMESPEC_H_ */ 53 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/sys/_timeval.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 | * 4 | * Copyright (c) 2002 Mike Barcroft 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following 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 AND CONTRIBUTORS ``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 THE AUTHOR OR CONTRIBUTORS 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: head/sys/sys/_timeval.h 326256 2017-11-27 15:01:59Z pfg $ 29 | */ 30 | 31 | #ifndef _SYS__TIMEVAL_H_ 32 | #define _SYS__TIMEVAL_H_ 33 | 34 | #include 35 | 36 | #ifndef _SUSECONDS_T_DECLARED 37 | typedef __suseconds_t suseconds_t; 38 | #define _SUSECONDS_T_DECLARED 39 | #endif 40 | 41 | #if !defined(__time_t_defined) && !defined(_TIME_T_DECLARED) 42 | typedef _TIME_T_ time_t; 43 | #define __time_t_defined 44 | #define _TIME_T_DECLARED 45 | #endif 46 | 47 | /* This define is also used outside of Newlib, e.g. in MinGW-w64 */ 48 | #ifndef _TIMEVAL_DEFINED 49 | #define _TIMEVAL_DEFINED 50 | 51 | /* 52 | * Structure returned by gettimeofday(2) system call, and used in other calls. 53 | */ 54 | struct timeval { 55 | time_t tv_sec; /* seconds */ 56 | suseconds_t tv_usec; /* and microseconds */ 57 | }; 58 | #endif /* _TIMEVAL_DEFINED */ 59 | 60 | #endif /* !_SYS__TIMEVAL_H_ */ 61 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/sys/custom_file.h: -------------------------------------------------------------------------------- 1 | #error System-specific custom_file.h is missing. 2 | 3 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/sys/dir.h: -------------------------------------------------------------------------------- 1 | /* BSD predecessor of POSIX.1 and struct dirent */ 2 | 3 | #ifndef _SYS_DIR_H_ 4 | #define _SYS_DIR_H_ 5 | 6 | #include 7 | 8 | #define direct dirent 9 | 10 | #endif /*_SYS_DIR_H_*/ 11 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/sys/dirent.h: -------------------------------------------------------------------------------- 1 | /* includes , which is this file. On a 2 | system which supports , this file is overridden by 3 | dirent.h in the libc/sys/.../sys directory. On a system which does 4 | not support , we will get this file which uses #error to force 5 | an error. */ 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | #error " not supported" 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/sys/fcntl.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_FCNTL_H_ 2 | #define _SYS_FCNTL_H_ 3 | #include 4 | #endif 5 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/sys/file.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/sys/iconvnls.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003-2004, Artem B. Bityuckiy. 3 | * Rights transferred to Franklin Electronic Publishers. 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 | 27 | /* 28 | * Funtions, macros, etc implimented in iconv library but used by other 29 | * NLS-related subsystems too. 30 | */ 31 | #ifndef __SYS_ICONVNLS_H__ 32 | #define __SYS_ICONVNLS_H__ 33 | 34 | #include <_ansi.h> 35 | #include 36 | #include 37 | #include 38 | 39 | /* Iconv data path environment variable name */ 40 | #define NLS_ENVVAR_NAME "NLSPATH" 41 | /* Default NLSPATH value */ 42 | #define ICONV_DEFAULT_NLSPATH "/usr/locale" 43 | /* Direction markers */ 44 | #define ICONV_NLS_FROM 0 45 | #define ICONV_NLS_TO 1 46 | 47 | void 48 | _iconv_nls_get_state (iconv_t cd, mbstate_t *ps, int direction); 49 | 50 | int 51 | _iconv_nls_set_state (iconv_t cd, mbstate_t *ps, int direction); 52 | 53 | int 54 | _iconv_nls_is_stateful (iconv_t cd, int direction); 55 | 56 | int 57 | _iconv_nls_get_mb_cur_max (iconv_t cd, int direction); 58 | 59 | size_t 60 | _iconv_nls_conv (struct _reent *rptr, iconv_t cd, 61 | const char **inbuf, size_t *inbytesleft, 62 | char **outbuf, size_t *outbytesleft); 63 | 64 | const char * 65 | _iconv_nls_construct_filename (struct _reent *rptr, const char *file, 66 | const char *dir, const char *ext); 67 | 68 | 69 | int 70 | _iconv_nls_open (struct _reent *rptr, const char *encoding, 71 | iconv_t *towc, iconv_t *fromwc, int flag); 72 | 73 | char * 74 | _iconv_resolve_encoding_name (struct _reent *rptr, const char *ca); 75 | 76 | #endif /* __SYS_ICONVNLS_H__ */ 77 | 78 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/sys/lock.h: -------------------------------------------------------------------------------- 1 | #ifndef __SYS_LOCK_H__ 2 | #define __SYS_LOCK_H__ 3 | 4 | /* dummy lock routines for single-threaded aps */ 5 | 6 | #include 7 | #include <_ansi.h> 8 | 9 | #if !defined(_RETARGETABLE_LOCKING) 10 | 11 | typedef int _LOCK_T; 12 | typedef int _LOCK_RECURSIVE_T; 13 | 14 | #define __LOCK_INIT(class,lock) static int lock = 0; 15 | #define __LOCK_INIT_RECURSIVE(class,lock) static int lock = 0; 16 | #define __lock_init(lock) ((void) 0) 17 | #define __lock_init_recursive(lock) ((void) 0) 18 | #define __lock_close(lock) ((void) 0) 19 | #define __lock_close_recursive(lock) ((void) 0) 20 | #define __lock_acquire(lock) ((void) 0) 21 | #define __lock_acquire_recursive(lock) ((void) 0) 22 | #define __lock_try_acquire(lock) ((void) 0) 23 | #define __lock_try_acquire_recursive(lock) ((void) 0) 24 | #define __lock_release(lock) ((void) 0) 25 | #define __lock_release_recursive(lock) ((void) 0) 26 | 27 | #else 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | struct __lock; 34 | typedef struct __lock * _LOCK_T; 35 | #define _LOCK_RECURSIVE_T _LOCK_T 36 | 37 | #define __LOCK_INIT(class,lock) extern struct __lock __lock_ ## lock; \ 38 | class _LOCK_T lock = &__lock_ ## lock 39 | #define __LOCK_INIT_RECURSIVE(class,lock) __LOCK_INIT(class,lock) 40 | 41 | extern void __retarget_lock_init(_LOCK_T *lock); 42 | #define __lock_init(lock) __retarget_lock_init(&lock) 43 | extern void __retarget_lock_init_recursive(_LOCK_T *lock); 44 | #define __lock_init_recursive(lock) __retarget_lock_init_recursive(&lock) 45 | extern void __retarget_lock_close(_LOCK_T lock); 46 | #define __lock_close(lock) __retarget_lock_close(lock) 47 | extern void __retarget_lock_close_recursive(_LOCK_T lock); 48 | #define __lock_close_recursive(lock) __retarget_lock_close_recursive(lock) 49 | extern void __retarget_lock_acquire(_LOCK_T lock); 50 | #define __lock_acquire(lock) __retarget_lock_acquire(lock) 51 | extern void __retarget_lock_acquire_recursive(_LOCK_T lock); 52 | #define __lock_acquire_recursive(lock) __retarget_lock_acquire_recursive(lock) 53 | extern int __retarget_lock_try_acquire(_LOCK_T lock); 54 | #define __lock_try_acquire(lock) __retarget_lock_try_acquire(lock) 55 | extern int __retarget_lock_try_acquire_recursive(_LOCK_T lock); 56 | #define __lock_try_acquire_recursive(lock) \ 57 | __retarget_lock_try_acquire_recursive(lock) 58 | extern void __retarget_lock_release(_LOCK_T lock); 59 | #define __lock_release(lock) __retarget_lock_release(lock) 60 | extern void __retarget_lock_release_recursive(_LOCK_T lock); 61 | #define __lock_release_recursive(lock) __retarget_lock_release_recursive(lock) 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif /* !defined(_RETARGETABLE_LOCKING) */ 68 | 69 | #endif /* __SYS_LOCK_H__ */ 70 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/sys/param.h: -------------------------------------------------------------------------------- 1 | /* This is a dummy file, not customized for any 2 | particular system. If there is a param.h in libc/sys/SYSDIR/sys, 3 | it will override this one. */ 4 | 5 | #ifndef _SYS_PARAM_H 6 | # define _SYS_PARAM_H 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #ifndef NBBY 14 | # define NBBY 8 /* number of bits in a byte */ 15 | #endif 16 | #ifndef HZ 17 | # define HZ (60) 18 | #endif 19 | #ifndef NOFILE 20 | # define NOFILE (60) 21 | #endif 22 | #ifndef PATHSIZE 23 | # define PATHSIZE (1024) 24 | #endif 25 | 26 | #define MAXPATHLEN PATH_MAX 27 | 28 | #define MAX(a,b) ((a) > (b) ? (a) : (b)) 29 | #define MIN(a,b) ((a) < (b) ? (a) : (b)) 30 | 31 | #ifndef howmany 32 | #define howmany(x, y) (((x)+((y)-1))/(y)) 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/sys/resource.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_RESOURCE_H_ 2 | #define _SYS_RESOURCE_H_ 3 | 4 | #include 5 | 6 | #define RUSAGE_SELF 0 /* calling process */ 7 | #define RUSAGE_CHILDREN -1 /* terminated child processes */ 8 | 9 | struct rusage { 10 | struct timeval ru_utime; /* user time used */ 11 | struct timeval ru_stime; /* system time used */ 12 | }; 13 | 14 | int getrusage (int, struct rusage*); 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/sys/sched.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by Joel Sherrill . 3 | * 4 | * COPYRIGHT (c) 1989-2010. 5 | * On-Line Applications Research Corporation (OAR). 6 | * 7 | * Permission to use, copy, modify, and distribute this software for any 8 | * purpose without fee is hereby granted, provided that this entire notice 9 | * is included in all copies of any software which is or includes a copy 10 | * or modification of this software. 11 | * 12 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 13 | * WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION 14 | * OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS 15 | * SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 16 | * 17 | * $Id$ 18 | */ 19 | 20 | 21 | #ifndef _SYS_SCHED_H_ 22 | #define _SYS_SCHED_H_ 23 | 24 | #include 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Scheduling Policies */ 31 | /* Open Group Specifications Issue 6 */ 32 | #if defined(__CYGWIN__) 33 | #define SCHED_OTHER 3 34 | #else 35 | #define SCHED_OTHER 0 36 | #endif 37 | 38 | #define SCHED_FIFO 1 39 | #define SCHED_RR 2 40 | 41 | #if defined(_POSIX_SPORADIC_SERVER) 42 | #define SCHED_SPORADIC 4 43 | #endif 44 | 45 | /* Scheduling Parameters */ 46 | /* Open Group Specifications Issue 6 */ 47 | 48 | struct sched_param { 49 | int sched_priority; /* Process execution scheduling priority */ 50 | 51 | #if defined(_POSIX_SPORADIC_SERVER) || defined(_POSIX_THREAD_SPORADIC_SERVER) 52 | int sched_ss_low_priority; /* Low scheduling priority for sporadic */ 53 | /* server */ 54 | struct timespec sched_ss_repl_period; 55 | /* Replenishment period for sporadic server */ 56 | struct timespec sched_ss_init_budget; 57 | /* Initial budget for sporadic server */ 58 | int sched_ss_max_repl; /* Maximum pending replenishments for */ 59 | /* sporadic server */ 60 | #endif 61 | }; 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif 68 | /* end of include file */ 69 | 70 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/sys/select.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_SELECT_H 2 | #define _SYS_SELECT_H 3 | 4 | /* We don't define fd_set and friends if we are compiling POSIX 5 | source, or if we have included (or may include as indicated 6 | by __USE_W32_SOCKETS) the W32api winsock[2].h header which 7 | defines Windows versions of them. Note that a program which 8 | includes the W32api winsock[2].h header must know what it is doing; 9 | it must not call the Cygwin select function. 10 | */ 11 | # if !(defined (_WINSOCK_H) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS)) 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #if !defined(_SIGSET_T_DECLARED) 19 | #define _SIGSET_T_DECLARED 20 | typedef __sigset_t sigset_t; 21 | #endif 22 | 23 | # define _SYS_TYPES_FD_SET 24 | /* 25 | * Select uses bit masks of file descriptors in longs. 26 | * These macros manipulate such bit fields (the filesystem macros use chars). 27 | * FD_SETSIZE may be defined by the user, but the default here 28 | * should be >= NOFILE (param.h). 29 | */ 30 | # ifndef FD_SETSIZE 31 | # define FD_SETSIZE 64 32 | # endif 33 | 34 | typedef unsigned long fd_mask; 35 | # define NFDBITS (sizeof (fd_mask) * 8) /* bits per mask */ 36 | # ifndef _howmany 37 | # define _howmany(x,y) (((x)+((y)-1))/(y)) 38 | # endif 39 | 40 | /* We use a macro for fd_set so that including Sockets.h afterwards 41 | can work. */ 42 | typedef struct _types_fd_set { 43 | fd_mask fds_bits[_howmany(FD_SETSIZE, NFDBITS)]; 44 | } _types_fd_set; 45 | 46 | #define fd_set _types_fd_set 47 | 48 | # define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS))) 49 | # define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS))) 50 | # define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS))) 51 | # define FD_ZERO(p) (__extension__ (void)({ \ 52 | size_t __i; \ 53 | char *__tmp = (char *)p; \ 54 | for (__i = 0; __i < sizeof (*(p)); ++__i) \ 55 | *__tmp++ = 0; \ 56 | })) 57 | 58 | #if !defined (__INSIDE_CYGWIN_NET__) 59 | 60 | __BEGIN_DECLS 61 | 62 | int select __P ((int __n, fd_set *__readfds, fd_set *__writefds, 63 | fd_set *__exceptfds, struct timeval *__timeout)); 64 | #if __POSIX_VISIBLE >= 200112 65 | int pselect __P ((int __n, fd_set *__readfds, fd_set *__writefds, 66 | fd_set *__exceptfds, const struct timespec *__timeout, 67 | const sigset_t *__set)); 68 | #endif 69 | 70 | __END_DECLS 71 | 72 | #endif /* !__INSIDE_CYGWIN_NET__ */ 73 | 74 | #endif /* !(_WINSOCK_H || _WINSOCKAPI_ || __USE_W32_SOCKETS) */ 75 | 76 | #endif /* sys/select.h */ 77 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/sys/stdio.h: -------------------------------------------------------------------------------- 1 | #ifndef _NEWLIB_STDIO_H 2 | #define _NEWLIB_STDIO_H 3 | 4 | #include 5 | #include 6 | 7 | /* Internal locking macros, used to protect stdio functions. In the 8 | general case, expand to nothing. Use __SSTR flag in FILE _flags to 9 | detect if FILE is private to sprintf/sscanf class of functions; if 10 | set then do nothing as lock is not initialised. */ 11 | #if !defined(_flockfile) 12 | #ifndef __SINGLE_THREAD__ 13 | # define _flockfile(fp) (((fp)->_flags & __SSTR) ? 0 : __lock_acquire_recursive((fp)->_lock)) 14 | #else 15 | # define _flockfile(fp) ((void) 0) 16 | #endif 17 | #endif 18 | 19 | #if !defined(_funlockfile) 20 | #ifndef __SINGLE_THREAD__ 21 | # define _funlockfile(fp) (((fp)->_flags & __SSTR) ? 0 : __lock_release_recursive((fp)->_lock)) 22 | #else 23 | # define _funlockfile(fp) ((void) 0) 24 | #endif 25 | #endif 26 | 27 | #endif /* _NEWLIB_STDIO_H */ 28 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/sys/string.h: -------------------------------------------------------------------------------- 1 | /* This is a dummy used as a placeholder for 2 | systems that need to have a special header file. */ 3 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/sys/timeb.h: -------------------------------------------------------------------------------- 1 | /* timeb.h -- An implementation of the standard Unix file. 2 | Written by Ian Lance Taylor 3 | Public domain; no rights reserved. 4 | 5 | declares the structure used by the ftime function, as 6 | well as the ftime function itself. Newlib does not provide an 7 | implementation of ftime. */ 8 | 9 | #ifndef _SYS_TIMEB_H 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #define _SYS_TIMEB_H 16 | 17 | #include <_ansi.h> 18 | #include 19 | 20 | #if !defined(__time_t_defined) && !defined(_TIME_T_DECLARED) 21 | typedef _TIME_T_ time_t; 22 | #define __time_t_defined 23 | #define _TIME_T_DECLARED 24 | #endif 25 | 26 | struct timeb 27 | { 28 | time_t time; 29 | unsigned short millitm; 30 | short timezone; 31 | short dstflag; 32 | }; 33 | 34 | extern int ftime (struct timeb *); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif /* ! defined (_SYS_TIMEB_H) */ 41 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/sys/times.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_TIMES_H 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | #define _SYS_TIMES_H 6 | 7 | #include <_ansi.h> 8 | #include 9 | 10 | #if !defined(__clock_t_defined) && !defined(_CLOCK_T_DECLARED) 11 | typedef _CLOCK_T_ clock_t; 12 | #define __clock_t_defined 13 | #define _CLOCK_T_DECLARED 14 | #endif 15 | 16 | /* Get Process Times, P1003.1b-1993, p. 92 */ 17 | struct tms { 18 | clock_t tms_utime; /* user time */ 19 | clock_t tms_stime; /* system time */ 20 | clock_t tms_cutime; /* user time, children */ 21 | clock_t tms_cstime; /* system time, children */ 22 | }; 23 | 24 | clock_t times (struct tms *); 25 | #ifdef _COMPILING_NEWLIB 26 | clock_t _times (struct tms *); 27 | #endif 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | #endif /* !_SYS_TIMES_H */ 33 | -------------------------------------------------------------------------------- /aarch64-none-darwin/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$ 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 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/sys/utime.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_UTIME_H 2 | #define _SYS_UTIME_H 3 | 4 | /* This is a dummy file, not customized for any 5 | particular system. If there is a utime.h in libc/sys/SYSDIR/sys, 6 | it will override this one. */ 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | struct utimbuf 13 | { 14 | time_t actime; 15 | time_t modtime; 16 | }; 17 | 18 | #ifdef __cplusplus 19 | }; 20 | #endif 21 | 22 | #endif /* _SYS_UTIME_H */ 23 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/sys/wait.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_WAIT_H 2 | #define _SYS_WAIT_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | #define WNOHANG 1 11 | #define WUNTRACED 2 12 | 13 | /* A status looks like: 14 | <1 byte info> <1 byte code> 15 | 16 | == 0, child has exited, info is the exit value 17 | == 1..7e, child has exited, info is the signal number. 18 | == 7f, child has stopped, info was the signal number. 19 | == 80, there was a core dump. 20 | */ 21 | 22 | #define WIFEXITED(w) (((w) & 0xff) == 0) 23 | #define WIFSIGNALED(w) (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f)) 24 | #define WIFSTOPPED(w) (((w) & 0xff) == 0x7f) 25 | #define WEXITSTATUS(w) (((w) >> 8) & 0xff) 26 | #define WTERMSIG(w) ((w) & 0x7f) 27 | #define WSTOPSIG WEXITSTATUS 28 | 29 | pid_t wait (int *); 30 | pid_t waitpid (pid_t, int *, int); 31 | 32 | #ifdef _COMPILING_NEWLIB 33 | pid_t _wait (int *); 34 | #endif 35 | 36 | /* Provide prototypes for most of the _ names that are 37 | provided in newlib for some compilers. */ 38 | pid_t _wait (int *); 39 | 40 | #ifdef __cplusplus 41 | }; 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/tar.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tar.h 3 | */ 4 | 5 | #ifndef _TAR_H 6 | #define _TAR_H 7 | 8 | #include 9 | 10 | /* General definitions */ 11 | #define TMAGIC "ustar" /* ustar plus null byte. */ 12 | #define TMAGLEN 6 /* Length of the above. */ 13 | #define TVERSION "00" /* 00 without a null byte. */ 14 | #define TVERSLEN 2 /* Length of the above. */ 15 | 16 | /* Typeflag field definitions */ 17 | #define REGTYPE '0' /* Regular file. */ 18 | #define AREGTYPE '\0' /* Regular file. */ 19 | #define LNKTYPE '1' /* Link. */ 20 | #define SYMTYPE '2' /* Symbolic link. */ 21 | #define CHRTYPE '3' /* Character special. */ 22 | #define BLKTYPE '4' /* Block special. */ 23 | #define DIRTYPE '5' /* Directory. */ 24 | #define FIFOTYPE '6' /* FIFO special. */ 25 | #define CONTTYPE '7' /* Reserved. */ 26 | 27 | /* Mode field bit definitions (octal) */ 28 | #define TSUID 04000 /* Set UID on execution. */ 29 | #define TSGID 02000 /* Set GID on execution. */ 30 | #if __XSI_VISIBLE || __POSIX_VISIBLE < 200112 31 | #define TSVTX 01000 /* On directories, restricted deletion flag. */ 32 | #endif 33 | #define TUREAD 00400 /* Read by owner. */ 34 | #define TUWRITE 00200 /* Write by owner. */ 35 | #define TUEXEC 00100 /* Execute/search by owner. */ 36 | #define TGREAD 00040 /* Read by group. */ 37 | #define TGWRITE 00020 /* Write by group. */ 38 | #define TGEXEC 00010 /* Execute/search by group. */ 39 | #define TOREAD 00004 /* Read by other. */ 40 | #define TOWRITE 00002 /* Write by other. */ 41 | #define TOEXEC 00001 /* Execute/search by other. */ 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/termios.h: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | extern "C" { 3 | #endif 4 | #include 5 | #ifdef __cplusplus 6 | } 7 | #endif 8 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/unctrl.h: -------------------------------------------------------------------------------- 1 | /* From curses.h. */ 2 | /* 3 | * Copyright (c) 1981, 1993 4 | * The Regents of the University of California. 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 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by the University of 17 | * California, Berkeley and its contributors. 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 | 35 | #ifndef _UNCTRL_H_ 36 | #define _UNCTRL_H_ 37 | 38 | #include <_ansi.h> 39 | 40 | #define unctrl(c) __unctrl[(c) & 0xff] 41 | #define unctrllen(ch) __unctrllen[(ch) & 0xff] 42 | 43 | extern __IMPORT const char * const __unctrl[256]; /* Control strings. */ 44 | extern __IMPORT const char __unctrllen[256]; /* Control strings length. */ 45 | 46 | #endif /* _UNCTRL_H_ */ 47 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/unistd.h: -------------------------------------------------------------------------------- 1 | #ifndef _UNISTD_H_ 2 | #define _UNISTD_H_ 3 | 4 | # include 5 | 6 | #endif /* _UNISTD_H_ */ 7 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/utime.h: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | extern "C" { 3 | #endif 4 | 5 | #include <_ansi.h> 6 | 7 | /* The utime function is defined in libc/sys//sys if it exists. */ 8 | #include 9 | 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/utmp.h: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | extern "C" { 3 | #endif 4 | #include 5 | #ifdef __cplusplus 6 | } 7 | #endif 8 | 9 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/wctype.h: -------------------------------------------------------------------------------- 1 | #ifndef _WCTYPE_H_ 2 | #define _WCTYPE_H_ 3 | 4 | #include <_ansi.h> 5 | #include 6 | 7 | #define __need_wint_t 8 | #include 9 | 10 | #if __POSIX_VISIBLE >= 200809 11 | #include 12 | #endif 13 | 14 | #ifndef WEOF 15 | # define WEOF ((wint_t)-1) 16 | #endif 17 | 18 | _BEGIN_STD_C 19 | 20 | #ifndef _WCTYPE_T 21 | #define _WCTYPE_T 22 | typedef int wctype_t; 23 | #endif 24 | 25 | #ifndef _WCTRANS_T 26 | #define _WCTRANS_T 27 | typedef int wctrans_t; 28 | #endif 29 | 30 | int iswalpha (wint_t); 31 | int iswalnum (wint_t); 32 | #if __ISO_C_VISIBLE >= 1999 33 | int iswblank (wint_t); 34 | #endif 35 | int iswcntrl (wint_t); 36 | int iswctype (wint_t, wctype_t); 37 | int iswdigit (wint_t); 38 | int iswgraph (wint_t); 39 | int iswlower (wint_t); 40 | int iswprint (wint_t); 41 | int iswpunct (wint_t); 42 | int iswspace (wint_t); 43 | int iswupper (wint_t); 44 | int iswxdigit (wint_t); 45 | wint_t towctrans (wint_t, wctrans_t); 46 | wint_t towupper (wint_t); 47 | wint_t towlower (wint_t); 48 | wctrans_t wctrans (const char *); 49 | wctype_t wctype (const char *); 50 | 51 | #if __POSIX_VISIBLE >= 200809 52 | extern int iswalpha_l (wint_t, locale_t); 53 | extern int iswalnum_l (wint_t, locale_t); 54 | extern int iswblank_l (wint_t, locale_t); 55 | extern int iswcntrl_l (wint_t, locale_t); 56 | extern int iswctype_l (wint_t, wctype_t, locale_t); 57 | extern int iswdigit_l (wint_t, locale_t); 58 | extern int iswgraph_l (wint_t, locale_t); 59 | extern int iswlower_l (wint_t, locale_t); 60 | extern int iswprint_l (wint_t, locale_t); 61 | extern int iswpunct_l (wint_t, locale_t); 62 | extern int iswspace_l (wint_t, locale_t); 63 | extern int iswupper_l (wint_t, locale_t); 64 | extern int iswxdigit_l (wint_t, locale_t); 65 | extern wint_t towctrans_l (wint_t, wctrans_t, locale_t); 66 | extern wint_t towupper_l (wint_t, locale_t); 67 | extern wint_t towlower_l (wint_t, locale_t); 68 | extern wctrans_t wctrans_l (const char *, locale_t); 69 | extern wctype_t wctype_l (const char *, locale_t); 70 | #endif 71 | 72 | _END_STD_C 73 | 74 | #endif /* _WCTYPE_H_ */ 75 | -------------------------------------------------------------------------------- /aarch64-none-darwin/include/wordexp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002, 2010 by Red Hat, Incorporated. All rights reserved. 2 | * 3 | * Permission to use, copy, modify, and distribute this software 4 | * is freely granted, provided that this notice is preserved. 5 | */ 6 | 7 | #ifndef _WORDEXP_H_ 8 | #define _WORDEXP_H_ 9 | 10 | #include 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | struct _wordexp_t 17 | { 18 | size_t we_wordc; /* Count of words matched by words. */ 19 | char **we_wordv; /* Pointer to list of expanded words. */ 20 | size_t we_offs; /* Slots to reserve at the beginning of we_wordv. */ 21 | }; 22 | 23 | typedef struct _wordexp_t wordexp_t; 24 | 25 | #define WRDE_DOOFFS 0x0001 /* Use we_offs. */ 26 | #define WRDE_APPEND 0x0002 /* Append to output from previous call. */ 27 | #define WRDE_NOCMD 0x0004 /* Don't perform command substitution. */ 28 | #define WRDE_REUSE 0x0008 /* pwordexp points to a wordexp_t struct returned from 29 | a previous successful call to wordexp. */ 30 | #define WRDE_SHOWERR 0x0010 /* Print error messages to stderr. */ 31 | #define WRDE_UNDEF 0x0020 /* Report attempt to expand undefined shell variable. */ 32 | 33 | enum { 34 | WRDE_SUCCESS, 35 | WRDE_NOSPACE, 36 | WRDE_BADCHAR, 37 | WRDE_BADVAL, 38 | WRDE_CMDSUB, 39 | WRDE_SYNTAX, 40 | WRDE_NOSYS 41 | }; 42 | 43 | /* Note: This implementation of wordexp requires a version of bash 44 | that supports the --wordexp and --protected arguments to be present 45 | on the system. It does not support the WRDE_UNDEF flag. */ 46 | int wordexp(const char *__restrict, wordexp_t *__restrict, int); 47 | void wordfree(wordexp_t *); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif /* _WORDEXP_H_ */ 54 | -------------------------------------------------------------------------------- /aarch64-none-darwin/lib/libc.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Proteas/pongoOS/c32fc47863ff8943bb97712efbb3e86b64a7435a/aarch64-none-darwin/lib/libc.a -------------------------------------------------------------------------------- /aarch64-none-darwin/lib/libg.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Proteas/pongoOS/c32fc47863ff8943bb97712efbb3e86b64a7435a/aarch64-none-darwin/lib/libg.a -------------------------------------------------------------------------------- /aarch64-none-darwin/lib/libm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Proteas/pongoOS/c32fc47863ff8943bb97712efbb3e86b64a7435a/aarch64-none-darwin/lib/libm.a -------------------------------------------------------------------------------- /apple-include/mach/arm/boolean.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | /* 29 | * @OSF_COPYRIGHT@ 30 | */ 31 | /* 32 | * Mach Operating System 33 | * Copyright (c) 1991,1990,1989 Carnegie Mellon University 34 | * All Rights Reserved. 35 | * 36 | * Permission to use, copy, modify and distribute this software and its 37 | * documentation is hereby granted, provided that both the copyright 38 | * notice and this permission notice appear in all copies of the 39 | * software, derivative works or modified versions, and any portions 40 | * thereof, and that both notices appear in supporting documentation. 41 | * 42 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 43 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 44 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 | * 46 | * Carnegie Mellon requests users of this software to return to 47 | * 48 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 | * School of Computer Science 50 | * Carnegie Mellon University 51 | * Pittsburgh PA 15213-3890 52 | * 53 | * any improvements or extensions that they make and grant Carnegie Mellon 54 | * the rights to redistribute these changes. 55 | */ 56 | /* 57 | */ 58 | 59 | /* 60 | * File: boolean.h 61 | * 62 | * Boolean type, for ARM. 63 | */ 64 | 65 | #ifndef _MACH_ARM_BOOLEAN_H_ 66 | #define _MACH_ARM_BOOLEAN_H_ 67 | 68 | typedef int boolean_t; 69 | 70 | #endif /* _MACH_ARM_BOOLEAN_H_ */ 71 | -------------------------------------------------------------------------------- /apple-include/mach/arm/thread_state.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | /* 29 | * @OSF_COPYRIGHT@ 30 | */ 31 | 32 | #ifndef _MACH_ARM_THREAD_STATE_H_ 33 | #define _MACH_ARM_THREAD_STATE_H_ 34 | 35 | /* Size of maximum exported thread state in words */ 36 | #define ARM_THREAD_STATE_MAX (144) /* Size of biggest state possible */ 37 | 38 | #if defined (__arm__) || defined(__arm64__) || defined(__aarch64__) 39 | #define THREAD_STATE_MAX ARM_THREAD_STATE_MAX 40 | #else 41 | #error Unsupported arch 42 | #endif 43 | 44 | #endif /* _MACH_ARM_THREAD_STATE_H_ */ 45 | -------------------------------------------------------------------------------- /apple-include/mach/machine/boolean.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | 29 | #ifndef _MACH_MACHINE_BOOLEAN_H_ 30 | #define _MACH_MACHINE_BOOLEAN_H_ 31 | 32 | #if defined (__arm__) || defined (__arm64__) || defined (__aarch64__) 33 | #include "mach/arm/boolean.h" 34 | #else 35 | #error architecture not supported 36 | #endif 37 | 38 | #endif /* _MACH_MACHINE_BOOLEAN_H_ */ 39 | -------------------------------------------------------------------------------- /apple-include/mach/machine/thread_state.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | 29 | #ifndef _MACH_MACHINE_THREAD_STATE_H_ 30 | #define _MACH_MACHINE_THREAD_STATE_H_ 31 | 32 | #if defined (__arm__) || defined (__arm64__) || defined(__aarch64__) 33 | #include "mach/arm/thread_state.h" 34 | #else 35 | #error architecture not supported 36 | #endif 37 | 38 | #endif /* _MACH_MACHINE_THREAD_STATE_H_ */ 39 | -------------------------------------------------------------------------------- /apple-include/mach/machine/vm_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | 29 | #ifndef _MACH_MACHINE_VM_TYPES_H_ 30 | #define _MACH_MACHINE_VM_TYPES_H_ 31 | 32 | #if defined (__arm__) || defined (__arm64__) || defined (__aarch64__) 33 | #include "mach/arm/vm_types.h" 34 | #else 35 | #error architecture not supported 36 | #endif 37 | 38 | #endif /* _MACH_MACHINE_VM_TYPES_H_ */ 39 | -------------------------------------------------------------------------------- /apple-include/sys/_types/_os_inline.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003-2012 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | #if !defined(OS_INLINE) 29 | # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 30 | # define OS_INLINE static inline 31 | # else 32 | # define OS_INLINE static __inline__ 33 | # endif 34 | #endif /* OS_INLINE */ 35 | -------------------------------------------------------------------------------- /checkra1n/kpf-test/.gitignore: -------------------------------------------------------------------------------- 1 | /kpf-test 2 | -------------------------------------------------------------------------------- /checkra1n/kpf-test/Makefile: -------------------------------------------------------------------------------- 1 | ifndef $(HOST_OS) 2 | ifeq ($(OS),Windows_NT) 3 | HOST_OS = Windows 4 | else 5 | HOST_OS := $(shell uname -s) 6 | endif 7 | endif 8 | 9 | PONGO_VERSION := 1.2.1-$(shell git log -1 --pretty=format:"%H" | cut -c1-8) 10 | ROOT := $(shell dirname $(shell dirname $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))))) 11 | SRC := $(ROOT)/src 12 | INC := $(ROOT)/include 13 | RA1N := $(ROOT)/checkra1n/kpf 14 | 15 | CHECKRA1N_C := main.c $(RA1N)/main.c $(RA1N)/shellcode.S $(SRC)/drivers/xnu/xnu.c $(SRC)/drivers/xnu/xnu.S 16 | CHECKRA1N_LDFLAGS := -Wl,-fatal_warnings -Wl,-dead_strip 17 | CHECKRA1N_FLAGS := -Wall -Wunused-label -Werror -O3 -flto -I$(INC) -I$(SRC)/kernel -I$(SRC)/drivers -DCHECKRAIN_VERSION='' -Diprintf=printf -Dpanic=realpanic -DOVERRIDE_CACHEABLE_VIEW=0x800000000ULL -DDEV_BUILD=1 $(CHECKRA1N_LDFLAGS) $(KPF_CFLAGS) $(CFLAGS) 18 | 19 | ifeq ($(HOST_OS),Darwin) 20 | EMBEDDED_CC ?= xcrun -sdk iphoneos clang -arch arm64 21 | EMBEDDED_SIGN ?= codesign -s - --entitlements ent.plist 22 | CHECKRA1N_FLAGS += -miphoneos-version-min=7.0 23 | else 24 | ifeq ($(HOST_OS),Linux) 25 | EMBEDDED_CC ?= arm64-apple-ios12.0.0-clang -arch arm64 26 | EMBEDDED_SIGN ?= ldid -Sent.plist 27 | endif 28 | endif 29 | 30 | 31 | .PHONY: all clean 32 | 33 | all: kpf-test 34 | 35 | kpf-test: $(CHECKRA1N_C) 36 | $(EMBEDDED_CC) -o $@ $(CHECKRA1N_C) $(CHECKRA1N_FLAGS) $(MODULE_CC_FLAGS) 37 | $(EMBEDDED_SIGN) $@ 38 | 39 | clean: 40 | rm -f kpf-test 41 | -------------------------------------------------------------------------------- /checkra1n/kpf-test/ent.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.private.security.no-container 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /checkra1n/kpf/not_strip.txt: -------------------------------------------------------------------------------- 1 | _module_entry 2 | _module_name 3 | _exported_symbols 4 | -------------------------------------------------------------------------------- /checkra1n/kpf/sep/sep.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | void sep_setup(); 28 | extern void (*sepfw_kpf_hook)(void* sepfw_bytes, size_t sepfw_size); 29 | -------------------------------------------------------------------------------- /include/kerninfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #ifndef _KERNINFO_H 28 | #define _KERNINFO_H 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #define MAX_BOOTARGS_LEN 256 35 | #define DEFAULT_BOOTARGS "rootdev=md0" 36 | 37 | typedef enum { 38 | checkrain_option_none = 0, 39 | checkrain_option_all = -1, 40 | checkrain_option_failure = -2, 41 | 42 | checkrain_option_safemode = 1 << 0, 43 | checkrain_option_verbose_boot = 1 << 1, 44 | checkrain_option_verbose_logging = 1 << 2, 45 | checkrain_option_demote = 1 << 3, 46 | checkrain_option_pongo_shell = 1 << 4, 47 | checkrain_option_early_exit = 1 << 5, 48 | } checkrain_option_t, *checkrain_option_p; 49 | 50 | struct kerninfo { 51 | uint64_t size; 52 | uint64_t base; 53 | uint64_t slide; 54 | checkrain_option_t flags; 55 | uint16_t cpid; 56 | char bootargs[MAX_BOOTARGS_LEN]; 57 | }; 58 | 59 | #define checkrain_set_option(options, option, enabled) do { \ 60 | if (enabled) \ 61 | options = (checkrain_option_t)(options | option); \ 62 | else \ 63 | options = (checkrain_option_t)(options & ~option); \ 64 | } while (0); 65 | 66 | static inline bool checkrain_option_enabled(checkrain_option_t flags, checkrain_option_t opt) 67 | { 68 | if(flags == checkrain_option_failure) 69 | { 70 | switch(opt) 71 | { 72 | case checkrain_option_safemode: 73 | return true; 74 | default: 75 | return false; 76 | } 77 | } 78 | return (flags & opt) != 0; 79 | } 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /include/key.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #define PUBKEY_BITS (const unsigned char[]) { \ 28 | 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xaf, 0xb0, 0xe8, 0xed, 0x4d, 0xc5, 0x18, \ 29 | 0x72, 0xcd, 0x0d, 0xbe, 0x8f, 0xd7, 0x00, 0x1a, 0xcf, 0xdb, 0x42, 0x39, 0x6c, 0x77, 0x4f, 0x80, \ 30 | 0x77, 0x9c, 0x01, 0x12, 0x0e, 0x01, 0xbb, 0x0e, 0x95, 0xdb, 0x39, 0xcd, 0xee, 0x75, 0xa1, 0x82, \ 31 | 0x82, 0x0d, 0xfa, 0x48, 0xb6, 0xa5, 0x66, 0xce, 0xe2, 0x0f, 0x0e, 0x10, 0xe6, 0xa8, 0xf6, 0x60, \ 32 | 0xe2, 0xb8, 0xa1, 0xf9, 0xf9, 0x98, 0x1d, 0x29, 0xb0, 0x0c, 0xbf, 0x6b, 0xf1, 0x10, 0x8b, 0xbe, \ 33 | 0x4a, 0x4b, 0x60, 0x35, 0x4f, 0x6e, 0x1c, 0x0a, 0x6a, 0xc8, 0xb4, 0xfa, 0x81, 0x6e, 0xbd, 0x74, \ 34 | 0x74, 0xba, 0x92, 0x57, 0xab, 0x58, 0xaa, 0x27, 0x44, 0x70, 0xc5, 0xa4, 0x2c, 0xf9, 0x16, 0xfd, \ 35 | 0xef, 0x4b, 0x39, 0xfb, 0xfa, 0x60, 0x40, 0x16, 0x30, 0xda, 0x5f, 0xb7, 0xdc, 0x85, 0x80, 0xd1, \ 36 | 0x16, 0xe5, 0x6a, 0x7d, 0x18, 0xb1, 0xa6, 0xc1, 0xae, 0x7d, 0x48, 0x86, 0x2c, 0x29, 0x98, 0x8a, \ 37 | 0xe2, 0x33, 0xb1, 0x7f, 0xa4, 0x3d, 0x4a, 0xda, 0x14, 0xec, 0xb5, 0x69, 0x03, 0x3c, 0x35, 0xf2, \ 38 | 0xd9, 0xe1, 0x04, 0x1f, 0xfc, 0x24, 0xa5, 0x87, 0x35, 0x86, 0x46, 0x07, 0xa7, 0x3d, 0x93, 0x29, \ 39 | 0x80, 0xd3, 0x0c, 0xdb, 0xff, 0x09, 0xaa, 0x4a, 0xe8, 0x59, 0x71, 0x32, 0x39, 0x9a, 0xb2, 0x8d, \ 40 | 0xeb, 0xbc, 0x51, 0xee, 0x7d, 0x52, 0x3b, 0x42, 0xc8, 0x0c, 0xee, 0x0e, 0xcf, 0x22, 0x1e, 0x50, \ 41 | 0x6f, 0x3b, 0xd8, 0x67, 0xbf, 0x93, 0x8d, 0xa9, 0xe4, 0x35, 0x0c, 0xa3, 0xfd, 0x6d, 0x02, 0x28, \ 42 | 0x29, 0x49, 0xb2, 0x9a, 0x49, 0x24, 0xfc, 0xc5, 0xe6, 0x61, 0x59, 0xde, 0x1f, 0xb7, 0x0d, 0x43, \ 43 | 0x0a, 0xa1, 0x14, 0x69, 0xc3, 0x54, 0x7e, 0x31, 0x81, 0x97, 0x84, 0x19, 0xaf, 0xa9, 0xa3, 0x0f, \ 44 | 0x9b, 0x28, 0xa7, 0x44, 0x6d, 0x5f, 0x32, 0x47, 0x47, 0x02, 0x03, 0x01, 0x00, 0x01 } 45 | -------------------------------------------------------------------------------- /scripts/.gitignore: -------------------------------------------------------------------------------- 1 | /pongoterm 2 | -------------------------------------------------------------------------------- /scripts/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019-2020 checkra1n team 3 | # This file is part of pongoOS. 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | 24 | .PHONY: all clean 25 | 26 | all: pongoterm 27 | 28 | pongoterm: pongoterm.m 29 | $(CC) -o $@ $^ -Wall -O3 -framework Foundation -framework CoreFoundation -framework IOKit 30 | 31 | clean: 32 | rm -f pongoterm 33 | -------------------------------------------------------------------------------- /scripts/arm64-apple-ios12.0.0-clang: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | # 3 | # Copyright (c) 2019-2020 checkra1n team 4 | # This file is part of pongoOS. 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to deal 8 | # in the Software without restriction, including without limitation the rights 9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | # copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in all 14 | # copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | # SOFTWARE. 23 | # 24 | 25 | TOOLCHAIN=/opt/ios-arm64e-clang-toolchain 26 | REALNAME="$(realpath "$0")" 27 | DIR="$(dirname "${REALNAME}")" 28 | BASENAME="$(basename "${REALNAME}")" 29 | TARGET="${BASENAME%-*}" 30 | EXE="${BASENAME##*-}" 31 | ARCH="${TARGET%%-*}" 32 | export SDKROOT="$TOOLCHAIN/sdks/MacOSX.sdk" 33 | export PATH="${TOOLCHAIN}/bin:$PATH" 34 | TOOL="clang" 35 | case $EXE in 36 | clang++|g++|c++) 37 | TOOL="clang++" # -isystem $TOOLCHAIN/libc++/include/c++/v1" 38 | ;; 39 | as) 40 | # TOOL="as" 41 | esac 42 | case $ARCH in 43 | x86_64|x86_64h) 44 | export SDKROOT="$TOOLCHAIN/sdks/MacOSX.sdk" 45 | #LINKER="-Xlinker $TOOLCHAIN/clangrt/lib/darwin/libclang_rt.osx.a" 46 | ;; 47 | i386) 48 | #LINKER="-Xlinker $TOOLCHAIN/clangrt/lib/darwin/libclang_rt.osx.a 49 | export SDKROOT="$TOOLCHAIN/sdks/MacOSX.sdk" 50 | ;; 51 | arm64) 52 | #LINKER="-Xlinker $TOOLCHAIN/clangrt/lib/darwin/libclang_rt.ios.a 53 | export SDKROOT="$TOOLCHAIN/sdks/iPhoneOS.sdk" 54 | ;; 55 | esac 56 | "${TOOLCHAIN}/bin/${EXE}" -Wno-unused-command-line-argument -fuse-ld="${TOOLCHAIN}/bin/ld" -isysroot "${SDKROOT}" -target $TARGET $LINKER "$@" 57 | -------------------------------------------------------------------------------- /scripts/boot-checkra1n.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019-2020 checkra1n team 3 | # This file is part of pongoOS. 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | import sys 24 | import time 25 | import usb.core 26 | data = open(sys.argv[1], "rb").read() 27 | rdsk = open(sys.argv[2], "rb").read() 28 | dev = usb.core.find(idVendor=0x05ac, idProduct=0x4141) 29 | if dev is None: 30 | raise ValueError('Device not found') 31 | dev.set_configuration() 32 | 33 | dev.ctrl_transfer(0x21, 4, 0, 0, 0) 34 | dev.ctrl_transfer(0x21, 3, 0, 0, "xargs serial=3 rootdev=md0\n") 35 | dev.ctrl_transfer(0x21, 2, 0, 0, 0) 36 | dev.ctrl_transfer(0x21, 1, 0, 0, 0) 37 | dev.write(2,data) 38 | #dev.write(2,"") 39 | dev.ctrl_transfer(0x21, 4, 0, 0, 0) 40 | dev.ctrl_transfer(0x21, 3, 0, 0, "modload\n") 41 | dev.ctrl_transfer(0x21, 2, 0, 0, 0) 42 | dev.ctrl_transfer(0x21, 1, 0, 0, 0) 43 | dev.write(2,rdsk,100000) 44 | dev.write(2,"") 45 | dev.ctrl_transfer(0x21, 4, 0, 0, 0) 46 | dev.ctrl_transfer(0x21, 3, 0, 0, "ramdisk\n") 47 | dev.ctrl_transfer(0x21, 4, 0, 0, 0) 48 | dev.ctrl_transfer(0x21, 3, 0, 0, "kpf_flags 1\n") 49 | dev.ctrl_transfer(0x21, 4, 0, 0, 0) 50 | dev.ctrl_transfer(0x21, 3, 0, 0, "bootx\n") 51 | -------------------------------------------------------------------------------- /scripts/fetch_stdout.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019-2020 checkra1n team 3 | # This file is part of pongoOS. 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | 24 | import sys 25 | import usb.core 26 | dev = usb.core.find(idVendor=0x05ac, idProduct=0x4141) 27 | if dev is None: 28 | raise ValueError('Device not found') 29 | dev.set_configuration() 30 | 31 | #dev.ctrl_transfer(0x21, 4, 0, 0, 0) 32 | print("".join(chr (x) for x in dev.ctrl_transfer(0xa1, 1, 0, 0, 512))) 33 | -------------------------------------------------------------------------------- /scripts/issue_cmd.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019-2020 checkra1n team 3 | # This file is part of pongoOS. 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | import sys 24 | import usb.core 25 | dev = usb.core.find(idVendor=0x05ac, idProduct=0x4141) 26 | if dev is None: 27 | raise ValueError('Device not found') 28 | dev.set_configuration() 29 | 30 | #dev.ctrl_transfer(0x21, 4, 0, 0, 0) 31 | dev.ctrl_transfer(0x21, 3, 0, 0, sys.argv[1] + "\n") 32 | -------------------------------------------------------------------------------- /scripts/module_load.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019-2020 checkra1n team 3 | # This file is part of pongoOS. 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | import sys 24 | data = open(sys.argv[1], "rb").read() 25 | import usb.core 26 | dev = usb.core.find(idVendor=0x05ac, idProduct=0x4141) 27 | if dev is None: 28 | raise ValueError('Device not found') 29 | dev.set_configuration() 30 | 31 | dev.ctrl_transfer(0x21, 2, 0, 0, 0) 32 | dev.ctrl_transfer(0x21, 1, 0, 0, 0) 33 | dev.write(2,data,100000) 34 | if len(data) % 512 == 0: 35 | dev.write(2,"") 36 | dev.ctrl_transfer(0x21, 3, 0, 0, "modload\n") 37 | -------------------------------------------------------------------------------- /scripts/module_load_boot.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019-2020 checkra1n team 3 | # This file is part of pongoOS. 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | import sys 24 | data = open(sys.argv[1], "rb").read() 25 | import usb.core 26 | dev = usb.core.find(idVendor=0x05ac, idProduct=0x4141) 27 | if dev is None: 28 | raise ValueError('Device not found') 29 | dev.set_configuration() 30 | 31 | dev.ctrl_transfer(0x21, 2, 0, 0, 0) 32 | dev.ctrl_transfer(0x21, 1, 0, 0, 0) 33 | dev.write(2,data,100000) 34 | if len(data) % 512 == 0: 35 | dev.write(2,"") 36 | dev.ctrl_transfer(0x21, 3, 0, 0, "modload\n") 37 | dev.ctrl_transfer(0x21, 3, 0, 0, "bootx\n") 38 | -------------------------------------------------------------------------------- /scripts/upload_data.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019-2020 checkra1n team 3 | # This file is part of pongoOS. 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | import struct 24 | import sys 25 | data = open(sys.argv[1], "rb").read() 26 | import usb.core 27 | dev = usb.core.find(idVendor=0x05ac, idProduct=0x4141) 28 | if dev is None: 29 | raise ValueError('Device not found') 30 | dev.set_configuration() 31 | 32 | dev.ctrl_transfer(0x21, 2, 0, 0, 0) 33 | dev.ctrl_transfer(0x21, 1, 0, 0, struct.pack('I', len(data))) 34 | dev.write(2,data,1000000) 35 | -------------------------------------------------------------------------------- /src/boot/clearhook.S: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | .globl _clear_hook 28 | .globl _clear_hook_end 29 | .globl _clear_hook_orig_backing 30 | 31 | 32 | .align 4 33 | _clear_hook: 34 | mov x16, x30 35 | mov x30, x5 36 | mov x3, #0x800000000 37 | movk x3, #0x1800, lsl#16 38 | cmp x0, x3 39 | b.hi _clear_hook_orig_backing 40 | add x2, x1, x0 41 | cmp x2, x3 42 | b.lo _clear_hook_orig_backing 43 | mov x3, #0x800000000 44 | movk x3, #0x1900, lsl#16 45 | cmp x0, x3 46 | b.hi _clear_hook_orig_backing 47 | add x2, x1, x0 48 | cmp x2, x3 49 | b.lo _clear_hook_orig_backing 50 | mov x1, #0 51 | _clear_hook_orig_backing: 52 | nop 53 | nop 54 | br x16 55 | _clear_hook_end: 56 | -------------------------------------------------------------------------------- /src/boot/jump_to_image.S: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | .align 2 28 | .global _jump_to_image 29 | _jump_to_image: 30 | mov x30, x0 31 | mov x0, x1 32 | isb 33 | dsb sy 34 | ic iallu 35 | dsb sy 36 | isb 37 | mov x1, xzr 38 | mov x2, xzr 39 | mov x3, xzr 40 | ret 41 | 42 | .global _jump_to_image_extended 43 | _jump_to_image_extended: 44 | mov x30, x0 45 | mov x0, x1 46 | mov x8, x2 47 | isb 48 | dsb sy 49 | ic iallu 50 | dsb sy 51 | isb 52 | mov x1, xzr 53 | mov x2, xzr 54 | mov x3, xzr 55 | ret 56 | 57 | .global _tramp_hook 58 | _tramp_hook: 59 | mov x8, x27 60 | mov x9, x29 61 | mov x27, #0x800000000 62 | movk x27, #0x1800, lsl#16 63 | add x29, x27, #0x4 64 | -------------------------------------------------------------------------------- /src/boot/libc_workarounds.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #define strcpy strcpy_ 28 | #define memcpy memcpy_ 29 | #define strcmp strcmp_ 30 | #define strlen strlen_ 31 | 32 | char* strcpy_(char* to, const char* from) 33 | { 34 | char cur = 0; 35 | while ((cur = (*from++))) 36 | *to++ = cur; 37 | *to++ = 0; 38 | return to; // i know this is not up to spec but who uses the return value of strcpy anyway lmao 39 | } 40 | 41 | void* memcpy_(void* dst, const void* src, unsigned long n) 42 | { 43 | while (n) { 44 | *(char*)dst++ = *(char*)src++; 45 | n--; 46 | } 47 | return dst; // i know this is not up to spec but who uses the return value of memcpy anyway lmao 48 | } 49 | 50 | int strcmp_(const char* s1, const char* s2) 51 | { 52 | while (*s1 && (*s1 == *s2)) 53 | s1++, s2++; 54 | return *(const unsigned char*)s1 - *(const unsigned char*)s2; 55 | } 56 | 57 | unsigned long strlen_(const char* str) 58 | { 59 | unsigned long rv = 0; 60 | while (*str++) 61 | rv++; 62 | return rv; 63 | } 64 | 65 | -------------------------------------------------------------------------------- /src/boot/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #include 28 | extern void stage3_exit_to_el1_image(void* boot_args, void* boot_entry_point); 29 | extern void* gboot_args; 30 | extern void* gboot_entry_point; 31 | void main (void) { 32 | // hypv or kernel 33 | if (*(uint8_t*)(gboot_args + 8 + 7)) { 34 | // kernel 35 | pongo_entry((uint64_t*)gboot_args, gboot_entry_point, stage3_exit_to_el1_image); 36 | } else { 37 | // hypv 38 | pongo_entry(*(uint64_t**)(gboot_args + 0x20), (void*)*(uint64_t*)(gboot_args + 0x28), stage3_exit_to_el1_image); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/drivers/aes/aes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #ifndef AES_H 28 | #define AES_H 29 | 30 | #include 31 | #include 32 | 33 | #define AES_ALL_MASK (AES_MODE_MASK | AES_CIPHER_MASK | AES_BITS_MASK | AES_KEY_MASK) 34 | 35 | #define AES_ENCRYPT 0x00000000 36 | #define AES_DECRYPT 0x80000000 37 | #define AES_MODE_MASK 0x80000000 38 | 39 | #define AES_CBC 0x00000000 40 | #define AES_ECB 0x40000000 41 | #define AES_CIPHER_MASK 0x40000000 42 | 43 | #define AES_128 0x10000000 44 | #define AES_192 0x20000000 45 | #define AES_256 0x30000000 46 | #define AES_BITS_MASK 0x30000000 47 | 48 | #define AES_USER_KEY 0x00000000 49 | #define AES_UID 0x00000001 50 | #define AES_GID0 0x00000002 51 | #define AES_GID1 0x00000003 52 | #define AES_KEY_MASK 0x00000003 53 | 54 | // Return value of 0 = success. 55 | // Any other return value is an error from . 56 | int aes(uint32_t op, const void *src, void *dst, size_t len, const void *iv, const void *key); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/drivers/aes/aes_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #ifndef AES_PRIVATE_H 28 | #define AES_PRIVATE_H 29 | 30 | #ifdef PONGO_PRIVATE 31 | 32 | #include 33 | #include 34 | 35 | void aes_init(void); 36 | void aes_a7_init(void); 37 | void aes_a9_init(void); 38 | int aes_a7(uint32_t op, const void *src, void *dst, size_t len, const void *iv, const void *key); 39 | int aes_a9(uint32_t op, const void *src, void *dst, size_t len, const void *iv, const void *key); 40 | 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/drivers/framebuffer/fb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #include 28 | 29 | #define SCALE_FACTOR scale_factor 30 | #define LEFT_MARGIN 4 * scale_factor 31 | 32 | extern char overflow_mode; 33 | extern uint32_t* gFramebuffer; 34 | extern uint32_t gWidth; 35 | extern uint32_t gHeight; 36 | extern uint32_t gRowPixels; 37 | extern uint32_t y_cursor; 38 | extern uint32_t x_cursor; 39 | extern uint8_t scale_factor; 40 | 41 | void screen_init(); 42 | void screen_puts(const char* str); 43 | void screen_write(const char* str); 44 | void screen_putc(uint8_t c); 45 | void screen_clear_row(); 46 | void screen_mark_banner(); 47 | void screen_fill_basecolor(); 48 | void screen_fill(uint32_t color); 49 | -------------------------------------------------------------------------------- /src/drivers/gpio/gpio.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #include 28 | 29 | void gpio_main() { 30 | while(1) { 31 | iprintf("gpio irq %x\n", task_current()->irq_type); 32 | task_exit_irq(); 33 | } 34 | } 35 | struct task gpio_task = {.name = "gpio"}; 36 | 37 | uint64_t gGpioBase; 38 | void gpio_early_init() { 39 | gGpioBase = dt_get_u32_prop("gpio", "reg"); 40 | gGpioBase += gIOBase; 41 | } 42 | 43 | void gpio_init() { 44 | /* 45 | uint32_t len = 0; 46 | dt_node_t* buttons = dt_find(gDeviceTree, "buttons"); 47 | if (!buttons) panic("invalid devicetree: no buttons!"); 48 | uint32_t* interrupts = dt_prop(buttons, "interrupts", &len); 49 | if (!interrupts) panic("invalid devicetree: no interrupts!"); 50 | 51 | for (int i=0; i 28 | 29 | static bool s5l8960_probe(struct hal_platform_driver* device_driver, struct hal_platform* device) { 30 | if (device->cpid == 0x8960) { 31 | return true; 32 | } 33 | return false; 34 | } 35 | 36 | static struct usb_regs s5l8960_usb_regs = { 37 | .reg1 = 0x0e020158, 38 | .reg2 = 0x0e020160, 39 | .reg3 = 0x0e020188, 40 | .otg_irq = 162 41 | }; 42 | 43 | static bool s5l8960_get_platform_value(const char* name, void* value, size_t* size) { 44 | if (strcmp(name, "usb_regs") == 0 && *size == sizeof(struct usb_regs)) { 45 | memcpy(value, &s5l8960_usb_regs, sizeof(struct usb_regs)); 46 | return true; 47 | } 48 | return false; 49 | } 50 | 51 | static struct hal_platform_driver s5l8960_plat = { 52 | .name = "Apple A7 (S5L8960)", 53 | .context = NULL, 54 | .probe = s5l8960_probe, 55 | .get_platform_value = s5l8960_get_platform_value 56 | }; 57 | 58 | static void s5l8960_init(struct driver* driver) { 59 | hal_register_platform_driver(&s5l8960_plat); 60 | } 61 | 62 | REGISTER_DRIVER(s5l8960, s5l8960_init, NULL, DRIVER_FLAGS_PLATFORM); 63 | -------------------------------------------------------------------------------- /src/drivers/plat/s8000.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #import 28 | 29 | static bool s8000_probe(struct hal_platform_driver* device_driver, struct hal_platform* device) { 30 | if (device->cpid == 0x8000) { 31 | return true; 32 | } 33 | return false; 34 | } 35 | 36 | static struct usb_regs s8000_usb_regs = { 37 | .reg1 = 0x0e080250, 38 | .reg2 = 0x0e080258, 39 | .reg3 = 0x0e080290, 40 | .otg_irq = 214 41 | }; 42 | 43 | static bool s8000_get_platform_value(const char* name, void* value, size_t* size) { 44 | if (strcmp(name, "usb_regs") == 0 && *size == sizeof(struct usb_regs)) { 45 | memcpy(value, &s8000_usb_regs, sizeof(struct usb_regs)); 46 | return true; 47 | } 48 | return false; 49 | } 50 | 51 | static struct hal_platform_driver s8000_plat = { 52 | .name = "Apple A9 (S8000, Samsung)", 53 | .context = NULL, 54 | .probe = s8000_probe, 55 | .get_platform_value = s8000_get_platform_value 56 | }; 57 | 58 | static void s8000_init(struct driver* driver) { 59 | hal_register_platform_driver(&s8000_plat); 60 | } 61 | 62 | REGISTER_DRIVER(s8000, s8000_init, NULL, DRIVER_FLAGS_PLATFORM); 63 | -------------------------------------------------------------------------------- /src/drivers/plat/s8001.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #import 28 | 29 | static bool s8001_probe(struct hal_platform_driver* device_driver, struct hal_platform* device) { 30 | if (device->cpid == 0x8001) { 31 | return true; 32 | } 33 | return false; 34 | } 35 | 36 | static struct usb_regs s8001_usb_regs = { 37 | .reg1 = 0x0e080278, 38 | .reg2 = 0x0e080280, 39 | .reg3 = 0x0e0802B8, 40 | .otg_irq = 241 41 | }; 42 | 43 | static bool s8001_get_platform_value(const char* name, void* value, size_t* size) { 44 | if (strcmp(name, "usb_regs") == 0 && *size == sizeof(struct usb_regs)) { 45 | memcpy(value, &s8001_usb_regs, sizeof(struct usb_regs)); 46 | return true; 47 | } 48 | return false; 49 | } 50 | 51 | static struct hal_platform_driver s8001_plat = { 52 | .name = "Apple A9X (S8001)", 53 | .context = NULL, 54 | .probe = s8001_probe, 55 | .get_platform_value = s8001_get_platform_value 56 | }; 57 | 58 | static void s8001_init(struct driver* driver) { 59 | hal_register_platform_driver(&s8001_plat); 60 | } 61 | 62 | REGISTER_DRIVER(s8001, s8001_init, NULL, DRIVER_FLAGS_PLATFORM); 63 | -------------------------------------------------------------------------------- /src/drivers/plat/s8003.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #import 28 | 29 | static bool s8003_probe(struct hal_platform_driver* device_driver, struct hal_platform* device) { 30 | if (device->cpid == 0x8003) { 31 | return true; 32 | } 33 | return false; 34 | } 35 | 36 | static struct usb_regs s8003_usb_regs = { 37 | .reg1 = 0x0e080250, 38 | .reg2 = 0x0e080258, 39 | .reg3 = 0x0e080290, 40 | .otg_irq = 214 41 | }; 42 | 43 | static bool s8003_get_platform_value(const char* name, void* value, size_t* size) { 44 | if (strcmp(name, "usb_regs") == 0 && *size == sizeof(struct usb_regs)) { 45 | memcpy(value, &s8003_usb_regs, sizeof(struct usb_regs)); 46 | return true; 47 | } 48 | return false; 49 | } 50 | 51 | static struct hal_platform_driver s8003_plat = { 52 | .name = "Apple A9 (S8003, TSMC)", 53 | .context = NULL, 54 | .probe = s8003_probe, 55 | .get_platform_value = s8003_get_platform_value 56 | }; 57 | 58 | static void s8003_init(struct driver* driver) { 59 | hal_register_platform_driver(&s8003_plat); 60 | } 61 | 62 | REGISTER_DRIVER(s8003, s8003_init, NULL, DRIVER_FLAGS_PLATFORM); 63 | -------------------------------------------------------------------------------- /src/drivers/plat/t7000.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #import 28 | 29 | static bool t7000_probe(struct hal_platform_driver* device_driver, struct hal_platform* device) { 30 | if (device->cpid == 0x7000) { 31 | return true; 32 | } 33 | return false; 34 | } 35 | 36 | static struct usb_regs t7000_usb_regs = { 37 | .reg1 = 0x0e020248, 38 | .reg2 = 0x0e020250, 39 | .reg3 = 0x0e020288, 40 | .otg_irq = 182 41 | }; 42 | 43 | static bool t7000_get_platform_value(const char* name, void* value, size_t* size) { 44 | if (strcmp(name, "usb_regs") == 0 && *size == sizeof(struct usb_regs)) { 45 | memcpy(value, &t7000_usb_regs, sizeof(struct usb_regs)); 46 | return true; 47 | } 48 | return false; 49 | } 50 | 51 | static struct hal_platform_driver t7000_plat = { 52 | .name = "Apple A8 (T7000)", 53 | .context = NULL, 54 | .probe = t7000_probe, 55 | .get_platform_value = t7000_get_platform_value 56 | }; 57 | 58 | static void t7000_init(struct driver* driver) { 59 | hal_register_platform_driver(&t7000_plat); 60 | } 61 | 62 | REGISTER_DRIVER(t7000, t7000_init, NULL, DRIVER_FLAGS_PLATFORM); 63 | -------------------------------------------------------------------------------- /src/drivers/plat/t7001.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #import 28 | 29 | static bool t7001_probe(struct hal_platform_driver* device_driver, struct hal_platform* device) { 30 | if (device->cpid == 0x7001) { 31 | return true; 32 | } 33 | return false; 34 | } 35 | 36 | static struct usb_regs t7001_usb_regs = { 37 | .reg1 = 0x0e020248, 38 | .reg2 = 0x0e020250, 39 | .reg3 = 0x0e020288, 40 | .otg_irq = 182 41 | }; 42 | 43 | static bool t7001_get_platform_value(const char* name, void* value, size_t* size) { 44 | if (strcmp(name, "usb_regs") == 0 && *size == sizeof(struct usb_regs)) { 45 | memcpy(value, &t7001_usb_regs, sizeof(struct usb_regs)); 46 | return true; 47 | } 48 | return false; 49 | } 50 | 51 | static struct hal_platform_driver t7001_plat = { 52 | .name = "Apple A8X (T7001)", 53 | .context = NULL, 54 | .probe = t7001_probe, 55 | .get_platform_value = t7001_get_platform_value 56 | }; 57 | 58 | static void t7001_init(struct driver* driver) { 59 | hal_register_platform_driver(&t7001_plat); 60 | } 61 | 62 | REGISTER_DRIVER(t7001, t7001_init, NULL, DRIVER_FLAGS_PLATFORM); 63 | -------------------------------------------------------------------------------- /src/drivers/plat/t8010.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #import 28 | 29 | static bool t8010_probe(struct hal_platform_driver* device_driver, struct hal_platform* device) { 30 | if (device->cpid == 0x8010) { 31 | return true; 32 | } 33 | return false; 34 | } 35 | 36 | static struct usb_regs t8010_usb_regs = { 37 | .reg1 = 0x0e080268, 38 | .reg2 = 0x0e080270, 39 | .reg3 = 0x0e080290, 40 | .otg_irq = 241 41 | }; 42 | 43 | static bool t8010_get_platform_value(const char* name, void* value, size_t* size) { 44 | if (strcmp(name, "usb_regs") == 0 && *size == sizeof(struct usb_regs)) { 45 | memcpy(value, &t8010_usb_regs, sizeof(struct usb_regs)); 46 | return true; 47 | } 48 | return false; 49 | } 50 | 51 | static struct hal_platform_driver t8010_plat = { 52 | .name = "Apple A10 (T8010)", 53 | .context = NULL, 54 | .probe = t8010_probe, 55 | .get_platform_value = t8010_get_platform_value 56 | }; 57 | 58 | static void t8010_init(struct driver* driver) { 59 | hal_register_platform_driver(&t8010_plat); 60 | } 61 | 62 | REGISTER_DRIVER(t8010, t8010_init, NULL, DRIVER_FLAGS_PLATFORM); 63 | -------------------------------------------------------------------------------- /src/drivers/plat/t8011.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #import 28 | 29 | static bool t8011_probe(struct hal_platform_driver* device_driver, struct hal_platform* device) { 30 | if (device->cpid == 0x8011) { 31 | return true; 32 | } 33 | return false; 34 | } 35 | 36 | static struct usb_regs t8011_usb_regs = { 37 | .reg1 = 0x0e080288, 38 | .reg2 = 0x0e080290, 39 | .reg3 = 0x0e0802a0, 40 | .otg_irq = 243 41 | }; 42 | 43 | static bool t8011_get_platform_value(const char* name, void* value, size_t* size) { 44 | if (strcmp(name, "usb_regs") == 0 && *size == sizeof(struct usb_regs)) { 45 | memcpy(value, &t8011_usb_regs, sizeof(struct usb_regs)); 46 | return true; 47 | } 48 | return false; 49 | } 50 | 51 | static struct hal_platform_driver t8011_plat = { 52 | .name = "Apple A10X (T8011)", 53 | .context = NULL, 54 | .probe = t8011_probe, 55 | .get_platform_value = t8011_get_platform_value 56 | }; 57 | 58 | static void t8011_init(struct driver* driver) { 59 | hal_register_platform_driver(&t8011_plat); 60 | } 61 | 62 | REGISTER_DRIVER(t8011, t8011_init, NULL, DRIVER_FLAGS_PLATFORM); 63 | -------------------------------------------------------------------------------- /src/drivers/plat/t8012.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #import 28 | 29 | static bool t8012_probe(struct hal_platform_driver* device_driver, struct hal_platform* device) { 30 | if (device->cpid == 0x8012) { 31 | return true; 32 | } 33 | return false; 34 | } 35 | 36 | static struct usb_regs t8012_usb_regs = { 37 | .reg1 = 0x0e080268, 38 | .reg2 = 0x0e080270, 39 | .reg3 = 0x0e080290, 40 | .otg_irq = 304 41 | }; 42 | 43 | static bool t8012_get_platform_value(const char* name, void* value, size_t* size) { 44 | if (strcmp(name, "usb_regs") == 0 && *size == sizeof(struct usb_regs)) { 45 | memcpy(value, &t8012_usb_regs, sizeof(struct usb_regs)); 46 | return true; 47 | } 48 | return false; 49 | } 50 | 51 | static struct hal_platform_driver t8012_plat = { 52 | .name = "Apple T2 (T8012)", 53 | .context = NULL, 54 | .probe = t8012_probe, 55 | .get_platform_value = t8012_get_platform_value 56 | }; 57 | 58 | static void t8012_init(struct driver* driver) { 59 | hal_register_platform_driver(&t8012_plat); 60 | } 61 | 62 | REGISTER_DRIVER(t8012, t8012_init, NULL, DRIVER_FLAGS_PLATFORM); 63 | -------------------------------------------------------------------------------- /src/drivers/plat/t8015.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #import 28 | 29 | static bool t8015_probe(struct hal_platform_driver* device_driver, struct hal_platform* device) { 30 | if (device->cpid == 0x8015) { 31 | return true; 32 | } 33 | return false; 34 | } 35 | 36 | static struct usb_regs t8015_usb_regs = { 37 | .reg1 = 0x32080270, 38 | .reg2 = 0x32080278, 39 | .reg3 = 0x32080270, 40 | .otg_irq = 324 41 | }; 42 | 43 | static bool t8015_get_platform_value(const char* name, void* value, size_t* size) { 44 | if (strcmp(name, "usb_regs") == 0 && *size == sizeof(struct usb_regs)) { 45 | memcpy(value, &t8015_usb_regs, sizeof(struct usb_regs)); 46 | return true; 47 | } 48 | return false; 49 | } 50 | 51 | static struct hal_platform_driver t8015_plat = { 52 | .name = "Apple A11 (T8015)", 53 | .context = NULL, 54 | .probe = t8015_probe, 55 | .get_platform_value = t8015_get_platform_value 56 | }; 57 | 58 | static void t8015_init(struct driver* driver) { 59 | hal_register_platform_driver(&t8015_plat); 60 | } 61 | 62 | REGISTER_DRIVER(t8015, t8015_init, NULL, DRIVER_FLAGS_PLATFORM); 63 | -------------------------------------------------------------------------------- /src/drivers/timer/timer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #include 28 | extern void set_timer_reg(uint64_t v); 29 | extern void set_timer_ctr(uint64_t v); 30 | 31 | void timer_enable() { 32 | set_timer_reg(1); // turn on timer 33 | 34 | } 35 | void timer_disable() { 36 | set_timer_reg(2); // turn off timer 37 | } 38 | 39 | #define LLKTRW_QUANTA 24000 // 1ms quanta 40 | char timer_inited = 0; 41 | 42 | void timer_rearm() { 43 | set_timer_ctr(LLKTRW_QUANTA); 44 | } 45 | 46 | void timer_init() { 47 | set_timer_reg(2); // turn off timer 48 | set_timer_ctr(0xfffffff); 49 | set_timer_reg(1); // turn on timer 50 | timer_inited = 1; 51 | } 52 | -------------------------------------------------------------------------------- /src/drivers/timer/timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | void timer_init(); 28 | void timer_rearm(); 29 | void timer_disable(); 30 | void timer_enable(); 31 | -------------------------------------------------------------------------------- /src/drivers/tz/tz.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | 28 | void tz_setup(void); 29 | void tz_lockdown(void); 30 | bool tz_blackbird(void); 31 | void *tz0_calculate_encrypted_block_addr(uint64_t offset); 32 | -------------------------------------------------------------------------------- /src/drivers/uart/uart.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | void serial_init(); 28 | void serial_early_init(); 29 | void serial_pinmux_init(); 30 | void serial_putc(char c); 31 | void serial_disable_rx(); 32 | void serial_enable_rx(); 33 | void uart_flush(); 34 | 35 | #ifdef UART_INTERNAL 36 | #define rULCON0 (*(volatile uint32_t*)(gUartBase + 0x00)) //UART 0 Line control 37 | #define rUCON0 (*(volatile uint32_t*)(gUartBase + 0x04)) //UART 0 Control 38 | #define rUFCON0 (*(volatile uint32_t*)(gUartBase + 0x08)) //UART 0 FIFO control 39 | #define rUMCON0 (*(volatile uint32_t*)(gUartBase + 0x0c)) //UART 0 Modem control 40 | #define rUTRSTAT0 (*(volatile uint32_t*)(gUartBase + 0x10)) //UART 0 Tx/Rx status 41 | #define rUERSTAT0 (*(volatile uint32_t*)(gUartBase + 0x14)) //UART 0 Rx error status 42 | #define rUFSTAT0 (*(volatile uint32_t*)(gUartBase + 0x18)) //UART 0 FIFO status 43 | #define rUMSTAT0 (*(volatile uint32_t*)(gUartBase + 0x1c)) //UART 0 Modem status 44 | #define rUTXH0 (*(volatile uint32_t*)(gUartBase + 0x20)) //UART 0 Transmission Hold 45 | #define rURXH0 (*(volatile uint32_t*)(gUartBase + 0x24)) //UART 0 Receive buffer 46 | #define rUBRDIV0 (*(volatile uint32_t*)(gUartBase + 0x28)) //UART 0 Baud rate divisor 47 | #define rUDIVSLOT0 (*(volatile uint32_t*)(gUartBase + 0x2C)) //UART 0 Baud rate divisor 48 | #define rUINTM0 (*(volatile uint32_t*)(gUartBase + 0x38)) //UART 0 Baud rate divisor 49 | 50 | #define rT8011RX (*(volatile uint32_t*)(gGpioBase + 0x2A0)) 51 | #define rT8011TX (*(volatile uint32_t*)(gGpioBase + 0x2A4)) 52 | #define UART_TX_MUX 0x8723A0 53 | #define UART_RX_MUX 0x0763A0 54 | 55 | extern uint64_t gUartBase; 56 | #endif 57 | -------------------------------------------------------------------------------- /src/drivers/xnu/xnu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | extern void xnu_boot(void); 28 | extern void xnu_init(void); 29 | extern void xnu_loadrd(void); 30 | extern void xnu_hook(void); 31 | -------------------------------------------------------------------------------- /src/kernel/dtree_getprop.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #include 28 | 29 | uint32_t dt_get_u32_prop(const char* device, const char* prop) { 30 | uint32_t rval = 0; 31 | uint32_t len = 0; 32 | dt_node_t* dev = dt_find(gDeviceTree, device); 33 | if (!dev) panic("invalid devicetree: no device!"); 34 | uint32_t* val = dt_prop(dev, prop, &len); 35 | if (!val) panic("invalid devicetree: no prop!"); 36 | memcpy(&rval, &val[0], 4); 37 | return rval; 38 | } 39 | uint64_t dt_get_u64_prop(const char* device, const char* prop) { 40 | uint64_t rval = 0; 41 | uint32_t len = 0; 42 | dt_node_t* dev = dt_find(gDeviceTree, device); 43 | if (!dev) panic("invalid devicetree: no device!"); 44 | uint64_t* val = dt_prop(dev, prop, &len); 45 | if (!val) panic("invalid devicetree: no prop!"); 46 | memcpy(&rval, &val[0], 8); 47 | return rval; 48 | } 49 | uint64_t dt_get_u64_prop_i(const char* device, const char* prop, uint32_t idx) { 50 | uint64_t rval = 0; 51 | uint32_t len = 0; 52 | dt_node_t* dev = dt_find(gDeviceTree, device); 53 | if (!dev) panic("invalid devicetree: no device!"); 54 | uint64_t* val = dt_prop(dev, prop, &len); 55 | if (!val) panic("invalid devicetree: no prop!"); 56 | memcpy(&rval, &val[idx], 8); 57 | return rval; 58 | } 59 | void* dt_get_prop(const char* device, const char* prop, uint32_t* size) { 60 | uint32_t len = 0; 61 | dt_node_t* dev = dt_find(gDeviceTree, device); 62 | if (!dev) panic("invalid devicetree: no device!"); 63 | void* val = dt_prop(dev, prop, &len); 64 | if (!val) panic("invalid devicetree: no prop!"); 65 | if (size) *size = len; 66 | return val; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /src/kernel/legacy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #include 28 | #include 29 | // Legacy support - this was exported to modules 30 | 31 | void print_register(uint64_t value) 32 | { 33 | iprintf("0x%016llx\n", value); 34 | } 35 | 36 | void command_puts(const char* c) 37 | { 38 | puts(c); 39 | } 40 | 41 | void command_putc(char c) 42 | { 43 | putc(c, stdout); 44 | } 45 | 46 | void* memstr(const void* big, unsigned long blength, const char* little) 47 | { 48 | return memmem(big, blength, (void*)little, strlen(little) + 1); 49 | } 50 | void* memstr_partial(const void* big, unsigned long blength, const char* little) 51 | { 52 | return memmem(big, blength, (void*)little, strlen(little)); 53 | } 54 | 55 | -------------------------------------------------------------------------------- /src/kernel/panic.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #include 28 | #include 29 | #include 30 | char preemption_over; 31 | 32 | char panic_did_enter = 0; 33 | void panic(const char* str, ...) { 34 | disable_interrupts(); 35 | 36 | if (panic_did_enter) { 37 | iprintf("\ndouble panic: %s\n", str); 38 | while(1) {} 39 | } 40 | panic_did_enter = 1; 41 | preemption_over = 1; 42 | 43 | va_list va; 44 | va_start(va, str); 45 | iprintf("\npanic: "); 46 | viprintf(str, va); 47 | va_end(va); 48 | 49 | struct task *t = task_current(); 50 | 51 | iprintf("\ncrashed task: "); 52 | if (t && t->name[0]) 53 | puts(t->name); 54 | else puts("unknown"); 55 | iprintf("\ncrashed process: "); 56 | if (t && t->proc && t->proc->name[0]) 57 | puts(t->proc->name); 58 | else puts("unknown"); 59 | int depth = 0; 60 | 61 | iprintf("\nCall stack:\n"); 62 | uint64_t fpcopy[2]; 63 | for(uint64_t *fp = __builtin_frame_address(0); fp; fp = (uint64_t*)fpcopy[0]) 64 | { 65 | if (memcpy_trap(fpcopy, fp, 0x10) == 0x10) { 66 | iprintf("0x%016llx: fp 0x%016llx, lr 0x%016llx\n", ((uint64_t)fp), fpcopy[0], fpcopy[1]); 67 | } else { 68 | iprintf("couldn't access frame at %016llx, stopping here..,\n", (uint64_t)fp); 69 | break; 70 | } 71 | depth++; 72 | if (depth > 64) { 73 | iprintf("stack depth too large, stopping here...\n"); 74 | } 75 | } 76 | 77 | sleep(5); 78 | wdt_reset(); 79 | } 80 | -------------------------------------------------------------------------------- /src/kernel/support/exit.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #include 28 | 29 | int _exit() { 30 | task_exit(); 31 | return -1; // should never be reached, ever. 32 | } 33 | -------------------------------------------------------------------------------- /src/kernel/support/malloc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #include 28 | 29 | void __malloc_lock(struct _reent * unused) { 30 | disable_interrupts(); 31 | } 32 | 33 | void __malloc_unlock(struct _reent * unused) { 34 | enable_interrupts(); 35 | } 36 | -------------------------------------------------------------------------------- /src/kernel/support/process.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #include 28 | #include 29 | 30 | #undef errno 31 | int errno; 32 | 33 | pid_t _getpid(void) 34 | { 35 | return task_current()->pid; 36 | } 37 | 38 | int _kill(pid_t pid, int sig) 39 | { 40 | return ENOTSUP; 41 | } 42 | -------------------------------------------------------------------------------- /src/kernel/support/sbrk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #include 28 | 29 | uint64_t heap_base = 0xe00000000; 30 | uint64_t heap_cursor = 0xe00000000; 31 | uint64_t heap_end = 0xe00000000; 32 | extern struct vm_space kernel_vm_space; 33 | caddr_t _sbrk(int size) { 34 | disable_interrupts(); 35 | uint64_t cursor_copy = heap_cursor; 36 | heap_cursor += size; 37 | while (heap_cursor > heap_end) { 38 | vm_space_map_page_physical_prot(&kernel_vm_space, heap_end, ppage_alloc(), PROT_READ|PROT_WRITE|PROT_KERN_ONLY); 39 | heap_end += 0x4000; 40 | } 41 | enable_interrupts(); 42 | return (caddr_t)cursor_copy; 43 | } 44 | -------------------------------------------------------------------------------- /src/kernel/vfs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #ifndef vfs_h 28 | #define vfs_h 29 | 30 | #include 31 | 32 | #define FILETABLE_MAX_SIZE 512 33 | 34 | struct file; 35 | 36 | struct fileops { 37 | void (*initialize)(struct file* file); 38 | void (*destroy)(struct file* file); 39 | }; 40 | 41 | struct vnode { 42 | 43 | }; 44 | 45 | struct file { 46 | lock lock; 47 | uint32_t refcount; 48 | struct fileops* fileops; 49 | void* fileinfo; 50 | }; 51 | 52 | struct filedesc { 53 | struct file* file; 54 | uint32_t refcount; 55 | }; 56 | 57 | struct filetable { 58 | struct filedesc** file_table; 59 | uint32_t file_count; 60 | uint32_t refcount; 61 | }; 62 | 63 | void filetable_reference(struct filetable* filetable); 64 | void filetable_release(struct filetable* filetable); 65 | 66 | void filedesc_reference(struct filedesc* filetable); 67 | void filedesc_release(struct filedesc* filetable); 68 | 69 | void file_reference(struct file* filetable); 70 | void file_release(struct file* filetable); 71 | 72 | struct file* file_create(); 73 | struct filedesc* filedesc_create(struct file* file); 74 | struct filetable* filetable_create(uint32_t size); 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /src/lib/libDER/libDER.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2007,2011,2014 Apple Inc. All Rights Reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | 25 | /* 26 | * libDER.h - main header for libDER, a ROM-capable DER decoding library. 27 | * 28 | */ 29 | 30 | #ifndef _LIB_DER_H_ 31 | #define _LIB_DER_H_ 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | #include 38 | /* 39 | * Error returns generated by this library. 40 | */ 41 | typedef enum { 42 | DR_Success, 43 | DR_EndOfSequence, /* end of sequence or set */ 44 | DR_UnexpectedTag, /* unexpected tag found while decoding */ 45 | DR_DecodeError, /* misc. decoding error (badly formatted DER) */ 46 | DR_Unimplemented, /* function not implemented in this configuration */ 47 | DR_IncompleteSeq, /* incomplete sequence */ 48 | DR_ParamErr, /* incoming parameter error */ 49 | DR_BufOverflow /* buffer overflow */ 50 | /* etc. */ 51 | } DERReturn; 52 | 53 | /* 54 | * Primary representation of a block of memory. 55 | */ 56 | typedef struct { 57 | DERByte *data; 58 | DERSize length; 59 | } DERItem; 60 | 61 | /* 62 | * The structure of a sequence during decode or encode is expressed as 63 | * an array of DERItemSpecs. While decoding or encoding a sequence, 64 | * each item in the sequence corresponds to one DERItemSpec. 65 | */ 66 | typedef struct { 67 | DERSize offset; /* offset of destination DERItem */ 68 | DERTag tag; /* DER tag */ 69 | DERShort options; /* DER_DEC_xxx or DER_ENC_xxx */ 70 | } DERItemSpec; 71 | 72 | /* 73 | * Macro to obtain offset of a DERDecodedInfo within a struct. 74 | * FIXME this is going to need reworking to avoid compiler warnings 75 | * on 64-bit compiles. It'll work OK as long as an offset can't be larger 76 | * than a DERSize, but the cast from a pointer to a DERSize may 77 | * provoke compiler warnings. 78 | */ 79 | #define DER_OFFSET(type, field) ((DERSize)(&((type *)0)->field)) 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif /* _LIB_DER_H_ */ 86 | 87 | -------------------------------------------------------------------------------- /src/modules/linux/libfdt/Makefile.libfdt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) 2 | # Makefile.libfdt 3 | # 4 | # This is not a complete Makefile of itself. Instead, it is designed to 5 | # be easily embeddable into other systems of Makefiles. 6 | # 7 | LIBFDT_soname = libfdt.$(SHAREDLIB_EXT).1 8 | LIBFDT_INCLUDES = fdt.h libfdt.h libfdt_env.h 9 | LIBFDT_VERSION = version.lds 10 | LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c fdt_empty_tree.c \ 11 | fdt_addresses.c fdt_overlay.c 12 | LIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o) 13 | LIBFDT_LIB = libfdt-$(DTC_VERSION).$(SHAREDLIB_EXT) 14 | 15 | libfdt_clean: 16 | @$(VECHO) CLEAN "(libfdt)" 17 | rm -f $(STD_CLEANFILES:%=$(LIBFDT_dir)/%) 18 | rm -f $(LIBFDT_dir)/$(LIBFDT_soname) 19 | -------------------------------------------------------------------------------- /src/modules/linux/libfdt/TODO: -------------------------------------------------------------------------------- 1 | - Tree traversal functions 2 | - Graft function 3 | - Complete libfdt.h documenting comments 4 | -------------------------------------------------------------------------------- /src/modules/linux/libfdt/fdt.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */ 2 | #ifndef FDT_H 3 | #define FDT_H 4 | /* 5 | * libfdt - Flat Device Tree manipulation 6 | * Copyright (C) 2006 David Gibson, IBM Corporation. 7 | * Copyright 2012 Kim Phillips, Freescale Semiconductor. 8 | */ 9 | 10 | #ifndef __ASSEMBLY__ 11 | 12 | struct fdt_header { 13 | fdt32_t magic; /* magic word FDT_MAGIC */ 14 | fdt32_t totalsize; /* total size of DT block */ 15 | fdt32_t off_dt_struct; /* offset to structure */ 16 | fdt32_t off_dt_strings; /* offset to strings */ 17 | fdt32_t off_mem_rsvmap; /* offset to memory reserve map */ 18 | fdt32_t version; /* format version */ 19 | fdt32_t last_comp_version; /* last compatible version */ 20 | 21 | /* version 2 fields below */ 22 | fdt32_t boot_cpuid_phys; /* Which physical CPU id we're 23 | booting on */ 24 | /* version 3 fields below */ 25 | fdt32_t size_dt_strings; /* size of the strings block */ 26 | 27 | /* version 17 fields below */ 28 | fdt32_t size_dt_struct; /* size of the structure block */ 29 | }; 30 | 31 | struct fdt_reserve_entry { 32 | fdt64_t address; 33 | fdt64_t size; 34 | }; 35 | 36 | struct fdt_node_header { 37 | fdt32_t tag; 38 | char name[0]; 39 | }; 40 | 41 | struct fdt_property { 42 | fdt32_t tag; 43 | fdt32_t len; 44 | fdt32_t nameoff; 45 | char data[0]; 46 | }; 47 | 48 | #endif /* !__ASSEMBLY */ 49 | 50 | #define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */ 51 | #define FDT_TAGSIZE sizeof(fdt32_t) 52 | 53 | #define FDT_BEGIN_NODE 0x1 /* Start node: full name */ 54 | #define FDT_END_NODE 0x2 /* End node */ 55 | #define FDT_PROP 0x3 /* Property: name off, 56 | size, content */ 57 | #define FDT_NOP 0x4 /* nop */ 58 | #define FDT_END 0x9 59 | 60 | #define FDT_V1_SIZE (7*sizeof(fdt32_t)) 61 | #define FDT_V2_SIZE (FDT_V1_SIZE + sizeof(fdt32_t)) 62 | #define FDT_V3_SIZE (FDT_V2_SIZE + sizeof(fdt32_t)) 63 | #define FDT_V16_SIZE FDT_V3_SIZE 64 | #define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(fdt32_t)) 65 | 66 | #endif /* FDT_H */ 67 | -------------------------------------------------------------------------------- /src/modules/linux/libfdt/fdt_addresses.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) 2 | /* 3 | * libfdt - Flat Device Tree manipulation 4 | * Copyright (C) 2014 David Gibson 5 | * Copyright (C) 2018 embedded brains GmbH 6 | */ 7 | #include "libfdt_env.h" 8 | 9 | #include 10 | #include 11 | 12 | #include "libfdt_internal.h" 13 | 14 | static int fdt_cells(const void *fdt, int nodeoffset, const char *name) 15 | { 16 | const fdt32_t *c; 17 | uint32_t val; 18 | int len; 19 | 20 | c = fdt_getprop(fdt, nodeoffset, name, &len); 21 | if (!c) 22 | return len; 23 | 24 | if (len != sizeof(*c)) 25 | return -FDT_ERR_BADNCELLS; 26 | 27 | val = fdt32_to_cpu(*c); 28 | if (val > FDT_MAX_NCELLS) 29 | return -FDT_ERR_BADNCELLS; 30 | 31 | return (int)val; 32 | } 33 | 34 | int fdt_address_cells(const void *fdt, int nodeoffset) 35 | { 36 | int val; 37 | 38 | val = fdt_cells(fdt, nodeoffset, "#address-cells"); 39 | if (val == 0) 40 | return -FDT_ERR_BADNCELLS; 41 | if (val == -FDT_ERR_NOTFOUND) 42 | return 2; 43 | return val; 44 | } 45 | 46 | int fdt_size_cells(const void *fdt, int nodeoffset) 47 | { 48 | int val; 49 | 50 | val = fdt_cells(fdt, nodeoffset, "#size-cells"); 51 | if (val == -FDT_ERR_NOTFOUND) 52 | return 1; 53 | return val; 54 | } 55 | 56 | /* This function assumes that [address|size]_cells is 1 or 2 */ 57 | int fdt_appendprop_addrrange(void *fdt, int parent, int nodeoffset, 58 | const char *name, uint64_t addr, uint64_t size) 59 | { 60 | int addr_cells, size_cells, ret; 61 | uint8_t data[sizeof(fdt64_t) * 2], *prop; 62 | 63 | ret = fdt_address_cells(fdt, parent); 64 | if (ret < 0) 65 | return ret; 66 | addr_cells = ret; 67 | 68 | ret = fdt_size_cells(fdt, parent); 69 | if (ret < 0) 70 | return ret; 71 | size_cells = ret; 72 | 73 | /* check validity of address */ 74 | prop = data; 75 | if (addr_cells == 1) { 76 | if ((addr > UINT32_MAX) || ((UINT32_MAX + 1 - addr) < size)) 77 | return -FDT_ERR_BADVALUE; 78 | 79 | fdt32_st(prop, (uint32_t)addr); 80 | } else if (addr_cells == 2) { 81 | fdt64_st(prop, addr); 82 | } else { 83 | return -FDT_ERR_BADNCELLS; 84 | } 85 | 86 | /* check validity of size */ 87 | prop += addr_cells * sizeof(fdt32_t); 88 | if (size_cells == 1) { 89 | if (size > UINT32_MAX) 90 | return -FDT_ERR_BADVALUE; 91 | 92 | fdt32_st(prop, (uint32_t)size); 93 | } else if (size_cells == 2) { 94 | fdt64_st(prop, size); 95 | } else { 96 | return -FDT_ERR_BADNCELLS; 97 | } 98 | 99 | return fdt_appendprop(fdt, nodeoffset, name, data, 100 | (addr_cells + size_cells) * sizeof(fdt32_t)); 101 | } 102 | -------------------------------------------------------------------------------- /src/modules/linux/libfdt/fdt_empty_tree.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) 2 | /* 3 | * libfdt - Flat Device Tree manipulation 4 | * Copyright (C) 2012 David Gibson, IBM Corporation. 5 | */ 6 | #include "libfdt_env.h" 7 | 8 | #include 9 | #include 10 | 11 | #include "libfdt_internal.h" 12 | 13 | int fdt_create_empty_tree(void *buf, int bufsize) 14 | { 15 | int err; 16 | 17 | err = fdt_create(buf, bufsize); 18 | if (err) 19 | return err; 20 | 21 | err = fdt_finish_reservemap(buf); 22 | if (err) 23 | return err; 24 | 25 | err = fdt_begin_node(buf, ""); 26 | if (err) 27 | return err; 28 | 29 | err = fdt_end_node(buf); 30 | if (err) 31 | return err; 32 | 33 | err = fdt_finish(buf); 34 | if (err) 35 | return err; 36 | 37 | return fdt_open_into(buf, buf, bufsize); 38 | } 39 | -------------------------------------------------------------------------------- /src/modules/linux/libfdt/fdt_strerror.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) 2 | /* 3 | * libfdt - Flat Device Tree manipulation 4 | * Copyright (C) 2006 David Gibson, IBM Corporation. 5 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 6 | */ 7 | #include "libfdt_env.h" 8 | 9 | #include 10 | #include 11 | 12 | #include "libfdt_internal.h" 13 | 14 | struct fdt_errtabent { 15 | const char *str; 16 | }; 17 | 18 | #define FDT_ERRTABENT(val) \ 19 | [(val)] = { .str = #val, } 20 | 21 | static struct fdt_errtabent fdt_errtable[] = { 22 | FDT_ERRTABENT(FDT_ERR_NOTFOUND), 23 | FDT_ERRTABENT(FDT_ERR_EXISTS), 24 | FDT_ERRTABENT(FDT_ERR_NOSPACE), 25 | 26 | FDT_ERRTABENT(FDT_ERR_BADOFFSET), 27 | FDT_ERRTABENT(FDT_ERR_BADPATH), 28 | FDT_ERRTABENT(FDT_ERR_BADPHANDLE), 29 | FDT_ERRTABENT(FDT_ERR_BADSTATE), 30 | 31 | FDT_ERRTABENT(FDT_ERR_TRUNCATED), 32 | FDT_ERRTABENT(FDT_ERR_BADMAGIC), 33 | FDT_ERRTABENT(FDT_ERR_BADVERSION), 34 | FDT_ERRTABENT(FDT_ERR_BADSTRUCTURE), 35 | FDT_ERRTABENT(FDT_ERR_BADLAYOUT), 36 | FDT_ERRTABENT(FDT_ERR_INTERNAL), 37 | FDT_ERRTABENT(FDT_ERR_BADNCELLS), 38 | FDT_ERRTABENT(FDT_ERR_BADVALUE), 39 | FDT_ERRTABENT(FDT_ERR_BADOVERLAY), 40 | FDT_ERRTABENT(FDT_ERR_NOPHANDLES), 41 | FDT_ERRTABENT(FDT_ERR_BADFLAGS), 42 | }; 43 | #define FDT_ERRTABSIZE (sizeof(fdt_errtable) / sizeof(fdt_errtable[0])) 44 | 45 | const char *fdt_strerror(int errval) 46 | { 47 | if (errval > 0) 48 | return ""; 49 | else if (errval == 0) 50 | return ""; 51 | else if (errval > -FDT_ERRTABSIZE) { 52 | const char *s = fdt_errtable[-errval].str; 53 | 54 | if (s) 55 | return s; 56 | } 57 | 58 | return ""; 59 | } 60 | -------------------------------------------------------------------------------- /src/modules/linux/libfdt/fdt_wip.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) 2 | /* 3 | * libfdt - Flat Device Tree manipulation 4 | * Copyright (C) 2006 David Gibson, IBM Corporation. 5 | */ 6 | #include "libfdt_env.h" 7 | 8 | #include 9 | #include 10 | 11 | #include "libfdt_internal.h" 12 | 13 | int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset, 14 | const char *name, int namelen, 15 | uint32_t idx, const void *val, 16 | int len) 17 | { 18 | void *propval; 19 | int proplen; 20 | 21 | propval = fdt_getprop_namelen_w(fdt, nodeoffset, name, namelen, 22 | &proplen); 23 | if (!propval) 24 | return proplen; 25 | 26 | if (proplen < (len + idx)) 27 | return -FDT_ERR_NOSPACE; 28 | 29 | memcpy((char *)propval + idx, val, len); 30 | return 0; 31 | } 32 | 33 | int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, 34 | const void *val, int len) 35 | { 36 | const void *propval; 37 | int proplen; 38 | 39 | propval = fdt_getprop(fdt, nodeoffset, name, &proplen); 40 | if (!propval) 41 | return proplen; 42 | 43 | if (proplen != len) 44 | return -FDT_ERR_NOSPACE; 45 | 46 | return fdt_setprop_inplace_namelen_partial(fdt, nodeoffset, name, 47 | strlen(name), 0, 48 | val, len); 49 | } 50 | 51 | static void fdt_nop_region_(void *start, int len) 52 | { 53 | fdt32_t *p; 54 | 55 | for (p = start; (char *)p < ((char *)start + len); p++) 56 | *p = cpu_to_fdt32(FDT_NOP); 57 | } 58 | 59 | int fdt_nop_property(void *fdt, int nodeoffset, const char *name) 60 | { 61 | struct fdt_property *prop; 62 | int len; 63 | 64 | prop = fdt_get_property_w(fdt, nodeoffset, name, &len); 65 | if (!prop) 66 | return len; 67 | 68 | fdt_nop_region_(prop, len + sizeof(*prop)); 69 | 70 | return 0; 71 | } 72 | 73 | int fdt_node_end_offset_(void *fdt, int offset) 74 | { 75 | int depth = 0; 76 | 77 | while ((offset >= 0) && (depth >= 0)) 78 | offset = fdt_next_node(fdt, offset, &depth); 79 | 80 | return offset; 81 | } 82 | 83 | int fdt_nop_node(void *fdt, int nodeoffset) 84 | { 85 | int endoffset; 86 | 87 | endoffset = fdt_node_end_offset_(fdt, nodeoffset); 88 | if (endoffset < 0) 89 | return endoffset; 90 | 91 | fdt_nop_region_(fdt_offset_ptr_w(fdt, nodeoffset, 0), 92 | endoffset - nodeoffset); 93 | return 0; 94 | } 95 | -------------------------------------------------------------------------------- /src/modules/linux/libfdt/libfdt_internal.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */ 2 | #ifndef LIBFDT_INTERNAL_H 3 | #define LIBFDT_INTERNAL_H 4 | /* 5 | * libfdt - Flat Device Tree manipulation 6 | * Copyright (C) 2006 David Gibson, IBM Corporation. 7 | */ 8 | #include 9 | 10 | #define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) 11 | #define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE)) 12 | 13 | int32_t fdt_ro_probe_(const void *fdt); 14 | #define FDT_RO_PROBE(fdt) \ 15 | { \ 16 | int32_t totalsize_; \ 17 | if ((totalsize_ = fdt_ro_probe_(fdt)) < 0) \ 18 | return totalsize_; \ 19 | } 20 | 21 | int fdt_check_node_offset_(const void *fdt, int offset); 22 | int fdt_check_prop_offset_(const void *fdt, int offset); 23 | const char *fdt_find_string_(const char *strtab, int tabsize, const char *s); 24 | int fdt_node_end_offset_(void *fdt, int nodeoffset); 25 | 26 | static inline const void *fdt_offset_ptr_(const void *fdt, int offset) 27 | { 28 | return (const char *)fdt + fdt_off_dt_struct(fdt) + offset; 29 | } 30 | 31 | static inline void *fdt_offset_ptr_w_(void *fdt, int offset) 32 | { 33 | return (void *)(uintptr_t)fdt_offset_ptr_(fdt, offset); 34 | } 35 | 36 | static inline const struct fdt_reserve_entry *fdt_mem_rsv_(const void *fdt, int n) 37 | { 38 | const struct fdt_reserve_entry *rsv_table = 39 | (const struct fdt_reserve_entry *) 40 | ((const char *)fdt + fdt_off_mem_rsvmap(fdt)); 41 | 42 | return rsv_table + n; 43 | } 44 | static inline struct fdt_reserve_entry *fdt_mem_rsv_w_(void *fdt, int n) 45 | { 46 | return (void *)(uintptr_t)fdt_mem_rsv_(fdt, n); 47 | } 48 | 49 | #define FDT_SW_MAGIC (~FDT_MAGIC) 50 | 51 | #endif /* LIBFDT_INTERNAL_H */ 52 | -------------------------------------------------------------------------------- /src/modules/linux/libfdt/version.lds: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */ 2 | LIBFDT_1.2 { 3 | global: 4 | fdt_next_node; 5 | fdt_check_header; 6 | fdt_move; 7 | fdt_string; 8 | fdt_num_mem_rsv; 9 | fdt_get_mem_rsv; 10 | fdt_subnode_offset_namelen; 11 | fdt_subnode_offset; 12 | fdt_path_offset_namelen; 13 | fdt_path_offset; 14 | fdt_get_name; 15 | fdt_get_property_namelen; 16 | fdt_get_property; 17 | fdt_getprop_namelen; 18 | fdt_getprop; 19 | fdt_get_phandle; 20 | fdt_get_alias_namelen; 21 | fdt_get_alias; 22 | fdt_get_path; 23 | fdt_supernode_atdepth_offset; 24 | fdt_node_depth; 25 | fdt_parent_offset; 26 | fdt_node_offset_by_prop_value; 27 | fdt_node_offset_by_phandle; 28 | fdt_node_check_compatible; 29 | fdt_node_offset_by_compatible; 30 | fdt_setprop_inplace; 31 | fdt_nop_property; 32 | fdt_nop_node; 33 | fdt_create; 34 | fdt_add_reservemap_entry; 35 | fdt_finish_reservemap; 36 | fdt_begin_node; 37 | fdt_property; 38 | fdt_end_node; 39 | fdt_finish; 40 | fdt_open_into; 41 | fdt_pack; 42 | fdt_add_mem_rsv; 43 | fdt_del_mem_rsv; 44 | fdt_set_name; 45 | fdt_setprop; 46 | fdt_delprop; 47 | fdt_add_subnode_namelen; 48 | fdt_add_subnode; 49 | fdt_del_node; 50 | fdt_strerror; 51 | fdt_offset_ptr; 52 | fdt_next_tag; 53 | fdt_appendprop; 54 | fdt_create_empty_tree; 55 | fdt_first_property_offset; 56 | fdt_get_property_by_offset; 57 | fdt_getprop_by_offset; 58 | fdt_next_property_offset; 59 | fdt_first_subnode; 60 | fdt_next_subnode; 61 | fdt_address_cells; 62 | fdt_size_cells; 63 | fdt_stringlist_contains; 64 | fdt_stringlist_count; 65 | fdt_stringlist_search; 66 | fdt_stringlist_get; 67 | fdt_resize; 68 | fdt_overlay_apply; 69 | fdt_get_string; 70 | fdt_find_max_phandle; 71 | fdt_generate_phandle; 72 | fdt_check_full; 73 | fdt_setprop_placeholder; 74 | fdt_property_placeholder; 75 | fdt_header_size_; 76 | fdt_appendprop_addrrange; 77 | fdt_setprop_inplace_namelen_partial; 78 | fdt_create_with_flags; 79 | local: 80 | *; 81 | }; 82 | -------------------------------------------------------------------------------- /src/shell/autoboot.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #ifdef AUTOBOOT 28 | #include 29 | uint64_t* autoboot_block; 30 | void pongo_autoboot() 31 | { 32 | if (autoboot_block) { 33 | resize_loader_xfer_data((uint32_t)autoboot_block[1]); 34 | memcpy(loader_xfer_recv_data, &autoboot_block[2], (uint32_t)autoboot_block[1]); 35 | loader_xfer_recv_count = (uint32_t)autoboot_block[1]; 36 | autoboot_count = loader_xfer_recv_count; 37 | phys_force_free(vatophys((uint64_t)autoboot_block), (autoboot_block[1] + 0x20 + 0x3fff) & ~0x3fff); 38 | 39 | queue_rx_string("modload\nautoboot\n"); 40 | } 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/shell/aux.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | int hexparse(uint8_t *buf, char *s, size_t len) 33 | { 34 | for(size_t i = 0; i < len; ++i) 35 | { 36 | char c = s[2*i], 37 | d = s[2*i+1]; 38 | if(!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')) || 39 | !((d >= '0' && d <= '9') || (d >= 'a' && d <= 'f') || (d >= 'A' && d <= 'F'))) 40 | { 41 | return -1; 42 | } 43 | buf[i] = ((uint8_t)(c >= '0' && c <= '9' ? c - '0' : (c >= 'a' && c <= 'f' ? c - 'a' : c - 'A') + 10) << 4) | 44 | (uint8_t)(d >= '0' && d <= '9' ? d - '0' : (d >= 'a' && d <= 'f' ? d - 'a' : d - 'A') + 10); 45 | } 46 | return 0; 47 | } 48 | 49 | void hexprint(uint8_t *data, size_t sz) 50 | { 51 | char buf[0x61]; 52 | for(size_t i = 0; i < sz; i += 0x30) 53 | { 54 | size_t max = sz - i > 0x30 ? 0x30 : sz - i; 55 | for(size_t j = 0; j < max; ++j) 56 | { 57 | uint8_t u = data[i+j], 58 | hi = (u >> 4) & 0xf, 59 | lo = u & 0xf; 60 | buf[2*j] = hi < 10 ? '0' + hi : 'a' + (hi - 10); 61 | buf[2*j+1] = lo < 10 ? '0' + lo : 'a' + (lo - 10); 62 | } 63 | buf[2*max] = '\0'; 64 | iprintf("%s", buf); 65 | } 66 | iprintf("\n"); 67 | } 68 | -------------------------------------------------------------------------------- /src/shell/linux.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pongoOS - https://checkra.in 3 | * 4 | * Copyright (C) 2019-2020 checkra1n team 5 | * 6 | * This file is part of pongoOS. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | */ 27 | #include 28 | uint32_t autoboot_count; 29 | #define BOOT_FLAG_DEFAULT 0 30 | #define BOOT_FLAG_HARD 1 31 | #define BOOT_FLAG_HOOK 2 32 | #define BOOT_FLAG_LINUX 3 33 | #define BOOT_FLAG_RAW 4 34 | 35 | extern volatile char gBootFlag; 36 | 37 | /* 38 | 39 | Name: fdt_cmd 40 | Description: command handler for fdt 41 | 42 | */ 43 | extern void * fdt; 44 | extern bool fdt_initialized; 45 | #define LINUX_DTREE_SIZE 65536 46 | 47 | void fdt_cmd() { 48 | if (!loader_xfer_recv_count) { 49 | iprintf("please upload a fdt before issuing this command\n"); 50 | return; 51 | } 52 | if (fdt_initialized) free(fdt); 53 | fdt = malloc(LINUX_DTREE_SIZE); 54 | if (!fdt) panic("couldn't reserve heap for fdt"); 55 | memcpy(fdt, loader_xfer_recv_data, loader_xfer_recv_count); 56 | fdt_initialized = 1; 57 | loader_xfer_recv_count = 0; 58 | } 59 | 60 | /* 61 | 62 | Name: pongo_boot_linux 63 | Description: command handler for bootl 64 | 65 | */ 66 | 67 | void pongo_boot_linux() { 68 | if (!linux_can_boot()) { 69 | printf("linux boot not prepared\n"); 70 | return; 71 | } 72 | gBootFlag = BOOT_FLAG_LINUX; 73 | task_yield(); 74 | } 75 | 76 | void linux_commands_register() { 77 | command_register("bootl", "boots linux", pongo_boot_linux); 78 | command_register("fdt", "load linux fdt from usb", fdt_cmd); 79 | } 80 | -------------------------------------------------------------------------------- /src/sym_order.txt: -------------------------------------------------------------------------------- 1 | start 2 | --------------------------------------------------------------------------------