drivers/rpmsg: refactor internal APIs to private header

Move rpmsg internal APIs from public header include/nuttx/rpmsg/rpmsg.h
to private header drivers/rpmsg/rpmsg.h. These APIs are only used within
the rpmsg driver implementation and should not be exposed to external
modules.

Moved APIs:
- rpmsg_modify_signals()
- rpmsg_ns_bind() / rpmsg_ns_unbind()
- rpmsg_device_created() / rpmsg_device_destory()
- rpmsg_register() / rpmsg_unregister()

Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
This commit is contained in:
Yongrong Wang
2025-02-26 16:50:51 +08:00
committed by Alan C. Assis
parent 8226e8e8fe
commit f56ea30479
7 changed files with 71 additions and 29 deletions
+1 -1
View File
@@ -31,8 +31,8 @@
#include <nuttx/mutex.h>
#include <nuttx/rwsem.h>
#include <nuttx/semaphore.h>
#include <nuttx/rpmsg/rpmsg.h>
#include "rpmsg.h"
#include "rpmsg_ping.h"
#include "rpmsg_router.h"
#include "rpmsg_test.h"
+63
View File
@@ -0,0 +1,63 @@
/****************************************************************************
* drivers/rpmsg/rpmsg.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __DRIVERS_RPMSG_RPMSG_H
#define __DRIVERS_RPMSG_RPMSG_H
/****************************************************************************
* Included Files
****************************************************************************/
#ifdef CONFIG_RPMSG
#include <nuttx/rpmsg/rpmsg.h>
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
static inline FAR struct rpmsg_device *
rpmsg_get_rdev_by_rpmsg(FAR struct rpmsg_s *rpmsg)
{
if (!rpmsg)
{
return NULL;
}
return (FAR struct rpmsg_device *)(rpmsg + 1);
}
void rpmsg_modify_signals(FAR struct rpmsg_s *rpmsg,
int setflags, int clrflags);
void rpmsg_ns_bind(FAR struct rpmsg_device *rdev,
FAR const char *name, uint32_t dest);
void rpmsg_ns_unbind(FAR struct rpmsg_device *rdev,
FAR const char *name, uint32_t dest);
void rpmsg_device_created(FAR struct rpmsg_s *rpmsg);
void rpmsg_device_destory(FAR struct rpmsg_s *rpmsg);
int rpmsg_register(FAR const char *path, FAR struct rpmsg_s *rpmsg,
FAR const struct rpmsg_ops_s *ops);
void rpmsg_unregister(FAR const char *path, FAR struct rpmsg_s *rpmsg);
#endif /* CONFIG_RPMSG */
#endif /* __DRIVERS_RPMSG_RPMSG_H */
+2 -1
View File
@@ -32,9 +32,10 @@
#include <nuttx/list.h>
#include <nuttx/spinlock.h>
#include <nuttx/semaphore.h>
#include <nuttx/rpmsg/rpmsg.h>
#include <nuttx/rpmsg/rpmsg_port.h>
#include "rpmsg.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+1 -1
View File
@@ -27,7 +27,7 @@
* Included Files
****************************************************************************/
#include <nuttx/rpmsg/rpmsg.h>
#include "rpmsg.h"
/****************************************************************************
* Pre-processor Definitions
+2 -1
View File
@@ -31,7 +31,6 @@
#include <nuttx/kmalloc.h>
#include <nuttx/kthread.h>
#include <nuttx/power/pm.h>
#include <nuttx/rpmsg/rpmsg.h>
#include <nuttx/rpmsg/rpmsg_virtio.h>
#include <nuttx/semaphore.h>
#include <nuttx/spinlock.h>
@@ -40,6 +39,8 @@
#include <metal/utilities.h>
#include <openamp/rpmsg_virtio.h>
#include "rpmsg.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+2
View File
@@ -38,6 +38,8 @@
#include <nuttx/semaphore.h>
#include <nuttx/rpmsg/rpmsg_virtio_lite.h>
#include "rpmsg.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
-25
View File
@@ -107,25 +107,12 @@ extern "C"
#define EXTERN extern
#endif
static inline FAR struct rpmsg_device *
rpmsg_get_rdev_by_rpmsg(FAR struct rpmsg_s *rpmsg)
{
if (!rpmsg)
{
return NULL;
}
return (FAR struct rpmsg_device *)(rpmsg + 1);
}
int rpmsg_wait(FAR struct rpmsg_endpoint *ept, FAR sem_t *sem);
int rpmsg_post(FAR struct rpmsg_endpoint *ept, FAR sem_t *sem);
FAR const char *rpmsg_get_local_cpuname(FAR struct rpmsg_device *rdev);
FAR const char *rpmsg_get_cpuname(FAR struct rpmsg_device *rdev);
int rpmsg_get_signals(FAR struct rpmsg_device *rdev);
void rpmsg_modify_signals(FAR struct rpmsg_s *rpmsg,
int setflags, int clrflags);
static inline_function bool rpmsg_is_running(FAR struct rpmsg_device *rdev)
{
@@ -143,18 +130,6 @@ void rpmsg_unregister_callback(FAR void *priv,
rpmsg_match_cb_t ns_match,
rpmsg_bind_cb_t ns_bind);
void rpmsg_ns_bind(FAR struct rpmsg_device *rdev,
FAR const char *name, uint32_t dest);
void rpmsg_ns_unbind(FAR struct rpmsg_device *rdev,
FAR const char *name, uint32_t dest);
void rpmsg_device_created(FAR struct rpmsg_s *rpmsg);
void rpmsg_device_destory(FAR struct rpmsg_s *rpmsg);
int rpmsg_register(FAR const char *path, FAR struct rpmsg_s *rpmsg,
FAR const struct rpmsg_ops_s *ops);
void rpmsg_unregister(FAR const char *path, FAR struct rpmsg_s *rpmsg);
int rpmsg_ioctl(FAR const char *cpuname, int cmd, unsigned long arg);
int rpmsg_panic(FAR const char *cpuname);
void rpmsg_dump_all(void);