1#!/bin/sh -
2#
3# THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
4# generated from:
5#
6#	OpenBSD: etc.octeon/MAKEDEV.md,v 1.22 2021/11/11 09:47:33 claudio Exp 
7#	OpenBSD: MAKEDEV.common,v 1.120 2023/01/28 11:04:47 phessler Exp 
8#	OpenBSD: MAKEDEV.mi,v 1.83 2016/09/11 03:06:31 deraadt Exp 
9#	OpenBSD: MAKEDEV.sub,v 1.14 2005/02/07 06:14:18 david Exp 
10#
11#
12# Copyright (c) 2001-2004 Todd T. Fries <todd@OpenBSD.org>
13#
14# Permission to use, copy, modify, and distribute this software for any
15# purpose with or without fee is hereby granted, provided that the above
16# copyright notice and this permission notice appear in all copies.
17#
18# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
19# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
20# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
21# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
22# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
23# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
24# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25#
26# Device "make" file.  Valid arguments:
27#	all	makes all known devices, including local devices.
28#		Tries to make the ``standard'' number of each type.
29#	ramdisk	Ramdisk kernel devices
30#	std	Standard devices
31#	local	Configuration specific devices
32# Disks:
33#	cd*	ATAPI and SCSI CD-ROM drives
34#	rd*	"rd" pseudo-disks
35#	sd*	SCSI disks, including flopticals
36#	vnd*	"file" pseudo-disk devices
37#	wd*	"winchester" disk drives (ST506, IDE, ESDI, RLL, ...)
38#	octcf*	octeon compact flash
39# Tapes:
40#	ch*	SCSI media changers
41#	st*	SCSI tape drives
42# Terminal ports:
43#	tty[0-7][0-9a-f]	NS16x50 serial ports
44# Pseudo terminals:
45#	ptm	pty master device
46#	pty*	Set of 62 master pseudo terminals
47#	tty*	Set of 62 slave pseudo terminals
48# Console ports:
49#	ttyC-J*	wscons display devices
50#	wscons	Minimal wscons devices
51#	wskbd*	wscons keyboards
52#	wsmux	wscons keyboard/mouse mux devices
53# Pointing devices:
54#	wsmouse*	wscons mice
55# USB devices:
56#	ttyU*	USB serial ports
57#	uall	All USB devices
58#	usb*	Bus control devices used by usbd for attach/detach
59#	uhid*	Generic HID devices
60#	fido	fido/* nodes
61#	ujoy	ujoy/* nodes
62# Special purpose devices:
63#	audio*	Audio devices
64#	bio	ioctl tunnel pseudo-device
65#	bpf	Berkeley Packet Filter
66#	dt	Dynamic Tracer
67#	diskmap	Disk mapper
68#	fd	fd/* nodes
69#	fuse	Userland Filesystem
70#	hotplug	devices hot plugging
71#	pci*	PCI bus devices
72#	pf	Packet Filter
73#	pppx*	PPP Multiplexer
74#	pppac*	PPP Access Concentrator
75#	*random	In-kernel random data source
76#	tun*	Network tunnel driver
77#	tap*	Ethernet tunnel driver
78#	uk*	Unknown SCSI devices
79#	video*	Video V4L2 devices
80#	vscsi*	Virtual SCSI controller
81#	kstat	Kernel Statistics
82PATH=/sbin:/usr/sbin:/bin:/usr/bin
83T=$0
84
85# set this to echo for Echo-Only debugging
86[ "$eo" ] || eo=
87
88hex()
89{
90	case $1 in
91	[0-9]) echo -n $1;;
92	10) echo -n a;;
93	11) echo -n b;;
94	12) echo -n c;;
95	13) echo -n d;;
96	14) echo -n e;;
97	15) echo -n f;;
98	esac
99}
100
101alph2d()
102{
103	local t="$1"
104	local p="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
105	local sub=${p%${t}*}
106	echo ${#sub}
107}
108
109h2d()
110{
111	local s="$1"
112	local f=${s%*[0-9a-f]} n=${s#[0-9a-f]*}
113
114	echo $(($(_h2d $f)*16+ $(_h2d $n) ))
115}
116
117_h2d()
118{
119	case $1 in
120	[0-9]) echo -n $1;;
121	a) echo -n 10;;
122	b) echo -n 11;;
123	c) echo -n 12;;
124	d) echo -n 13;;
125	e) echo -n 14;;
126	f) echo -n 15;;
127	esac
128}
129
130unt()
131{
132	# XXX pdksh can't seem to deal with locally scoped variables
133	# in ${foo#$bar} expansions
134	arg="$1"
135	tmp="${arg#[a-zA-Z]*}"
136	tmp="${tmp%*[a-zA-Z]}"
137	while [ "$tmp" != "$arg" ]
138	do
139		arg=$tmp
140		tmp="${arg#[a-zA-Z]*}"
141		tmp="${tmp%*[a-zA-Z]}"
142	done
143	echo $arg
144}
145
146dodisk()
147{
148	[ "$DEBUG" ] && set -x
149	n=$(($((${5}*${7:-16}))+${6})) count=0
150	[ 0$7 -ne 8 ] && l="i j k l m n o p"
151	for d in a b c d e f g h $l
152	do
153		M $1$2$d	b $3 $(($n+$count)) 640 operator
154		M r$1$2$d	c $4 $(($n+$count)) 640 operator
155		let count=count+1
156	done
157}
158
159dodisk2()
160{
161	n=$(($(($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=$(($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() {
173	: ${mklist[0]:=";mknod"}
174	mklist[${#mklist[*]}]=" -m $1 $2 $3 $4 $5"
175}
176
177M() {
178	RMlist[${#RMlist[*]}]=$1
179	mkl ${5-666} $1 $2 $3 $4
180	G=${6:-wheel}
181	[ "$7" ] && {
182		MKlist[${#MKlist[*]}]="&& chown $7:$G $1"
183	} || {
184		case $G in
185		wheel)
186			[ ${#whlist[*]} = 0 ] && whlist[0]="&& chgrp wheel"
187			whlist[${#whlist[*]}]="$1"
188		;;
189		operator)
190			[ ${#oplist[*]} = 0 ] && oplist[0]="&& chgrp operator"
191			oplist[${#oplist[*]}]="$1"
192		;;
193		*)
194			MKlist[${#MKlist[*]}]="&& chgrp $G $1";
195		esac
196	}
197	return 0
198}
199
200R() {
201[ "$DEBUG" ] && set -x
202for i in "$@"
203do
204U=`unt $i`
205[ "$U" ] || U=0
206
207case $i in
208boot)
209	R ramdisk random
210	M octboot	c 21 0 600
211	;;
212std)
213	M console	c 0 0 600
214	M tty		c 2 0
215	M mem		c 3 0 640 kmem
216	M kmem		c 3 1 640 kmem
217	M null		c 3 2
218	M zero		c 3 12
219	M stdin		c 7 0
220	M stdout	c 7 1
221	M stderr	c 7 2
222	M ksyms		c 35 0 640 kmem
223	M klog		c 6 0 600
224	M openprom	c 20 0 600
225	;;
226
227kstat)
228	M kstat c 51 0 640
229	;;
230
231vscsi*)
232	M vscsi$U c 69 $U 600
233	;;
234
235video*)
236	M video$U  c 45 $U 600
237	MKlist[${#MKlist[*]}]=";[ -e video ] || ln -s video$U video"
238	;;
239
240uk*)
241	M uk$U c 32 $U 640 operator
242	;;
243
244tap*)
245	M tap$U c 74 $U 600
246	;;
247
248tun*)
249	M tun$U c 13 $U 600
250	;;
251
252*random)
253	M urandom c 33 0 644
254	RMlist[${#RMlist[*]}]=random
255	MKlist[${#MKlist[*]}]=";ln -s urandom random"
256	;;
257
258pppac*)
259	M pppac$U c 77 $U 600
260	;;
261
262pppx*)
263	M pppx$U c 71 $U 600
264	;;
265
266pf)
267	M pf c 31 0 600
268	;;
269
270pci*)
271	M pci$U	c 29 $U 600
272	MKlist[${#MKlist[*]}]=";[ -h pci ] || ln -sf pci0 pci"
273	;;
274
275hotplug)
276	M hotplug c 67 $U 400
277	;;
278
279fuse)
280	M fuse$U c 53 $U 600
281	;;
282
283fd)
284	RMlist[${#RMlist[*]}]=";mkdir -p fd;rm -f" n=0
285	while [ $n -lt 64 ];do M fd/$n c 7 $n;n=$(($n+1));done
286	MKlist[${#MKlist[*]}]=";chmod 555 fd"
287	;;
288
289diskmap)
290	M diskmap c 70 0 640 operator
291	;;
292
293dt)
294	M dt c 30 0 600
295	;;
296
297bpf)
298	M bpf c 12 0 600
299	M bpf0 c 12 0 600
300	;;
301
302bio)
303	M bio c 49 0 600
304	;;
305
306audio*)
307	M audio$U	c 44 $U 660 _sndiop
308	M audioctl$U	c 44 $(($U+192)) 660 _sndiop
309	;;
310
311ujoy)
312	RMlist[${#RMlist[*]}]=";mkdir -p ujoy;rm -f" n=0
313	while [ $n -lt 4 ];do M ujoy/$n c 78 $n 444;n=$(($n+1));done
314	MKlist[${#MKlist[*]}]=";chmod 555 ujoy"
315	;;
316
317fido)
318	RMlist[${#RMlist[*]}]=";mkdir -p fido;rm -f" n=0
319	while [ $n -lt 4 ];do M fido/$n c 76 $n 666;n=$(($n+1));done
320	MKlist[${#MKlist[*]}]=";chmod 555 fido"
321	;;
322
323uhid*)
324	M uhid$U c 62 $U 600
325	;;
326
327usb*)
328	[ "$i" = "usb" ] && u= || u=$U
329	M usb$u c 61 $U 640
330	;;
331
332uall)
333	R ttyU0 ttyU1 ttyU2 ttyU3 ujoy fido uhid0 uhid1 uhid2 uhid3
334	R uhid4 uhid5 uhid6 uhid7 usb0 usb1 usb2 usb3 usb4 usb5 usb6
335	R usb7
336	;;
337
338ttyU[0-9a-zA-Z])
339	U=${i#ttyU*}
340	o=$(alph2d $U)
341	M ttyU$U c 66 $o 660 dialer root
342	M cuaU$U c 66 $(($o+128)) 660 dialer root
343	;;
344
345wsmouse[0-9]*)
346	M wsmouse$U c 27 $U 600
347	;;
348
349wsmux|wsmouse|wskbd)
350	M wsmouse c 28 0 600
351	M wskbd c 28 1 600
352	;;
353
354wskbd[0-9]*)
355	M wskbd$U c 26 $U 600
356	;;
357
358wscons)
359	R wsmouse0 wsmouse1 wsmouse2 wsmouse3 wsmouse4 wsmouse5
360	R wsmouse6 wsmouse7 wsmouse8 wsmouse9 wskbd0 wskbd1 wskbd2
361	R wskbd3 wskbd4 wskbd5 wskbd6 wskbd7 wskbd8 wskbd9 wsmux
362	R ttyCcfg ttyC0 ttyC1 ttyC2 ttyC3 ttyC4 ttyC5 ttyC6 ttyC7
363	R ttyC8 ttyC9 ttyCa ttyCb
364	;;
365
366tty[C-J]*)
367	U=${i##tty[C-J]}
368	case $i in
369	ttyC*) n=C m=0;;
370	ttyD*) n=D m=256;;
371	ttyE*) n=E m=512;;
372	ttyF*) n=F m=768;;
373	ttyG*) n=G m=1024;;
374	ttyH*) n=H m=1280;;
375	ttyI*) n=I m=1536;;
376	ttyJ*) n=J m=1792;;
377	esac
378	case $U in
379	[0-9a-f]) M tty$n$U c 25 $((16#$U+$m)) 600;;
380	cfg) M tty${n}cfg c 25 $((255+$m)) 600;;
381	*) echo bad unit $U for $i; exit 1;;
382	esac
383	;;
384
385pty*)
386	if [ $U -gt 15 ]; then
387		echo bad unit for pty in: $i
388		continue
389	fi
390	set -A letters p q r s t u v w x y z P Q R S T
391	set -A suffixes 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q \
392	    r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X \
393	    Y Z
394
395	name=${letters[$U]}
396	n=0
397	while [ $n -lt 62 ]
398	do
399		nam=$name${suffixes[$n]}
400		off=$(($U*62))
401		M tty$nam c 4 $(($off+$n))
402		M pty$nam c 5 $(($off+$n))
403		n=$(($n+1))
404	done
405	;;
406
407ptm)
408	M ptm c 52 0 666
409	;;
410
411tty[0-7][0-9a-f])
412	U=${i#tty*}
413	o=$(h2d $U)
414	M tty$U c 17 $o 660 dialer root
415	M cua$U c 17 $(($o+128)) 660 dialer root
416	;;
417
418st*)
419	n=$(($U*16))
420	for pre in " " n e en
421	do
422		M ${pre}rst$U	c 10 $n 660 operator
423		n=$(($n+1))
424	done
425	;;
426
427ch*)
428	M ch$U c 36 $U 660 operator
429	;;
430
431vnd*)
432	dodisk vnd $U 2 11 $U 0
433	;;
434
435rd*)
436	dodisk2 rd $U 8 22 $U 0
437	;;
438
439cd*)
440	dodisk2 cd $U 3 8 $U 0
441	;;
442
443local)
444	test -s $T.local && sh $T.local
445	;;
446
447ramdisk)
448	R octcf0 diskmap bio rd0 cd0 cd1 st0 st1 wd0 wd1 wd2 wd3 wd4
449	R sd0 sd1 sd2 sd3 sd4 tty00 tty01 bpf std
450	;;
451
452all)
453	R octcf0 vnd0 vnd1 vnd2 vnd3 sd0 sd1 sd2 sd3 sd4 sd5 sd6 sd7
454	R sd8 sd9 cd0 cd1 rd0 tap0 tap1 tap2 tap3 tun0 tun1 tun2 tun3
455	R bio pty0 pty1 pty2 diskmap vscsi0 ch0 audio0 audio1 audio2
456	R audio3 kstat dt bpf fuse pppac pppx hotplug ptm local wscons
457	R pci0 pci1 pci2 pci3 uall video0 video1 uk0 random tty00
458	R tty01 tty02 tty03 tty04 tty05 tty06 tty07 tty08 tty09 tty0a
459	R tty0b pf wd0 wd1 wd2 wd3 std st0 st1 fd
460	;;
461
462octcf*|wd*|sd*)
463	case $i in
464	octcf*) dodisk octcf $U 15 15 $U 0;;
465	wd*) dodisk wd $U 4 18 $U 0;;
466	sd*) dodisk sd $U 0 9 $U 0;;
467	esac
468	;;
469
470*)
471	echo $i: unknown device
472	;;
473esac
474done
475}
476R "$@"
477{
478echo -n ${RMlist[*]}
479echo -n ${mklist[*]}
480echo -n ${MKlist[*]}
481echo -n ${whlist[*]}
482echo ${oplist[*]}
483} | if [ "$eo" = "echo" ]; then
484	cat
485else
486	sh
487fi
488