Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-7]: src/sys/modules Pull up following revision(s) (requested by p...



details:   https://anonhg.NetBSD.org/src/rev/480e1ec1f64e
branches:  netbsd-7
changeset: 799400:480e1ec1f64e
user:      snj <snj%NetBSD.org@localhost>
date:      Wed Jun 03 06:51:39 2015 +0000

description:
Pull up following revision(s) (requested by pgoyette in ticket #752):
        sys/modules/example/Makefile: file removal
        sys/modules/example/example.c: file removal
        sys/modules/examples/Makefile: revision 1.1
        sys/modules/examples/Makefile.inc: revision 1.1
        sys/modules/examples/README: revisions 1.1-1.3
        sys/modules/examples/hello/Makefile: revision 1.1
        sys/modules/examples/hello/hello.c: revision 1.1
        sys/modules/examples/luahello/luahello.lua: revisions 1.1, 1.2
        sys/modules/examples/ping/Makefile: revision 1.1
        sys/modules/examples/ping/cmd_ping.c: revisions 1.1, 1.2
        sys/modules/examples/ping/ping.c: revision 1.1
        sys/modules/examples/ping/ping.h: revision 1.1
        sys/modules/examples/properties/Makefile: revision 1.1
        sys/modules/examples/properties/properties.c: revision 1.1
        sys/modules/examples/readhappy/Makefile: revision 1.1
        sys/modules/examples/readhappy/readhappy.c: revision 1.1
Soon to be replaced with a more comprehensive set of examples.
--
A set of more comprehensive example kernel modules to replace our
previous single example.
These examples were provided by Kamil Rytarowski.
XXX These modules are built as part of a system build, but they
XXX are NOT installed in $DESTDIR.
--
Fix instructions to match reality.  (I renamed the example from the
original submitter, but didn't catch all internal references.)
--
Fix up another internal reference to renamed module, and adjust some
English grammar.
--
Even though this isn't a man page, it looks like one.  So sort the
SEE ALSO section accordingly.
--
Fix RCS ID.

diffstat:

 sys/modules/example/Makefile                 |    6 -
 sys/modules/example/example.c                |   93 ------------
 sys/modules/examples/Makefile                |   11 +
 sys/modules/examples/Makefile.inc            |    9 +
 sys/modules/examples/README                  |   59 ++++++++
 sys/modules/examples/hello/Makefile          |    9 +
 sys/modules/examples/hello/hello.c           |   64 ++++++++
 sys/modules/examples/luahello/luahello.lua   |   47 ++++++
 sys/modules/examples/ping/Makefile           |   18 ++
 sys/modules/examples/ping/cmd_ping.c         |   61 ++++++++
 sys/modules/examples/ping/ping.c             |  131 ++++++++++++++++++
 sys/modules/examples/ping/ping.h             |    8 +
 sys/modules/examples/properties/Makefile     |    9 +
 sys/modules/examples/properties/properties.c |   75 ++++++++++
 sys/modules/examples/readhappy/Makefile      |    9 +
 sys/modules/examples/readhappy/readhappy.c   |  195 +++++++++++++++++++++++++++
 16 files changed, 705 insertions(+), 99 deletions(-)

diffs (truncated from 868 to 300 lines):

diff -r 309eae24bef3 -r 480e1ec1f64e sys/modules/example/Makefile
--- a/sys/modules/example/Makefile      Tue Jun 02 20:43:40 2015 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-#      $NetBSD: Makefile,v 1.3 2008/05/02 14:20:50 ad Exp $
-
-KMOD=   example
-SRCS=  example.c
-
-.include <bsd.kmodule.mk>
diff -r 309eae24bef3 -r 480e1ec1f64e sys/modules/example/example.c
--- a/sys/modules/example/example.c     Tue Jun 02 20:43:40 2015 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-/*     $NetBSD: example.c,v 1.7 2010/10/25 22:41:42 jnemeth Exp $      */
-
-/*-
- * Copyright (c) 2008 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 THE FOUNDATION 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 <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: example.c,v 1.7 2010/10/25 22:41:42 jnemeth Exp $");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-
-/*
- * Last parameter of MODULE macro is a list of names (as string; names are
- * separated by commas) of dependencies.  If module has no dependencies,
- * then NULL should be passed.
- */
-
-MODULE(MODULE_CLASS_MISC, example, NULL);
-
-static
-void
-handle_props(prop_dictionary_t props)
-{
-       const char *msg;
-       prop_string_t str;
-
-       if (props != NULL) {
-               str = prop_dictionary_get(props, "msg");
-       } else {
-               printf("No property dictionary was provided.\n");
-               str = NULL;
-       }
-       if (str == NULL)
-               printf("The 'msg' property was not given.\n");
-       else if (prop_object_type(str) != PROP_TYPE_STRING)
-               printf("The 'msg' property is not a string.\n");
-       else {
-               msg = prop_string_cstring_nocopy(str);
-               if (msg == NULL)
-                       printf("Failed to process the 'msg' property.\n");
-               else
-                       printf("The 'msg' property is: %s\n", msg);
-       }
-}
-
-static int
-example_modcmd(modcmd_t cmd, void *arg)
-{
-
-       switch (cmd) {
-       case MODULE_CMD_INIT:
-               printf("Example module loaded.\n");
-               handle_props(arg);
-               break;
-
-       case MODULE_CMD_FINI:
-               printf("Example module unloaded.\n");
-               break;
-
-       case MODULE_CMD_STAT:
-               printf("Example module status queried.\n");
-               return ENOTTY;
-
-       default:
-               return ENOTTY;
-       }
-
-       return 0;
-}
diff -r 309eae24bef3 -r 480e1ec1f64e sys/modules/examples/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/modules/examples/Makefile     Wed Jun 03 06:51:39 2015 +0000
@@ -0,0 +1,11 @@
+#      $NetBSD: Makefile,v 1.1.2.2 2015/06/03 06:51:40 snj Exp $
+
+.include <bsd.own.mk>
+
+SUBDIR+=       hello
+#SUBDIR+=      luahello        # Nothing to build here, only text files
+SUBDIR+=       ping            # Needs an additional helper program
+SUBDIR+=       properties
+SUBDIR+=       readhappy
+
+.include <bsd.subdir.mk>
diff -r 309eae24bef3 -r 480e1ec1f64e sys/modules/examples/Makefile.inc
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/modules/examples/Makefile.inc Wed Jun 03 06:51:39 2015 +0000
@@ -0,0 +1,9 @@
+#      $NetBSD: Makefile.inc,v 1.1.2.2 2015/06/03 06:51:40 snj Exp $
+
+# We only build the example modules; we don't want to install them anywhere
+
+kmodinstall:
+
+# Include parent's Makefile.inc
+
+.include "../Makefile.inc"
diff -r 309eae24bef3 -r 480e1ec1f64e sys/modules/examples/README
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/modules/examples/README       Wed Jun 03 06:51:39 2015 +0000
@@ -0,0 +1,59 @@
+       $NetBSD: README,v 1.3.2.2 2015/06/03 06:51:40 snj Exp $
+
+                           Kernel Developer's Manual
+
+DESCRIPTION
+     The kernel example dynamic modules.
+
+     This directory contains the following example modules:
+     * hello           - the simplest `hello world' module
+     * properties      - handle incoming properties during the module load
+     * readhappy       - basic implementation of read(9) with happy numbers
+     * ping            - basic ioctl(9)
+     * luahello        - the simplest `hello world' Lua module
+
+     To build the examples you need a local copy of NetBSD sources. You also
+     need the comp set with toolchain. To build the module just enter a
+     directory with example modules and use make(1):
+
+         # make
+
+     To load, unload, and stat the module use modload(8), modunload(8) and
+     modstat(8).
+
+     The S parameter in the Makefile files points to src/sys and it can be
+     overloaded in this way:
+
+         # make S=/data/netbsd/src/sys
+
+     The code of a module does not need to be in src/sys unless you use
+     the autoconf(9) framework.
+
+     A cross-built of a module for a target platform is possible with the
+     build.sh framework. You need to generate the toolchain and set
+     appropriately PATH to point bin/ in the TOOLDIR path. An example command
+     to cross-build a module with the amd64 toolchain is as follows:
+
+        # nbmake-amd64 S=/data/netbsd/src/sys
+
+
+     The example modules should not be used on a production machine.
+
+     All modules that create a cdevsw should be verified that the major number
+     should not conflict with a real device.
+
+SEE ALSO
+     modctl(2), module(7), modload(8), modstat(8), modunload(8), module(9),
+     intro(9lua)
+
+HISTORY
+     An example of handling incoming properties first appeared in NetBSD 5.0
+     and was written by Julio Merino with further modifications by Martin
+     Husemann, Adam Hamsik, John Nemeth and Mindaugas Rasiukevicius.
+
+     This document and additional modules (hello, readhappy, properties,
+     ping, and luahello) first appeared in NetBSD 8.0; they were written
+     by Kamil Rytarowski.
+
+AUTHORS
+     This document was written by Kamil Rytarowski.
diff -r 309eae24bef3 -r 480e1ec1f64e sys/modules/examples/hello/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/modules/examples/hello/Makefile       Wed Jun 03 06:51:39 2015 +0000
@@ -0,0 +1,9 @@
+#      $NetBSD: Makefile,v 1.1.2.2 2015/06/03 06:51:40 snj Exp $
+
+.include "../Makefile.inc"
+
+#S?=   /usr/src/sys
+KMOD=  hello
+SRCS=  hello.c
+
+.include <bsd.kmodule.mk>
diff -r 309eae24bef3 -r 480e1ec1f64e sys/modules/examples/hello/hello.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/modules/examples/hello/hello.c        Wed Jun 03 06:51:39 2015 +0000
@@ -0,0 +1,64 @@
+/*     $NetBSD: hello.c,v 1.1.2.2 2015/06/03 06:51:40 snj Exp $        */
+
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 THE FOUNDATION 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 <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: hello.c,v 1.1.2.2 2015/06/03 06:51:40 snj Exp $");
+
+#include <sys/param.h>
+#include <sys/module.h>
+
+/*
+ * Last parameter of MODULE macro is a list of names (as string; names are
+ * separated by commas) of dependencies.  If module has no dependencies,
+ * then NULL should be passed.
+ */
+
+MODULE(MODULE_CLASS_MISC, hello, NULL);
+
+static int
+hello_modcmd(modcmd_t cmd, void *arg __unused)
+{
+       switch (cmd) {
+       case MODULE_CMD_INIT:
+               printf("Example module loaded.\n");
+               break;
+
+       case MODULE_CMD_FINI:
+               printf("Example module unloaded.\n");
+               break;
+
+       case MODULE_CMD_STAT:
+               printf("Example module status queried.\n");
+               break;
+
+       default:
+               return ENOTTY;
+       }
+
+       return 0;
+}
diff -r 309eae24bef3 -r 480e1ec1f64e sys/modules/examples/luahello/luahello.lua
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/modules/examples/luahello/luahello.lua        Wed Jun 03 06:51:39 2015 +0000
@@ -0,0 +1,47 @@
+#      $NetBSD: luahello.lua,v 1.2.2.2 2015/06/03 06:51:40 snj Exp $
+#
+#
+# Copyright (c) 2015 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED



Home | Main Index | Thread Index | Old Index