Public API reference — 0.1.0 stable surface¶
The application-facing API and its stability contract for the 0.1.0 development release. This is the
single reference for what an app may call and what it may rely on; the authoritative per-symbol contract
lives in the headers themselves (kernel/*.h, hal/*.h), which this doc indexes.
How to read this¶
Header tiers
Tier |
Headers |
Meaning |
|---|---|---|
A — application API |
|
what an app includes |
B — tooling / observability |
|
trace tools + a DET hook; the interface is stable, details experimental |
Internal — NOT the API |
|
live in |
Annotation tags (in the headers)
[rt]— callable at runtime from a thread, including an unprivileged one (traps through the syscall path).[setup]— privileged/setup-only (beforetk_kernel_start, or from a system thread).[override]— a weak seam you provide (app or board), not a call-in API; the kernel calls it.[experimental]— signature or semantics may still change; NOT frozen for 0.1.0.
Stability: everything below is STABLE (frozen for 0.1.0) unless marked [experimental]. Frozen means
it will not change without a deprecation. The current experimental set is the WORLD security axis, the
INSTANCE supervisor-fence override seams, and the thread-introspection snapshot — surfaces whose
backing feature is not yet proven on a shipping board.
Threads (tk_kernel.h)¶
Symbol |
Tag |
Contract |
|---|---|---|
|
|
positional create; NULL if the pool is full |
|
|
create into a specific instance |
|
|
attr create (pthread_create shape) |
|
|
attr create into an instance |
|
|
attribute builders (pthread_attr_* shape) |
|
|
yield / sleep (the last is the one aliased short form) |
|
|
exit (noreturn) / join+reap / detach |
|
|
own handle / stable id / owning instance |
|
|
per-thread config (affinity |
|
|
attach a name (no-op without a trace/introspect build) |
|
|
ps/top snapshot; record shape may change |
Types: tk_thread_fn = void*(*)(void*) (pthread-shaped), tk_thread_attr_t, enum tk_thread_state,
enum tk_thread_detachstate. Constants: TK_PRIO_IDLE/MIN/MAX, TK_CORE(n), TK_THREAD_STACK(name, size).
Kernel lifecycle & instances (tk_kernel.h)¶
Symbol |
Tag |
Contract |
|---|---|---|
|
|
init once; enter the scheduler (no return on a switching port) |
|
|
kernel config (bare = default instance) |
|
|
declare an AMP/SMP-subset island |
|
|
island private arena (C3-B) / trusted-monitor escape hatch |
|
|
instance-handle ergonomics |
|
|
this-core instance / name / core mask |
|
|
the HW isolation boundary this build enforces |
|
|
cross-island stall poll / a specific instance’s clock |
WORLD axis: |
|
TrustZone-AMP security attribution — no shipping board realizes it yet |
Override seams: |
|
weak; you/the board provide them |
Synchronization¶
Header |
Stable surface |
|---|---|
|
|
|
|
|
|
|
|
|
|
Handles (tk_sem_t / tk_mutex_t / tk_cond_t) are opaque int16_t into a static kernel pool; [rt] for
the operate calls, [setup] for create/init/set_name.
Time (tk_time.h)¶
tk_time_init() [setup]; tk_time_ms() · tk_time_us() · tk_kernel_now_ms() [rt]. tk_kernel_now_ms
is a second name for tk_time_ms kept for the scheduler/EDF timebase.
HAL (hal/*.h)¶
Minimal, stable contract (a status-returning / UART-RX layer is a compatible future add): tk_board_init;
tk_console_init + tk_print / tk_print_u32 (+ weak tk_console_lock/unlock); tk_dio_read/write/flip
(channel + pin) with TK_DIO_LOW/HIGH; tk_dio_irq_* (edge → callback); tk_uart_init/write/setup;
tk_port_init/config_pin with tk_dir_t/tk_pull_t; tk_mcu_init / tk_mcu_clock_hz. The HAL uses its
own tk_*_channel_t id types and does not carry the [rt]/[setup] scheme (that vocabulary is kernel-only).
POSIX / pthreads¶
The threads + mutex + cond surface is pthread-shaped (not compliant). An opt-in shim
compat/pthread.h maps pthread_{create,join,detach,exit,self,equal},
pthread_attr_*, pthread_mutex_*/mutexattr, pthread_cond_* onto tk_*; the demo examples/pthread_api
proves it. Full analysis: docs/evaluation/standards-api-ergonomics.md.
Compile-time configuration¶
Knobs (TK_CONFIG_*) and derived capability flags (TK_FEAT_*, TK_ISOLATION_*, TK_ARCH_*) are
transitively public through tk_kernel.h. Each carries a labelled contract block in
kernel/tk_config.h — the single source of truth for values, defaults,
requirements, and effects.
Naming notes (frozen for 0.1.0)¶
Three construction verbs are deliberate, not inconsistent:
create(positional convenience),spawn(attr form, pthread_create shape),define(a kernel instance).tk_sleep_msis the single intentional short alias (ADR 0002 §8);yield/exit/joinkeeptk_thread_.The
_insuffix consistently marks the instance-targeted twin of a default-instance call.