runtime/README.md

29 lines
1.5 KiB
Markdown
Raw Normal View History

2025-01-04 05:34:24 -05:00
# Reborn Runtime
This is a simple program allowing ARM32 code to easily call "native" code.
2024-06-08 05:28:22 -04:00
2025-01-04 05:34:24 -05:00
By running an ARM32 program inside this runtime, it gains the ability to call `raw_trampoline`. This function copies its arguments and passes them to the `trampoline` function inside `libmedia-layer-trampoline.so`.
2024-06-08 05:28:22 -04:00
2025-01-04 05:34:24 -05:00
The runtime also automatically uses QEMU on x86_64 systems.
2024-06-08 05:28:22 -04:00
2025-01-04 05:34:24 -05:00
## Terminology
- "Guest" code is the main ARM32 program.
- "Host" code is the native code located in `libmedia-layer-trampoline.so`.
2024-06-08 05:28:22 -04:00
2025-01-04 05:34:24 -05:00
## Example
There is a simple C example [here](./example). It sends a given string to the host, which returns the string's length multiplied by two.
2024-06-08 05:28:22 -04:00
2025-01-04 05:34:24 -05:00
## Early Returning
`raw_trampoline` supports returning before the host code has finished executing. This can be enabled by passing `true` to `allow_early_return`. However, this is only supported in certain circumstances, can cause race-conditions, and prevents the guest code from receiving the host's return value.
2024-06-08 05:28:22 -04:00
2025-01-04 05:34:24 -05:00
## Syscall Versus Pipe Trampolines
The runtime supports two methods of passing data between the guest and host.
- System Call
- Data is passed through a custom system-call added to QEMU.
- Only supported on x86_64.
- Pipes
- Data is passed through standard UNIX pipes.
- Supports early-returning.
- Can be forced using an environmental variable.
2024-06-08 05:28:22 -04:00
2025-01-04 05:34:24 -05:00
## Licensing
The runtime itself is licensed with [GPLv2](./LICENSE) to comply with QEMU's license. However, the `raw_trampoline` function and associated headers are licensed with the [Unlicense](lib/LICENSE) as they do not directly link to the runtime.