Commit graph

11 commits

Author SHA1 Message Date
Hector Martin
eb49df38bd rust: Initial Rust-based EFI FAT32 chainloader
This code is gated behind the CHAINLOADING define. To build a
release-style m1n1 with chainloading for use with the installer
or kmutil, use:

make CHAINLOADING=1 RELEASE=1

To tell m1n1 to chainload another binary, use this var payload:

chainload=<ESP partition UUID>;<file path>

e.g.

chainload=a17b7e46-e950-bb4f-bc82-8ab1047a058e;m1n1/m1n1.bin

Closes: #154
Co-authored-by: Finn Behrens <me@kloenk.dev>
Co-authored-by: Joey Gouly <joey.gouly@arm.com>
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-09 21:50:40 +09:00
Hector Martin
84acf60c24 Fix warnings when building/linking with clang/llvm
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-11-08 13:53:04 +09:00
Hector Martin
e08457aaa9 Makefile, m1n1.ld: Build with debug info
This allows addr2line to work. The Mach-O output should be unchanged.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-21 17:13:03 +09:00
Hector Martin
dc2b7b3bb4 startup: clear bss section
iBoot does this for us, but this is for the benefit of chainload.py and
other dump loaders that may not.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 03:03:03 +09:00
Hector Martin
986c6730e9 Add heapblock and dlmalloc for managing memory
heapblock is a simple `sbrk` style implementation, also useful as an
"endless" decompression buffer. dlmalloc is used on top as a malloc
implementation.

This also changes how the Python side manages its heap. We still use a
python-side malloc implementation (since this is faster), and we put the
Python heap at the m1n1 heap + 128MB, without allocating it.
Hopefully this should never step on anything m1n1 neads, and avoids
having to manage freeing across Python script calls.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-29 16:25:15 +09:00
Hector Martin
35e24d58d9 linkerscript: add a dummy payload section starting at EOF
So it turns out iBoot is happy to load mach-o files with a section hanging
"off the end" of the file (it does not over-read, it just ignores the
excess). We can use this to our advantage to support appending payloads
to m1n1 with a simple `cat`.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-28 16:06:12 +09:00
Ferdinand Bachmann
505eb4ce4f m1n1.ld: clang compat, define _base symbol inside SECTIONS for relative symbol resolution
Signed-off-by: Ferdinand Bachmann <theferdi265@gmail.com>
2021-01-23 22:09:22 +09:00
Ferdinand Bachmann
d48fa181c4 clang support: fix LLD warning about implicitly added sections by adding them explicitly
Signed-off-by: Ferdinand Bachmann <theferdi265@gmail.com>
2021-01-23 22:09:22 +09:00
Hector Martin
81aaf2ed35 Basic exceptions, irq, cache mgmt support
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-17 00:49:22 +09:00
Hector Martin
ec8bb045f2 Reduce alignment to 16k, size optimization
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-15 04:04:12 +09:00
Hector Martin
8af9f1eb95 Initial commit
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-15 04:03:35 +09:00