Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/2026-12-01-runtime-loader-gpl2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Runtime loader and upload controller: their C sources (`sdk/runtime/loader`, `sdk/runtime/upload`) are now GPL-2.0-or-later, with their authors' agreement, so a base whose release set may hold GPL-2.0-only modules (the Analog Rytm MKII's) can carry the loader. Two small loader checks (an engine's price per voice, the machine's look at a rebuilt DSP image) were rewritten; they accept and refuse the same packages. The Octatrack base is built from these files, so it is rebuilt with base 0.8.6.
2 changes: 1 addition & 1 deletion sdk/runtime/loader/context.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: GPL-3.0-or-later */
/* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef MODWERK_RUNTIME_CONTEXT_H
#define MODWERK_RUNTIME_CONTEXT_H
/* ColdFire backend-entry wrappers capture before a C prologue can reuse a
Expand Down
2 changes: 1 addition & 1 deletion sdk/runtime/loader/journal.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
/* SPDX-License-Identifier: GPL-2.0-or-later
* Private engine-only volatile publication journal. No host-supplied image,
* generation, readiness, extent or ACK authority. Feature64 remains closed. */
#ifndef MODWERK_RUNTIME_JOURNAL_H
Expand Down
28 changes: 20 additions & 8 deletions sdk/runtime/loader/loader.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
/* SPDX-License-Identifier: GPL-2.0-or-later
* Machine-neutral runtime module loader (README.md). Several modules are
* live at once, each at its own dispatch position with its own pool extent.
* Prepare admits a package (memory, a position, and sites no other live
Expand Down Expand Up @@ -120,10 +120,20 @@ __attribute__((weak)) int modwerk_machine_metadata_admit(const struct runtime_ds
#endif

#ifndef MODWERK_RUNTIME_IMAGE_EXTERNAL
__attribute__((weak)) int modwerk_machine_image_validate(const struct runtime_dsp *d)
{ (void)d;return RUNTIME_OK; }
/* A machine without its own check takes every rebuilt image. */
__attribute__((weak)) int modwerk_machine_image_validate(const struct runtime_dsp *dsp)
{
(void)dsp;
return RUNTIME_OK;
}
#endif

/* An engine's price per voice: a nonzero cycle count, measured by running it or on the hardware. */
static int engine_priced(const struct runtime_dsp *dsp)
{
return dsp->cycles != 0u && (dsp->kind == RUNTIME_EXECUTED || dsp->kind == RUNTIME_HARDWARE);
}

const struct runtime_module *modwerk_runtime_module(unsigned i) { return i < RUNTIME_MODULES ? live[i] : 0; }
/* The engine task is the only writer. Add the new bits before publishing the module and clear its absent
* hooks afterwards. A reader can interrupt anywhere: an extra bit just makes it look at the live slot. */
Expand Down Expand Up @@ -1136,8 +1146,7 @@ static int __attribute__((used)) prepare_context(void *u, const uint8_t *data, u
if (dsp.count > RUNTIME_DSP_WORDS || dsp.relocation_count > RUNTIME_DSP_RELOCATIONS ||
left != 4u * dsp.count + 2u * dsp.relocation_count + 4u * init_words || (!dsp.count && dsp.relocation_count) ||
(dsp.count && !engine && (dsp.init >= dsp.count || dsp.proc >= dsp.count || !dsp.slots || dsp.slots > 3u)) ||
(engine && (dsp.init || dsp.proc || !dsp.cycles || (dsp.kind != RUNTIME_EXECUTED && dsp.kind != RUNTIME_HARDWARE) ||
dsp.state || dsp.buffer || dsp.id || !entries)))
(engine && (dsp.init || dsp.proc || !engine_priced(&dsp) || dsp.state || dsp.buffer || dsp.id || !entries)))
return refuse(RUNTIME_MALFORMED);
for (uint32_t i = 0; i < dsp.count; ++i) if (be32(words + 4u * i) > 0xffffffu) return refuse(RUNTIME_MALFORMED);
for (uint32_t i = 0; i < init_words; ++i) if (be32(init + 4u * i) > 0xffffffu) return refuse(RUNTIME_MALFORMED);
Expand Down Expand Up @@ -1222,11 +1231,14 @@ static int __attribute__((used)) prepare_context(void *u, const uint8_t *data, u
p += site_bytes(abi, n, r);
}
dsp.image = to;
if (be16(data + 6) & 1u) dsp.page = to, dsp.page_bytes = image; /* a page recipe heads the image */
admission_lock = modwerk_machine_lock();
if (be16(data + 6) & 1u) { /* the image starts with a page recipe */
dsp.page = to;
dsp.page_bytes = image;
}
admission_lock = modwerk_machine_lock(); /* the machine looks at the rebuilt image before anyone can use it */
why = modwerk_machine_image_validate(&dsp);
modwerk_machine_unlock(admission_lock);
if (why) return refuse((enum runtime_refusal)why);
if (why != RUNTIME_OK) return refuse((enum runtime_refusal)why);
#if CACHED_MODULES /* instruction fetches read memory, not the data cache: the extent's lines reach memory first */
modwerk_machine_flush_data((uint32_t)(uintptr_t)m, head + code + tail);
#endif
Expand Down
14 changes: 8 additions & 6 deletions sdk/runtime/loader/loader.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
/* SPDX-License-Identifier: GPL-2.0-or-later
* Machine-neutral runtime module loader: the upload controller's backend
* (README.md). A machine adds the glue declared at the end and trampolines
* from its hook bus that call the active module's hooks. */
Expand Down Expand Up @@ -100,8 +100,9 @@ struct runtime_dsp {
const struct runtime_dsp_claim *claims;
/* ABI 10: an engine instead of an effect (the package's slots 0): DSP words for the base's hook sites, at base 0,
* each relocation an index (| 0x8000: the word holds a fixed P address, value - base; else an offset, value +
* base); count 0 here, so nothing takes it for an effect. Kept in its pool extent, as the claims are. Its `cycles`
* and `kind` are its price per voice (never 0, executed or hardware), outside the controller digest. */
* base); count 0 here, so nothing takes it for an effect. Kept in its pool extent, as the claims are. An engine
* prices each voice in `cycles` (more than 0) and says how in `kind` (executed or hardware); the controller digest
* leaves both out. */
uint32_t engine_count, init_count; /* init_count: every init claim's words, in claim order (`initial`) */
uint16_t engine_relocation_count;
uint8_t entry_count, pad;
Expand Down Expand Up @@ -266,9 +267,10 @@ enum runtime_metadata_operation { RUNTIME_METADATA_PREPARE=1, RUNTIME_METADATA_S
* declaration and current/paused consumer checks. */
int modwerk_machine_metadata_admit(const struct runtime_dsp *from, struct runtime_dsp *to,
const struct runtime_context *,enum runtime_metadata_operation);
/* Read-only format check of the reconstructed image, after relocations/copies/fills and before it receives an
* owner identity or can be published. Locked; no roots, retirement, DSP commands or admission side effects.
* image/page name reconstructed bytes; other arrays are still temporary. Default accepts. A runtime_refusal. */
/* The machine's look at a module's DSP image once the loader has rebuilt it (relocated, copied, filled), before
* the image has an owner or is published. Called under the machine lock; it only reads: it starts no DSP command,
* takes no root and admits or retires nothing. `image` and `page` point at the rebuilt bytes; the other arrays are
* scratch at this point. Returns RUNTIME_OK, or the runtime_refusal to give; without a machine's own, it accepts. */
int modwerk_machine_image_validate(const struct runtime_dsp *);
int modwerk_machine_dsp_admit(const struct runtime_dsp *from, struct runtime_dsp *to); /* may set to->id */
/* 1 while a restore switches (an Undo, or the rollback after a failed self-test): it puts a position back as it was
Expand Down
2 changes: 1 addition & 1 deletion sdk/runtime/loader/modwerk_module.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
/* SPDX-License-Identifier: GPL-2.0-or-later
* What a runtime module sees (ABI 2, README.md): build it with build.py.
* Define any of these handlers. They are the events every Elekloader core's
* hook bus has, with its conventions (Elekloader docs/ADAPTING.md), and run
Expand Down
2 changes: 1 addition & 1 deletion sdk/runtime/loader/set_package.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
/* SPDX-License-Identifier: GPL-2.0-or-later
* MWMS v1: one stopped module-set transaction, over the production lifecycle.
* Header: magic, version u16, count u16, total u32, reserved-zero u32,
* exact base SHA-256, baseline MWS1 SHA-256. Then length u32 and an MWRM
Expand Down
3 changes: 2 additions & 1 deletion sdk/runtime/upload/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ Native compilation uses GNU `m68k-elf` for MCF54455, strict warnings, no libc
assumptions and no unresolved symbols. Compiler stack reports are recorded
privately; they are not chip timing or complete call/interrupt-stack bounds.
Objects contain only authored code and standard SHA constants. No stock,
firmware or device is read by either command. Authored code is GPL-3.0-or-later.
firmware or device is read by either command. The C sources here are GPL-2.0-or-later (1 December 2026), so a
release base carries them beside GPL-2.0-only modules; the rest of the authored code is GPL-3.0-or-later.

## Remaining integration

Expand Down
2 changes: 1 addition & 1 deletion sdk/runtime/upload/sha256.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
/* SPDX-License-Identifier: GPL-2.0-or-later
* Original freestanding SHA-256 implementation. All input lengths are bounded
* by the upload controller; no heap or firmware-derived data. */
#include "upload.h"
Expand Down
2 changes: 1 addition & 1 deletion sdk/runtime/upload/upload.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
/* SPDX-License-Identifier: GPL-2.0-or-later
* No OS calls, malloc, filesystem, raw destination addresses or flash writes.
* Preparation/publishing is deliberately impossible without a complete adapter. */
#include "upload.h"
Expand Down
2 changes: 1 addition & 1 deletion sdk/runtime/upload/upload.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: GPL-3.0-or-later */
/* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef MODWERK_UPLOAD_H
#define MODWERK_UPLOAD_H
#include <stdint.h>
Expand Down
2 changes: 1 addition & 1 deletion sdk/runtime/upload/vendor.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: GPL-3.0-or-later */
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include "vendor.h"

enum { IDLE, RECEIVING, QUEUED, READY, REFUSED };
Expand Down
2 changes: 1 addition & 1 deletion sdk/runtime/upload/vendor.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: GPL-3.0-or-later */
/* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef MODWERK_UPLOAD_VENDOR_H
#define MODWERK_UPLOAD_VENDOR_H
#include "wire.h"
Expand Down
2 changes: 1 addition & 1 deletion sdk/runtime/upload/wire.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: GPL-3.0-or-later */
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include "wire.h"
static uint32_t read32(const uint8_t *p)
{
Expand Down
2 changes: 1 addition & 1 deletion sdk/runtime/upload/wire.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: GPL-3.0-or-later */
/* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef MODWERK_UPLOAD_WIRE_H
#define MODWERK_UPLOAD_WIRE_H
#include "upload.h"
Expand Down