diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index 2fd98cb0f..7debff32f 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -65,7 +65,26 @@ LIBUHD_REGISTER_COMPONENT("USB" ENABLE_USB ON "ENABLE_LIBUHD;LIBUSB_FOUND" OFF O # Devices LIBUHD_REGISTER_COMPONENT("B100" ENABLE_B100 ON "ENABLE_LIBUHD;ENABLE_USB" OFF OFF) LIBUHD_REGISTER_COMPONENT("B200" ENABLE_B200 ON "ENABLE_LIBUHD;ENABLE_USB" OFF OFF) -LIBUHD_REGISTER_COMPONENT("B300" ENABLE_B300 ON "ENABLE_LIBUHD" OFF OFF) +# B300 support is available on Linux and Windows. +# Only Linux requires the nib310rio kernel driver userspace header. +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + find_file(NIB310RIO_HEADER + NAMES nib310rio/nib310rio.h + DOC "nib310rio kernel driver userspace header (from nib310rio-dev package)") + if(NIB310RIO_HEADER) + set(NIB310RIO_FOUND TRUE) + else() + set(NIB310RIO_FOUND FALSE) + message(STATUS "nib310rio/nib310rio.h not found — B300 support requires the nib310rio-dev package.") + endif() +elseif(WIN32) + # Windows B300 support does not depend on nib310rio/nib310rio.h. + set(NIB310RIO_FOUND TRUE) +else() + # B300 is not supported on other platforms (e.g., macOS). + set(NIB310RIO_FOUND FALSE) +endif() +LIBUHD_REGISTER_COMPONENT("B300" ENABLE_B300 ON "ENABLE_LIBUHD;NIB310RIO_FOUND" OFF OFF) LIBUHD_REGISTER_COMPONENT("USRP1" ENABLE_USRP1 ON "ENABLE_LIBUHD;ENABLE_USB" OFF OFF) LIBUHD_REGISTER_COMPONENT("USRP2" ENABLE_USRP2 ON "ENABLE_LIBUHD" OFF OFF) LIBUHD_REGISTER_COMPONENT("X300" ENABLE_X300 ON "ENABLE_LIBUHD" OFF OFF) diff --git a/host/lib/usrp/b300/b300_pcie_session_linux.cpp b/host/lib/usrp/b300/b300_pcie_session_linux.cpp index d439b6e4b..f24695cd5 100644 --- a/host/lib/usrp/b300/b300_pcie_session_linux.cpp +++ b/host/lib/usrp/b300/b300_pcie_session_linux.cpp @@ -7,7 +7,6 @@ #include "./inchworm/user/libnifpga-usrp/src/Exception.h" #include "./inchworm/user/libnifpga-usrp/src/SysfsFile.h" #include "./inchworm/user/libnifpga-usrp/src/Timer.h" -#include "./inchworm/user/libnifpga-usrp/src/nib310rio.h" #include "b300_regs.hpp" #include #include @@ -15,6 +14,7 @@ #include #include #include +#include #include #include #include diff --git a/host/lib/usrp/b300/inchworm/user/libnifpga-usrp/src/Fifo.cpp b/host/lib/usrp/b300/inchworm/user/libnifpga-usrp/src/Fifo.cpp index 79e7c0fcf..ba3d45e4b 100644 --- a/host/lib/usrp/b300/inchworm/user/libnifpga-usrp/src/Fifo.cpp +++ b/host/lib/usrp/b300/inchworm/user/libnifpga-usrp/src/Fifo.cpp @@ -15,7 +15,7 @@ #include "Fifo.h" #include "ErrnoMap.h" #include "Exception.h" -#include "nib310rio.h" +#include #include // sysconf #include // assert #include // valloc diff --git a/host/lib/usrp/b300/inchworm/user/libnifpga-usrp/src/nib310rio.h b/host/lib/usrp/b300/inchworm/user/libnifpga-usrp/src/nib310rio.h deleted file mode 100644 index 0c87279a2..000000000 --- a/host/lib/usrp/b300/inchworm/user/libnifpga-usrp/src/nib310rio.h +++ /dev/null @@ -1,68 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ -#ifndef __NIB310RIO_H__ -#define __NIB310RIO_H__ - -#include - -#define NIB310RIO_IOC_MAGIC (93) - -struct ioctl_nib310rio_array -{ - __u32 offset; - __u32 count; - __u32 data[0]; -}; - -struct ioctl_nib310rio_fifo_set_buf -{ - __u32 fd; -}; - -struct ioctl_nib310rio_fifo_acquire -{ - __aligned_u64 elements; - __aligned_u64 available; - __u32 timeout_ms; - __u32 timed_out; -}; - -struct ioctl_nib310rio_irq_wait -{ - __u32 ctx; - __u32 mask; - __u32 timeout_ms; - __u32 asserted; - __u32 timed_out; -}; - -struct ioctl_nib310rio_reg32 -{ - __u32 offset; - __u32 value; -}; - -struct ioctl_nib310rio_reg64 -{ - __u32 offset; - __u64 value; -}; - -#define NIB310RIO_IOC_FIFO_STOP _IO(NIB310RIO_IOC_MAGIC, 2) -#define NIB310RIO_IOC_FIFO_START _IO(NIB310RIO_IOC_MAGIC, 3) -#define NIB310RIO_IOC_FIFO_SET_BUF \ - _IOW(NIB310RIO_IOC_MAGIC, 4, struct ioctl_nib310rio_fifo_set_buf) -#define NIB310RIO_IOC_FIFO_ACQUIRE \ - _IOWR(NIB310RIO_IOC_MAGIC, 5, struct ioctl_nib310rio_fifo_acquire) -#define NIB310RIO_IOC_FIFO_RELEASE _IOW(NIB310RIO_IOC_MAGIC, 6, __u64) -#define NIB310RIO_IOC_FIFO_GET_AVAIL _IOR(NIB310RIO_IOC_MAGIC, 7, __u64) -#define NIB310RIO_IOC_IRQ_CTX_ALLOC _IOR(NIB310RIO_IOC_MAGIC, 10, __u32) -#define NIB310RIO_IOC_IRQ_CTX_FREE _IOW(NIB310RIO_IOC_MAGIC, 11, __u32) -#define NIB310RIO_IOC_IRQ_WAIT \ - _IOWR(NIB310RIO_IOC_MAGIC, 12, struct ioctl_nib310rio_irq_wait) -#define NIB310RIO_IOC_IRQ_ACK _IOW(NIB310RIO_IOC_MAGIC, 13, __u32) -#define NIB310RIO_IOC_PEEK32 _IOWR(NIB310RIO_IOC_MAGIC, 20, struct ioctl_nib310rio_reg32) -#define NIB310RIO_IOC_POKE32 _IOW(NIB310RIO_IOC_MAGIC, 21, struct ioctl_nib310rio_reg32) -#define NIB310RIO_IOC_PEEK64 _IOWR(NIB310RIO_IOC_MAGIC, 22, struct ioctl_nib310rio_reg64) -#define NIB310RIO_IOC_POKE64 _IOW(NIB310RIO_IOC_MAGIC, 23, struct ioctl_nib310rio_reg64) - -#endif