CVS commit: src/sys/modules/examples

2021-08-08 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Aug  8 20:55:33 UTC 2021

Modified Files:
src/sys/modules/examples: Makefile

Log Message:
Add ddbping example module to SUBDIR list.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/modules/examples/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/Makefile
diff -u src/sys/modules/examples/Makefile:1.11 src/sys/modules/examples/Makefile:1.12
--- src/sys/modules/examples/Makefile:1.11	Thu Apr 30 00:48:10 2020
+++ src/sys/modules/examples/Makefile	Sun Aug  8 20:55:33 2021
@@ -1,8 +1,9 @@
-#	$NetBSD: Makefile,v 1.11 2020/04/30 00:48:10 christos Exp $
+#	$NetBSD: Makefile,v 1.12 2021/08/08 20:55:33 uwe Exp $
 
 .include 
 
 SUBDIR+=	current_time
+SUBDIR+=	ddbping
 SUBDIR+=	executor
 SUBDIR+=	fopsmapper		# Needs an additional helper program
 SUBDIR+=	hello



CVS commit: src/sys/modules/examples/sysctl

2021-03-23 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Mar 23 13:19:09 UTC 2021

Modified Files:
src/sys/modules/examples/sysctl: sysctl.c

Log Message:
Add some \n's to the end of some printf()s.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/examples/sysctl/sysctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/sysctl/sysctl.c
diff -u src/sys/modules/examples/sysctl/sysctl.c:1.1 src/sys/modules/examples/sysctl/sysctl.c:1.2
--- src/sys/modules/examples/sysctl/sysctl.c:1.1	Fri Apr 13 01:20:28 2018
+++ src/sys/modules/examples/sysctl/sysctl.c	Tue Mar 23 13:19:09 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysctl.c,v 1.1 2018/04/13 01:20:28 kamil Exp $	*/
+/*	$NetBSD: sysctl.c,v 1.2 2021/03/23 13:19:09 simonb Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sysctl.c,v 1.1 2018/04/13 01:20:28 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysctl.c,v 1.2 2021/03/23 13:19:09 simonb Exp $");
 
 #include 
 #include 
@@ -104,11 +104,11 @@ sysctl_modcmd(modcmd_t cmd, void *arg)
 {
 	switch(cmd) {
 	case MODULE_CMD_INIT:
-		printf("sysctl module inserted");
+		printf("sysctl module inserted\n");
 		sysctl_example_setup(&example_sysctl_log);
 		break;
 	case MODULE_CMD_FINI:
-		printf("sysctl module unloaded");
+		printf("sysctl module unloaded\n");
 		sysctl_teardown(&example_sysctl_log);
 		break;
 	default:



CVS commit: src/sys/modules/examples/ddbping

2020-05-31 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Jun  1 03:37:40 UTC 2020

Added Files:
src/sys/modules/examples/ddbping: Makefile ddbping.c

Log Message:
Example of a kernel module that registers DDB commands.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/modules/examples/ddbping/Makefile \
src/sys/modules/examples/ddbping/ddbping.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/sys/modules/examples/ddbping/Makefile
diff -u /dev/null src/sys/modules/examples/ddbping/Makefile:1.1
--- /dev/null	Mon Jun  1 03:37:40 2020
+++ src/sys/modules/examples/ddbping/Makefile	Mon Jun  1 03:37:40 2020
@@ -0,0 +1,9 @@
+#	$NetBSD: Makefile,v 1.1 2020/06/01 03:37:40 uwe Exp $
+
+# set in nbmake-$machine wrapper:
+# NETBSDSRCDIR?=/usr/src
+
+KMOD=	ddbping
+SRCS=	ddbping.c
+
+.include 
Index: src/sys/modules/examples/ddbping/ddbping.c
diff -u /dev/null src/sys/modules/examples/ddbping/ddbping.c:1.1
--- /dev/null	Mon Jun  1 03:37:40 2020
+++ src/sys/modules/examples/ddbping/ddbping.c	Mon Jun  1 03:37:40 2020
@@ -0,0 +1,126 @@
+/*	$NetBSD: ddbping.c,v 1.1 2020/06/01 03:37:40 uwe Exp $ */
+/*
+ * Copyright (c) 2020 Valery Ushakov
+ * 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 AUTHOR ``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 AUTHOR 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.
+ */
+
+/*
+ * Example of a kernel module that registers DDB commands.
+ */
+#include 
+__KERNEL_RCSID(0, "$NetBSD: ddbping.c,v 1.1 2020/06/01 03:37:40 uwe Exp $");
+
+#include 
+#include 
+
+#include 
+
+/* XXX: db_command.h should provide something like these */
+#define DB_CMD_TBL_END { DDB_ADD_CMD(NULL, NULL, 0, NULL, NULL, NULL) }
+typedef void db_cmdfn_t(db_expr_t, bool, db_expr_t, const char *);
+
+
+static db_cmdfn_t db_ping;
+static db_cmdfn_t db_show_ping;
+
+
+static const struct db_command db_ping_base_tbl[] = {
+	{ DDB_ADD_CMD("ping", db_ping, 0,
+		  "Example command",
+		  NULL, NULL) },
+	DB_CMD_TBL_END
+};
+
+static const struct db_command db_ping_show_tbl[] = {
+	{ DDB_ADD_CMD("ping", db_show_ping, 0,
+		  "Example command stats",
+		  NULL, NULL) },
+	DB_CMD_TBL_END
+};
+
+
+static unsigned int ping_count;
+static unsigned int ping_count_modif;
+static unsigned int ping_count_addr;
+static unsigned int ping_count_count;
+
+
+static void
+db_ping(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
+{
+	db_printf("pong");
+	++ping_count;
+
+	if (modif != NULL && *modif != '\0') {
+		db_printf("/%s", modif);
+		++ping_count_modif;
+	}
+
+	if (have_addr) {
+		db_printf(" 0x%zx", (size_t)addr);
+		++ping_count_addr;
+	}
+
+	if (count > 0) {
+		db_printf(", 0t%zu", (size_t)count);
+		++ping_count_count;
+	}
+
+	db_printf("\n");
+}
+
+
+static void
+db_show_ping(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
+{
+	db_printf("total\t\t%u\n", ping_count);
+	db_printf("with modifiers\t%u\n", ping_count_modif);
+	db_printf("with address\t%u\n", ping_count_addr);
+	db_printf("with count\t%u\n", ping_count_count);
+}
+
+
+
+MODULE(MODULE_CLASS_MISC, ddbping, NULL);
+
+static int
+ddbping_modcmd(modcmd_t cmd, void *arg __unused)
+{
+	switch (cmd) {
+	case MODULE_CMD_INIT:
+		db_register_tbl(DDB_BASE_CMD, db_ping_base_tbl);
+		db_register_tbl(DDB_SHOW_CMD, db_ping_show_tbl);
+		break;
+
+	case MODULE_CMD_FINI:
+		db_unregister_tbl(DDB_BASE_CMD, db_ping_base_tbl);
+		db_unregister_tbl(DDB_SHOW_CMD, db_ping_show_tbl);
+		break;
+
+	case MODULE_CMD_STAT:	/* FALLTHROUGH */
+	default:
+		return ENOTTY;
+	}
+
+	return 0;
+}



CVS commit: src/sys/modules/examples/pollpal

2020-05-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri May  1 21:42:34 UTC 2020

Modified Files:
src/sys/modules/examples/pollpal: pollpal.c

Log Message:
s/&&/&/ and also return POLLRDNORM (pointed out by joerg@)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/modules/examples/pollpal/pollpal.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/pollpal/pollpal.c
diff -u src/sys/modules/examples/pollpal/pollpal.c:1.2 src/sys/modules/examples/pollpal/pollpal.c:1.3
--- src/sys/modules/examples/pollpal/pollpal.c:1.2	Thu Apr 30 03:07:22 2020
+++ src/sys/modules/examples/pollpal/pollpal.c	Fri May  1 17:42:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pollpal.c,v 1.2 2020/04/30 07:07:22 mrg Exp $	*/ 
+/*	$NetBSD: pollpal.c,v 1.3 2020/05/01 21:42:34 christos Exp $	*/ 
 
 /*-
 * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
 */ 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pollpal.c,v 1.2 2020/04/30 07:07:22 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pollpal.c,v 1.3 2020/05/01 21:42:34 christos Exp $");
 
 #include 
 #include 
@@ -281,9 +281,9 @@ pollpal_poll(struct file *fp, int events
 		}
 		break;
 	case WRITE_WAITING:
-		if (events && (POLLIN | POLLRDNORM)) {
+		if (events & (POLLIN | POLLRDNORM)) {
 			/* When device is in WRITE_WAITING state it can read. */
-			revents |= POLLIN;
+			revents |= POLLIN | POLLRDNORM;
 		} else {
 			/* Record the request if it wasn't satisfied. */
 			selrecord(curlwp, &pl->psel);



CVS commit: src/sys/modules/examples/ping

2020-04-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 30 10:55:32 UTC 2020

Modified Files:
src/sys/modules/examples/ping: ping.c

Log Message:
remove debugging stuff accidentally committed.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/modules/examples/ping/ping.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/ping/ping.c
diff -u src/sys/modules/examples/ping/ping.c:1.4 src/sys/modules/examples/ping/ping.c:1.5
--- src/sys/modules/examples/ping/ping.c:1.4	Wed Apr 29 20:48:10 2020
+++ src/sys/modules/examples/ping/ping.c	Thu Apr 30 06:55:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ping.c,v 1.4 2020/04/30 00:48:10 christos Exp $	*/
+/*	$NetBSD: ping.c,v 1.5 2020/04/30 10:55:32 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -27,15 +27,13 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ping.c,v 1.4 2020/04/30 00:48:10 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ping.c,v 1.5 2020/04/30 10:55:32 christos Exp $");
 
-#define DDB
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 
 #include "ping.h"
 
@@ -101,7 +99,6 @@ ping_ioctl(dev_t self __unused, u_long c
 	switch(cmd) {
 	case CMD_PING:
 		printf("ping: pong!\n");
-		Debugger();
 		return 0;
 	default:
 		return ENOTTY;



CVS commit: src/sys/modules/examples/pollpal

2020-04-30 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Apr 30 07:07:22 UTC 2020

Modified Files:
src/sys/modules/examples/pollpal: pollpal.c

Log Message:
include sys/lwp.h and fix the build.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/examples/pollpal/pollpal.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/pollpal/pollpal.c
diff -u src/sys/modules/examples/pollpal/pollpal.c:1.1 src/sys/modules/examples/pollpal/pollpal.c:1.2
--- src/sys/modules/examples/pollpal/pollpal.c:1.1	Thu Apr 30 00:48:10 2020
+++ src/sys/modules/examples/pollpal/pollpal.c	Thu Apr 30 07:07:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pollpal.c,v 1.1 2020/04/30 00:48:10 christos Exp $	*/ 
+/*	$NetBSD: pollpal.c,v 1.2 2020/04/30 07:07:22 mrg Exp $	*/ 
 
 /*-
 * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,12 +27,13 @@
 */ 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pollpal.c,v 1.1 2020/04/30 00:48:10 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pollpal.c,v 1.2 2020/04/30 07:07:22 mrg Exp $");
 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 



CVS commit: src/sys/modules/examples

2020-04-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 30 00:48:10 UTC 2020

Modified Files:
src/sys/modules/examples: Makefile README
src/sys/modules/examples/ping: ping.c
Added Files:
src/sys/modules/examples/pollpal: Makefile cmd_pollpal.c pollpal.c

Log Message:
New kernel example module written by Ayushi Sharma


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/modules/examples/Makefile
cvs rdiff -u -r1.14 -r1.15 src/sys/modules/examples/README
cvs rdiff -u -r1.3 -r1.4 src/sys/modules/examples/ping/ping.c
cvs rdiff -u -r0 -r1.1 src/sys/modules/examples/pollpal/Makefile \
src/sys/modules/examples/pollpal/cmd_pollpal.c \
src/sys/modules/examples/pollpal/pollpal.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/Makefile
diff -u src/sys/modules/examples/Makefile:1.10 src/sys/modules/examples/Makefile:1.11
--- src/sys/modules/examples/Makefile:1.10	Sat Apr  4 17:15:04 2020
+++ src/sys/modules/examples/Makefile	Wed Apr 29 20:48:10 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.10 2020/04/04 21:15:04 kamil Exp $
+#	$NetBSD: Makefile,v 1.11 2020/04/30 00:48:10 christos Exp $
 
 .include 
 
@@ -12,6 +12,7 @@ SUBDIR+=	mapper			# Needs an additional 
 SUBDIR+=	panic_string		# Crashes the system
 SUBDIR+=	ping			# Needs an additional helper program
 SUBDIR+=	ping_block		# Needs an additional helper program
+SUBDIR+=	pollpal			# Needs an additional helper program
 SUBDIR+=	properties
 SUBDIR+=	readhappy
 SUBDIR+=	readhappy_mpsafe	# Contains an additional helper program

Index: src/sys/modules/examples/README
diff -u src/sys/modules/examples/README:1.14 src/sys/modules/examples/README:1.15
--- src/sys/modules/examples/README:1.14	Sat Apr  4 17:15:04 2020
+++ src/sys/modules/examples/README	Wed Apr 29 20:48:10 2020
@@ -1,4 +1,4 @@
-	$NetBSD: README,v 1.14 2020/04/04 21:15:04 kamil Exp $
+	$NetBSD: README,v 1.15 2020/04/30 00:48:10 christos Exp $
 
Kernel Developer's Manual
 
@@ -17,6 +17,7 @@ DESCRIPTION
  * ping- basic ioctl(9)
  * ping_block  - basic ioctl(9) with a block device
  * properties  - handle incoming properties during the module load
+ * pollpal - implementation of basic poll(9) using palindrome
  * readhappy   - basic implementation of read(9) with happy numbers
  * readhappy_mpsafe- demonstrates how to make a module MPSAFE
  * sysctl  - demonstrates adding a sysctl handle dynamically
@@ -82,5 +83,8 @@ HISTORY
  The current_time module first appeared in NetBSD 10.0 and was authored by
  Apurva Nandan.
 
+ The pollpall module first appeared in NetBSD 10.0 and was authored by
+ Ayushi Sharma.
+
 AUTHORS
  This document was written by Kamil Rytarowski.

Index: src/sys/modules/examples/ping/ping.c
diff -u src/sys/modules/examples/ping/ping.c:1.3 src/sys/modules/examples/ping/ping.c:1.4
--- src/sys/modules/examples/ping/ping.c:1.3	Wed Feb  5 09:10:46 2020
+++ src/sys/modules/examples/ping/ping.c	Wed Apr 29 20:48:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ping.c,v 1.3 2020/02/05 14:10:46 pgoyette Exp $	*/
+/*	$NetBSD: ping.c,v 1.4 2020/04/30 00:48:10 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -27,13 +27,15 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ping.c,v 1.3 2020/02/05 14:10:46 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ping.c,v 1.4 2020/04/30 00:48:10 christos Exp $");
 
+#define DDB
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include "ping.h"
 
@@ -99,6 +101,7 @@ ping_ioctl(dev_t self __unused, u_long c
 	switch(cmd) {
 	case CMD_PING:
 		printf("ping: pong!\n");
+		Debugger();
 		return 0;
 	default:
 		return ENOTTY;

Added files:

Index: src/sys/modules/examples/pollpal/Makefile
diff -u /dev/null src/sys/modules/examples/pollpal/Makefile:1.1
--- /dev/null	Wed Apr 29 20:48:10 2020
+++ src/sys/modules/examples/pollpal/Makefile	Wed Apr 29 20:48:10 2020
@@ -0,0 +1,18 @@
+#   $NetBSD: Makefile,v 1.1 2020/04/30 00:48:10 christos Exp $
+
+.include "../Makefile.inc"
+
+#S?=	/usr/src/sys
+
+KMOD=   pollpal
+SRCS=   pollpal.c
+
+.include 
+
+# To make use of this module, you'll need to separately build the
+# cmd_pollpall program, with a Makefile similar to
+#
+#   MKMAN=  NO
+#   PROG=   cmd_pollpal
+#   .include 
+
Index: src/sys/modules/examples/pollpal/cmd_pollpal.c
diff -u /dev/null src/sys/modules/examples/pollpal/cmd_pollpal.c:1.1
--- /dev/null	Wed Apr 29 20:48:10 2020
+++ src/sys/modules/examples/pollpal/cmd_pollpal.c	Wed Apr 29 20:48:10 2020
@@ -0,0 +1,130 @@
+/*	$NetBSD: cmd_pollpal.c,v 1.1 2020/04/30 00:48:10 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2020 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 c

CVS commit: src/sys/modules/examples/current_time

2020-04-04 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Apr  4 23:22:12 UTC 2020

Modified Files:
src/sys/modules/examples/current_time: current_time.c

Log Message:
Switch to type generic PRIu macros

Fixes build on i386.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/examples/current_time/current_time.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/current_time/current_time.c
diff -u src/sys/modules/examples/current_time/current_time.c:1.1 src/sys/modules/examples/current_time/current_time.c:1.2
--- src/sys/modules/examples/current_time/current_time.c:1.1	Sat Apr  4 21:15:04 2020
+++ src/sys/modules/examples/current_time/current_time.c	Sat Apr  4 23:22:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: current_time.c,v 1.1 2020/04/04 21:15:04 kamil Exp $  */
+/*	$NetBSD: current_time.c,v 1.2 2020/04/04 23:22:12 kamil Exp $  */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: current_time.c,v 1.1 2020/04/04 21:15:04 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: current_time.c,v 1.2 2020/04/04 23:22:12 kamil Exp $");
 
 #include 
 #include 
@@ -55,7 +55,8 @@ print_current_time(void)
 	getmicrotime(&tv);
 	clock_secs_to_ymdhms(tv.tv_sec, &dt);
 
-	printf("Current Time: %s, %04lu/%02u/%02u %02u:%02u:%02u UTC\n",
+	printf("Current Time: %s, %04" PRIu64 "/%02" PRIu8 "/%02" PRIu8
+	" %02" PRIu8 ":%02" PRIu8 ":%02" PRIu8 " UTC\n",
 	w_day[dt.dt_wday], dt.dt_year, dt.dt_mon, dt.dt_day, dt.dt_hour,
 	dt.dt_min, dt.dt_sec);
 }



CVS commit: src/sys/modules/examples

2020-04-04 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Apr  4 21:15:04 UTC 2020

Modified Files:
src/sys/modules/examples: Makefile README
Added Files:
src/sys/modules/examples/current_time: Makefile current_time.c

Log Message:
Add new example kernel module: current_time

Submitted by Apurva Nandan.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/modules/examples/Makefile
cvs rdiff -u -r1.13 -r1.14 src/sys/modules/examples/README
cvs rdiff -u -r0 -r1.1 src/sys/modules/examples/current_time/Makefile \
src/sys/modules/examples/current_time/current_time.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/Makefile
diff -u src/sys/modules/examples/Makefile:1.9 src/sys/modules/examples/Makefile:1.10
--- src/sys/modules/examples/Makefile:1.9	Wed Apr  1 01:57:20 2020
+++ src/sys/modules/examples/Makefile	Sat Apr  4 21:15:04 2020
@@ -1,7 +1,8 @@
-#	$NetBSD: Makefile,v 1.9 2020/04/01 01:57:20 kamil Exp $
+#	$NetBSD: Makefile,v 1.10 2020/04/04 21:15:04 kamil Exp $
 
 .include 
 
+SUBDIR+=	current_time
 SUBDIR+=	executor
 SUBDIR+=	fopsmapper		# Needs an additional helper program
 SUBDIR+=	hello

Index: src/sys/modules/examples/README
diff -u src/sys/modules/examples/README:1.13 src/sys/modules/examples/README:1.14
--- src/sys/modules/examples/README:1.13	Wed Apr  1 01:57:20 2020
+++ src/sys/modules/examples/README	Sat Apr  4 21:15:04 2020
@@ -1,4 +1,4 @@
-	$NetBSD: README,v 1.13 2020/04/01 01:57:20 kamil Exp $
+	$NetBSD: README,v 1.14 2020/04/04 21:15:04 kamil Exp $
 
Kernel Developer's Manual
 
@@ -6,6 +6,7 @@ DESCRIPTION
  The kernel example dynamic modules.
 
  This directory contains the following example modules:
+ * current_time- prints current date and time in GMT/UTC
  * executor- basic implementation of callout and RUN_ONCE
  * fopsmapper  - basic implementation of mmap with fileops fo_mmap
  * hello   - the simplest `hello world' module
@@ -78,5 +79,8 @@ HISTORY
  The fopsmapper module first appeared in NetBSD 10.0 and was authored by
  Aditya Vardhan Padala.
 
+ The current_time module first appeared in NetBSD 10.0 and was authored by
+ Apurva Nandan.
+
 AUTHORS
  This document was written by Kamil Rytarowski.

Added files:

Index: src/sys/modules/examples/current_time/Makefile
diff -u /dev/null src/sys/modules/examples/current_time/Makefile:1.1
--- /dev/null	Sat Apr  4 21:15:04 2020
+++ src/sys/modules/examples/current_time/Makefile	Sat Apr  4 21:15:04 2020
@@ -0,0 +1,9 @@
+#	$NetBSD: Makefile,v 1.1 2020/04/04 21:15:04 kamil Exp $
+
+.include "../Makefile.inc"
+
+#S?=	/usr/src/sys
+KMOD=	current_time
+SRCS=	current_time.c
+
+.include 
Index: src/sys/modules/examples/current_time/current_time.c
diff -u /dev/null src/sys/modules/examples/current_time/current_time.c:1.1
--- /dev/null	Sat Apr  4 21:15:04 2020
+++ src/sys/modules/examples/current_time/current_time.c	Sat Apr  4 21:15:04 2020
@@ -0,0 +1,81 @@
+/*	$NetBSD: current_time.c,v 1.1 2020/04/04 21:15:04 kamil Exp $  */
+
+/*-
+ * Copyright (c) 2020 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 
+__KERNEL_RCSID(0, "$NetBSD: current_time.c,v 1.1 2020/04/04 21:15:04 kamil Exp $");
+
+#include 
+#include 
+#include 
+
+/*
+ * Function print_time() fetches the epoch seconds/unix time from the
+ * getmicrotime() function and sends its to clock_secs_to_ymdhms(..) in
+ * dev/clock_subr to parse it into readable date and time format and print it.
+ *
+ * Please note that the current

CVS commit: src/sys/modules/examples/fopsmapper

2020-04-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Apr  1 13:07:32 UTC 2020

Modified Files:
src/sys/modules/examples/fopsmapper: cmd_mapper.c

Log Message:
Fix CVS Id


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/examples/fopsmapper/cmd_mapper.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/fopsmapper/cmd_mapper.c
diff -u src/sys/modules/examples/fopsmapper/cmd_mapper.c:1.1 src/sys/modules/examples/fopsmapper/cmd_mapper.c:1.2
--- src/sys/modules/examples/fopsmapper/cmd_mapper.c:1.1	Wed Apr  1 01:57:20 2020
+++ src/sys/modules/examples/fopsmapper/cmd_mapper.c	Wed Apr  1 13:07:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cmd_mapper.c,v 1.1 2020/04/01 01:57:20 kamil Exp $	*/
+/*	$NetBSD: cmd_mapper.c,v 1.2 2020/04/01 13:07:32 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD");
+__RCSID("$NetBSD: cmd_mapper.c,v 1.2 2020/04/01 13:07:32 kamil Exp $");
 
 #include 
 



CVS commit: src/sys/modules/examples/fopsmapper

2020-04-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Apr  1 11:45:53 UTC 2020

Modified Files:
src/sys/modules/examples/fopsmapper: fopsmapper.c

Log Message:
Avoid comparison between signed and unsigned integer

Cast PAGE_SIZE to size_t.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/examples/fopsmapper/fopsmapper.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/fopsmapper/fopsmapper.c
diff -u src/sys/modules/examples/fopsmapper/fopsmapper.c:1.1 src/sys/modules/examples/fopsmapper/fopsmapper.c:1.2
--- src/sys/modules/examples/fopsmapper/fopsmapper.c:1.1	Wed Apr  1 01:57:20 2020
+++ src/sys/modules/examples/fopsmapper/fopsmapper.c	Wed Apr  1 11:45:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: fopsmapper.c,v 1.1 2020/04/01 01:57:20 kamil Exp $	*/
+/*	$NetBSD: fopsmapper.c,v 1.2 2020/04/01 11:45:53 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fopsmapper.c,v 1.1 2020/04/01 01:57:20 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fopsmapper.c,v 1.2 2020/04/01 11:45:53 kamil Exp $");
 
 #include 
 #include 
@@ -115,7 +115,7 @@ fopsmapper_mmap(file_t * fp, off_t * off
 	if (prot & PROT_EXEC)
 		return EACCES;
 
-	if (size != PAGE_SIZE)
+	if (size != (size_t)PAGE_SIZE)
 		return EINVAL;
 
 	if ((fo = fp->f_data) == NULL)



CVS commit: src/sys/modules/examples

2020-03-31 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Apr  1 01:57:20 UTC 2020

Modified Files:
src/sys/modules/examples: Makefile README
Added Files:
src/sys/modules/examples/fopsmapper: Makefile cmd_mapper.c fopsmapper.c

Log Message:
Import a new example kernel module fopsmapper

fopsmapper - basic implementation of mmap with fileops fo_mmap

Submitted by Aditya Vardhan Padala.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/modules/examples/Makefile
cvs rdiff -u -r1.12 -r1.13 src/sys/modules/examples/README
cvs rdiff -u -r0 -r1.1 src/sys/modules/examples/fopsmapper/Makefile \
src/sys/modules/examples/fopsmapper/cmd_mapper.c \
src/sys/modules/examples/fopsmapper/fopsmapper.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/Makefile
diff -u src/sys/modules/examples/Makefile:1.8 src/sys/modules/examples/Makefile:1.9
--- src/sys/modules/examples/Makefile:1.8	Wed Feb  5 13:23:42 2020
+++ src/sys/modules/examples/Makefile	Wed Apr  1 01:57:20 2020
@@ -1,8 +1,9 @@
-#	$NetBSD: Makefile,v 1.8 2020/02/05 13:23:42 kamil Exp $
+#	$NetBSD: Makefile,v 1.9 2020/04/01 01:57:20 kamil Exp $
 
 .include 
 
 SUBDIR+=	executor
+SUBDIR+=	fopsmapper		# Needs an additional helper program
 SUBDIR+=	hello
 #SUBDIR+=	luahello		# Nothing to build here, only text files
 SUBDIR+=	luareadhappy		# Needs an additional Lua script

Index: src/sys/modules/examples/README
diff -u src/sys/modules/examples/README:1.12 src/sys/modules/examples/README:1.13
--- src/sys/modules/examples/README:1.12	Fri Feb  7 19:22:21 2020
+++ src/sys/modules/examples/README	Wed Apr  1 01:57:20 2020
@@ -1,4 +1,4 @@
-	$NetBSD: README,v 1.12 2020/02/07 19:22:21 pgoyette Exp $
+	$NetBSD: README,v 1.13 2020/04/01 01:57:20 kamil Exp $
 
Kernel Developer's Manual
 
@@ -7,6 +7,7 @@ DESCRIPTION
 
  This directory contains the following example modules:
  * executor- basic implementation of callout and RUN_ONCE
+ * fopsmapper  - basic implementation of mmap with fileops fo_mmap
  * hello   - the simplest `hello world' module
  * luahello- the simplest `hello world' Lua module
  * luareadhappy- demonstrates calling Lua code from C
@@ -74,5 +75,8 @@ HISTORY
  The ping_block module first appeared in NetBSD 10.0 and was authored by
  Nisarg Joshi.
 
+ The fopsmapper module first appeared in NetBSD 10.0 and was authored by
+ Aditya Vardhan Padala.
+
 AUTHORS
  This document was written by Kamil Rytarowski.

Added files:

Index: src/sys/modules/examples/fopsmapper/Makefile
diff -u /dev/null src/sys/modules/examples/fopsmapper/Makefile:1.1
--- /dev/null	Wed Apr  1 01:57:20 2020
+++ src/sys/modules/examples/fopsmapper/Makefile	Wed Apr  1 01:57:20 2020
@@ -0,0 +1,6 @@
+#S?=/usr/src/sys
+
+KMOD= fopsmapper
+SRCS= fopsmapper.c
+
+.include 
Index: src/sys/modules/examples/fopsmapper/cmd_mapper.c
diff -u /dev/null src/sys/modules/examples/fopsmapper/cmd_mapper.c:1.1
--- /dev/null	Wed Apr  1 01:57:20 2020
+++ src/sys/modules/examples/fopsmapper/cmd_mapper.c	Wed Apr  1 01:57:20 2020
@@ -0,0 +1,64 @@
+/*	$NetBSD: cmd_mapper.c,v 1.1 2020/04/01 01:57:20 kamil Exp $	*/
+
+/*-
+ * Copyright (c) 2020 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 
+__RCSID("$NetBSD");
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define _PATH_DEV_MAPPER "/dev/fopsmapper"
+
+int main(int argc, char **argv)
+{
+	int devfd;
+	char *map = NULL;
+
+	if ((devfd = open(_PATH_DEV_MAPPER, O_RDO

CVS commit: src/sys/modules/examples

2020-02-07 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Fri Feb  7 19:22:21 UTC 2020

Modified Files:
src/sys/modules/examples: README

Log Message:
Improve wording


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/modules/examples/README

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/README
diff -u src/sys/modules/examples/README:1.11 src/sys/modules/examples/README:1.12
--- src/sys/modules/examples/README:1.11	Thu Feb  6 22:52:25 2020
+++ src/sys/modules/examples/README	Fri Feb  7 19:22:21 2020
@@ -1,4 +1,4 @@
-	$NetBSD: README,v 1.11 2020/02/06 22:52:25 kamil Exp $
+	$NetBSD: README,v 1.12 2020/02/07 19:22:21 pgoyette Exp $
 
Kernel Developer's Manual
 
@@ -33,10 +33,10 @@ DESCRIPTION
 
  # make S=/data/netbsd/src/sys
 
- The code of a module does not need to be in src/sys unless you use
+ The code of a module does not need to be in src/sys unless it uses
  the autoconf(9) framework.
 
- A cross-built of a module for a target platform is possible with the
+ A cross-build 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:
@@ -46,8 +46,8 @@ DESCRIPTION
 
  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.
+ All modules that create a cdevsw (or bdevsw) should be verified that
+ the major number(s) should not conflict with a real device.
 
 SEE ALSO
  modctl(2), module(7), modload(8), modstat(8), modunload(8), module(9),



CVS commit: src/sys/modules/examples

2020-02-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Thu Feb  6 22:52:26 UTC 2020

Modified Files:
src/sys/modules/examples: README

Log Message:
Document what does ping_block.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/modules/examples/README

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/README
diff -u src/sys/modules/examples/README:1.10 src/sys/modules/examples/README:1.11
--- src/sys/modules/examples/README:1.10	Wed Feb  5 13:23:42 2020
+++ src/sys/modules/examples/README	Thu Feb  6 22:52:25 2020
@@ -1,4 +1,4 @@
-	$NetBSD: README,v 1.10 2020/02/05 13:23:42 kamil Exp $
+	$NetBSD: README,v 1.11 2020/02/06 22:52:25 kamil Exp $
 
Kernel Developer's Manual
 
@@ -13,6 +13,7 @@ DESCRIPTION
  * mapper  - basic implementation of mmap
  * panic_string- shows how panic is being called through a device
  * ping- basic ioctl(9)
+ * ping_block  - basic ioctl(9) with a block device
  * properties  - handle incoming properties during the module load
  * readhappy   - basic implementation of read(9) with happy numbers
  * readhappy_mpsafe- demonstrates how to make a module MPSAFE



CVS commit: src/sys/modules/examples

2020-02-05 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Feb  5 14:10:47 UTC 2020

Modified Files:
src/sys/modules/examples/ping: ping.c
src/sys/modules/examples/ping_block: ping.c

Log Message:
Use ENOTTY as error for an unrecognized ioctl() code, rather than
"magic number" 1.

ok kamil@


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/modules/examples/ping/ping.c
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/examples/ping_block/ping.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/ping/ping.c
diff -u src/sys/modules/examples/ping/ping.c:1.2 src/sys/modules/examples/ping/ping.c:1.3
--- src/sys/modules/examples/ping/ping.c:1.2	Thu Jan 30 07:58:33 2020
+++ src/sys/modules/examples/ping/ping.c	Wed Feb  5 14:10:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ping.c,v 1.2 2020/01/30 07:58:33 kamil Exp $	*/
+/*	$NetBSD: ping.c,v 1.3 2020/02/05 14:10:46 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ping.c,v 1.2 2020/01/30 07:58:33 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ping.c,v 1.3 2020/02/05 14:10:46 pgoyette Exp $");
 
 #include 
 #include 
@@ -101,7 +101,7 @@ ping_ioctl(dev_t self __unused, u_long c
 		printf("ping: pong!\n");
 		return 0;
 	default:
-		return 1;
+		return ENOTTY;
 	}
 }
 

Index: src/sys/modules/examples/ping_block/ping.c
diff -u src/sys/modules/examples/ping_block/ping.c:1.1 src/sys/modules/examples/ping_block/ping.c:1.2
--- src/sys/modules/examples/ping_block/ping.c:1.1	Wed Feb  5 13:23:42 2020
+++ src/sys/modules/examples/ping_block/ping.c	Wed Feb  5 14:10:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ping.c,v 1.1 2020/02/05 13:23:42 kamil Exp $	*/
+/*	$NetBSD: ping.c,v 1.2 2020/02/05 14:10:47 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ping.c,v 1.1 2020/02/05 13:23:42 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ping.c,v 1.2 2020/02/05 14:10:47 pgoyette Exp $");
 
 #include 
 #include 
@@ -111,7 +111,7 @@ ping_ioctl(dev_t self __unused, u_long c
 		printf("ping: pong!\n");
 		return 0;
 	default:
-		return 1;
+		return ENOTTY;
 	}
 }
 



CVS commit: src/sys/modules/examples

2020-02-05 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Feb  5 13:23:42 UTC 2020

Modified Files:
src/sys/modules/examples: Makefile README
Added Files:
src/sys/modules/examples/ping_block: Makefile cmd_ping.c ping.c ping.h

Log Message:
Import new example kernel module ping_block

Subbmitted by Nisarg Joshi.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/modules/examples/Makefile
cvs rdiff -u -r1.9 -r1.10 src/sys/modules/examples/README
cvs rdiff -u -r0 -r1.1 src/sys/modules/examples/ping_block/Makefile \
src/sys/modules/examples/ping_block/cmd_ping.c \
src/sys/modules/examples/ping_block/ping.c \
src/sys/modules/examples/ping_block/ping.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/Makefile
diff -u src/sys/modules/examples/Makefile:1.7 src/sys/modules/examples/Makefile:1.8
--- src/sys/modules/examples/Makefile:1.7	Thu Jan 17 20:47:42 2019
+++ src/sys/modules/examples/Makefile	Wed Feb  5 13:23:42 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.7 2019/01/17 20:47:42 kamil Exp $
+#	$NetBSD: Makefile,v 1.8 2020/02/05 13:23:42 kamil Exp $
 
 .include 
 
@@ -9,6 +9,7 @@ SUBDIR+=	luareadhappy		# Needs an additi
 SUBDIR+=	mapper			# Needs an additional helper program
 SUBDIR+=	panic_string		# Crashes the system
 SUBDIR+=	ping			# Needs an additional helper program
+SUBDIR+=	ping_block		# Needs an additional helper program
 SUBDIR+=	properties
 SUBDIR+=	readhappy
 SUBDIR+=	readhappy_mpsafe	# Contains an additional helper program

Index: src/sys/modules/examples/README
diff -u src/sys/modules/examples/README:1.9 src/sys/modules/examples/README:1.10
--- src/sys/modules/examples/README:1.9	Thu Jan 17 20:47:42 2019
+++ src/sys/modules/examples/README	Wed Feb  5 13:23:42 2020
@@ -1,4 +1,4 @@
-	$NetBSD: README,v 1.9 2019/01/17 20:47:42 kamil Exp $
+	$NetBSD: README,v 1.10 2020/02/05 13:23:42 kamil Exp $
 
Kernel Developer's Manual
 
@@ -69,6 +69,9 @@ HISTORY
 
  The mapper module first appeared in NetBSD 9.0 and was authored by
  Akul Pillai.
+ 
+ The ping_block module first appeared in NetBSD 10.0 and was authored by
+ Nisarg Joshi.
 
 AUTHORS
  This document was written by Kamil Rytarowski.

Added files:

Index: src/sys/modules/examples/ping_block/Makefile
diff -u /dev/null src/sys/modules/examples/ping_block/Makefile:1.1
--- /dev/null	Wed Feb  5 13:23:42 2020
+++ src/sys/modules/examples/ping_block/Makefile	Wed Feb  5 13:23:42 2020
@@ -0,0 +1,18 @@
+#	$NetBSD: Makefile,v 1.1 2020/02/05 13:23:42 kamil Exp $
+
+.include "../Makefile.inc"
+
+#S?=	/usr/src/sys
+
+KMOD=	ping_block
+SRCS=	ping.c
+
+.include 
+
+# To make use of this module, you'll need to separately build the
+# cmd_ping program, with a Makefile similar to
+#
+#	MKMAN=	NO
+#	PROG=	cmd_ping
+#	.include 
+
Index: src/sys/modules/examples/ping_block/cmd_ping.c
diff -u /dev/null src/sys/modules/examples/ping_block/cmd_ping.c:1.1
--- /dev/null	Wed Feb  5 13:23:42 2020
+++ src/sys/modules/examples/ping_block/cmd_ping.c	Wed Feb  5 13:23:42 2020
@@ -0,0 +1,61 @@
+/*	$NetBSD: cmd_ping.c,v 1.1 2020/02/05 13:23:42 kamil 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 
+__RCSID("$NetBSD: cmd_ping.c,v 1.1 2020/02/05 13:23:42 kamil Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ping.h"
+
+#define _PATH_DEV_PING "/dev/ping"
+
+int main(int argc, char **argv)
+{
+	int devfd;
+
+	setprogname(argv[0]);
+
+	if ((devfd = open(_PATH_DEV_PING, O_RDWR)

CVS commit: src/sys/modules/examples

2020-01-29 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Thu Jan 30 07:58:34 UTC 2020

Modified Files:
src/sys/modules/examples/luareadhappy: luareadhappy.c
src/sys/modules/examples/mapper: mapper.c
src/sys/modules/examples/panic_string: panic_string.c
src/sys/modules/examples/ping: ping.c
src/sys/modules/examples/readhappy_mpsafe: readhappy_mpsafe.c

Log Message:
Align major numbers in example modules with sys/conf/majors

Patch submitted by: Aditya Vardhan Padala (silv3r)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/examples/luareadhappy/luareadhappy.c
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/examples/mapper/mapper.c
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/examples/panic_string/panic_string.c
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/examples/ping/ping.c
cvs rdiff -u -r1.1 -r1.2 \
src/sys/modules/examples/readhappy_mpsafe/readhappy_mpsafe.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/luareadhappy/luareadhappy.c
diff -u src/sys/modules/examples/luareadhappy/luareadhappy.c:1.1 src/sys/modules/examples/luareadhappy/luareadhappy.c:1.2
--- src/sys/modules/examples/luareadhappy/luareadhappy.c:1.1	Sat Apr 15 04:27:30 2017
+++ src/sys/modules/examples/luareadhappy/luareadhappy.c	Thu Jan 30 07:58:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: luareadhappy.c,v 1.1 2017/04/15 04:27:30 kamil Exp $	*/
+/*	$NetBSD: luareadhappy.c,v 1.2 2020/01/30 07:58:33 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: luareadhappy.c,v 1.1 2017/04/15 04:27:30 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: luareadhappy.c,v 1.2 2020/01/30 07:58:33 kamil Exp $");
 
 #include 
 #include 
@@ -42,7 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: luareadhappy
  * happy numbers.
  *
  * To use this device you need to do:
- * mknod /dev/happy c 210 0
+ * mknod /dev/happy c 351 0
  *
  * Commentary:
  * A happy number is a number defined by the following process: Starting with
@@ -189,7 +189,7 @@ happy_modcmd(modcmd_t cmd, void *arg __u
 {
 	/* The major should be verified and changed if needed to avoid
 	 * conflicts with other devices. */
-	int cmajor = 210, bmajor = -1;
+	int cmajor = 351, bmajor = -1;
 
 	switch (cmd) {
 	case MODULE_CMD_INIT:

Index: src/sys/modules/examples/mapper/mapper.c
diff -u src/sys/modules/examples/mapper/mapper.c:1.1 src/sys/modules/examples/mapper/mapper.c:1.2
--- src/sys/modules/examples/mapper/mapper.c:1.1	Thu Jan 17 20:47:42 2019
+++ src/sys/modules/examples/mapper/mapper.c	Thu Jan 30 07:58:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: mapper.c,v 1.1 2019/01/17 20:47:42 kamil Exp $	*/
+/*	$NetBSD: mapper.c,v 1.2 2020/01/30 07:58:33 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mapper.c,v 1.1 2019/01/17 20:47:42 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mapper.c,v 1.2 2020/01/30 07:58:33 kamil Exp $");
 
 #include 
 #include 
@@ -42,7 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: mapper.c,v 1
 /*
  * Creating a device /dev/mapper for demonstration.
  * To use this device you need to do:
- * 	mknod /dev/mapper c 210 0
+ * 	mknod /dev/mapper c 351 0
  *
  */
 
@@ -121,7 +121,7 @@ mapper_modcmd(modcmd_t cmd, void *arg __
 {
 	/* The major should be verified and changed if needed to avoid
 	 * conflicts with other devices. */
-	int cmajor = 210, bmajor = -1;
+	int cmajor = 351, bmajor = -1;
 
 	switch (cmd) {
 	case MODULE_CMD_INIT:

Index: src/sys/modules/examples/panic_string/panic_string.c
diff -u src/sys/modules/examples/panic_string/panic_string.c:1.1 src/sys/modules/examples/panic_string/panic_string.c:1.2
--- src/sys/modules/examples/panic_string/panic_string.c:1.1	Tue May 29 16:53:56 2018
+++ src/sys/modules/examples/panic_string/panic_string.c	Thu Jan 30 07:58:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: panic_string.c,v 1.1 2018/05/29 16:53:56 kamil Exp $	*/
+/*	$NetBSD: panic_string.c,v 1.2 2020/01/30 07:58:33 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: panic_string.c,v 1.1 2018/05/29 16:53:56 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: panic_string.c,v 1.2 2020/01/30 07:58:33 kamil Exp $");
 
 #include 
 #include 
@@ -46,7 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: panic_string
  * user input.
  *
  * To use this device you need to do:
- *  mknod /dev/panic c 210 0
+ *  mknod /dev/panic c 351 0
  *
  * To write to the device you might need:
  *  chmod 666 /dev/panic
@@ -173,7 +173,7 @@ panic_string_modcmd(modcmd_t cmd, void *
 {
 	/* The major should be verified and changed if needed to avoid
 	 * conflicts with other devices. */
-	int cmajor = 210, bmajor = -1;
+	int cmajor = 351, bmajor = -1;
 
 	switch (cmd) {
 	case MODULE_CMD_INIT:

Index: src/sys/modules/examples/ping/pi

CVS commit: src/sys/modules/examples/executor

2019-12-14 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sat Dec 14 15:36:08 UTC 2019

Modified Files:
src/sys/modules/examples/executor: executor.c

Log Message:
Use MPSAFE callouts.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/examples/executor/executor.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/executor/executor.c
diff -u src/sys/modules/examples/executor/executor.c:1.1 src/sys/modules/examples/executor/executor.c:1.2
--- src/sys/modules/examples/executor/executor.c:1.1	Fri Apr 13 20:30:09 2018
+++ src/sys/modules/examples/executor/executor.c	Sat Dec 14 15:36:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: executor.c,v 1.1 2018/04/13 20:30:09 kamil Exp $	*/
+/*	$NetBSD: executor.c,v 1.2 2019/12/14 15:36:08 ad Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: executor.c,v 1.1 2018/04/13 20:30:09 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: executor.c,v 1.2 2019/12/14 15:36:08 ad Exp $");
 
 #include 
 #include 
@@ -93,12 +93,12 @@ executor_modcmd(modcmd_t cmd, void *arg)
 	switch(cmd) {
 	case MODULE_CMD_INIT:
 		printf("executor module inserted\n");
-		callout_init(&sc, 0);
+		callout_init(&sc, CALLOUT_MPSAFE);
 		callout_reset(&sc, mstohz(1000), callout_example, NULL);
 		break;
 	case MODULE_CMD_FINI:
 		printf("executor module unloaded\n");
-		callout_stop(&sc);
+		callout_halt(&sc, NULL);
 		callout_destroy(&sc);
 		break;
 	default:



CVS commit: src/sys/modules/examples

2019-01-17 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Thu Jan 17 20:47:42 UTC 2019

Modified Files:
src/sys/modules/examples: Makefile README
Added Files:
src/sys/modules/examples/mapper: Makefile cmd_mapper.c mapper.c

Log Message:
Add a new example kernel module: mapper

Basic implementation of mmap.

Submitted by Akul Pillai.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/modules/examples/Makefile
cvs rdiff -u -r1.8 -r1.9 src/sys/modules/examples/README
cvs rdiff -u -r0 -r1.1 src/sys/modules/examples/mapper/Makefile \
src/sys/modules/examples/mapper/cmd_mapper.c \
src/sys/modules/examples/mapper/mapper.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/Makefile
diff -u src/sys/modules/examples/Makefile:1.6 src/sys/modules/examples/Makefile:1.7
--- src/sys/modules/examples/Makefile:1.6	Tue May 29 16:53:56 2018
+++ src/sys/modules/examples/Makefile	Thu Jan 17 20:47:42 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.6 2018/05/29 16:53:56 kamil Exp $
+#	$NetBSD: Makefile,v 1.7 2019/01/17 20:47:42 kamil Exp $
 
 .include 
 
@@ -6,6 +6,7 @@ SUBDIR+=	executor
 SUBDIR+=	hello
 #SUBDIR+=	luahello		# Nothing to build here, only text files
 SUBDIR+=	luareadhappy		# Needs an additional Lua script
+SUBDIR+=	mapper			# Needs an additional helper program
 SUBDIR+=	panic_string		# Crashes the system
 SUBDIR+=	ping			# Needs an additional helper program
 SUBDIR+=	properties

Index: src/sys/modules/examples/README
diff -u src/sys/modules/examples/README:1.8 src/sys/modules/examples/README:1.9
--- src/sys/modules/examples/README:1.8	Tue May 29 16:53:56 2018
+++ src/sys/modules/examples/README	Thu Jan 17 20:47:42 2019
@@ -1,4 +1,4 @@
-	$NetBSD: README,v 1.8 2018/05/29 16:53:56 kamil Exp $
+	$NetBSD: README,v 1.9 2019/01/17 20:47:42 kamil Exp $
 
Kernel Developer's Manual
 
@@ -10,6 +10,7 @@ DESCRIPTION
  * hello   - the simplest `hello world' module
  * luahello- the simplest `hello world' Lua module
  * luareadhappy- demonstrates calling Lua code from C
+ * mapper  - basic implementation of mmap
  * panic_string- shows how panic is being called through a device
  * ping- basic ioctl(9)
  * properties  - handle incoming properties during the module load
@@ -66,5 +67,8 @@ HISTORY
  The panic_string module first appeared in NetBSD 9.0 and was authored by
  Harry Pantazis.
 
+ The mapper module first appeared in NetBSD 9.0 and was authored by
+ Akul Pillai.
+
 AUTHORS
  This document was written by Kamil Rytarowski.

Added files:

Index: src/sys/modules/examples/mapper/Makefile
diff -u /dev/null src/sys/modules/examples/mapper/Makefile:1.1
--- /dev/null	Thu Jan 17 20:47:42 2019
+++ src/sys/modules/examples/mapper/Makefile	Thu Jan 17 20:47:42 2019
@@ -0,0 +1,17 @@
+#	$NetBSD: Makefile,v 1.1 2019/01/17 20:47:42 kamil Exp $
+
+.include "../Makefile.inc"
+
+#S?=	/usr/src/sys
+
+KMOD=	mapper
+SRCS=	mapper.c
+
+.include 
+
+# To make use of this module, you'll need to separately build the
+# cmd_mapper program, with a Makefile similar to
+#
+#	MKMAN=	NO
+#	PROG=	cmd_mapper
+#	.include 
Index: src/sys/modules/examples/mapper/cmd_mapper.c
diff -u /dev/null src/sys/modules/examples/mapper/cmd_mapper.c:1.1
--- /dev/null	Thu Jan 17 20:47:42 2019
+++ src/sys/modules/examples/mapper/cmd_mapper.c	Thu Jan 17 20:47:42 2019
@@ -0,0 +1,64 @@
+/*	$NetBSD: cmd_mapper.c,v 1.1 2019/01/17 20:47:42 kamil Exp $	*/
+
+/*-
+ * Copyright (c) 2019 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
+ 

CVS commit: src/sys/modules/examples

2018-05-29 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue May 29 16:53:56 UTC 2018

Modified Files:
src/sys/modules/examples: Makefile README
Added Files:
src/sys/modules/examples/panic_string: Makefile panic_string.c

Log Message:
Introduce new example kernel module: panic_string

The panic_string module accepts input from a device file over the write(2)
system call.

It prints panic(9) message passed from user space, e.g.:

   echo "Hello world" > /dev/panic

If a string is empty or contain only whitespaces it's ignored and panic(9)
is not triggered. If a non printable character is passed within the input
buffer, the rest of the string is ignored.

This module performs the sync(8) operation before panic(9) to flush cache.

Submitted by Harry Pantazis.
Simplified and cleaned up by myself.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/modules/examples/Makefile
cvs rdiff -u -r1.7 -r1.8 src/sys/modules/examples/README
cvs rdiff -u -r0 -r1.1 src/sys/modules/examples/panic_string/Makefile \
src/sys/modules/examples/panic_string/panic_string.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/Makefile
diff -u src/sys/modules/examples/Makefile:1.5 src/sys/modules/examples/Makefile:1.6
--- src/sys/modules/examples/Makefile:1.5	Fri Apr 20 00:06:45 2018
+++ src/sys/modules/examples/Makefile	Tue May 29 16:53:56 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.5 2018/04/20 00:06:45 kamil Exp $
+#	$NetBSD: Makefile,v 1.6 2018/05/29 16:53:56 kamil Exp $
 
 .include 
 
@@ -6,6 +6,7 @@ SUBDIR+=	executor
 SUBDIR+=	hello
 #SUBDIR+=	luahello		# Nothing to build here, only text files
 SUBDIR+=	luareadhappy		# Needs an additional Lua script
+SUBDIR+=	panic_string		# Crashes the system
 SUBDIR+=	ping			# Needs an additional helper program
 SUBDIR+=	properties
 SUBDIR+=	readhappy

Index: src/sys/modules/examples/README
diff -u src/sys/modules/examples/README:1.7 src/sys/modules/examples/README:1.8
--- src/sys/modules/examples/README:1.7	Fri Apr 20 00:06:45 2018
+++ src/sys/modules/examples/README	Tue May 29 16:53:56 2018
@@ -1,4 +1,4 @@
-	$NetBSD: README,v 1.7 2018/04/20 00:06:45 kamil Exp $
+	$NetBSD: README,v 1.8 2018/05/29 16:53:56 kamil Exp $
 
Kernel Developer's Manual
 
@@ -10,8 +10,9 @@ DESCRIPTION
  * hello   - the simplest `hello world' module
  * luahello- the simplest `hello world' Lua module
  * luareadhappy- demonstrates calling Lua code from C
- * properties  - handle incoming properties during the module load
+ * panic_string- shows how panic is being called through a device
  * ping- basic ioctl(9)
+ * properties  - handle incoming properties during the module load
  * readhappy   - basic implementation of read(9) with happy numbers
  * readhappy_mpsafe- demonstrates how to make a module MPSAFE
  * sysctl  - demonstrates adding a sysctl handle dynamically
@@ -62,5 +63,8 @@ HISTORY
  The readhappy_mpsafe, executor and sysctls modules first appeared in NetBSD
  9.0 and were authored by Siddharth Muralee.
 
+ The panic_string module first appeared in NetBSD 9.0 and was authored by
+ Harry Pantazis.
+
 AUTHORS
  This document was written by Kamil Rytarowski.

Added files:

Index: src/sys/modules/examples/panic_string/Makefile
diff -u /dev/null src/sys/modules/examples/panic_string/Makefile:1.1
--- /dev/null	Tue May 29 16:53:56 2018
+++ src/sys/modules/examples/panic_string/Makefile	Tue May 29 16:53:56 2018
@@ -0,0 +1,9 @@
+#	$NetBSD: Makefile,v 1.1 2018/05/29 16:53:56 kamil Exp $
+
+.include "../Makefile.inc"
+
+#S?=	/usr/src/sys
+KMOD=	panic_string
+SRCS=	panic_string.c
+
+.include 
Index: src/sys/modules/examples/panic_string/panic_string.c
diff -u /dev/null src/sys/modules/examples/panic_string/panic_string.c:1.1
--- /dev/null	Tue May 29 16:53:56 2018
+++ src/sys/modules/examples/panic_string/panic_string.c	Tue May 29 16:53:56 2018
@@ -0,0 +1,196 @@
+/*	$NetBSD: panic_string.c,v 1.1 2018/05/29 16:53:56 kamil Exp $	*/
+
+/*-
+ * Copyright (c) 2018 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

CVS commit: src/sys/modules/examples

2018-04-19 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Fri Apr 20 00:06:45 UTC 2018

Modified Files:
src/sys/modules/examples: Makefile README
Added Files:
src/sys/modules/examples/readhappy_mpsafe: Makefile readhappy_mpsafe.c
test_readhappy.c

Log Message:
Add new example loadable kernel module example: readhappy_mpsafe

readhappy_mpsafe - demonstrates how to make a module MPSAFE

This module contains an additional helper program test_readhappy.c,
that is designed to exercise the kernel module with multiple threads.

Submitted by 


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/modules/examples/Makefile
cvs rdiff -u -r1.6 -r1.7 src/sys/modules/examples/README
cvs rdiff -u -r0 -r1.1 src/sys/modules/examples/readhappy_mpsafe/Makefile \
src/sys/modules/examples/readhappy_mpsafe/readhappy_mpsafe.c \
src/sys/modules/examples/readhappy_mpsafe/test_readhappy.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/Makefile
diff -u src/sys/modules/examples/Makefile:1.4 src/sys/modules/examples/Makefile:1.5
--- src/sys/modules/examples/Makefile:1.4	Fri Apr 13 20:30:09 2018
+++ src/sys/modules/examples/Makefile	Fri Apr 20 00:06:45 2018
@@ -1,14 +1,15 @@
-#	$NetBSD: Makefile,v 1.4 2018/04/13 20:30:09 kamil Exp $
+#	$NetBSD: Makefile,v 1.5 2018/04/20 00:06:45 kamil Exp $
 
 .include 
 
-SUBDIR+=	hello
 SUBDIR+=	executor
-#SUBDIR+=	luahello	# Nothing to build here, only text files
-SUBDIR+=	luareadhappy	# Needs an additional Lua script
-SUBDIR+=	ping		# Needs an additional helper program
+SUBDIR+=	hello
+#SUBDIR+=	luahello		# Nothing to build here, only text files
+SUBDIR+=	luareadhappy		# Needs an additional Lua script
+SUBDIR+=	ping			# Needs an additional helper program
 SUBDIR+=	properties
 SUBDIR+=	readhappy
+SUBDIR+=	readhappy_mpsafe	# Contains an additional helper program
 SUBDIR+=	sysctl
 
 .include 

Index: src/sys/modules/examples/README
diff -u src/sys/modules/examples/README:1.6 src/sys/modules/examples/README:1.7
--- src/sys/modules/examples/README:1.6	Fri Apr 13 20:30:09 2018
+++ src/sys/modules/examples/README	Fri Apr 20 00:06:45 2018
@@ -1,4 +1,4 @@
-	$NetBSD: README,v 1.6 2018/04/13 20:30:09 kamil Exp $
+	$NetBSD: README,v 1.7 2018/04/20 00:06:45 kamil Exp $
 
Kernel Developer's Manual
 
@@ -13,6 +13,7 @@ DESCRIPTION
  * properties  - handle incoming properties during the module load
  * ping- basic ioctl(9)
  * readhappy   - basic implementation of read(9) with happy numbers
+ * readhappy_mpsafe- demonstrates how to make a module MPSAFE
  * sysctl  - demonstrates adding a sysctl handle dynamically
 
  To build the examples you need a local copy of NetBSD sources. You also
@@ -58,8 +59,8 @@ HISTORY
  ping, luahello and luareadhappy) first appeared in NetBSD 8.0; they were
  written by Kamil Rytarowski.
 
- The executor and sysctls module first appeared in NetBSD 9.0 and were
- authored by Siddharth Muralee.
+ The readhappy_mpsafe, executor and sysctls modules first appeared in NetBSD
+ 9.0 and were authored by Siddharth Muralee.
 
 AUTHORS
  This document was written by Kamil Rytarowski.

Added files:

Index: src/sys/modules/examples/readhappy_mpsafe/Makefile
diff -u /dev/null src/sys/modules/examples/readhappy_mpsafe/Makefile:1.1
--- /dev/null	Fri Apr 20 00:06:45 2018
+++ src/sys/modules/examples/readhappy_mpsafe/Makefile	Fri Apr 20 00:06:45 2018
@@ -0,0 +1,22 @@
+#	$NetBSD: Makefile,v 1.1 2018/04/20 00:06:45 kamil Exp $
+
+.include "../Makefile.inc"
+
+#S?=	/usr/src/sys
+KMOD=	readhappy_mpsafe
+SRCS=	readhappy_mpsafe.c
+
+.include 
+
+# To make use of this module, you'll need to separately build the
+# test_readhappy program, with a Makefile similar to
+#
+#	MKMAN=	NO
+#	PROG=	test_readhappy
+#
+#	CFLAGS+=-pthread
+#
+#	LDADD+= -lpthread
+#	DPADD+= ${LIBPTHREAD}
+#
+#	.include 
Index: src/sys/modules/examples/readhappy_mpsafe/readhappy_mpsafe.c
diff -u /dev/null src/sys/modules/examples/readhappy_mpsafe/readhappy_mpsafe.c:1.1
--- /dev/null	Fri Apr 20 00:06:45 2018
+++ src/sys/modules/examples/readhappy_mpsafe/readhappy_mpsafe.c	Fri Apr 20 00:06:45 2018
@@ -0,0 +1,243 @@
+/*	$NetBSD: readhappy_mpsafe.c,v 1.1 2018/04/20 00:06:45 kamil Exp $*/
+
+/*-
+ * Copyright (c) 2018 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 dist

CVS commit: src/sys/modules/examples

2018-04-13 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Fri Apr 13 20:30:09 UTC 2018

Modified Files:
src/sys/modules/examples: Makefile README
Added Files:
src/sys/modules/examples/executor: Makefile executor.c

Log Message:
Add a new example kernel module

executor - basic implementation of callout and RUN_ONCE

While there, perform a small cleanup in README.

Patch by 
Polishing by myself.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/modules/examples/Makefile
cvs rdiff -u -r1.5 -r1.6 src/sys/modules/examples/README
cvs rdiff -u -r0 -r1.1 src/sys/modules/examples/executor/Makefile \
src/sys/modules/examples/executor/executor.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/Makefile
diff -u src/sys/modules/examples/Makefile:1.3 src/sys/modules/examples/Makefile:1.4
--- src/sys/modules/examples/Makefile:1.3	Fri Apr 13 01:20:27 2018
+++ src/sys/modules/examples/Makefile	Fri Apr 13 20:30:09 2018
@@ -1,8 +1,9 @@
-#	$NetBSD: Makefile,v 1.3 2018/04/13 01:20:27 kamil Exp $
+#	$NetBSD: Makefile,v 1.4 2018/04/13 20:30:09 kamil Exp $
 
 .include 
 
 SUBDIR+=	hello
+SUBDIR+=	executor
 #SUBDIR+=	luahello	# Nothing to build here, only text files
 SUBDIR+=	luareadhappy	# Needs an additional Lua script
 SUBDIR+=	ping		# Needs an additional helper program

Index: src/sys/modules/examples/README
diff -u src/sys/modules/examples/README:1.5 src/sys/modules/examples/README:1.6
--- src/sys/modules/examples/README:1.5	Fri Apr 13 01:20:27 2018
+++ src/sys/modules/examples/README	Fri Apr 13 20:30:09 2018
@@ -1,17 +1,18 @@
-	$NetBSD: README,v 1.5 2018/04/13 01:20:27 kamil Exp $
+	$NetBSD: README,v 1.6 2018/04/13 20:30:09 kamil Exp $
 
Kernel Developer's Manual
 
 DESCRIPTION
  The kernel example dynamic modules.
 
- This directory contains the following example modules
+ This directory contains the following example modules:
+ * executor- basic implementation of callout and RUN_ONCE
  * 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
  * luareadhappy- demonstrates calling Lua code from C
+ * properties  - handle incoming properties during the module load
+ * ping- basic ioctl(9)
+ * readhappy   - basic implementation of read(9) with happy numbers
  * sysctl  - demonstrates adding a sysctl handle dynamically
 
  To build the examples you need a local copy of NetBSD sources. You also
@@ -57,8 +58,8 @@ HISTORY
  ping, luahello and luareadhappy) first appeared in NetBSD 8.0; they were
  written by Kamil Rytarowski.
 
- The sysctl module first appeared in NetBSD 9.0 and was authored by
- Siddharth Muralee.
+ The executor and sysctls module first appeared in NetBSD 9.0 and were
+ authored by Siddharth Muralee.
 
 AUTHORS
  This document was written by Kamil Rytarowski.

Added files:

Index: src/sys/modules/examples/executor/Makefile
diff -u /dev/null src/sys/modules/examples/executor/Makefile:1.1
--- /dev/null	Fri Apr 13 20:30:09 2018
+++ src/sys/modules/examples/executor/Makefile	Fri Apr 13 20:30:09 2018
@@ -0,0 +1,11 @@
+#	$NetBSD: Makefile,v 1.1 2018/04/13 20:30:09 kamil Exp $
+
+.include "../Makefile.inc"
+
+#S?=	/usr/src/sys
+
+KMOD=	executor
+SRCS=	executor.c
+
+.include 
+
Index: src/sys/modules/examples/executor/executor.c
diff -u /dev/null src/sys/modules/examples/executor/executor.c:1.1
--- /dev/null	Fri Apr 13 20:30:09 2018
+++ src/sys/modules/examples/executor/executor.c	Fri Apr 13 20:30:09 2018
@@ -0,0 +1,108 @@
+/*	$NetBSD: executor.c,v 1.1 2018/04/13 20:30:09 kamil Exp $	*/
+
+/*-
+ * Copyright (c) 2018 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
+ * CONSEQUENT

CVS commit: src/sys/modules/examples

2018-04-12 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Fri Apr 13 01:20:28 UTC 2018

Modified Files:
src/sys/modules/examples: Makefile README
Added Files:
src/sys/modules/examples/sysctl: Makefile sysctl.c

Log Message:
Add new example kernel module: sysctl

sysctl - demonstrates adding a sysctl handle dynamically.

Patch by 
Polishing by myself.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/modules/examples/Makefile
cvs rdiff -u -r1.4 -r1.5 src/sys/modules/examples/README
cvs rdiff -u -r0 -r1.1 src/sys/modules/examples/sysctl/Makefile \
src/sys/modules/examples/sysctl/sysctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/Makefile
diff -u src/sys/modules/examples/Makefile:1.2 src/sys/modules/examples/Makefile:1.3
--- src/sys/modules/examples/Makefile:1.2	Sat Apr 15 18:22:35 2017
+++ src/sys/modules/examples/Makefile	Fri Apr 13 01:20:27 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.2 2017/04/15 18:22:35 kamil Exp $
+#	$NetBSD: Makefile,v 1.3 2018/04/13 01:20:27 kamil Exp $
 
 .include 
 
@@ -8,5 +8,6 @@ SUBDIR+=	luareadhappy	# Needs an additio
 SUBDIR+=	ping		# Needs an additional helper program
 SUBDIR+=	properties
 SUBDIR+=	readhappy
+SUBDIR+=	sysctl
 
 .include 

Index: src/sys/modules/examples/README
diff -u src/sys/modules/examples/README:1.4 src/sys/modules/examples/README:1.5
--- src/sys/modules/examples/README:1.4	Sun Apr 23 23:39:42 2017
+++ src/sys/modules/examples/README	Fri Apr 13 01:20:27 2018
@@ -1,17 +1,18 @@
-	$NetBSD: README,v 1.4 2017/04/23 23:39:42 sevan Exp $
+	$NetBSD: README,v 1.5 2018/04/13 01:20:27 kamil Exp $
 
Kernel Developer's Manual
 
 DESCRIPTION
  The kernel example dynamic modules.
 
- This directory contains the following example 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
  * luareadhappy- demonstrates calling Lua code from C
+ * sysctl  - demonstrates adding a sysctl handle dynamically
 
  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
@@ -56,5 +57,8 @@ HISTORY
  ping, luahello and luareadhappy) first appeared in NetBSD 8.0; they were
  written by Kamil Rytarowski.
 
+ The sysctl module first appeared in NetBSD 9.0 and was authored by
+ Siddharth Muralee.
+
 AUTHORS
  This document was written by Kamil Rytarowski.

Added files:

Index: src/sys/modules/examples/sysctl/Makefile
diff -u /dev/null src/sys/modules/examples/sysctl/Makefile:1.1
--- /dev/null	Fri Apr 13 01:20:28 2018
+++ src/sys/modules/examples/sysctl/Makefile	Fri Apr 13 01:20:28 2018
@@ -0,0 +1,10 @@
+#	$NetBSD: Makefile,v 1.1 2018/04/13 01:20:28 kamil Exp $
+
+.include "../Makefile.inc"
+
+#S?=	/usr/src/sys
+
+KMOD=	sysctl
+SRCS=	sysctl.c
+
+.include 
Index: src/sys/modules/examples/sysctl/sysctl.c
diff -u /dev/null src/sys/modules/examples/sysctl/sysctl.c:1.1
--- /dev/null	Fri Apr 13 01:20:28 2018
+++ src/sys/modules/examples/sysctl/sysctl.c	Fri Apr 13 01:20:28 2018
@@ -0,0 +1,118 @@
+/*	$NetBSD: sysctl.c,v 1.1 2018/04/13 01:20:28 kamil Exp $	*/
+
+/*-
+ * Copyright (c) 2018 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.
+ */
+

CVS commit: src/sys/modules/examples

2017-04-23 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Sun Apr 23 23:39:42 UTC 2017

Modified Files:
src/sys/modules/examples: README

Log Message:
Add luareadhappy to the list.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/modules/examples/README

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/README
diff -u src/sys/modules/examples/README:1.3 src/sys/modules/examples/README:1.4
--- src/sys/modules/examples/README:1.3	Fri May 15 06:21:12 2015
+++ src/sys/modules/examples/README	Sun Apr 23 23:39:42 2017
@@ -1,4 +1,4 @@
-	$NetBSD: README,v 1.3 2015/05/15 06:21:12 pgoyette Exp $
+	$NetBSD: README,v 1.4 2017/04/23 23:39:42 sevan Exp $
 
Kernel Developer's Manual
 
@@ -11,6 +11,7 @@ DESCRIPTION
  * readhappy   - basic implementation of read(9) with happy numbers
  * ping- basic ioctl(9)
  * luahello- the simplest `hello world' Lua module
+ * luareadhappy- demonstrates calling Lua code from C
 
  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
@@ -52,8 +53,8 @@ HISTORY
  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.
+ ping, luahello and luareadhappy) first appeared in NetBSD 8.0; they were
+ written by Kamil Rytarowski.
 
 AUTHORS
  This document was written by Kamil Rytarowski.



CVS commit: src/sys/modules/examples

2017-04-15 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Apr 15 18:22:35 UTC 2017

Modified Files:
src/sys/modules/examples: Makefile

Log Message:
Build without installation example lua kernel module: luareadhappy


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/examples/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/Makefile
diff -u src/sys/modules/examples/Makefile:1.1 src/sys/modules/examples/Makefile:1.2
--- src/sys/modules/examples/Makefile:1.1	Wed May 13 07:07:36 2015
+++ src/sys/modules/examples/Makefile	Sat Apr 15 18:22:35 2017
@@ -1,9 +1,10 @@
-#	$NetBSD: Makefile,v 1.1 2015/05/13 07:07:36 pgoyette Exp $
+#	$NetBSD: Makefile,v 1.2 2017/04/15 18:22:35 kamil Exp $
 
 .include 
 
 SUBDIR+=	hello
 #SUBDIR+=	luahello	# Nothing to build here, only text files
+SUBDIR+=	luareadhappy	# Needs an additional Lua script
 SUBDIR+=	ping		# Needs an additional helper program
 SUBDIR+=	properties
 SUBDIR+=	readhappy



CVS commit: src/sys/modules/examples/luareadhappy

2017-04-14 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Apr 15 04:27:30 UTC 2017

Added Files:
src/sys/modules/examples/luareadhappy: Makefile happy.lua
luareadhappy.c

Log Message:
Add new example kernel module in Lua luareadhappy

This example presents a C module with its device (/dev entry) and its
content generator with algorithm defined in Lua state. The Lua state can
be changed dynamically from userland, without interruption of read(2) over
the device.

This is an example how to call Lua code from C.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/modules/examples/luareadhappy/Makefile \
src/sys/modules/examples/luareadhappy/happy.lua \
src/sys/modules/examples/luareadhappy/luareadhappy.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/sys/modules/examples/luareadhappy/Makefile
diff -u /dev/null src/sys/modules/examples/luareadhappy/Makefile:1.1
--- /dev/null	Sat Apr 15 04:27:30 2017
+++ src/sys/modules/examples/luareadhappy/Makefile	Sat Apr 15 04:27:30 2017
@@ -0,0 +1,14 @@
+#	$NetBSD: Makefile,v 1.1 2017/04/15 04:27:30 kamil Exp $
+
+#.include "../Makefile.inc"
+
+#S?=	/usr/src/sys
+
+KMOD=	luareadhappy
+SRCS=	luareadhappy.c
+
+CPPFLAGS+=	-I${S}/../external/mit/lua/dist/src \
+		-I${S}/modules/lua \
+		-I${S}/sys
+
+.include 
Index: src/sys/modules/examples/luareadhappy/happy.lua
diff -u /dev/null src/sys/modules/examples/luareadhappy/happy.lua:1.1
--- /dev/null	Sat Apr 15 04:27:30 2017
+++ src/sys/modules/examples/luareadhappy/happy.lua	Sat Apr 15 04:27:30 2017
@@ -0,0 +1,77 @@
+--	$NetBSD: happy.lua,v 1.1 2017/04/15 04:27:30 kamil 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.
+--
+--
+-- Commentary:
+-- A happy number is a number defined by the following process: Starting with
+-- any positive integer, replace the number by the sum of the squares of its
+-- digits, and repeat the process until the number equals 1 (where it will
+-- stay), or it loops endlessly in a cycle which does not include 1. Those
+-- numbers for which this process ends in 1 are happy numbers, while those that
+-- do not end in 1 are unhappy numbers (or sad numbers).
+--
+-- For more information on happy numbers, and the algorithms, see
+--  http://en.wikipedia.org/wiki/Happy_number
+--
+-- The happy number generator is here only to have something that the user
+-- can read from our device.  Any other arbitrary data generator could
+-- have been used.  The algorithm is not critical to the implementation
+-- of the module.
+
+local HAPPY_NUMBER = 1
+
+-- If n is not happy then its sequence ends in the cycle:
+-- 4, 16, 37, 58, 89, 145, 42, 20, 4, ...
+local SAD_NUMBER = 4
+
+-- This following algorithm is designed for numbers of the integer type.
+-- Integer numbers are used by default in the NetBSD kernel, as there would be
+-- need for additional overhead in context-switch with support for floats.
+
+function dsum(n)
+	local sum = 0
+	while n > 0 do
+		local x = n % 10
+		sum = sum + (x * x)
+		n = n / 10
+	end
+	return sum
+end
+
+function is_happy(n)
+	while true do
+		local total = dsum(n)
+
+		if total == HAPPY_NUMBER then
+			return 1
+		end
+		if total == SAD_NUMBER then
+			return 0
+		end
+
+		n = total
+	end
+end
Index: src/sys/modules/examples/luareadhappy/luareadhappy.c
diff -u /dev/null src/sys/modules/examples/luareadhappy/luareadhappy.c:1.1
--- /dev/null	Sat Apr 15 04:27:30 2017
+++ src/sys/modules/examples/luareadhappy/luareadhappy.c	Sat Apr 15 04:27:30 2017
@@ -0,0 +1,217 @@
+/*	$NetBSD: luareadhappy.c,v 1.1 2017/04/15 0

CVS commit: src/sys/modules/examples

2015-05-14 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Fri May 15 06:21:12 UTC 2015

Modified Files:
src/sys/modules/examples: README

Log Message:
Even though this isn't a man page, it looks like one.  So sort the
SEE ALSO section accordingly.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/modules/examples/README

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/README
diff -u src/sys/modules/examples/README:1.2 src/sys/modules/examples/README:1.3
--- src/sys/modules/examples/README:1.2	Wed May 13 22:41:48 2015
+++ src/sys/modules/examples/README	Fri May 15 06:21:12 2015
@@ -1,4 +1,4 @@
-	$NetBSD: README,v 1.2 2015/05/13 22:41:48 pgoyette Exp $
+	$NetBSD: README,v 1.3 2015/05/15 06:21:12 pgoyette Exp $
 
Kernel Developer's Manual
 
@@ -43,8 +43,8 @@ DESCRIPTION
  should not conflict with a real device.
 
 SEE ALSO
- lua(9lua), modctl(2), modload(8), module(7), module(9), modstat(8),
- modunload(8)
+ 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



CVS commit: src/sys/modules/examples

2015-05-13 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 13 22:41:48 UTC 2015

Modified Files:
src/sys/modules/examples: README

Log Message:
Fix up another internal reference to renamed module, and adjust some
English grammar.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/examples/README

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/README
diff -u src/sys/modules/examples/README:1.1 src/sys/modules/examples/README:1.2
--- src/sys/modules/examples/README:1.1	Wed May 13 07:07:36 2015
+++ src/sys/modules/examples/README	Wed May 13 22:41:48 2015
@@ -1,4 +1,4 @@
-	$NetBSD: README,v 1.1 2015/05/13 07:07:36 pgoyette Exp $
+	$NetBSD: README,v 1.2 2015/05/13 22:41:48 pgoyette Exp $
 
Kernel Developer's Manual
 
@@ -10,7 +10,7 @@ DESCRIPTION
  * properties  - handle incoming properties during the module load
  * readhappy   - basic implementation of read(9) with happy numbers
  * ping- basic ioctl(9)
- * hellolua- the simplest `hello world' Lua module
+ * 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
@@ -52,7 +52,7 @@ HISTORY
  Husemann, Adam Hamsik, John Nemeth and Mindaugas Rasiukevicius.
 
  This document and additional modules (hello, readhappy, properties,
- and ping, hellolua) first appeared in NetBSD 8.0 and they were written
+ ping, and luahello) first appeared in NetBSD 8.0; they were written
  by Kamil Rytarowski.
 
 AUTHORS



CVS commit: src/sys/modules/examples/luahello

2015-05-13 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 13 22:37:53 UTC 2015

Modified Files:
src/sys/modules/examples/luahello: luahello.lua

Log Message:
Fix instructions to match reality.  (I renamed the example from the
original submitter, but didn't catch all internal references.)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/examples/luahello/luahello.lua

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/luahello/luahello.lua
diff -u src/sys/modules/examples/luahello/luahello.lua:1.1 src/sys/modules/examples/luahello/luahello.lua:1.2
--- src/sys/modules/examples/luahello/luahello.lua:1.1	Wed May 13 07:07:36 2015
+++ src/sys/modules/examples/luahello/luahello.lua	Wed May 13 22:37:53 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: luahello.lua,v 1.1 2015/05/13 07:07:36 pgoyette Exp $
+#	$NetBSD: luahello.lua,v 1.2 2015/05/13 22:37:53 pgoyette Exp $
 #
 #
 # Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
 #luactl require state1 systm
 #
 # 4. Load our code in state1
-#luactl load state1 ./hellolua.lua
+#luactl load state1 ./luahello.lua
 #
 # NB. The path with our code must contain at least single '/' character
 



CVS commit: src/sys/modules/examples/ping

2015-05-13 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Wed May 13 12:13:38 UTC 2015

Modified Files:
src/sys/modules/examples/ping: cmd_ping.c

Log Message:
Fix RCS ID.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/examples/ping/cmd_ping.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/examples/ping/cmd_ping.c
diff -u src/sys/modules/examples/ping/cmd_ping.c:1.1 src/sys/modules/examples/ping/cmd_ping.c:1.2
--- src/sys/modules/examples/ping/cmd_ping.c:1.1	Wed May 13 07:07:36 2015
+++ src/sys/modules/examples/ping/cmd_ping.c	Wed May 13 12:13:38 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: cmd_ping.c,v 1.1 2015/05/13 07:07:36 pgoyette Exp $	*/
+/*	$NetBSD: cmd_ping.c,v 1.2 2015/05/13 12:13:38 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD $");
+__RCSID("$NetBSD: cmd_ping.c,v 1.2 2015/05/13 12:13:38 joerg Exp $");
 
 #include 
 #include 



CVS commit: src/sys/modules/examples

2015-05-13 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 13 07:07:36 UTC 2015

Added Files:
src/sys/modules/examples: Makefile Makefile.inc README
src/sys/modules/examples/hello: Makefile hello.c
src/sys/modules/examples/luahello: luahello.lua
src/sys/modules/examples/ping: Makefile cmd_ping.c ping.c ping.h
src/sys/modules/examples/properties: Makefile properties.c
src/sys/modules/examples/readhappy: Makefile readhappy.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/modules/examples/Makefile \
src/sys/modules/examples/Makefile.inc src/sys/modules/examples/README
cvs rdiff -u -r0 -r1.1 src/sys/modules/examples/hello/Makefile \
src/sys/modules/examples/hello/hello.c
cvs rdiff -u -r0 -r1.1 src/sys/modules/examples/luahello/luahello.lua
cvs rdiff -u -r0 -r1.1 src/sys/modules/examples/ping/Makefile \
src/sys/modules/examples/ping/cmd_ping.c \
src/sys/modules/examples/ping/ping.c src/sys/modules/examples/ping/ping.h
cvs rdiff -u -r0 -r1.1 src/sys/modules/examples/properties/Makefile \
src/sys/modules/examples/properties/properties.c
cvs rdiff -u -r0 -r1.1 src/sys/modules/examples/readhappy/Makefile \
src/sys/modules/examples/readhappy/readhappy.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/sys/modules/examples/Makefile
diff -u /dev/null src/sys/modules/examples/Makefile:1.1
--- /dev/null	Wed May 13 07:07:36 2015
+++ src/sys/modules/examples/Makefile	Wed May 13 07:07:36 2015
@@ -0,0 +1,11 @@
+#	$NetBSD: Makefile,v 1.1 2015/05/13 07:07:36 pgoyette Exp $
+
+.include 
+
+SUBDIR+=	hello
+#SUBDIR+=	luahello	# Nothing to build here, only text files
+SUBDIR+=	ping		# Needs an additional helper program
+SUBDIR+=	properties
+SUBDIR+=	readhappy
+
+.include 
Index: src/sys/modules/examples/Makefile.inc
diff -u /dev/null src/sys/modules/examples/Makefile.inc:1.1
--- /dev/null	Wed May 13 07:07:36 2015
+++ src/sys/modules/examples/Makefile.inc	Wed May 13 07:07:36 2015
@@ -0,0 +1,9 @@
+#	$NetBSD: Makefile.inc,v 1.1 2015/05/13 07:07:36 pgoyette Exp $
+
+# We only build the example modules; we don't want to install them anywhere
+
+kmodinstall:
+
+# Include parent's Makefile.inc
+
+.include "../Makefile.inc"
Index: src/sys/modules/examples/README
diff -u /dev/null src/sys/modules/examples/README:1.1
--- /dev/null	Wed May 13 07:07:36 2015
+++ src/sys/modules/examples/README	Wed May 13 07:07:36 2015
@@ -0,0 +1,59 @@
+	$NetBSD: README,v 1.1 2015/05/13 07:07:36 pgoyette 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)
+ * hellolua- 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
+ lua(9lua), modctl(2), modload(8), module(7), module(9), modstat(8),
+ modunload(8)
+
+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,
+ and ping, hellolua) first appeared in NetBSD 8.0 and they were written
+ by Kamil Rytarowski.
+
+AUTHORS
+