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