omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / src / runtime / rx_resident_gpu.h
| 1 | /* SPDX-License-Identifier: Apache-2.0 |
| 2 | * Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef RX_RESIDENT_GPU_H |
| 18 | #define RX_RESIDENT_GPU_H |
| 19 | |
| 20 | #include "rx_world.h" |
| 21 | |
| 22 | /* Words in the seat's heartbeat block, as byte offsets from its start. */ |
| 23 | #define RX_SEAT_HB_HOLD 8u /* processor writes nonzero: seat holds its claim */ |
| 24 | #define RX_SEAT_HB_HELD 12u /* seat writes claim sequence + 1 before the hold */ |
| 25 | #define RX_SEAT_HB_LIVE 16u /* seat writes a moving count on every pass */ |
| 26 | /* R15 timing words, written by the seat for the claim it is serving. */ |
| 27 | #define RX_SEAT_HB_T_PICK 20u /* chip %globaltimer (low 32 bits, ns) at pickup */ |
| 28 | #define RX_SEAT_HB_T_DONE 24u /* chip %globaltimer when the result is written */ |
| 29 | #define RX_SEAT_HB_CLAIM 28u /* ring index of the claim those stamps belong to */ |
| 30 | #define RX_SEAT_HB_LEASE 32u /* processor bumps it while its process lives */ |
| 31 | #define RX_SEAT_HB_BUDGET 36u /* passes the seat waits for a new lease */ |
| 32 | /* A lease value that asks the seat to leave at once. */ |
| 33 | #define RX_SEAT_LEASE_QUIT 0xffffffffu |
| 34 | |
| 35 | /* One persistent graphics seat on the world's existing image. |
| 36 | * A null out and a nonzero return means the chip was not started. |
| 37 | * A non-null out must be finished, whether or not the seat was observed. */ |
| 38 | typedef struct RxGpuSeat RxGpuSeat; |
| 39 | |
| 40 | int rx_gpu_seat_begin(RxWorld *w, RxGpuSeat **out); |
| 41 | int rx_gpu_seat_finish(RxGpuSeat *seat); |
| 42 | |
| 43 | /* What the host read when the seat left: both words, so a stale or missing read is visible. */ |
| 44 | typedef struct { int marker_ok, sem_ok; uint32_t marker_value, sem_value; } RxGpuSeatLeave; |
| 45 | int rx_gpu_seat_finish_ex(RxGpuSeat *seat, RxGpuSeatLeave *leave); |
| 46 | |
| 47 | /* Destroy the seat's channel while it runs, as a fault would. When this |
| 48 | * returns the chip no longer writes the image; the image stays mapped and |
| 49 | * bound. The caller then declares the seat lost to the world. */ |
| 50 | int rx_gpu_seat_kill(RxGpuSeat *seat); |
| 51 | |
| 52 | /* After a kill: build a new channel on the same device and memory and launch |
| 53 | * a new seat on the same image, taking the world's current seat generation. */ |
| 54 | int rx_gpu_seat_relaunch(RxGpuSeat *seat); |
| 55 | |
| 56 | #endif |