1define(COMM,`#')dnl
2include(MAKEDEV.sub)dnl
3dnl
4vers(a, {-$OpenBSD: MAKEDEV.mi,v 1.83 2016/09/11 03:06:31 deraadt Exp $-})dnl
5dnl
6divert(1)dnl
7{-#-}
8{-#-} Copyright (c) 2001-2004 Todd T. Fries <todd@OpenBSD.org>
9{-#-}
10{-#-} Permission to use, copy, modify, and distribute this software for any
11{-#-} purpose with or without fee is hereby granted, provided that the above
12{-#-} copyright notice and this permission notice appear in all copies.
13{-#-}
14{-#-} THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15{-#-} WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16{-#-} MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17{-#-} ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18{-#-} WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19{-#-} ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20{-#-} OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21{-#-}
22define(quote,{-"$1" -})dnl
23include(MAKEDEV.common)dnl
24dnl
25__devtitle(make, {-Device "make" file.  Valid arguments-})dnl
26__devitem({-all-}, {-all-}, {-makes all known devices{-,-} including local devices.
27{-#-}		Tries to make the ``standard'' number of each type.-})dnl
28__devitem(std,{-std-},Standard devices)dnl
29__devitem(local,local,Configuration specific devices)dnl
30dnl
31dnl _std
32dnl
33dnl $1: tty
34dnl $2: memstuff
35dnl $3: ksyms
36dnl $4: klog
37dnl
38define({-_std-},{-dnl
39std)
40	M console	c 0 0 600
41	M tty		c $1 0
42	M mem		c $2 0 640 kmem
43	M kmem		c $2 1 640 kmem
44	M null		c $2 2
45	M zero		c $2 12
46	M stdin		c major_fdesc_c 0
47	M stdout	c major_fdesc_c 1
48	M stderr	c major_fdesc_c 2
49	M ksyms		c $3 0 640 kmem
50	M klog		c $4 0 600-})dnl
51dnl
52divert(1)dnl
53define(__mddivert,7)dnl
54include(MAKEDEV.md)dnl
55dnl
56dnl
57divert(0)dnl
58#!/bin/sh -
59#
60# THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
61# generated from:
62#
63show_vers()dnl <-- now that all files are included, show versions
64#
65dnl
66divert(2)dnl
67PATH=/sbin:/usr/sbin:/bin:/usr/bin
68T=$0
69
70# set this to echo for Echo-Only debugging
71[ "$eo" ] || eo=
72
73hex()
74{
75	case ${--}1 in
76	[0-9]) echo -n {-$-}1;;
77	10) echo -n a;;
78	11) echo -n b;;
79	12) echo -n c;;
80	13) echo -n d;;
81	14) echo -n e;;
82	15) echo -n f;;
83	esac
84}
85
86alph2d()
87{
88	local t="$1"
89	local p="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
90	local sub=${p%${t}*}
91	echo ${#sub}
92}
93
94h2d()
95{
96	local s="$1"
97	local f=${s%*[0-9a-f]} n=${s#[0-9a-f]*}
98
99	echo $(($(_h2d $f)*16+ $(_h2d $n) ))
100}
101
102_h2d()
103{
104	case $1 in
105	[0-9]) echo -n $1;;
106	a) echo -n 10;;
107	b) echo -n 11;;
108	c) echo -n 12;;
109	d) echo -n 13;;
110	e) echo -n 14;;
111	f) echo -n 15;;
112	esac
113}
114
115unt()
116{
117	# XXX pdksh can't seem to deal with locally scoped variables
118	# in ${foo#$bar} expansions
119	arg="{-$-}1"
120	tmp="${arg#[a-zA-Z]*}"
121	tmp="${tmp%*[a-zA-Z]}"
122	while [ "$tmp" != "$arg" ]
123	do
124		arg=$tmp
125		tmp="${arg#[a-zA-Z]*}"
126		tmp="${tmp%*[a-zA-Z]}"
127	done
128	echo $arg
129}
130dnl
131dnl dodisk(name, unit, blkmaj, chrmaj, unit, off[, stepping])
132dnl   arg: 1    2    3      4      5    6    7
133dnl
134
135dodisk()
136{
137	[ "$DEBUG" ] && set -x
138	n=Add(Mult(${5}, ${7:-16}), ${6}) count=0
139	[ 0$7 -ne 8 ] && l="i j k l m n o p"
140	for d in a b c d e f g h $l
141	do
142		M {-$-}1{-$-}2$d	b {-$-}3 Add($n, $count) 640 operator
143		M r{-$-}1{-$-}2$d	c {-$-}4 Add($n, $count) 640 operator
144		let count=count+1
145	done
146}
147dnl
148dnl dodisk2(name, unit, blkmaj, chrmaj, unit, off[, stepping])
149dnl
150dnl 1. name    - prefix name of the device
151dnl 2. unit    - beginning unit number for block devices
152dnl 3. blkmaj  - block device major number
153dnl 4. chrmaj  - character device major number
154dnl 5. unit    - beginning unit number for character devices
155dnl 6. off     - offset from 0 for all minor numbers
156dnl 7. step    - optional, defaults to 16, number of partitions per device
157dnl
158
159dodisk2()
160{
161	n=Add(Mult({-$-}5, ${7:-16}), {-$-}6)
162	M {-$-}1{-$-}2a b {-$-}3 $n 640 operator
163	M r{-$-}1{-$-}2a c {-$-}4 $n 640 operator
164	n=Add($n, 2)
165	M {-$-}1{-$-}2c b {-$-}3 $n 640 operator
166	M r{-$-}1{-$-}2c c {-$-}4 $n 640 operator
167}
168
169# M name b/c major minor [mode] [group]
170RMlist[0]="rm -f"
171
172mkl() {
173dnl
174dnl multi mknod
175dnl
176	: {-$-}{mklist[0]:=";mknod"}
177	mklist[{-$-}{#mklist[*]}]=" -m {-$-}1 {-$-}2 {-$-}3 {-$-}4 {-$-}5"
178}
179
180M() {
181	RMlist[{-$-}{#RMlist[*]}]={-$-}1
182	mkl ${5-666} {-$-}1 {-$-}2 {-$-}3 {-$-}4
183	G={-$-}{6:-wheel}
184	[ "{-$-}7" ] && {
185		MKlist[{-$-}{#MKlist[*]}]="&& chown {-$-}7:{-$-}G {-$-}1"
186	} || {
187		case $G in
188		wheel)
189			[ {-$-}{#whlist[*]} = 0 ] && whlist[0]="&& chgrp wheel"
190			whlist[{-$-}{#whlist[*]}]="$1"
191		;;
192		operator)
193			[ {-$-}{#oplist[*]} = 0 ] && oplist[0]="&& chgrp operator"
194			oplist[{-$-}{#oplist[*]}]="$1"
195		;;
196		*)
197			MKlist[{-$-}{#MKlist[*]}]="&& chgrp $G $1";
198		esac
199	}
200	return 0
201}
202divert(7)dnl
203dnl
204dnl there is no blank line at the end of etc.arch/MAKEDEV.md files, so add one
205dnl on the following line:
206
207show_devs()dnl
208dnl
209divert(9)dnl
210*)
211	echo $i: unknown device
212	;;
213esac
214done
215}
216_recurse "$@"
217{
218echo -n ${RMlist[*]}
219echo -n ${mklist[*]}
220echo -n ${MKlist[*]}
221echo -n ${whlist[*]}
222echo ${oplist[*]}
223} | if [ "$eo" = "echo" ]; then
224	cat
225else
226	sh
227fi
228divert(3)dnl
229dnl
230
231R() {
232[ "$DEBUG" ] && set -x
233for i in "$@"
234do
235U=`unt $i`
236[ "$U" ] || U=0
237
238case $i in
239dnl
240