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/fbcon.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 / core / fbcon.h` 75 lines ยท 3599 bytes Raw Blame History 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 /* fbcon.h -- text console on a linear 32-bit framebuffer (the UEFI GOP 18 * framebuffer the boot stub hands over in the CHANDOF3 record). 19 * 20 * Pure layout and drawing: no globals, no I/O besides the pixel stores, so 21 * the kernel (core/console.c, framebuffer mapped Device-nGnRE) and the host 22 * checker (tools/ck_fb_check.c, a malloc'd buffer) run the same code and 23 * the checker can render the exact screen a serial log must produce. 24 * 25 * Layout: 8x8 glyphs (core/font8x8.h) in cells of 8 x 10 pixels times an 26 * integer scale; white on black. Scrolling is "half-scroll": when the 27 * bottom row is full, the screen is cleared and the newest half of the rows 28 * is redrawn at the top from a text copy kept here (no read-back of device 29 * memory), so the screen always shows at least half a screen of the latest 30 * lines, in order, and each line is drawn about twice. A newline is applied 31 * lazily, when the next character arrives, so the last line of a 32 * run stays on screen. Long lines wrap. Bytes outside 0x20..0x7e (except 33 * '\n', '\r', '\t') are drawn as '?'. */ 34 #ifndef AIENOS_CK_FBCON_H 35 #define AIENOS_CK_FBCON_H 36 #include 37 #include 38 39 #define CK_FBCON_CELL_W 8 /* times scale */ 40 #define CK_FBCON_CELL_H 10 /* 8 glyph rows + 2 blank rows, times scale */ 41 #define CK_FBCON_FG 0x00ffffffu /* white in both RGBX and BGRX */ 42 #define CK_FBCON_BG 0x00000000u 43 #define CK_FBCON_MAX_COLS 256 /* text copy; wider screens leave the right edge black */ 44 #define CK_FBCON_MAX_ROWS 256 45 46 struct ck_fbcon { 47 volatile uint32_t *px; /* pixel (0,0) */ 48 uint32_t width, height; /* visible pixels */ 49 uint32_t pitch; /* pixels per scan line */ 50 uint32_t format; /* 0 RGBX, 1 BGRX (EFI_GRAPHICS_PIXEL_FORMAT) */ 51 uint32_t scale, cols, rows; 52 uint32_t col, row; 53 int pending_nl; /* a '\n' not yet applied */ 54 uint64_t scrolls; /* half-scrolls so far */ 55 char text[CK_FBCON_MAX_ROWS][CK_FBCON_MAX_COLS]; /* what each cell shows, 0 = never written */ 56 }; 57 58 /* Scale for a screen: height / 540 clamped to 1..4, lowered until at least 59 * 80 columns fit (1920x1080 -> 2, 3840x2160 -> 4, 800x600 -> 1). */ 60 uint32_t ck_fbcon_scale_for(uint32_t width, uint32_t height); 61 62 /* Sets up c for the framebuffer and clears the visible area. Returns -1 63 * (and touches no pixel) when the geometry cannot hold one cell or the 64 * format is not 0/1. */ 65 int ck_fbcon_setup(struct ck_fbcon *c, volatile uint32_t *px, uint32_t width, uint32_t height, 66 uint32_t pitch, uint32_t format); 67 /* The same without touching a pixel: the screen keeps what is on it until 68 * the first clear or write. */ 69 int ck_fbcon_attach(struct ck_fbcon *c, volatile uint32_t *px, uint32_t width, uint32_t height, 70 uint32_t pitch, uint32_t format); 71 72 void ck_fbcon_clear(struct ck_fbcon *c); 73 void ck_fbcon_write(struct ck_fbcon *c, const char *s, size_t n); 74 75 #endif