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