476c31e973
Make the ringbuffer class robust to various block sizes to generalize to both DCP and AOP. The first three blocks of the ringbuffer is reserved for exchanging size, rptr, wptr: ``` bufsize unk 00000000 00007e80 00070006 00000000 00000000 00000000 00000000 00000000 00000000 00000020 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000040 * rptr 00000080 00000600 00000000 00000000 00000000 00000000 00000000 00000000 00000000 000000a0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 000000c0 * wptr 00000100 00000680 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000120 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000140 * ``` Each block is spread out by some block_size multiple of 0x40 (step). The 0th block holds the size of the ringbuffer contents, the 1st block holds the rptr, and the 2nd block holds the wptr. The actual contents of the ringbuffer starts after the first three blocks, which will be collectively called the "header". However, this block_size isn't constant. DCP seems to consistently use 0x40, but AOP can use both 0x40/0x80. Since we're not given the block_size, so wemust bootstrap it. Recall we are given the total size of the rinbuffer in the mailbox message. Since we're always given the size of the ringbuffer `bufsize` at offset +block_size * 0 (or simply 0), and we can find the header size by subtracting `bufsize` from the total size. Since we also know that the header is always 3 blocks wide, we can divide the header size by 3 to obtain the block_size. Signed-off-by: Eileen Yoon <eyn@gmx.com> |
||
---|---|---|
.github/workflows | ||
3rdparty_licenses | ||
artwork@35626c31f5 | ||
data | ||
font | ||
proxyclient | ||
rust | ||
src | ||
sysinc | ||
tools | ||
udev | ||
.clang-format | ||
.editorconfig | ||
.gitignore | ||
.gitmodules | ||
config.h | ||
docker-compose.yml | ||
Dockerfile | ||
LICENSE | ||
m1n1-raw.ld | ||
m1n1.ld | ||
Makefile | ||
README.md | ||
version.sh |
m1n1: an experimentation playground for Apple Silicon
(And to some extent a Linux bootloader)
Building
You need an aarch64-linux-gnu-gcc
cross-compiler toolchain (or a native one, if running on ARM64).
$ git clone --recursive https://github.com/AsahiLinux/m1n1.git
$ cd m1n1
$ make
The output will be in build/m1n1.macho.
To build on a native arm64 machine, use make ARCH=
.
To build verbosely, use make V=1
.
Building on ARM64 macOS is supported with clang and LLVM; you need to use Homebrew to install the required dependencies:
$ brew install llvm
After that, just type make
.
Building using the container setup
If you have a container runtime installed, like Podman or Docker, you can make use of the compose setup, which contains all build dependencies.
$ git clone --recursive https://github.com/AsahiLinux/m1n1.git
$ cd m1n1
$ podman-compose run m1n1 make
$ # or
$ docker-compose run m1n1 make
Usage
Our wiki has more information on how to use m1n1.
To install on an OS container based on macOS <12.1, use m1n1.macho
:
kmutil configure-boot -c m1n1.macho -v <path to your OS volume>
To install on an OS container based on macOS >=12.1, use m1n1.bin
:
kmutil configure-boot -c m1n1.bin --raw --entry-point 2048 --lowest-virtual-address 0 -v <path to your OS volume>
Payloads
m1n1 supports running payloads by simple concatenation:
$ cat build/m1n1.macho Image.gz build/dtb/apple-j274.dtb initramfs.cpio.gz > m1n1-payload.macho
$ cat build/m1n1.bin Image.gz build/dtb/apple-j274.dtb initramfs.cpio.gz > m1n1-payload.bin
Supported payload file formats:
- Kernel images (or compatible). Must be compressed or last payload.
- Devicetree blobs (FDT). May be uncompressed or compressed.
- Initramfs cpio images. Must be compressed.
Supported compression formats:
- gzip
- xz
License
m1n1 is licensed under the MIT license, as included in the LICENSE file.
- Copyright The Asahi Linux Contributors
Please see the Git history for authorship information.
Portions of m1n1 are based on mini:
- Copyright (C) 2008-2010 Hector Martin "marcan" marcan@marcan.st
- Copyright (C) 2008-2010 Sven Peter sven@svenpeter.dev
- Copyright (C) 2008-2010 Andre Heider a.heider@gmail.com
m1n1 embeds libfdt, which is dual BSD and GPL-2 licensed and copyright:
- Copyright (C) 2014 David Gibson david@gibson.dropbear.id.au
- Copyright (C) 2018 embedded brains GmbH
- Copyright (C) 2006-2012 David Gibson, IBM Corporation.
- Copyright (C) 2012 David Gibson, IBM Corporation.
- Copyright 2012 Kim Phillips, Freescale Semiconductor.
- Copyright (C) 2016 Free Electrons
- Copyright (C) 2016 NextThing Co.
The ADT code in mini is also based on libfdt and subject to the same license.
m1n1 embeds minlzma, which is MIT licensed and copyright:
- Copyright (c) 2020 Alex Ionescu
m1n1 embeds a slightly modified version of tinf, which is ZLIB licensed and copyright:
- Copyright (c) 2003-2019 Joergen Ibsen
m1n1 embeds portions taken from arm-trusted-firmware, which is BSD licensed and copyright:
- Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved.
m1n1 embeds Doug Lea's malloc (dlmalloc), which is in the public domain (CC0).
m1n1 embeds portions of PDCLib, which is in the public domain (CC0).
m1n1 embeds the Source Code Pro font, which is licensed under the OFL-1.1 license and copyright:
- Copyright 2010-2019 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries.
- This Font Software is licensed under the SIL Open Font License, Version 1.1.
m1n1 embeds portions of the dwc3 usb linux driver, which was BSD-or-GPLv2 dual-licensed and copyright
- Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
m1n1 embeds portions of musl-libc's floating point library, which are MIT licensed and copyright
- Copyright (c) 2017-2018, Arm Limited.
m1n1 embeds some rust crates. Licenses can be found in the vendor directory for every crate.