input, fb, vt, sysfs: the kernel calls Xorg makes

Xorg on a framebuffer -- the fbdev video driver, the evdev input driver,
libpciaccess -- asks the kernel a fixed set of questions before it draws
anything, and gives up on the first wrong answer. These are those
answers.

evdev: EVIOCGVERSION, GID, GNAME, GPHYS, GUNIQ, GPROP, GBIT, GKEY, GABS,
GREP and the accepted setters. Xorg and libinput decide what a device
*is* from the capability bitmaps; /dev/input/eventN answered only
EVIOCGRAB, which reads as no device at all. Each device's bitmaps are
its defaults plus whatever it has reported, so a USB tablet makes the
pointer absolute.

fbdev: FBIOPUT_VSCREENINFO succeeds for the mode already set, as on
Linux -- the fbdev driver sets it every time it starts -- and still
refuses any other. FBIOPAN_DISPLAY to the origin; FBIOBLANK.

The console: KDSETMODE(KD_GRAPHICS) stops it drawing on a terminal,
KDSKBMODE(K_OFF) stops keys reaching its tty, and VT_PROCESS now does
the switch handshake: leaving the terminal sends relsig and waits for
VT_RELDISP, arriving sends acqsig. A terminal whose owner has died goes
back to the kernel whole, so a crashed X cannot leave the console dead.

/sys: boot_vga, a writable enable, and graphics/fb0 under the display
device, which is how the fbdev driver pairs a card with /dev/fb0.

ports/linux-headers: <linux/*.h> into musl's prefix, from sabotage-
linux's kernel-headers 4.19.88-2. Its checksum is recorded from the
first download; upstream publishes none.

cmd/xready makes each call and checks the answer, including the switch
handshake on tty2 and an owner that dies holding it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1giNvrHTrPMPw7V6x1kQ4
This commit is contained in:
Nexoniarz 2026-10-24 12:06:04 +02:00
commit b1323e193a
14 changed files with 860 additions and 32 deletions

View file

@ -0,0 +1,52 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Linux's userspace headers -- GPL-2.0 WITH Linux-syscall-note, which is the
# exception that makes them includable by anything: https://kernel.org/
#
# <linux/input.h>, <linux/fb.h>, <linux/kd.h>, <linux/vt.h> and the rest are
# how a program spells the ioctls SchOS answers in Linux's numbering, and
# Xorg, libevdev and libinput include them without asking whether the kernel
# underneath is Linux. Taken from sabotage-linux's kernel-headers: the
# headers alone, sanitised, a megabyte rather than a kernel tree.
#
# Installed into musl's prefix, next to libc's own, because that is where
# every port already looks. Not scsi/: musl ships its own scsi/*.h, and these
# would overwrite them. Nothing goes into sysroot/ -- headers are build input.
include ../mk/port.mk
LH_VERSION := 4.19.88-2
LH_URL := https://github.com/sabotage-linux/kernel-headers/releases/download/v$(LH_VERSION)/linux-headers-$(LH_VERSION).tar.xz
# Recorded on first download; upstream publishes no checksum to compare with.
LH_SHA256 := dc7abf734487553644258a3822cfd429d74656749e309f2b25f09f4282e05588
TARBALL := $(DISTDIR)/linux-headers-$(LH_VERSION).tar.xz
STAMP := $(MUSL)/include/linux/input.h
$(TARBALL): | $(DISTDIR)
curl -fsSL -o $@ $(LH_URL)
sh $(SHA256CHECK) "$(LH_SHA256)" "$@"
download: $(TARBALL)
$(SRCDIR): $(TARBALL)
mkdir -p $(PORTDIR)
rm -rf $@ $(PORTDIR)/linux-headers-$(LH_VERSION)
tar -xJf $< -C $(PORTDIR)
mv $(PORTDIR)/linux-headers-$(LH_VERSION) $@
# A file in the prefix as the target, not a stamp here: musl's prefix is
# rebuilt from scratch when musl is, and the headers have to come back with it.
$(STAMP): | $(SRCDIR)
test -d $(MUSL)/include || { echo "linux-headers: build musl first"; exit 1; }
cd $(SRCDIR)/x86/include && for d in *; do \
[ "$$d" = scsi ] && continue; \
mkdir -p $(MUSL)/include/$$d && cp -R $$d/. $(MUSL)/include/$$d/; \
done
build install: $(STAMP)
clean:
rm -rf $(PORTDIR)
distclean: clean
rm -f $(TARBALL)