This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 9babc6e811443d27d673138400c552bb4f49ca5a
Author: Yongrong Wang <[email protected]>
AuthorDate: Wed Oct 9 15:39:38 2024 +0800

    drivers/virtio-serial: move the protocol definitions to a header
    
    Move the virtqueue indexes and struct virtio_serial_config_s from
    virtio-serial.c to include/nuttx/virtio/virtio-serial.h, and add
    struct vhost_serial_config_s, so a vhost-serial backend can share them
    with the frontend.  No functional change.
    
    Signed-off-by: Yongrong Wang <[email protected]>
---
 drivers/virtio/virtio-serial.c       |  5 +--
 include/nuttx/virtio/virtio-serial.h | 78 ++++++++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+), 4 deletions(-)

diff --git a/drivers/virtio/virtio-serial.c b/drivers/virtio/virtio-serial.c
index c99fa853c0d..1b2786687cc 100644
--- a/drivers/virtio/virtio-serial.c
+++ b/drivers/virtio/virtio-serial.c
@@ -33,6 +33,7 @@
 #include <nuttx/serial/serial.h>
 #include <nuttx/spinlock.h>
 #include <nuttx/virtio/virtio.h>
+#include <nuttx/virtio/virtio-serial.h>
 
 #include "virtio-serial.h"
 
@@ -40,10 +41,6 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
-#define VIRTIO_SERIAL_RX           0
-#define VIRTIO_SERIAL_TX           1
-#define VIRTIO_SERIAL_NUM          2
-
 /****************************************************************************
  * Private Types
  ****************************************************************************/
diff --git a/include/nuttx/virtio/virtio-serial.h 
b/include/nuttx/virtio/virtio-serial.h
new file mode 100644
index 00000000000..7ffce14c476
--- /dev/null
+++ b/include/nuttx/virtio/virtio-serial.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+ * include/nuttx/virtio/virtio-serial.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 __INCLUDE_NUTTX_VIRTIO_VIRTIO_SERIAL_H
+#define __INCLUDE_NUTTX_VIRTIO_VIRTIO_SERIAL_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <limits.h>
+#include <stdint.h>
+
+#include <nuttx/compiler.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define VIRTIO_SERIAL_RX           0
+#define VIRTIO_SERIAL_TX           1
+#define VIRTIO_SERIAL_NUM          2
+
+#define VIRTIO_SERIAL_PATH_SIZE    64
+
+/****************************************************************************
+ * Public Type Definitions
+ ****************************************************************************/
+
+begin_packed_struct struct virtio_serial_config_s
+{
+  uint16_t cols;
+  uint16_t rows;
+  uint32_t max_nr_ports;
+  uint32_t emerg_wr;
+} end_packed_struct;
+
+begin_packed_struct struct vhost_serial_config_s
+{
+  struct virtio_serial_config_s config;
+  char path[VIRTIO_SERIAL_PATH_SIZE];
+} end_packed_struct;
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+#undef EXTERN
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __INCLUDE_NUTTX_VIRTIO_VIRTIO_SERIAL_H */

Reply via email to