SchOS/include/gfx/fb.h
Nexoniarz 906318f2b6 X on the console: /dev/tty0, a palette, and startx that works
Xorg finds its VT through /dev/tty0, and without one ran on none: the
console went on drawing into the framebuffer over the X screen. tty0 is
the terminal on screen, as on Linux. FBIOPUTCMAP succeeds, as it does on
a true-colour Linux framebuffer, instead of 256 logged errors per start.

schos-base gives root a .xserverrc with -dumbSched, Xorg's switch for
input on the main loop: SchOS has no threads, and Xorg crashed in
pthread_join on its input thread when the first client left. It adds
the hostname to /etc/hosts, so xauth can resolve schos:0.

zsh loses PROMPT_SP: on a serial terminal narrower than the console its
padding wrapped and left a # above every prompt. bootcheck knows zsh's
prompt and matches without colour codes, so busybox's ls reads as text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1giNvrHTrPMPw7V6x1kQ4
2026-10-24 19:44:10 +02:00

97 lines
3.7 KiB
C

#pragma once
// Framebuffer device ABI -- /dev/fb0.
//
// These are Linux's fbdev request numbers and structure layouts, not ours.
// SchOS invented this device, so nothing forced the choice; matching Linux
// was still the right one. A framebuffer is the first thing a graphics
// program looks for, and every such program already knows how to ask
// FBIOGET_VSCREENINFO. Inventing a private struct would have meant patching
// each one we ever port, and -- worse -- a Linux-ABI binary calling
// FBIOGET_VSCREENINFO would have gotten a *differently shaped* answer to a
// request it thought it understood, which is the failure mode that made
// `>>` truncate back when include/uapi/fcntl.h held xv6's open flags instead of
// Linux's. Same lesson, applied before it bites rather than after.
//
// Plain C types throughout (no types.h) so userspace can include this
// directly. Both sides are LP64.
#define FBIOGET_VSCREENINFO 0x4600
#define FBIOPUT_VSCREENINFO 0x4601
#define FBIOGET_FSCREENINFO 0x4602
#define FBIOPUTCMAP 0x4605
#define FBIOBLANK 0x4611
#define FBIOPAN_DISPLAY 0x4606
// fb_fix_screeninfo.type
#define FB_TYPE_PACKED_PIXELS 0
// fb_fix_screeninfo.visual
#define FB_VISUAL_TRUECOLOR 2
// fb_var_screeninfo.activate
#define FB_ACTIVATE_NOW 0
// One colour channel's position within a pixel. `offset` is the bit position
// of the channel's least significant bit; `length` is how many bits it gets.
// A length of 0 means the channel does not exist -- which is how an opaque
// framebuffer reports `transp`.
struct fb_bitfield {
unsigned int offset;
unsigned int length;
unsigned int msb_right; // != 0 means bit 0 is the MSB; never here
};
struct fb_var_screeninfo {
unsigned int xres; // visible resolution
unsigned int yres;
unsigned int xres_virtual; // virtual resolution; == visible, no panning
unsigned int yres_virtual;
unsigned int xoffset; // offset of visible area within virtual
unsigned int yoffset;
unsigned int bits_per_pixel;
unsigned int grayscale; // 0 == colour
struct fb_bitfield red;
struct fb_bitfield green;
struct fb_bitfield blue;
struct fb_bitfield transp;
unsigned int nonstd; // 0 == standard pixel format
unsigned int activate;
unsigned int height; // physical size in mm; 0 == unknown, and
unsigned int width; // VBE does not tell us, so it stays 0
unsigned int accel_flags;
// Timings. The mode is whatever the bootloader's VBE call established and
// we cannot change it, so these are all reported as zero rather than
// invented.
unsigned int pixclock;
unsigned int left_margin;
unsigned int right_margin;
unsigned int upper_margin;
unsigned int lower_margin;
unsigned int hsync_len;
unsigned int vsync_len;
unsigned int sync;
unsigned int vmode;
unsigned int rotate;
unsigned int colorspace;
unsigned int reserved[4];
};
struct fb_fix_screeninfo {
char id[16]; // "schosfb"
unsigned long smem_start; // physical address of the framebuffer
unsigned int smem_len; // its length in bytes
unsigned int type;
unsigned int type_aux;
unsigned int visual;
unsigned short xpanstep; // 0 == panning unsupported
unsigned short ypanstep;
unsigned short ywrapstep;
unsigned int line_length; // bytes per scanline (the VBE stride, which
// is NOT always xres * bytes_per_pixel)
unsigned long mmio_start; // no separate register aperture
unsigned int mmio_len;
unsigned int accel; // no acceleration
unsigned short capabilities;
unsigned short reserved[2];
};