1#! /usr/local/bin/generate 2# $Id: driver.pck 1350 2011-09-16 16:46:58Z darcy $ 3# driver.pck 4# Written by D'Arcy J.M. Cain 5 6# This is a sample script for generate. It will create a skeleton of 7# a System V R4 device driver. To use this fill in the following defines, 8# create a directory, cd to it and run: 9# generate <path>/driver.pck 10# where <path> is the directory where this file resides. 11 12# Note that I don't work on System V any more so I haven't tested 13# this lately. Consider it a sample generate script more than 14# anything else 15 16# Replace the "xxx" with the tag used by your driver 17@DEFINE TAG xxx 18 19# The full name of the driver goes here 20@DEFINE NAME Test driver from generate distribution 21 22# Replace with your name - note escape on apostophe in my name 23# Without that you will see the comment because it is within 24# a string. It is not an error to run off the end of a line 25# while in a quoted string. The EOL is effectively an end quote. 26@DEFINE AUTHOR D\'Arcy J.M. Cain 27 28# Define your email address 29@DEFINE EMAIL darcy@druid.net 30 31# If you use gcc define this otherwise SVR4 cc is assumed 32# To undefine this simply change the '@' to a '#' 33@DEFINE GCC 34 35# If you want an inittab entry enter the command here and uncomment 36# by changing the '#' to a '@' 37#DEFINE INIT \$(BIN)/command 38 39# End of generate custom area - Ignore instructions in the rest of the 40# file. They apply in the files that are built by generate 41#------------------------------------------------------------------- 42 43@FILE Makefile 44\# Makefile for $(NAME) driver 45\# Written by $(AUTHOR) 46! 47\# Note that anything that runs su displays the command line so that 48\# the builder knows what he/she is getting into. 49! 50@IFDEF GCC 51CFLAGS = -O -pipe -ansi -Wall -Wshadow -Wpointer-arith -Wcast-qual \\ 52! -Wwrite-strings -Dscanf=DONT_USE_SCANF -Dgets=DONT_USE_GETS 53CC = gcc 54@ELSE 55CFLAGS = -O -Xa -v -Dscanf=DONT_USE_SCANF -Dgets=DONT_USE_GETS 56@ENDIF 57! 58@IFDEF INIT 59\# If you don't want to run $(INIT) automatically change 60\# "respawn" in the following definition to "off" 61RESPAWN = respawn 62@ENDIF 63! 64\# If you want to build and install all the files but not activate 65\# the driver then change the 'Y' here to 'N'. 66ACTIVE = Y 67! 68\# modify these if things are kept somewhere else on your system 69BIN = /usr/local/bin 70MAN = /usr/share/man/man 71CONFBIN = /etc/conf/bin 72INCLUDE = /usr/include/sys 73! 74\# You shouldn't have to change anything after this (with the possible 75\# exception of Node, see comments below.) If you do find changes 76\# necessary I would appreciate a message at $(EMAIL). In 77\# fact please tell me when you have to make any changes to the package 78\# other than above. 79! 80SU_INSTALL = "if \$(CONFBIN)/idcheck -p $(TAG);\\ 81! then \$(CONFBIN)/idinstall -k -a $(TAG);\\ 82! else \$(CONFBIN)/idinstall -k -u $(TAG);\\ 83! fi" 84SU_UNINSTALL = "\$(CONFBIN)/idinstall -k -d $(TAG); \$(CONFBIN)/idbuild" 85SU_BUILD = "\$(CONFBIN)/idbuild" 86! 87 88@IFDEF INIT 89@DEFINE INIT_FILE Init 90@ELSE 91@DEFINE INIT_FILE 92@ENDIF 93SYSFILES = $(INIT_FILE) Master Name Node System 94.SILENT: 95! 96all: Driver.o 97! 98 99@IFDEF INIT 100Init: Makefile 101! echo "Creating Init" 102! echo \"$(TAG)0:23:\$(RESPAWN):$(INIT)\" > Init 103! 104@ENDIF 105 106Master: Makefile 107! echo "Creating Master" 108! echo \"$(TAG) ocrwiI icoH $(TAG) 0 0 1 4 -1\" > Master 109! 110Name: Makefile 111! echo "Creating Name" 112! echo \"$(NAME)\" > Name 113! 114Node: Makefile 115! echo "Creating Node" 116! echo "$(TAG) $(TAG) c 0" > Node 117! 118System: Makefile 119! echo "Creating System" 120! echo "$(TAG) \$(ACTIVE) 1 0 0 0 0 0 0 0" > System 121! 122clean: 123! rm -f *.o core \$(SYSFILES) install build $(TAG).shar 124! 125Driver.o: $(TAG).c 126! echo "Creating Driver.o from $(TAG).c" 127! \$(CC) -c \$(CFLAGS) $(TAG).c 128! mv $(TAG).o Driver.o 129! 130install: Driver.o \$(SYSFILES) 131! echo "Installing package files" 132! cp $(TAG).7 \$(MAN)7 133! chmod 644 \$(MAN)7/$(TAG).7 134! echo "I need the root password to run the following command" 135! echo \$(SU_INSTALL) 136! su root -c \$(SU_INSTALL) 137! touch install 138! 139uninstall: 140! echo \"Removing $(NAME)\" 141! echo "I need the root password to run the following command" 142! echo \$(SU_UNINSTALL) 143! su root -c \$(SU_UNINSTALL) 144! rm -f \$(MAN)7/$(TAG).7 145! rm -f install 146! 147build: install 148! echo "Rebuilding kernel" 149! echo "I need the root password to run the following command" 150! echo \$(SU_BUILD) 151! su root -c \$(CONFBIN)/idbuild 152! touch build 153! 154shar: $(TAG).shar 155! 156$(TAG).shar: Readme Makefile $(TAG).7 $(TAG).c 157! shar -vxf \$^ > $(TAG).shar 158! 159what: 160! clear 161! echo "The following options are available in this makefile\\n" 162! echo "all: This is the default. It makes the driver, the config" 163! echo " files and the user programs. Root password is not" 164! echo " required for this option\\n" 165! echo "shar: Builds the shar distribution file\\n" 166! echo "install: Installs the driver - root password required\\n" 167! echo "build: Installs and builds the driver - root password required\\n" 168! echo "uninstall: Removes the driver - root password required\\n" 169! echo "clean: Removes files built from distribution" 170! 171 172@FILE Readme 173Fill this in with your own information 174! 175$(AUTHOR) 176$(EMAIL) 177 178@FILE $(TAG).7 179.TH XXX 7 180.de I 181\\fI\$0\\fR 182.. 183.SH NAME 184$(TAG) - $(NAME) 185.SH DESCRIPTION 186Blah blah blah 187.SH FILES 188/dev/$(TAG) 189.SH SEE ALSO 190generate(3) (For no good reason) 191.SH AUTHOR 192$(AUTHOR) ($(EMAIL)) 193.SH COPYRIGHT 194In the spirit of free interchange of (hopefully) high 195quality software, this driver is released to the public 196domain and can be used for any purposes at all, including 197personal, commercial, military, blackmail, etc. 198 199@FILE $(TAG).c 200/* 201! * $(TAG).c 202! * 203! * Written by: $(AUTHOR) 204! * 205! * ======================================================== 206! * In the spirit of free interchange of { hopefully } high- 207! * quality software, this driver is released to the public 208! * domain and can be used for any purposes at all, including 209! * personal, commercial, military, blackmail, etc. 210! * 211! * Have fun, folks. 212! * ======================================================== 213! */ 214! 215\#define _KERNEL 1 216\#include <limits.h> 217\#include <sys/types.h> 218\#include <sys/param.h> 219\#include <sys/user.h> 220\#include <sys/systm.h> 221\#include <sys/sysmacros.h> 222\#include <sys/inline.h> 223\#include <sys/errno.h> 224\#include <sys/signal.h> 225\#include <sys/dir.h> 226\#include <sys/clock.h> 227\#include <sys/cmn_err.h> 228! 229\#define DEBUGx 230! 231static char buf[128]; 232 233static void end_timeout(void) 234{ 235\#ifdef DEBUG 236! printf(\"\\n$(TAG): Rise and shine\"); 237\#endif 238! 239! wakeup((caddr_t)(buf)); 240} 241! 242 243void $(TAG)init(void) 244{ 245! printf(\"$(NAME)\\n\"); 246} 247! 248 249@FOR func read write open close 250 void $(TAG)$(func)(dev_t dev) 251 { 252 \#ifdef DEBUG 253 ! printf(\"$(TAG)$(func): dev_t = %x\\n\", dev); 254 \#endif 255 } 256 ! 257@END 258 259void $(TAG)ioctl(dev_t dev, int cmd, char *cmdarg) 260{ 261\#ifdef DEBUG 262! printf(\"$(TAG)ioctl: dev_t = %x - cmd %d [%s]\\n\", dev, cmd, cmdarg); 263\#endif 264} 265