===== LinuxKPI ===== %%LinuxKPI%% is a small compatibility layer that allows Linux drivers to run in a %%FreeBSD%% environment with minor modification. You can find the %%LinuxKPI%% source in the %%FreeBSD%% kernel under ''%%sys/compat/linuxkpi%%''. A quick look at the code reveals that the kernel programming interface (KPI) is simply a collection of Linux headers and source files that map Linux-exclusive functions to %%FreeBSD%% equivalents. %%FreeBSD%% relies on %%LinuxKPI%% to power essential desktop features like graphics drivers and wireless networking. The [[https://www.freshports.org/graphics/drm-kmod|drm-kmod]] package includes Linux drivers for AMD/Intel graphics and is able to compile and run smoothly on %%FreeBSD%% using %%LinuxKPI%%. Intel wireless networking through [[https://wiki.freebsd.org/WiFi/Iwlwifi|iwlwifi]] is also functional and is in %%FreeBSD%% base thanks to [[https://wiki.freebsd.org/BjoernZeeb|Bjoern Zeeb]]. It should be noted that there is a distinction between [[https://wiki.freebsd.org/Linuxulator|Linuxulator (Linux Emulation)]] and %%LinuxKPI%%. Both subsystems exist to support Linux compatibility, but %%LinuxKPI%% focuses on providing a programming interface for kernel drivers, while Linuxulator runs unmodified Linux userspace binaries. ===== Status ===== %%LinuxKPI%% does not officially target compatibility with any specific Linux kernel version. Instead, subsystems that use %%LinuxKPI%% often declare targets. For example, the [[https://www.freshports.org/graphics/drm-kmod/|drm-kmod]] meta-port encompasses many DRM targets and automatically serves a version based on the recommendation of the %%FreeBSDDesktop%% team. ===== Development ===== Linux development occurs rapidly, so %%LinuxKPI%% is always receiving changes to keep up. Due to the nature of Linux's GPLv2 licensing, %%FreeBSD%% developers cannot derive code directly from Linux source. Instead, manual pages serve as the primary source of reference for development specifications. ==== Debugging ==== %%LinuxKPI%% is intended to be used in Linux kernel drivers, so the standard %%FreeBSD%% [[https://docs.freebsd.org/en/books/developers-handbook/kerneldebug/|kernel debugging]] procedures are recommended. ===== Bugs ===== A deeper dive into %%LinuxKPI%% source proves that Linux --> %%FreeBSD%% translation is not easy. Even though %%LinuxKPI%% enables working drivers, there exist %%FreeBSD%%-specific bugs and missing features as a result of %%LinuxKPI%%'s incomplete, and sometimes incorrect, translation. Create a Phabricator review with tag ''%%LinuxKPI%%'' for bug fixes. ---- {{tag>Project}}