CUDApp
CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.
Brought by drakestapleton
CUDApp / om / platform-linux / gen / link / plat_fx_wait.c
| 1 | /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ |
| 2 | /* Generated by om/platform-linux/gen_effects.sh; do not edit. */ |
| 3 | #if defined(__aarch64__) |
| 4 | #define OMBR_USES_MAPS 1 |
| 5 | /* Generated by omega-bridge src/native.om: native call ABI v1 (docs/NATIVE-ABI.md). |
| 6 | * The Omega machine code below is embedded byte for byte as the seeded compiler wrote it. |
| 7 | * This file only adapts the C calling convention to it. Regenerate it; do not edit it. */ |
| 8 | #include <pthread.h> |
| 9 | #include <signal.h> |
| 10 | #include <stdint.h> |
| 11 | #include <stdlib.h> |
| 12 | #include <sys/mman.h> |
| 13 | #define OMEGA_OK 0u |
| 14 | #define OMEGA_BAD_ARG 32u |
| 15 | #define OMEGA_REENTRY 33u |
| 16 | #define OMEGA_BAD_RT 34u |
| 17 | #define OMEGA_NO_STACK 35u |
| 18 | #define OMBR_STACK (8u << 20) |
| 19 | #define OMBR_GUARD (8u << 20) |
| 20 | /* entry[2] is the trap entry (OSC-1 section 7). */ |
| 21 | typedef struct ombr_rt { const void *entry[32]; } ombr_rt; |
| 22 | typedef struct ombr_span { uintptr_t lo, hi; int w; } ombr_span; |
| 23 | #define OMEGA_CONTEXT_BUSY 36u |
| 24 | typedef struct omega_native_context { |
| 25 | pthread_mutex_t lock; |
| 26 | uint64_t *maps; |
| 27 | const ombr_rt *rt; |
| 28 | } omega_native_context; |
| 29 | static _Alignas(16) uint64_t ombr_maps[516]; |
| 30 | static omega_native_context ombr_default = { .lock = PTHREAD_MUTEX_INITIALIZER, .maps = ombr_maps }; |
| 31 | static _Thread_local volatile sig_atomic_t ombr_active; |
| 32 | static _Thread_local unsigned char *ombr_stk; |
| 33 | static pthread_key_t ombr_key; |
| 34 | static int ombr_keyok; |
| 35 | static pthread_once_t ombr_once = PTHREAD_ONCE_INIT; |
| 36 | uint32_t plat_wt_ombr_enter(const void *code, const uint64_t *args, const ombr_rt *rt, uint64_t *out, void *top) |
| 37 | __attribute__((visibility("hidden"))); |
| 38 | extern const unsigned char plat_wt_ombr_trap[] __attribute__((visibility("hidden"))); |
| 39 | extern const unsigned char plat_wt_ombr_no_entry[] __attribute__((visibility("hidden"))); |
| 40 | /* The object format's spelling of the embedded code and runtime symbols. ELF keeps them local and hidden |
| 41 | * in .text.omega_bridge. Mach-O (macOS) prefixes C symbol names with an underscore and keeps them local |
| 42 | * by not declaring them .globl; .alt_entry keeps the runtime entries in plat_wt_ombr_enter's atom. */ |
| 43 | #if defined(__APPLE__) && defined(__MACH__) |
| 44 | #define OMBR_SYM(n) "_" #n |
| 45 | #define OMBR_LOCAL(n) "" |
| 46 | #define OMBR_HIDDEN(n) "" |
| 47 | #define OMBR_FUNC(n) "" |
| 48 | #define OMBR_ALT(n) ".alt_entry _" #n "\n" |
| 49 | #define OMBR_SIZE(n) "" |
| 50 | #define OMBR_LEAVE "Lombr_leave" |
| 51 | #define OMBR_CODE_SECTION ".section __TEXT,__text,regular,pure_instructions\n" |
| 52 | #define OMBR_PREVIOUS "" |
| 53 | #elif defined(__ELF__) |
| 54 | #define OMBR_SYM(n) #n |
| 55 | #define OMBR_LOCAL(n) ".local " #n "\n" |
| 56 | #define OMBR_HIDDEN(n) ".hidden " #n "\n" |
| 57 | #define OMBR_FUNC(n) ".type " #n ",%function\n" |
| 58 | #define OMBR_ALT(n) OMBR_FUNC(n) |
| 59 | #define OMBR_SIZE(n) ".size " #n ",.-" #n "\n" |
| 60 | #define OMBR_LEAVE "ombr_leave" |
| 61 | #define OMBR_CODE_SECTION ".section .text.omega_bridge,\"ax\",@progbits\n" |
| 62 | #define OMBR_PREVIOUS ".previous\n" |
| 63 | #else |
| 64 | #error "omega-bridge native binding: ELF or Mach-O objects only" |
| 65 | #endif |
| 66 | /* plat_wt_ombr_enter saves the callee-saved registers on the caller's stack, keeps that stack pointer in x19 and |
| 67 | * runs the code on the binding's own stack. A normal return stores x0 through out and |
| 68 | * returns 0. A runtime entry restores the stack pointer from x19 and returns a status; out is not |
| 69 | * written. A unit's code must not write x18, x19 or x29 and must keep sp balanced; it may write x0..x17, |
| 70 | * x20..x28 and v0..v31 (x20..x28 and d8..d15 are restored here). Runtime entries are reached by blr/br, so they start with bti jc. */ |
| 71 | #if !defined(__aarch64__) |
| 72 | #error "omega-bridge native binding: the embedded code is AArch64" |
| 73 | #endif |
| 74 | __asm__(".text\n.balign 4\n" OMBR_LOCAL( plat_wt_ombr_enter ) OMBR_HIDDEN(plat_wt_ombr_enter) OMBR_FUNC(plat_wt_ombr_enter) |
| 75 | OMBR_SYM(plat_wt_ombr_enter) ":\n" |
| 76 | "hint #34\nstp x29,x30,[sp,#-176]!\nmov x29,sp\nstp x19,x20,[sp,#16]\nstp x21,x22,[sp,#32]\n" |
| 77 | "stp x23,x24,[sp,#48]\nstp x25,x26,[sp,#64]\nstp x27,x28,[sp,#80]\nstp d8,d9,[sp,#96]\n" |
| 78 | "stp d10,d11,[sp,#112]\nstp d12,d13,[sp,#128]\nstp d14,d15,[sp,#144]\nstr x3,[sp,#160]\n" |
| 79 | "mov x19,sp\nmov x16,x0\nmov x17,x1\nmov x7,x2\nmov sp,x4\n" |
| 80 | "ldp x0,x1,[x17]\nldp x2,x3,[x17,#16]\nldp x4,x5,[x17,#32]\nblr x16\n" |
| 81 | "mov sp,x19\nldr x9,[sp,#160]\nstr x0,[x9]\nmov w0,#0\n" |
| 82 | OMBR_LEAVE ":\nldp d14,d15,[sp,#144]\nldp d12,d13,[sp,#128]\nldp d10,d11,[sp,#112]\n" |
| 83 | "ldp d8,d9,[sp,#96]\nldp x27,x28,[sp,#80]\nldp x25,x26,[sp,#64]\nldp x23,x24,[sp,#48]\n" |
| 84 | "ldp x21,x22,[sp,#32]\nldp x19,x20,[sp,#16]\nldp x29,x30,[sp],#176\nret\n" OMBR_SIZE(plat_wt_ombr_enter) |
| 85 | OMBR_LOCAL(plat_wt_ombr_trap) OMBR_HIDDEN(plat_wt_ombr_trap) OMBR_ALT(plat_wt_ombr_trap) OMBR_SYM(plat_wt_ombr_trap) ":\nhint #38\n" |
| 86 | "mov sp,x19\nsub x2,x1,#1\nmov w3,#34\ncmp x2,#13\ncsel w0,w1,w3,ls\nb " OMBR_LEAVE "\n" |
| 87 | OMBR_SIZE(plat_wt_ombr_trap) |
| 88 | OMBR_LOCAL(plat_wt_ombr_no_entry) OMBR_HIDDEN(plat_wt_ombr_no_entry) OMBR_ALT(plat_wt_ombr_no_entry) OMBR_SYM(plat_wt_ombr_no_entry) ":\nhint #38\n" |
| 89 | "mov sp,x19\nmov w0,#34\nb " OMBR_LEAVE "\n" OMBR_SIZE(plat_wt_ombr_no_entry)); |
| 90 | static void ombr_free(void *p) |
| 91 | { |
| 92 | munmap(p, OMBR_STACK + OMBR_GUARD); |
| 93 | } |
| 94 | static void ombr_init(void) |
| 95 | { |
| 96 | ombr_keyok = pthread_key_create(&ombr_key, ombr_free) == 0; |
| 97 | } |
| 98 | /* The thread's Omega stack: OMBR_STACK usable bytes above an OMBR_GUARD no-access region. A function-mode |
| 99 | * unit has no call cycles and at most 4 MiB of local arrays per function (OMEGESE, local arrays), so a frame that |
| 100 | * would pass the bottom starts inside the guard and faults there; nothing below the guard is touched. */ |
| 101 | static unsigned char *ombr_stack(void) |
| 102 | { |
| 103 | if (ombr_stk) |
| 104 | return ombr_stk; |
| 105 | pthread_once(&ombr_once, ombr_init); |
| 106 | if (!ombr_keyok) |
| 107 | return 0; |
| 108 | unsigned char *p = mmap(0, OMBR_STACK + OMBR_GUARD, PROT_READ | PROT_WRITE, |
| 109 | MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0); |
| 110 | if (p == MAP_FAILED) |
| 111 | return 0; |
| 112 | if (mprotect(p, OMBR_GUARD, PROT_NONE) != 0 || pthread_setspecific(ombr_key, p) != 0) { |
| 113 | munmap(p, OMBR_STACK + OMBR_GUARD); |
| 114 | return 0; |
| 115 | } |
| 116 | ombr_stk = p + OMBR_GUARD + OMBR_STACK; |
| 117 | return ombr_stk; |
| 118 | } |
| 119 | static int ombr_span_add(ombr_span *sp, unsigned *ns, const void *p, uint64_t n, uint64_t want, uint64_t es, int w) |
| 120 | { |
| 121 | uintptr_t lo = (uintptr_t)p; |
| 122 | if (!p || n != want || lo % es != 0u || n > (UINTPTR_MAX - lo) / es) |
| 123 | return 1; |
| 124 | sp[*ns].lo = lo; |
| 125 | sp[*ns].hi = lo + n * es; |
| 126 | sp[*ns].w = w; |
| 127 | (*ns)++; |
| 128 | return 0; |
| 129 | } |
| 130 | static int ombr_overlap(const ombr_span *sp, unsigned ns) |
| 131 | { |
| 132 | for (unsigned i = 0; i < ns; i++) |
| 133 | for (unsigned j = i + 1; j < ns; j++) |
| 134 | if ((sp[i].w || sp[j].w) && sp[i].lo < sp[j].hi && sp[j].lo < sp[i].hi) |
| 135 | return 1; |
| 136 | return 0; |
| 137 | } |
| 138 | /* One read-only runtime table for every call and thread: the code only reads it (a write would fault). */ |
| 139 | static const ombr_rt ombr_rt_table = {{ plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_trap, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, ombr_maps }}; |
| 140 | /* Explicit C ABI contexts: compatibility-runtime ownership, not driver policy. */ |
| 141 | static pthread_once_t ombr_map_once = PTHREAD_ONCE_INIT; |
| 142 | static pthread_mutex_t ombr_id_lock = PTHREAD_MUTEX_INITIALIZER; |
| 143 | static uint64_t ombr_next_context = 2; |
| 144 | static void ombr_map_init(void) |
| 145 | { |
| 146 | ombr_maps[0] = 128; |
| 147 | ombr_maps[1] = 67108864; |
| 148 | ombr_maps[2] = 134217727; |
| 149 | for (unsigned i = 0; i < 128; i++) |
| 150 | ombr_maps[4 + i * 4 + 2] = ombr_maps[1]; |
| 151 | ombr_default.rt = &ombr_rt_table; |
| 152 | } |
| 153 | __attribute__((visibility("default"))) uint32_t plat_wt_context_create(uint64_t capacity, |
| 154 | omega_native_context **out) |
| 155 | { |
| 156 | if (!out || capacity == 0 || capacity > 4098) |
| 157 | return OMEGA_BAD_ARG; |
| 158 | if (ombr_active) |
| 159 | return OMEGA_REENTRY; |
| 160 | if (pthread_mutex_lock(&ombr_id_lock) != 0) |
| 161 | return OMEGA_BAD_RT; |
| 162 | uint64_t id = ombr_next_context; |
| 163 | if (id <= 16777215) |
| 164 | ombr_next_context++; |
| 165 | int unlock_error = pthread_mutex_unlock(&ombr_id_lock); |
| 166 | if (unlock_error || id > 16777215) |
| 167 | return OMEGA_BAD_RT; |
| 168 | omega_native_context *c = calloc(1, sizeof *c); |
| 169 | if (!c) |
| 170 | return OMEGA_BAD_RT; |
| 171 | c->maps = calloc((size_t)capacity + 1u, 32u); |
| 172 | if (!c->maps) { |
| 173 | free(c); |
| 174 | return OMEGA_BAD_RT; |
| 175 | } |
| 176 | if (pthread_mutex_init(&c->lock, 0) != 0) { |
| 177 | free(c->maps); |
| 178 | free(c); |
| 179 | return OMEGA_BAD_RT; |
| 180 | } |
| 181 | ombr_rt *rt = mmap(0, sizeof *rt, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
| 182 | if (rt == MAP_FAILED) { |
| 183 | pthread_mutex_destroy(&c->lock); |
| 184 | free(c->maps); |
| 185 | free(c); |
| 186 | return OMEGA_BAD_RT; |
| 187 | } |
| 188 | *rt = ombr_rt_table; |
| 189 | rt->entry[31] = c->maps; |
| 190 | if (mprotect(rt, sizeof *rt, PROT_READ) != 0) { |
| 191 | munmap(rt, sizeof *rt); |
| 192 | pthread_mutex_destroy(&c->lock); |
| 193 | free(c->maps); |
| 194 | free(c); |
| 195 | return OMEGA_BAD_RT; |
| 196 | } |
| 197 | c->rt = rt; |
| 198 | c->maps[0] = capacity; |
| 199 | c->maps[1] = id << 26; |
| 200 | c->maps[2] = ((id + 1u) << 26) - 1u; |
| 201 | for (uint64_t i = 0; i < capacity; i++) |
| 202 | c->maps[4 + i * 4 + 2] = c->maps[1]; |
| 203 | *out = c; |
| 204 | return OMEGA_OK; |
| 205 | } |
| 206 | __attribute__((visibility("default"))) uint32_t plat_wt_context_destroy(omega_native_context *c) |
| 207 | { |
| 208 | if (!c || c == &ombr_default) |
| 209 | return OMEGA_BAD_ARG; |
| 210 | if (ombr_active) |
| 211 | return OMEGA_REENTRY; |
| 212 | /* Caller has joined/drained users and waiters before entering destruction. */ |
| 213 | if (pthread_mutex_lock(&c->lock) != 0) |
| 214 | return OMEGA_BAD_RT; |
| 215 | for (uint64_t i = 0; i < c->maps[0]; i++) { |
| 216 | if (c->maps[4 + i * 4] != 0) { |
| 217 | if (pthread_mutex_unlock(&c->lock) != 0) |
| 218 | return OMEGA_BAD_RT; |
| 219 | return OMEGA_CONTEXT_BUSY; |
| 220 | } |
| 221 | } |
| 222 | if (pthread_mutex_unlock(&c->lock) != 0 || pthread_mutex_destroy(&c->lock) != 0) |
| 223 | return OMEGA_BAD_RT; |
| 224 | int failed = munmap((void *)c->rt, sizeof *c->rt) != 0; |
| 225 | free(c->maps); |
| 226 | free(c); |
| 227 | return failed ? OMEGA_BAD_RT : OMEGA_OK; |
| 228 | } |
| 229 | static uint32_t ombr_context_lock(omega_native_context *c) |
| 230 | { |
| 231 | if (!c) |
| 232 | return OMEGA_BAD_ARG; |
| 233 | if (ombr_active) |
| 234 | return OMEGA_REENTRY; |
| 235 | ombr_active = 1; |
| 236 | if (c == &ombr_default && pthread_once(&ombr_map_once, ombr_map_init) != 0) { |
| 237 | ombr_active = 0; |
| 238 | return OMEGA_BAD_RT; |
| 239 | } |
| 240 | if (pthread_mutex_lock(&c->lock) != 0) { |
| 241 | ombr_active = 0; |
| 242 | return OMEGA_BAD_RT; |
| 243 | } |
| 244 | return OMEGA_OK; |
| 245 | } |
| 246 | static uint32_t ombr_context_unlock(omega_native_context *c, uint32_t status) |
| 247 | { |
| 248 | int failed = pthread_mutex_unlock(&c->lock); |
| 249 | ombr_active = 0; |
| 250 | return failed ? OMEGA_BAD_RT : status; |
| 251 | } |
| 252 | static uint32_t ombr_run(const void *code, const uint64_t *args, uint64_t *result, int has_value) |
| 253 | { |
| 254 | omega_native_context *context = &ombr_default; |
| 255 | uint32_t s = ombr_context_lock(context); |
| 256 | if (s != OMEGA_OK) |
| 257 | return s; |
| 258 | unsigned char *top = ombr_stack(); |
| 259 | if (!top) |
| 260 | return ombr_context_unlock(context, OMEGA_NO_STACK); |
| 261 | uint64_t v = 0; |
| 262 | s = plat_wt_ombr_enter(code, args, context->rt, &v, top); |
| 263 | if (s == OMEGA_OK) |
| 264 | *result = has_value ? v : 0u; |
| 265 | return ombr_context_unlock(context, s); |
| 266 | } |
| 267 | /* ABI v2 (docs/NATIVE-ABI.md, ABI v2): OM-2 units, bound as omega2_<export>. An unsized view is its |
| 268 | * pointer and its element count; a layout is a pointer to its fixed bytes; an out parameter is written |
| 269 | * to a buffer the binding owns and copied to the caller only after status 0. */ |
| 270 | #include <string.h> |
| 271 | typedef struct ombr2_out { unsigned slot; uint64_t n; void *dst; } ombr2_out; |
| 272 | /* A library of OM-2 units alone calls neither of the ABI v1 helpers. */ |
| 273 | __attribute__((unused)) static void ombr2_keep(void) |
| 274 | { |
| 275 | (void)ombr_overlap; |
| 276 | (void)ombr_run; |
| 277 | } |
| 278 | /* An unsized view of n elements of es bytes. n == 0 is the empty view whatever the pointer (it adds no |
| 279 | * range, so it overlaps nothing). Otherwise refused: a null pointer, a pointer not aligned to es, |
| 280 | * n * es over 64 bits, or an end past the top of the address space. */ |
| 281 | __attribute__((unused)) static int ombr2_view(ombr_span *sp, unsigned *ns, const void *p, uint64_t n, uint64_t es, int w) |
| 282 | { |
| 283 | uintptr_t lo = (uintptr_t)p; |
| 284 | if (n == 0u) |
| 285 | return 0; |
| 286 | if (!p || lo % es != 0u || n > UINT64_MAX / es || n * es > UINTPTR_MAX - lo) |
| 287 | return 1; |
| 288 | sp[*ns].lo = lo; |
| 289 | sp[*ns].hi = lo + n * es; |
| 290 | sp[*ns].w = w; |
| 291 | (*ns)++; |
| 292 | return 0; |
| 293 | } |
| 294 | /* A fixed range of nb > 0 bytes (a layout or an out parameter) aligned to es. */ |
| 295 | __attribute__((unused)) static int ombr2_fixed(ombr_span *sp, unsigned *ns, const void *p, uint64_t nb, uint64_t es, |
| 296 | int w) |
| 297 | { |
| 298 | uintptr_t lo = (uintptr_t)p; |
| 299 | if (!p || lo % es != 0u || nb > UINTPTR_MAX - lo) |
| 300 | return 1; |
| 301 | sp[*ns].lo = lo; |
| 302 | sp[*ns].hi = lo + nb; |
| 303 | sp[*ns].w = w; |
| 304 | (*ns)++; |
| 305 | return 0; |
| 306 | } |
| 307 | /* w: 0 view, 1 edit or the result, 2 out. Refused: an edit or the result overlapping any other range, |
| 308 | * or two out ranges overlapping. An out may overlap a view: it is written only after the code returns. */ |
| 309 | static int ombr2_overlap(const ombr_span *sp, unsigned ns) |
| 310 | { |
| 311 | for (unsigned i = 0; i < ns; i++) |
| 312 | for (unsigned j = i + 1; j < ns; j++) |
| 313 | if ((sp[i].w == 1 || sp[j].w == 1 || (sp[i].w == 2 && sp[j].w == 2)) |
| 314 | && sp[i].lo < sp[j].hi && sp[j].lo < sp[i].hi) |
| 315 | return 1; |
| 316 | return 0; |
| 317 | } |
| 318 | /* As ombr_run, and each out buffer is carved from the top of the thread's Omega stack (16-byte aligned, |
| 319 | * zero-filled), passed in its slot and copied to the caller with memmove only after status 0. */ |
| 320 | static uint32_t ombr2_run(omega_native_context *context, const void *code, uint64_t *args, uint64_t *result, int has_value, const ombr2_out *o, |
| 321 | unsigned no) |
| 322 | { |
| 323 | uint32_t s = ombr_context_lock(context); |
| 324 | if (s != OMEGA_OK) |
| 325 | return s; |
| 326 | unsigned char *top = ombr_stack(); |
| 327 | if (!top) |
| 328 | return ombr_context_unlock(context, OMEGA_NO_STACK); |
| 329 | unsigned char *buf[6] = {0}; |
| 330 | for (unsigned i = 0; i < no; i++) { |
| 331 | top -= (o[i].n + 15u) / 16u * 16u; |
| 332 | memset(top, 0, o[i].n); |
| 333 | buf[i] = top; |
| 334 | args[o[i].slot] = (uint64_t)(uintptr_t)top; |
| 335 | } |
| 336 | uint64_t v = 0; |
| 337 | s = plat_wt_ombr_enter(code, args, context->rt, &v, top); |
| 338 | if (s == OMEGA_OK) { |
| 339 | for (unsigned i = 0; i < no; i++) |
| 340 | memmove(o[i].dst, buf[i], o[i].n); |
| 341 | *result = has_value ? v : 0u; |
| 342 | } |
| 343 | return ombr_context_unlock(context, s); |
| 344 | } |
| 345 | #if defined(__APPLE__) |
| 346 | #error "omega-bridge native binding: unit plat_wait makes Linux system calls (Omega host words), which macOS does not run" |
| 347 | #endif |
| 348 | __asm__(OMBR_CODE_SECTION ".balign 4\n" OMBR_LOCAL(ombr2_code_plat_wait) OMBR_HIDDEN(ombr2_code_plat_wait) OMBR_SYM(ombr2_code_plat_wait) ":\n.byte 0x05,0x00,0x00,0x14,0x11,0x00,0x00,0x14,0x6c,0x00,0x00,0x14,0xbb,0x00,0x00,0x14,0xed,0x00,0x00,0x14,0x1f,0x00,0x00,0xf1,0x61,0x00,0x00,0x54,0x00,0x00,0x80,0xd2,0xc0,0x03,0x5f,0xd6,0x82,0x02,0x80,0xd2,0x01,0x7c,0x02,0x9b,0x02,0x88,0x93,0xd2,0x3f,0x00,0x02,0xeb,0x62,0x00,0x00,0x54,0xe0,0x03,0x01,0xaa,0xc0,0x03,0x5f,0xd6,0x00,0x88,0x93,0xd2,0xc0,0x03,0x5f,0xd6,0xff,0x83,0x00,0xd1,0xe0,0x03,0x00,0xf9,0xe1,0x07,0x00,0xf9,0xfe,0x0b,0x00,0xf9,0xe1,0x07,0x40,0xf9,0x3f,0x00,0x00,0xf1,0x80,0x0a,0x00,0x54,0x0f,0x02,0xc0,0xd2,0x3f,0x00,0x0f,0xeb,0x28,0x0a,0x00,0x54,0xe0,0x03,0x40,0xf9,0x2f,0x00,0xa0,0xd2,0x1f,0x00,0x0f,0xeb,0xa3,0x09,0x00,0x54,0x0f,0x20,0xc0,0xd2,0xef,0x01,0x01,0xcb,0x1f,0x00,0x0f,0xeb,0x28,0x09,0x00,0x54,0xef,0xff,0x81,0xd2,0x0e,0x00,0x0f,0x8a,0xdf,0x01,0x00,0xf1,0xa1,0x08,0x00,0x54,0x2e,0x00,0x0f,0x8a,0xdf,0x01,0x00,0xf1,0x41,0x08,0x00,0x54,0x04,0x00,0x80,0x92,0x05,0x00,0x80,0xd2,0xe9,0x7c,0x40,0xf9,0x2c,0x01,0x40,0xf9,0x9f,0x05,0x00,0xf1,0x83,0x07,0x00,0x54,0x4f,0x00,0x82,0xd2,0x9f,0x01,0x0f,0xeb,0x28,0x07,0x00,0x54,0x2e,0x09,0x40,0xf9,0xdf,0x05,0x00,0xf1,0xc3,0x06,0x00,0x54,0xef,0xff,0x9f,0xd2,0xef,0xff,0xbf,0xf2,0xef,0xff,0xdf,0xf2,0x6f,0x00,0xe0,0xf2,0xdf,0x01,0x0f,0xeb,0x08,0x06,0x00,0x54,0x29,0x81,0x00,0x91,0x2a,0x00,0x80,0xd2,0x2b,0x01,0x40,0xf9,0x7f,0x01,0x00,0xf1,0x81,0x00,0x00,0x54,0x2b,0x09,0x40,0xf9,0x7f,0x01,0x0e,0xeb,0xe3,0x00,0x00,0x54,0x29,0x81,0x00,0x91,0x4a,0x05,0x00,0x91,0x5f,0x01,0x0c,0xeb,0xe9,0xfe,0xff,0x54,0xe0,0x02,0x80,0x92,0x1b,0x00,0x00,0x14,0xe0,0x03,0x40,0xf9,0x02,0x00,0x80,0xd2,0x43,0x04,0x80,0xd2,0x03,0x02,0xa0,0xf2,0xc8,0x1b,0x80,0xd2,0x01,0x00,0x00,0xd4,0x1f,0x00,0x00,0xf1,0x6b,0x02,0x00,0x54,0xee,0x03,0x40,0xf9,0x1f,0x00,0x0e,0xeb,0xe0,0x00,0x00,0x54,0xe8,0x1a,0x80,0xd2,0x01,0x00,0x00,0xd4,0x1f,0x00,0x00,0xf1,0x61,0x02,0x00,0x54,0xc0,0x0b,0x80,0x92,0x0a,0x00,0x00,0x14,0x20,0x01,0x00,0xf9,0x21,0x05,0x00,0xf9,0x6b,0x05,0x00,0x91,0x2b,0x09,0x00,0xf9,0x0f,0x00,0x80,0xd2,0x2f,0x0d,0x00,0xf9,0xaf,0x01,0x80,0xd2,0x60,0x21,0xcf,0x9a,0x00,0x00,0x0a,0xaa,0xe1,0x07,0x40,0xf9,0xfe,0x0b,0x40,0xf9,0xff,0x83,0x00,0x91,0xc0,0x03,0x5f,0xd6,0xe0,0x03,0x07,0xaa,0xf0,0x08,0x40,0xf9,0x00,0x02,0x1f,0xd6,0x61,0x00,0x80,0xd2,0xfc,0xff,0xff,0x17,0x3f,0xc0,0x21,0xeb,0xa1,0x09,0x00,0x54,0xff,0x83,0x00,0xd1,0xe0,0x03,0x00,0xf9,0xe1,0x07,0x00,0xf9,0xfe,0x0b,0x00,0xf9,0xea,0x03,0x40,0xf9,0xef,0xff,0x83,0xd2,0x4b,0x01,0x0f,0x8a,0x7f,0x05,0x00,0xf1,0x43,0x08,0x00,0x54,0xee,0x7c,0x40,0xf9,0xce,0x01,0x40,0xf9,0xdf,0x05,0x00,0xf1,0xc3,0x07,0x00,0x54,0x4f,0x00,0x82,0xd2,0xdf,0x01,0x0f,0xeb,0x68,0x07,0x00,0x54,0x7f,0x01,0x0e,0xeb,0x28,0x07,0x00,0x54,0x6b,0x05,0x00,0xd1,0x0f,0x04,0x80,0xd2,0x6b,0x7d,0x0f,0x9b,0xef,0x7c,0x40,0xf9,0xef,0x81,0x00,0x91,0x6b,0x01,0x0f,0x8b,0x6e,0x09,0x40,0xf9,0xdf,0x01,0x00,0xf1,0x00,0x06,0x00,0x54,0xaf,0x01,0x80,0xd2,0x4a,0x25,0xcf,0x9a,0x5f,0x01,0x0e,0xeb,0x81,0x05,0x00,0x54,0x6d,0x01,0x40,0xf9,0xbf,0x01,0x00,0xf1,0x20,0x05,0x00,0x54,0x6c,0x05,0x40,0xf9,0x6f,0x0d,0x40,0xf9,0xff,0x01,0x00,0xf1,0xa1,0x04,0x00,0x54,0xe0,0x03,0x0d,0xaa,0xe1,0x03,0x0c,0xaa,0x22,0x00,0x80,0xd2,0x23,0x02,0x80,0xd2,0xe4,0x07,0x40,0xf9,0x05,0x00,0x80,0xd2,0xc8,0x1b,0x80,0xd2,0x01,0x00,0x00,0xd4,0x1f,0x00,0x00,0xf1,0xeb,0x00,0x00,0x54,0x1f,0x00,0x0d,0xeb,0x21,0x03,0x00,0x54,0x2f,0x00,0x80,0xd2,0x6f,0x0d,0x00,0xf9,0x00,0x00,0x80,0xd2,0x0e,0x00,0x00,0x14,0xea,0x03,0x00,0xaa,0xe0,0x03,0x0d,0xaa,0xe1,0x03,0x0c,0xaa,0x8f,0x00,0x80,0xd2,0x6f,0x0d,0x00,0xf9,0xe8,0x1a,0x80,0xd2,0x01,0x00,0x00,0xd4,0x1f,0x00,0x00,0xf1,0x81,0x01,0x00,0x54,0x7f,0x01,0x00,0xf9,0x7f,0x05,0x00,0xf9,0x7f,0x0d,0x00,0xf9,0xe0,0x03,0x0a,0xaa,0xe1,0x07,0x40,0xf9,0xfe,0x0b,0x40,0xf9,0xff,0x83,0x00,0x91,0xc0,0x03,0x5f,0xd6,0xe0,0x03,0x07,0xaa,0xf0,0x08,0x40,0xf9,0x00,0x02,0x1f,0xd6,0x61,0x00,0x80,0xd2,0xfc,0xff,0xff,0x17,0xa1,0x00,0x80,0xd2,0xfa,0xff,0xff,0x17,0xff,0x43,0x00,0xd1,0xe0,0x03,0x00,0xf9,0xfe,0x07,0x00,0xf9,0xea,0x03,0x40,0xf9,0xef,0xff,0x83,0xd2,0x4b,0x01,0x0f,0x8a,0x7f,0x05,0x00,0xf1,0x43,0x05,0x00,0x54,0xee,0x7c,0x40,0xf9,0xce,0x01,0x40,0xf9,0xdf,0x05,0x00,0xf1,0xc3,0x04,0x00,0x54,0x4f,0x00,0x82,0xd2,0xdf,0x01,0x0f,0xeb,0x68,0x04,0x00,0x54,0x7f,0x01,0x0e,0xeb,0x28,0x04,0x00,0x54,0x6b,0x05,0x00,0xd1,0x0f,0x04,0x80,0xd2,0x6b,0x7d,0x0f,0x9b,0xef,0x7c,0x40,0xf9,0xef,0x81,0x00,0x91,0x6b,0x01,0x0f,0x8b,0x6e,0x09,0x40,0xf9,0xdf,0x01,0x00,0xf1,0x00,0x03,0x00,0x54,0xaf,0x01,0x80,0xd2,0x4a,0x25,0xcf,0x9a,0x5f,0x01,0x0e,0xeb,0x81,0x02,0x00,0x54,0x6d,0x01,0x40,0xf9,0xbf,0x01,0x00,0xf1,0x20,0x02,0x00,0x54,0x6c,0x05,0x40,0xf9,0xe0,0x03,0x0d,0xaa,0xe1,0x03,0x0c,0xaa,0xe8,0x1a,0x80,0xd2,0x01,0x00,0x00,0xd4,0x1f,0x00,0x00,0xf1,0x81,0x00,0x00,0x54,0x7f,0x01,0x00,0xf9,0x7f,0x05,0x00,0xf9,0x7f,0x0d,0x00,0xf9,0xfe,0x07,0x40,0xf9,0xff,0x43,0x00,0x91,0xc0,0x03,0x5f,0xd6,0xe0,0x03,0x07,0xaa,0xf0,0x08,0x40,0xf9,0x00,0x02,0x1f,0xd6,0x61,0x00,0x80,0xd2,0xfc,0xff,0xff,0x17,0xe4,0x03,0x03,0xaa,0x9f,0x00,0x00,0xf1,0x41,0x00,0x00,0x54,0x24,0x00,0x80,0xd2,0x05,0x00,0x80,0xd2,0x06,0x00,0x80,0xd2,0xbf,0x00,0x04,0xeb,0x02,0x0b,0x00,0x54,0x08,0x48,0x88,0xd2,0xe8,0x01,0xa0,0xf2,0xdf,0x00,0x08,0xeb,0xe2,0x0b,0x00,0x54,0xc6,0x04,0x00,0x91,0xff,0x43,0x01,0xd1,0xe0,0x03,0x00,0xf9,0xe1,0x07,0x00,0xf9,0xe2,0x0b,0x00,0xf9,0xe3,0x0f,0x00,0xf9,0xe4,0x13,0x00,0xf9,0xe5,0x17,0x00,0xf9,0xe6,0x1b,0x00,0xf9,0xe8,0x1f,0x00,0xf9,0xfe,0x23,0x00,0xf9,0xea,0x03,0x40,0xf9,0xef,0xff,0x83,0xd2,0x4b,0x01,0x0f,0x8a,0x7f,0x05,0x00,0xf1,0xa3,0x09,0x00,0x54,0xee,0x7c,0x40,0xf9,0xce,0x01,0x40,0xf9,0xdf,0x05,0x00,0xf1,0x23,0x09,0x00,0x54,0x4f,0x00,0x82,0xd2,0xdf,0x01,0x0f,0xeb,0xc8,0x08,0x00,0x54,0x7f,0x01,0x0e,0xeb,0x88,0x08,0x00,0x54,0x6b,0x05,0x00,0xd1,0x0f,0x04,0x80,0xd2,0x6b,0x7d,0x0f,0x9b,0xef,0x7c,0x40,0xf9,0xef,0x81,0x00,0x91,0x6b,0x01,0x0f,0x8b,0x6e,0x09,0x40,0xf9,0xdf,0x01,0x00,0xf1,0x60,0x07,0x00,0x54,0xaf,0x01,0x80,0xd2,0x4a,0x25,0xcf,0x9a,0x5f,0x01,0x0e,0xeb,0xe1,0x06,0x00,0x54,0x6d,0x01,0x40,0xf9,0xbf,0x01,0x00,0xf1,0x80,0x06,0x00,0x54,0x6c,0x05,0x40,0xf9,0xe0,0x07,0x40,0xf9,0x6f,0x0d,0x40,0xf9,0xff,0x01,0x00,0xf1,0xe0,0x05,0x00,0x54,0xff,0x0d,0x00,0xf1,0xa8,0x05,0x00,0x54,0x1f,0x00,0x0c,0xeb,0x68,0x05,0x00,0x54,0x8c,0x01,0x00,0xcb,0x9f,0x11,0x00,0xf1,0x03,0x05,0x00,0x54,0x6f,0x00,0x80,0xd2,0x0e,0x00,0x0f,0x8a,0xdf,0x01,0x00,0xf1,0x81,0x04,0x00,0x54,0xad,0x01,0x00,0x8b,0x9f,0x3f,0x03,0xd5,0xa0,0x01,0x40,0xb9,0x9f,0x3f,0x03,0xd5,0xe8,0x03,0x00,0xaa,0xe0,0x03,0x40,0xf9,0xe1,0x07,0x40,0xf9,0xe2,0x0b,0x40,0xf9,0xe3,0x0f,0x40,0xf9,0xe4,0x13,0x40,0xf9,0xe5,0x17,0x40,0xf9,0xe6,0x1b,0x40,0xf9,0xfe,0x23,0x40,0xf9,0xff,0x43,0x01,0x91,0x0a,0x01,0x02,0xcb,0xeb,0xff,0x9f,0xd2,0xeb,0xff,0xbf,0xf2,0x49,0x01,0x0b,0x8a,0x0a,0x00,0xb0,0xd2,0x3f,0x01,0x0a,0xeb,0x62,0x00,0x00,0x54,0x00,0x00,0x80,0xd2,0xc0,0x03,0x5f,0xd6,0x3f,0x20,0x03,0xd5,0xa5,0x04,0x00,0x91,0xa8,0xff,0xff,0x17,0x26,0x00,0x80,0xd2,0xe0,0x03,0x06,0xeb,0xa6,0x00,0x00,0x54,0xc0,0x03,0x5f,0xd6,0xe0,0x03,0x07,0xaa,0xf0,0x08,0x40,0xf9,0x00,0x02,0x1f,0xd6,0x21,0x00,0x80,0xd2,0xfc,0xff,0xff,0x17,0x61,0x00,0x80,0xd2,0xfa,0xff,0xff,0x17,0x81,0x00,0x80,0xd2,0xf8,0xff,0xff,0x17\n" OMBR_PREVIOUS); |
| 349 | static const char ombr2_ident_plat_wait[] = "omega-ident 1 unit=plat_wait abi=2 profile=OM-2 src=fd83645cd4f9e32c5777ebff47f64ea0f7bc288844d1946176cc24a5455ed91d omc=d1a3047153e14676c4baf9248fa2b88bb1b68c37cfeb71d76f30f5230c7d2765 host=mapdrop,mapget,maphold,mapbind"; |
| 350 | __attribute__((visibility("default"))) const char *omega2_ident_plat_wait(void) |
| 351 | { |
| 352 | return ombr2_ident_plat_wait; |
| 353 | } |
| 354 | __asm__(OMBR_CODE_SECTION ".balign 4\n" OMBR_LOCAL(ombr2_entry_plat_wait_budget) OMBR_HIDDEN(ombr2_entry_plat_wait_budget) OMBR_SYM(ombr2_entry_plat_wait_budget) ":\nhint #34\nb " OMBR_SYM(ombr2_code_plat_wait) "+0\n" OMBR_PREVIOUS); |
| 355 | extern const unsigned char ombr2_entry_plat_wait_budget[] __attribute__((visibility("hidden"))); |
| 356 | /* export fn plat_wait_budget ms ulong to ulong */ |
| 357 | __attribute__((visibility("default"))) uint32_t omega2_plat_wait_budget(uint64_t *result, uint64_t o_ms) |
| 358 | { |
| 359 | ombr_span sp[7]; |
| 360 | unsigned ns = 0; |
| 361 | uint64_t a[6] = {0}; |
| 362 | ombr2_out ou[6] = {{0, 0, 0}}; |
| 363 | unsigned no = 0; |
| 364 | if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1)) |
| 365 | return OMEGA_BAD_ARG; |
| 366 | a[0] = o_ms; |
| 367 | if (ombr2_overlap(sp, ns)) |
| 368 | return OMEGA_BAD_ARG; |
| 369 | return ombr2_run(&ombr_default, ombr2_entry_plat_wait_budget, a, result, 1, ou, no); |
| 370 | } |
| 371 | /* export fn plat_wait_budget ms ulong to ulong */ |
| 372 | __attribute__((visibility("default"))) uint32_t omega2_ctx_plat_wait_budget(omega_native_context *context, uint64_t *result, uint64_t o_ms) |
| 373 | { |
| 374 | ombr_span sp[7]; |
| 375 | unsigned ns = 0; |
| 376 | uint64_t a[6] = {0}; |
| 377 | ombr2_out ou[6] = {{0, 0, 0}}; |
| 378 | unsigned no = 0; |
| 379 | if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1)) |
| 380 | return OMEGA_BAD_ARG; |
| 381 | a[0] = o_ms; |
| 382 | if (ombr2_overlap(sp, ns)) |
| 383 | return OMEGA_BAD_ARG; |
| 384 | return ombr2_run(context, ombr2_entry_plat_wait_budget, a, result, 1, ou, no); |
| 385 | } |
| 386 | __asm__(OMBR_CODE_SECTION ".balign 4\n" OMBR_LOCAL(ombr2_entry_plat_wait_hold) OMBR_HIDDEN(ombr2_entry_plat_wait_hold) OMBR_SYM(ombr2_entry_plat_wait_hold) ":\nhint #34\nb " OMBR_SYM(ombr2_code_plat_wait) "+4\n" OMBR_PREVIOUS); |
| 387 | extern const unsigned char ombr2_entry_plat_wait_hold[] __attribute__((visibility("hidden"))); |
| 388 | /* export fn plat_wait_hold addr ulong n ulong to long */ |
| 389 | __attribute__((visibility("default"))) uint32_t omega2_plat_wait_hold(uint64_t *result, uint64_t o_addr, uint64_t o_n) |
| 390 | { |
| 391 | ombr_span sp[7]; |
| 392 | unsigned ns = 0; |
| 393 | uint64_t a[6] = {0}; |
| 394 | ombr2_out ou[6] = {{0, 0, 0}}; |
| 395 | unsigned no = 0; |
| 396 | if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1)) |
| 397 | return OMEGA_BAD_ARG; |
| 398 | a[0] = o_addr; |
| 399 | a[1] = o_n; |
| 400 | if (ombr2_overlap(sp, ns)) |
| 401 | return OMEGA_BAD_ARG; |
| 402 | return ombr2_run(&ombr_default, ombr2_entry_plat_wait_hold, a, result, 1, ou, no); |
| 403 | } |
| 404 | /* export fn plat_wait_hold addr ulong n ulong to long */ |
| 405 | __attribute__((visibility("default"))) uint32_t omega2_ctx_plat_wait_hold(omega_native_context *context, uint64_t *result, uint64_t o_addr, uint64_t o_n) |
| 406 | { |
| 407 | ombr_span sp[7]; |
| 408 | unsigned ns = 0; |
| 409 | uint64_t a[6] = {0}; |
| 410 | ombr2_out ou[6] = {{0, 0, 0}}; |
| 411 | unsigned no = 0; |
| 412 | if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1)) |
| 413 | return OMEGA_BAD_ARG; |
| 414 | a[0] = o_addr; |
| 415 | a[1] = o_n; |
| 416 | if (ombr2_overlap(sp, ns)) |
| 417 | return OMEGA_BAD_ARG; |
| 418 | return ombr2_run(context, ombr2_entry_plat_wait_hold, a, result, 1, ou, no); |
| 419 | } |
| 420 | __asm__(OMBR_CODE_SECTION ".balign 4\n" OMBR_LOCAL(ombr2_entry_plat_wait_bind) OMBR_HIDDEN(ombr2_entry_plat_wait_bind) OMBR_SYM(ombr2_entry_plat_wait_bind) ":\nhint #34\nb " OMBR_SYM(ombr2_code_plat_wait) "+8\n" OMBR_PREVIOUS); |
| 421 | extern const unsigned char ombr2_entry_plat_wait_bind[] __attribute__((visibility("hidden"))); |
| 422 | /* export fn plat_wait_bind handle long fd long to long */ |
| 423 | __attribute__((visibility("default"))) uint32_t omega2_plat_wait_bind(uint64_t *result, uint64_t o_handle, uint64_t o_fd) |
| 424 | { |
| 425 | ombr_span sp[7]; |
| 426 | unsigned ns = 0; |
| 427 | uint64_t a[6] = {0}; |
| 428 | ombr2_out ou[6] = {{0, 0, 0}}; |
| 429 | unsigned no = 0; |
| 430 | if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1)) |
| 431 | return OMEGA_BAD_ARG; |
| 432 | a[0] = o_handle; |
| 433 | a[1] = o_fd; |
| 434 | if (ombr2_overlap(sp, ns)) |
| 435 | return OMEGA_BAD_ARG; |
| 436 | return ombr2_run(&ombr_default, ombr2_entry_plat_wait_bind, a, result, 1, ou, no); |
| 437 | } |
| 438 | /* export fn plat_wait_bind handle long fd long to long */ |
| 439 | __attribute__((visibility("default"))) uint32_t omega2_ctx_plat_wait_bind(omega_native_context *context, uint64_t *result, uint64_t o_handle, uint64_t o_fd) |
| 440 | { |
| 441 | ombr_span sp[7]; |
| 442 | unsigned ns = 0; |
| 443 | uint64_t a[6] = {0}; |
| 444 | ombr2_out ou[6] = {{0, 0, 0}}; |
| 445 | unsigned no = 0; |
| 446 | if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1)) |
| 447 | return OMEGA_BAD_ARG; |
| 448 | a[0] = o_handle; |
| 449 | a[1] = o_fd; |
| 450 | if (ombr2_overlap(sp, ns)) |
| 451 | return OMEGA_BAD_ARG; |
| 452 | return ombr2_run(context, ombr2_entry_plat_wait_bind, a, result, 1, ou, no); |
| 453 | } |
| 454 | __asm__(OMBR_CODE_SECTION ".balign 4\n" OMBR_LOCAL(ombr2_entry_plat_wait_drop) OMBR_HIDDEN(ombr2_entry_plat_wait_drop) OMBR_SYM(ombr2_entry_plat_wait_drop) ":\nhint #34\nb " OMBR_SYM(ombr2_code_plat_wait) "+12\n" OMBR_PREVIOUS); |
| 455 | extern const unsigned char ombr2_entry_plat_wait_drop[] __attribute__((visibility("hidden"))); |
| 456 | /* export fn plat_wait_drop handle long to long */ |
| 457 | __attribute__((visibility("default"))) uint32_t omega2_plat_wait_drop(uint64_t *result, uint64_t o_handle) |
| 458 | { |
| 459 | ombr_span sp[7]; |
| 460 | unsigned ns = 0; |
| 461 | uint64_t a[6] = {0}; |
| 462 | ombr2_out ou[6] = {{0, 0, 0}}; |
| 463 | unsigned no = 0; |
| 464 | if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1)) |
| 465 | return OMEGA_BAD_ARG; |
| 466 | a[0] = o_handle; |
| 467 | if (ombr2_overlap(sp, ns)) |
| 468 | return OMEGA_BAD_ARG; |
| 469 | return ombr2_run(&ombr_default, ombr2_entry_plat_wait_drop, a, result, 1, ou, no); |
| 470 | } |
| 471 | /* export fn plat_wait_drop handle long to long */ |
| 472 | __attribute__((visibility("default"))) uint32_t omega2_ctx_plat_wait_drop(omega_native_context *context, uint64_t *result, uint64_t o_handle) |
| 473 | { |
| 474 | ombr_span sp[7]; |
| 475 | unsigned ns = 0; |
| 476 | uint64_t a[6] = {0}; |
| 477 | ombr2_out ou[6] = {{0, 0, 0}}; |
| 478 | unsigned no = 0; |
| 479 | if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1)) |
| 480 | return OMEGA_BAD_ARG; |
| 481 | a[0] = o_handle; |
| 482 | if (ombr2_overlap(sp, ns)) |
| 483 | return OMEGA_BAD_ARG; |
| 484 | return ombr2_run(context, ombr2_entry_plat_wait_drop, a, result, 1, ou, no); |
| 485 | } |
| 486 | __asm__(OMBR_CODE_SECTION ".balign 4\n" OMBR_LOCAL(ombr2_entry_plat_wait_ge) OMBR_HIDDEN(ombr2_entry_plat_wait_ge) OMBR_SYM(ombr2_entry_plat_wait_ge) ":\nhint #34\nb " OMBR_SYM(ombr2_code_plat_wait) "+16\n" OMBR_PREVIOUS); |
| 487 | extern const unsigned char ombr2_entry_plat_wait_ge[] __attribute__((visibility("hidden"))); |
| 488 | /* export fn plat_wait_ge handle long off ulong want ulong polls ulong to long */ |
| 489 | __attribute__((visibility("default"))) uint32_t omega2_plat_wait_ge(uint64_t *result, uint64_t o_handle, uint64_t o_off, uint64_t o_want, uint64_t o_polls) |
| 490 | { |
| 491 | ombr_span sp[7]; |
| 492 | unsigned ns = 0; |
| 493 | uint64_t a[6] = {0}; |
| 494 | ombr2_out ou[6] = {{0, 0, 0}}; |
| 495 | unsigned no = 0; |
| 496 | if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1)) |
| 497 | return OMEGA_BAD_ARG; |
| 498 | a[0] = o_handle; |
| 499 | a[1] = o_off; |
| 500 | a[2] = o_want; |
| 501 | a[3] = o_polls; |
| 502 | if (ombr2_overlap(sp, ns)) |
| 503 | return OMEGA_BAD_ARG; |
| 504 | return ombr2_run(&ombr_default, ombr2_entry_plat_wait_ge, a, result, 1, ou, no); |
| 505 | } |
| 506 | /* export fn plat_wait_ge handle long off ulong want ulong polls ulong to long */ |
| 507 | __attribute__((visibility("default"))) uint32_t omega2_ctx_plat_wait_ge(omega_native_context *context, uint64_t *result, uint64_t o_handle, uint64_t o_off, uint64_t o_want, uint64_t o_polls) |
| 508 | { |
| 509 | ombr_span sp[7]; |
| 510 | unsigned ns = 0; |
| 511 | uint64_t a[6] = {0}; |
| 512 | ombr2_out ou[6] = {{0, 0, 0}}; |
| 513 | unsigned no = 0; |
| 514 | if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1)) |
| 515 | return OMEGA_BAD_ARG; |
| 516 | a[0] = o_handle; |
| 517 | a[1] = o_off; |
| 518 | a[2] = o_want; |
| 519 | a[3] = o_polls; |
| 520 | if (ombr2_overlap(sp, ns)) |
| 521 | return OMEGA_BAD_ARG; |
| 522 | return ombr2_run(context, ombr2_entry_plat_wait_ge, a, result, 1, ou, no); |
| 523 | } |
| 524 | |
| 525 | #elif defined(__x86_64__) |
| 526 | #define OMBR_USES_MAPS 1 |
| 527 | /* Generated by omega-bridge src/native.om: native call ABI v1 (docs/NATIVE-ABI.md). |
| 528 | * The Omega machine code below is embedded byte for byte as the seeded compiler wrote it. |
| 529 | * This file only adapts the C calling convention to it. Regenerate it; do not edit it. */ |
| 530 | #include <pthread.h> |
| 531 | #include <signal.h> |
| 532 | #include <stdint.h> |
| 533 | #include <stdlib.h> |
| 534 | #include <sys/mman.h> |
| 535 | #define OMEGA_OK 0u |
| 536 | #define OMEGA_BAD_ARG 32u |
| 537 | #define OMEGA_REENTRY 33u |
| 538 | #define OMEGA_BAD_RT 34u |
| 539 | #define OMEGA_NO_STACK 35u |
| 540 | #define OMBR_STACK (8u << 20) |
| 541 | #define OMBR_GUARD (8u << 20) |
| 542 | /* entry[2] is the trap entry (OSC-1 section 7). */ |
| 543 | typedef struct ombr_rt { const void *entry[32]; } ombr_rt; |
| 544 | typedef struct ombr_span { uintptr_t lo, hi; int w; } ombr_span; |
| 545 | #define OMEGA_CONTEXT_BUSY 36u |
| 546 | typedef struct omega_native_context { |
| 547 | pthread_mutex_t lock; |
| 548 | uint64_t *maps; |
| 549 | const ombr_rt *rt; |
| 550 | } omega_native_context; |
| 551 | static _Alignas(16) uint64_t ombr_maps[516]; |
| 552 | static omega_native_context ombr_default = { .lock = PTHREAD_MUTEX_INITIALIZER, .maps = ombr_maps }; |
| 553 | static _Thread_local volatile sig_atomic_t ombr_active; |
| 554 | static _Thread_local unsigned char *ombr_stk; |
| 555 | static pthread_key_t ombr_key; |
| 556 | static int ombr_keyok; |
| 557 | static pthread_once_t ombr_once = PTHREAD_ONCE_INIT; |
| 558 | uint32_t plat_wt_ombr_enter(const void *code, const uint64_t *args, const ombr_rt *rt, uint64_t *out, void *top) |
| 559 | __attribute__((visibility("hidden"))); |
| 560 | extern const unsigned char plat_wt_ombr_trap[] __attribute__((visibility("hidden"))); |
| 561 | extern const unsigned char plat_wt_ombr_no_entry[] __attribute__((visibility("hidden"))); |
| 562 | /* The object format's spelling of the embedded code and runtime symbols. ELF keeps them local and hidden |
| 563 | * in .text.omega_bridge. Mach-O (macOS) prefixes C symbol names with an underscore and keeps them local |
| 564 | * by not declaring them .globl; .alt_entry keeps the runtime entries in plat_wt_ombr_enter's atom. */ |
| 565 | #if defined(__APPLE__) && defined(__MACH__) |
| 566 | #define OMBR_SYM(n) "_" #n |
| 567 | #define OMBR_LOCAL(n) "" |
| 568 | #define OMBR_HIDDEN(n) "" |
| 569 | #define OMBR_FUNC(n) "" |
| 570 | #define OMBR_ALT(n) ".alt_entry _" #n "\n" |
| 571 | #define OMBR_SIZE(n) "" |
| 572 | #define OMBR_LEAVE "Lombr_leave" |
| 573 | #define OMBR_CODE_SECTION ".section __TEXT,__text,regular,pure_instructions\n" |
| 574 | #define OMBR_PREVIOUS "" |
| 575 | #elif defined(__ELF__) |
| 576 | #define OMBR_SYM(n) #n |
| 577 | #define OMBR_LOCAL(n) ".local " #n "\n" |
| 578 | #define OMBR_HIDDEN(n) ".hidden " #n "\n" |
| 579 | #define OMBR_FUNC(n) ".type " #n ",%function\n" |
| 580 | #define OMBR_ALT(n) OMBR_FUNC(n) |
| 581 | #define OMBR_SIZE(n) ".size " #n ",.-" #n "\n" |
| 582 | #define OMBR_LEAVE "ombr_leave" |
| 583 | #define OMBR_CODE_SECTION ".section .text.omega_bridge,\"ax\",@progbits\n" |
| 584 | #define OMBR_PREVIOUS ".previous\n" |
| 585 | #else |
| 586 | #error "omega-bridge native binding: ELF or Mach-O objects only" |
| 587 | #endif |
| 588 | /* SysV AMD64 adapter to the pinned private Omega frame ABI. R12 anchors the native |
| 589 | * stack, R14 the runtime table, R15 the owned-stack floor. Hosted device helpers and legacy read/write preserve these reserved registers; |
| 590 | * the selected hosted compiler also restores its R13 argument-stack scratch. |
| 591 | * CET shadow-stack enforcement is not supported by the nonlocal trap return. */ |
| 592 | __asm__(".text\n.balign 16\n.local plat_wt_ombr_enter\n.hidden plat_wt_ombr_enter\n.type plat_wt_ombr_enter,@function\nplat_wt_ombr_enter:\n" |
| 593 | "endbr64\npush %rbx\npush %rbp\npush %r12\npush %r13\npush %r14\npush %r15\npush %rcx\n" |
| 594 | "mov %rsp,%r12\nmov %rdx,%r14\nmov %r9,%r15\nmov %rdi,%r10\n" |
| 595 | "mov %r8,%rbp\nmov %r8,%rsp\nsub $256,%rsp\n" |
| 596 | "mov 0(%rsi),%rax\nmov %rax,-8(%rbp)\nmov 8(%rsi),%rax\nmov %rax,-16(%rbp)\n" |
| 597 | "mov 16(%rsi),%rax\nmov %rax,-24(%rbp)\nmov 24(%rsi),%rax\nmov %rax,-32(%rbp)\n" |
| 598 | "mov 32(%rsi),%rax\nmov %rax,-40(%rbp)\nmov 40(%rsi),%rax\nmov %rax,-48(%rbp)\n" |
| 599 | "call *%r10\nmov %r12,%rsp\nmov (%rsp),%rcx\nmov %rax,(%rcx)\nxor %eax,%eax\n" |
| 600 | "ombr_leave:\nadd $8,%rsp\npop %r15\npop %r14\npop %r13\npop %r12\npop %rbp\npop %rbx\nret\n" |
| 601 | ".size plat_wt_ombr_enter,.-plat_wt_ombr_enter\n.local plat_wt_ombr_trap\n.hidden plat_wt_ombr_trap\n.type plat_wt_ombr_trap,@function\nplat_wt_ombr_trap:\n" |
| 602 | "endbr64\nmov %r12,%rsp\nlea -1(%rsi),%eax\ncmp $13,%eax\nmov $34,%eax\ncmovbe %esi,%eax\njmp ombr_leave\n" |
| 603 | ".size plat_wt_ombr_trap,.-plat_wt_ombr_trap\n.local plat_wt_ombr_no_entry\n.hidden plat_wt_ombr_no_entry\n.type plat_wt_ombr_no_entry,@function\nplat_wt_ombr_no_entry:\n" |
| 604 | "endbr64\nmov %r12,%rsp\nmov $34,%eax\njmp ombr_leave\n.size plat_wt_ombr_no_entry,.-plat_wt_ombr_no_entry\n"); |
| 605 | uint32_t ombr_xenter(const void *code, const uint64_t *args, const ombr_rt *rt, uint64_t *out, void *top, void *floor) __asm__("plat_wt_ombr_enter") __attribute__((visibility("hidden"))); |
| 606 | /* The true mapping floor must not move when ABI-v2 out buffers lower top. */ |
| 607 | #define plat_wt_ombr_enter(code,args,rt,out,top) ombr_xenter(code,args,rt,out,top,ombr_stk - OMBR_STACK) |
| 608 | static void ombr_free(void *p) |
| 609 | { |
| 610 | munmap(p, OMBR_STACK + OMBR_GUARD); |
| 611 | } |
| 612 | static void ombr_init(void) |
| 613 | { |
| 614 | ombr_keyok = pthread_key_create(&ombr_key, ombr_free) == 0; |
| 615 | } |
| 616 | /* The thread's Omega stack: OMBR_STACK usable bytes above an OMBR_GUARD no-access region. A function-mode |
| 617 | * unit has no call cycles and at most 4 MiB of local arrays per function (OMEGESE, local arrays), so a frame that |
| 618 | * would pass the bottom starts inside the guard and faults there; nothing below the guard is touched. */ |
| 619 | static unsigned char *ombr_stack(void) |
| 620 | { |
| 621 | if (ombr_stk) |
| 622 | return ombr_stk; |
| 623 | pthread_once(&ombr_once, ombr_init); |
| 624 | if (!ombr_keyok) |
| 625 | return 0; |
| 626 | unsigned char *p = mmap(0, OMBR_STACK + OMBR_GUARD, PROT_READ | PROT_WRITE, |
| 627 | MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0); |
| 628 | if (p == MAP_FAILED) |
| 629 | return 0; |
| 630 | if (mprotect(p, OMBR_GUARD, PROT_NONE) != 0 || pthread_setspecific(ombr_key, p) != 0) { |
| 631 | munmap(p, OMBR_STACK + OMBR_GUARD); |
| 632 | return 0; |
| 633 | } |
| 634 | ombr_stk = p + OMBR_GUARD + OMBR_STACK; |
| 635 | return ombr_stk; |
| 636 | } |
| 637 | static int ombr_span_add(ombr_span *sp, unsigned *ns, const void *p, uint64_t n, uint64_t want, uint64_t es, int w) |
| 638 | { |
| 639 | uintptr_t lo = (uintptr_t)p; |
| 640 | if (!p || n != want || lo % es != 0u || n > (UINTPTR_MAX - lo) / es) |
| 641 | return 1; |
| 642 | sp[*ns].lo = lo; |
| 643 | sp[*ns].hi = lo + n * es; |
| 644 | sp[*ns].w = w; |
| 645 | (*ns)++; |
| 646 | return 0; |
| 647 | } |
| 648 | static int ombr_overlap(const ombr_span *sp, unsigned ns) |
| 649 | { |
| 650 | for (unsigned i = 0; i < ns; i++) |
| 651 | for (unsigned j = i + 1; j < ns; j++) |
| 652 | if ((sp[i].w || sp[j].w) && sp[i].lo < sp[j].hi && sp[j].lo < sp[i].hi) |
| 653 | return 1; |
| 654 | return 0; |
| 655 | } |
| 656 | /* One read-only runtime table for every call and thread: the code only reads it (a write would fault). */ |
| 657 | static const ombr_rt ombr_rt_table = {{ plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_trap, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, plat_wt_ombr_no_entry, ombr_maps }}; |
| 658 | /* Explicit C ABI contexts: compatibility-runtime ownership, not driver policy. */ |
| 659 | static pthread_once_t ombr_map_once = PTHREAD_ONCE_INIT; |
| 660 | static pthread_mutex_t ombr_id_lock = PTHREAD_MUTEX_INITIALIZER; |
| 661 | static uint64_t ombr_next_context = 2; |
| 662 | static void ombr_map_init(void) |
| 663 | { |
| 664 | ombr_maps[0] = 128; |
| 665 | ombr_maps[1] = 67108864; |
| 666 | ombr_maps[2] = 134217727; |
| 667 | for (unsigned i = 0; i < 128; i++) |
| 668 | ombr_maps[4 + i * 4 + 2] = ombr_maps[1]; |
| 669 | ombr_default.rt = &ombr_rt_table; |
| 670 | } |
| 671 | __attribute__((visibility("default"))) uint32_t plat_wt_context_create(uint64_t capacity, |
| 672 | omega_native_context **out) |
| 673 | { |
| 674 | if (!out || capacity == 0 || capacity > 4098) |
| 675 | return OMEGA_BAD_ARG; |
| 676 | if (ombr_active) |
| 677 | return OMEGA_REENTRY; |
| 678 | if (pthread_mutex_lock(&ombr_id_lock) != 0) |
| 679 | return OMEGA_BAD_RT; |
| 680 | uint64_t id = ombr_next_context; |
| 681 | if (id <= 16777215) |
| 682 | ombr_next_context++; |
| 683 | int unlock_error = pthread_mutex_unlock(&ombr_id_lock); |
| 684 | if (unlock_error || id > 16777215) |
| 685 | return OMEGA_BAD_RT; |
| 686 | omega_native_context *c = calloc(1, sizeof *c); |
| 687 | if (!c) |
| 688 | return OMEGA_BAD_RT; |
| 689 | c->maps = calloc((size_t)capacity + 1u, 32u); |
| 690 | if (!c->maps) { |
| 691 | free(c); |
| 692 | return OMEGA_BAD_RT; |
| 693 | } |
| 694 | if (pthread_mutex_init(&c->lock, 0) != 0) { |
| 695 | free(c->maps); |
| 696 | free(c); |
| 697 | return OMEGA_BAD_RT; |
| 698 | } |
| 699 | ombr_rt *rt = mmap(0, sizeof *rt, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
| 700 | if (rt == MAP_FAILED) { |
| 701 | pthread_mutex_destroy(&c->lock); |
| 702 | free(c->maps); |
| 703 | free(c); |
| 704 | return OMEGA_BAD_RT; |
| 705 | } |
| 706 | *rt = ombr_rt_table; |
| 707 | rt->entry[31] = c->maps; |
| 708 | if (mprotect(rt, sizeof *rt, PROT_READ) != 0) { |
| 709 | munmap(rt, sizeof *rt); |
| 710 | pthread_mutex_destroy(&c->lock); |
| 711 | free(c->maps); |
| 712 | free(c); |
| 713 | return OMEGA_BAD_RT; |
| 714 | } |
| 715 | c->rt = rt; |
| 716 | c->maps[0] = capacity; |
| 717 | c->maps[1] = id << 26; |
| 718 | c->maps[2] = ((id + 1u) << 26) - 1u; |
| 719 | for (uint64_t i = 0; i < capacity; i++) |
| 720 | c->maps[4 + i * 4 + 2] = c->maps[1]; |
| 721 | *out = c; |
| 722 | return OMEGA_OK; |
| 723 | } |
| 724 | __attribute__((visibility("default"))) uint32_t plat_wt_context_destroy(omega_native_context *c) |
| 725 | { |
| 726 | if (!c || c == &ombr_default) |
| 727 | return OMEGA_BAD_ARG; |
| 728 | if (ombr_active) |
| 729 | return OMEGA_REENTRY; |
| 730 | /* Caller has joined/drained users and waiters before entering destruction. */ |
| 731 | if (pthread_mutex_lock(&c->lock) != 0) |
| 732 | return OMEGA_BAD_RT; |
| 733 | for (uint64_t i = 0; i < c->maps[0]; i++) { |
| 734 | if (c->maps[4 + i * 4] != 0) { |
| 735 | if (pthread_mutex_unlock(&c->lock) != 0) |
| 736 | return OMEGA_BAD_RT; |
| 737 | return OMEGA_CONTEXT_BUSY; |
| 738 | } |
| 739 | } |
| 740 | if (pthread_mutex_unlock(&c->lock) != 0 || pthread_mutex_destroy(&c->lock) != 0) |
| 741 | return OMEGA_BAD_RT; |
| 742 | int failed = munmap((void *)c->rt, sizeof *c->rt) != 0; |
| 743 | free(c->maps); |
| 744 | free(c); |
| 745 | return failed ? OMEGA_BAD_RT : OMEGA_OK; |
| 746 | } |
| 747 | static uint32_t ombr_context_lock(omega_native_context *c) |
| 748 | { |
| 749 | if (!c) |
| 750 | return OMEGA_BAD_ARG; |
| 751 | if (ombr_active) |
| 752 | return OMEGA_REENTRY; |
| 753 | ombr_active = 1; |
| 754 | if (c == &ombr_default && pthread_once(&ombr_map_once, ombr_map_init) != 0) { |
| 755 | ombr_active = 0; |
| 756 | return OMEGA_BAD_RT; |
| 757 | } |
| 758 | if (pthread_mutex_lock(&c->lock) != 0) { |
| 759 | ombr_active = 0; |
| 760 | return OMEGA_BAD_RT; |
| 761 | } |
| 762 | return OMEGA_OK; |
| 763 | } |
| 764 | static uint32_t ombr_context_unlock(omega_native_context *c, uint32_t status) |
| 765 | { |
| 766 | int failed = pthread_mutex_unlock(&c->lock); |
| 767 | ombr_active = 0; |
| 768 | return failed ? OMEGA_BAD_RT : status; |
| 769 | } |
| 770 | static uint32_t ombr_run(const void *code, const uint64_t *args, uint64_t *result, int has_value) |
| 771 | { |
| 772 | omega_native_context *context = &ombr_default; |
| 773 | uint32_t s = ombr_context_lock(context); |
| 774 | if (s != OMEGA_OK) |
| 775 | return s; |
| 776 | unsigned char *top = ombr_stack(); |
| 777 | if (!top) |
| 778 | return ombr_context_unlock(context, OMEGA_NO_STACK); |
| 779 | uint64_t v = 0; |
| 780 | s = plat_wt_ombr_enter(code, args, context->rt, &v, top); |
| 781 | if (s == OMEGA_OK) |
| 782 | *result = has_value ? v : 0u; |
| 783 | return ombr_context_unlock(context, s); |
| 784 | } |
| 785 | /* ABI v2 (docs/NATIVE-ABI.md, ABI v2): OM-2 units, bound as omega2_<export>. An unsized view is its |
| 786 | * pointer and its element count; a layout is a pointer to its fixed bytes; an out parameter is written |
| 787 | * to a buffer the binding owns and copied to the caller only after status 0. */ |
| 788 | #include <string.h> |
| 789 | typedef struct ombr2_out { unsigned slot; uint64_t n; void *dst; } ombr2_out; |
| 790 | /* A library of OM-2 units alone calls neither of the ABI v1 helpers. */ |
| 791 | __attribute__((unused)) static void ombr2_keep(void) |
| 792 | { |
| 793 | (void)ombr_overlap; |
| 794 | (void)ombr_run; |
| 795 | } |
| 796 | /* An unsized view of n elements of es bytes. n == 0 is the empty view whatever the pointer (it adds no |
| 797 | * range, so it overlaps nothing). Otherwise refused: a null pointer, a pointer not aligned to es, |
| 798 | * n * es over 64 bits, or an end past the top of the address space. */ |
| 799 | __attribute__((unused)) static int ombr2_view(ombr_span *sp, unsigned *ns, const void *p, uint64_t n, uint64_t es, int w) |
| 800 | { |
| 801 | uintptr_t lo = (uintptr_t)p; |
| 802 | if (n == 0u) |
| 803 | return 0; |
| 804 | if (!p || lo % es != 0u || n > UINT64_MAX / es || n * es > UINTPTR_MAX - lo) |
| 805 | return 1; |
| 806 | sp[*ns].lo = lo; |
| 807 | sp[*ns].hi = lo + n * es; |
| 808 | sp[*ns].w = w; |
| 809 | (*ns)++; |
| 810 | return 0; |
| 811 | } |
| 812 | /* A fixed range of nb > 0 bytes (a layout or an out parameter) aligned to es. */ |
| 813 | __attribute__((unused)) static int ombr2_fixed(ombr_span *sp, unsigned *ns, const void *p, uint64_t nb, uint64_t es, |
| 814 | int w) |
| 815 | { |
| 816 | uintptr_t lo = (uintptr_t)p; |
| 817 | if (!p || lo % es != 0u || nb > UINTPTR_MAX - lo) |
| 818 | return 1; |
| 819 | sp[*ns].lo = lo; |
| 820 | sp[*ns].hi = lo + nb; |
| 821 | sp[*ns].w = w; |
| 822 | (*ns)++; |
| 823 | return 0; |
| 824 | } |
| 825 | /* w: 0 view, 1 edit or the result, 2 out. Refused: an edit or the result overlapping any other range, |
| 826 | * or two out ranges overlapping. An out may overlap a view: it is written only after the code returns. */ |
| 827 | static int ombr2_overlap(const ombr_span *sp, unsigned ns) |
| 828 | { |
| 829 | for (unsigned i = 0; i < ns; i++) |
| 830 | for (unsigned j = i + 1; j < ns; j++) |
| 831 | if ((sp[i].w == 1 || sp[j].w == 1 || (sp[i].w == 2 && sp[j].w == 2)) |
| 832 | && sp[i].lo < sp[j].hi && sp[j].lo < sp[i].hi) |
| 833 | return 1; |
| 834 | return 0; |
| 835 | } |
| 836 | /* As ombr_run, and each out buffer is carved from the top of the thread's Omega stack (16-byte aligned, |
| 837 | * zero-filled), passed in its slot and copied to the caller with memmove only after status 0. */ |
| 838 | static uint32_t ombr2_run(omega_native_context *context, const void *code, uint64_t *args, uint64_t *result, int has_value, const ombr2_out *o, |
| 839 | unsigned no) |
| 840 | { |
| 841 | uint32_t s = ombr_context_lock(context); |
| 842 | if (s != OMEGA_OK) |
| 843 | return s; |
| 844 | unsigned char *top = ombr_stack(); |
| 845 | if (!top) |
| 846 | return ombr_context_unlock(context, OMEGA_NO_STACK); |
| 847 | unsigned char *buf[6] = {0}; |
| 848 | for (unsigned i = 0; i < no; i++) { |
| 849 | top -= (o[i].n + 15u) / 16u * 16u; |
| 850 | memset(top, 0, o[i].n); |
| 851 | buf[i] = top; |
| 852 | args[o[i].slot] = (uint64_t)(uintptr_t)top; |
| 853 | } |
| 854 | uint64_t v = 0; |
| 855 | s = plat_wt_ombr_enter(code, args, context->rt, &v, top); |
| 856 | if (s == OMEGA_OK) { |
| 857 | for (unsigned i = 0; i < no; i++) |
| 858 | memmove(o[i].dst, buf[i], o[i].n); |
| 859 | *result = has_value ? v : 0u; |
| 860 | } |
| 861 | return ombr_context_unlock(context, s); |
| 862 | } |
| 863 | __asm__(OMBR_CODE_SECTION ".balign 4\n" OMBR_LOCAL(ombr2_code_plat_wait) OMBR_HIDDEN(ombr2_code_plat_wait) OMBR_SYM(ombr2_code_plat_wait) ":\n.quad 0x02e99000000019e9,0x000683e990000001,0x9000000b86e99000,0x89499000000f4de9,0xec8148e5894855eb,0xf8838b4900000100,0xfff8858948ffffff,0xfffff8858b48ffff,0x0000000000b948ff,0x850fc83948000000,0x0000b8480000001a,0x8948000000000000,0x858b48fffffff885,0xb848c3c9fffffff8,0x0000000000000014,0x48ffffffe8858948,0x8b48fffffff8858b,0xaf0f48ffffffe88d,0xfffffff0858948c1,0x48fffffff0858b48,0x8b48fffffff08589,0x858948fffffff085,0x9c40b848fffffff0,0x8948000000000000,0x858b48ffffffe885,0xe88d8b48fffffff0,0x830fc83948ffffff,0xf0858b4800000017,0xfff8858948ffffff,0xfffff8858b48ffff,0x009c40b848c3c9ff,0x8589480000000000,0xf8858b48fffffff8,0xeb8949c3c9ffffff,0x00ec8148e5894855,0xfff8838b49000001,0xfffff8858948ffff,0xfffffff0838b49ff,0x48fffffff0858948,0x4cffffff0024848d,0x000004ce820ff839,0x4800000100ec8148,0x8948fffffff8858b,0x8b48000000002484,0x848948fffffff085,0x858b480000000824,0x24848948ffffffe8,0xe0858b4800000010,0x1824848948ffffff,0xffd8858b48000000,0x002024848948ffff,0xffffd0858b480000,0x00002824848948ff,0xffffffc8858b4800,0x0000003024848948,0x48ffffffc0858b48,0x4800000038248489,0x8948ffffffb8858b,0x8b48000000402484,0x848948ffffffb085,0x858b480000004824,0x24848948ffffffa8,0xa0858b4800000050,0x5824848948ffffff,0xff98858b48000000,0x006024848948ffff,0xffff90858b480000,0x00006824848948ff,0xffffff88858b4800,0x0000007024848948,0x48ffffff80858b48,0x4800000078248489,0x8948ffffff78858b,0x8b48000000802484,0x848948ffffff7085,0x848d480000008824,0xf8394cfffffef024,0x894c000003b1820f,0x89480000009024ac,0x00000008b38b48e3,0x00039f840ff68548,0x1000000000bb4900,0x870fde394c000000,0x00bb8b4800000395,0x010000bb49000000,0xdf394c0000000000,0xb84800000384820f,0x0000010000000000,0x870fc73948f02948,0x0fffb84800000377,0x8948000000000000,0x0fc98548c12148f9,0xf189480000036785,0x850fc98548c12148,0xffffb84900000361,0xb949ffffffffffff,0x0000000000000000,0x49000000f8ae8b4d,0xbb4900000000858b,0x0000000000000001,0x000335820fd8394c,0x0000001002bb4900,0x870fd8394c000000,0x10858b490000032b,0x000001bb49000000,0xd8394c0000000000,0xbb490000031a820f,0x0003ffffffffffff,0x000310870fd8394c,0x0000000020bb4900,0xba48dd014d000000,0x0000000000000001,0x4800000000858b49,0x0000001e850fc085,0x4d00000010958b4d,0x8b4d000000f89e8b,0xda394d000000109b,0xbb4900000041820f,0x0000000000000020,0x000001bb49dd014d,0xda014c0000000000,0x4d000000f89e8b4d,0x394c000000009b8b,0x48ffffffa1860fda,0xffffffffffffe8b8,0x4890000000fde9ff,0x4cffffffe024848d,0x00000282820ff839,0x4800000020ec8148,0x4800000000249489,0x4c0000000824b489,0x4800000010249489,0xba4800000000bb8b,0x0000000000000000,0x000000100022ba49,0x00000009b8480000,0x8548050f00000000,0x48000000958c0fc0,0x394800000000938b,0x4800000030840fd0,0x000824b48b48c789,0x0000000bb8480000,0x8548050f00000000,0x480000020c850fc0,0xffffffffffffa1b8,0x499000000056e9ff,0x8b48000000008589,0x8949000000082494,0x948b480000000895,0x01bb490000001024,0x4c00000000000000,0x000010958949da01,0x0000000000b84800,0x0018858949000000,0xe0c148d089480000,0x00000024948b480d,0x20c48148d0094800,0x0090ab8b4c000000,0xfffff88589480000,0x00000824848b48ff,0xfffffff085894800,0x0000001024848b48,0x48ffffffe8858948,0x480000001824848b,0x8b48ffffffe08589,0x8948000000202484,0x848b48ffffffd885,0x8589480000002824,0x24848b48ffffffd0,0xc885894800000030,0x3824848b48ffffff,0xffc0858948000000,0x004024848b48ffff,0xffffb88589480000,0x00004824848b48ff,0xffffffb085894800,0x0000005024848b48,0x48ffffffa8858948,0x480000005824848b,0x8b48ffffffa08589,0x8948000000602484,0x848b48ffffff9885,0x8589480000006824,0x24848b48ffffff90,0x8885894800000070,0x7824848b48ffffff,0xff80858948000000,0x008024848b48ffff,0xffff788589480000,0x00008824848b48ff,0xffffff7085894800,0x4800000100c48148,0x8948fffffff8858b,0x858b48fffffff885,0x06bec3c9fffffff8,0xbe1066ff41000000,0x1066ff4100000006,0x66ff4100000003be,0xff4100000003be10,0x4100000003be1066,0x00000003be1066ff,0x000003be1066ff41,0x0003be1066ff4100,0x03be1066ff410000,0xbe1066ff41000000,0x1066ff4100000003,0x66ff4100000003be,0xff4100000003be10,0x4100000006be1066,0x00000003be1066ff,0x55eb89491066ff41,0x0100ec8148e58948,0xfffff8838b490000,0xfffffff8858948ff,0x48fffffff0838b49,0x8b48fffffff08589,0xc28948fffffff085,0x20f8c14820e0c148,0x000446850fd03948,0xffff0024848d4800,0x043e820ff8394cff,0x000100ec81480000,0xfffffff8858b4800,0x0000000024848948,0x48fffffff0858b48,0x4800000008248489,0x8948ffffffe8858b,0x8b48000000102484,0x848948ffffffe085,0x858b480000001824,0x24848948ffffffd8,0xd0858b4800000020,0x2824848948ffffff,0xffc8858b48000000,0x003024848948ffff,0xffffc0858b480000,0x00003824848948ff,0xffffffb8858b4800,0x0000004024848948,0x48ffffffb0858b48,0x4800000048248489,0x8948ffffffa8858b,0x8b48000000502484,0x848948ffffffa085,0x858b480000005824,0x24848948ffffff98,0x90858b4800000060,0x6824848948ffffff,0xff88858b48000000,0x007024848948ffff,0xffff80858b480000,0x00007824848948ff,0xffffff78858b4800,0x0000008024848948,0x48ffffff70858b48,0x4800000088248489,0x4cfffffef024848d,0x00000321820ff839,0x0000009024ac894c,0x0000938b4ce38948,0xffb848d5894d0000,0x490000000000001f,0x00000001bb49c521,0x0fdd394d00000000,0x868b49000002f582,0x00808b48000000f8,0x000001bb49000000,0xd8394c0000000000,0xbb49000002dd820f,0x0000000000001002,0x0002d3870fd8394c,0x02d3870fc5394900,0x00000001bb490000,0x49dd294d00000000,0x00f8868b4905e5c1,0x00000020bb490000,0x49d8014c00000000,0x0000108d8b4dc501,0x02a4840fc9854d00,0x394d0deac1490000,0x4d000002a0850fca,0x854d00000000858b,0x4d00000299840fc0,0x8b49000000088d8b,0xc085480000001885,0x8d480000028b850f,0x394cffffffe02484,0x4800000283820ff8,0x894c00000020ec81,0x894c000000002484,0x894c00000008248c,0x08838b4cce894cc7,0x000000b949000000,0x01ba480000000000,0x4900000000000000,0x00000000000011ba,0x0000000009b84800,0xc08548050f000000,0x8b48000000328c0f,0x3948000000002494,0x4800000224850fd0,0x00000000000001b8,0x0000001885894900,0x000000000000b848,0x9000000066e90000,0x0000001024848948,0x000000000004b848,0x0000188589490000,0x00000024bc8b4800,0x00000824b48b4800,0x000000000bb84800,0xc08548050f000000,0xb848000001ce850f,0x0000000000000000,0x4900000000858949,0x8949000000088589,0x848b480000001885,0xc481480000001024,0x90ab8b4c00000020,0xfff8858948000000,0x000824848b48ffff,0xfffff08589480000,0x00001024848b48ff,0xffffffe885894800,0x0000001824848b48,0x48ffffffe0858948,0x480000002024848b,0x8b48ffffffd88589,0x8948000000282484,0x848b48ffffffd085,0x8589480000003024,0x24848b48ffffffc8,0xc085894800000038,0x4024848b48ffffff,0xffb8858948000000,0x004824848b48ffff,0xffffb08589480000,0x00005024848b48ff,0xffffffa885894800,0x0000005824848b48,0x48ffffffa0858948,0x480000006024848b,0x8b48ffffff988589,0x8948000000682484,0x848b48ffffff9085,0x8589480000007024,0x24848b48ffffff88,0x8085894800000078,0x8024848b48ffffff,0xff78858948000000,0x008824848b48ffff,0xffff708589480000,0x00000100c48148ff,0x48fffffff8858b48,0x8b48fffffff88589,0xbec3c9fffffff885,0x1066ff4100000005,0x66ff4100000006be,0xff4100000006be10,0x4100000003be1066,0x00000003be1066ff,0x000003be1066ff41,0x0003be1066ff4100,0x03be1066ff410000,0xbe1066ff41000000,0x1066ff4100000003,0x66ff4100000003be,0xff4100000003be10,0x4100000006be1066,0x00000003be1066ff,0x000003be1066ff41,0xeb89491066ff4100,0x00ec8148e5894855,0xfff8838b49000001,0xfffff8858948ffff,0xffff0024848d48ff,0x034f820ff8394cff,0x000100ec81480000,0xfffffff8858b4800,0x0000000024848948,0x48fffffff0858b48,0x4800000008248489,0x8948ffffffe8858b,0x8b48000000102484,0x848948ffffffe085,0x858b480000001824,0x24848948ffffffd8,0xd0858b4800000020,0x2824848948ffffff,0xffc8858b48000000,0x003024848948ffff,0xffffc0858b480000,0x00003824848948ff,0xffffffb8858b4800,0x0000004024848948,0x48ffffffb0858b48,0x4800000048248489,0x8948ffffffa8858b,0x8b48000000502484,0x848948ffffffa085,0x858b480000005824,0x24848948ffffff98,0x90858b4800000060,0x6824848948ffffff,0xff88858b48000000,0x007024848948ffff,0xffff80858b480000,0x00007824848948ff,0xffffff78858b4800,0x0000008024848948,0x48ffffff70858b48,0x4800000088248489,0x4cfffffef024848d,0x00000232820ff839,0x0000009024ac894c,0x0000938b4ce38948,0xffb848d5894d0000,0x490000000000001f,0x00000001bb49c521,0x0fdd394d00000000,0x868b490000020682,0x00808b48000000f8,0x000001bb49000000,0xd8394c0000000000,0xbb49000001ee820f,0x0000000000001002,0x0001e4870fd8394c,0x01e4870fc5394900,0x00000001bb490000,0x49dd294d00000000,0x00f8868b4905e5c1,0x00000020bb490000,0x49d8014c00000000,0x0000108d8b4dc501,0x01b5840fc9854d00,0x394d0deac1490000,0x4d000001b1850fca,0x854d00000000858b,0x4d000001aa840fc0,0x894c000000088d8b,0x000bb848ce894cc7,0x050f000000000000,0x000015850fc08548,0x0000000085894900,0x4900000008858949,0x8b4c000000188589,0x85894800000090ab,0x24848b48fffffff8,0xf085894800000008,0x1024848b48ffffff,0xffe8858948000000,0x001824848b48ffff,0xffffe08589480000,0x00002024848b48ff,0xffffffd885894800,0x0000002824848b48,0x48ffffffd0858948,0x480000003024848b,0x8b48ffffffc88589,0x8948000000382484,0x848b48ffffffc085,0x8589480000004024,0x24848b48ffffffb8,0xb085894800000048,0x5024848b48ffffff,0xffa8858948000000,0x005824848b48ffff,0xffffa08589480000,0x00006024848b48ff,0xffffff9885894800,0x0000006824848b48,0x48ffffff90858948,0x480000007024848b,0x8b48ffffff888589,0x8948000000782484,0x848b48ffffff8085,0x8589480000008024,0x24848b48ffffff78,0x7085894800000088,0x0100c48148ffffff,0xfffff8858b480000,0xfffffff8858948ff,0xc9fffffff8858b48,0xff4100000006bec3,0x4100000006be1066,0x00000003be1066ff,0x000003be1066ff41,0x0003be1066ff4100,0x03be1066ff410000,0xbe1066ff41000000,0x1066ff4100000003,0x66ff4100000003be,0xff4100000003be10,0x894855eb89491066,0x00000100ec8148e5,0x48fffffff8838b49,0x8b49fffffff88589,0x858948fffffff083,0xe8838b49fffffff0,0xffe8858948ffffff,0xffffe0838b49ffff,0xffffffe0858948ff,0x48ffffffe0858b48,0x8b48ffffffd88589,0x00b948ffffffd885,0x4800000000000000,0x00000011850fc839,0x000000000001b848,0xffffd88589480000,0x0000000000b848ff,0xffd0858948000000,0x00000000b848ffff,0xc885894800000000,0xffd0858b48ffffff,0xffffd88d8b48ffff,0x04ba830fc83948ff,0xffffc8858b480000,0x00000f4240b948ff,0x830fc83948000000,0xc8858b48000004df,0x000001b948ffffff,0xc801480000000000,0x48ffffffc8858948,0x8948ffffffc8858b,0x848d48ffffffc885,0xf8394cffffff0024,0x8148000004ae820f,0x858b4800000100ec,0x24848948fffffff8,0xf0858b4800000000,0x0824848948ffffff,0xffe8858b48000000,0x001024848948ffff,0xffffe0858b480000,0x00001824848948ff,0xffffffd8858b4800,0x0000002024848948,0x48ffffffd0858b48,0x4800000028248489,0x8948ffffffc8858b,0x8b48000000302484,0x848948ffffffc085,0x858b480000003824,0x24848948ffffffb8,0xb0858b4800000040,0x4824848948ffffff,0xffa8858b48000000,0x005024848948ffff,0xffffa0858b480000,0x00005824848948ff,0xffffff98858b4800,0x0000006024848948,0x48ffffff90858b48,0x4800000068248489,0x8948ffffff88858b,0x8b48000000702484,0x848948ffffff8085,0x858b480000007824,0x24848948ffffff78,0x70858b4800000080,0x8824848948ffffff,0xf024848d48000000,0x820ff8394cfffffe,0x24ac894c00000391,0x4ce3894800000090,0x894d00000000938b,0x0000001fffb848d5,0xbb49c52149000000,0x0000000000000001,0x000365820fdd394d,0x000000f8868b4900,0x4900000000808b48,0x00000000000001bb,0x034d820fd8394c00,0x00001002bb490000,0x0fd8394c00000000,0xc539490000034387,0xbb4900000343870f,0x0000000000000001,0x4905e5c149dd294d,0xbb49000000f8868b,0x0000000000000020,0x8b4dc50149d8014c,0xc9854d000000108d,0xc14900000314840f,0x10850fca394d0dea,0x0000858b4d000003,0x09840fc0854d0000,0x00088d8b4d000003,0x000008938b480000,0x00000018858b4900,0x0002f4840fc08548,0x0000000003bb4900,0x870fd8394c000000,0x0fca394c000002ea,0xd12949000002ea87,0x000000000004bb49,0xdd820fd9394d0000,0xb948d08948000002,0x0000000000000003,0x850fc08548c82148,0x0fd00149000002cd,0x000000808b41f0ae,0x90ab8b4cf0ae0f00,0xffb8858948000000,0x000024848b48ffff,0xfffff88589480000,0x00000824848b48ff,0xfffffff085894800,0x0000001024848b48,0x48ffffffe8858948,0x480000001824848b,0x8b48ffffffe08589,0x8948000000202484,0x848b48ffffffd885,0x8589480000002824,0x24848b48ffffffd0,0xc885894800000030,0x3824848b48ffffff,0xffc0858948000000,0x004824848b48ffff,0xffffb08589480000,0x00005024848b48ff,0xffffffa885894800,0x0000005824848b48,0x48ffffffa0858948,0x480000006024848b,0x8b48ffffff988589,0x8948000000682484,0x848b48ffffff9085,0x8589480000007024,0x24848b48ffffff88,0x8085894800000078,0x8024848b48ffffff,0xff78858948000000,0x008824848b48ffff,0xffff708589480000,0x00000100c48148ff,0x48ffffffb8858b48,0x8b48ffffffb88589,0x8d8b48ffffffb885,0x48c82948ffffffe8,0x8b48ffffffa88589,0x858948ffffffa885,0xffffb848ffffffa8,0x894800000000ffff,0x858b48ffffffa085,0xa08d8b48ffffffa8,0x8948c82148ffffff,0x858b48ffffffb085,0xb0858948ffffffb0,0x000000b848ffffff,0x8589480000000080,0xb0858b48ffffffa8,0xffa88d8b48ffffff,0x1a830fc83948ffff,0x000000b848000000,0x8589480000000000,0xf8858b48fffffff8,0x4890f3c3c9ffffff,0xb948ffffffd0858b,0x0000000000000001,0xffd0858948c80148,0xffffd0858b48ffff,0xffffffd0858948ff,0x48ffffffd0858b48,0x30e9ffffffd08589,0x0001b84890fffffb,0x8948000000000000,0x858b48ffffffc885,0x0fd8f748ffffffc8,0x858948000000a580,0xf8858b48fffffff8,0xfff8858948ffffff,0xfffff8858b48ffff,0x00000004bec3c9ff,0x000006be1066ff41,0x0006be1066ff4100,0x03be1066ff410000,0xbe1066ff41000000,0x1066ff4100000003,0x66ff4100000003be,0xff4100000003be10,0x4100000003be1066,0x00000003be1066ff,0x000003be1066ff41,0x0003be1066ff4100,0x03be1066ff410000,0xbe1066ff41000000,0x1066ff4100000003,0x66ff4100000003be,0xff4100000003be10,0x4100000001be1066\n.byte 0xff,0x66,0x10\n" OMBR_PREVIOUS); |
| 864 | static const char ombr2_ident_plat_wait[] = "omega-ident 1 unit=plat_wait abi=2 profile=OM-2 src=fd83645cd4f9e32c5777ebff47f64ea0f7bc288844d1946176cc24a5455ed91d omc=cf4fcbbb4752c5dd0652b426c0f2d08f82e380e8fc6f5114acf51a4c077bb579 host=mapdrop,mapget,maphold,mapbind"; |
| 865 | __attribute__((visibility("default"))) const char *omega2_ident_plat_wait(void) |
| 866 | { |
| 867 | return ombr2_ident_plat_wait; |
| 868 | } |
| 869 | __asm__(OMBR_CODE_SECTION ".balign 4\n" OMBR_LOCAL(ombr2_entry_plat_wait_budget) OMBR_HIDDEN(ombr2_entry_plat_wait_budget) OMBR_SYM(ombr2_entry_plat_wait_budget) ":\nendbr64\njmp " OMBR_SYM(ombr2_code_plat_wait) "+0\n" OMBR_PREVIOUS); |
| 870 | extern const unsigned char ombr2_entry_plat_wait_budget[] __attribute__((visibility("hidden"))); |
| 871 | /* export fn plat_wait_budget ms ulong to ulong */ |
| 872 | __attribute__((visibility("default"))) uint32_t omega2_plat_wait_budget(uint64_t *result, uint64_t o_ms) |
| 873 | { |
| 874 | ombr_span sp[7]; |
| 875 | unsigned ns = 0; |
| 876 | uint64_t a[6] = {0}; |
| 877 | ombr2_out ou[6] = {{0, 0, 0}}; |
| 878 | unsigned no = 0; |
| 879 | if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1)) |
| 880 | return OMEGA_BAD_ARG; |
| 881 | a[0] = o_ms; |
| 882 | if (ombr2_overlap(sp, ns)) |
| 883 | return OMEGA_BAD_ARG; |
| 884 | return ombr2_run(&ombr_default, ombr2_entry_plat_wait_budget, a, result, 1, ou, no); |
| 885 | } |
| 886 | /* export fn plat_wait_budget ms ulong to ulong */ |
| 887 | __attribute__((visibility("default"))) uint32_t omega2_ctx_plat_wait_budget(omega_native_context *context, uint64_t *result, uint64_t o_ms) |
| 888 | { |
| 889 | ombr_span sp[7]; |
| 890 | unsigned ns = 0; |
| 891 | uint64_t a[6] = {0}; |
| 892 | ombr2_out ou[6] = {{0, 0, 0}}; |
| 893 | unsigned no = 0; |
| 894 | if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1)) |
| 895 | return OMEGA_BAD_ARG; |
| 896 | a[0] = o_ms; |
| 897 | if (ombr2_overlap(sp, ns)) |
| 898 | return OMEGA_BAD_ARG; |
| 899 | return ombr2_run(context, ombr2_entry_plat_wait_budget, a, result, 1, ou, no); |
| 900 | } |
| 901 | __asm__(OMBR_CODE_SECTION ".balign 4\n" OMBR_LOCAL(ombr2_entry_plat_wait_hold) OMBR_HIDDEN(ombr2_entry_plat_wait_hold) OMBR_SYM(ombr2_entry_plat_wait_hold) ":\nendbr64\njmp " OMBR_SYM(ombr2_code_plat_wait) "+6\n" OMBR_PREVIOUS); |
| 902 | extern const unsigned char ombr2_entry_plat_wait_hold[] __attribute__((visibility("hidden"))); |
| 903 | /* export fn plat_wait_hold addr ulong n ulong to long */ |
| 904 | __attribute__((visibility("default"))) uint32_t omega2_plat_wait_hold(uint64_t *result, uint64_t o_addr, uint64_t o_n) |
| 905 | { |
| 906 | ombr_span sp[7]; |
| 907 | unsigned ns = 0; |
| 908 | uint64_t a[6] = {0}; |
| 909 | ombr2_out ou[6] = {{0, 0, 0}}; |
| 910 | unsigned no = 0; |
| 911 | if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1)) |
| 912 | return OMEGA_BAD_ARG; |
| 913 | a[0] = o_addr; |
| 914 | a[1] = o_n; |
| 915 | if (ombr2_overlap(sp, ns)) |
| 916 | return OMEGA_BAD_ARG; |
| 917 | return ombr2_run(&ombr_default, ombr2_entry_plat_wait_hold, a, result, 1, ou, no); |
| 918 | } |
| 919 | /* export fn plat_wait_hold addr ulong n ulong to long */ |
| 920 | __attribute__((visibility("default"))) uint32_t omega2_ctx_plat_wait_hold(omega_native_context *context, uint64_t *result, uint64_t o_addr, uint64_t o_n) |
| 921 | { |
| 922 | ombr_span sp[7]; |
| 923 | unsigned ns = 0; |
| 924 | uint64_t a[6] = {0}; |
| 925 | ombr2_out ou[6] = {{0, 0, 0}}; |
| 926 | unsigned no = 0; |
| 927 | if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1)) |
| 928 | return OMEGA_BAD_ARG; |
| 929 | a[0] = o_addr; |
| 930 | a[1] = o_n; |
| 931 | if (ombr2_overlap(sp, ns)) |
| 932 | return OMEGA_BAD_ARG; |
| 933 | return ombr2_run(context, ombr2_entry_plat_wait_hold, a, result, 1, ou, no); |
| 934 | } |
| 935 | __asm__(OMBR_CODE_SECTION ".balign 4\n" OMBR_LOCAL(ombr2_entry_plat_wait_bind) OMBR_HIDDEN(ombr2_entry_plat_wait_bind) OMBR_SYM(ombr2_entry_plat_wait_bind) ":\nendbr64\njmp " OMBR_SYM(ombr2_code_plat_wait) "+12\n" OMBR_PREVIOUS); |
| 936 | extern const unsigned char ombr2_entry_plat_wait_bind[] __attribute__((visibility("hidden"))); |
| 937 | /* export fn plat_wait_bind handle long fd long to long */ |
| 938 | __attribute__((visibility("default"))) uint32_t omega2_plat_wait_bind(uint64_t *result, uint64_t o_handle, uint64_t o_fd) |
| 939 | { |
| 940 | ombr_span sp[7]; |
| 941 | unsigned ns = 0; |
| 942 | uint64_t a[6] = {0}; |
| 943 | ombr2_out ou[6] = {{0, 0, 0}}; |
| 944 | unsigned no = 0; |
| 945 | if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1)) |
| 946 | return OMEGA_BAD_ARG; |
| 947 | a[0] = o_handle; |
| 948 | a[1] = o_fd; |
| 949 | if (ombr2_overlap(sp, ns)) |
| 950 | return OMEGA_BAD_ARG; |
| 951 | return ombr2_run(&ombr_default, ombr2_entry_plat_wait_bind, a, result, 1, ou, no); |
| 952 | } |
| 953 | /* export fn plat_wait_bind handle long fd long to long */ |
| 954 | __attribute__((visibility("default"))) uint32_t omega2_ctx_plat_wait_bind(omega_native_context *context, uint64_t *result, uint64_t o_handle, uint64_t o_fd) |
| 955 | { |
| 956 | ombr_span sp[7]; |
| 957 | unsigned ns = 0; |
| 958 | uint64_t a[6] = {0}; |
| 959 | ombr2_out ou[6] = {{0, 0, 0}}; |
| 960 | unsigned no = 0; |
| 961 | if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1)) |
| 962 | return OMEGA_BAD_ARG; |
| 963 | a[0] = o_handle; |
| 964 | a[1] = o_fd; |
| 965 | if (ombr2_overlap(sp, ns)) |
| 966 | return OMEGA_BAD_ARG; |
| 967 | return ombr2_run(context, ombr2_entry_plat_wait_bind, a, result, 1, ou, no); |
| 968 | } |
| 969 | __asm__(OMBR_CODE_SECTION ".balign 4\n" OMBR_LOCAL(ombr2_entry_plat_wait_drop) OMBR_HIDDEN(ombr2_entry_plat_wait_drop) OMBR_SYM(ombr2_entry_plat_wait_drop) ":\nendbr64\njmp " OMBR_SYM(ombr2_code_plat_wait) "+18\n" OMBR_PREVIOUS); |
| 970 | extern const unsigned char ombr2_entry_plat_wait_drop[] __attribute__((visibility("hidden"))); |
| 971 | /* export fn plat_wait_drop handle long to long */ |
| 972 | __attribute__((visibility("default"))) uint32_t omega2_plat_wait_drop(uint64_t *result, uint64_t o_handle) |
| 973 | { |
| 974 | ombr_span sp[7]; |
| 975 | unsigned ns = 0; |
| 976 | uint64_t a[6] = {0}; |
| 977 | ombr2_out ou[6] = {{0, 0, 0}}; |
| 978 | unsigned no = 0; |
| 979 | if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1)) |
| 980 | return OMEGA_BAD_ARG; |
| 981 | a[0] = o_handle; |
| 982 | if (ombr2_overlap(sp, ns)) |
| 983 | return OMEGA_BAD_ARG; |
| 984 | return ombr2_run(&ombr_default, ombr2_entry_plat_wait_drop, a, result, 1, ou, no); |
| 985 | } |
| 986 | /* export fn plat_wait_drop handle long to long */ |
| 987 | __attribute__((visibility("default"))) uint32_t omega2_ctx_plat_wait_drop(omega_native_context *context, uint64_t *result, uint64_t o_handle) |
| 988 | { |
| 989 | ombr_span sp[7]; |
| 990 | unsigned ns = 0; |
| 991 | uint64_t a[6] = {0}; |
| 992 | ombr2_out ou[6] = {{0, 0, 0}}; |
| 993 | unsigned no = 0; |
| 994 | if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1)) |
| 995 | return OMEGA_BAD_ARG; |
| 996 | a[0] = o_handle; |
| 997 | if (ombr2_overlap(sp, ns)) |
| 998 | return OMEGA_BAD_ARG; |
| 999 | return ombr2_run(context, ombr2_entry_plat_wait_drop, a, result, 1, ou, no); |
| 1000 | } |
| 1001 | __asm__(OMBR_CODE_SECTION ".balign 4\n" OMBR_LOCAL(ombr2_entry_plat_wait_ge) OMBR_HIDDEN(ombr2_entry_plat_wait_ge) OMBR_SYM(ombr2_entry_plat_wait_ge) ":\nendbr64\njmp " OMBR_SYM(ombr2_code_plat_wait) "+24\n" OMBR_PREVIOUS); |
| 1002 | extern const unsigned char ombr2_entry_plat_wait_ge[] __attribute__((visibility("hidden"))); |
| 1003 | /* export fn plat_wait_ge handle long off ulong want ulong polls ulong to long */ |
| 1004 | __attribute__((visibility("default"))) uint32_t omega2_plat_wait_ge(uint64_t *result, uint64_t o_handle, uint64_t o_off, uint64_t o_want, uint64_t o_polls) |
| 1005 | { |
| 1006 | ombr_span sp[7]; |
| 1007 | unsigned ns = 0; |
| 1008 | uint64_t a[6] = {0}; |
| 1009 | ombr2_out ou[6] = {{0, 0, 0}}; |
| 1010 | unsigned no = 0; |
| 1011 | if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1)) |
| 1012 | return OMEGA_BAD_ARG; |
| 1013 | a[0] = o_handle; |
| 1014 | a[1] = o_off; |
| 1015 | a[2] = o_want; |
| 1016 | a[3] = o_polls; |
| 1017 | if (ombr2_overlap(sp, ns)) |
| 1018 | return OMEGA_BAD_ARG; |
| 1019 | return ombr2_run(&ombr_default, ombr2_entry_plat_wait_ge, a, result, 1, ou, no); |
| 1020 | } |
| 1021 | /* export fn plat_wait_ge handle long off ulong want ulong polls ulong to long */ |
| 1022 | __attribute__((visibility("default"))) uint32_t omega2_ctx_plat_wait_ge(omega_native_context *context, uint64_t *result, uint64_t o_handle, uint64_t o_off, uint64_t o_want, uint64_t o_polls) |
| 1023 | { |
| 1024 | ombr_span sp[7]; |
| 1025 | unsigned ns = 0; |
| 1026 | uint64_t a[6] = {0}; |
| 1027 | ombr2_out ou[6] = {{0, 0, 0}}; |
| 1028 | unsigned no = 0; |
| 1029 | if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1)) |
| 1030 | return OMEGA_BAD_ARG; |
| 1031 | a[0] = o_handle; |
| 1032 | a[1] = o_off; |
| 1033 | a[2] = o_want; |
| 1034 | a[3] = o_polls; |
| 1035 | if (ombr2_overlap(sp, ns)) |
| 1036 | return OMEGA_BAD_ARG; |
| 1037 | return ombr2_run(context, ombr2_entry_plat_wait_ge, a, result, 1, ou, no); |
| 1038 | } |
| 1039 | |
| 1040 | #else |
| 1041 | #error "platform omega units require Linux AArch64 or x86-64" |
| 1042 | #endif |