Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/native/kernel/ui/boot_show.h # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / native / kernel / ui / boot_show.h` 64 lines ยท 3717 bytes Raw Blame History 1 /* boot_show.h -- the boot sequence on any screen: the night (ui/night.c, two 2 * black holes circling and merging) drawn by Allen's home (ui/allen_ui.c), 3 * with its chirp (ui/chirp.c) kept in time by the same clock. One module for 4 * every image: the x86 kernel (iMac, PC, the aienos-run VM) and the aarch64 5 * kernel (Spark, Pi 5, the aienos-run VM). The caller hands in the pixels 6 * (a linear GOP framebuffer, or a virtio-gpu resource's backing) and, 7 * where the screen needs one, a present hook that shows a drawn frame. 8 * 9 * It also keeps the receipt: frames drawn against the 60 Hz beat a screen 10 * refreshes at. Every 1/60 s slot of the night that ends without a new frame 11 * counts as one dropped frame (the screen showed the old picture again). 12 * Integer only, freestanding; host tested in ui/tests/boot_show_test.c. */ 13 #ifndef AIENOS_BOOT_SHOW_H 14 #define AIENOS_BOOT_SHOW_H 15 #include 16 #include 17 #include "chirp.h" 18 #include "night.h" 19 20 #define CK_BOOT_SHOW_HZ 60u /* the beat frames are counted against */ 21 #define CK_BOOT_SHOW_MS CK_NIGHT_GONE_MS /* the night is over: the last black hole has dissolved */ 22 /* 60 Hz slots in the night: 912 */ 23 #define CK_BOOT_SHOW_SLOTS (CK_BOOT_SHOW_MS * CK_BOOT_SHOW_HZ / 1000u) 24 25 struct ck_boot_show_stats { 26 uint32_t frames; /* frames drawn while the night played */ 27 uint32_t slots; /* 60 Hz slots the night has run through so far */ 28 uint32_t dropped; /* slots that ended with no new frame */ 29 uint32_t average_us; /* drawing time per frame (present included) */ 30 uint32_t slowest_us; 31 uint32_t ms; /* the night's clock at the last tick */ 32 }; 33 34 /* Called after every drawn frame with the frame's dirty area unknown: the 35 * hook shows the whole picture (virtio-gpu: transfer and flush). NULL for a 36 * linear framebuffer the screen scans out by itself. */ 37 typedef void (*ck_boot_present_fn)(void *ctx); 38 39 /* Starts the night on fb (w x h, pitch in pixels, format 0 RGBX / 1 BGRX) 40 * with mem = ck_allen_ui_mem_bytes(w, h) bytes; hz = ticks a second of clock, 41 * now = clock() at the night's 0 ms. 0, or -1 (as ck_allen_ui_start). */ 42 int ck_boot_show_start(volatile uint32_t *fb, uint32_t w, uint32_t h, uint32_t pitch, uint32_t format, void *mem, 43 size_t mem_len, uint64_t hz, uint64_t now, uint64_t (*clock)(void), ck_boot_present_fn present, 44 void *ctx); 45 /* Draws a frame when one is due. Returns 1 while the night plays, 0 once 46 * CK_BOOT_SHOW_MS has passed (the counts are then final). */ 47 int ck_boot_show_tick(uint64_t now); 48 /* Milliseconds on the night's clock (0 before start). */ 49 uint32_t ck_boot_show_ms(uint64_t now); 50 /* The chirp frame (CK_CHIRP_RATE) the night has reached: the sound driver 51 * starts its stream here so the sound lands on the merger. */ 52 uint32_t ck_boot_show_audio_frame(uint64_t now); 53 void ck_boot_show_stats(struct ck_boot_show_stats *s); 54 55 /* One receipt line, the same on every machine (printed by the caller): 56 * ck_printf(CK_BOOT_SHOW_LINE, CK_BOOT_SHOW_ARGS(st, w, h, how)); */ 57 #define CK_BOOT_SHOW_LINE \ 58 "boot-show: %ux%u via %s: %u frames in %u ms, %u of %u slots at 60 Hz dropped, %u.%u fps, draw avg %u us " \ 59 "slowest %u us\n" 60 #define CK_BOOT_SHOW_ARGS(st, w, h, how) \ 61 (w), (h), (how), (st).frames, (st).ms, (st).dropped, (st).slots, \ 62 (st).ms ? (st).frames * 1000u / (st).ms : 0u, (st).ms ? (st).frames * 10000u / (st).ms % 10u : 0u, \ 63 (st).average_us, (st).slowest_us 64 #endif