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