Index: head/sys/conf/files.amd64 =================================================================== --- head/sys/conf/files.amd64 (revision 316514) +++ head/sys/conf/files.amd64 (revision 316515) @@ -1,698 +1,700 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # # $FreeBSD$ # # 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. # # cloudabi32_vdso.o optional compat_cloudabi32 \ dependency "$S/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S" \ compile-with "${CC} -x assembler-with-cpp -m32 -shared -nostdinc -nostdlib -Wl,-T$S/compat/cloudabi/cloudabi_vdso.lds $S/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S -o ${.TARGET}" \ no-obj no-implicit-rule \ clean "cloudabi32_vdso.o" # cloudabi32_vdso_blob.o optional compat_cloudabi32 \ dependency "cloudabi32_vdso.o" \ compile-with "${OBJCOPY} --input-target binary --output-target elf64-x86-64-freebsd --binary-architecture i386 cloudabi32_vdso.o ${.TARGET}" \ no-implicit-rule \ clean "cloudabi32_vdso_blob.o" # cloudabi64_vdso.o optional compat_cloudabi64 \ dependency "$S/contrib/cloudabi/cloudabi_vdso_x86_64.S" \ compile-with "${CC} -x assembler-with-cpp -shared -nostdinc -nostdlib -Wl,-T$S/compat/cloudabi/cloudabi_vdso.lds $S/contrib/cloudabi/cloudabi_vdso_x86_64.S -o ${.TARGET}" \ no-obj no-implicit-rule \ clean "cloudabi64_vdso.o" # cloudabi64_vdso_blob.o optional compat_cloudabi64 \ dependency "cloudabi64_vdso.o" \ compile-with "${OBJCOPY} --input-target binary --output-target elf64-x86-64-freebsd --binary-architecture i386 cloudabi64_vdso.o ${.TARGET}" \ no-implicit-rule \ clean "cloudabi64_vdso_blob.o" # linux32_genassym.o optional compat_linux32 \ dependency "$S/amd64/linux32/linux32_genassym.c" \ compile-with "${CC} ${CFLAGS:N-flto:N-fno-common} -c ${.IMPSRC}" \ no-obj no-implicit-rule \ clean "linux32_genassym.o" # linux32_assym.h optional compat_linux32 \ dependency "$S/kern/genassym.sh linux32_genassym.o" \ compile-with "sh $S/kern/genassym.sh linux32_genassym.o > ${.TARGET}" \ no-obj no-implicit-rule before-depend \ clean "linux32_assym.h" # linux32_locore.o optional compat_linux32 \ dependency "linux32_assym.h $S/amd64/linux32/linux32_locore.s" \ compile-with "${CC} -x assembler-with-cpp -DLOCORE -m32 -shared -s -pipe -I. -I$S -Werror -Wall -fno-common -nostdinc -nostdlib -Wl,-T$S/amd64/linux32/linux32_vdso.lds.s -Wl,-soname=linux32_vdso.so,--eh-frame-hdr,-fPIC,-warn-common ${.IMPSRC} -o ${.TARGET}" \ no-obj no-implicit-rule \ clean "linux32_locore.o" # linux32_vdso.so optional compat_linux32 \ dependency "linux32_locore.o" \ compile-with "${OBJCOPY} --input-target binary --output-target elf64-x86-64-freebsd --binary-architecture i386 linux32_locore.o ${.TARGET}" \ no-implicit-rule \ clean "linux32_vdso.so" # ia32_genassym.o standard \ dependency "$S/compat/ia32/ia32_genassym.c" \ compile-with "${CC} ${CFLAGS:N-flto:N-fno-common} -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" # font.h optional sc_dflt_font \ compile-with "uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x16.fnt && file2c 'static u_char dflt_font_16[16*256] = {' '};' < ${SC_DFLT_FONT}-8x16 > font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x14.fnt && file2c 'static u_char dflt_font_14[14*256] = {' '};' < ${SC_DFLT_FONT}-8x14 >> font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x8.fnt && file2c 'static u_char dflt_font_8[8*256] = {' '};' < ${SC_DFLT_FONT}-8x8 >> font.h" \ no-obj no-implicit-rule before-depend \ clean "font.h ${SC_DFLT_FONT}-8x14 ${SC_DFLT_FONT}-8x16 ${SC_DFLT_FONT}-8x8" # atkbdmap.h optional atkbd_dflt_keymap \ compile-with "kbdcontrol -P ${S:S/sys$/share/}/vt/keymaps -P ${S:S/sys$/share/}/syscons/keymaps -L ${ATKBD_DFLT_KEYMAP} | sed -e 's/^static keymap_t.* = /static keymap_t key_map = /' -e 's/^static accentmap_t.* = /static accentmap_t accent_map = /' > atkbdmap.h" \ no-obj no-implicit-rule before-depend \ clean "atkbdmap.h" # ukbdmap.h optional ukbd_dflt_keymap \ compile-with "kbdcontrol -P ${S:S/sys$/share/}/vt/keymaps -P ${S:S/sys$/share/}/syscons/keymaps -L ${UKBD_DFLT_KEYMAP} | sed -e 's/^static keymap_t.* = /static keymap_t key_map = /' -e 's/^static accentmap_t.* = /static accentmap_t accent_map = /' > ukbdmap.h" \ no-obj no-implicit-rule before-depend \ clean "ukbdmap.h" # hpt27xx_lib.o optional hpt27xx \ dependency "$S/dev/hpt27xx/amd64-elf.hpt27xx_lib.o.uu" \ compile-with "uudecode < $S/dev/hpt27xx/amd64-elf.hpt27xx_lib.o.uu" \ no-implicit-rule # hptmvraid.o optional hptmv \ dependency "$S/dev/hptmv/amd64-elf.raid.o.uu" \ compile-with "uudecode < $S/dev/hptmv/amd64-elf.raid.o.uu" \ no-implicit-rule # hptnr_lib.o optional hptnr \ dependency "$S/dev/hptnr/amd64-elf.hptnr_lib.o.uu" \ compile-with "uudecode < $S/dev/hptnr/amd64-elf.hptnr_lib.o.uu" \ no-implicit-rule # hptrr_lib.o optional hptrr \ dependency "$S/dev/hptrr/amd64-elf.hptrr_lib.o.uu" \ compile-with "uudecode < $S/dev/hptrr/amd64-elf.hptrr_lib.o.uu" \ no-implicit-rule # amd64/acpica/acpi_machdep.c optional acpi acpi_wakecode.o optional acpi \ dependency "$S/amd64/acpica/acpi_wakecode.S assym.s" \ 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/atomic.c standard amd64/amd64/bios.c standard amd64/amd64/bpf_jit_machdep.c optional bpf_jitter 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.c optional efirt amd64/amd64/elf_machdep.c standard amd64/amd64/exception.S standard amd64/amd64/fpu.c standard amd64/amd64/gdb_machdep.c optional gdb amd64/amd64/in_cksum.c optional inet | inet6 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 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/prof_machdep.c optional profiling-routine amd64/amd64/ptrace_machdep.c standard amd64/amd64/sigtramp.S 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/cloudabi32/cloudabi32_sysvec.c optional compat_cloudabi32 amd64/cloudabi64/cloudabi64_sysvec.c optional compat_cloudabi64 amd64/pci/pci_cfgreg.c optional pci cddl/contrib/opensolaris/common/atomic/amd64/opensolaris_atomic.S optional zfs | dtrace compile-with "${ZFS_S}" 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}" cddl/dev/fbt/x86/fbt_isa.c optional dtrace_fbt | dtraceall compile-with "${FBT_C}" cddl/dev/dtrace/x86/dis_tables.c optional dtrace_fbt | dtraceall compile-with "${DTRACE_C}" cddl/dev/dtrace/x86/instr_size.c optional dtrace_fbt | dtraceall compile-with "${DTRACE_C}" crypto/aesni/aeskeys_amd64.S optional aesni crypto/aesni/aesni.c optional aesni aesni_ghash.o optional aesni \ dependency "$S/crypto/aesni/aesni_ghash.c" \ compile-with "${CC} -c ${CFLAGS:C/^-O2$/-O3/:N-nostdinc} ${WERROR} ${NO_WCAST_QUAL} ${PROF} -mmmx -msse -msse4 -maes -mpclmul ${.IMPSRC}" \ no-implicit-rule \ clean "aesni_ghash.o" aesni_wrap.o optional aesni \ dependency "$S/crypto/aesni/aesni_wrap.c" \ compile-with "${CC} -c ${CFLAGS:C/^-O2$/-O3/:N-nostdinc} ${WERROR} ${NO_WCAST_QUAL} ${PROF} -mmmx -msse -msse4 -maes ${.IMPSRC}" \ no-implicit-rule \ clean "aesni_wrap.o" crypto/blowfish/bf_enc.c optional crypto | ipsec | ipsec_support crypto/des/des_enc.c optional crypto | ipsec | \ ipsec_support | netsmb crypto/via/padlock.c optional padlock crypto/via/padlock_cipher.c optional padlock crypto/via/padlock_hash.c optional padlock dev/acpica/acpi_if.m standard dev/acpica/acpi_hpet.c optional acpi dev/acpica/acpi_pci.c optional acpi pci dev/acpica/acpi_pci_link.c optional acpi pci dev/acpica/acpi_pcib.c optional acpi pci dev/acpica/acpi_pcib_acpi.c optional acpi pci dev/acpica/acpi_pcib_pci.c optional acpi pci dev/acpica/acpi_timer.c optional acpi dev/acpi_support/acpi_wmi_if.m standard dev/agp/agp_amd64.c optional agp dev/agp/agp_i810.c optional agp dev/agp/agp_via.c optional agp dev/amdsbwd/amdsbwd.c optional amdsbwd dev/amdtemp/amdtemp.c optional amdtemp dev/arcmsr/arcmsr.c optional arcmsr pci dev/asmc/asmc.c optional asmc isa dev/atkbdc/atkbd.c optional atkbd atkbdc dev/atkbdc/atkbd_atkbdc.c optional atkbd atkbdc dev/atkbdc/atkbdc.c optional atkbdc dev/atkbdc/atkbdc_isa.c optional atkbdc isa dev/atkbdc/atkbdc_subr.c optional atkbdc dev/atkbdc/psm.c optional psm atkbdc dev/bxe/bxe.c optional bxe pci dev/bxe/bxe_stats.c optional bxe pci dev/bxe/bxe_debug.c optional bxe pci dev/bxe/ecore_sp.c optional bxe pci dev/bxe/bxe_elink.c optional bxe pci dev/bxe/57710_init_values.c optional bxe pci dev/bxe/57711_init_values.c optional bxe pci dev/bxe/57712_init_values.c optional bxe pci dev/coretemp/coretemp.c optional coretemp dev/cpuctl/cpuctl.c optional cpuctl dev/dpms/dpms.c optional dpms # There are no systems with isa slots, so all ed isa entries should go.. dev/ed/if_ed_3c503.c optional ed isa ed_3c503 dev/ed/if_ed_isa.c optional ed isa dev/ed/if_ed_wd80x3.c optional ed isa dev/ed/if_ed_hpp.c optional ed isa ed_hpp dev/ed/if_ed_sic.c optional ed isa ed_sic dev/fb/fb.c optional fb | vga dev/fb/s3_pci.c optional s3pci dev/fb/vesa.c optional vga vesa dev/fb/vga.c optional vga dev/ichwd/ichwd.c optional ichwd dev/if_ndis/if_ndis.c optional ndis dev/if_ndis/if_ndis_pccard.c optional ndis pccard dev/if_ndis/if_ndis_pci.c optional ndis cardbus | ndis pci dev/if_ndis/if_ndis_usb.c optional ndis usb dev/intel/spi.c optional intelspi dev/io/iodev.c optional io dev/ioat/ioat.c optional ioat pci dev/ioat/ioat_test.c optional ioat pci dev/ipmi/ipmi.c optional ipmi dev/ipmi/ipmi_acpi.c optional ipmi acpi dev/ipmi/ipmi_isa.c optional ipmi isa dev/ipmi/ipmi_kcs.c optional ipmi dev/ipmi/ipmi_smic.c optional ipmi dev/ipmi/ipmi_smbus.c optional ipmi smbus dev/ipmi/ipmi_smbios.c optional ipmi dev/ipmi/ipmi_ssif.c optional ipmi smbus dev/ipmi/ipmi_pci.c optional ipmi pci dev/ipmi/ipmi_linux.c optional ipmi compat_linux32 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_qmgr.c optional ixl pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/ixl_pf_iov.c optional ixl pci \ 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_iw.c optional ixl pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/if_ixlv.c optional ixlv pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/ixlvc.c optional ixlv pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/ixl_txrx.c optional ixl pci | ixlv pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/i40e_osdep.c optional ixl pci | ixlv pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/i40e_lan_hmc.c optional ixl pci | ixlv pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/i40e_hmc.c optional ixl pci | ixlv pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/i40e_common.c optional ixl pci | ixlv pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/i40e_nvm.c optional ixl pci | ixlv pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/i40e_adminq.c optional ixl pci | ixlv pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/fdc/fdc.c optional fdc dev/fdc/fdc_acpi.c optional fdc dev/fdc/fdc_isa.c optional fdc isa dev/fdc/fdc_pccard.c optional fdc pccard dev/gpio/bytgpio.c optional bytgpio dev/hpt27xx/hpt27xx_os_bsd.c optional hpt27xx dev/hpt27xx/hpt27xx_osm_bsd.c optional hpt27xx dev/hpt27xx/hpt27xx_config.c optional hpt27xx dev/hptmv/entry.c optional hptmv dev/hptmv/mv.c optional hptmv dev/hptmv/gui_lib.c optional hptmv dev/hptmv/hptproc.c optional hptmv dev/hptmv/ioctl.c optional hptmv dev/hptnr/hptnr_os_bsd.c optional hptnr dev/hptnr/hptnr_osm_bsd.c optional hptnr dev/hptnr/hptnr_config.c optional hptnr dev/hptrr/hptrr_os_bsd.c optional hptrr dev/hptrr/hptrr_osm_bsd.c optional hptrr dev/hptrr/hptrr_config.c optional hptrr dev/hwpmc/hwpmc_amd.c optional hwpmc dev/hwpmc/hwpmc_intel.c optional hwpmc dev/hwpmc/hwpmc_core.c optional hwpmc dev/hwpmc/hwpmc_uncore.c optional hwpmc dev/hwpmc/hwpmc_piv.c optional hwpmc dev/hwpmc/hwpmc_tsc.c optional hwpmc dev/hwpmc/hwpmc_x86.c optional hwpmc +dev/hyperv/input/hv_kbd.c optional hyperv +dev/hyperv/input/hv_kbdc.c optional hyperv dev/hyperv/pcib/vmbus_pcib.c optional hyperv pci dev/hyperv/netvsc/hn_nvs.c optional hyperv dev/hyperv/netvsc/hn_rndis.c optional hyperv dev/hyperv/netvsc/if_hn.c optional hyperv dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c optional hyperv dev/hyperv/utilities/hv_kvp.c optional hyperv dev/hyperv/utilities/hv_snapshot.c optional hyperv dev/hyperv/utilities/vmbus_heartbeat.c optional hyperv dev/hyperv/utilities/vmbus_ic.c optional hyperv dev/hyperv/utilities/vmbus_shutdown.c optional hyperv dev/hyperv/utilities/vmbus_timesync.c optional hyperv dev/hyperv/vmbus/hyperv.c optional hyperv dev/hyperv/vmbus/hyperv_busdma.c optional hyperv dev/hyperv/vmbus/vmbus.c optional hyperv pci dev/hyperv/vmbus/vmbus_br.c optional hyperv dev/hyperv/vmbus/vmbus_chan.c optional hyperv dev/hyperv/vmbus/vmbus_et.c optional hyperv dev/hyperv/vmbus/vmbus_if.m optional hyperv dev/hyperv/vmbus/vmbus_xact.c optional hyperv dev/hyperv/vmbus/amd64/hyperv_machdep.c optional hyperv dev/hyperv/vmbus/amd64/vmbus_vector.S optional hyperv dev/nctgpio/nctgpio.c optional nctgpio dev/nfe/if_nfe.c optional nfe pci dev/ntb/if_ntb/if_ntb.c optional if_ntb dev/ntb/ntb_transport.c optional if_ntb dev/ntb/ntb.c optional if_ntb | ntb_hw dev/ntb/ntb_if.m optional if_ntb | ntb_hw dev/ntb/ntb_hw/ntb_hw.c optional ntb_hw dev/nvd/nvd.c optional nvd nvme dev/nvme/nvme.c optional nvme dev/nvme/nvme_ctrlr.c optional nvme dev/nvme/nvme_ctrlr_cmd.c optional nvme dev/nvme/nvme_ns.c optional nvme dev/nvme/nvme_ns_cmd.c optional nvme dev/nvme/nvme_qpair.c optional nvme dev/nvme/nvme_sim.c optional nvme scbus !nvd dev/nvme/nvme_sysctl.c optional nvme dev/nvme/nvme_test.c optional nvme dev/nvme/nvme_util.c optional nvme dev/nvram/nvram.c optional nvram isa dev/random/ivy.c optional rdrand_rng dev/random/nehemiah.c optional padlock_rng 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/qlnx/qlnxe/ecore_cxt.c optional qlnxe pci dev/qlnx/qlnxe/ecore_dbg_fw_funcs.c optional qlnxe pci dev/qlnx/qlnxe/ecore_dcbx.c optional qlnxe pci dev/qlnx/qlnxe/ecore_dev.c optional qlnxe pci dev/qlnx/qlnxe/ecore_hw.c optional qlnxe pci dev/qlnx/qlnxe/ecore_init_fw_funcs.c optional qlnxe pci dev/qlnx/qlnxe/ecore_init_ops.c optional qlnxe pci dev/qlnx/qlnxe/ecore_int.c optional qlnxe pci dev/qlnx/qlnxe/ecore_l2.c optional qlnxe pci dev/qlnx/qlnxe/ecore_mcp.c optional qlnxe pci dev/qlnx/qlnxe/ecore_sp_commands.c optional qlnxe pci dev/qlnx/qlnxe/ecore_spq.c optional qlnxe pci dev/qlnx/qlnxe/qlnx_ioctl.c optional qlnxe pci dev/qlnx/qlnxe/qlnx_os.c optional qlnxe pci dev/sfxge/common/ef10_ev.c optional sfxge pci dev/sfxge/common/ef10_filter.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_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/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/sio/sio.c optional sio dev/sio/sio_isa.c optional sio isa dev/sio/sio_pccard.c optional sio pccard dev/sio/sio_pci.c optional sio pci dev/sio/sio_puc.c optional sio puc dev/speaker/spkr.c optional speaker dev/syscons/apm/apm_saver.c optional apm_saver apm dev/syscons/scterm-teken.c optional sc dev/syscons/scvesactl.c optional sc vga vesa dev/syscons/scvgarndr.c optional sc vga dev/syscons/scvtb.c optional sc dev/tpm/tpm.c optional tpm dev/tpm/tpm_acpi.c optional tpm acpi dev/tpm/tpm_isa.c optional tpm isa dev/uart/uart_cpu_x86.c optional uart dev/viawd/viawd.c optional viawd dev/vmware/vmxnet3/if_vmx.c optional vmx dev/wbwd/wbwd.c optional wbwd dev/wpi/if_wpi.c optional wpi dev/xen/pci/xen_acpi_pci.c optional xenhvm dev/xen/pci/xen_pci.c optional xenhvm dev/isci/isci.c optional isci dev/isci/isci_controller.c optional isci dev/isci/isci_domain.c optional isci dev/isci/isci_interrupt.c optional isci dev/isci/isci_io_request.c optional isci dev/isci/isci_logger.c optional isci dev/isci/isci_oem_parameters.c optional isci dev/isci/isci_remote_device.c optional isci dev/isci/isci_sysctl.c optional isci dev/isci/isci_task_request.c optional isci dev/isci/isci_timer.c optional isci dev/isci/scil/sati.c optional isci dev/isci/scil/sati_abort_task_set.c optional isci dev/isci/scil/sati_atapi.c optional isci dev/isci/scil/sati_device.c optional isci dev/isci/scil/sati_inquiry.c optional isci dev/isci/scil/sati_log_sense.c optional isci dev/isci/scil/sati_lun_reset.c optional isci dev/isci/scil/sati_mode_pages.c optional isci dev/isci/scil/sati_mode_select.c optional isci dev/isci/scil/sati_mode_sense.c optional isci dev/isci/scil/sati_mode_sense_10.c optional isci dev/isci/scil/sati_mode_sense_6.c optional isci dev/isci/scil/sati_move.c optional isci dev/isci/scil/sati_passthrough.c optional isci dev/isci/scil/sati_read.c optional isci dev/isci/scil/sati_read_buffer.c optional isci dev/isci/scil/sati_read_capacity.c optional isci dev/isci/scil/sati_reassign_blocks.c optional isci dev/isci/scil/sati_report_luns.c optional isci dev/isci/scil/sati_request_sense.c optional isci dev/isci/scil/sati_start_stop_unit.c optional isci dev/isci/scil/sati_synchronize_cache.c optional isci dev/isci/scil/sati_test_unit_ready.c optional isci dev/isci/scil/sati_unmap.c optional isci dev/isci/scil/sati_util.c optional isci dev/isci/scil/sati_verify.c optional isci dev/isci/scil/sati_write.c optional isci dev/isci/scil/sati_write_and_verify.c optional isci dev/isci/scil/sati_write_buffer.c optional isci dev/isci/scil/sati_write_long.c optional isci dev/isci/scil/sci_abstract_list.c optional isci dev/isci/scil/sci_base_controller.c optional isci dev/isci/scil/sci_base_domain.c optional isci dev/isci/scil/sci_base_iterator.c optional isci dev/isci/scil/sci_base_library.c optional isci dev/isci/scil/sci_base_logger.c optional isci dev/isci/scil/sci_base_memory_descriptor_list.c optional isci dev/isci/scil/sci_base_memory_descriptor_list_decorator.c optional isci dev/isci/scil/sci_base_object.c optional isci dev/isci/scil/sci_base_observer.c optional isci dev/isci/scil/sci_base_phy.c optional isci dev/isci/scil/sci_base_port.c optional isci dev/isci/scil/sci_base_remote_device.c optional isci dev/isci/scil/sci_base_request.c optional isci dev/isci/scil/sci_base_state_machine.c optional isci dev/isci/scil/sci_base_state_machine_logger.c optional isci dev/isci/scil/sci_base_state_machine_observer.c optional isci dev/isci/scil/sci_base_subject.c optional isci dev/isci/scil/sci_util.c optional isci dev/isci/scil/scic_sds_controller.c optional isci dev/isci/scil/scic_sds_library.c optional isci dev/isci/scil/scic_sds_pci.c optional isci dev/isci/scil/scic_sds_phy.c optional isci dev/isci/scil/scic_sds_port.c optional isci dev/isci/scil/scic_sds_port_configuration_agent.c optional isci dev/isci/scil/scic_sds_remote_device.c optional isci dev/isci/scil/scic_sds_remote_node_context.c optional isci dev/isci/scil/scic_sds_remote_node_table.c optional isci dev/isci/scil/scic_sds_request.c optional isci dev/isci/scil/scic_sds_sgpio.c optional isci dev/isci/scil/scic_sds_smp_remote_device.c optional isci dev/isci/scil/scic_sds_smp_request.c optional isci dev/isci/scil/scic_sds_ssp_request.c optional isci dev/isci/scil/scic_sds_stp_packet_request.c optional isci dev/isci/scil/scic_sds_stp_remote_device.c optional isci dev/isci/scil/scic_sds_stp_request.c optional isci dev/isci/scil/scic_sds_unsolicited_frame_control.c optional isci dev/isci/scil/scif_sas_controller.c optional isci dev/isci/scil/scif_sas_controller_state_handlers.c optional isci dev/isci/scil/scif_sas_controller_states.c optional isci dev/isci/scil/scif_sas_domain.c optional isci dev/isci/scil/scif_sas_domain_state_handlers.c optional isci dev/isci/scil/scif_sas_domain_states.c optional isci dev/isci/scil/scif_sas_high_priority_request_queue.c optional isci dev/isci/scil/scif_sas_internal_io_request.c optional isci dev/isci/scil/scif_sas_io_request.c optional isci dev/isci/scil/scif_sas_io_request_state_handlers.c optional isci dev/isci/scil/scif_sas_io_request_states.c optional isci dev/isci/scil/scif_sas_library.c optional isci dev/isci/scil/scif_sas_remote_device.c optional isci dev/isci/scil/scif_sas_remote_device_ready_substate_handlers.c optional isci dev/isci/scil/scif_sas_remote_device_ready_substates.c optional isci dev/isci/scil/scif_sas_remote_device_starting_substate_handlers.c optional isci dev/isci/scil/scif_sas_remote_device_starting_substates.c optional isci dev/isci/scil/scif_sas_remote_device_state_handlers.c optional isci dev/isci/scil/scif_sas_remote_device_states.c optional isci dev/isci/scil/scif_sas_request.c optional isci dev/isci/scil/scif_sas_smp_activity_clear_affiliation.c optional isci dev/isci/scil/scif_sas_smp_io_request.c optional isci dev/isci/scil/scif_sas_smp_phy.c optional isci dev/isci/scil/scif_sas_smp_remote_device.c optional isci dev/isci/scil/scif_sas_stp_io_request.c optional isci dev/isci/scil/scif_sas_stp_remote_device.c optional isci dev/isci/scil/scif_sas_stp_task_request.c optional isci dev/isci/scil/scif_sas_task_request.c optional isci dev/isci/scil/scif_sas_task_request_state_handlers.c optional isci dev/isci/scil/scif_sas_task_request_states.c optional isci dev/isci/scil/scif_sas_timer.c optional isci isa/syscons_isa.c optional sc isa/vga_isa.c optional vga kern/kern_clocksource.c standard kern/link_elf_obj.c standard libkern/x86/crc32_sse42.c standard libkern/memmove.c standard libkern/memset.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_sigtramp.S 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 compat/linprocfs/linprocfs.c optional linprocfs compat/linsysfs/linsysfs.c optional linsysfs # # Linux/i386 binary support # amd64/linux32/linux32_dummy.c optional compat_linux32 amd64/linux32/linux32_machdep.c optional compat_linux32 amd64/linux32/linux32_support.s optional compat_linux32 \ dependency "linux32_assym.h" amd64/linux32/linux32_sysent.c optional compat_linux32 amd64/linux32/linux32_sysvec.c optional compat_linux32 compat/linux/linux_emul.c optional compat_linux32 compat/linux/linux_file.c optional compat_linux32 compat/linux/linux_fork.c optional compat_linux32 compat/linux/linux_futex.c optional compat_linux32 compat/linux/linux_getcwd.c optional compat_linux32 compat/linux/linux_ioctl.c optional compat_linux32 compat/linux/linux_ipc.c optional compat_linux32 compat/linux/linux_mib.c optional compat_linux32 compat/linux/linux_misc.c optional compat_linux32 compat/linux/linux_mmap.c optional compat_linux32 compat/linux/linux_signal.c optional compat_linux32 compat/linux/linux_socket.c optional compat_linux32 compat/linux/linux_stats.c optional compat_linux32 compat/linux/linux_sysctl.c optional compat_linux32 compat/linux/linux_time.c optional compat_linux32 compat/linux/linux_timer.c optional compat_linux32 compat/linux/linux_uid16.c optional compat_linux32 compat/linux/linux_util.c optional compat_linux32 compat/linux/linux_vdso.c optional compat_linux32 compat/linux/linux_common.c optional compat_linux32 compat/linux/linux_event.c optional compat_linux32 compat/linux/linux.c optional compat_linux32 dev/amr/amr_linux.c optional compat_linux32 amr dev/mfi/mfi_linux.c optional compat_linux32 mfi # # Windows NDIS driver support # compat/ndis/kern_ndis.c optional ndisapi pci compat/ndis/kern_windrv.c optional ndisapi pci compat/ndis/subr_hal.c optional ndisapi pci compat/ndis/subr_ndis.c optional ndisapi pci compat/ndis/subr_ntoskrnl.c optional ndisapi pci compat/ndis/subr_pe.c optional ndisapi pci compat/ndis/subr_usbd.c optional ndisapi pci compat/ndis/winx64_wrap.S optional ndisapi pci # # 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 # # bvm console # dev/bvm/bvm_console.c optional bvmconsole dev/bvm/bvm_dbg.c optional bvmdebug # # x86 shared code between IA32 and AMD64 architectures # x86/acpica/OsdEnvironment.c optional acpi x86/acpica/acpi_apm.c optional acpi x86/acpica/acpi_wakeup.c optional acpi x86/acpica/madt.c optional acpi x86/acpica/srat.c optional acpi x86/bios/smbios.c optional smbios x86/bios/vpd.c optional vpd x86/cpufreq/powernow.c optional cpufreq x86/cpufreq/est.c optional cpufreq x86/cpufreq/hwpstate.c optional cpufreq x86/cpufreq/p4tcc.c optional cpufreq x86/iommu/busdma_dmar.c optional acpi acpi_dmar pci x86/iommu/intel_ctx.c optional acpi acpi_dmar pci x86/iommu/intel_drv.c optional acpi acpi_dmar pci x86/iommu/intel_fault.c optional acpi acpi_dmar pci x86/iommu/intel_gas.c optional acpi acpi_dmar pci x86/iommu/intel_idpgtbl.c optional acpi acpi_dmar pci x86/iommu/intel_intrmap.c optional acpi acpi_dmar pci x86/iommu/intel_qi.c optional acpi acpi_dmar pci x86/iommu/intel_quirks.c optional acpi acpi_dmar pci x86/iommu/intel_utils.c optional acpi acpi_dmar pci x86/isa/atpic.c optional atpic isa x86/isa/atrtc.c standard x86/isa/clock.c standard x86/isa/elcr.c optional atpic isa | mptable x86/isa/isa.c standard x86/isa/isa_dma.c standard x86/isa/nmi.c standard x86/isa/orm.c optional isa x86/pci/pci_bus.c optional pci x86/pci/qpi.c optional pci x86/x86/autoconf.c standard x86/x86/bus_machdep.c standard x86/x86/busdma_bounce.c standard x86/x86/busdma_machdep.c standard x86/x86/cpu_machdep.c standard x86/x86/dump_machdep.c standard x86/x86/fdt_machdep.c optional fdt x86/x86/identcpu.c standard x86/x86/intr_machdep.c standard x86/x86/io_apic.c standard x86/x86/legacy.c standard x86/x86/local_apic.c standard x86/x86/mca.c standard x86/x86/x86_mem.c optional mem x86/x86/mptable.c optional mptable x86/x86/mptable_pci.c optional mptable pci x86/x86/mp_x86.c optional smp x86/x86/mp_watchdog.c optional mp_watchdog smp x86/x86/msi.c optional pci x86/x86/nexus.c standard x86/x86/pvclock.c standard x86/x86/stack_machdep.c optional ddb | stack x86/x86/tsc.c standard x86/x86/delay.c standard x86/xen/hvm.c optional xenhvm x86/xen/xen_intr.c optional xenhvm x86/xen/pv.c optional xenhvm x86/xen/pvcpu_enum.c optional xenhvm x86/xen/xen_apic.c optional xenhvm x86/xen/xenpv.c optional xenhvm x86/xen/xen_nexus.c optional xenhvm x86/xen/xen_msi.c optional xenhvm x86/xen/xen_pci_bus.c optional xenhvm Index: head/sys/dev/hyperv/input/hv_kbd.c =================================================================== --- head/sys/dev/hyperv/input/hv_kbd.c (nonexistent) +++ head/sys/dev/hyperv/input/hv_kbd.c (revision 316515) @@ -0,0 +1,564 @@ +/*- + * Copyright (c) 2017 Microsoft Corp. + * 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 unmodified, 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "dev/hyperv/input/hv_kbdc.h" + +#define HVKBD_MTX_LOCK(_m) do { \ + mtx_lock(_m); \ +} while (0) + +#define HVKBD_MTX_UNLOCK(_m) do { \ + mtx_unlock(_m); \ +} while (0) + +#define HVKBD_MTX_ASSERT(_m, _t) do { \ + mtx_assert(_m, _t); \ +} while (0) + +#define HVKBD_LOCK() HVKBD_MTX_LOCK(&Giant) +#define HVKBD_UNLOCK() HVKBD_MTX_UNLOCK(&Giant) +#define HVKBD_LOCK_ASSERT() HVKBD_MTX_ASSERT(&Giant, MA_OWNED) + +#define HVKBD_FLAG_POLLING 0x00000002 + +/* early keyboard probe, not supported */ +static int +hvkbd_configure(int flags) +{ + return (0); +} + +/* detect a keyboard, not used */ +static int +hvkbd_probe(int unit, void *arg, int flags) +{ + return (ENXIO); +} + +/* reset and initialize the device, not used */ +static int +hvkbd_init(int unit, keyboard_t **kbdp, void *arg, int flags) +{ + DEBUG_HVKBD(*kbdp, "%s\n", __func__); + return (ENXIO); +} + +/* test the interface to the device, not used */ +static int +hvkbd_test_if(keyboard_t *kbd) +{ + DEBUG_HVKBD(kbd, "%s\n", __func__); + return (0); +} + +/* finish using this keyboard, not used */ +static int +hvkbd_term(keyboard_t *kbd) +{ + DEBUG_HVKBD(kbd, "%s\n", __func__); + return (ENXIO); +} + +/* keyboard interrupt routine, not used */ +static int +hvkbd_intr(keyboard_t *kbd, void *arg) +{ + DEBUG_HVKBD(kbd, "%s\n", __func__); + return (0); +} + +/* lock the access to the keyboard, not used */ +static int +hvkbd_lock(keyboard_t *kbd, int lock) +{ + DEBUG_HVKBD(kbd, "%s\n", __func__); + return (1); +} + +/* save the internal state, not used */ +static int +hvkbd_get_state(keyboard_t *kbd, void *buf, size_t len) +{ + DEBUG_HVKBD(kbd,"%s\n", __func__); + return (len == 0) ? 1 : -1; +} + +/* set the internal state, not used */ +static int +hvkbd_set_state(keyboard_t *kbd, void *buf, size_t len) +{ + DEBUG_HVKBD(kbd, "%s\n", __func__); + return (EINVAL); +} + +static int +hvkbd_poll(keyboard_t *kbd, int on) +{ + hv_kbd_sc *sc = kbd->kb_data; + + HVKBD_LOCK(); + /* + * Keep a reference count on polling to allow recursive + * cngrab() during a panic for example. + */ + if (on) + sc->sc_polling++; + else if (sc->sc_polling > 0) + sc->sc_polling--; + + if (sc->sc_polling != 0) { + sc->sc_flags |= HVKBD_FLAG_POLLING; + } else { + sc->sc_flags &= ~HVKBD_FLAG_POLLING; + } + HVKBD_UNLOCK(); + return (0); +} + +/* + * Enable the access to the device; until this function is called, + * the client cannot read from the keyboard. + */ +static int +hvkbd_enable(keyboard_t *kbd) +{ + HVKBD_LOCK(); + KBD_ACTIVATE(kbd); + HVKBD_UNLOCK(); + return (0); +} + +/* disallow the access to the device */ +static int +hvkbd_disable(keyboard_t *kbd) +{ + DEBUG_HVKBD(kbd, "%s\n", __func__); + HVKBD_LOCK(); + KBD_DEACTIVATE(kbd); + HVKBD_UNLOCK(); + return (0); +} + +static void +hvkbd_do_poll(hv_kbd_sc *sc, uint8_t wait) +{ + while (!hv_kbd_prod_is_ready(sc)) { + hv_kbd_read_channel(NULL, sc); + if (!wait) + break; + } +} + +/* check if data is waiting */ +/* Currently unused. */ +static int +hvkbd_check(keyboard_t *kbd) +{ + DEBUG_HVKBD(kbd, "%s\n", __func__); + return (0); +} + +/* check if char is waiting */ +static int +hvkbd_check_char_locked(keyboard_t *kbd) +{ + HVKBD_LOCK_ASSERT(); + if (!KBD_IS_ACTIVE(kbd)) + return (FALSE); + + hv_kbd_sc *sc = kbd->kb_data; + if (sc->sc_flags & HVKBD_FLAG_POLLING) + hvkbd_do_poll(sc, 0); + if (hv_kbd_prod_is_ready(sc)) { + return (TRUE); + } + return (FALSE); +} + +static int +hvkbd_check_char(keyboard_t *kbd) +{ + int result; + + HVKBD_LOCK(); + result = hvkbd_check_char_locked(kbd); + HVKBD_UNLOCK(); + + return (result); +} + +/* read char from the keyboard */ +static uint32_t +hvkbd_read_char_locked(keyboard_t *kbd, int wait) +{ + uint32_t scancode = NOKEY; + keystroke ks; + hv_kbd_sc *sc = kbd->kb_data; + HVKBD_LOCK_ASSERT(); + + if (!KBD_IS_ACTIVE(kbd) || !hv_kbd_prod_is_ready(sc)) + return (NOKEY); + if (sc->sc_mode == K_RAW) { + if (hv_kbd_fetch_top(sc, &ks)) { + return (NOKEY); + } + if ((ks.info & IS_E0) || (ks.info & IS_E1)) { + /** + * Emulate the generation of E0 or E1 scancode, + * the real scancode will be consumed next time. + */ + if (ks.info & IS_E0) { + scancode = XTKBD_EMUL0; + ks.info &= ~IS_E0; + } else if (ks.info & IS_E1) { + scancode = XTKBD_EMUL1; + ks.info &= ~IS_E1; + } + /** + * Change the top item to avoid encountering + * E0 or E1 twice. + */ + hv_kbd_modify_top(sc, &ks); + } else if (ks.info & IS_UNICODE) { + /** + * XXX: Hyperv host send unicode to VM through + * 'Type clipboard text', the mapping from + * unicode to scancode depends on the keymap. + * It is so complicated that we do not plan to + * support it yet. + */ + if (bootverbose) + device_printf(sc->dev, "Unsupported unicode\n"); + hv_kbd_remove_top(sc); + return (NOKEY); + } else { + scancode = ks.makecode; + if (ks.info & IS_BREAK) { + scancode |= XTKBD_RELEASE; + } + hv_kbd_remove_top(sc); + } + } else { + if (bootverbose) + device_printf(sc->dev, "Unsupported mode: %d\n", sc->sc_mode); + } + ++kbd->kb_count; + DEBUG_HVKBD(kbd, "read scan: 0x%x\n", scancode); + return scancode; +} + +/* Currently wait is always false. */ +static uint32_t +hvkbd_read_char(keyboard_t *kbd, int wait) +{ + uint32_t keycode; + + HVKBD_LOCK(); + keycode = hvkbd_read_char_locked(kbd, wait); + HVKBD_UNLOCK(); + + return (keycode); +} + +/* clear the internal state of the keyboard */ +static void +hvkbd_clear_state(keyboard_t *kbd) +{ + hv_kbd_sc *sc = kbd->kb_data; + sc->sc_state &= LOCK_MASK; /* preserve locking key state */ + sc->sc_flags &= ~HVKBD_FLAG_POLLING; +} + +static int +hvkbd_ioctl_locked(keyboard_t *kbd, u_long cmd, caddr_t arg) +{ + int i; +#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \ + defined(COMPAT_FREEBSD4) || defined(COMPAT_43) + int ival; +#endif + hv_kbd_sc *sc = kbd->kb_data; + switch (cmd) { + case KDGKBMODE: + *(int *)arg = sc->sc_mode; + break; +#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \ + defined(COMPAT_FREEBSD4) || defined(COMPAT_43) + case _IO('K', 7): + ival = IOCPARM_IVAL(arg); + arg = (caddr_t)&ival; + /* FALLTHROUGH */ +#endif + case KDSKBMODE: /* set keyboard mode */ + DEBUG_HVKBD(kbd, "expected mode: %x\n", *(int *)arg); + switch (*(int *)arg) { + case K_XLATE: + if (sc->sc_mode != K_XLATE) { + /* make lock key state and LED state match */ + sc->sc_state &= ~LOCK_MASK; + sc->sc_state |= KBD_LED_VAL(kbd); + } + /* FALLTHROUGH */ + case K_RAW: + case K_CODE: + if (sc->sc_mode != *(int *)arg) { + DEBUG_HVKBD(kbd, "mod changed to %x\n", *(int *)arg); + if ((sc->sc_flags & HVKBD_FLAG_POLLING) == 0) + hvkbd_clear_state(kbd); + sc->sc_mode = *(int *)arg; + } + break; + default: + return (EINVAL); + } + break; + case KDGKBSTATE: /* get lock key state */ + *(int *)arg = sc->sc_state & LOCK_MASK; + break; +#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \ + defined(COMPAT_FREEBSD4) || defined(COMPAT_43) + case _IO('K', 20): + ival = IOCPARM_IVAL(arg); + arg = (caddr_t)&ival; + /* FALLTHROUGH */ +#endif + case KDSKBSTATE: /* set lock key state */ + if (*(int *)arg & ~LOCK_MASK) { + return (EINVAL); + } + sc->sc_state &= ~LOCK_MASK; + sc->sc_state |= *(int *)arg; + return hvkbd_ioctl_locked(kbd, KDSETLED, arg); + case KDGETLED: /* get keyboard LED */ + *(int *)arg = KBD_LED_VAL(kbd); + break; +#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \ + defined(COMPAT_FREEBSD4) || defined(COMPAT_43) + case _IO('K', 66): + ival = IOCPARM_IVAL(arg); + arg = (caddr_t)&ival; + /* FALLTHROUGH */ +#endif + case KDSETLED: /* set keyboard LED */ + /* NOTE: lock key state in "sc_state" won't be changed */ + if (*(int *)arg & ~LOCK_MASK) + return (EINVAL); + + i = *(int *)arg; + + /* replace CAPS LED with ALTGR LED for ALTGR keyboards */ + if (sc->sc_mode == K_XLATE && + kbd->kb_keymap->n_keys > ALTGR_OFFSET) { + if (i & ALKED) + i |= CLKED; + else + i &= ~CLKED; + } + if (KBD_HAS_DEVICE(kbd)) { + DEBUG_HVSC(sc, "setled 0x%x\n", *(int *)arg); + } + + KBD_LED_VAL(kbd) = *(int *)arg; + break; + default: + return (genkbd_commonioctl(kbd, cmd, arg)); + } + return (0); +} + +/* some useful control functions */ +static int +hvkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) +{ + DEBUG_HVKBD(kbd, "%s: %lx start\n", __func__, cmd); + HVKBD_LOCK(); + int ret = hvkbd_ioctl_locked(kbd, cmd, arg); + HVKBD_UNLOCK(); + DEBUG_HVKBD(kbd, "%s: %lx end %d\n", __func__, cmd, ret); + return (ret); +} + +/* read one byte from the keyboard if it's allowed */ +/* Currently unused. */ +static int +hvkbd_read(keyboard_t *kbd, int wait) +{ + DEBUG_HVKBD(kbd, "%s\n", __func__); + HVKBD_LOCK_ASSERT(); + if (!KBD_IS_ACTIVE(kbd)) + return (-1); + return hvkbd_read_char_locked(kbd, wait); +} + +static keyboard_switch_t hvkbdsw = { + hvkbd_probe, /* not used */ + hvkbd_init, + hvkbd_term, /* not used */ + hvkbd_intr, /* not used */ + hvkbd_test_if, /* not used */ + hvkbd_enable, + hvkbd_disable, + hvkbd_read, + hvkbd_check, + hvkbd_read_char, + hvkbd_check_char, + hvkbd_ioctl, + hvkbd_lock, /* not used */ + hvkbd_clear_state, + hvkbd_get_state, /* not used */ + hvkbd_set_state, /* not used */ + genkbd_get_fkeystr, + hvkbd_poll, + genkbd_diag, +}; + +KEYBOARD_DRIVER(hvkbd, hvkbdsw, hvkbd_configure); + +void +hv_kbd_intr(hv_kbd_sc *sc) +{ + uint32_t c; + if ((sc->sc_flags & HVKBD_FLAG_POLLING) != 0) + return; + + if (KBD_IS_ACTIVE(&sc->sc_kbd) && + KBD_IS_BUSY(&sc->sc_kbd)) { + /* let the callback function process the input */ + (sc->sc_kbd.kb_callback.kc_func) (&sc->sc_kbd, KBDIO_KEYINPUT, + sc->sc_kbd.kb_callback.kc_arg); + } else { + /* read and discard the input, no one is waiting for it */ + do { + c = hvkbd_read_char(&sc->sc_kbd, 0); + } while (c != NOKEY); + } +} + +int +hvkbd_driver_load(module_t mod, int what, void *arg) +{ + switch (what) { + case MOD_LOAD: + kbd_add_driver(&hvkbd_kbd_driver); + break; + case MOD_UNLOAD: + kbd_delete_driver(&hvkbd_kbd_driver); + break; + } + return (0); +} + +int +hv_kbd_drv_attach(device_t dev) +{ + hv_kbd_sc *sc = device_get_softc(dev); + int unit = device_get_unit(dev); + keyboard_t *kbd = &sc->sc_kbd; + keyboard_switch_t *sw; + sw = kbd_get_switch(HVKBD_DRIVER_NAME); + if (sw == NULL) { + return (ENXIO); + } + + kbd_init_struct(kbd, HVKBD_DRIVER_NAME, KB_OTHER, unit, 0, 0, 0); + kbd->kb_data = (void *)sc; + kbd_set_maps(kbd, &key_map, &accent_map, fkey_tab, nitems(fkey_tab)); + KBD_FOUND_DEVICE(kbd); + hvkbd_clear_state(kbd); + KBD_PROBE_DONE(kbd); + KBD_INIT_DONE(kbd); + sc->sc_mode = K_RAW; + (*sw->enable)(kbd); + + if (kbd_register(kbd) < 0) { + goto detach; + } + KBD_CONFIG_DONE(kbd); +#ifdef KBD_INSTALL_CDEV + if (kbd_attach(kbd)) { + goto detach; + } +#endif + if (bootverbose) { + genkbd_diag(kbd, bootverbose); + } + return (0); +detach: + hv_kbd_drv_detach(dev); + return (ENXIO); +} + +int +hv_kbd_drv_detach(device_t dev) +{ + int error = 0; + hv_kbd_sc *sc = device_get_softc(dev); + hvkbd_disable(&sc->sc_kbd); + if (KBD_IS_CONFIGURED(&sc->sc_kbd)) { + error = kbd_unregister(&sc->sc_kbd); + if (error) { + device_printf(dev, "WARNING: kbd_unregister() " + "returned non-zero! (ignored)\n"); + } + } +#ifdef KBD_INSTALL_CDEV + error = kbd_detach(&sc->sc_kbd); +#endif + return (error); +} + Property changes on: head/sys/dev/hyperv/input/hv_kbd.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: head/sys/dev/hyperv/input/hv_kbdc.c =================================================================== --- head/sys/dev/hyperv/input/hv_kbdc.c (nonexistent) +++ head/sys/dev/hyperv/input/hv_kbdc.c (revision 316515) @@ -0,0 +1,532 @@ +/*- + * Copyright (c) 2017 Microsoft Corp. + * 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 unmodified, 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "dev/hyperv/input/hv_kbdc.h" +#include "vmbus_if.h" + +#define HV_KBD_VER_MAJOR (1) +#define HV_KBD_VER_MINOR (0) + +#define HV_KBD_VER (HV_KBD_VER_MINOR | (HV_KBD_VER_MAJOR) << 16) + +#define HV_KBD_PROTO_ACCEPTED (1) + +#define HV_BUFF_SIZE (4*PAGE_SIZE) +#define HV_KBD_RINGBUFF_SEND_SZ (10*PAGE_SIZE) +#define HV_KBD_RINGBUFF_RECV_SZ (10*PAGE_SIZE) + +enum hv_kbd_msg_type_t { + HV_KBD_PROTO_REQUEST = 1, + HV_KBD_PROTO_RESPONSE = 2, + HV_KBD_PROTO_EVENT = 3, + HV_KBD_PROTO_LED_INDICATORS = 4, +}; + +typedef struct hv_kbd_msg_hdr_t { + uint32_t type; +} hv_kbd_msg_hdr; + +typedef struct hv_kbd_msg_t { + hv_kbd_msg_hdr hdr; + char data[]; +} hv_kbd_msg; + +typedef struct hv_kbd_proto_req_t { + hv_kbd_msg_hdr hdr; + uint32_t ver; +} hv_kbd_proto_req; + +typedef struct hv_kbd_proto_resp_t { + hv_kbd_msg_hdr hdr; + uint32_t status; +} hv_kbd_proto_resp; + +#define HV_KBD_PROTO_REQ_SZ (sizeof(hv_kbd_proto_req)) +#define HV_KBD_PROTO_RESP_SZ (sizeof(hv_kbd_proto_resp)) + +/** + * the struct in win host: + * typedef struct _HK_MESSAGE_KEYSTROKE + * { + * HK_MESSAGE_HEADER Header; + * UINT16 MakeCode; + * UINT32 IsUnicode:1; + * UINT32 IsBreak:1; + * UINT32 IsE0:1; + * UINT32 IsE1:1; + * UINT32 Reserved:28; + * } HK_MESSAGE_KEYSTROKE + */ +typedef struct hv_kbd_keystroke_t { + hv_kbd_msg_hdr hdr; + keystroke ks; +} hv_kbd_keystroke; + +static const struct vmbus_ic_desc vmbus_kbd_descs[] = { + { + .ic_guid = { .hv_guid = { + 0x6d, 0xad, 0x12, 0xf9, 0x17, 0x2b, 0xea, 0x48, + 0xbd, 0x65, 0xf9, 0x27, 0xa6, 0x1c, 0x76, 0x84} }, + .ic_desc = "Hyper-V KBD" + }, + VMBUS_IC_DESC_END +}; + +static int hv_kbd_attach(device_t dev); +static int hv_kbd_detach(device_t dev); + +/** + * return 1 if producer is ready + */ +int +hv_kbd_prod_is_ready(hv_kbd_sc *sc) +{ + int ret; + mtx_lock(&sc->ks_mtx); + ret = !STAILQ_EMPTY(&sc->ks_queue); + mtx_unlock(&sc->ks_mtx); + return (ret); +} + +int +hv_kbd_produce_ks(hv_kbd_sc *sc, const keystroke *ks) +{ + int ret = 0; + keystroke_info *ksi; + mtx_lock(&sc->ks_mtx); + if (LIST_EMPTY(&sc->ks_free_list)) { + DEBUG_HVSC(sc, "NO buffer!\n"); + ret = 1; + } else { + ksi = LIST_FIRST(&sc->ks_free_list); + LIST_REMOVE(ksi, link); + ksi->ks = *ks; + STAILQ_INSERT_TAIL(&sc->ks_queue, ksi, slink); + } + mtx_unlock(&sc->ks_mtx); + return (ret); +} + +/** + * return 0 if successfully get the 1st item of queue without removing it + */ +int +hv_kbd_fetch_top(hv_kbd_sc *sc, keystroke *result) +{ + int ret = 0; + keystroke_info *ksi = NULL; + mtx_lock(&sc->ks_mtx); + if (STAILQ_EMPTY(&sc->ks_queue)) { + DEBUG_HVSC(sc, "Empty queue!\n"); + ret = 1; + } else { + ksi = STAILQ_FIRST(&sc->ks_queue); + *result = ksi->ks; + } + mtx_unlock(&sc->ks_mtx); + return (ret); +} + +/** + * return 0 if successfully removing the top item + */ +int +hv_kbd_remove_top(hv_kbd_sc *sc) +{ + int ret = 0; + keystroke_info *ksi = NULL; + mtx_lock(&sc->ks_mtx); + if (STAILQ_EMPTY(&sc->ks_queue)) { + DEBUG_HVSC(sc, "Empty queue!\n"); + ret = 1; + } else { + ksi = STAILQ_FIRST(&sc->ks_queue); + STAILQ_REMOVE_HEAD(&sc->ks_queue, slink); + LIST_INSERT_HEAD(&sc->ks_free_list, ksi, link); + } + mtx_unlock(&sc->ks_mtx); + return (ret); +} + +/** + * return 0 if successfully modify the 1st item of queue + */ +int +hv_kbd_modify_top(hv_kbd_sc *sc, keystroke *top) +{ + int ret = 0; + keystroke_info *ksi = NULL; + mtx_lock(&sc->ks_mtx); + if (STAILQ_EMPTY(&sc->ks_queue)) { + DEBUG_HVSC(sc, "Empty queue!\n"); + ret = 1; + } else { + ksi = STAILQ_FIRST(&sc->ks_queue); + ksi->ks = *top; + } + mtx_unlock(&sc->ks_mtx); + return (ret); +} + +static int +hv_kbd_probe(device_t dev) +{ + device_t bus = device_get_parent(dev); + const struct vmbus_ic_desc *d; + + if (resource_disabled(device_get_name(dev), 0)) + return (ENXIO); + + for (d = vmbus_kbd_descs; d->ic_desc != NULL; ++d) { + if (VMBUS_PROBE_GUID(bus, dev, &d->ic_guid) == 0) { + device_set_desc(dev, d->ic_desc); + return (BUS_PROBE_DEFAULT); + } + } + return (ENXIO); +} + +static void +hv_kbd_on_response(hv_kbd_sc *sc, struct vmbus_chanpkt_hdr *pkt) +{ + struct vmbus_xact_ctx *xact = sc->hs_xact_ctx; + if (xact != NULL) { + DEBUG_HVSC(sc, "hvkbd is ready\n"); + vmbus_xact_ctx_wakeup(xact, VMBUS_CHANPKT_CONST_DATA(pkt), + VMBUS_CHANPKT_DATALEN(pkt)); + } +} + +static void +hv_kbd_on_received(hv_kbd_sc *sc, struct vmbus_chanpkt_hdr *pkt) +{ + + const hv_kbd_msg *msg = VMBUS_CHANPKT_CONST_DATA(pkt); + const hv_kbd_proto_resp *resp = + VMBUS_CHANPKT_CONST_DATA(pkt); + const hv_kbd_keystroke *keystroke = + VMBUS_CHANPKT_CONST_DATA(pkt); + uint32_t msg_len = VMBUS_CHANPKT_DATALEN(pkt); + enum hv_kbd_msg_type_t msg_type; + uint32_t info; + uint16_t scan_code; + + if (msg_len <= sizeof(hv_kbd_msg)) { + device_printf(sc->dev, "Illegal packet\n"); + return; + } + msg_type = msg->hdr.type; + switch (msg_type) { + case HV_KBD_PROTO_RESPONSE: + hv_kbd_on_response(sc, pkt); + DEBUG_HVSC(sc, "keyboard resp: 0x%x\n", + resp->status); + break; + case HV_KBD_PROTO_EVENT: + info = keystroke->ks.info; + scan_code = keystroke->ks.makecode; + DEBUG_HVSC(sc, "keystroke info: 0x%x, scan: 0x%x\n", + info, scan_code); + hv_kbd_produce_ks(sc, &keystroke->ks); + hv_kbd_intr(sc); + default: + break; + } +} + +void +hv_kbd_read_channel(struct vmbus_channel *channel, void *context) +{ + uint8_t *buf; + uint32_t buflen = 0; + int ret = 0; + + hv_kbd_sc *sc = (hv_kbd_sc*)context; + channel = vmbus_get_channel(sc->dev); + buf = sc->buf; + buflen = sc->buflen; + for (;;) { + struct vmbus_chanpkt_hdr *pkt = (struct vmbus_chanpkt_hdr *)buf; + uint32_t rxed = buflen; + + ret = vmbus_chan_recv_pkt(channel, pkt, &rxed); + if (__predict_false(ret == ENOBUFS)) { + buflen = sc->buflen * 2; + while (buflen < rxed) + buflen *= 2; + buf = malloc(buflen, M_DEVBUF, M_WAITOK | M_ZERO); + device_printf(sc->dev, "expand recvbuf %d -> %d\n", + sc->buflen, buflen); + free(sc->buf, M_DEVBUF); + sc->buf = buf; + sc->buflen = buflen; + continue; + } else if (__predict_false(ret == EAGAIN)) { + /* No more channel packets; done! */ + break; + } + KASSERT(!ret, ("vmbus_chan_recv_pkt failed: %d", ret)); + + DEBUG_HVSC(sc, "event: 0x%x\n", pkt->cph_type); + switch (pkt->cph_type) { + case VMBUS_CHANPKT_TYPE_COMP: + case VMBUS_CHANPKT_TYPE_RXBUF: + device_printf(sc->dev, "unhandled event: %d\n", + pkt->cph_type); + break; + case VMBUS_CHANPKT_TYPE_INBAND: + hv_kbd_on_received(sc, pkt); + break; + default: + device_printf(sc->dev, "unknown event: %d\n", + pkt->cph_type); + break; + } + } +} + +static int +hv_kbd_connect_vsp(hv_kbd_sc *sc) +{ + int ret; + size_t resplen; + struct vmbus_xact *xact; + hv_kbd_proto_req *req; + const hv_kbd_proto_resp *resp; + + xact = vmbus_xact_get(sc->hs_xact_ctx, sizeof(*req)); + if (xact == NULL) { + device_printf(sc->dev, "no xact for kbd init"); + return (ENODEV); + } + req = vmbus_xact_req_data(xact); + req->hdr.type = HV_KBD_PROTO_REQUEST; + req->ver = HV_KBD_VER; + + vmbus_xact_activate(xact); + ret = vmbus_chan_send(sc->hs_chan, + VMBUS_CHANPKT_TYPE_INBAND, + VMBUS_CHANPKT_FLAG_RC, + req, sizeof(hv_kbd_proto_req), + (uint64_t)(uintptr_t)xact); + if (ret) { + device_printf(sc->dev, "fail to send\n"); + vmbus_xact_deactivate(xact); + return (ret); + } + resp = vmbus_chan_xact_wait(sc->hs_chan, xact, &resplen, true); + if (resplen < HV_KBD_PROTO_RESP_SZ) { + device_printf(sc->dev, "hv_kbd init communicate failed\n"); + ret = ENODEV; + goto clean; + } + + if (!(resp->status & HV_KBD_PROTO_ACCEPTED)) { + device_printf(sc->dev, "hv_kbd protocol request failed\n"); + ret = ENODEV; + } +clean: + vmbus_xact_put(xact); + DEBUG_HVSC(sc, "finish connect vsp\n"); + return (ret); +} + +static int +hv_kbd_attach1(device_t dev, vmbus_chan_callback_t cb) +{ + int ret; + hv_kbd_sc *sc; + + sc = device_get_softc(dev); + sc->buflen = HV_BUFF_SIZE; + sc->buf = malloc(sc->buflen, M_DEVBUF, M_WAITOK | M_ZERO); + vmbus_chan_set_readbatch(sc->hs_chan, false); + ret = vmbus_chan_open( + sc->hs_chan, + HV_KBD_RINGBUFF_SEND_SZ, + HV_KBD_RINGBUFF_RECV_SZ, + NULL, 0, + cb, + sc); + if (ret != 0) { + free(sc->buf, M_DEVBUF); + } + return (ret); +} + +static int +hv_kbd_detach1(device_t dev) +{ + hv_kbd_sc *sc = device_get_softc(dev); + vmbus_chan_close(vmbus_get_channel(dev)); + free(sc->buf, M_DEVBUF); + return (0); +} + +static void +hv_kbd_init(hv_kbd_sc *sc) +{ + const int max_list = 16; + int i; + keystroke_info *ksi; + + mtx_init(&sc->ks_mtx, "hv_kbdc mutex", NULL, MTX_DEF); + LIST_INIT(&sc->ks_free_list); + STAILQ_INIT(&sc->ks_queue); + for (i = 0; i < max_list; i++) { + ksi = malloc(sizeof(keystroke_info), + M_DEVBUF, M_WAITOK|M_ZERO); + LIST_INSERT_HEAD(&sc->ks_free_list, ksi, link); + } +} + +static void +hv_kbd_fini(hv_kbd_sc *sc) +{ + keystroke_info *ksi; + while (!LIST_EMPTY(&sc->ks_free_list)) { + ksi = LIST_FIRST(&sc->ks_free_list); + LIST_REMOVE(ksi, link); + free(ksi, M_DEVBUF); + } + while (!STAILQ_EMPTY(&sc->ks_queue)) { + ksi = STAILQ_FIRST(&sc->ks_queue); + STAILQ_REMOVE_HEAD(&sc->ks_queue, slink); + free(ksi, M_DEVBUF); + } + mtx_destroy(&sc->ks_mtx); +} + +static void +hv_kbd_sysctl(device_t dev) +{ + struct sysctl_oid_list *child; + struct sysctl_ctx_list *ctx; + hv_kbd_sc *sc; + + sc = device_get_softc(dev); + ctx = device_get_sysctl_ctx(dev); + child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); + SYSCTL_ADD_INT(ctx, child, OID_AUTO, "debug", CTLFLAG_RW, + &sc->debug, 0, "debug hyperv keyboard"); +} + +static int +hv_kbd_attach(device_t dev) +{ + int error = 0; + hv_kbd_sc *sc; + + sc = device_get_softc(dev); + sc->hs_chan = vmbus_get_channel(dev); + sc->dev = dev; + hv_kbd_init(sc); + sc->hs_xact_ctx = vmbus_xact_ctx_create(bus_get_dma_tag(dev), + HV_KBD_PROTO_REQ_SZ, HV_KBD_PROTO_RESP_SZ, 0); + if (sc->hs_xact_ctx == NULL) { + error = ENOMEM; + goto failed; + } + + error = hv_kbd_attach1(dev, hv_kbd_read_channel); + if (error) + goto failed; + error = hv_kbd_connect_vsp(sc); + if (error) + goto failed; + + error = hv_kbd_drv_attach(dev); + if (error) + goto failed; + hv_kbd_sysctl(dev); + return (0); +failed: + hv_kbd_detach(dev); + return (error); +} + +static int +hv_kbd_detach(device_t dev) +{ + int ret; + hv_kbd_sc *sc = device_get_softc(dev); + hv_kbd_fini(sc); + if (sc->hs_xact_ctx != NULL) + vmbus_xact_ctx_destroy(sc->hs_xact_ctx); + ret = hv_kbd_detach1(dev); + if (!ret) + device_printf(dev, "Fail to detach\n"); + return hv_kbd_drv_detach(dev); +} + +static device_method_t kbd_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, hv_kbd_probe), + DEVMETHOD(device_attach, hv_kbd_attach), + DEVMETHOD(device_detach, hv_kbd_detach), + { 0, 0 } +}; + +static driver_t kbd_driver = {HVKBD_DRIVER_NAME , kbd_methods, sizeof(hv_kbd_sc)}; + +static devclass_t kbd_devclass; + +DRIVER_MODULE(hv_kbd, vmbus, kbd_driver, kbd_devclass, hvkbd_driver_load, NULL); +MODULE_VERSION(hv_kbd, 1); +MODULE_DEPEND(hv_kbd, vmbus, 1, 1, 1); Property changes on: head/sys/dev/hyperv/input/hv_kbdc.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: head/sys/dev/hyperv/input/hv_kbdc.h =================================================================== --- head/sys/dev/hyperv/input/hv_kbdc.h (nonexistent) +++ head/sys/dev/hyperv/input/hv_kbdc.h (revision 316515) @@ -0,0 +1,104 @@ +/*- + * Copyright (c) 2017 Microsoft Corp. + * 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 unmodified, 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. + * + * $FreeBSD$ + */ + +#ifndef _HV_KBD_H +#define _HV_KBD_H +#include +#include +#include +#include +#include + +#include + +#define HVKBD_DRIVER_NAME "hvkbd" +#define IS_UNICODE (1) +#define IS_BREAK (2) +#define IS_E0 (4) +#define IS_E1 (8) + +#define XTKBD_EMUL0 (0xe0) +#define XTKBD_EMUL1 (0xe1) +#define XTKBD_RELEASE (0x80) + +#define DEBUG_HVSC(sc, ...) do { \ + if (sc->debug > 0) { \ + device_printf(sc->dev, __VA_ARGS__); \ + } \ +} while (0) +#define DEBUG_HVKBD(kbd, ...) do { \ + hv_kbd_sc *sc = (kbd)->kb_data; \ + DEBUG_HVSC(sc, __VA_ARGS__); \ +} while (0) + +struct vmbus_channel; +struct vmbus_xact_ctx; + +typedef struct keystroke_t { + uint16_t makecode; + uint32_t info; +} keystroke; + +typedef struct keystroke_info { + LIST_ENTRY(keystroke_info) link; + STAILQ_ENTRY(keystroke_info) slink; + keystroke ks; +} keystroke_info; + +typedef struct hv_kbd_sc_t { + struct vmbus_channel *hs_chan; + device_t dev; + struct vmbus_xact_ctx *hs_xact_ctx; + int32_t buflen; + uint8_t *buf; + + struct mtx ks_mtx; + LIST_HEAD(, keystroke_info) ks_free_list; + STAILQ_HEAD(, keystroke_info) ks_queue; /* keystroke info queue */ + + keyboard_t sc_kbd; + int sc_mode; + int sc_state; + int sc_polling; /* polling recursion count */ + uint32_t sc_flags; + int debug; +} hv_kbd_sc; + +int hv_kbd_produce_ks(hv_kbd_sc *sc, const keystroke *ks); +int hv_kbd_fetch_top(hv_kbd_sc *sc, keystroke *top); +int hv_kbd_modify_top(hv_kbd_sc *sc, keystroke *top); +int hv_kbd_remove_top(hv_kbd_sc *sc); +int hv_kbd_prod_is_ready(hv_kbd_sc *sc); +void hv_kbd_read_channel(struct vmbus_channel *, void *); + +int hv_kbd_drv_attach(device_t dev); +int hv_kbd_drv_detach(device_t dev); + +int hvkbd_driver_load(module_t, int, void *); +void hv_kbd_intr(hv_kbd_sc *sc); +#endif Property changes on: head/sys/dev/hyperv/input/hv_kbdc.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property