#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/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 FBIOBLANK 0x4611 // 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]; };