From 318b00c3dd4c9890c6db3f27d940bea488491d21 Mon Sep 17 00:00:00 2001
From: Koine Yuusuke <koinec@yahoo.co.jp>
Date: Mon, 6 May 2024 11:32:59 +0900
Subject: [PATCH 4/7] Add the coredirector driver's source-code & Makefile for
 the Intel ThreadDirector / Hardware Feedback Interface.

---
 sys/conf/files.amd64                |   1 +
 sys/dev/coredirector/coredirector.c | 642 ++++++++++++++++++++++++++++
 sys/modules/Makefile                |   2 +
 sys/modules/coredirector/Makefile   |   7 +
 4 files changed, 652 insertions(+)
 create mode 100644 sys/dev/coredirector/coredirector.c
 create mode 100644 sys/modules/coredirector/Makefile

diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64
index 18dec5ed47b0..e1aad601ef11 100644
--- a/sys/conf/files.amd64
+++ b/sys/conf/files.amd64
@@ -1,446 +1,447 @@
 # This file tells config what files go into building a kernel,
 # files marked standard are always included.
 #
 #
 
 # common files stuff between i386 and amd64
 include 	"conf/files.x86"
 
 # The long compile-with and dependency lines are required because of
 # limitations in config: backslash-newline doesn't work in strings, and
 # dependency lines other than the first are silently ignored.
 #
 #
 elf-vdso.so.o			standard				\
 	dependency	"$S/amd64/amd64/sigtramp.S assym.inc $S/conf/vdso_amd64.ldscript $S/tools/amd64_vdso.sh" \
 	compile-with	"env AWK='${AWK}' NM='${NM}' LD='${LD}' CC='${CC}' DEBUG='${DEBUG}' OBJCOPY='${OBJCOPY}' ELFDUMP='${ELFDUMP}' S='${S}' sh $S/tools/amd64_vdso.sh" \
 	no-ctfconvert	\
 	no-implicit-rule before-depend	\
 	clean		"elf-vdso.so.o elf-vdso.so.1 vdso_offsets.h sigtramp.pico"
 #
 elf-vdso32.so.o			optional	compat_freebsd32		\
 	dependency	"$S/amd64/ia32/ia32_sigtramp.S ia32_assym.h $S/conf/vdso_amd64_ia32.ldscript $S/tools/amd64_ia32_vdso.sh" \
 	compile-with	"env AWK='${AWK}' NM='${NM}' LD='${LD}' CC='${CC}' DEBUG='${DEBUG}' OBJCOPY='${OBJCOPY}' ELFDUMP='${ELFDUMP}' S='${S}' sh $S/tools/amd64_ia32_vdso.sh" \
 	no-ctfconvert	\
 	no-implicit-rule before-depend	\
 	clean		"elf-vdso32.so.o elf-vdso32.so.1 vdso_ia32_offsets.h ia32_sigtramp.pico"
 #
 ia32_genassym.o			standard				\
 	dependency 	"$S/compat/ia32/ia32_genassym.c offset.inc"		\
 	compile-with	"${CC} ${CFLAGS:N-flto*:N-fno-common:N-fsanitize*:N-fno-sanitize*} -fcommon -c ${.IMPSRC}" \
 	no-obj no-implicit-rule						\
 	clean		"ia32_genassym.o"
 #
 ia32_assym.h			standard				\
 	dependency 	"$S/kern/genassym.sh ia32_genassym.o"		\
 	compile-with	"env NM='${NM}' NMFLAGS='${NMFLAGS}' sh $S/kern/genassym.sh ia32_genassym.o > ${.TARGET}" \
 	no-obj no-implicit-rule before-depend				\
 	clean		"ia32_assym.h"
 #
 amd64/acpica/acpi_machdep.c	optional	acpi
 amd64/acpica/acpi_wakeup.c	optional	acpi
 acpi_wakecode.o			optional	acpi			\
 	dependency	"$S/amd64/acpica/acpi_wakecode.S assym.inc"	\
 	compile-with	"${NORMAL_S}"					\
 	no-obj no-implicit-rule before-depend				\
 	clean		"acpi_wakecode.o"
 acpi_wakecode.bin		optional	acpi			\
 	dependency	"acpi_wakecode.o"				\
 	compile-with	"${OBJCOPY} -S -O binary acpi_wakecode.o ${.TARGET}" \
 	no-obj no-implicit-rule	before-depend				\
 	clean		"acpi_wakecode.bin"
 acpi_wakecode.h			optional	acpi			\
 	dependency	"acpi_wakecode.bin"				\
 	compile-with	"file2c -sx 'static char wakecode[] = {' '};' < acpi_wakecode.bin > ${.TARGET}" \
 	no-obj no-implicit-rule	before-depend				\
 	clean		"acpi_wakecode.h"
 acpi_wakedata.h			optional	acpi			\
 	dependency	"acpi_wakecode.o"				\
 	compile-with	'${NM} -n --defined-only acpi_wakecode.o | while read offset dummy what; do echo "#define	$${what}	0x$${offset}"; done > ${.TARGET}' \
 	no-obj no-implicit-rule	before-depend				\
 	clean		"acpi_wakedata.h"
 #
 #amd64/amd64/apic_vector.S	standard
 amd64/amd64/bios.c		standard
 amd64/amd64/bpf_jit_machdep.c	optional	bpf_jitter
 amd64/amd64/copyout.c		standard
 amd64/amd64/cpu_switch.S	standard
 amd64/amd64/db_disasm.c		optional	ddb
 amd64/amd64/db_interface.c	optional	ddb
 amd64/amd64/db_trace.c		optional	ddb
 amd64/amd64/efirt_machdep.c	optional	efirt
 amd64/amd64/efirt_support.S	optional	efirt
 amd64/amd64/elf_machdep.c	standard
 amd64/amd64/exception.S		standard
 amd64/amd64/exec_machdep.c	standard
 amd64/amd64/fpu.c		standard
 amd64/amd64/gdb_machdep.c	optional	gdb
 amd64/amd64/initcpu.c		standard
 amd64/amd64/io.c		optional	io
 amd64/amd64/locore.S		standard	no-obj
 amd64/amd64/xen-locore.S	optional	xenhvm \
 	compile-with "${NORMAL_S} -g0" \
 	no-ctfconvert
 amd64/amd64/machdep.c		standard
 amd64/amd64/mem.c		optional	mem
 amd64/amd64/minidump_machdep.c	standard
 amd64/amd64/mp_machdep.c	optional	smp
 amd64/amd64/mpboot.S		optional	smp
 amd64/amd64/pmap.c		standard
 amd64/amd64/ptrace_machdep.c	standard
 amd64/amd64/support.S		standard
 amd64/amd64/sys_machdep.c	standard
 amd64/amd64/trap.c		standard
 amd64/amd64/uio_machdep.c	standard
 amd64/amd64/uma_machdep.c	standard
 amd64/amd64/vm_machdep.c	standard
 amd64/pci/pci_cfgreg.c		optional	pci
 cddl/dev/dtrace/amd64/dtrace_asm.S			optional dtrace compile-with "${DTRACE_S}"
 cddl/dev/dtrace/amd64/dtrace_subr.c			optional dtrace compile-with "${DTRACE_C}"
 crypto/aesni/aeskeys_amd64.S	optional aesni
 crypto/des/des_enc.c		optional	netsmb
 crypto/openssl/amd64/aes-gcm-avx512.S	optional ossl
 crypto/openssl/amd64/aesni-x86_64.S	optional ossl
 crypto/openssl/amd64/aesni-gcm-x86_64.S	optional ossl
 crypto/openssl/amd64/chacha-x86_64.S	optional ossl
 crypto/openssl/amd64/ghash-x86_64.S	optional ossl
 crypto/openssl/amd64/poly1305-x86_64.S	optional ossl
 crypto/openssl/amd64/sha1-x86_64.S	optional ossl
 crypto/openssl/amd64/sha256-x86_64.S	optional ossl
 crypto/openssl/amd64/sha512-x86_64.S	optional ossl
 crypto/openssl/amd64/ossl_aes_gcm.c	optional ossl
 dev/amdgpio/amdgpio.c		optional	amdgpio
 dev/axgbe/if_axgbe_pci.c	optional	axp
 dev/axgbe/xgbe-desc.c		optional	axp
 dev/axgbe/xgbe-dev.c		optional	axp
 dev/axgbe/xgbe-drv.c		optional	axp
 dev/axgbe/xgbe-mdio.c		optional	axp
 dev/axgbe/xgbe-sysctl.c		optional	axp
 dev/axgbe/xgbe-txrx.c		optional	axp
 dev/axgbe/xgbe_osdep.c		optional	axp
 dev/axgbe/xgbe-i2c.c		optional	axp
 dev/axgbe/xgbe-phy-v2.c		optional	axp
+dev/coredirector/coredirector.c	optional	coredirector
 dev/enic/enic_res.c		optional	enic
 dev/enic/enic_txrx.c		optional	enic
 dev/enic/if_enic.c		optional	enic
 dev/enic/vnic_cq.c		optional	enic
 dev/enic/vnic_dev.c		optional	enic
 dev/enic/vnic_intr.c		optional	enic
 dev/enic/vnic_rq.c		optional	enic
 dev/enic/vnic_wq.c		optional	enic
 dev/ftgpio/ftgpio.c		optional	ftgpio superio
 dev/hyperv/vmbus/amd64/hyperv_machdep.c			optional	hyperv
 dev/hyperv/vmbus/amd64/vmbus_vector.S			optional	hyperv
 dev/iavf/if_iavf_iflib.c	optional	iavf pci \
 	compile-with "${NORMAL_C} -I$S/dev/iavf"
 dev/iavf/iavf_lib.c		optional	iavf pci \
 	compile-with "${NORMAL_C} -I$S/dev/iavf"
 dev/iavf/iavf_osdep.c		optional	iavf pci \
 	compile-with "${NORMAL_C} -I$S/dev/iavf"
 dev/iavf/iavf_txrx_iflib.c	optional	iavf pci \
 	compile-with "${NORMAL_C} -I$S/dev/iavf"
 dev/iavf/iavf_common.c		optional	iavf pci \
 	compile-with "${NORMAL_C} -I$S/dev/iavf"
 dev/iavf/iavf_adminq.c		optional	iavf pci \
 	compile-with "${NORMAL_C} -I$S/dev/iavf"
 dev/iavf/iavf_vc_common.c	optional	iavf pci \
 	compile-with "${NORMAL_C} -I$S/dev/iavf"
 dev/iavf/iavf_vc_iflib.c	optional	iavf pci \
 	compile-with "${NORMAL_C} -I$S/dev/iavf"
 dev/ice/if_ice_iflib.c		optional	ice pci \
 	compile-with "${NORMAL_C} -I$S/dev/ice"
 dev/ice/ice_lib.c		optional	ice pci \
 	compile-with "${NORMAL_C} -I$S/dev/ice"
 dev/ice/ice_osdep.c		optional	ice pci \
 	compile-with "${NORMAL_C} -I$S/dev/ice"
 dev/ice/ice_resmgr.c		optional	ice pci \
 	compile-with "${NORMAL_C} -I$S/dev/ice"
 dev/ice/ice_strings.c		optional	ice pci \
 	compile-with "${NORMAL_C} -I$S/dev/ice"
 dev/ice/ice_iflib_recovery_txrx.c	optional	ice pci \
 	compile-with "${NORMAL_C} -I$S/dev/ice"
 dev/ice/ice_iflib_txrx.c	optional	ice pci \
 	compile-with "${NORMAL_C} -I$S/dev/ice"
 dev/ice/ice_common.c		optional	ice pci \
 	compile-with "${NORMAL_C} -I$S/dev/ice"
 dev/ice/ice_controlq.c		optional	ice pci \
 	compile-with "${NORMAL_C} -I$S/dev/ice"
 dev/ice/ice_dcb.c		optional	ice pci \
 	compile-with "${NORMAL_C} -I$S/dev/ice"
 dev/ice/ice_flex_pipe.c		optional	ice pci \
 	compile-with "${NORMAL_C} -I$S/dev/ice"
 dev/ice/ice_flow.c		optional	ice pci \
 	compile-with "${NORMAL_C} -I$S/dev/ice"
 dev/ice/ice_nvm.c		optional	ice pci \
 	compile-with "${NORMAL_C} -I$S/dev/ice"
 dev/ice/ice_sched.c		optional	ice pci \
 	compile-with "${NORMAL_C} -I$S/dev/ice"
 dev/ice/ice_switch.c		optional	ice pci \
 	compile-with "${NORMAL_C} -I$S/dev/ice"
 dev/ice/ice_vlan_mode.c		optional	ice pci \
 	compile-with "${NORMAL_C} -I$S/dev/ice"
 dev/ice/ice_fw_logging.c	optional	ice pci \
 	compile-with "${NORMAL_C} -I$S/dev/ice"
 dev/ice/ice_fwlog.c		optional	ice pci \
 	compile-with "${NORMAL_C} -I$S/dev/ice"
 dev/ice/ice_rdma.c		optional	ice pci \
 	compile-with "${NORMAL_C} -I$S/dev/ice"
 dev/ice/irdma_if.m		optional	ice pci \
 	compile-with "${NORMAL_M} -I$S/dev/ice"
 dev/ice/irdma_di_if.m		optional	ice pci \
 	compile-with "${NORMAL_M} -I$S/dev/ice"
 dev/ice/ice_ddp_common.c	optional	ice pci \
 	compile-with "${NORMAL_C} -I$S/dev/ice"
 ice_ddp.c			optional ice_ddp	\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk ice_ddp.fw:ice_ddp:0x01032400 -mice_ddp -c${.TARGET}"	\
 	no-ctfconvert no-implicit-rule before-depend local	\
 	clean		"ice_ddp.c"
 ice_ddp.fwo			optional ice_ddp	\
 	dependency	"ice_ddp.fw"			\
 	compile-with	"${NORMAL_FWO}"			\
 	no-implicit-rule				\
 	clean		"ice_ddp.fwo"
 ice_ddp.fw			optional ice_ddp	\
 	dependency	"$S/contrib/dev/ice/ice-1.3.36.0.pkg" \
 	compile-with	"${CP} $S/contrib/dev/ice/ice-1.3.36.0.pkg ice_ddp.fw" \
 	no-obj no-implicit-rule				\
 	clean		"ice_ddp.fw"
 dev/ioat/ioat.c			optional	ioat pci
 dev/ioat/ioat_test.c		optional	ioat pci
 dev/ixl/if_ixl.c		optional	ixl pci \
 	compile-with "${NORMAL_C} -I$S/dev/ixl"
 dev/ixl/ixl_pf_main.c		optional	ixl pci \
 	compile-with "${NORMAL_C} -I$S/dev/ixl"
 dev/ixl/ixl_pf_iflib.c		optional	ixl pci \
 	compile-with "${NORMAL_C} -I$S/dev/ixl"
 dev/ixl/ixl_pf_qmgr.c		optional	ixl pci \
 	compile-with "${NORMAL_C} -I$S/dev/ixl"
 dev/ixl/ixl_pf_iov.c		optional	ixl pci  pci_iov \
 	compile-with "${NORMAL_C} -I$S/dev/ixl"
 dev/ixl/ixl_pf_i2c.c		optional	ixl pci \
 	compile-with "${NORMAL_C} -I$S/dev/ixl"
 dev/ixl/ixl_txrx.c		optional	ixl pci \
 	compile-with "${NORMAL_C} -I$S/dev/ixl"
 dev/ixl/i40e_osdep.c		optional	ixl pci \
 	compile-with "${NORMAL_C} -I$S/dev/ixl"
 dev/ixl/i40e_lan_hmc.c		optional	ixl pci \
 	compile-with "${NORMAL_C} -I$S/dev/ixl"
 dev/ixl/i40e_hmc.c		optional	ixl pci \
 	compile-with "${NORMAL_C} -I$S/dev/ixl"
 dev/ixl/i40e_common.c		optional	ixl pci \
 	compile-with "${NORMAL_C} -I$S/dev/ixl"
 dev/ixl/i40e_nvm.c		optional	ixl pci \
 	compile-with "${NORMAL_C} -I$S/dev/ixl"
 dev/ixl/i40e_adminq.c		optional	ixl pci \
 	compile-with "${NORMAL_C} -I$S/dev/ixl"
 dev/ixl/i40e_dcb.c		optional	ixl pci \
 	compile-with "${NORMAL_C} -I$S/dev/ixl"
 dev/ncthwm/ncthwm.c		optional	ncthwm superio
 dev/qlxge/qls_dbg.c		optional	qlxge pci
 dev/qlxge/qls_dump.c		optional	qlxge pci
 dev/qlxge/qls_hw.c		optional	qlxge pci
 dev/qlxge/qls_ioctl.c		optional	qlxge pci
 dev/qlxge/qls_isr.c		optional	qlxge pci
 dev/qlxge/qls_os.c		optional	qlxge pci
 dev/qlxgb/qla_dbg.c		optional	qlxgb pci
 dev/qlxgb/qla_hw.c		optional	qlxgb pci
 dev/qlxgb/qla_ioctl.c		optional	qlxgb pci
 dev/qlxgb/qla_isr.c		optional	qlxgb pci
 dev/qlxgb/qla_misc.c		optional	qlxgb pci
 dev/qlxgb/qla_os.c		optional	qlxgb pci
 dev/qlxgbe/ql_dbg.c		optional	qlxgbe pci
 dev/qlxgbe/ql_hw.c		optional	qlxgbe pci
 dev/qlxgbe/ql_ioctl.c		optional	qlxgbe pci
 dev/qlxgbe/ql_isr.c		optional	qlxgbe pci
 dev/qlxgbe/ql_misc.c		optional	qlxgbe pci
 dev/qlxgbe/ql_os.c		optional	qlxgbe pci
 dev/qlxgbe/ql_reset.c		optional	qlxgbe pci
 dev/qlxgbe/ql_fw.c		optional	qlxgbe pci
 dev/qlxgbe/ql_boot.c		optional	qlxgbe pci
 dev/qlxgbe/ql_minidump.c	optional	qlxgbe pci
 dev/qlnx/qlnxe/ecore_cxt.c	optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/qlnx/qlnxe/ecore_dbg_fw_funcs.c optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/qlnx/qlnxe/ecore_dcbx.c	optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/qlnx/qlnxe/ecore_dev.c	optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/qlnx/qlnxe/ecore_hw.c	optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/qlnx/qlnxe/ecore_init_fw_funcs.c optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/qlnx/qlnxe/ecore_init_ops.c	optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/qlnx/qlnxe/ecore_int.c	optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/qlnx/qlnxe/ecore_l2.c	optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/qlnx/qlnxe/ecore_mcp.c	optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/qlnx/qlnxe/ecore_sp_commands.c optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/qlnx/qlnxe/ecore_spq.c	optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/qlnx/qlnxe/ecore_sriov.c	optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/qlnx/qlnxe/ecore_vf.c	optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/qlnx/qlnxe/ecore_ll2.c	optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/qlnx/qlnxe/ecore_iwarp.c	optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/qlnx/qlnxe/ecore_rdma.c	optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/qlnx/qlnxe/ecore_roce.c	optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/qlnx/qlnxe/ecore_ooo.c	optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/qlnx/qlnxe/qlnx_rdma.c	optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/qlnx/qlnxe/qlnx_ioctl.c	optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/qlnx/qlnxe/qlnx_os.c	optional	qlnxe pci \
 	compile-with "${LINUXKPI_C}"
 dev/sfxge/common/ef10_ev.c	optional	sfxge pci
 dev/sfxge/common/ef10_filter.c	optional	sfxge pci
 dev/sfxge/common/ef10_image.c	optional	sfxge pci
 dev/sfxge/common/ef10_intr.c	optional	sfxge pci
 dev/sfxge/common/ef10_mac.c	optional	sfxge pci
 dev/sfxge/common/ef10_mcdi.c	optional	sfxge pci
 dev/sfxge/common/ef10_nic.c	optional	sfxge pci
 dev/sfxge/common/ef10_nvram.c	optional	sfxge pci
 dev/sfxge/common/ef10_phy.c	optional	sfxge pci
 dev/sfxge/common/ef10_rx.c	optional	sfxge pci
 dev/sfxge/common/ef10_tx.c	optional	sfxge pci
 dev/sfxge/common/ef10_vpd.c	optional	sfxge pci
 dev/sfxge/common/efx_bootcfg.c	optional	sfxge pci
 dev/sfxge/common/efx_crc32.c	optional	sfxge pci
 dev/sfxge/common/efx_ev.c	optional	sfxge pci
 dev/sfxge/common/efx_filter.c	optional	sfxge pci
 dev/sfxge/common/efx_hash.c	optional	sfxge pci
 dev/sfxge/common/efx_intr.c	optional	sfxge pci
 dev/sfxge/common/efx_lic.c	optional	sfxge pci
 dev/sfxge/common/efx_mac.c	optional	sfxge pci
 dev/sfxge/common/efx_mcdi.c	optional	sfxge pci
 dev/sfxge/common/efx_mon.c	optional	sfxge pci
 dev/sfxge/common/efx_nic.c	optional	sfxge pci
 dev/sfxge/common/efx_nvram.c	optional	sfxge pci
 dev/sfxge/common/efx_phy.c	optional	sfxge pci
 dev/sfxge/common/efx_port.c	optional	sfxge pci
 dev/sfxge/common/efx_rx.c	optional	sfxge pci
 dev/sfxge/common/efx_sram.c	optional	sfxge pci
 dev/sfxge/common/efx_tunnel.c	optional	sfxge pci
 dev/sfxge/common/efx_tx.c	optional	sfxge pci
 dev/sfxge/common/efx_vpd.c	optional	sfxge pci
 dev/sfxge/common/hunt_nic.c	optional	sfxge pci
 dev/sfxge/common/mcdi_mon.c	optional	sfxge pci
 dev/sfxge/common/medford_nic.c	optional	sfxge pci
 dev/sfxge/common/medford2_nic.c	optional	sfxge pci
 dev/sfxge/common/siena_mac.c	optional	sfxge pci
 dev/sfxge/common/siena_mcdi.c	optional	sfxge pci
 dev/sfxge/common/siena_nic.c	optional	sfxge pci
 dev/sfxge/common/siena_nvram.c	optional	sfxge pci
 dev/sfxge/common/siena_phy.c	optional	sfxge pci
 dev/sfxge/common/siena_sram.c	optional	sfxge pci
 dev/sfxge/common/siena_vpd.c	optional	sfxge pci
 dev/sfxge/sfxge.c		optional	sfxge pci
 dev/sfxge/sfxge_dma.c		optional	sfxge pci
 dev/sfxge/sfxge_ev.c		optional	sfxge pci
 dev/sfxge/sfxge_intr.c		optional	sfxge pci
 dev/sfxge/sfxge_mcdi.c		optional	sfxge pci
 dev/sfxge/sfxge_nvram.c		optional	sfxge pci
 dev/sfxge/sfxge_port.c		optional	sfxge pci
 dev/sfxge/sfxge_rx.c		optional	sfxge pci
 dev/sfxge/sfxge_tx.c		optional	sfxge pci
 dev/smartpqi/smartpqi_cam.c     optional 	smartpqi
 dev/smartpqi/smartpqi_cmd.c     optional 	smartpqi
 dev/smartpqi/smartpqi_discovery.c	optional	smartpqi
 dev/smartpqi/smartpqi_event.c   optional 	smartpqi
 dev/smartpqi/smartpqi_features.c   optional 	smartpqi
 dev/smartpqi/smartpqi_helper.c  optional 	smartpqi
 dev/smartpqi/smartpqi_init.c    optional 	smartpqi
 dev/smartpqi/smartpqi_intr.c    optional 	smartpqi
 dev/smartpqi/smartpqi_ioctl.c   optional 	smartpqi
 dev/smartpqi/smartpqi_main.c    optional 	smartpqi
 dev/smartpqi/smartpqi_mem.c     optional 	smartpqi
 dev/smartpqi/smartpqi_misc.c    optional 	smartpqi
 dev/smartpqi/smartpqi_queue.c   optional 	smartpqi
 dev/smartpqi/smartpqi_request.c optional 	smartpqi
 dev/smartpqi/smartpqi_response.c	optional 	smartpqi
 dev/smartpqi/smartpqi_sis.c     optional 	smartpqi
 dev/smartpqi/smartpqi_tag.c     optional 	smartpqi
 dev/sume/if_sume.c		optional	sume
 dev/syscons/apm/apm_saver.c	optional	apm_saver apm
 dev/tpm/tpm_crb.c		optional	tpm acpi
 dev/tpm/tpm_acpi.c		optional	tpm acpi
 dev/tpm/tpm_isa.c		optional	tpm isa
 dev/p2sb/p2sb.c			optional	p2sb pci
 dev/p2sb/lewisburg_gpiocm.c	optional	lbggpiocm p2sb
 dev/p2sb/lewisburg_gpio.c	optional	lbggpio lbggpiocm
 kern/link_elf_obj.c		standard
 #
 # IA32 binary support
 #
 #amd64/ia32/ia32_exception.S	optional	compat_freebsd32
 amd64/ia32/ia32_reg.c		optional	compat_freebsd32
 amd64/ia32/ia32_signal.c	optional	compat_freebsd32
 amd64/ia32/ia32_syscall.c	optional	compat_freebsd32
 amd64/ia32/ia32_misc.c		optional	compat_freebsd32
 compat/ia32/ia32_sysvec.c	optional	compat_freebsd32
 #
 # x86 real mode BIOS emulator, required by dpms/pci/vesa
 #
 compat/x86bios/x86bios.c	optional x86bios | dpms | pci | vesa
 contrib/x86emu/x86emu.c		optional x86bios | dpms | pci | vesa
 # Common files where we currently configure the system differently, but perhaps shouldn't
 # config(8) doesn't have a way to force standard options, so we've been inconsistent
 # about marking non-optional things 'standard'.
 x86/acpica/madt.c		optional	acpi
 x86/isa/atpic.c			optional	atpic isa
 x86/isa/elcr.c			optional	atpic isa | mptable
 x86/isa/isa.c			standard
 x86/isa/isa_dma.c		standard
 x86/pci/pci_early_quirks.c	optional	pci
 x86/x86/io_apic.c		standard
 x86/x86/local_apic.c		standard
 x86/x86/mptable.c		optional	mptable
 x86/x86/mptable_pci.c		optional	mptable pci
 x86/x86/msi.c			optional	pci
 x86/xen/pv.c			optional	xenhvm
 
 # zfs blake3 hash support
 contrib/openzfs/module/icp/asm-x86_64/blake3/blake3_avx2.S      optional zfs compile-with "${ZFS_S}"
 contrib/openzfs/module/icp/asm-x86_64/blake3/blake3_avx512.S    optional zfs compile-with "${ZFS_S}"
 contrib/openzfs/module/icp/asm-x86_64/blake3/blake3_sse2.S      optional zfs compile-with "${ZFS_S}"
 contrib/openzfs/module/icp/asm-x86_64/blake3/blake3_sse41.S     optional zfs compile-with "${ZFS_S}"
 
 # zfs sha2 hash support
 zfs-sha256-x86_64.o		optional	zfs			\
 	dependency "$S/contrib/openzfs/module/icp/asm-x86_64/sha2/sha256-x86_64.S" \
 	compile-with	"${CC} -c ${ZFS_ASM_CFLAGS} -o ${.TARGET} ${WERROR} $S/contrib/openzfs/module/icp/asm-x86_64/sha2/sha256-x86_64.S" \
 	no-implicit-rule \
 	clean "zfs-sha256-x86_64.o"
 
 zfs-sha512-x86_64.o		optional	zfs			\
 	dependency "$S/contrib/openzfs/module/icp/asm-x86_64/sha2/sha512-x86_64.S" \
 	compile-with	"${CC} -c ${ZFS_ASM_CFLAGS} -o ${.TARGET} ${WERROR} $S/contrib/openzfs/module/icp/asm-x86_64/sha2/sha512-x86_64.S" \
 	no-implicit-rule \
 	clean "zfs-sha512-x86_64.o"
 
 # zfs checksums / zcommon
 contrib/openzfs/module/zcommon/zfs_fletcher_avx512.c		optional zfs compile-with "${ZFS_C}"
 contrib/openzfs/module/zcommon/zfs_fletcher_intel.c		optional zfs compile-with "${ZFS_C}"
 contrib/openzfs/module/zcommon/zfs_fletcher_sse.c		optional zfs compile-with "${ZFS_C}"
 
 contrib/openzfs/module/zfs/vdev_raidz_math_avx2.c		optional zfs compile-with "${ZFS_C}"
 contrib/openzfs/module/zfs/vdev_raidz_math_avx512bw.c		optional zfs compile-with "${ZFS_C}"
 contrib/openzfs/module/zfs/vdev_raidz_math_avx512f.c		optional zfs compile-with "${ZFS_C}"
 contrib/openzfs/module/zfs/vdev_raidz_math_sse2.c		optional zfs compile-with "${ZFS_C}"
 contrib/openzfs/module/zfs/vdev_raidz_math_ssse3.c		optional zfs compile-with "${ZFS_C}"
 # Clock calibration subroutine; uses floating-point arithmetic
 subr_clockcalib.o		standard				\
 	dependency	"$S/kern/subr_clockcalib.c"			\
 	compile-with	"${CC} -c ${CFLAGS:C/^-O2$/-O3/:N-nostdinc} ${WERROR} -mmmx -msse -msse2 ${.IMPSRC}" \
 	no-implicit-rule						\
 	clean		"subr_clockcalib.o"
diff --git a/sys/dev/coredirector/coredirector.c b/sys/dev/coredirector/coredirector.c
new file mode 100644
index 000000000000..06db1a76cfb9
--- /dev/null
+++ b/sys/dev/coredirector/coredirector.c
@@ -0,0 +1,642 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Koine Yuusuke <koinec@yahoo.co.jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include "opt_global.h"
+#include "opt_sched.h"
+
+#include <sys/malloc.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/mutex.h>
+#include <sys/lock.h>
+#include <sys/proc.h>
+#include <sys/smp.h>
+#include <sys/sysctl.h>
+#include <sys/sbuf.h>
+
+#include <machine/specialreg.h>
+#include <machine/cputypes.h>
+#include <machine/md_var.h>
+#include <machine/bus.h>
+
+#include <vm/vm.h>
+#include <vm/vm_extern.h>
+#include <vm/pmap.h>
+#include <vm/vm_kern.h>
+
+#include <x86/intr_machdep.h>
+#include <x86/apicvar.h>
+
+#define	COREDIRECTOR_NAME "coredirector"
+
+#ifdef DEBUG
+#define DPRINTF(fmt, args...) printf("coredirector:" fmt, ##args)
+#else
+#define DPRINTF(fmt, args...)
+#endif
+
+#define BITSCOUNT(n)	(!!((n)&((uint8_t)1<<0)) \
+							+ !!((n)&((uint8_t)1<<1)) \
+							+ !!((n)&((uint8_t)1<<2)) \
+							+ !!((n)&((uint8_t)1<<3)) \
+							+ !!((n)&((uint8_t)1<<4)) \
+							+ !!((n)&((uint8_t)1<<5)) \
+							+ !!((n)&((uint8_t)1<<6)) \
+							+ !!((n)&((uint8_t)1<<7)))
+#define ROUNDUP8(n)	((((n)+7)/8)*8)
+
+#define CPUID_LEAF6_ECX_CLASSES(c)			(((c)&CPUID_PERF_TD_CLASSES)>>8)
+#define CPUID_LEAF6_EDX_TBLPAGES(c)			(((c)&CPUID_TD_TBLPAGES)>>8)
+
+/*
+ * Structure defines
+ */
+struct coredirector_instance {
+	int		ref;
+
+	struct	{
+		uint32_t	hfi		:1;
+		uint32_t	thdirector	:1;
+		uint32_t	pmaped		:1;
+		uint32_t	reserved	:30;
+	} flags;
+
+	uint32_t	hdrsize;
+	uint32_t	entrysize;
+	uint32_t	allocsize;
+	uint32_t	tblsize;
+
+	int32_t		cpugroups;
+
+	uint64_t	capabilities;
+	uint64_t	classes;
+
+	union	{
+		void		*ptr;
+		uint64_t	*timestamp;
+	} hwtable;
+	struct mtx		hwtbl_lock;
+
+	union {
+		void		*ptr;
+		uint64_t	*timestamp;
+	} cache;
+
+	struct mtx	intr_lock;
+};
+
+struct coredirector_softc {
+	device_t	sc_dev;
+
+	int		cpuid;
+
+	struct coredirector_instance *inst;
+};
+
+/*
+ * Prototype defines
+ */
+static void coredirector_msr_setflag(uint64_t addr, int cpu, uint64_t flag);
+static void coredirector_get_hwtable(struct coredirector_instance *inst);
+static void coredirector_interrupt(int cpu, void *value);
+static void coredirector_identify(driver_t *driver, device_t parent);
+static int coredirector_probe(device_t dev);
+static void coredirector_set_instance(struct coredirector_softc *sc);
+static int coredirector_attach_notbsp(device_t dev);
+static int coredirector_attach(device_t dev);
+static int coredirector_detach(device_t dev);
+static int coredirector_dumptable_sysctl(SYSCTL_HANDLER_ARGS);
+
+#if defined(SMP) && defined(SCHED_ULE)
+extern struct cpu_group *cpu_top;		/* CPU topology */
+#endif
+
+/*
+ * Device methods.
+ */
+static device_method_t coredirector_methods[] = {
+	/* Device interface */
+	DEVMETHOD(device_identify,	coredirector_identify),
+	DEVMETHOD(device_probe,		coredirector_probe),
+	DEVMETHOD(device_attach,	coredirector_attach),
+	DEVMETHOD(device_detach,	coredirector_detach),
+
+	DEVMETHOD_END
+};
+
+static driver_t coredirector_driver = {
+	COREDIRECTOR_NAME,
+	coredirector_methods,
+	sizeof(struct coredirector_softc),
+};
+
+DRIVER_MODULE(coredirector, cpu, coredirector_driver, NULL, NULL);
+
+static MALLOC_DEFINE(M_COREHFI, COREDIRECTOR_NAME, "Buffers for coredirector driver");
+
+static void
+coredirector_msr_setflag(uint64_t addr, int cpu, uint64_t flag)
+{
+	uint64_t msr;
+
+	x86_msr_op(MSR_IA32_HW_FEEDBACK_THREAD_CONFIG, MSR_OP_RENDEZVOUS_ONE | MSR_OP_READ |
+				MSR_OP_CPUID(cpu), 0, &msr);
+	x86_msr_op(MSR_IA32_HW_FEEDBACK_THREAD_CONFIG, MSR_OP_RENDEZVOUS_ONE | MSR_OP_WRITE |
+				MSR_OP_CPUID(cpu), msr | flag, NULL);
+}
+
+static void
+coredirector_get_hwtable(struct coredirector_instance *inst)
+{
+	uint64_t msr_status;
+#if defined(CPUGRP_SCORE) && defined(SMP) && defined(SCHED_ULE)
+	int grp;
+	uint8_t *entry;
+	struct cpu_group *cg;
+#endif
+
+	if (! mtx_trylock_spin(&inst->intr_lock))
+		return;
+
+	/* Check HFI/ITD update status */
+	msr_status = rdmsr(MSR_IA32_PKG_THERM_STATUS);
+	if (msr_status & IA32_PKG_THERM_STATUS_HFI_UPDATED) {
+		DPRINTF("[DEBUG] HWtable UPDATED : status= %lx\n", msr_status );
+
+		/* Check HFI/ITD update's timestamp */
+		if (*(inst->cache.timestamp) != *(inst->hwtable.timestamp)) {
+			/* Copy HFI/ITD HW table to local cache */
+			mtx_lock_spin(&inst->hwtbl_lock);
+			memcpy(inst->cache.ptr, inst->hwtable.ptr, inst->tblsize);
+			mtx_unlock_spin(&inst->hwtbl_lock);
+		}
+
+		/* Clear HFI/ITD update's flag on MSR */
+		msr_status &= ~IA32_PKG_THERM_STATUS_HFI_UPDATED;
+		wrmsr(MSR_IA32_PKG_THERM_STATUS, msr_status);
+
+		/* Set Perf./Eff. valut to cpu_group structure */
+#if defined(CPUGRP_SCORE) && defined(SMP) && defined(SCHED_ULE)
+		entry = (uint8_t *)inst->cache.ptr + inst->hdrsize;
+		for(grp=0, cg=cpu_top->cg_child; grp<inst->cpugroups; grp++, cg++, entry+=inst->entrysize)
+			memcpy(cg->cg_score, entry, inst->entrysize);
+#endif
+	}
+
+	mtx_unlock_spin(&inst->intr_lock);
+}
+
+static void
+coredirector_interrupt(int cpu, void *value)
+{
+	coredirector_get_hwtable((struct coredirector_instance *)value);
+}
+
+static void
+coredirector_identify(driver_t *driver, device_t parent)
+{
+	device_t child;
+	u_int regs[4];
+
+	/* Check exist this driver */
+	if (device_find_child(parent, COREDIRECTOR_NAME, -1) != NULL)
+		return;
+
+	/* Check kernel build option with SMP & SCHED_ULE */
+#if !defined(SMP) || !defined(SCHED_ULE)
+	return;
+#endif
+
+	/* Check Intel CPU */
+	if (cpu_high < 6 || cpu_vendor_id != CPU_VENDOR_INTEL)
+		return;
+
+	/* Check Intel Hardware Feedback & Thread Director feature */
+	do_cpuid(0x06, regs);
+	if( !(regs[0] & CPUTPM1_HW_FEEDBACK) && !(regs[0] & CPUTPM1_THREAD_DIRECTOR))
+		return;
+
+	/* Regist driver */
+	child = device_add_child(parent, COREDIRECTOR_NAME, device_get_unit(parent));
+	if (child == NULL)
+		device_printf(parent, "Failure add coredirector driver\n");
+
+	return;
+}
+
+static int
+coredirector_probe(device_t dev)
+{
+	u_int regs[4];
+
+	if (resource_disabled(COREDIRECTOR_NAME, 0))
+		return (ENXIO);
+
+	/* Check Intel Hardware Feedback & Thread Director feature */
+	do_cpuid(0x06, regs);
+	if( !(regs[0] &  CPUTPM1_HW_FEEDBACK) && !(regs[0] & CPUTPM1_THREAD_DIRECTOR))
+		return (ENXIO);
+
+	/* Disable output driver features without Bootstrap CPU core */
+	if (!bootverbose && device_get_unit(dev) != 0)
+		device_quiet(dev);
+
+	if (regs[0] & CPUTPM1_HW_FEEDBACK) {
+		if (regs[0] & CPUTPM1_THREAD_DIRECTOR)
+			device_set_desc(dev, "Intel(R) Thread Director");
+		else
+			device_set_desc(dev, "Intel(R) Hardware-Feedback Interface");
+	}
+
+	return (BUS_PROBE_GENERIC);
+}
+
+static void
+coredirector_set_instance(struct coredirector_softc *sc)
+{
+	struct coredirector_softc *scbsp;
+	struct coredirector_instance *inst;
+	device_t *devchild;
+	int childs, cnt;
+
+	if (sc->inst != NULL)
+		return;
+
+	scbsp = NULL;
+	devclass_get_devices(devclass_find(COREDIRECTOR_NAME), &devchild, &childs);
+	for(cnt=0; cnt<childs && scbsp==NULL; cnt++) {
+		if(device_get_unit(*(devchild + cnt)) == 0)
+			scbsp = device_get_softc(*(devchild + cnt));
+	}
+	free(devchild, M_TEMP);
+
+	if (scbsp != NULL) {
+		inst = scbsp->inst;
+		if (NULL != inst) {
+			/* Increment instance ref.counter */
+			mtx_lock_spin(&inst->intr_lock);
+			inst->ref++;
+			mtx_unlock_spin(&inst->intr_lock);
+
+			sc->inst = inst;
+		}
+	}
+}
+
+static int
+coredirector_attach_notbsp(device_t dev)
+{
+	struct coredirector_softc *sc = device_get_softc(dev);
+
+	coredirector_set_instance(sc);
+
+	return (0);
+}
+
+static int
+coredirector_attach(device_t dev)
+{
+	int ret = 0;
+	struct coredirector_softc *sc = device_get_softc(dev);
+	struct coredirector_instance *inst;
+	u_int regs[4];
+	uint64_t msrval;
+	uint64_t capabilities;
+	uint64_t classes;
+	void *mapptr;
+
+	sc->sc_dev = dev;
+	sc->cpuid = device_get_unit(dev);
+	sc->inst = NULL;
+
+	/* Get CPUID Leaf 6 */
+	do_cpuid(0x06, regs);
+
+	/* Check performance reporting features */
+	if (!(regs[3] & CPUID_HF_PERFORMANCE)) {
+		device_printf(dev, "Not support performace reporting. - disable HFI/ITD.\n");
+		return (ENXIO);
+	}
+	/* Check efficiency reporting features */
+	if (!(regs[3] & CPUID_HF_EFFICIENCY)) {
+		device_printf(dev, "Not support performace reporting. - disable HFI/ITD.\n");
+		return (ENXIO);
+	}
+
+	/* Check & Get ITD capabilites (CP) */
+	capabilities = 2;
+	if (regs[0] & CPUTPM1_THREAD_DIRECTOR) {
+		capabilities = BITSCOUNT(regs[3] & CPUID_TD_CAPABLITIES);
+
+		if (capabilities != 2) {
+			device_printf(dev, "Not support other than 2 capablities. - disable HFI/ITD.\n");
+			return (ENXIO);
+		}
+	}
+
+	/* Check & Get ITD classes (CL) */
+	classes = 1;
+	if (regs[0] & CPUTPM1_THREAD_DIRECTOR) {
+		classes = CPUID_LEAF6_ECX_CLASSES(regs[2]);
+
+#if defined(CPUGRP_SCORE)
+		if (classes > CG_SCORE_CLASS_MAX) {
+			device_printf(dev, "Not support more than %d capablities. - disable HFI/ITD.\n",
+							CG_SCORE_CLASS_MAX);
+			return (ENXIO);
+		}
+#endif
+
+		if (classes != 4) {
+			device_printf(dev, "Not support other than 4 classes. - fallback to HFI.\n");
+			classes = 1;
+		}
+	}
+
+	/* Enable Intel ThreadDirector features for each Core */
+	if (regs[0] & CPUTPM1_THREAD_DIRECTOR)
+		coredirector_msr_setflag(MSR_IA32_HW_FEEDBACK_THREAD_CONFIG, device_get_unit(dev), 1ULL);
+
+	/* Attach for not Bootstrap Processor */
+	if (device_get_unit(dev) != 0) {
+		coredirector_attach_notbsp(dev);
+		return (0);
+	}
+
+	/* Alloc driver instance sturcture */
+	inst = (struct coredirector_instance *)malloc(sizeof(struct coredirector_instance),
+													M_COREHFI, M_NOWAIT | M_ZERO);
+	if (inst == NULL) {
+		device_printf(dev, "Not enough memory for instance structure. - disable HFI/ITD.\n");
+		return (ENOMEM);
+	}
+
+	/* Set Intel Hardware Feedback & Thread Director feature flags */
+	if (regs[0] & CPUTPM1_THREAD_DIRECTOR)
+		inst->flags.thdirector = 1;
+	if (regs[0] & CPUTPM1_HW_FEEDBACK)
+		inst->flags.hfi = 1;
+
+	/* Set Intel Hardware Feedback & Thread Director settings */
+	inst->capabilities = capabilities;
+	inst->classes = classes;
+	inst->ref = 1;
+
+	/* Get CPU groups */
+#if defined(SMP) && defined(SCHED_ULE)
+	inst->cpugroups = cpu_top->cg_children;
+#else
+	inst->cpugroups = 0;
+#endif
+
+	/* Calc. Header & Entry size */
+	inst->hdrsize = ROUNDUP8((capabilities * classes)+8);
+	inst->entrysize = ROUNDUP8(capabilities * classes);
+	inst->tblsize = ROUNDUP8(inst->hdrsize + (inst->entrysize * inst->cpugroups));
+
+	/* Alloc Cache page */
+	inst->allocsize = (CPUID_LEAF6_EDX_TBLPAGES(regs[3]) + 1) * PAGE_SIZE;
+	inst->cache.ptr = malloc(inst->allocsize, M_COREHFI, M_NOWAIT | M_ZERO);
+	if (inst->cache.ptr == NULL) {
+		device_printf(dev, "Not enough memory for local table cache. - disable HFI/ITD.\n");
+		ret = ENOMEM;
+		goto attach_err1;
+	}
+
+	/* Init. spin-lock structure */
+	mtx_init(&inst->hwtbl_lock, "coredirector HWtable lock", NULL, MTX_SPIN);
+	mtx_init(&inst->intr_lock, "coredirector Interrupt lock", NULL, MTX_SPIN);
+
+	/* Set Hardware feedback interface table */
+	msrval = rdmsr(MSR_IA32_HW_FEEDBACK_PTR);
+	if (msrval == 0) {
+		/* Alloc HFI page */
+		inst->hwtable.ptr = kmem_alloc_contig(inst->allocsize, M_NOWAIT | M_ZERO, 0, BUS_SPACE_MAXADDR,
+												PAGE_SIZE, 0, VM_MEMATTR_DEFAULT );
+		if (inst->hwtable.ptr == NULL) {
+			device_printf(dev, "Not enough memory for Hardware table. - disable HFI/ITD.\n");
+			ret = ENOMEM;
+			goto attach_err2;
+		}
+
+		inst->flags.pmaped = 0;
+
+		/* Set HFI memory page to MSR_IA32_HW_FEEDBACK_PTR MSR */
+		msrval = (uint64_t)vtophys(inst->hwtable.ptr) | IA32_HW_FEEDBACK_PTR_ENABLE;
+		wrmsr(MSR_IA32_HW_FEEDBACK_PTR, msrval);
+	} else	{
+		/* Mapping hardware feedback table physical page to kernel memory. */
+		mapptr = pmap_mapdev((msrval & ~IA32_HW_FEEDBACK_PTR_ENABLE), inst->allocsize);
+		if (NULL == mapptr)	{
+			device_printf(dev, "Not enough memory for Hardware mapping table. - disable HFI/ITD.\n");
+			ret = ENOMEM;
+			goto attach_err2;
+		}
+
+		inst->flags.pmaped = 1;
+		inst->hwtable.ptr = mapptr;
+	}
+
+	/* Enable HFI & Thread Director to MSR_IA32_HW_FEEDBACK_CONFIG MSR */
+	msrval = rdmsr(MSR_IA32_HW_FEEDBACK_CONFIG);
+	if (inst->flags.hfi)
+		msrval |= IA32_HW_FEEDBACK_CONFIG_EN_HFI;
+	if (inst->flags.thdirector)
+		msrval |= IA32_HW_FEEDBACK_CONFIG_EN_THDIR;
+	wrmsr(MSR_IA32_HW_FEEDBACK_CONFIG, msrval);
+
+	/* Init. copy Hardware feedback table to cache table when reload this module. */
+	if (inst->flags.pmaped)
+		memcpy(inst->cache.ptr, inst->hwtable.ptr, inst->allocsize);
+
+	/* Enable Local APIC thermal interrupt handle */
+	lapic_enable_thermal(coredirector_interrupt, (void *)inst);
+
+	/* Set instance for softc structure */
+	sc->inst = inst;
+
+	/* Enable HFI/ITD interrupt */
+	msrval = rdmsr(MSR_IA32_PKG_THERM_INTERRUPT) | IA32_PKG_THERM_INTERRUPT_HFI_ENABLE;
+	wrmsr(MSR_IA32_PKG_THERM_INTERRUPT, msrval);
+
+	/* Set sysctl interface */
+	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
+	    OID_AUTO, "hwtable", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
+	    dev, sizeof(dev), coredirector_dumptable_sysctl, "A", "Printout HFI/ITD HW table.");
+
+	return (0);
+
+attach_err2:
+	mtx_destroy(&inst->hwtbl_lock);
+	mtx_destroy(&inst->intr_lock);
+
+attach_err1:
+	if (inst->cache.ptr != NULL) {
+		free(inst->cache.ptr, M_COREHFI);
+		inst->cache.ptr = NULL;
+	}
+
+	if (sc->inst != NULL) {
+		free(sc->inst, M_COREHFI);
+		sc->inst = NULL;
+	}
+
+	return (ret);
+}
+
+static int
+coredirector_detach(device_t dev)
+{
+	int ref;
+	uint64_t msr_intr;
+	struct coredirector_softc *sc = device_get_softc(dev);
+	struct coredirector_instance *inst;
+
+	inst = sc->inst;
+	if (inst == NULL)
+		return (0);
+
+	/* Decrement instance ref.counter */
+	mtx_lock_spin(&inst->intr_lock);
+	ref = --(inst->ref);
+	mtx_unlock_spin(&inst->intr_lock);
+
+	/* Return if the instance is still referenced. */
+	if (ref > 0)
+		return (0);
+
+	/* Disable HFI/ITD interrupt */
+	msr_intr = rdmsr(MSR_IA32_PKG_THERM_INTERRUPT);
+	msr_intr &= ~IA32_PKG_THERM_INTERRUPT_HFI_ENABLE;
+	wrmsr(MSR_IA32_PKG_THERM_INTERRUPT, msr_intr);
+
+	/* Disable Local APIC thermal interrupt handle */
+	/* TODO:
+	 * Currently, Local APIC thermal interrupt handler is only used
+	 * by this driver, so Local APIC thermal interrupt is disabled, but
+	 * if other drivers are used in the future, instead of disabling Local
+	 * APIC thermal interrupt itself, it will be necessary to disable the
+	 * interrupt handler of this driver. Must make sure to unregister.
+	 */
+	lapic_disable_thermal();
+
+	/* Unmap Hardware feedback table physical page area */
+	if (inst->flags.pmaped)
+		pmap_unmapdev(inst->hwtable.ptr, inst->allocsize);
+
+	/*
+	 * The physical address set for MSR_IA32_HW_FEEDBACK_PTR MSR and the enable
+	 * flag set for MSR_IA32_HW_FEEDBACK_CONFIG MSR should also be disabled,
+	 * but the current CPU implementation is that the physical address once
+	 * set for MSR_IA32_HW_FEEDBACK_PTR MSR remains inside the CPU even after
+	 * being disabled.
+	 * For this reason, We have not intentionally disabled them at this time.
+	 */
+
+	/* Destroy spin-lock structure */
+	mtx_destroy(&inst->hwtbl_lock);
+	mtx_destroy(&inst->intr_lock);
+
+	/* Free cache area */
+	if (inst->cache.ptr != NULL) {
+		free(inst->cache.ptr, M_COREHFI);
+		inst->cache.ptr = NULL;
+	}
+
+	/* Free Instance */
+	free(sc->inst, M_COREHFI);
+	sc->inst = NULL;
+
+	return (0);
+}
+
+static int
+coredirector_dumptable_sysctl(SYSCTL_HANDLER_ARGS)
+{
+	device_t dev;
+	struct coredirector_softc *sc;
+	struct coredirector_instance *inst;
+	struct sbuf *buf;
+	uint8_t *entry;
+	int grp, cl, err;
+#if defined(SMP) && defined(SCHED_ULE)
+	struct cpu_group *cg;
+#endif
+
+	dev = (device_t)arg1;
+	sc = device_get_softc(dev);
+
+	inst = sc->inst;
+	KASSERT(inst != NULL, ("Not initialized coredirector instance."));
+
+	buf = sbuf_new_for_sysctl(NULL, NULL, 512, req);
+	if (buf == NULL)
+		return (ENOMEM);
+
+	sbuf_printf(buf, "\n[Dump HFI/ITD table]  TimeStamp=%lx\n", *(inst->cache.timestamp));
+
+	sbuf_cat(buf, "         ");
+	for(cl=0; cl<inst->classes; cl++)
+		sbuf_printf(buf, "  Class %d  ", cl);
+
+	sbuf_cat(buf, "\n---------");
+	for(cl=0; cl<inst->classes; cl++)
+		sbuf_cat(buf, "  Perf: Eff");
+
+#if defined(SMP) && defined(SCHED_ULE)
+	cg = cpu_top->cg_child;
+	KASSERT(cg != NULL, ("CPU topology is single."));
+#endif
+
+	for(grp=0; grp<inst->cpugroups; grp++) {
+		entry = (uint8_t *)inst->cache.ptr + inst->hdrsize + (grp * inst->entrysize);
+
+		sbuf_printf(buf, "\n  Grp %2d:", grp);
+
+		for(cl=0; cl<inst->classes; cl++, entry+=2)
+			sbuf_printf(buf, "  %3d : %3d", *(entry+0), *(entry+1));
+
+#if defined(SMP) && defined(SCHED_ULE)
+		if (cg->cg_first != cg->cg_last)
+			sbuf_printf(buf, "  (Core #%d - #%d)", cg->cg_first, cg->cg_last);
+		else
+			sbuf_printf(buf, "  (Core #%d)", cg->cg_first);
+
+		cg++;
+#endif
+	}
+
+	err = sbuf_finish(buf);
+
+	sbuf_delete(buf);
+
+	return (err);
+}
+
diff --git a/sys/modules/Makefile b/sys/modules/Makefile
index 35e5d77b9f07..bd6bce99627d 100644
--- a/sys/modules/Makefile
+++ b/sys/modules/Makefile
@@ -1,933 +1,935 @@
 
 SYSDIR?=${SRCTOP}/sys
 .include "${SYSDIR}/conf/kern.opts.mk"
 
 SUBDIR_PARALLEL=
 
 # Modules that include binary-only blobs of microcode should be selectable by
 # MK_SOURCELESS_UCODE option (see below).
 
 .include "${SYSDIR}/conf/config.mk"
 
 .if defined(MODULES_OVERRIDE) && !defined(ALL_MODULES)
 SUBDIR=${MODULES_OVERRIDE}
 .else
 SUBDIR=	\
 	${_3dfx} \
 	${_3dfx_linux} \
 	${_aac} \
 	${_aacraid} \
 	accf_data \
 	accf_dns \
 	accf_http \
 	accf_tls \
 	acl_nfs4 \
 	acl_posix1e \
 	${_acpi} \
 	ae \
 	${_aesni} \
 	age \
 	${_agp} \
 	ahci \
 	aic7xxx \
 	alc \
 	ale \
 	alq \
 	${_amd_ecc_inject} \
 	${_amdgpio} \
 	${_amdsbwd} \
 	${_amdsmn} \
 	${_amdtemp} \
 	${_aout} \
 	${_arcmsr} \
 	${_allwinner} \
 	${_armv8crypto} \
 	${_armv8_rng} \
 	${_asmc} \
 	ata \
 	ath \
 	ath_dfs \
 	ath_hal \
 	ath_hal_ar5210 \
 	ath_hal_ar5211 \
 	ath_hal_ar5212 \
 	ath_hal_ar5416 \
 	ath_hal_ar9300 \
 	ath_main \
 	ath_rate \
 	${_autofs} \
 	axgbe \
 	backlight \
 	${_bce} \
 	${_bcm283x_clkman} \
 	${_bcm283x_pwm} \
 	bfe \
 	bge \
 	bhnd \
 	${_bxe} \
 	${_bios} \
 	${_blake2} \
 	${_bnxt} \
 	bridgestp \
 	bwi \
 	bwn \
 	${_bytgpio} \
 	${_chvgpio} \
 	cam \
 	${_cardbus} \
 	${_carp} \
 	cas \
 	${_cbb} \
 	cc \
 	${_ccp} \
 	cd9660 \
 	cd9660_iconv \
 	${_cfi} \
 	${_chromebook_platform} \
 	${_ciss} \
+	${_coredirector} \
 	${_coretemp} \
 	${_cpsw} \
 	${_cpuctl} \
 	${_cpufreq} \
 	${_crypto} \
 	${_cryptodev} \
 	ctl \
 	${_cxgb} \
 	${_cxgbe} \
 	dc \
 	dcons \
 	dcons_crom \
 	${_dpaa2} \
 	${_dpdk_lpm4} \
 	${_dpdk_lpm6} \
 	${_dpms} \
 	dummynet \
 	${_dwwdt} \
 	${_e6000sw} \
 	${_efirt} \
 	${_em} \
 	${_ena} \
 	${_enic} \
 	${_enetc} \
 	${_et} \
 	evdev \
 	${_exca} \
 	ext2fs \
 	fdc \
 	fdescfs \
 	${_felix} \
 	${_ffec} \
 	${_fib_dxr} \
 	filemon \
 	firewire \
 	firmware \
 	flash \
 	${_ftgpio} \
 	${_ftwd} \
 	fusefs \
 	${_fxp} \
 	gem \
 	geom \
 	${_glxiic} \
 	${_glxsb} \
 	gpio \
 	${_gve} \
 	hid \
 	hifn \
 	${_hpt27xx} \
 	${_hptiop} \
 	${_hptmv} \
 	${_hptnr} \
 	${_hptrr} \
 	hwpmc \
 	${_hyperv} \
 	i2c \
 	${_iavf} \
         ${_ibcore} \
 	${_ichwd} \
 	${_ice} \
 	${_ice_ddp} \
 	${_irdma} \
 	${_ida} \
 	if_bridge \
 	${_if_cgem} \
 	if_disc \
 	if_edsc \
 	${_if_enc} \
 	if_epair \
 	${_genet} \
 	${_if_gif} \
 	${_if_gre} \
 	${_if_me} \
 	if_infiniband \
 	if_lagg \
 	if_ovpn \
 	${_if_stf} \
 	if_tuntap \
 	if_vlan \
 	if_vxlan \
 	${_if_wg} \
 	iflib \
 	${_igc} \
 	imgact_binmisc \
 	${_intelspi} \
 	${_io} \
 	${_ioat} \
         ${_ipoib} \
 	ipdivert \
 	${_ipfilter} \
 	${_ipfw} \
 	ipfw_nat \
 	${_ipfw_nat64} \
 	${_ipfw_nptv6} \
 	${_ipfw_pmod} \
 	${_ipmi} \
 	ip6_mroute_mod \
 	ip_mroute_mod \
 	${_ips} \
 	${_ipsec} \
 	${_ipw} \
 	${_ipwfw} \
 	${_isci} \
 	${_iser} \
 	isp \
 	${_ispfw} \
 	${_itwd} \
 	${_iwi} \
 	${_iwifw} \
 	${_iwlwifi} \
 	${_iwlwififw} \
 	${_iwm} \
 	${_iwmfw} \
 	${_iwn} \
 	${_iwnfw} \
 	${_ix} \
 	${_ixv} \
 	${_ixl} \
 	jme \
 	kbdmux \
 	kgssapi \
 	kgssapi_krb5 \
 	khelp \
 	krpc \
 	ksyms \
 	le \
 	lge \
 	libalias \
 	libiconv \
 	libmchain \
 	lindebugfs \
 	linuxkpi \
 	linuxkpi_hdmi \
 	linuxkpi_video \
 	linuxkpi_wlan \
 	${_lio} \
 	lpt \
 	${_mac_biba} \
 	${_mac_bsdextended} \
 	${_mac_ddb} \
 	${_mac_ifoff} \
 	${_mac_ipacl} \
 	${_mac_lomac} \
 	${_mac_mls} \
 	${_mac_none} \
 	${_mac_ntpd} \
 	${_mac_partition} \
 	${_mac_pimd} \
 	${_mac_portacl} \
 	${_mac_priority} \
 	${_mac_seeotheruids} \
 	${_mac_stub} \
 	${_mac_test} \
 	${_mac_veriexec} \
 	${_mac_veriexec_sha1} \
 	${_mac_veriexec_sha256} \
 	${_mac_veriexec_sha384} \
 	${_mac_veriexec_sha512} \
 	${_malo} \
 	${_mana} \
 	md \
 	mdio \
 	${_mgb} \
 	mem \
 	mfi \
 	mii \
 	mlx \
 	mlxfw \
 	${_mlx4} \
 	${_mlx4ib} \
 	${_mlx4en} \
 	${_mlx5} \
 	${_mlx5en} \
 	${_mlx5ib} \
 	mmc \
 	mmcsd \
 	${_mpi3mr} \
 	${_mpr} \
 	${_mps} \
 	mpt \
 	mqueue \
 	mrsas \
 	msdosfs \
 	msdosfs_iconv \
 	msk \
 	${_mthca} \
 	mvs \
 	mwl \
 	${_mwlfw} \
 	mxge \
 	my \
 	${_nctgpio} \
 	${_ncthwm} \
 	${_neta} \
 	netlink \
 	${_netgraph} \
 	${_nfe} \
 	nfscl \
 	nfscommon \
 	nfsd \
 	nfslockd \
 	nfssvc \
 	nlsysevent \
 	nge \
 	nmdm \
 	nullfs \
 	${_ntb} \
 	nvd \
 	${_nvdimm} \
 	nvme \
 	nvmf \
 	${_nvram} \
 	oce \
 	${_ocs_fc} \
 	${_ossl} \
 	otus \
 	${_otusfw} \
 	ow \
 	${_padlock} \
 	${_padlock_rng} \
 	${_pchtherm} \
 	${_pcfclock} \
 	${_pf} \
 	${_pflog} \
 	${_pflow} \
 	${_pfsync} \
 	plip \
 	${_pms} \
 	ppbus \
 	ppc \
 	ppi \
 	pps \
 	procfs \
 	proto \
 	pseudofs \
 	${_pst} \
 	pty  \
 	puc \
 	pwm \
 	${_qat} \
 	${_qatfw} \
 	${_qat_c2xxx} \
 	${_qat_c2xxxfw} \
 	${_qlxge} \
 	${_qlxgb} \
 	${_qlxgbe} \
 	${_qlnx} \
 	ral \
 	${_ralfw} \
 	${_random_fortuna} \
 	${_random_other} \
 	rc4 \
 	${_rdma} \
 	${_rdrand_rng} \
 	re \
 	rl \
 	${_rockchip} \
 	rtsx \
 	${_rtw88} \
 	rtwn \
 	rtwn_pci \
 	rtwn_usb \
 	${_rtwnfw} \
 	${_s3} \
 	${_safe} \
 	safexcel \
 	${_sbni} \
 	scc \
 	${_sctp} \
 	sdhci \
 	${_sdhci_acpi} \
 	${_sdhci_fdt} \
 	sdhci_pci \
 	sdio \
 	${_sff} \
 	sem \
 	send \
 	${_sfxge} \
 	sge \
 	${_sgx} \
 	${_sgx_linux} \
 	siftr \
 	siis \
 	sis \
 	sk \
 	${_smartpqi} \
 	smbfs \
 	snp \
 	sound \
 	${_speaker} \
 	spi \
 	${_splash} \
 	ste \
 	stge \
 	${_sume} \
 	${_superio} \
 	${_p2sb} \
 	sym \
 	${_syscons} \
 	sysvipc \
 	tarfs \
 	tcp \
 	${_ti} \
 	tmpfs \
 	${_toecore} \
 	tpm \
 	tws \
 	uart \
 	udf \
 	udf_iconv \
 	ufs \
 	uinput \
 	unionfs \
 	usb \
 	${_vesa} \
 	${_vf_i2c} \
 	virtio \
 	vge \
 	${_viawd} \
 	videomode \
 	vkbd \
 	${_vmd} \
 	${_vmm} \
 	${_vmware} \
 	vr \
 	vte \
 	${_wbwd} \
 	${_wdatwd} \
 	wlan \
 	wlan_acl \
 	wlan_amrr \
 	wlan_ccmp \
 	wlan_rssadapt \
 	wlan_tkip \
 	wlan_wep \
 	wlan_xauth \
 	${_wpi} \
 	${_wpifw} \
 	${_x86bios} \
 	xdr \
 	xl \
 	xz \
 	zlib
 
 .if ${MK_AUTOFS} != "no" || defined(ALL_MODULES)
 _autofs=	autofs
 .endif
 
 .if ${MK_DTRACE} != "no" || defined(ALL_MODULES)
 .if ${KERN_OPTS:MKDTRACE_HOOKS}
 SUBDIR+=	dtrace
 .endif
 SUBDIR+=	opensolaris
 .endif
 
 # Requires bus_space_read_8
 .if ${MACHINE_ARCH} != "i386"
 _bnxt=		bnxt
 .endif
 
 .if ${MK_CRYPT} != "no" || defined(ALL_MODULES)
 .if exists(${SRCTOP}/sys/opencrypto)
 _crypto=	crypto
 _cryptodev=	cryptodev
 _random_fortuna=random_fortuna
 _random_other=	random_other
 .endif
 .endif
 
 .if ${MK_CUSE} != "no" || defined(ALL_MODULES)
 SUBDIR+=	cuse
 .endif
 
 .if ${MK_EFI} != "no"
 .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64"
 _efirt=		efirt
 .endif
 .endif
 
 .if (${MK_INET_SUPPORT} != "no" || ${MK_INET6_SUPPORT} != "no") || \
 	defined(ALL_MODULES)
 _carp=		carp
 _toecore=	toecore
 _if_enc=	if_enc
 _if_gif=	if_gif
 _if_gre=	if_gre
 .if ${MK_CRYPT} != "no" || defined(ALL_MODULES)
 _if_wg=		if_wg
 .endif
 _ipfw_pmod=	ipfw_pmod
 .if ${KERN_OPTS:MIPSEC_SUPPORT} && !${KERN_OPTS:MIPSEC}
 _ipsec=		ipsec
 .endif
 .if ${KERN_OPTS:MSCTP_SUPPORT} || ${KERN_OPTS:MSCTP}
 _sctp=		sctp
 .endif
 .endif
 
 .if (${MK_INET_SUPPORT} != "no" && ${MK_INET6_SUPPORT} != "no") || \
 	defined(ALL_MODULES)
 _if_stf=	if_stf
 .endif
 
 .if ${MK_INET_SUPPORT} != "no" || defined(ALL_MODULES)
 _if_me=		if_me
 _ipfw=		ipfw
 .if ${MK_INET6_SUPPORT} != "no" || defined(ALL_MODULES)
 _ipfw_nat64=	ipfw_nat64
 .endif
 .endif
 
 .if ${MK_INET6_SUPPORT} != "no" || defined(ALL_MODULES)
 _ipfw_nptv6=	ipfw_nptv6
 .endif
 
 .if ${MK_IPFILTER} != "no" || defined(ALL_MODULES)
 _ipfilter=	ipfilter
 .endif
 
 .if ${MK_INET_SUPPORT} != "no" && ${KERN_OPTS:MFIB_ALGO}
 _dpdk_lpm4=	dpdk_lpm4
 _fib_dxr=	fib_dxr
 .endif
 
 .if ${MK_INET6_SUPPORT} != "no" && ${KERN_OPTS:MFIB_ALGO}
 _dpdk_lpm6=	dpdk_lpm6
 .endif
 
 .if ${MK_ISCSI} != "no" || defined(ALL_MODULES)
 SUBDIR+=	cfiscsi
 SUBDIR+=	iscsi
 .endif
 
 .if !empty(OPT_FDT)
 SUBDIR+=	fdt
 .endif
 
 # Linuxulator
 .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \
     ${MACHINE_CPUARCH} == "i386"
 SUBDIR+=	linprocfs
 SUBDIR+=	linsysfs
 .endif
 .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
 SUBDIR+=	linux
 .endif
 .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64"
 SUBDIR+=	linux64
 SUBDIR+=	linux_common
 .endif
 
 .if ${MACHINE_CPUARCH} != "arm"
 .if ${MK_OFED} != "no" || defined(ALL_MODULES)
 _ibcore=	ibcore
 _ipoib=		ipoib
 _iser=		iser
 _mthca=		mthca
 _rdma=		rdma
 .endif
 .endif
 
 .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \
     ${MACHINE_CPUARCH} == "i386" || ${MACHINE_ARCH:Mpowerpc64*} != ""
 _ipmi=		ipmi
 _mlx4=		mlx4
 _mlx5=		mlx5
 .if (${MK_INET_SUPPORT} != "no" && ${MK_INET6_SUPPORT} != "no") || \
 	defined(ALL_MODULES)
 _mlx4en=	mlx4en
 _mlx5en=	mlx5en
 .endif
 .if ${MK_OFED} != "no" || defined(ALL_MODULES)
 _mlx4ib=	mlx4ib
 _mlx5ib=	mlx5ib
 .endif
 .endif
 
 .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \
     ${MACHINE_CPUARCH} == "i386"
 _ena=		ena
 _gve=		gve
 _iwlwifi=	iwlwifi
 .if ${MK_SOURCELESS_UCODE} != "no"
 _iwlwififw=	iwlwififw
 .endif
 _rtw88=		rtw88
 _vmware=	vmware
 .endif
 
 .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \
     ${MACHINE_CPUARCH} == "i386" || ${MACHINE_ARCH} == "armv7"
 _ossl=		ossl
 .endif
 
 # MAC framework
 .if ${KERN_OPTS:MMAC} || defined(ALL_MODULES)
 _mac_biba=	mac_biba
 _mac_bsdextended= mac_bsdextended
 .if ${KERN_OPTS:MDDB} || defined(ALL_MODULES)
 _mac_ddb=	mac_ddb
 .endif
 _mac_ifoff=	mac_ifoff
 _mac_ipacl=	mac_ipacl
 _mac_lomac=	mac_lomac
 _mac_mls=	mac_mls
 _mac_none=	mac_none
 _mac_ntpd=	mac_ntpd
 _mac_partition=	mac_partition
 _mac_pimd=	mac_pimd
 _mac_portacl=	mac_portacl
 _mac_priority=	mac_priority
 _mac_seeotheruids= mac_seeotheruids
 _mac_stub=	mac_stub
 _mac_test=	mac_test
 .if ${MK_VERIEXEC} != "no" || defined(ALL_MODULES)
 _mac_veriexec=	mac_veriexec
 _mac_veriexec_sha1= mac_veriexec_sha1
 _mac_veriexec_sha256= mac_veriexec_sha256
 _mac_veriexec_sha384= mac_veriexec_sha384
 _mac_veriexec_sha512= mac_veriexec_sha512
 .endif
 .endif
 
 .if ${MK_NETGRAPH} != "no" || defined(ALL_MODULES)
 _netgraph=	netgraph
 .endif
 
 .if (${MK_PF} != "no" && (${MK_INET_SUPPORT} != "no" || \
 	${MK_INET6_SUPPORT} != "no")) || defined(ALL_MODULES)
 _pf=		pf
 _pflog=		pflog
 _pflow=		pflow
 .if ${MK_INET_SUPPORT} != "no"
 _pfsync=	pfsync
 .endif
 .endif
 
 .if ${MK_SOURCELESS_UCODE} != "no"
 _bce=		bce
 _fxp=		fxp
 _ispfw=		ispfw
 _ti=		ti
 _mwlfw=		mwlfw
 _otusfw=	otusfw
 _ralfw=		ralfw
 _rtwnfw=	rtwnfw
 .endif
 
 .if ${MK_SOURCELESS_UCODE} != "no" && ${MACHINE_CPUARCH} != "arm" && \
 	${MACHINE_ARCH} != "powerpc" && ${MACHINE_ARCH} != "powerpcspe" && \
 	${MACHINE_CPUARCH} != "riscv"
 _cxgbe=		cxgbe
 .endif
 
 # This has only been tested on amd64 and arm64
 .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "aarch64"
 _mpi3mr=mpi3mr
 .endif
 
 # Specific to the Raspberry Pi.
 .if ${MACHINE_CPUARCH} == "aarch64"
 _genet=		genet
 .endif
 
 .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "aarch64" || \
 	${MACHINE_ARCH:Mpowerpc64*}
 _ice=		ice
 .if ${MK_SOURCELESS_UCODE} != "no"
 _ice_ddp=	ice_ddp
 .endif
 .if ${MK_OFED} != "no" || defined(ALL_MODULES)
 .if ${MK_INET_SUPPORT} != "no" && ${MK_INET6_SUPPORT} != "no"
 _irdma=		irdma
 .endif
 .endif
 .endif
 
 .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm" || \
 	${MACHINE_CPUARCH} == "riscv"
 .if !empty(OPT_FDT)
 _if_cgem=	if_cgem
 .endif
 .endif
 
 # These rely on 64bit atomics
 .if ${MACHINE_ARCH} != "powerpc" && ${MACHINE_ARCH} != "powerpcspe"
 _mps=		mps
 _mpr=		mpr
 .endif
 
 .if ${MK_TESTS} != "no" || defined(ALL_MODULES)
 SUBDIR+=	ktest
 SUBDIR+=	tests
 .endif
 
 .if ${MK_ZFS} != "no" || defined(ALL_MODULES)
 SUBDIR+=	zfs
 .endif
 
 .if ${MK_SOURCELESS_UCODE} != "no"
 _cxgb=		cxgb
 .endif
 
 .if ${MACHINE_CPUARCH} == "aarch64"
 _armv8crypto=	armv8crypto
 _armv8_rng=	armv8_rng
 _dpaa2=		dpaa2
 _sff=		sff
 _em=		em
 _hyperv=  hyperv
 _vf_i2c=	vf_i2c
 
 .if !empty(OPT_FDT)
 _allwinner=	allwinner
 _dwwdt=		dwwdt
 _enetc=		enetc
 _felix=		felix
 _rockchip=	rockchip
 .endif
 .endif
 
 .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm"
 .if !empty(OPT_FDT)
 _sdhci_fdt=	sdhci_fdt
 .endif
 _e6000sw=	e6000sw
 _neta=		neta
 .endif
 
 .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
 _agp=		agp
 .if ${MACHINE_CPUARCH} == "i386" || !empty(COMPAT_FREEBSD32_ENABLED)
 _aout=		aout
 .endif
 _bios=		bios
 .if ${MK_SOURCELESS_UCODE} != "no"
 _bxe=		bxe
 .endif
 _cardbus=	cardbus
 _cbb=		cbb
 _cpuctl=	cpuctl
 _cpufreq=	cpufreq
 _dpms=		dpms
 _em=		em
 _et=		et
 _ftgpio=	ftgpio
 _ftwd=		ftwd
 _exca=		exca
 _igc=		igc
 _io=		io
 _itwd=		itwd
 _ix=		ix
 _ixv=		ixv
 .if ${MK_SOURCELESS_UCODE} != "no"
 _lio=		lio
 .endif
 _mana=		mana
 _mgb=		mgb
 _nctgpio=	nctgpio
 _ncthwm=	ncthwm
 _ntb=		ntb
 _ocs_fc=	ocs_fc
 _p2sb=		p2sb
 _qat_c2xxx=	qat_c2xxx
 _qat_c2xxxfw=	qat_c2xxxfw
 _safe=		safe
 _speaker=	speaker
 _splash=	splash
 _syscons=	syscons
 _wbwd=		wbwd
 _wdatwd=	wdatwd
 
 _aac=		aac
 _aacraid=	aacraid
 _acpi=		acpi
 .if ${MK_CRYPT} != "no" || defined(ALL_MODULES)
 _aesni=		aesni
 .endif
 _amd_ecc_inject=amd_ecc_inject
 _amdsbwd=	amdsbwd
 _amdsmn=	amdsmn
 _amdtemp=	amdtemp
 _arcmsr=	arcmsr
 _asmc=		asmc
 .if ${MK_CRYPT} != "no" || defined(ALL_MODULES)
 _blake2=	blake2
 .endif
 _bytgpio=	bytgpio
 _chvgpio=	chvgpio
 _ciss=		ciss
 _chromebook_platform=	chromebook_platform
+_coredirector=	coredirector
 _coretemp=	coretemp
 .if ${MK_SOURCELESS_HOST} != "no" && empty(KCSAN_ENABLED)
 _hpt27xx=	hpt27xx
 .endif
 _hptiop=	hptiop
 .if ${MK_SOURCELESS_HOST} != "no" && empty(KCSAN_ENABLED)
 _hptmv=		hptmv
 _hptnr=		hptnr
 _hptrr=		hptrr
 .endif
 _hyperv=	hyperv
 _ichwd=		ichwd
 _ida=		ida
 _intelspi=	intelspi
 _ips=		ips
 _isci=		isci
 _ipw=		ipw
 _iwi=		iwi
 _iwm=		iwm
 _iwn=		iwn
 .if ${MK_SOURCELESS_UCODE} != "no"
 _ipwfw=		ipwfw
 _iwifw=		iwifw
 _iwmfw=		iwmfw
 _iwnfw=		iwnfw
 .endif
 _nfe=		nfe
 _nvram=		nvram
 .if ${MK_CRYPT} != "no" || defined(ALL_MODULES)
 _padlock=	padlock
 _padlock_rng=	padlock_rng
 _rdrand_rng=	rdrand_rng
 .endif
 _pchtherm = pchtherm
 _s3=		s3
 _sdhci_acpi=	sdhci_acpi
 _superio=	superio
 _vesa=		vesa
 _viawd=		viawd
 _vmd=		vmd
 _wpi=		wpi
 .if ${MK_SOURCELESS_UCODE} != "no"
 _wpifw=		wpifw
 .endif
 _x86bios=	x86bios
 .endif
 
 .if ${MACHINE_CPUARCH} == "amd64"
 _amdgpio=	amdgpio
 _ccp=		ccp
 _enic=		enic
 _iavf=		iavf
 _ioat=		ioat
 _ixl=		ixl
 _nvdimm=	nvdimm
 _pms=		pms
 _qat=		qat
 .if ${MK_SOURCELESS_UCODE} != "no"
 _qatfw=		qatfw
 .endif
 _qlxge=		qlxge
 _qlxgb=		qlxgb
 _sume=		sume
 .if ${MK_SOURCELESS_UCODE} != "no"
 _qlxgbe=	qlxgbe
 _qlnx=		qlnx
 .endif
 _sfxge=		sfxge
 _sgx=		sgx
 _sgx_linux=	sgx_linux
 _smartpqi=	smartpqi
 _p2sb=		p2sb
 .endif
 
 .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64"
 .if ${MK_BHYVE} != "no" || defined(ALL_MODULES)
 .if ${KERN_OPTS:MSMP}
 _vmm=		vmm
 .endif
 .endif
 .endif
 
 .if ${MACHINE_CPUARCH} == "i386"
 # XXX some of these can move to the general case when de-i386'ed
 # XXX some of these can move now, but are untested on other architectures.
 _3dfx=		3dfx
 _3dfx_linux=	3dfx_linux
 _glxiic=	glxiic
 _glxsb=		glxsb
 _pcfclock=	pcfclock
 _pst=		pst
 _sbni=		sbni
 .endif
 
 .if ${MACHINE_ARCH} == "armv7"
 _cfi=		cfi
 _cpsw=		cpsw
 .endif
 
 .if ${MACHINE_CPUARCH} == "powerpc"
 _aacraid=	aacraid
 _agp=		agp
 _an=		an
 _cardbus=	cardbus
 _cbb=		cbb
 _cfi=		cfi
 _cpufreq=	cpufreq
 _exca=		exca
 _ffec=		ffec
 .endif
 
 .if ${MACHINE_ARCH:Mpowerpc64*} != ""
 _ixl=		ixl
 _nvram=		opal_nvram
 .endif
 
 .if ${MACHINE_CPUARCH} == "powerpc" && ${MACHINE_ARCH} != "powerpcspe"
 # Don't build powermac_nvram for powerpcspe, it's never supported.
 _nvram+=	powermac_nvram
 .endif
 
 .if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "aarch64"
 _bcm283x_clkman=  bcm283x_clkman
 _bcm283x_pwm=  bcm283x_pwm
 .endif
 
 .if !(${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} < 110000)
 # LLVM 10 crashes when building if_malo_pci.c, fixed in LLVM11:
 # https://bugs.llvm.org/show_bug.cgi?id=44351
 _malo=	malo
 .endif
 
 SUBDIR+=${MODULES_EXTRA}
 
 .for reject in ${WITHOUT_MODULES}
 SUBDIR:= ${SUBDIR:N${reject}}
 .endfor
 
 .endif # MODULES_OVERRIDE -- Keep last
 
 # Calling kldxref(8) for each module is expensive.
 .if !defined(NO_XREF)
 .MAKEFLAGS+=	-DNO_XREF
 afterinstall: .PHONY
 	${KLDXREF_CMD} ${DESTDIR}${KMODDIR}
 .if defined(NO_ROOT) && defined(METALOG)
 	echo ".${DISTBASE}${KMODDIR}/linker.hints type=file mode=0644 uname=root gname=wheel" | \
 	    cat -l >> ${METALOG}
 .endif
 .endif
 
 SUBDIR:= ${SUBDIR:u:O}
 
 .include <bsd.subdir.mk>
diff --git a/sys/modules/coredirector/Makefile b/sys/modules/coredirector/Makefile
new file mode 100644
index 000000000000..5e3674d02279
--- /dev/null
+++ b/sys/modules/coredirector/Makefile
@@ -0,0 +1,7 @@
+
+.PATH: ${SRCTOP}/sys/dev/coredirector
+
+KMOD=	coredirector
+SRCS=	coredirector.c bus_if.h device_if.h
+
+.include <bsd.kmod.mk>
-- 
2.41.0

