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/core/boot_screen.c # 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 / core / boot_screen.c` 76 lines ยท 3090 bytes Raw Blame History 1 /* boot_screen.c -- the boot sequence on the aarch64 kernel (boot_screen.h). */ 2 #include "boot_screen.h" 3 #include "devices.h" 4 #include "../ui/allen_ui.h" 5 #include "../ui/boot_show.h" 6 #include "arch.h" 7 #include "ck.h" 8 #include "ck_internal.h" 9 #include "virtio_gpu.h" 10 #include "virtio_snd.h" 11 #include "../../boot/handoff.h" 12 13 /* The largest picture the night is drawn at: its drawing memory comes from 14 * the kernel heap (17 MiB at this size), the VM picture from the DMA pool. */ 15 #define BOOT_SCREEN_MAX_W 1920u 16 #define BOOT_SCREEN_MAX_H 1080u 17 18 static uint64_t counter(void) { return ck_rd(cntvct_el0); } 19 20 void ck_boot_screen_run(void) 21 { 22 const pci_system *pci = ck_dev_pci(); 23 volatile uint32_t *fb = 0; 24 uint32_t w = 0, h = 0, pitch = 0, format = 1; 25 ck_boot_present_fn present = 0; 26 const char *how = "gop"; 27 if (pci && ck_vgpu_open(pci, BOOT_SCREEN_MAX_W, BOOT_SCREEN_MAX_H, &fb, &w, &h) == 0) { 28 pitch = w, format = 1, present = ck_vgpu_present, how = "virtio-gpu"; 29 } else { 30 const struct ck_handoff *hd = ck_handoff_get(); 31 const struct ck_mm_report *mm = ck_mm_report(); 32 if (!hd || hd->fb_status != CK_HANDOFF_FB_PRESENT || mm->fb_map != CK_MM_FB_MAPPED) { 33 ck_puts("boot-show: skipped (no screen: no virtio-gpu, no linear GOP framebuffer)\n"); 34 return; 35 } 36 fb = (volatile uint32_t *)(uintptr_t)hd->fb_base; 37 w = hd->fb_width < BOOT_SCREEN_MAX_W ? hd->fb_width : BOOT_SCREEN_MAX_W; 38 h = hd->fb_height < BOOT_SCREEN_MAX_H ? hd->fb_height : BOOT_SCREEN_MAX_H; 39 pitch = hd->fb_pitch, format = hd->fb_format; 40 } 41 size_t need = ck_allen_ui_mem_bytes(w, h); 42 void *mem = ck_alloc(need); 43 if (!mem) { 44 ck_printf("boot-show: skipped (no %zu KiB of drawing memory for %ux%u)\n", need >> 10, w, h); 45 return; 46 } 47 int snd = pci ? ck_vsnd_open(pci) : -1; 48 uint64_t hz = ck_rd(cntfrq_el0); 49 ck_console_fb_pause(); 50 if (ck_boot_show_start(fb, w, h, pitch, format, mem, need, hz, counter(), counter, present, 0)) { 51 ck_console_fb_resume(); 52 ck_printf("boot-show: skipped (screen %ux%u pitch %u format %u refused)\n", w, h, pitch, format); 53 ck_free(mem); 54 return; 55 } 56 ck_printf("boot-show: the night starts on %ux%u (%s)\n", w, h, how); 57 int playing = 1, sounding = snd == 0; 58 while (playing || sounding) { 59 uint64_t now = counter(); 60 if (!playing && ck_boot_show_ms(now) > CK_BOOT_SHOW_MS + 2000u) { 61 ck_puts("sound: the speakers stopped answering; chirp abandoned 2 s after the night\n"); 62 break; 63 } 64 if (playing) 65 playing = ck_boot_show_tick(now); 66 if (sounding) 67 sounding = ck_vsnd_step(ck_boot_show_ms(now), ck_boot_show_audio_frame(now)); 68 } 69 ck_console_fb_resume(); 70 struct ck_boot_show_stats st; 71 ck_boot_show_stats(&st); 72 ck_printf(CK_BOOT_SHOW_LINE, CK_BOOT_SHOW_ARGS(st, w, h, how)); 73 if (snd) 74 ck_puts("sound: none for the chirp (no virtio-sound); the night played silent\n"); 75 ck_free(mem); 76 }