Apple's open-source XNU kernel on Android phones: its own loader and drivers, Metal on the Adreno. Runs from RAM; a reboot gives the phone back to Android.
C
docs: legal and compliance -- LEGAL.md (independent of Apple; what is and is not distributed; not legal advice), COMPLIANCE.md (how APSL 2.0 is met, items still to verify), THIRD_PARTY_LICENSES.md (every third-party component with origin, license, status), NOTICE/CONTRIBUTING/README cross-reference them and flag the UEFI and FocalTech blobs as to-verify
shimoku74a59220e1e9b2
diff --git a/.gitignore b/.gitignoreindex 9fbf0ed..82c16e9 100644--- a/.gitignore+++ b/.gitignore@@ -12,6 +12,9 @@!/LICENSE!/LICENSE.APSL!/NOTICE+!/LEGAL.md+!/COMPLIANCE.md+!/THIRD_PARTY_LICENSES.md!/devices/!/docs/!/xldiff --git a/COMPLIANCE.md b/COMPLIANCE.mdnew file mode 100644index 0000000..49b9841--- /dev/null+++ b/COMPLIANCE.md@@ -0,0 +1,60 @@+# License compliance++How HakiOS meets the terms of the licenses that apply to it. This is a working checklist, not a+legal opinion, and it does not assert that the project is free of all risk. See `LEGAL.md` and+`THIRD_PARTY_LICENSES.md`.++## Apple Public Source License 2.0 (the kernel)++`xnu/hakios.patch` and everything under `xnu/files/` are modifications of Apple's XNU, which Apple+publishes under the APSL 2.0. The full text is in `LICENSE.APSL`. The obligations we track:++- **Source availability (APSL 2.3).** Our modifications are published here as source. The exact+ Apple base they apply to is the tag `xnu-8796.121.2` at+ `github.com/apple-oss-distributions/xnu`, fetched by `xnu/apply.sh`. CI checks that the patch+ still applies to that tag.+- **Retention of notices (APSL 2.1).** Apple's original copyright and license notices are kept in+ the files they belong to. Our added files carry their own notices and do not remove Apple's.+- **Marking modifications (APSL 2.2).** Changes are described in the patch and in the commit+ history; the project's own files are named `hakios.<thing>.c` so that what is ours is+ distinguishable from Apple's original code.+- **Executable distribution (APSL 2.3(c)).** Where a built kernel is distributed (`prebuilt/`),+ the corresponding source is in the same repository, and this file points at it.+- **No re-licensing.** The XNU-derived code stays under the APSL; it is **not** relabeled MIT. The+ MIT License in `LICENSE` applies only to our own non-XNU code.++What is NOT covered and must not be assumed covered by the APSL: iOS user space, Apple firmware,+trademarks, and any Apple binary. None of those are in this repository.++## MIT (our own code)++The loader, user-space sources, tools, scripts, docs and the device layer are under the MIT+License (`LICENSE`). Contributions are accepted under the same terms (`CONTRIBUTING.md`).++## Third-party components++Each third-party component is listed in `THIRD_PARTY_LICENSES.md` with its origin, license, and+whether it is redistributed in the tree or fetched at build time. Components fetched at build time+(the iOS SDK, Mesa, Procursus/Sileo, lzfse, ath11k, LinuxKPI headers) are never committed; they+are obtained from their own upstreams under their own licenses.++## Items still to verify++These are flagged for review and are **not** asserted to be settled:++- **UEFI driver binaries** under `devices/poco-x5-pro/uefi/files/Binaries/` are the phone+ vendor's (Qualcomm/Xiaomi), extracted from the device's own `xbl.img`. They are needed only to+ rebuild the UEFI image and can be removed and re-extracted by each user from their own phone+ with UEFIReader. Whether redistributing them is permitted has not been confirmed with the+ vendor; a user who is unsure should delete them and extract their own. Tracked in+ `THIRD_PARTY_LICENSES.md`.+- **The FocalTech touch-controller firmware header** (`xnu/files/bsd/dev/hakios.focaltech_fw.h`)+ is generated from a firmware blob on the device. Its redistribution terms are the touch+ vendor's and have not been confirmed; it is a candidate for moving to the pull-from-device+ model the rest of the firmware already uses.+- **Mu-Silicium / Project Mu** derived files under `devices/poco-x5-pro/uefi/` carry upstream+ BSD-2-Clause-Patent and GPL-2.0-or-MIT headers; the derived parts keep those licenses.++If any of these cannot be confirmed as redistributable, the fallback is the same as for all+device firmware: remove the file from the tree and have each user obtain it from their own+hardware.diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 71c4d51..87ca5b1 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -16,6 +16,25 @@- Licenses: the kernel patch and files are APSL 2.0 (derived from XNU); everything else is MIT.Third-party code goes into `NOTICE`.+## Legal and licensing++- HakiOS is an independent research project and is not affiliated with Apple. See `LEGAL.md`.+- The kernel patch and files are APSL 2.0 (derived from XNU); everything else is MIT. Do not+ relabel XNU-derived code as MIT. New third-party code goes into `NOTICE` and+ `THIRD_PARTY_LICENSES.md` with its origin and license.+- Nothing of Apple's in the tree: no iOS files, images, caches, screenshots or headers derived+ from the firmware. Nothing of the vendor's firmware either. If you add a file whose origin or+ license you are not certain of, mark it "to verify" in `THIRD_PARTY_LICENSES.md` rather than+ asserting it is cleared.+- You can build and test the whole open path with nothing of Apple's:++ ```sh+ make qemu-open # kernel + placeholder loader + the hello RAM disk, under QEMU+ ```++ The full iOS user space (`make qemu`, `make phone`) additionally needs software and firmware you+ supply yourself.+## CI`ci/github-check.yml` is a GitHub Actions workflow (Python compiles, scripts parse, no Applediff --git a/LEGAL.md b/LEGAL.mdnew file mode 100644index 0000000..f7cc8a6--- /dev/null+++ b/LEGAL.md@@ -0,0 +1,54 @@+# Legal++HakiOS is an independent open-source research project that ports the open-source XNU kernel to+ARM64 Qualcomm hardware. It is **not affiliated with, endorsed by, or connected to Apple Inc.**+"iOS", "iPhone", "XNU", "Apple" and other marks belong to their owners and are used here only to+describe what the code works with.++This file explains, in plain terms, what is and is not distributed by this repository. It is a+description of the project's intent and current state, **not legal advice**, and it does **not**+claim that any use of the project is lawful in your jurisdiction. Running the full system image+requires software and firmware you must obtain and are licensed to use yourself; whether you may+do so is your responsibility. If in doubt, consult a lawyer.++## What this repository contains++- **The kernel changes**: a patch to Apple's open-source XNU (`xnu/hakios.patch`) and added+ source files (`xnu/files/`). These are a derivative work of XNU and are licensed under the+ Apple Public Source License 2.0 (`LICENSE.APSL`). See `COMPLIANCE.md` for how the APSL terms+ are met.+- **Our own original code**: the boot loader (`xnuloader/`), user-space programs+ (`userland/src/`), the tools (`tools/`), the build and run scripts, the documentation, and the+ device layer under `devices/`. These are licensed under the MIT License (`LICENSE`).+- **Third-party open-source components** that are redistributed or fetched at build time, each+ under its own license. They are listed with origin and license in `THIRD_PARTY_LICENSES.md`.+- **Pre-built artifacts** in `prebuilt/`: the kernel, user-space programs and libraries built+ from this repository's own source. They carry the same licenses as the source they are built+ from.++## What this repository does NOT contain and never distributes++- **No part of iOS**: no iOS binary, image, cache, font, picture or screenshot. The user-space+ half of the system image is built on your machine from the iOS 16.5 IPSW, which+ `sysimage/fetch.sh` downloads from Apple's public servers under Apple's license, to your+ machine only. Nothing of it is committed here.+- **No device firmware**: the GPU, Wi-Fi, audio DSP, modem, haptics and camera firmware is the+ vendor's (Qualcomm/Xiaomi). It is pulled from your own phone (`make firmware`) and is git-ignored.+- **No keys, certificates, activation data, or anything to impersonate a genuine Apple device to+ Apple's services.** Signing in to an Apple account is not possible here and is not a goal.++## The Apple-free configuration++The core kernel, the boot loader and the open tools build and run with **nothing of Apple's**:++ make qemu-open++builds the kernel and a placeholder loader (no IPSW needed, see `xnuloader/mkidentity.sh+--placeholder`) and boots a small raw-syscall user space (`userland/src/hello.c`) under QEMU.+This is the configuration a contributor can build and test without downloading any closed Apple+software. The full iOS user space is an optional target that depends on software you supply.++## Reporting++If you believe a file in this repository infringes anyone's rights, open an issue (or email the+maintainer listed in the repository) and it will be reviewed and, where warranted, removed.diff --git a/NOTICE b/NOTICEindex c2eef7a..cd3483f 100644--- a/NOTICE+++ b/NOTICE@@ -1,4 +1,5 @@Third-party components in or used by HakiOS+(full table with origins and status: THIRD_PARTY_LICENSES.md; compliance notes: COMPLIANCE.md)In the repository:@@ -13,6 +14,9 @@ In the repository:such drivers for other phones. They are needed only to rebuild the UEFI image; they can be removed andextracted by each user from their own phone's firmware with UEFIReader.+- the FocalTech touch firmware, xnu/files/bsd/dev/hakios.focaltech_fw.h: the touch vendor's;+ generated from a device blob, redistribution terms "to verify" (THIRD_PARTY_LICENSES.md).+- the Wi-Fi driver: Linux's ath11k (BSD-3-Clause-Clear) and FreeBSD's LinuxKPI headers (BSD-2-Clause) arefetched by tools/mk-ath11k.sh at pinned releases and built on our layer wifi/lx (MIT); only the layer is here.diff --git a/README.md b/README.mdindex 54d8cc4..79ca60b 100644--- a/README.md+++ b/README.md@@ -152,6 +152,20 @@ clock and SMMU context, and the handshake with the modem goes through. The SIM isubscription and NAS reads the signal. The current state and the whole story are in`docs/cellular.md`.+## Independent, and Apple-free at the core++HakiOS is an independent research project. It is **not affiliated with or endorsed by Apple**;+"iOS", "iPhone", "XNU" and "Apple" are named only to describe what the code works with. The core+kernel, the boot loader and the open tools build and run with nothing of Apple's:++```sh+make qemu-open # the open kernel + a placeholder loader + a tiny raw-syscall user space, in QEMU+```++No IPSW, no iOS user space, no firmware. Booting the stock iOS user space (`make qemu`,+`make phone`) is an optional path that needs the IPSW and the phone's firmware, which you supply+from your own device.+## Licenses and the legal sideMy code is under the license of the files it changes: the XNU patch under the Apple Public Source@@ -161,3 +175,8 @@ phone's firmware belong to their owners, are not in this repository and are noteveryone takes them from their own phone and their own IPSW. "iOS", "iPhone" and "Apple" arenamed only to describe what the code works with. If you believe a file here infringes anyone'srights, open an issue and I will remove it.++The detail is in separate files: `LEGAL.md` (what is and is not distributed, and the limits of+these statements), `COMPLIANCE.md` (how the APSL 2.0 and other terms are met, and the items still+to verify), `THIRD_PARTY_LICENSES.md` (every third-party component with origin and license), and+`NOTICE` (the short canonical list). None of this is legal advice.diff --git a/THIRD_PARTY_LICENSES.md b/THIRD_PARTY_LICENSES.mdnew file mode 100644index 0000000..4fc9a0d--- /dev/null+++ b/THIRD_PARTY_LICENSES.md@@ -0,0 +1,46 @@+# Third-party licenses++Every third-party component HakiOS redistributes or fetches at build time, with its origin,+license, and status. Where "origin uncertain" or "to verify" is written, the item is **not**+asserted to be cleared for redistribution; treat it as pending review (see `COMPLIANCE.md`).++This supersedes the summary in `NOTICE`, which stays as the short, canonical list.++## Redistributed in this repository++| Component | Path | Origin | License | Notes |+|---|---|---|---|---|+| XNU modifications | `xnu/hakios.patch`, `xnu/files/` | derivative of Apple XNU | APSL 2.0 (`LICENSE.APSL`) | base tag `xnu-8796.121.2`, fetched by `xnu/apply.sh` |+| libdeflate | `xnu/files/bsd/miscfs/apfs/libdeflate/` | Eric Biggers | MIT | see its `COPYING` |+| libzbitmap | `xnu/files/bsd/miscfs/apfs/libzbitmap/`, `xnu-deps/build/lzbitmap/` | Corellium LLC (port of eafer/libzbitmap) | GPL-2.0+ OR MIT | used under MIT |+| LinuxKPI / Linux headers | `wifi/lx/include/linux/`, `wifi/lx/include/net/` | Linux / FreeBSD LinuxKPI | GPL-2.0 (Linux) / BSD-2-Clause (FreeBSD) | small compatibility headers; see each file's notice |+| Linux DRM shim | `tools/mesa/hakios-drm/`, `xf86drm.h` | Linux / X.Org | MIT | build-time shim for Mesa |+| AIR / Metal-library tooling | `tools/mesa/air/` | HakiOS (Darwin on redwood contributors) | MIT | our own; LLVM bitcode layout is a published format |+| mkbootimg.py | `devices/poco-x5-pro/prebuilt/mkbootimg.py` | Android Open Source Project | Apache-2.0 | |+| Mu-Silicium / Project Mu derived files | `devices/poco-x5-pro/uefi/` | Project Silicium, Microsoft, contributors | BSD-2-Clause-Patent; some GPL-2.0+ OR MIT | derived parts keep upstream license |+| Qualcomm/Xiaomi UEFI driver binaries | `devices/poco-x5-pro/uefi/files/Binaries/` | Qualcomm / Xiaomi (from device `xbl.img`) | vendor's — **to verify** | needed only to rebuild UEFI; removable, re-extract with UEFIReader |+| FocalTech touch firmware header | `xnu/files/bsd/dev/hakios.focaltech_fw.h` | FocalTech (device firmware blob) | vendor's — **to verify** | candidate to move to pull-from-device |+| Apple host headers (build only) | `xnu-deps/hostinc/mach-o/`, `.../mach/` | Apple (open-source cctools/xnu headers) | APSL 2.0 | host-side Mach-O headers for the cross build |+| Pre-built kernel & user space | `prebuilt/` | built from this repo | APSL 2.0 / MIT (as source) | reproducible from source here |++## Fetched at build time, never committed++| Component | Fetched by | Origin | License |+|---|---|---|---|+| iOS 16.5 IPSW (user space of the system image) | `sysimage/fetch.sh` | Apple | Apple's — user supplies, user's own copy |+| iPhoneOS 16.5 SDK | `xnu-deps/setup.sh` (github.com/theos/sdks) | Apple (headers) via theos | Apple's / theos |+| Apple open sources (AvailabilityVersions, libdispatch, libpthread, cctools, bootstrap_cmds) | `xnu-deps/setup.sh` | Apple | APSL 2.0 |+| MacOSX13.3 SDK (Kernel.framework DriverKit headers only) | `xnu-deps/setup.sh` | Apple via joseluisq/macosx-sdks | Apple's |+| lzfse | `xnuloader/mkidentity.sh` (when no decoder present) | Apple, github.com/lzfse/lzfse | BSD-3-Clause |+| ath11k (Wi-Fi driver) | `tools/mk-ath11k.sh` | Linux | BSD-3-Clause-Clear |+| Mesa (GL=1 images) | `tools/mk-mesa.sh` | Mesa project | MIT and others |+| Procursus / Sileo packages | `tools/mk-jb.sh` | Procursus team | their own licenses |+| Phone firmware (GPU, Wi-Fi, DSP, modem, haptics, cameras) | `devices/poco-x5-pro/pull-firmware.sh` | Qualcomm / Xiaomi | vendor's — user's own device |++## How to rebuild the inventory++- Tracked non-text/binary files: `git ls-files -z | xargs -0 file --mime-type | grep -v text/`+- License mentions in tracked files: `git grep -li "SPDX-License-Identifier\|GPL\|BSD\|MIT\|APSL\|copyright"`++If a component's origin is uncertain, it is marked **to verify** above and must be treated as not+yet cleared for redistribution until confirmed with its owner.