Browse Source

Add initial code. Add virtio_9p.h from
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/plain/include/linux/virtio_9p.h?id=refs/tags/v3.4.113

Signed-off-by: golubovsky <golubovsky@gmail.com>

golubovsky 7 years ago
parent
commit
97bcdc349c
5 changed files with 96 additions and 0 deletions
  1. 44 0
      sys/include/virtio_9p.c
  2. 2 0
      sys/src/9/amd64/BUILD
  3. 1 0
      sys/src/9/amd64/build.json
  4. 48 0
      sys/src/9/port/dev9p.c
  5. 1 0
      sys/src/9/port/port.json

+ 44 - 0
sys/include/virtio_9p.c

@@ -0,0 +1,44 @@
+#ifndef _LINUX_VIRTIO_9P_H
+#define _LINUX_VIRTIO_9P_H
+/* This header is BSD licensed so anyone can use the definitions to implement
+ * compatible drivers/servers.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of IBM nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE. */
+#include <linux/types.h>
+#include <linux/virtio_ids.h>
+#include <linux/virtio_config.h>
+
+/* The feature bitmap for virtio 9P */
+
+/* The mount point is specified in a config variable */
+#define VIRTIO_9P_MOUNT_TAG 0
+
+struct virtio_9p_config {
+	/* length of the tag name */
+	__u16 tag_len;
+	/* non-NULL terminated tag name */
+	__u8 tag[0];
+} __attribute__((packed));
+
+#endif /* _LINUX_VIRTIO_9P_H */

+ 2 - 0
sys/src/9/amd64/BUILD

@@ -79,6 +79,7 @@ PORT_SRCS = [
 	"//sys/src/9/port/devtab.c",
 	"//sys/src/9/port/devtrace.c",
 	"//sys/src/9/port/devuart.c",
+	"//sys/src/9/port/dev9p.c",
 	"//sys/src/9/port/devvcon.c",
 	"//sys/src/9/port/devwd.c",
 	"//sys/src/9/port/devws.c",
@@ -352,6 +353,7 @@ config(
 		"uart",
 		"ws",
 		"usb",
+		"v9p",
 		"vcon",
 		"vga",
 	],

+ 1 - 0
sys/src/9/amd64/build.json

@@ -48,6 +48,7 @@
 					"uart",
 					"ws",
 					"usb",
+					"v9p",
 					"vcon",
 					"vga"
 				],

+ 48 - 0
sys/src/9/port/dev9p.c

@@ -0,0 +1,48 @@
+/*
+ * This file is part of the Harvey operating system.  It is subject to the
+ * license terms of the GNU GPL v2 in LICENSE.gpl found in the top-level
+ * directory of this distribution and at http://www.gnu.org/licenses/gpl-2.0.txt
+ *
+ * No part of Harvey operating system, including this file, may be copied,
+ * modified, propagated, or distributed except according to the terms
+ * contained in the LICENSE.gpl file.
+ */
+
+// dev9p.c ('#9'): a virtio9p protocol translation driver to use QEMU's built-in 9p.
+
+
+#include        "u.h"
+#include        "../port/lib.h"
+#include        "mem.h"
+#include        "dat.h"
+#include        "fns.h"
+#include        "io.h"
+#include        "../port/error.h"
+
+#include        "virtio_ring.h"
+
+#include        "virtio_config.h"
+#include        "virtio_pci.h"
+
+#include        "virtio_lib.h"
+
+Dev v9pdevtab = {
+        .dc = '9',
+        .name = "9p",
+
+        .reset = devreset,
+        .init = v9pinit,
+        .shutdown = devshutdown,
+        .attach = v9pattach,
+        .walk = v9pwalk,
+        .stat = v9pstat,
+        .open = v9popen,
+        .create = devcreate,
+        .close = v9pclose,
+        .read = v9pread,
+        .bread = devbread,
+        .write = v9pwrite,
+        .bwrite = devbwrite,
+        .remove = devremove,
+        .wstat = devwstat,
+};

+ 1 - 0
sys/src/9/port/port.json

@@ -40,6 +40,7 @@
 			"../port/devtab.c",
 			"../port/devtrace.c",
 			"../port/devuart.c",
+			"../port/dev9p.c",
 			"../port/devwd.c",
 			"../port/devws.c",
 			"../port/edf.c",