masayuki2009 commented on code in PR #7673:
URL: https://github.com/apache/nuttx/pull/7673#discussion_r1033347269


##########
drivers/virtio/virtio-mmio.c:
##########
@@ -0,0 +1,226 @@
+/****************************************************************************
+ * drivers/virtio/virtio-mmio.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <debug.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/kmalloc.h>
+#include <nuttx/virtio/virtio.h>
+
+#ifdef CONFIG_DRIVERS_VIRTIO_NET
+#  include <nuttx/virtio/virtio-net.h>
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define ptr_to_uint64(x)  ((uint64_t)(uintptr_t)(x))
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: virtq_create
+ ****************************************************************************/
+
+FAR struct virtqueue *virtq_create(uint32_t len)
+{
+  FAR struct virtqueue *virtq = (FAR struct virtqueue *)
+    kmm_zalloc(sizeof(struct virtqueue));
+  ASSERT(virtq);
+
+  virtq->len = len;
+
+  /* See: 2.6 Split Virtqueues */
+
+  virtq->desc  = (FAR struct virtqueue_desc *)
+    kmm_memalign(16, 16 * len);
+  ASSERT(virtq->desc);
+
+  virtq->avail = (FAR struct virtqueue_avail *)
+    kmm_memalign(2, 6 + 2 * len);
+  ASSERT(virtq->avail);
+
+  virtq->used  = (FAR struct virtqueue_used *)
+    kmm_memalign(4, 6 + 8 * len);
+  ASSERT(virtq->used);
+
+  virtq->desc_virt = (FAR void **)
+    kmm_memalign(16, sizeof(FAR void *) * len);
+  ASSERT(virtq->desc_virt);
+
+  _info("virtq=%p (len=%" PRId32 ")\n", virtq, len);

Review Comment:
   done
   



##########
drivers/virtio/virtio-mmio.c:
##########
@@ -0,0 +1,226 @@
+/****************************************************************************
+ * drivers/virtio/virtio-mmio.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <debug.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/kmalloc.h>
+#include <nuttx/virtio/virtio.h>
+
+#ifdef CONFIG_DRIVERS_VIRTIO_NET
+#  include <nuttx/virtio/virtio-net.h>
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define ptr_to_uint64(x)  ((uint64_t)(uintptr_t)(x))
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: virtq_create
+ ****************************************************************************/
+
+FAR struct virtqueue *virtq_create(uint32_t len)
+{
+  FAR struct virtqueue *virtq = (FAR struct virtqueue *)
+    kmm_zalloc(sizeof(struct virtqueue));
+  ASSERT(virtq);
+
+  virtq->len = len;
+
+  /* See: 2.6 Split Virtqueues */
+
+  virtq->desc  = (FAR struct virtqueue_desc *)
+    kmm_memalign(16, 16 * len);
+  ASSERT(virtq->desc);
+
+  virtq->avail = (FAR struct virtqueue_avail *)
+    kmm_memalign(2, 6 + 2 * len);
+  ASSERT(virtq->avail);
+
+  virtq->used  = (FAR struct virtqueue_used *)
+    kmm_memalign(4, 6 + 8 * len);
+  ASSERT(virtq->used);
+
+  virtq->desc_virt = (FAR void **)
+    kmm_memalign(16, sizeof(FAR void *) * len);
+  ASSERT(virtq->desc_virt);
+
+  _info("virtq=%p (len=%" PRId32 ")\n", virtq, len);
+  _info("virtq->desc=%p \n", virtq->desc);
+  _info("virtq->avail=%p \n", virtq->avail);
+  _info("virtq->used=%p \n", virtq->used);
+
+  virtq->avail->idx = 0;
+  virtq->used->idx = 0;
+  virtq->last_used_idx = 0;
+
+  return virtq;
+}
+
+/****************************************************************************
+ * Name: virtq_dev_init
+ ****************************************************************************/
+
+static int virtio_dev_init(uintptr_t virt, uint32_t irq)
+{
+  FAR struct virtio_mmio_regs *regs = (FAR struct virtio_mmio_regs *)virt;
+  int ret = -1;

Review Comment:
   done
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to