devsys: wire up the network hooks
authorAlan Cox <alan@linux.intel.com>
Sat, 20 Feb 2016 19:34:25 +0000 (19:34 +0000)
committerAlan Cox <alan@linux.intel.com>
Sat, 20 Feb 2016 19:34:25 +0000 (19:34 +0000)
Kernel/devsys.c
Kernel/include/devsys.h
Kernel/include/kernel.h
Kernel/platform-z80pack/devices.c

index 54e9f8c..451035c 100644 (file)
@@ -3,6 +3,8 @@
 #include <kdata.h>
 #include <devsys.h>
 #include <audio.h>
+#include <netdev.h>
+#include <net_native.h>
 
 /*
  *     System devices:
@@ -12,6 +14,7 @@
  *     Minor   2       zero
  *     Minor   3       proc
  *     Minor   64      audio
+ *     Minor   65      net_native
  *
  *     Use Minor 128+ for platform specific devices
  */
@@ -38,6 +41,10 @@ int sys_read(uint8_t minor, uint8_t rawflag, uint8_t flag)
        if (udata.u_offset >= PTABSIZE * sizeof(struct p_tab))
                return 0;
        return uputsys(addr + udata.u_offset, udata.u_count);
+#ifdef CONFIG_NET_NATIVE
+  case 65:
+    return netdev_read(flag);
+#endif
   default:
     udata.u_error = ENXIO;
     return -1;
@@ -58,6 +65,10 @@ int sys_write(uint8_t minor, uint8_t rawflag, uint8_t flag)
   case 3:
     udata.u_error = EINVAL;
     return -1;
+#ifdef CONFIG_NET_NATIVE
+  case 65:
+    return netdev_write(flag);
+#endif
   default:
     udata.u_error = ENXIO;
     return -1;
@@ -72,6 +83,10 @@ int sys_ioctl(uint8_t minor, uarg_t request, char *data)
 #ifdef CONFIG_AUDIO
        if (minor == 64)
                return audio_ioctl(request, data);
+#endif
+#ifdef CONFIG_NET_NATIVE
+       if (minor == 65)
+               return netdev_ioctl(request, data);
 #endif
        if (minor != 3) {
           udata.u_error = ENOTTY;
@@ -93,3 +108,13 @@ int sys_ioctl(uint8_t minor, uarg_t request, char *data)
        }
        return 0;
 }
+
+int sys_close(uint8_t minor)
+{
+       used(minor);
+#ifdef CONFIG_NET_NATIVE
+       if (minor == 65)
+               return netdev_close(minor);
+#endif
+       return 0;
+}
\ No newline at end of file
index cef99da..b08da15 100644 (file)
@@ -1,3 +1,4 @@
 extern int sys_read(uint8_t minor, uint8_t rawflag, uint8_t flag);
 extern int sys_write(uint8_t minor, uint8_t rawflag, uint8_t flag);
 extern int sys_ioctl(uint8_t minor, uarg_t request, char *data);
+extern int sys_close(uint8_t minor);
index ee54012..f5955af 100644 (file)
@@ -565,6 +565,8 @@ struct s_argblk {
 #define EOPNOTSUPP     44              /* Operation not supported on transport
                                            endpoint */
 #define ECONNRESET     45              /* Connection reset by peer */
+#define ENETDOWN       46              /* Network is down */
+#define EMSGSIZE       47              /* Message too long */
 
 /*
  * ioctls for kernel internal operations start at 0x8000 and cannot be issued
@@ -603,6 +605,10 @@ struct s_argblk {
  *     Graphics ioctls 03xx (see graphics.h)
  */
 
+/*
+ *     Networking ioctls 04xx (see net_native.h)
+ */
+
 /*
  *     System info shared with user space
  */
index d44f9ca..e145828 100644 (file)
@@ -22,7 +22,7 @@ struct devsw dev_tab[] =  /* The device driver switch table */
   /* 3: /dev/lpr       Printer devices */
   {  lpr_open,     lpr_close,   no_rdwr,   lpr_write,  no_ioctl  },
   /* 4: /dev/mem etc   System devices (one offs) */
-  {  no_open,      no_close,    sys_read, sys_write, sys_ioctl  },
+  {  no_open,      sys_close,   sys_read, sys_write, sys_ioctl  },
   /* Pack to 7 with nxio if adding private devices and start at 8 */
 };