# keelOS display VM (docs/22 "核显直通" §7): kernel config fragment.
# build.sh runs `make allnoconfig KCONFIG_ALLCONFIG=<this + generated lines>` on an unmodified
# upstream kernel and then checks that every line below made it into .config unchanged
# (a dependency that silently drops an option fails the build). x86_64 only.
# build.sh adds: CONFIG_INITRAMFS_SOURCE, CONFIG_EXTRA_FIRMWARE, CONFIG_EXTRA_FIRMWARE_DIR.

CONFIG_64BIT=y
CONFIG_EXPERT=y
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
CONFIG_KERNEL_ZSTD=y
CONFIG_PRINTK=y
CONFIG_BUG=y
CONFIG_MULTIUSER=y
CONFIG_SHMEM=y
CONFIG_FUTEX=y
CONFIG_BINFMT_ELF=y
CONFIG_DMI=y
CONFIG_MTRR=y
CONFIG_X86_PAT=y
# Tickless when idle: the mirror loop sleeps 15-100 ms, a periodic 250 Hz tick would wake the
# vCPU 250 times a second for nothing (57% of a CPU in the nested test bed, docs/22 §7 D2a).
CONFIG_NO_HZ_IDLE=y

# Built-in command line; the boot loader's (none from the firmware's fallback boot) is appended.
# console=tty1: kernel messages only on the screen, never on COM1 (that is the host's login terminal).
CONFIG_CMDLINE_BOOL=y
CONFIG_CMDLINE="console=ttyS0,115200 loglevel=6 consoleblank=0 panic=10"
# CONFIG_CMDLINE_OVERRIDE is not set

# Boot: EFI stub, built-in initramfs (uncompressed; the kernel image is compressed as a whole).
CONFIG_EFI=y
CONFIG_EFI_STUB=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_COMPRESSION_NONE=y
CONFIG_ACPI=y
CONFIG_PCI=y
CONFIG_PCI_MSI=y

# Pseudo file systems for init.
CONFIG_DEVTMPFS=y
CONFIG_PROC_FS=y
CONFIG_SYSFS=y

# Mirror mode (D2a): the region bhyve's keel.mirror fills is found through fw_cfg (bhyve's ACPI
# device QEMU0002 with -o lpc.fwcfg=qemu) and read through /dev/mem. It is an E820 "reserved"
# range, not RAM; STRICT_DEVMEM is off anyway (nothing else runs in this guest) so that a test
# region in a PCI BAR (QEMU's ivshmem, qemu-test.py) is not refused either.
CONFIG_DEVMEM=y
# CONFIG_STRICT_DEVMEM is not set
CONFIG_FW_CFG_SYSFS=y

# Terminals: the screen's virtual terminal and COM1 (8250 at 0x3f8). The virtual terminal and
# fbcon are for dvm.mode=serial (D1) and the kernel's messages until init runs; in mirror mode
# init puts tty1 into graphics mode (KD_GRAPHICS) and fbcon draws nothing.
CONFIG_TTY=y
CONFIG_VT=y
CONFIG_CONSOLE_TRANSLATIONS=y
CONFIG_VT_CONSOLE=y
# CONFIG_VGA_CONSOLE is not set
CONFIG_SERIAL_8250=y
# Not used by default (console=tty1); lets `console=ttyS0` show the kernel log on the host's side when debugging.
CONFIG_SERIAL_8250_CONSOLE=y
CONFIG_SERIAL_8250_NR_UARTS=4
CONFIG_SERIAL_8250_RUNTIME_UARTS=4

# Keyboards: PS/2 (bhyve's atkbd) and USB HID behind xHCI (bhyve's USB keyboard/tablet).
CONFIG_INPUT=y
CONFIG_INPUT_KEYBOARD=y
CONFIG_KEYBOARD_ATKBD=y
CONFIG_SERIO=y
CONFIG_SERIO_I8042=y
CONFIG_HID_SUPPORT=y
CONFIG_HID=y
CONFIG_HID_GENERIC=y
CONFIG_USB_SUPPORT=y
CONFIG_USB=y
CONFIG_USB_PCI=y
CONFIG_USB_XHCI_HCD=y
CONFIG_USB_HID=y

# Display: DRM with i915 (the onboard GPU), bochs (QEMU std VGA / bochs-display), simpledrm
# (the firmware's GOP framebuffer: bhyve's fbuf, and the screen until a real driver takes over),
# fbcon on DRM's fbdev emulation.
CONFIG_DRM=y
CONFIG_DRM_FBDEV_EMULATION=y
# i915 (6th-12th gen) and xe (docs/64 §6.7: the 12th gen onboard GPU's SR-IOV PF driver, which
# then also draws the host's screen) are both modules: init loads one of them for the GPU (i915,
# or xe when keel asks for VFs), and neither may grab it before. xe has to be one anyway:
# DRM_XE_DISPLAY depends on DRM_XE=m (it compiles i915's display code a second time). The DRM
# helpers they select (drm_display_helper, ttm, drm_exec, drm_gpuvm, ...) are hidden tristates
# and become modules with them. build.sh puts them into the initramfs (/lib/modules, with a
# load list per driver, README.md).
CONFIG_DRM_I915=m
CONFIG_MODULES=y
CONFIG_DRM_XE=m
CONFIG_DRM_XE_DISPLAY=y
CONFIG_DRM_XE_FORCE_PROBE=""
# Power management core (runtime PM): without it pm_runtime_get_if_active() is a stub that says
# -EINVAL, and xe reads none of GuC's answers (xe_guc_ct.c: the G2H worker and fast path return
# when the device is not "active"): its probe timed out on the first request (W5012, 2026-10-13,
# "Timed out wait for G2H … action 550e"). i915 does not mind (no GuC submission on ADL-S).
CONFIG_PM=y
# PCIe extended configuration space (bhyve's MCFG/ECAM): the SR-IOV capability bhyve shows is at
# 0x320, beyond the 256 bytes of the old configuration mechanism; without it there is no
# sriov_totalvfs (W5012, 2026-10-13).
CONFIG_PCI_MMCONFIG=y
# SR-IOV: xe's PF code (xe_sriov_pf*, xe_gt_sriov_pf*) is only built with PCI_IOV.
CONFIG_PCI_IOV=y
# xe depends on X86_PLATFORM_DEVICES with ACPI.
CONFIG_X86_PLATFORM_DEVICES=y
CONFIG_DRM_BOCHS=y
CONFIG_DRM_SIMPLEDRM=y
CONFIG_SYSFB_SIMPLEFB=y
CONFIG_FB=y
# /dev/fb0 (mirror mode draws through it; since 6.6 a separate option, off in allnoconfig)
CONFIG_FB_DEVICE=y
CONFIG_FRAMEBUFFER_CONSOLE=y
CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
# Fonts: fbcon picks 8x16 up to about 1080p and Terminus 16x32 on 4K screens by itself.
CONFIG_FONTS=y
CONFIG_FONT_8x16=y
CONFIG_FONT_TER16x32=y

# Firmware: i915's DMC, GuC and HuC blobs are built into the image (EXTRA_FIRMWARE, set by
# build.sh); a built-in blob is also found by a module (xe).
CONFIG_FW_LOADER=y
# CONFIG_FW_LOADER_USER_HELPER is not set

# Not wanted: network, sound, block devices. Modules only for xe (above): no signing, no
# unloading; init is to load the files itself (finit_module).
# CONFIG_MODULE_UNLOAD is not set
# CONFIG_MODULE_SIG is not set
# CONFIG_NET is not set
# CONFIG_SOUND is not set
# the disk (bhyve's ahci-hd, the image itself) read-only: keelplay and its libraries live on
# its ESP (docs/110 §11)
CONFIG_BLOCK=y
CONFIG_PARTITION_ADVANCED=y
CONFIG_EFI_PARTITION=y
CONFIG_SCSI=y
CONFIG_BLK_DEV_SD=y
CONFIG_ATA=y
CONFIG_SATA_AHCI=y
CONFIG_FAT_FS=y
CONFIG_VFAT_FS=y
CONFIG_NLS=y
CONFIG_NLS_CODEPAGE_437=y
CONFIG_NLS_ISO8859_1=y
# the video player's glibc, libva and Intel's media driver (docs/110 §11): threads' timers,
# eventfd/epoll/timerfd, madvise
CONFIG_POSIX_TIMERS=y
CONFIG_EVENTFD=y
CONFIG_EPOLL=y
CONFIG_TIMERFD=y
CONFIG_ADVISE_SYSCALLS=y
