xref: /openbsd/etc/etc.macppc/MAKEDEV (revision 7b36286a)
1#!/bin/sh -
2#
3# THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
4# generated from:
5#
6#	OpenBSD: etc.macppc/MAKEDEV.md,v 1.36 2008/06/28 21:46:05 mglocker Exp
7#	OpenBSD: MAKEDEV.common,v 1.38 2008/06/12 22:38:14 todd Exp
8#	OpenBSD: MAKEDEV.mi,v 1.78 2008/06/14 23:09:05 todd 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#	ccd*	Concatenated disk devices
34#	cd*	ATAPI and SCSI CD-ROM drives
35#	raid*	RAIDframe disk devices
36#	rd*	"rd" pseudo-disks
37#	sd*	SCSI disks, including flopticals
38#	vnd*	"file" pseudo-disk devices
39#	wd*	"winchester" disk drives (ST506, IDE, ESDI, RLL, ...)
40# Tapes:
41#	ch*	SCSI media changers
42#	st*	SCSI tape drives
43# Terminal ports:
44#	tty[0-7][0-9a-f]	NS16x50 serial ports
45#	cua[a-z]*	Zilog 8530 serial ports
46#	tty[a-z]*	Zilog 8530 serial ports
47# Pseudo terminals:
48#	ptm	pty master device
49#	pty*	Set of 62 master pseudo terminals
50#	tty*	Set of 62 slave pseudo terminals
51# Console ports:
52#	wscons	Minimal wscons devices
53#	ttyC-J*	wscons display devices
54#	wskbd*	wscons keyboards
55#	wsmux	wscons keyboard/mouse mux devices
56# Pointing devices:
57#	wsmouse*	wscons mice
58# USB devices:
59#	uall	All USB devices
60#	ttyU*	USB serial ports
61#	ugen*	Generic USB devices
62#	uhid*	Generic HID devices
63#	ulpt*	Printer devices
64#	urio*	Diamond Multimedia Rio 500
65#	usb*	Bus control devices used by usbd for attach/detach
66#	uscanner*	Scanners
67# Special purpose devices:
68#	apm	Power management device
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#	fd	fd/* nodes
76#	hotplug	devices hot plugging
77#	gpio*	General Purpose Input/Output
78#	iop*	I2O controller devices
79#	lkm	Loadable kernel modules interface
80#	pci*	PCI bus devices
81#	pf*	Packet Filter
82#	radio*	FM tuner devices
83#	*random	In-kernel random data source
84#	ss*	SCSI scanners
85#	systrace*	System call tracing device
86#	tun*	Network tunnel driver
87#	tuner*	Tuner devices
88#	uk*	Unknown SCSI devices
89#	video*	Video V4L devices
90#	xfs*	XFS filesystem node
91PATH=/sbin:/usr/sbin:/bin:/usr/bin
92T=$0
93
94# set this to echo for Echo-Only debugging
95[ "$eo" ] || eo=
96
97hex()
98{
99	case $1 in
100	[0-9]) echo -n $1;;
101	10) echo -n a;;
102	11) echo -n b;;
103	12) echo -n c;;
104	13) echo -n d;;
105	14) echo -n e;;
106	15) echo -n f;;
107	esac
108}
109
110alph2d()
111{
112	local t="$1"
113	local p="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
114	local sub=${p%${t}*}
115	echo ${#sub}
116}
117
118h2d()
119{
120	local s="$1"
121	local f=${s%*[0-9a-f]} n=${s#[0-9a-f]*}
122
123	echo $(($(_h2d $f)*16+ $(_h2d $n) ))
124}
125
126_h2d()
127{
128	case $1 in
129	[0-9]) echo -n $1;;
130	a) echo -n 10;;
131	b) echo -n 11;;
132	c) echo -n 12;;
133	d) echo -n 13;;
134	e) echo -n 14;;
135	f) echo -n 15;;
136	esac
137}
138
139unt()
140{
141	# XXX pdksh can't seem to deal with locally scoped variables
142	# in ${foo#$bar} expansions
143	arg="$1"
144	tmp="${arg#[a-zA-Z]*}"
145	tmp="${tmp%*[a-zA-Z]}"
146	while [ "$tmp" != "$arg" ]
147	do
148		arg=$tmp
149		tmp="${arg#[a-zA-Z]*}"
150		tmp="${tmp%*[a-zA-Z]}"
151	done
152	echo $arg
153}
154
155dodisk()
156{
157	[ "$DEBUG" ] && set -x
158	n=$(($((${5}*${7:-16}))+${6})) count=0
159	[ 0$7 -ne 8 ] && l="i j k l m n o p"
160	for d in a b c d e f g h $l
161	do
162		M $1$2$d	b $3 $(($n+$count)) 640 operator
163		M r$1$2$d	c $4 $(($n+$count)) 640 operator
164		let count=count+1
165	done
166}
167
168dodisk2()
169{
170	n=$(($(($5*${7:-16}))+$6))
171	M $1$2a b $3 $n 640 operator
172	M r$1$2a c $4 $n 640 operator
173	n=$(($n+2))
174	M $1$2c b $3 $n 640 operator
175	M r$1$2c c $4 $n 640 operator
176}
177
178# M name b/c major minor [mode] [group]
179RMlist[0]="rm -f"
180
181mkl() {
182	mklist[${#mklist[*]}]=";mknod -m $1 $2 $3 $4 $5"
183}
184
185M() {
186	RMlist[${#RMlist[*]}]=$1
187	mkl ${5-666} $1 $2 $3 $4
188	G=${6:-wheel}
189	[ "$7" ] && {
190		MKlist[${#MKlist[*]}]=";chown $7:$G $1"
191	} || {
192		case $G in
193		wheel)
194			[ ${#whlist[*]} = 0 ] && whlist[0]=";chgrp wheel"
195			whlist[${#whlist[*]}]="$1"
196		;;
197		operator)
198			[ ${#oplist[*]} = 0 ] && oplist[0]=";chgrp operator"
199			oplist[${#oplist[*]}]="$1"
200		;;
201		*)
202			MKlist[${#MKlist[*]}]=";chgrp $G $1";
203		esac
204	}
205	return 0
206}
207
208R() {
209[ "$DEBUG" ] && set -x
210for i in "$@"
211do
212U=`unt $i`
213[ "$U" ] || U=0
214
215case $i in
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 21 0
224	M stdout	c 21 1
225	M stderr	c 21 2
226	M ksyms		c 43 0 640 kmem
227	M drum		c 3 0 640 kmem
228	M klog		c 6 0 600
229	M xf86		c 2 4 600
230	M openprom	c 82 0 640 kmem
231	;;
232
233
234xfs*)
235	M xfs$U c 51 $U 600
236	;;
237
238video*)
239	M video$U  c 45 $U
240	MKlist[${#MKlist[*]}]=";[ -e video ] || ln -s video$U video"
241	;;
242
243uk*)
244	M uk$U c 41 $U 640 operator
245	;;
246
247tuner*)
248	M tuner$U c 75 $(($(($U*2))+16)) 644
249	;;
250
251tun*)
252	M tun$U c 23 $U 600
253	;;
254
255systrace)
256	M systrace c 50 0 644
257	;;
258
259ss*)
260	M ss$U c 42 $(($U*16)) 640 operator
261	M nss$U c 42 $(($(($U*16))+1)) 640 operator
262	M enss$U c 42 $(($(($U*16))+3)) 640 operator
263	RMlist[${#RMlist[*]}]="scan$U"
264	MKlist[${#MKlist[*]}]=";umask 77;ln -s ss$U scan$U"
265	;;
266
267*random)
268	n=0
269	for pre in " " s u p a
270	do
271		M ${pre}random c 40 $n 644
272		n=$(($n+1))
273	done
274	;;
275
276radio*)
277	M radio$U     c 76 $U
278	MKlist[${#MKlist[*]}]=";[ -e radio ] || ln -s radio$U radio"
279	;;
280
281pf*)
282	M pf c 39 0 600
283	;;
284
285pci*)
286	M pci$U	c 71 $U 600
287	MKlist[${#MKlist[*]}]=";[ -h pci ] || ln -sf pci0 pci"
288	;;
289
290lkm)
291	M lkm c 24 0 640 _lkm
292	;;
293
294iop*)
295	M iop$U c 73 $U 660
296	;;
297
298gpio*)
299	M gpio$U c 79 $U 600
300	;;
301
302hotplug)
303	M hotplug c 78 $U 400
304	;;
305
306fd)
307	RMlist[${#RMlist[*]}]=";mkdir -p fd;rm -f" n=0
308	while [ $n -lt 64 ];do M fd/$n c 21 $n;n=$(($n+1));done
309	MKlist[${#MKlist[*]}]=";chmod 555 fd"
310	;;
311
312crypto)
313	M crypto c 47 0
314	;;
315
316bthub*)
317	M bthub$U c 81 $U
318	;;
319
320bpf*)
321	M bpf$U c 22 $U 600
322	;;
323
324bktr*)
325	M bktr$U c 75 $U 644
326	;;
327
328bio)
329	M bio c 80 0 600
330	;;
331
332audio*)
333	M sound$U	c 44 $U
334	M mixer$U	c 44 $(($U+16))
335	M audio$U	c 44 $(($U+128))
336	M audioctl$U	c 44 $(($U+192))
337	MKlist[${#MKlist[*]}]=";[ -e audio ] || ln -s audio$U audio"
338	MKlist[${#MKlist[*]}]=";[ -e mixer ] || ln -s mixer$U mixer"
339	MKlist[${#MKlist[*]}]=";[ -e sound ] || ln -s sound$U sound"
340	MKlist[${#MKlist[*]}]=";[ -e audioctl ] || ln -s audioctl$U audioctl"
341	;;
342
343apm*)
344	M apm	c 25 0 644
345	M apmctl	c 25 8 644
346	;;
347
348uscanner*)
349	M uscanner$U c 74 $U 660
350	;;
351
352usb*)
353	[ "$i" = "usb" ] && u= || u=$U
354	M usb$u c 61 $U 660
355	;;
356
357urio*)
358	M urio$U c 65 $U 660
359	;;
360
361ulpt*)
362	M ulpt$U c 64 $U 660
363	;;
364
365uhid*)
366	M uhid$U c 62 $U 660
367	;;
368
369ugen*)
370	n=$(($U*16))
371	for j in 0{0,1,2,3,4,5,6,7,8,9} 1{0,1,2,3,4,5}
372	do
373		M ugen$U.$j c 63 $(($n+10#$j)) 660
374	done
375	;;
376
377ttyU[0-9a-zA-Z])
378	U=${i#ttyU*}
379	o=$(alph2d $U)
380	M ttyU$U c 66 $o 660 dialer uucp
381	M cuaU$U c 66 $(($o+128)) 660 dialer uucp
382	;;
383
384uall)
385	R ttyU0 ttyU1 ttyU2 ttyU3 ugen0 ugen1 ulpt0 ulpt1 uhid0 uhid1
386	R uhid2 uhid3 uscanner0 urio0 usb0 usb1 usb2 usb3 usb4 usb5
387	;;
388
389wsmouse*)
390	M wsmouse$U c 69 $U 600
391	;;
392
393wsmux|wsmouse|wskbd)
394	M wsmouse c 70 0 600
395	M wskbd c 70 1 600
396	;;
397
398wskbd*)
399	M wskbd$U c 68 $U 600
400	;;
401
402tty[C-J]*)
403	U=${i##tty[C-J]}
404	case $i in
405	ttyC*) n=C m=0;;
406	ttyD*) n=D m=256;;
407	ttyE*) n=E m=512;;
408	ttyF*) n=F m=768;;
409	ttyG*) n=G m=1024;;
410	ttyH*) n=H m=1280;;
411	ttyI*) n=I m=1536;;
412	ttyJ*) n=J m=1792;;
413	esac
414	case $U in
415	[0-9a-f]) M tty$n$U c 67 $((16#$U+$m)) 600;;
416	cfg) M tty${n}cfg c 67 $((255+$m)) 600;;
417	*) echo bad unit $U for $i; exit 1;;
418	esac
419	;;
420
421wscons)
422	R wsmouse0 wsmouse1 wsmouse2 wsmouse3 wskbd0 wskbd1 wskbd2
423	R wskbd3 wsmux ttyCcfg ttyC0 ttyC1 ttyC2 ttyC3 ttyC4 ttyC5
424	R ttyC6 ttyC7 ttyC8 ttyC9 ttyCa ttyCb
425	;;
426
427pty*)
428	if [ $U -gt 15 ]; then
429		echo bad unit for pty in: $i
430		continue
431	fi
432	set -A letters p q r s t u v w x y z P Q R S T
433	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 \
434	    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 \
435	    Y Z
436
437	name=${letters[$U]}
438	n=0
439	while [ $n -lt 62 ]
440	do
441		nam=$name${suffixes[$n]}
442		off=$(($U*62))
443		M tty$nam c 4 $(($off+$n))
444		M pty$nam c 5 $(($off+$n))
445		n=$(($n+1))
446	done
447	;;
448
449ptm)
450	M ptm c 77 0 666
451	;;
452
453tty[a-z])
454	u=${i#tty*}
455	case $u in
456	a) n=0 ;;
457	b) n=1 ;;
458	*) echo unknown tty device $i ;;
459	esac
460	M tty$u c 7 $n 660 dialer uucp
461	;;
462
463cua[a-z])
464	u=${i#cua*}
465	case $u in
466	a) n=0 ;;
467	b) n=1 ;;
468	*) echo unknown cua device $i ;;
469	esac
470	M cua$u c 7 $(($n+128)) 660 dialer uucp
471	;;
472
473tty[0-7][0-9a-f])
474	U=${i#tty*}
475	o=$(h2d $U)
476	M tty$U c 26 $o 660 dialer uucp
477	M cua$U c 26 $(($o+128)) 660 dialer uucp
478	;;
479
480st*)
481	n=$(($U*16))
482	for pre in " " n e en
483	do
484		M ${pre}st$U	b 5 $n 660 operator
485		M ${pre}rst$U	c 20 $n 660 operator
486		n=$(($n+1))
487	done
488	;;
489
490ch*)
491	M ch$U c 10 $U 660 operator
492	;;
493
494vnd*)
495	dodisk vnd $U 14 19 $U 0
496	dodisk svnd $U 14 19 $U 2048
497	;;
498
499rd*)
500	dodisk2 rd $U 17 17 $U 0
501	;;
502
503cd*)
504	dodisk2 cd $U 3 9 $U 0
505	;;
506
507local)
508	test -s $T.local && sh $T.local
509	;;
510
511ramdisk)
512	R bio pty0 rd0 cd0 cd1 st0 st1 wd0 wd1 wd2 wd3 wd4 sd0 sd1
513	R sd2 sd3 sd4 tty00 tty01 bpf0 std
514	;;
515
516all)
517	R bthub0 bthub1 bthub2 bio gpio0 gpio1 gpio2 ccd0 ccd1 ccd2
518	R ccd3 vnd0 vnd1 vnd2 vnd3 sd0 sd1 sd2 sd3 sd4 cd0 cd1 rd0
519	R tun0 tun1 tun2 tun3 bpf0 bpf1 bpf2 bpf3 bpf4 bpf5 bpf6 bpf7
520	R bpf8 bpf9 pty0 xfs0 ss0 ss1 ch0 cuaa cuab ttya ttyb hotplug
521	R ptm local wscons pci0 pci1 pci2 pci3 iop0 iop1 uall tuner0
522	R radio0 video0 audio0 uk0 random lkm tty00 tty01 tty02 tty03
523	R apm crypto pf systrace wd0 wd1 wd2 wd3 raid0 raid1 raid2
524	R raid3 std st0 st1 fd
525	;;
526
527wd*|sd*|raid*|ccd*)
528	case $i in
529	wd*) dodisk wd $U 0 11 $U 0;;
530	sd*) dodisk sd $U 2 8 $U 0;;
531	raid*) dodisk raid $U 19 54 $U 0;;
532	ccd*) dodisk ccd $U 16 18 $U 0;;
533	esac
534	;;
535
536*)
537	echo $i: unknown device
538	;;
539esac
540done
541}
542R "$@"
543{
544echo -n ${RMlist[*]}
545echo -n ${mklist[*]}
546echo -n ${MKlist[*]}
547echo -n ${whlist[*]}
548echo ${oplist[*]}
549} | if [ "$eo" = "echo" ]; then
550        cat
551else
552	sh
553fi
554