xref: /openbsd/etc/etc.arm64/MAKEDEV (revision 6f40fd34)
1#!/bin/sh -
2#
3# THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
4# generated from:
5#
6#	OpenBSD: etc.arm64/MAKEDEV.md,v 1.2 2017/01/23 12:43:48 kettenis Exp
7#	OpenBSD: MAKEDEV.common,v 1.94 2016/09/11 19:59:51 deraadt 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# Tapes:
39#	ch*	SCSI media changers
40# Terminal ports:
41#	tty[0-7][0-9a-f]	NS16x50 serial ports
42# Pseudo terminals:
43#	ptm	pty master device
44#	pty*	Set of 62 master pseudo terminals
45#	tty*	Set of 62 slave pseudo terminals
46# Console ports:
47#	ttyC-J*	wscons display devices
48#	wscons	Minimal wscons devices
49#	wskbd*	wscons keyboards
50#	wsmux	wscons keyboard/mouse mux devices
51# Pointing devices:
52#	wsmouse*	wscons mice
53# Printers:
54# USB devices:
55#	ttyU*	USB serial ports
56#	uall	All USB devices
57#	ugen*	Generic USB devices
58#	uhid*	Generic HID devices
59#	ulpt*	Printer devices
60#	usb*	Bus control devices used by usbd for attach/detach
61# Special purpose devices:
62#	apm	Power Management Interface
63#	audio*	Audio devices
64#	bio	ioctl tunnel pseudo-device
65#	bktr*	Video frame grabbers
66#	bpf	Berkeley Packet Filter
67#	diskmap	Disk mapper
68#	fd	fd/* nodes
69#	fuse	Userland Filesystem
70#	gpio*	General Purpose Input/Output
71#	hotplug	devices hot plugging
72#	pci*	PCI bus devices
73#	pf*	Packet Filter
74#	pppx*	PPP Multiplexer
75#	radio*	FM tuner devices
76#	*random	In-kernel random data source
77#	rmidi*	Raw MIDI devices
78#	tun*	Network tunnel driver
79#	tap*	Ethernet tunnel driver
80#	tuner*	Tuner devices
81#	uk*	Unknown SCSI devices
82#	video*	Video V4L2 devices
83#	vscsi*	Virtual SCSI controller
84#	switch*	Switch driver
85PATH=/sbin:/usr/sbin:/bin:/usr/bin
86T=$0
87
88# set this to echo for Echo-Only debugging
89[ "$eo" ] || eo=
90
91hex()
92{
93	case $1 in
94	[0-9]) echo -n $1;;
95	10) echo -n a;;
96	11) echo -n b;;
97	12) echo -n c;;
98	13) echo -n d;;
99	14) echo -n e;;
100	15) echo -n f;;
101	esac
102}
103
104alph2d()
105{
106	local t="$1"
107	local p="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
108	local sub=${p%${t}*}
109	echo ${#sub}
110}
111
112h2d()
113{
114	local s="$1"
115	local f=${s%*[0-9a-f]} n=${s#[0-9a-f]*}
116
117	echo $(($(_h2d $f)*16+ $(_h2d $n) ))
118}
119
120_h2d()
121{
122	case $1 in
123	[0-9]) echo -n $1;;
124	a) echo -n 10;;
125	b) echo -n 11;;
126	c) echo -n 12;;
127	d) echo -n 13;;
128	e) echo -n 14;;
129	f) echo -n 15;;
130	esac
131}
132
133unt()
134{
135	# XXX pdksh can't seem to deal with locally scoped variables
136	# in ${foo#$bar} expansions
137	arg="$1"
138	tmp="${arg#[a-zA-Z]*}"
139	tmp="${tmp%*[a-zA-Z]}"
140	while [ "$tmp" != "$arg" ]
141	do
142		arg=$tmp
143		tmp="${arg#[a-zA-Z]*}"
144		tmp="${tmp%*[a-zA-Z]}"
145	done
146	echo $arg
147}
148
149dodisk()
150{
151	[ "$DEBUG" ] && set -x
152	n=$(($((${5}*${7:-16}))+${6})) count=0
153	[ 0$7 -ne 8 ] && l="i j k l m n o p"
154	for d in a b c d e f g h $l
155	do
156		M $1$2$d	b $3 $(($n+$count)) 640 operator
157		M r$1$2$d	c $4 $(($n+$count)) 640 operator
158		let count=count+1
159	done
160}
161
162dodisk2()
163{
164	n=$(($(($5*${7:-16}))+$6))
165	M $1$2a b $3 $n 640 operator
166	M r$1$2a c $4 $n 640 operator
167	n=$(($n+2))
168	M $1$2c b $3 $n 640 operator
169	M r$1$2c c $4 $n 640 operator
170}
171
172# M name b/c major minor [mode] [group]
173RMlist[0]="rm -f"
174
175mkl() {
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}
202
203R() {
204[ "$DEBUG" ] && set -x
205for i in "$@"
206do
207U=`unt $i`
208[ "$U" ] || U=0
209
210case $i in
211ramdisk)
212	R std bpf wd0 sd0 tty00 tty01 rd0 bio diskmap
213	R cd0 ttyC0 wskbd0 wskbd1 wskbd2 random
214	;;
215
216std)
217	M console	c 0 0 600
218	M tty		c 1 0
219	M mem		c 2 0 640 kmem
220	M kmem		c 2 1 640 kmem
221	M null		c 2 2
222	M zero		c 2 12
223	M stdin		c 22 0
224	M stdout	c 22 1
225	M stderr	c 22 2
226	M ksyms		c 50 0 640 kmem
227	M klog		c 7 0 600
228	M openprom	c 70 0 600
229	;;
230
231
232switch*)
233	M switch$U c 97 $U 600
234	;;
235
236vscsi*)
237	M vscsi$U c 89 $U 600
238	;;
239
240video*)
241	M video$U  c 44 $U 600
242	MKlist[${#MKlist[*]}]=";[ -e video ] || ln -s video$U video"
243	;;
244
245uk*)
246	M uk$U c 20 $U 640 operator
247	;;
248
249tuner*)
250	M tuner$U c 49 $(($(($U*2))+16)) 644
251	;;
252
253tap*)
254	M tap$U c 93 $U 600
255	;;
256
257tun*)
258	M tun$U c 40 $U 600
259	;;
260
261rmidi*)
262	M rmidi$U c 52 $U 666
263	;;
264
265*random)
266	n=0
267	for pre in " " s u a
268	do
269		M ${pre}random c 45 $n 644
270		n=$(($n+1))
271	done
272	;;
273
274radio*)
275	M radio$U	c 76 $U
276	MKlist[${#MKlist[*]}]=";[ -e radio ] || ln -s radio$U radio"
277	;;
278
279pppx*)
280	M pppx$U c 91 $U 600
281	;;
282
283pf*)
284	M pf c 73 0 600
285	;;
286
287pci*)
288	M pci$U	c 72 $U 600
289	MKlist[${#MKlist[*]}]=";[ -h pci ] || ln -sf pci0 pci"
290	;;
291
292hotplug)
293	M hotplug c 82 $U 400
294	;;
295
296gpio*)
297	M gpio$U c 88 $U 600
298	;;
299
300fuse)
301	M fuse$U c 92 $U 600
302	;;
303
304fd)
305	RMlist[${#RMlist[*]}]=";mkdir -p fd;rm -f" n=0
306	while [ $n -lt 64 ];do M fd/$n c 22 $n;n=$(($n+1));done
307	MKlist[${#MKlist[*]}]=";chmod 555 fd"
308	;;
309
310diskmap)
311	M diskmap c 90 0 640 operator
312	;;
313
314bpf)
315	M bpf c 23 0 600
316	M bpf0 c 23 0 600
317	;;
318
319bktr*)
320	M bktr$U c 49 $U 644
321	;;
322
323bio)
324	M bio c 79 0 600
325	;;
326
327audio*)
328	M audio$U	c 42 $U
329	M mixer$U	c 42 $(($U+16))
330	M audioctl$U	c 42 $(($U+192))
331	MKlist[${#MKlist[*]}]=";[ -e audio ] || ln -s audio$U audio"
332	MKlist[${#MKlist[*]}]=";[ -e mixer ] || ln -s mixer$U mixer"
333	MKlist[${#MKlist[*]}]=";[ -e audioctl ] || ln -s audioctl$U audioctl"
334	;;
335
336apm*)
337	M apm	c 83 0 644
338	M apmctl	c 83 8 644
339	;;
340
341usb*)
342	[ "$i" = "usb" ] && u= || u=$U
343	M usb$u c 61 $U 660
344	;;
345
346ulpt*)
347	M ulpt$U c 64 $U 660
348	;;
349
350uhid*)
351	M uhid$U c 62 $U 660
352	;;
353
354ugen*)
355	n=$(($U*16))
356	for j in 0{0,1,2,3,4,5,6,7,8,9} 1{0,1,2,3,4,5}
357	do
358		M ugen$U.$j c 63 $(($n+10#$j)) 660
359	done
360	;;
361
362uall)
363	R ttyU0 ttyU1 ttyU2 ttyU3 ugen0 ugen1 ugen2 ugen3 ugen4 ugen5
364	R ugen6 ugen7 ulpt0 ulpt1 uhid0 uhid1 uhid2 uhid3 usb0 usb1
365	R usb2 usb3 usb4 usb5 usb6 usb7
366	;;
367
368ttyU[0-9a-zA-Z])
369	U=${i#ttyU*}
370	o=$(alph2d $U)
371	M ttyU$U c 66 $o 660 dialer root
372	M cuaU$U c 66 $(($o+128)) 660 dialer root
373	;;
374
375wsmouse[0-9]*)
376	M wsmouse$U c 68 $U 600
377	;;
378
379wsmux|wsmouse|wskbd)
380	M wsmouse c 69 0 600
381	M wskbd c 69 1 600
382	;;
383
384wskbd[0-9]*)
385	M wskbd$U c 67 $U 600
386	;;
387
388wscons)
389	R wsmouse0 wsmouse1 wsmouse2 wsmouse3 wskbd0 wskbd1 wskbd2
390	R wskbd3 wsmux ttyCcfg ttyC0 ttyC1 ttyC2 ttyC3 ttyC4 ttyC5
391	R ttyC6 ttyC7 ttyC8 ttyC9 ttyCa ttyCb
392	;;
393
394tty[C-J]*)
395	U=${i##tty[C-J]}
396	case $i in
397	ttyC*) n=C m=0;;
398	ttyD*) n=D m=256;;
399	ttyE*) n=E m=512;;
400	ttyF*) n=F m=768;;
401	ttyG*) n=G m=1024;;
402	ttyH*) n=H m=1280;;
403	ttyI*) n=I m=1536;;
404	ttyJ*) n=J m=1792;;
405	esac
406	case $U in
407	[0-9a-f]) M tty$n$U c 12 $((16#$U+$m)) 600;;
408	cfg) M tty${n}cfg c 12 $((255+$m)) 600;;
409	*) echo bad unit $U for $i; exit 1;;
410	esac
411	;;
412
413pty*)
414	if [ $U -gt 15 ]; then
415		echo bad unit for pty in: $i
416		continue
417	fi
418	set -A letters p q r s t u v w x y z P Q R S T
419	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 \
420	    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 \
421	    Y Z
422
423	name=${letters[$U]}
424	n=0
425	while [ $n -lt 62 ]
426	do
427		nam=$name${suffixes[$n]}
428		off=$(($U*62))
429		M tty$nam c 5 $(($off+$n))
430		M pty$nam c 6 $(($off+$n))
431		n=$(($n+1))
432	done
433	;;
434
435ptm)
436	M ptm c 81 0 666
437	;;
438
439tty[0-7][0-9a-f])
440	U=${i#tty*}
441	o=$(h2d $U)
442	M tty$U c 8 $o 660 dialer root
443	M cua$U c 8 $(($o+128)) 660 dialer root
444	;;
445
446ch*)
447	M ch$U c 17 $U 660 operator
448	;;
449
450vnd*)
451	dodisk vnd $U 14 41 $U 0
452	;;
453
454rd*)
455	dodisk2 rd $U 17 47 $U 0
456	;;
457
458cd*)
459	dodisk2 cd $U 6 15 $U 0
460	;;
461
462local)
463	test -s $T.local && sh $T.local
464	;;
465
466all)
467	R switch0 switch1 switch2 switch3 gpio0 gpio1 gpio2 bktr0
468	R vnd0 vnd1 vnd2 vnd3 sd0 sd1 sd2 sd3 sd4 sd5 sd6 sd7 sd8 sd9
469	R cd0 cd1 rd0 tap0 tap1 tap2 tap3 tun0 tun1 tun2 tun3 bio pty0
470	R diskmap vscsi0 ch0 audio0 audio1 audio2 bpf fuse pppx
471	R hotplug ptm local wscons pci0 pci1 pci2 pci3 uall rmidi0
472	R rmidi1 rmidi2 rmidi3 rmidi4 rmidi5 rmidi6 rmidi7 tuner0
473	R radio0 video0 video1 uk0 random tty00 tty01 tty02 tty03
474	R tty04 tty05 tty06 tty07 tty08 tty09 tty0a tty0b apm pf wd0
475	R wd1 wd2 wd3 std fd
476	;;
477
478wd*|sd*)
479	case $i in
480	wd*) dodisk wd $U 0 3 $U 0;;
481	sd*) dodisk sd $U 4 13 $U 0;;
482	esac
483	;;
484
485*)
486	echo $i: unknown device
487	;;
488esac
489done
490}
491R "$@"
492{
493echo -n ${RMlist[*]}
494echo -n ${mklist[*]}
495echo -n ${MKlist[*]}
496echo -n ${whlist[*]}
497echo ${oplist[*]}
498} | if [ "$eo" = "echo" ]; then
499	cat
500else
501	sh
502fi
503