xref: /openbsd/etc/etc.alpha/MAKEDEV (revision e5dd7070)
1#!/bin/sh -
2#
3# THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
4# generated from:
5#
6#	OpenBSD: etc.alpha/MAKEDEV.md,v 1.76 2020/07/06 06:11:26 dlg Exp
7#	OpenBSD: MAKEDEV.common,v 1.111 2020/07/06 06:11:26 dlg 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#	fd*	Floppy disk drives (3 1/2", 5 1/4")
35#	rd*	"rd" pseudo-disks
36#	sd*	SCSI disks, including flopticals
37#	vnd*	"file" pseudo-disk devices
38#	wd*	"winchester" disk drives (ST506, IDE, ESDI, RLL, ...)
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#	ttyc*	Cyclades serial ports
45#	ttyB*	DEC 3000 serial ports
46# Pseudo terminals:
47#	ptm	pty master device
48#	pty*	Set of 62 master pseudo terminals
49#	tty*	Set of 62 slave pseudo terminals
50# Console ports:
51#	ttyC-J*	wscons display devices
52#	wscons	Minimal wscons devices
53#	wskbd*	wscons keyboards
54#	wsmux	wscons keyboard/mouse mux devices
55# Pointing devices:
56#	wsmouse*	wscons mice
57# Printers:
58#	lpa*	Polled printer port
59#	lpt*	IEEE 1284 centronics printer
60# USB devices:
61#	ttyU*	USB serial ports
62#	uall	All USB devices
63#	ugen*	Generic USB devices
64#	uhid*	Generic HID devices
65#	fido	fido/* nodes
66#	ulpt*	Printer devices
67#	usb*	Bus control devices used by usbd for attach/detach
68# Special purpose devices:
69#	audio*	Audio devices
70#	bio	ioctl tunnel pseudo-device
71#	bktr*	Video frame grabbers
72#	bpf	Berkeley Packet Filter
73#	diskmap	Disk mapper
74#	dt	Dynamic Tracer
75#	fd	fd/* nodes
76#	fuse	Userland Filesystem
77#	hotplug	devices hot plugging
78#	pci*	PCI bus devices
79#	pf*	Packet Filter
80#	pppx*	PPP Multiplexer
81#	pppac*	PPP Access Concentrator
82#	radio*	FM tuner devices
83#	*random	In-kernel random data source
84#	rmidi*	Raw MIDI devices
85#	speaker	PC speaker
86#	tun*	Network tunnel driver
87#	tap*	Ethernet tunnel driver
88#	tuner*	Tuner devices
89#	uk*	Unknown SCSI devices
90#	video*	Video V4L2 devices
91#	vscsi*	Virtual SCSI controller
92#	switch*	Switch driver
93#	kstat	Kernel Statistics
94PATH=/sbin:/usr/sbin:/bin:/usr/bin
95T=$0
96
97# set this to echo for Echo-Only debugging
98[ "$eo" ] || eo=
99
100hex()
101{
102	case $1 in
103	[0-9]) echo -n $1;;
104	10) echo -n a;;
105	11) echo -n b;;
106	12) echo -n c;;
107	13) echo -n d;;
108	14) echo -n e;;
109	15) echo -n f;;
110	esac
111}
112
113alph2d()
114{
115	local t="$1"
116	local p="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
117	local sub=${p%${t}*}
118	echo ${#sub}
119}
120
121h2d()
122{
123	local s="$1"
124	local f=${s%*[0-9a-f]} n=${s#[0-9a-f]*}
125
126	echo $(($(_h2d $f)*16+ $(_h2d $n) ))
127}
128
129_h2d()
130{
131	case $1 in
132	[0-9]) echo -n $1;;
133	a) echo -n 10;;
134	b) echo -n 11;;
135	c) echo -n 12;;
136	d) echo -n 13;;
137	e) echo -n 14;;
138	f) echo -n 15;;
139	esac
140}
141
142unt()
143{
144	# XXX pdksh can't seem to deal with locally scoped variables
145	# in ${foo#$bar} expansions
146	arg="$1"
147	tmp="${arg#[a-zA-Z]*}"
148	tmp="${tmp%*[a-zA-Z]}"
149	while [ "$tmp" != "$arg" ]
150	do
151		arg=$tmp
152		tmp="${arg#[a-zA-Z]*}"
153		tmp="${tmp%*[a-zA-Z]}"
154	done
155	echo $arg
156}
157
158dodisk()
159{
160	[ "$DEBUG" ] && set -x
161	n=$(($((${5}*${7:-16}))+${6})) count=0
162	[ 0$7 -ne 8 ] && l="i j k l m n o p"
163	for d in a b c d e f g h $l
164	do
165		M $1$2$d	b $3 $(($n+$count)) 640 operator
166		M r$1$2$d	c $4 $(($n+$count)) 640 operator
167		let count=count+1
168	done
169}
170
171dodisk2()
172{
173	n=$(($(($5*${7:-16}))+$6))
174	M $1$2a b $3 $n 640 operator
175	M r$1$2a c $4 $n 640 operator
176	n=$(($n+2))
177	M $1$2c b $3 $n 640 operator
178	M r$1$2c c $4 $n 640 operator
179}
180
181# M name b/c major minor [mode] [group]
182RMlist[0]="rm -f"
183
184mkl() {
185	: ${mklist[0]:=";mknod"}
186	mklist[${#mklist[*]}]=" -m $1 $2 $3 $4 $5"
187}
188
189M() {
190	RMlist[${#RMlist[*]}]=$1
191	mkl ${5-666} $1 $2 $3 $4
192	G=${6:-wheel}
193	[ "$7" ] && {
194		MKlist[${#MKlist[*]}]="&& chown $7:$G $1"
195	} || {
196		case $G in
197		wheel)
198			[ ${#whlist[*]} = 0 ] && whlist[0]="&& chgrp wheel"
199			whlist[${#whlist[*]}]="$1"
200		;;
201		operator)
202			[ ${#oplist[*]} = 0 ] && oplist[0]="&& chgrp operator"
203			oplist[${#oplist[*]}]="$1"
204		;;
205		*)
206			MKlist[${#MKlist[*]}]="&& chgrp $G $1";
207		esac
208	}
209	return 0
210}
211
212R() {
213[ "$DEBUG" ] && set -x
214for i in "$@"
215do
216U=`unt $i`
217[ "$U" ] || U=0
218
219case $i in
220ramdisk)
221	R std fd0 wd0 wd1 wd2 sd0 sd1 sd2 bpf
222	R st0 cd0 ttyC0 rd0 bio diskmap random
223	;;
224
225std)
226	M console	c 0 0 600
227	M tty		c 1 0
228	M mem		c 2 0 640 kmem
229	M kmem		c 2 1 640 kmem
230	M null		c 2 2
231	M zero		c 2 12
232	M stdin		c 10 0
233	M stdout	c 10 1
234	M stderr	c 10 2
235	M ksyms		c 39 0 640 kmem
236	M klog		c 6 0 600
237	M xf86		c 2 4 600
238	;;
239
240ttyB*|ttyc*)
241	U=${i##tty?}
242	case $i in
243	ttyB*)	type=B major=15 minor=$U;;
244	ttyc*)	type=c major=38 minor=$U;;
245	esac
246	M tty$type$U c $major $minor 660 dialer root
247	M cua$type$U c $major $(($minor+128)) 660 dialer root
248	;;
249
250kstat)
251	M kstat c 51 0 640
252	;;
253
254switch*)
255	M switch$U c 69 $U 600
256	;;
257
258vscsi*)
259	M vscsi$U c 61 $U 600
260	;;
261
262video*)
263	M video$U  c 44 $U 600
264	MKlist[${#MKlist[*]}]=";[ -e video ] || ln -s video$U video"
265	;;
266
267uk*)
268	M uk$U c 33 $U 640 operator
269	;;
270
271tuner*)
272	M tuner$U c 58 $(($(($U*2))+16)) 644
273	;;
274
275tap*)
276	M tap$U c 68 $U 600
277	;;
278
279tun*)
280	M tun$U c 7 $U 600
281	;;
282
283speaker)
284	M speaker c 40 0 600
285	;;
286
287rmidi*)
288	M rmidi$U c 41 $U 660 _sndiop
289	;;
290
291*random)
292	M urandom c 34 0 644
293	RMlist[${#RMlist[*]}]=random
294	MKlist[${#MKlist[*]}]=";ln -s urandom random"
295	;;
296
297radio*)
298	M radio$U	c 59 $U
299	MKlist[${#MKlist[*]}]=";[ -e radio ] || ln -s radio$U radio"
300	;;
301
302pppac*)
303	M pppac$U c 71 $U 600
304	;;
305
306pppx*)
307	M pppx$U c 64 $U 600
308	;;
309
310pf*)
311	M pf c 35 0 600
312	;;
313
314pci*)
315	M pci$U	c 52 $U 600
316	MKlist[${#MKlist[*]}]=";[ -h pci ] || ln -sf pci0 pci"
317	;;
318
319hotplug)
320	M hotplug c 56 $U 400
321	;;
322
323fuse)
324	M fuse$U c 67 $U 600
325	;;
326
327fd)
328	RMlist[${#RMlist[*]}]=";mkdir -p fd;rm -f" n=0
329	while [ $n -lt 64 ];do M fd/$n c 10 $n;n=$(($n+1));done
330	MKlist[${#MKlist[*]}]=";chmod 555 fd"
331	;;
332
333dt)
334	M dt c 32 0 600
335	;;
336
337diskmap)
338	M diskmap c 63 0 640 operator
339	;;
340
341bpf)
342	M bpf c 11 0 600
343	M bpf0 c 11 0 600
344	;;
345
346bktr*)
347	M bktr$U c 58 $U 644
348	;;
349
350bio)
351	M bio c 53 0 600
352	;;
353
354audio*)
355	M audio$U	c 24 $U 660 _sndiop
356	M audioctl$U	c 24 $(($U+192)) 660 _sndiop
357	;;
358
359usb*)
360	[ "$i" = "usb" ] && u= || u=$U
361	M usb$u c 45 $U 640
362	;;
363
364ulpt*)
365	M ulpt$U c 47 $U 600
366	;;
367
368fido)
369	RMlist[${#RMlist[*]}]=";mkdir -p fido;rm -f" n=0
370	while [ $n -lt 4 ];do M fido/$n c 70 $n 666;n=$(($n+1));done
371	MKlist[${#MKlist[*]}]=";chmod 555 fido"
372	;;
373
374uhid*)
375	M uhid$U c 46 $U 600
376	;;
377
378ugen*)
379	n=$(($U*16))
380	for j in 0{0,1,2,3,4,5,6,7,8,9} 1{0,1,2,3,4,5}
381	do
382		M ugen$U.$j c 48 $(($n+10#$j)) 600
383	done
384	;;
385
386uall)
387	R ttyU0 ttyU1 ttyU2 ttyU3 ugen0 ugen1 ugen2 ugen3 ugen4 ugen5
388	R ugen6 ugen7 ulpt0 ulpt1 fido uhid0 uhid1 uhid2 uhid3 uhid4
389	R uhid5 uhid6 uhid7 usb0 usb1 usb2 usb3 usb4 usb5 usb6 usb7
390	;;
391
392ttyU[0-9a-zA-Z])
393	U=${i#ttyU*}
394	o=$(alph2d $U)
395	M ttyU$U c 49 $o 660 dialer root
396	M cuaU$U c 49 $(($o+128)) 660 dialer root
397	;;
398
399lpt*|lpa*)
400	case $i in
401	lpt*) n=lpt f=0;;
402	lpa*) n=lpa f=128;;
403	esac
404	M $n$U c 31 $(($U+$f)) 600
405	;;
406
407wsmouse[0-9]*)
408	M wsmouse$U c 30 $U 600
409	;;
410
411wsmux|wsmouse|wskbd)
412	M wsmouse c 60 0 600
413	M wskbd c 60 1 600
414	;;
415
416wskbd[0-9]*)
417	M wskbd$U c 29 $U 600
418	;;
419
420wscons)
421	R wsmouse0 wsmouse1 wsmouse2 wsmouse3 wsmouse4 wsmouse5
422	R wsmouse6 wsmouse7 wsmouse8 wsmouse9 wskbd0 wskbd1 wskbd2
423	R wskbd3 wsmux ttyCcfg ttyC0 ttyC1 ttyC2 ttyC3 ttyC4 ttyC5
424	R ttyC6 ttyC7 ttyC8 ttyC9 ttyCa ttyCb
425	;;
426
427tty[C-J]*)
428	U=${i##tty[C-J]}
429	case $i in
430	ttyC*) n=C m=0;;
431	ttyD*) n=D m=256;;
432	ttyE*) n=E m=512;;
433	ttyF*) n=F m=768;;
434	ttyG*) n=G m=1024;;
435	ttyH*) n=H m=1280;;
436	ttyI*) n=I m=1536;;
437	ttyJ*) n=J m=1792;;
438	esac
439	case $U in
440	[0-9a-f]) M tty$n$U c 25 $((16#$U+$m)) 600;;
441	cfg) M tty${n}cfg c 25 $((255+$m)) 600;;
442	*) echo bad unit $U for $i; exit 1;;
443	esac
444	;;
445
446pty*)
447	if [ $U -gt 15 ]; then
448		echo bad unit for pty in: $i
449		continue
450	fi
451	set -A letters p q r s t u v w x y z P Q R S T
452	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 \
453	    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 \
454	    Y Z
455
456	name=${letters[$U]}
457	n=0
458	while [ $n -lt 62 ]
459	do
460		nam=$name${suffixes[$n]}
461		off=$(($U*62))
462		M tty$nam c 4 $(($off+$n))
463		M pty$nam c 5 $(($off+$n))
464		n=$(($n+1))
465	done
466	;;
467
468ptm)
469	M ptm c 55 0 666
470	;;
471
472tty[0-7][0-9a-f])
473	U=${i#tty*}
474	o=$(h2d $U)
475	M tty$U c 26 $o 660 dialer root
476	M cua$U c 26 $(($o+128)) 660 dialer root
477	;;
478
479st*)
480	n=$(($U*16))
481	for pre in " " n e en
482	do
483		M ${pre}rst$U	c 12 $n 660 operator
484		n=$(($n+1))
485	done
486	;;
487
488ch*)
489	M ch$U c 14 $U 660 operator
490	;;
491
492vnd*)
493	dodisk vnd $U 9 9 $U 0
494	;;
495
496rd*)
497	dodisk2 rd $U 6 28 $U 0
498	;;
499
500fd*)
501	typnam=$U${i#fd[01]*}
502	case $typnam in
503	0|1)	typnum=0;; # no type specified, assume A
504	*A)	typnum=0; typnam=0;;
505	*B)	typnum=1;;
506	*C)	typnum=2;;
507	*D)	typnum=3;;
508	*E)	typnum=4;;
509	*F)	typnum=5;;
510	*G)	typnum=6;;
511	*H)	typnum=7;;
512	*)	echo bad type $typnam for $i; exit 1;;
513	esac
514	case $U in
515	0|1)	blk=4; chr=37;;
516	*)	echo bad unit $U for $i; exit 1;;
517	esac
518	nam=fd${typnam}
519	n=$(($(($U*128))+$(($typnum*16))))
520	M ${nam}a	b $blk $n 640 operator
521	M ${nam}b	b $blk $(($n+1)) 640 operator
522	M ${nam}c	b $blk $(($n+2)) 640 operator
523	M ${nam}i	b $blk $(($n+8)) 640 operator
524	M r${nam}a	c $chr $n 640 operator
525	M r${nam}b	c $chr $(($n+1)) 640 operator
526	M r${nam}c	c $chr $(($n+2)) 640 operator
527	M r${nam}i	c $chr $(($n+8)) 640 operator
528	;;
529
530cd*)
531	dodisk2 cd $U 3 13 $U 0
532	;;
533
534local)
535	test -s $T.local && sh $T.local
536	;;
537
538all)
539	R switch0 switch1 switch2 switch3 vnd0 vnd1 vnd2 vnd3 sd0 sd1
540	R sd2 sd3 sd4 sd5 sd6 sd7 sd8 sd9 cd0 cd1 rd0 ttyB0 ttyB1 tap0
541	R tap1 tap2 tap3 tun0 tun1 tun2 tun3 pty0 fd1 fd1B fd1C fd1D
542	R fd1E fd1F fd1G fd1H fd0 fd0B fd0C fd0D fd0E fd0F fd0G fd0H
543	R diskmap vscsi0 ch0 bio audio0 audio1 audio2 audio3 kstat dt
544	R bpf fuse pppac pppx hotplug ptm local wscons pci0 pci1 pci2
545	R pci3 uall rmidi0 rmidi1 rmidi2 rmidi3 rmidi4 rmidi5 rmidi6
546	R rmidi7 tuner0 radio0 speaker video0 video1 uk0 random lpa0
547	R lpa1 lpa2 lpt0 lpt1 lpt2 tty00 tty01 tty02 tty03 tty04 tty05
548	R tty06 tty07 tty08 tty09 tty0a tty0b ttyc0 ttyc1 ttyc2 ttyc3
549	R ttyc4 ttyc5 ttyc6 ttyc7 pf wd0 wd1 wd2 wd3 std st0 st1 fd
550	;;
551
552wd*|sd*)
553	case $i in
554	wd*) dodisk wd $U 0 36 $U 0;;
555	sd*) dodisk sd $U 8 8 $U 0;;
556	esac
557	;;
558
559*)
560	echo $i: unknown device
561	;;
562esac
563done
564}
565R "$@"
566{
567echo -n ${RMlist[*]}
568echo -n ${mklist[*]}
569echo -n ${MKlist[*]}
570echo -n ${whlist[*]}
571echo ${oplist[*]}
572} | if [ "$eo" = "echo" ]; then
573	cat
574else
575	sh
576fi
577