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