Skip to content

Commit 94f4a6b

Browse files
committed
zingcore 2.5 ABI
1 parent df0fc37 commit 94f4a6b

24 files changed

Lines changed: 1247 additions & 156 deletions

src/zem/zingcore2.2_final/zingcore/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
This folder defines the **new final micro ABI** for Zing hosts and runtimes.
44

55
- Spec: `zingcore/ABI_V2.md`
6-
- C header (canonical signatures): `zingcore/include/zi_abi_v2.h`
6+
- C header (native shim API): `zingcore/include/zi_abi_v2.h`
7+
- System ABI header (wire contract): `zingcore/include/zi_sysabi_v2.h`
78

89
Design goals:
910
- Pure `zi_*` C ABI calls (no framed control-plane protocols).

src/zem/zingcore2.2_final/zingcore/include/zi_abi_v2.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ extern "C" {
99

1010
typedef int32_t zi_handle_t;
1111

12+
/*
13+
* NOTE:
14+
* This header is a C-friendly API surface (native shim).
15+
* For the fixed-width system ABI (wire contract), use:
16+
* zi_sysabi_v2.h
17+
*/
18+
1219
/* ------------------------------------------------------------------------- */
1320
/* ZASM note: "core ABI" vs optional capability surfaces */
1421
/*
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#pragma once
2+
3+
#include <stdint.h>
4+
5+
#ifdef __cplusplus
6+
extern "C" {
7+
#endif
8+
9+
/*
10+
* System ABI (wire contract) — v2.x
11+
*
12+
* This header defines the *wire-level* signatures at the system boundary.
13+
* It is suitable for both native shims and WASM hosts.
14+
*
15+
* Key rules for ABI stability:
16+
* - All integers are fixed-width.
17+
* - Guest memory pointers are carried as 64-bit values (zi_ptr_t).
18+
* WASM32 runtimes typically interpret these as zero-extended 32-bit offsets
19+
* into linear memory; higher bits must be rejected.
20+
* - Lengths/capacities are 32-bit.
21+
* - Error returns are negative int32_t values.
22+
*
23+
* Minimal core ABI (always present):
24+
* zi_abi_version, zi_abi_features
25+
* zi_ctl
26+
* zi_read, zi_write, zi_end
27+
* zi_alloc, zi_free
28+
* zi_telemetry
29+
*
30+
* Optional extension (caps model):
31+
* If a runtime exposes any capabilities, it must also provide zi_cap_* and
32+
* zi_handle_hflags.
33+
*/
34+
35+
typedef int32_t zi_handle_t;
36+
37+
typedef uint64_t zi_ptr_t; /* guest memory address/offset */
38+
typedef uint32_t zi_size32_t;/* byte counts (req_len, resp_cap, etc.) */
39+
40+
enum {
41+
ZI_OK = 0,
42+
43+
ZI_E_INVALID = -1,
44+
ZI_E_BOUNDS = -2,
45+
ZI_E_NOENT = -3,
46+
ZI_E_DENIED = -4,
47+
ZI_E_CLOSED = -5,
48+
ZI_E_AGAIN = -6,
49+
ZI_E_NOSYS = -7,
50+
ZI_E_OOM = -8,
51+
ZI_E_IO = -9,
52+
ZI_E_INTERNAL = -10,
53+
};
54+
55+
enum {
56+
/* Non-normative feature bits; see runtime pack policy. */
57+
ZI_FEAT_FS = 1ull << 0,
58+
ZI_FEAT_ASYNC = 1ull << 1,
59+
ZI_FEAT_TIME = 1ull << 2,
60+
ZI_FEAT_EXEC = 1ull << 3,
61+
ZI_FEAT_PROC = 1ull << 4,
62+
};
63+
64+
enum {
65+
/* ZCL1 framing ops (control plane). */
66+
ZI_CTL_OP_CAPS_LIST = 1,
67+
ZI_CTL_OP_CAPS_DESCRIBE = 2,
68+
ZI_CTL_OP_CAPS_OPEN = 3,
69+
};
70+
71+
enum {
72+
ZI_CAP_CAN_OPEN = 1u << 0,
73+
ZI_CAP_PURE = 1u << 1,
74+
ZI_CAP_MAY_BLOCK = 1u << 2,
75+
};
76+
77+
enum {
78+
ZI_H_READABLE = 1u << 0,
79+
ZI_H_WRITABLE = 1u << 1,
80+
ZI_H_ENDABLE = 1u << 2,
81+
ZI_H_SEEKABLE = 1u << 3,
82+
};
83+
84+
typedef struct {
85+
zi_ptr_t kind_ptr;
86+
int32_t kind_len;
87+
zi_ptr_t name_ptr;
88+
int32_t name_len;
89+
uint32_t mode;
90+
zi_ptr_t params_ptr;
91+
int32_t params_len;
92+
} zi_cap_open_req_v2;
93+
94+
/* --- Minimal core surface (expected everywhere) --- */
95+
96+
uint32_t zi_abi_version(void);
97+
uint64_t zi_abi_features(void);
98+
99+
int32_t zi_ctl(zi_ptr_t req_ptr, zi_size32_t req_len,
100+
zi_ptr_t resp_ptr, zi_size32_t resp_cap);
101+
102+
int32_t zi_read(zi_handle_t h, zi_ptr_t dst_ptr, zi_size32_t cap);
103+
int32_t zi_write(zi_handle_t h, zi_ptr_t src_ptr, zi_size32_t len);
104+
int32_t zi_end(zi_handle_t h);
105+
106+
zi_ptr_t zi_alloc(zi_size32_t size);
107+
int32_t zi_free(zi_ptr_t ptr);
108+
109+
int32_t zi_telemetry(zi_ptr_t topic_ptr, zi_size32_t topic_len,
110+
zi_ptr_t msg_ptr, zi_size32_t msg_len);
111+
112+
/* --- Caps extension (optional; required if any caps exist) --- */
113+
114+
int32_t zi_cap_count(void);
115+
int32_t zi_cap_get_size(int32_t index);
116+
int32_t zi_cap_get(int32_t index, zi_ptr_t out_ptr, zi_size32_t out_cap);
117+
zi_handle_t zi_cap_open(zi_ptr_t req_ptr);
118+
uint32_t zi_handle_hflags(zi_handle_t h);
119+
120+
#ifdef __cplusplus
121+
} // extern "C"
122+
#endif

src/zingcore/2.5/Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,29 @@ LIB := $(BUILD)/libzingcore25.a
1717

1818
SRC := \
1919
$(SRCDIR)/zingcore25.c \
20+
$(SRCDIR)/zi_runtime25.c \
21+
$(SRCDIR)/zi_handles25.c \
22+
$(SRCDIR)/zi_zcl1.c \
23+
$(SRCDIR)/zi_syscalls_core25.c \
24+
$(SRCDIR)/zi_syscalls_caps25.c \
2025
$(SRCDIR)/zi_caps.c \
2126
$(SRCDIR)/zi_async.c \
2227
$(SRCDIR)/zi_problem.c \
2328
$(SRCDIR)/zi_telemetry.c
2429

2530
OBJ := \
2631
$(BUILD)/zingcore25.o \
32+
$(BUILD)/zi_runtime25.o \
33+
$(BUILD)/zi_handles25.o \
34+
$(BUILD)/zi_zcl1.o \
35+
$(BUILD)/zi_syscalls_core25.o \
36+
$(BUILD)/zi_syscalls_caps25.o \
2737
$(BUILD)/zi_caps.o \
2838
$(BUILD)/zi_async.o \
2939
$(BUILD)/zi_problem.o \
3040
$(BUILD)/zi_telemetry.o
3141

32-
TESTS := test_caps test_async_registry test_zingcore25_api test_problem test_telemetry_jsonl
42+
TESTS := test_caps test_async_registry test_zingcore25_api test_problem test_telemetry_jsonl test_sysabi25_min_core test_sysabi25_ctl_caps_list
3343

3444
.PHONY: test
3545

src/zingcore/2.5/dist/debug/include/README.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/zingcore/2.5/dist/debug/include/zi_async.h

Lines changed: 0 additions & 69 deletions
This file was deleted.

src/zingcore/2.5/dist/debug/include/zi_caps.h

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/zingcore/2.5/dist/debug/include/zingcore25.h

Lines changed: 0 additions & 16 deletions
This file was deleted.
-4.77 KB
Binary file not shown.
Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1-
# zingcore2.5 public headers (WIP)
1+
# zingcore 25-family public headers
22

3-
This directory will contain the **public** headers for the zABI 2.5 runtime.
3+
This folder contains the public headers for the zingcore **25-family** implementation.
44

5-
Rules:
5+
## Naming policy
66

7-
- Headers in this folder define the stable API surface.
8-
- Keep includes minimal and C11-friendly.
9-
- Avoid leaking internal structs; prefer opaque handles.
7+
- **Wire/system ABI:** the stable syscall surface is `zi_*` as declared by the family’s sysabi header
8+
(for 2.5 that is `zi_sysabi25.h`). These names are *not* family-suffixed.
9+
- **Wiring/implementation:** process-global wiring and convenience APIs are family-namespaced
10+
(e.g. `zingcore25_*`, `zi_runtime25_*`).
11+
12+
## What “25” means
13+
14+
“25” is a **family namespace**, not “ABI version digits in a function name”.
1015

11-
Status: placeholder (not yet wired into the build).
16+
The intent is that 2.5 / 2.6 / 2.7 / … stay within the same wiring family without renaming exported
17+
wiring symbols on every minor bump. We only introduce a new family number when we make a truly
18+
incompatible wiring break.
19+
20+
## General rules
21+
22+
- Keep includes minimal and C11-friendly.
23+
- Prefer fixed-width integer types at ABI boundaries.
24+
- Avoid leaking internal structs; prefer opaque handles where practical.

0 commit comments

Comments
 (0)