env_internal.h (1632B)
1 #ifndef KIT_DRIVER_ENV_INTERNAL_H 2 #define KIT_DRIVER_ENV_INTERNAL_H 3 4 /* Internal header shared by every driver/env/ TU, regardless of host OS. 5 * 6 * Each TU implements one slice of the host environment with zero 7 * preprocessor conditionals -- selection is done by mk/env.mk, which 8 * picks at most one of {macos,linux,freebsd,windows}.c, one of 9 * icache_<arch>.c, and (on POSIX) one of uctx_<arch>_<os>.c per build. 10 * 11 * Scope of this header (must stay OS-neutral): 12 * - includes only of <stddef.h>/<stdint.h> and the libkit public API 13 * - the libc-pure vtables defined in common.c (g_heap_libc, g_diag_stderr) 14 * - the arch-only icache flush hook (icache_<arch>.c) 15 * 16 * The POSIX-shared surface (file I/O scaffold, exec_dual registry, signal 17 * machinery, the os_* hooks the per-OS POSIX file implements, ucontext 18 * marshalling) lives in env_posix.h. Windows has no POSIX overlap, so 19 * windows.c folds everything into a single TU and only needs this 20 * header. */ 21 22 #include <kit/compile.h> 23 #include <kit/core.h> 24 #include <kit/dbg.h> 25 #include <stddef.h> 26 #include <stdint.h> 27 28 #include "driver.h" 29 #include "env.h" 30 31 /* ---- vtable singletons wired into DriverEnv (common.c) ----------------- 32 * Defined in common.c and consumed by every host's driver_env_init. */ 33 extern KitHeap g_heap_libc; 34 extern KitDiagSink g_diag_stderr; 35 36 /* ---- icache (icache_<arch>.c) ------------------------------------------ 37 * Arch-only, OS-neutral. The POSIX dbg path delegates here from 38 * os_dbg_flush_icache; Windows uses FlushInstructionCache directly and 39 * does not consume this. */ 40 void env_flush_icache(void* addr, size_t n); 41 42 #endif