Initial commit: Geminux 0.1.0 (helio) for Planet Computers Gemini PDA (MT6797X)

This commit is contained in:
Luxferre committed 2026-11-22 10:49:59 +02:00
commit 034c1f61b1
816 files changed
+223435

No files matched your search

+119
View File
@@ -0,0 +1,119 @@
#!/usr/bin/env python3
"""Verify MT6797 CCCI UAPI header constants and 16-byte hardware framing logic."""
import os
import re
import shutil
import subprocess
import sys
import tempfile
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
HDR_PATH = os.path.join(BASE_DIR, "prebuilt", "kernel", "include", "linux", "mt6797_ccci.h")
PROTO_C = os.path.join(BASE_DIR, "src", "geminux-daemons", "geminux-ccci-proto.c")
DAEMON_INC = os.path.join(BASE_DIR, "src", "geminux-daemons")
KERNEL_INC = os.path.join(BASE_DIR, "prebuilt", "kernel", "include")
C_TEST = r"""
#include <assert.h>
#include <stdio.h>
#include "geminux-ccci-proto.h"
int main(void) {
assert(sizeof(struct mt6797_ccci_header) == 16);
geminux_ccci_sm_t sm;
geminux_ccci_sm_init(&sm);
assert(sm.state == MT6797_MD_STATE_GATED);
/* Little-endian wire encoding of HS1 on CONTROL_RX (channel 0) */
uint8_t hs1_wire[16] = {
0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00,
0x2a, 0x00, 0x00, 0x00,
};
struct mt6797_ccci_header rx, tx;
bool need_reply = false;
geminux_ccci_unpack_hdr(hs1_wire, &rx);
assert(rx.channel == MT6797_CCCI_CH_CONTROL_RX);
assert(rx.data1 == MT6797_CCCI_MSG_HS1);
assert(rx.reserved == 42U);
assert(geminux_ccci_handle_ctrl(&sm, &rx, &tx, &need_reply));
assert(need_reply);
assert(sm.state == MT6797_MD_STATE_HS1);
assert(tx.channel == MT6797_CCCI_CH_CONTROL_TX);
assert(tx.data1 == MT6797_CCCI_MSG_HS1);
assert(tx.reserved == 42U);
struct mt6797_ccci_header ready_rx;
geminux_ccci_pack_hdr(&ready_rx, 0, MT6797_CCCI_MSG_NORMAL_BOOT_READY,
MT6797_CCCI_CH_CONTROL_RX, 0);
assert(geminux_ccci_handle_ctrl(&sm, &ready_rx, &tx, &need_reply));
assert(!need_reply);
assert(sm.state == MT6797_MD_STATE_READY);
struct mt6797_ccci_header ex_rx;
geminux_ccci_pack_hdr(&ex_rx, 1, MT6797_CCCI_MSG_MD_EX,
MT6797_CCCI_CH_CONTROL_RX, 0);
assert(geminux_ccci_handle_ctrl(&sm, &ex_rx, &tx, &need_reply));
assert(sm.state == MT6797_MD_STATE_EXCEPTION);
return 0;
}
"""
def main():
with open(HDR_PATH, "r", encoding="utf-8") as handle:
hdr = handle.read()
expected = {
"MT6797_CCCI_CH_CONTROL_RX": r"\b0\b",
"MT6797_CCCI_CH_CONTROL_TX": r"\b1\b",
"MT6797_CCCI_CH_FS_RX": r"\b14\b",
"MT6797_CCCI_CH_FS_TX": r"\b15\b",
"MT6797_CCCI_CH_RPC_RX": r"\b32\b",
"MT6797_CCCI_CH_RPC_TX": r"\b33\b",
"MT6797_CCCI_CH_STATUS_RX": r"\b67\b",
"MT6797_CCCI_CH_STATUS_TX": r"\b68\b",
"MT6797_CCCI_MSG_HS1": r"0xFFFFFFFFU",
"MT6797_CCCI_MSG_NORMAL_BOOT_READY": r"0xB0000002U",
}
for macro, pat in expected.items():
if not re.search(rf"#define\s+{macro}\s+{pat}", hdr):
raise AssertionError(f"Missing or mismatched macro {macro} in {HDR_PATH}")
with tempfile.TemporaryDirectory(prefix="geminux-ccci-test-") as tmp:
src = os.path.join(tmp, "test_ccci.c")
bin_path = os.path.join(tmp, "test_ccci")
with open(src, "w", encoding="utf-8") as handle:
handle.write(C_TEST)
gcc = shutil.which("gcc")
if gcc:
subprocess.run(
[gcc, "-std=c11", "-Wall", "-Wextra", "-Werror",
"-I", DAEMON_INC, "-I", KERNEL_INC,
src, PROTO_C, "-o", bin_path],
check=True,
)
subprocess.run([bin_path], check=True)
else:
subprocess.run(
["docker", "run", "--rm", "-v", f"{BASE_DIR}:/geminux:ro",
"-v", f"{tmp}:/work", "alpine:3.24", "sh", "-eu", "-c",
"apk add --no-cache build-base linux-headers >/dev/null && "
"gcc -std=c11 -Wall -Wextra -Werror -I/geminux/src/geminux-daemons "
"-I/geminux/prebuilt/kernel/include /work/test_ccci.c "
"/geminux/src/geminux-daemons/geminux-ccci-proto.c -o /work/test_ccci && "
"/work/test_ccci"],
check=True,
)
print("[PASS] MT6797 CCCI 16-byte framing, channel map, and handshake verified")
return 0
if __name__ == "__main__":
sys.exit(main())