This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 43603190c7c19449dfce8c8056549b030a6790fa Author: Bowen Wang <[email protected]> AuthorDate: Mon Oct 26 11:45:16 2026 +0800 drivers/ivshmem: move the ivshmem drivers out of drivers/pci The uio, ramdisk and noteram ivshmem drivers only use the ivshmem bus, but they were built inside the CONFIG_PCI block of drivers/pci and, like rptun_ivshmem, registered from pci_register_drivers(), which only runs on machines with a PCI bus. With the ivshmem-flat backend they are needed without PCI as well. Move the three drivers to drivers/ivshmem and register all four from a new ivshmem_register_drivers(), called by drivers_initialize() before the PCI drivers so they are on the bus when either backend probes. They and RPTUN_IVSHMEM now depend on IVSHMEM instead of PCI_IVSHMEM, and the three drop the PCI_ prefix from their Kconfig names (no defconfig in the tree uses them). PCI_RTT_IVSHMEM stays in drivers/pci because it is handled in pci_ivshmem.c. The PCI naming goes too: the register functions become ivshmem_{uio,ramdisk,noteram}_register() and rptun_ivshmem_register{,_slave}(), and pcierr()/pciinfo() become _err()/_info() in the three drivers and rptunerr()/rptuninfo() in rptun_ivshmem.c, so the logs no longer depend on CONFIG_DEBUG_PCI. Signed-off-by: Bowen Wang <[email protected]> --- drivers/drivers_initialize.c | 5 ++ drivers/ivshmem/CMakeLists.txt | 12 ++++- drivers/ivshmem/Kconfig | 35 ++++++++++++++ drivers/ivshmem/Make.defs | 8 ++++ drivers/ivshmem/ivshmem.c | 38 +++++++++++++++ .../ivshmem/ivshmem_drivers.h | 54 ++++++---------------- .../ivshmem_ramdisk.c} | 18 ++++---- .../pci_uio_ivshmem.c => ivshmem/ivshmem_uio.c} | 26 ++++++----- drivers/pci/CMakeLists.txt | 8 ---- drivers/pci/Kconfig | 35 -------------- drivers/pci/Make.defs | 8 ---- drivers/pci/pci_drivers.c | 27 ----------- drivers/pci/pci_drivers.h | 8 ---- drivers/rptun/Kconfig | 4 +- drivers/rptun/rptun_ivshmem.c | 18 ++++---- include/nuttx/ivshmem.h | 11 +++++ include/nuttx/rptun/rptun_ivshmem.h | 8 ++-- 17 files changed, 160 insertions(+), 163 deletions(-) diff --git a/drivers/drivers_initialize.c b/drivers/drivers_initialize.c index 2c302e8e60c..a6af3b7efe6 100644 --- a/drivers/drivers_initialize.c +++ b/drivers/drivers_initialize.c @@ -35,6 +35,7 @@ #include <nuttx/fs/smart.h> #include <nuttx/fs/loopmtd.h> #include <nuttx/input/uinput.h> +#include <nuttx/ivshmem.h> #include <nuttx/mtd/mtd.h> #include <nuttx/net/loopback.h> #include <nuttx/net/rpmsgdrv.h> @@ -315,6 +316,10 @@ void drivers_initialize(void) usbhost_drivers_initialize(); #endif +#ifdef CONFIG_IVSHMEM + ivshmem_register_drivers(); +#endif + #if defined(CONFIG_PCI) && !defined(CONFIG_PCI_LATE_DRIVERS_REGISTER) pci_register_drivers(); #endif diff --git a/drivers/ivshmem/CMakeLists.txt b/drivers/ivshmem/CMakeLists.txt index 2ed330c558f..76ab056b2e4 100644 --- a/drivers/ivshmem/CMakeLists.txt +++ b/drivers/ivshmem/CMakeLists.txt @@ -20,5 +20,15 @@ # if(CONFIG_IVSHMEM) - target_sources(drivers PRIVATE ivshmem.c) + set(SRCS ivshmem.c) + + if(CONFIG_RAMDISK_IVSHMEM) + list(APPEND SRCS ivshmem_ramdisk.c) + endif() + + if(CONFIG_UIO_IVSHMEM) + list(APPEND SRCS ivshmem_uio.c) + endif() + + target_sources(drivers PRIVATE ${SRCS}) endif() diff --git a/drivers/ivshmem/Kconfig b/drivers/ivshmem/Kconfig index 280197042ba..1989cc54eaa 100644 --- a/drivers/ivshmem/Kconfig +++ b/drivers/ivshmem/Kconfig @@ -10,3 +10,38 @@ config IVSHMEM Inter-VM shared memory bus. Matches ivshmem devices registered by a backend (e.g. PCI) with the drivers that use them. Selected by the backends, not chosen directly. + +config RAMDISK_IVSHMEM + bool "Ramdisk ivshmem driver" + default n + depends on IVSHMEM && !DISABLE_MOUNTPOINT + ---help--- + Enable ramdisk device driver. + +config RAMDISK_IVSHMEM_IDTABLE + string "The id table of ramdisk ivshmem device" + depends on RAMDISK_IVSHMEM + ---help--- + "id0;id1;id2", e.g.: "0;1;2" + + +config UIO_IVSHMEM + bool "Enable uio ivshmem driver support" + default n + depends on IVSHMEM + ---help--- + When this option is enabled, char ivshmem driver will register + char device with name: "/dev/uioX" to the VFS, then + application can open this device and use `mmap()` to get the + share memory provided by ivshmem device. + +config UIO_IVSHMEM_IDTABLE + string "The id table of uio ivshmem device" + depends on UIO_IVSHMEM + ---help--- + "id0;id1;id2", e.g.: "0;1;2" + +config UIO_IVSHMEM_NPOLLWAITERS + int "Uio ivshmem poll waiter number" + default 2 + depends on UIO_IVSHMEM diff --git a/drivers/ivshmem/Make.defs b/drivers/ivshmem/Make.defs index 7166e941608..212359db14f 100644 --- a/drivers/ivshmem/Make.defs +++ b/drivers/ivshmem/Make.defs @@ -24,6 +24,14 @@ ifeq ($(CONFIG_IVSHMEM),y) CSRCS += ivshmem.c +ifeq ($(CONFIG_RAMDISK_IVSHMEM),y) +CSRCS += ivshmem_ramdisk.c +endif + +ifeq ($(CONFIG_UIO_IVSHMEM),y) +CSRCS += ivshmem_uio.c +endif + DEPPATH += --dep-path ivshmem VPATH += :ivshmem diff --git a/drivers/ivshmem/ivshmem.c b/drivers/ivshmem/ivshmem.c index ea9449056b8..d3fd06d6342 100644 --- a/drivers/ivshmem/ivshmem.c +++ b/drivers/ivshmem/ivshmem.c @@ -34,6 +34,9 @@ #include <nuttx/mutex.h> #include <nuttx/percpu.h> #include <nuttx/ivshmem.h> +#include <nuttx/rptun/rptun_ivshmem.h> + +#include "ivshmem_drivers.h" /**************************************************************************** * Private Types @@ -370,3 +373,38 @@ int ivshmem_unregister_driver(FAR struct ivshmem_driver_s *drv) nxmutex_unlock(&g_ivshmem_bus.lock); return ret; } + +/**************************************************************************** + * Name: ivshmem_register_drivers + ****************************************************************************/ + +void ivshmem_register_drivers(void) +{ + int ret = OK; + +#ifdef CONFIG_RAMDISK_IVSHMEM + ret = ivshmem_ramdisk_register(); + if (ret < 0) + { + _err("ivshmem_ramdisk_register failed, ret=%d\n", ret); + } +#endif + +#ifdef CONFIG_UIO_IVSHMEM + ret = ivshmem_uio_register(); + if (ret < 0) + { + _err("ivshmem_uio_register failed, ret=%d\n", ret); + } +#endif + +#ifdef CONFIG_RPTUN_IVSHMEM + ret = rptun_ivshmem_register(); + if (ret < 0) + { + _err("rptun_ivshmem_register failed, ret=%d\n", ret); + } +#endif + + UNUSED(ret); +} diff --git a/include/nuttx/rptun/rptun_ivshmem.h b/drivers/ivshmem/ivshmem_drivers.h similarity index 56% copy from include/nuttx/rptun/rptun_ivshmem.h copy to drivers/ivshmem/ivshmem_drivers.h index ea5a33d0342..b5409ee9b37 100644 --- a/include/nuttx/rptun/rptun_ivshmem.h +++ b/drivers/ivshmem/ivshmem_drivers.h @@ -1,5 +1,5 @@ /**************************************************************************** - * include/nuttx/rptun/rptun_ivshmem.h + * drivers/ivshmem/ivshmem_drivers.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __INCLUDE_NUTTX_RPTUN_RPTUN_IVSHMEM_H -#define __INCLUDE_NUTTX_RPTUN_RPTUN_IVSHMEM_H +#ifndef __DRIVERS_IVSHMEM_IVSHMEM_DRIVERS_H +#define __DRIVERS_IVSHMEM_IVSHMEM_DRIVERS_H /**************************************************************************** * Included Files @@ -29,60 +29,32 @@ #include <nuttx/config.h> -#ifdef CONFIG_RPTUN_IVSHMEM - /**************************************************************************** * Public Function Prototypes ****************************************************************************/ -#ifdef __cplusplus -extern "C" -{ -#endif - /**************************************************************************** - * Name: pci_register_rptun_ivshmem_driver + * Name: ivshmem_uio_register * * Description: - * Initializes the rptun ivshmem driver. - * - * Returned Value: - * OK on success, negated errno on failure + * Register uio ivshmem device driver * ****************************************************************************/ -int pci_register_rptun_ivshmem_driver(void); +#ifdef CONFIG_UIO_IVSHMEM +int ivshmem_uio_register(void); +#endif /**************************************************************************** - * Name: pci_register_rptun_ivshmem_slave_driver + * Name: ivshmem_ramdisk_register * * Description: - * Register the RPMsg RPTUN ivshmem driver configuration. - * This function initializes the shared resource table for RPMsg - * communication and registers the ivshmem driver with the specified - * CPU name and driver ID. It is typically called during system - * initialization to set up inter-processor communication (IPC) - * between RPMsg peers. - * - * Input Parameters: - * cpuname - The remote CPU name string - * drvid - Driver ID for registration - * rsc_table - Pointer to the resource table header - * rsc_size - Size of the resource table header - * - * Returned Value: - * Zero (OK) on success; a negated errno value on failure. + * Register ramdisk ivshmem device driver * ****************************************************************************/ -int pci_register_rptun_ivshmem_slave_driver( - FAR const char *cpuname, int drvid, - FAR const struct resource_table *rsc_table, - size_t rsc_size); - -#ifdef __cplusplus -} +#ifdef CONFIG_RAMDISK_IVSHMEM +int ivshmem_ramdisk_register(void); #endif -#endif /* CONFIG_RPTUN_IVSHMEM */ -#endif /* __INCLUDE_NUTTX_RPTUN_RPTUN_IVSHMEM_H */ +#endif /* __DRIVERS_IVSHMEM_IVSHMEM_DRIVERS_H */ diff --git a/drivers/pci/pci_ramdisk_ivshmem.c b/drivers/ivshmem/ivshmem_ramdisk.c similarity index 89% rename from drivers/pci/pci_ramdisk_ivshmem.c rename to drivers/ivshmem/ivshmem_ramdisk.c index 83e2a64470a..bf018efb2f1 100644 --- a/drivers/pci/pci_ramdisk_ivshmem.c +++ b/drivers/ivshmem/ivshmem_ramdisk.c @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/pci/pci_ramdisk_ivshmem.c + * drivers/ivshmem/ivshmem_ramdisk.c * * SPDX-License-Identifier: Apache-2.0 * @@ -32,7 +32,9 @@ #include <nuttx/drivers/ramdisk.h> #include <nuttx/kmalloc.h> -#include <nuttx/pci/pci_ivshmem.h> +#include <nuttx/ivshmem.h> + +#include "ivshmem_drivers.h" /**************************************************************************** * Pre-processor Definitions @@ -73,11 +75,11 @@ static int ramdisk_ivshmem_probe(FAR struct ivshmem_device_s *dev) ret = ramdisk_register_with_config(&config); if (ret < 0) { - pcierr("ERROR: ramdisk ivshmem probe failed %d\n", ret); + _err("ERROR: ramdisk ivshmem probe failed %d\n", ret); return ret; } - pciinfo("Ramdisk ivshmem %s buffer: %p size: %zu sectors: %" PRIu32 "\n", + _info("Ramdisk ivshmem %s buffer: %p size: %zu sectors: %" PRIu32 "\n", name, config.buffer, buffer_size, config.nsectors); return ret; } @@ -88,17 +90,17 @@ static int ramdisk_ivshmem_probe(FAR struct ivshmem_device_s *dev) static void ramdisk_ivshmem_remove(FAR struct ivshmem_device_s *dev) { - pcierr("ERROR: ramdisk ivshmem remove not support for now\n"); + _err("ERROR: ramdisk ivshmem remove not support for now\n"); } /**************************************************************************** * Public Functions ****************************************************************************/ -int pci_register_ramdisk_ivshmem_driver(void) +int ivshmem_ramdisk_register(void) { FAR struct ivshmem_driver_s *drv; - FAR char *start = CONFIG_PCI_RAMDISK_IVSHMEM_IDTABLE; + FAR char *start = CONFIG_RAMDISK_IVSHMEM_IDTABLE; do { @@ -116,7 +118,7 @@ int pci_register_ramdisk_ivshmem_driver(void) kmm_free(drv); } - pciinfo("Register ramdisk ivshmem driver, id=%d\n", drv->id); + _info("Register ramdisk ivshmem driver, id=%d\n", drv->id); } while (*start++ != '\0'); diff --git a/drivers/pci/pci_uio_ivshmem.c b/drivers/ivshmem/ivshmem_uio.c similarity index 95% rename from drivers/pci/pci_uio_ivshmem.c rename to drivers/ivshmem/ivshmem_uio.c index 06717722c42..fb94dcfd733 100644 --- a/drivers/pci/pci_uio_ivshmem.c +++ b/drivers/ivshmem/ivshmem_uio.c @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/pci/pci_uio_ivshmem.c + * drivers/ivshmem/ivshmem_uio.c * * SPDX-License-Identifier: Apache-2.0 * @@ -37,10 +37,12 @@ #include <nuttx/kmalloc.h> #include <nuttx/list.h> #include <nuttx/mm/map.h> -#include <nuttx/pci/pci_ivshmem.h> +#include <nuttx/ivshmem.h> #include <nuttx/semaphore.h> #include <nuttx/spinlock.h> +#include "ivshmem_drivers.h" + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -84,7 +86,7 @@ struct uio_ivshmem_dev_s spinlock_t lock; int32_t event_count; struct list_node notify_list; - struct uio_ivshmem_poll_s polls[CONFIG_PCI_UIO_IVSHMEM_NPOLLWAITERS]; + struct uio_ivshmem_poll_s polls[CONFIG_UIO_IVSHMEM_NPOLLWAITERS]; }; /**************************************************************************** @@ -300,7 +302,7 @@ static int uio_ivshmem_unmap(FAR struct task_group_s *group, offset = (uintptr_t)start - (uintptr_t)entry->vaddr; if (offset + length < entry->length) { - pcierr("ERROR: Cannot umap without unmapping to the end\n"); + _err("ERROR: Cannot umap without unmapping to the end\n"); return -ENOSYS; } @@ -311,14 +313,14 @@ static int uio_ivshmem_unmap(FAR struct task_group_s *group, length = entry->length - offset; if (length < entry->length) { - pcierr("ERROR: Cannot umap portion of the memory\n"); + _err("ERROR: Cannot umap portion of the memory\n"); return -ENOSYS; } ret = mm_map_remove(get_group_mm(group), entry); if (ret < 0) { - pcierr("ERROR: mm_map_remove failed, ret=%d\n", ret); + _err("ERROR: mm_map_remove failed, ret=%d\n", ret); return ret; } @@ -396,7 +398,7 @@ static int uio_ivshmem_poll(FAR struct file *filep, FAR struct pollfd_s *fds, { flags = spin_lock_irqsave(&dev->lock); - for (i = 0; i < CONFIG_PCI_UIO_IVSHMEM_NPOLLWAITERS; i++) + for (i = 0; i < CONFIG_UIO_IVSHMEM_NPOLLWAITERS; i++) { poll = &dev->polls[i]; if (poll->fds == NULL) @@ -409,7 +411,7 @@ static int uio_ivshmem_poll(FAR struct file *filep, FAR struct pollfd_s *fds, } } - if (i >= CONFIG_PCI_UIO_IVSHMEM_NPOLLWAITERS) + if (i >= CONFIG_UIO_IVSHMEM_NPOLLWAITERS) { spin_unlock_irqrestore(&dev->lock, flags); return -EBUSY; @@ -488,7 +490,7 @@ static int uio_ivshmem_probe(FAR struct ivshmem_device_s *dev) ret = register_driver(udev->name, &g_uio_ivshmem_fops, 0600, udev); if (ret < 0) { - pcierr("ERROR: Ivshmem register_driver failed, ret=%d\n", ret); + _err("ERROR: Ivshmem register_driver failed, ret=%d\n", ret); } return ret; @@ -510,10 +512,10 @@ static void uio_ivshmem_remove(FAR struct ivshmem_device_s *dev) * Public Functions ****************************************************************************/ -int pci_register_uio_ivshmem_driver(void) +int ivshmem_uio_register(void) { FAR struct uio_ivshmem_dev_s *dev; - FAR char *start = CONFIG_PCI_UIO_IVSHMEM_IDTABLE; + FAR char *start = CONFIG_UIO_IVSHMEM_IDTABLE; do { @@ -531,7 +533,7 @@ int pci_register_uio_ivshmem_driver(void) kmm_free(dev); } - pciinfo("Register ivshmem driver, id=%d\n", dev->drv.id); + _info("Register ivshmem driver, id=%d\n", dev->drv.id); } while (*start++ != '\0'); diff --git a/drivers/pci/CMakeLists.txt b/drivers/pci/CMakeLists.txt index 8e88f50d0ed..c0764ae3f0c 100644 --- a/drivers/pci/CMakeLists.txt +++ b/drivers/pci/CMakeLists.txt @@ -36,14 +36,6 @@ if(CONFIG_PCI) list(APPEND SRCS pci_ivshmem.c) endif() - if(CONFIG_PCI_RAMDISK_IVSHMEM) - list(APPEND SRCS pci_ramdisk_ivshmem.c) - endif() - - if(CONFIG_PCI_UIO_IVSHMEM) - list(APPEND SRCS pci_uio_ivshmem.c) - endif() - if(CONFIG_PCI_EP_TEST) list(APPEND SRCS pci_ep_test.c) endif() diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index 18f5abbacda..1f415b5f1cc 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -74,41 +74,6 @@ config PCI_IVSHMEM ---help--- Enable Inter-VM share memory device driver. -config PCI_RAMDISK_IVSHMEM - bool "PCI ramdisk ivshmem driver" - default n - depends on PCI_IVSHMEM && !DISABLE_MOUNTPOINT - ---help--- - Enable ramdisk device driver. - -config PCI_RAMDISK_IVSHMEM_IDTABLE - string "The id table of ramdisk ivshmem device" - depends on PCI_RAMDISK_IVSHMEM - ---help--- - "id0;id1;id2", e.g.: "0;1;2" - - -config PCI_UIO_IVSHMEM - bool "Enable uio ivshmem driver support" - default n - depends on PCI_IVSHMEM - ---help--- - When this option is enabled, char ivshmem driver will register - char device with name: "/dev/uioX" to the VFS, then - application can open this device and use `mmap()` to get the - share memory provided by ivshmem device. - -config PCI_UIO_IVSHMEM_IDTABLE - string "The id table of uio ivshmem device" - depends on PCI_UIO_IVSHMEM - ---help--- - "id0;id1;id2", e.g.: "0;1;2" - -config PCI_UIO_IVSHMEM_NPOLLWAITERS - int "PCI uio ivshmem poll waiter number" - default 2 - depends on PCI_UIO_IVSHMEM - config PCI_EP_TEST bool "PCI endpoint test" ---help--- diff --git a/drivers/pci/Make.defs b/drivers/pci/Make.defs index 6a5cb4b9851..ee847f27518 100644 --- a/drivers/pci/Make.defs +++ b/drivers/pci/Make.defs @@ -35,14 +35,6 @@ ifeq ($(CONFIG_PCI_IVSHMEM),y) CSRCS += pci_ivshmem.c endif -ifeq ($(CONFIG_PCI_RAMDISK_IVSHMEM),y) -CSRCS += pci_ramdisk_ivshmem.c -endif - -ifeq ($(CONFIG_PCI_UIO_IVSHMEM),y) -CSRCS += pci_uio_ivshmem.c -endif - ifeq ($(CONFIG_PCI_EP_TEST),y) CSRCS += pci_ep_test.c endif diff --git a/drivers/pci/pci_drivers.c b/drivers/pci/pci_drivers.c index 9b8769982b7..76c92418824 100644 --- a/drivers/pci/pci_drivers.c +++ b/drivers/pci/pci_drivers.c @@ -27,7 +27,6 @@ #include <nuttx/debug.h> #include <nuttx/pci/pci.h> -#include <nuttx/rptun/rptun_ivshmem.h> #include <nuttx/virtio/virtio-pci.h> #include <nuttx/net/e1000.h> #include <nuttx/net/igc.h> @@ -62,32 +61,6 @@ int pci_register_drivers(void) } #endif -#ifdef CONFIG_PCI_RAMDISK_IVSHMEM - ret = pci_register_ramdisk_ivshmem_driver(); - if (ret < 0) - { - pcierr("pci_register_ramdisk_ivshmem_driver failed, ret=%d\n", ret); - } -#endif - -#ifdef CONFIG_PCI_UIO_IVSHMEM - ret = pci_register_uio_ivshmem_driver(); - if (ret < 0) - { - pcierr("pci_register_uio_ivshmem_driver failed, ret=%d\n", ret); - } -#endif - - /* Initialization rptun ivshmem driver */ - -#ifdef CONFIG_RPTUN_IVSHMEM - ret = pci_register_rptun_ivshmem_driver(); - if (ret < 0) - { - pcierr("pci_register_rptun_ivshmem_driver failed, ret=%d\n", ret); - } -#endif - /* Initialization pci qemu test driver */ #ifdef CONFIG_PCI_QEMU_TEST diff --git a/drivers/pci/pci_drivers.h b/drivers/pci/pci_drivers.h index 32259607bb3..58145744df6 100644 --- a/drivers/pci/pci_drivers.h +++ b/drivers/pci/pci_drivers.h @@ -67,10 +67,6 @@ int pci_ivshmem_register(void); * ****************************************************************************/ -#ifdef CONFIG_PCI_UIO_IVSHMEM -int pci_register_uio_ivshmem_driver(void); -#endif - /**************************************************************************** * Name: pci_register_ramdisk_ivshmem_driver * @@ -79,10 +75,6 @@ int pci_register_uio_ivshmem_driver(void); * ****************************************************************************/ -#ifdef CONFIG_PCI_RAMDISK_IVSHMEM -int pci_register_ramdisk_ivshmem_driver(void); -#endif - #ifdef CONFIG_PCI_QEMU_EPC /**************************************************************************** * Name: pci_register_qemu_epc_driver diff --git a/drivers/rptun/Kconfig b/drivers/rptun/Kconfig index 8403607d0df..94b66ada69d 100644 --- a/drivers/rptun/Kconfig +++ b/drivers/rptun/Kconfig @@ -78,9 +78,9 @@ config RPTUN_BMP config RPTUN_IVSHMEM bool "rptun ivshmem support" default n - depends on PCI_IVSHMEM && DEV_SIMPLE_ADDRENV + depends on IVSHMEM && DEV_SIMPLE_ADDRENV ---help--- - This is rptun driver based on pci ivshmem. + This is rptun driver based on ivshmem. if RPTUN_IVSHMEM diff --git a/drivers/rptun/rptun_ivshmem.c b/drivers/rptun/rptun_ivshmem.c index fb444e66cc3..eac0493137d 100644 --- a/drivers/rptun/rptun_ivshmem.c +++ b/drivers/rptun/rptun_ivshmem.c @@ -33,7 +33,7 @@ #include <nuttx/nuttx.h> #include <nuttx/drivers/addrenv.h> #include <nuttx/virtio/virtio-i2c.h> -#include <nuttx/pci/pci_ivshmem.h> +#include <nuttx/ivshmem.h> #include <nuttx/rptun/rptun.h> #include <nuttx/rptun/rptun_ivshmem.h> #include <nuttx/virtio/virtio-config.h> @@ -784,20 +784,20 @@ static int rptun_ivshmem_probe(FAR struct ivshmem_device_s *ivdev) ivshmem_attach_irq(ivdev, rptun_ivshmem_interrupt, priv); ivshmem_control_irq(ivdev, true); - pciinfo("shmem addr=%p size=%zu\n", priv->shmem, priv->shmem_size); + rptuninfo("shmem addr=%p size=%zu\n", priv->shmem, priv->shmem_size); /* Do rptun initialize */ ret = rptun_initialize(&priv->rptun); if (ret < 0) { - pcierr("rptun initialize failed, ret=%d\n", ret); + rptunerr("rptun initialize failed, ret=%d\n", ret); goto err; } if (priv->rsc_table && !ivshmem_support_irq(ivdev)) { - pciinfo("Start the wdog\n"); + rptuninfo("Start the wdog\n"); wd_start(&priv->wdog, 0, rptun_ivshmem_wdog, (wdparm_t)priv); } @@ -827,7 +827,7 @@ static void rptun_ivshmem_remove(FAR struct ivshmem_device_s *ivdev) * Public Functions ****************************************************************************/ -int pci_register_rptun_ivshmem_driver(void) +int rptun_ivshmem_register(void) { FAR const char *str; FAR char *name = CONFIG_RPTUN_IVSHMEM_NAME; @@ -844,12 +844,12 @@ int pci_register_rptun_ivshmem_driver(void) master = *(str + 1) == 'm'; if (master) { - ret = pci_register_rptun_ivshmem_slave_driver(cpuname, drvid, + ret = rptun_ivshmem_register_slave(cpuname, drvid, NULL, 0); } else { - ret = pci_register_rptun_ivshmem_slave_driver( + ret = rptun_ivshmem_register_slave( cpuname, drvid, (FAR const struct resource_table *)&g_rsc_table, sizeof(g_rsc_table)); @@ -870,7 +870,7 @@ int pci_register_rptun_ivshmem_driver(void) return OK; } -int pci_register_rptun_ivshmem_slave_driver( +int rptun_ivshmem_register_slave( FAR const char *cpuname, int drvid, FAR const struct resource_table *rsc_table, size_t rsc_size) @@ -890,7 +890,7 @@ int pci_register_rptun_ivshmem_slave_driver( priv->rsc_table = rsc_table; priv->rsc_size = rsc_size; - pciinfo("Register ivshmem driver, id=%d, cpuname=%s, master=%d\n", + rptuninfo("Register ivshmem driver, id=%d, cpuname=%s, master=%d\n", priv->drv.id, priv->cpuname, !rsc_table); priv->drv.probe = rptun_ivshmem_probe; diff --git a/include/nuttx/ivshmem.h b/include/nuttx/ivshmem.h index 61d02c54304..4eff5adf09f 100644 --- a/include/nuttx/ivshmem.h +++ b/include/nuttx/ivshmem.h @@ -217,6 +217,17 @@ int ivshmem_register_device(FAR struct ivshmem_device_s *dev, int ivshmem_unregister_device(FAR struct ivshmem_device_s *dev); +/**************************************************************************** + * Name: ivshmem_register_drivers + * + * Description: + * Register the enabled ivshmem drivers (uio, ramdisk, rptun) on + * the ivshmem bus. Called once from drivers_initialize(). + * + ****************************************************************************/ + +void ivshmem_register_drivers(void); + #ifdef __cplusplus } #endif diff --git a/include/nuttx/rptun/rptun_ivshmem.h b/include/nuttx/rptun/rptun_ivshmem.h index ea5a33d0342..b675645a3a9 100644 --- a/include/nuttx/rptun/rptun_ivshmem.h +++ b/include/nuttx/rptun/rptun_ivshmem.h @@ -41,7 +41,7 @@ extern "C" #endif /**************************************************************************** - * Name: pci_register_rptun_ivshmem_driver + * Name: rptun_ivshmem_register * * Description: * Initializes the rptun ivshmem driver. @@ -51,10 +51,10 @@ extern "C" * ****************************************************************************/ -int pci_register_rptun_ivshmem_driver(void); +int rptun_ivshmem_register(void); /**************************************************************************** - * Name: pci_register_rptun_ivshmem_slave_driver + * Name: rptun_ivshmem_register_slave * * Description: * Register the RPMsg RPTUN ivshmem driver configuration. @@ -75,7 +75,7 @@ int pci_register_rptun_ivshmem_driver(void); * ****************************************************************************/ -int pci_register_rptun_ivshmem_slave_driver( +int rptun_ivshmem_register_slave( FAR const char *cpuname, int drvid, FAR const struct resource_table *rsc_table, size_t rsc_size);
