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