MAKEDEV.tmpl revision 1.81
1#!/bin/sh -
2#	$NetBSD: MAKEDEV.tmpl,v 1.81 2007/03/09 19:16:47 dsl Exp $
3#
4# Copyright (c) 2003,2007 The NetBSD Foundation, Inc.
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions
9# are met:
10# 1. Redistributions of source code must retain the above copyright
11#    notice, this list of conditions and the following disclaimer.
12# 2. Redistributions in binary form must reproduce the above copyright
13#    notice, this list of conditions and the following disclaimer in the
14#    documentation and/or other materials provided with the distribution.
15# 3. All advertising materials mentioning features or use of this software
16#    must display the following acknowledgement:
17#        This product includes software developed by the NetBSD
18#        Foundation, Inc. and its contributors.
19# 4. Neither the name of The NetBSD Foundation nor the names of its
20#    contributors may be used to endorse or promote products derived
21#    from this software without specific prior written permission.
22#
23# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
24# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
27# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33# POSSIBILITY OF SUCH DAMAGE.
34#
35#
36###########################################################################
37#
38#   PLEASE RUN "cd ../share/man/man8 ; make makedevs"
39#   AFTER CHANGING THIS FILE, AND COMMIT THE UPDATED MANPAGE!
40#
41###########################################################################
42#
43# Device "make" file.  Valid special arguments:
44#	all	makes all known devices, including local devices.
45#		Tries to make the 'standard' number of each type.
46#	init	A set of devices that is used for MFS /dev by init.
47#		May be equal to "all".
48#	floppy	devices to be put on install floppies
49#	ramdisk	devices to be put into INSTALL kernel ramdisks.
50#	std	standard devices
51#	local	configuration specific devices
52#	wscons	make wscons devices
53#	usbs	make USB devices
54#	isdns	make ISDN devices
55#
56# Tapes:
57#	st*	SCSI tapes
58#	wt*	QIC-interfaced (e.g. not SCSI) 3M cartridge tape
59#	ht*	MASSBUS TM03 and TU??
60#	mt*	MSCP tapes (e.g. TU81, TK50)
61#	tm*	UNIBUS TM11 and TE10 emulations (e.g. Emulex TC-11)
62#	ts*	UNIBUS TS11
63#	ut*	UNIBUS TU45 emulations (e.g. si 9700)
64#	uu*	TU58 cassettes on DL11 controller
65#
66# Disks:
67#	ccd*	concatenated disk devices
68#	cd*	SCSI or ATAPI CD-ROM
69#	cgd*	cryptographic disk devices
70#	raid*	RAIDframe disk devices
71#	sd*	SCSI disks
72#	wd*	"winchester" disk drives (ST506,IDE,ESDI,RLL,...)
73#	bmd*	Nereid bank memory disks
74#	ed*	IBM PS/2 ESDI disk devices
75#	fd*	"floppy" disk drives (3 1/2", 5 1/4")
76#	fss*	Files system snapshot devices
77#	gdrom*	Dreamcast "gigadisc" CD-ROM drive
78#	hk*	UNIBUS RK06 and RK07
79#	hp*	MASSBUS RM??
80#	ld*	Logical disk devices (e.g., hardware RAID)
81#	mcd*	Mitsumi CD-ROM
82#	md*	memory pseudo-disk devices
83#	ofdisk*	OpenFirmware disk devices
84#	ra*	MSCP disks (RA??, RD??)
85#	rb*	730 IDC w/ RB80 and/or RB02
86#	rd*	HDC9224 RD disks on VS2000
87#	rl*	UNIBUS RL02
88#	rx*	MSCP floppy disk (RX33/50/...)
89#	up*	other UNIBUS devices (e.g. on Emulex SC-21V controller)
90#	vnd*	"file" pseudo-disks
91#	xbd*	Xen virtual disks
92#	xd*	Xylogic 753/7053 disks
93#	xy*	Xylogic 450/451 disks
94#
95# Pointing devices:
96#	wsmouse* wscons mouse events
97#	lms*	Logitech bus mouse
98#	mms*	Microsoft bus mouse
99#	qms*	"quadrature mouse"
100#	pms*	PS/2 mouse
101#	mouse	mouse (provides events, for X11)
102#
103# Keyboard devices:
104#	wskbd*	wscons keyboard events
105#	kbd	raw keyboard (provides events, for X11)
106#	kbdctl	keyboard control
107#
108# Terminals/Console ports:
109#	tty[01]*	standard serial ports
110#	tty0*	SB1250 ("sbscn") serial ports (sbmips)
111#	ttyE*	wscons - Workstation console ("wscons") glass-tty emulators
112#	ttyCZ?	Cyclades-Z multiport serial boards.  Each "unit"
113#		makes 64 ports.
114#	ttyCY?	Cyclom-Y multiport serial boards. Each "unit" makes
115#		32 ports.
116#	ttye*	ITE bitmapped consoles
117#	ttyv0	pccons
118#	ttyC?	NS16550 ("com") serial ports
119#	ttyS*	SA1110 serial port (hpcarm)
120#	ttyTX?	TX39 internal serial ports (hpcmips)
121#	ttyB?	DEC 3000 ZS8530 ("scc") serial ports (alpha)
122#	ttyA*	mfc serial ports (amiga)
123#	ttyB*	msc serial ports (amiga)
124#	ttyC*	com style serial ports (DraCo, HyperCom) (amiga)
125#		On the DraCo, units 0 and 1 are the built-in "modem" and
126#		"mouse" ports, if configured.
127#	ttyA0   8530 Channel A (formerly ser02) (atari)
128#	ttyA1	8530 Channel B (formerly mdm02) (atari)
129#	ttyB0	UART on first 68901 (formerly mdm01) (atari)
130#	ixpcom	IXP12x0 COM ports
131#	epcom	EP93xx COM ports
132#	ttyM?	HP200/300 4 port serial mux interface (hp300)
133#	ttya	"ttya" system console (luna68k)
134#	ttyb	second system serial port (luna68k)
135#	tty*	Onboard serial ports (mvme68k)
136#		On the mvme147 these are: ttyZ1, ttyZ2 and ttyZ3.
137#		On the mvme167, and '177: ttyC1, ttyC2 and ttyC3.
138#		Note that tty[CZ]0 is grabbed by the console device
139#		so is not created by default
140#	dc*	PMAX 4 channel serial interface (kbd, mouse, modem, printer)
141#	scc*	82530 serial interface (pmax)
142#	ttyZ*	Zilog 8530 ("zstty") serial ports
143#	tty[abcd]	Built-in serial ports (sparc)
144#	tty*	Z88530 serial controllers (sparc64)
145#	ttyh*	SAB82532 serial controllers (sparc64)
146#	tty[a-j]	Built-in serial ports (sun2, sun3)
147#	ttyC?	pccons (arc)
148#	dz*	UNIBUS DZ11 and DZ32 (vax)
149#	dh*	UNIBUS DH11 and emulations (e.g. Able DMAX, Emulex CS-11) (vax)
150#	dmf*	UNIBUS DMF32 (vax)
151#	dhu*    UNIBUS DHU11 (vax)
152#	dmz*    UNIBUS DMZ32 (vax)
153#	dl*	UNIBUS DL11 (vax)
154#	xencons	Xen virtual console
155#
156# Terminal multiplexors:
157#	dc*	4 channel serial interface (keyboard, mouse, modem, printer)
158#	dh*	UNIBUS DH11 and emulations (e.g. Able DMAX, Emulex CS-11)
159#	dhu*	UNIBUS DHU11
160#	dl*	UNIBUS DL11
161#	dmf*	UNIBUS DMF32
162#	dmz*	UNIBUS DMZ32
163#	dz*	UNIBUS DZ11 and DZ32
164#	scc*	82530 serial interface
165#
166# Call units:
167#	dn*	UNIBUS DN11 and emulations (e.g. Able Quadracall)
168#
169# Pseudo terminals:
170#	ptm	pty multiplexor device.
171#	pty*	set of 16 master and slave pseudo terminals
172#	opty	first 16 ptys, to save inodes on install media
173#	ipty	first 2 ptys, for install media use only
174#
175# Printers:
176#	arcpp*	Archimedes parallel port
177#	lpt*	stock lp
178#	lpa*	interruptless lp
179#	par*	Amiga motherboard parallel port
180#
181# USB devices:
182#	usb*	USB control devices
183#	uhid*	USB generic HID devices
184#	ulpt*	USB printer devices
185#	ugen*	USB generic devices
186#	urio*	USB Diamond Rio 500 devices
187#	uscanner*	USB scanners
188#	ttyU*	USB modems
189#	ttyY*	USB serial adapters
190#
191# ISDN devices:
192#	isdn	communication between userland isdnd and kernel
193#	isdnctl	control device
194#	isdnbchan* raw b-channel access
195#	isdntel*	telephony device
196#	isdnteld*	telephony dialout device
197#	isdntrc*	trace device
198#
199# Video devices:
200#	bwtwo*	monochromatic frame buffer
201#	cgtwo*	8-bit color frame buffer
202#	cgthree*	8-bit color frame buffer
203#	cgfour*	8-bit color frame buffer
204#	cgsix*	accelerated 8-bit color frame buffer
205#	cgeight*	24-bit color frame buffer
206#	etvme	Tseng et-compatible cards on VME (atari)
207#	ik*	UNIBUS interface to Ikonas frame buffer
208#	leo	Circad Leonardo VME-bus true color (atari)
209#	ps*	UNIBUS interface to Picture System 2
210#	qv*	QVSS (MicroVAX) display
211#	tcx*	accelerated 8/24-bit color frame buffer
212#
213# Maple bus devices:
214#	maple	Maple bus control devices
215#	mlcd*	Maple bus LCD devices
216#	mmem*	Maple bus storage devices
217#
218# IEEE1394 bus devices:
219#	fw*	IEEE1394 bus generic node access devices
220#	fwmem*	IEEE1394 bus physical memory of the remote node access devices
221#
222# Special purpose devices:
223#	ad*	UNIBUS interface to Data Translation A/D converter
224#	agp*	AGP GART devices
225#	altq	ALTQ control interface
226#	amr*	AMI MegaRaid control device
227#	apm	power management device
228#	audio*	audio devices
229#	bell*	OPM bell device (x68k)
230#	bktr	Brooktree 848/849/878/879 based TV cards
231#	bpf	packet filter
232#	bthub	Bluetooth Device Hub control interface
233#	cfs*	Coda file system device
234#	ch*	SCSI media changer
235#	cir*	Consumer IR
236#	clockctl clock control for non root users
237#	crypto	hardware crypto access driver
238#	dmoverio hardware-assisted data movers
239#	dpt*	DPT/Adaptec EATA RAID management interface
240#	dpti*	DPT/Adaptec I2O RAID management interface
241#	fb*	PMAX generic framebuffer pseudo-device
242#	fd	file descriptors
243#	grf*	graphics frame buffer device
244#	hil	HP300 HIL input devices
245#	icp	ICP-Vortex/Intel RAID control interface
246#	iic*	IIC bus device
247#	io	x86 IOPL access for COMPAT_10, COMPAT_FREEBSD
248#	iop*	I2O IOP control interface
249#	ipl	IP Filter
250#	irframe* IrDA physical frame
251#	ite*	terminal emulator interface to HP300 graphics devices
252#	joy*	joystick device
253#	kttcp	kernel ttcp helper device
254#	lkm	loadable kernel modules interface
255#	lockstat kernel locking statistics
256#	magma*	Magma multiport serial/parallel cards
257#	midi*	MIDI
258#	mlx*	Mylex DAC960 control interface
259#	mly*	Mylex AcceleRAID/eXtremeRAID control interface
260#	np*	UNIBUS Ethernet co-processor interface, for downloading.
261#	nsmb*	SMB requester
262#	openfirm OpenFirmware accessor
263#	pci*	PCI bus access devices
264#	pf	PF packet filter
265#	pow*	power management device (x68k)
266#	puffs	Pass-to-Userspace Framework File System
267#	px*	PixelStamp Xserver access
268#	radio*	radio devices
269#	random	Random number generator
270#	rtc*	RealTimeClock
271#	satlink* PlanetConnect satellite receiver driver
272#	scsibus* SCSI busses
273#	se*	SCSI Ethernet
274#	ses*	SES/SAF-TE SCSI Devices
275#	speaker	PC speaker		(XXX - installed)
276#	sram	battery backuped memory (x68k)
277#	ss*	SCSI scanner
278#	stic*	PixelStamp interface chip
279#	sysmon	System Monitoring hardware
280#	systrace syscall tracer
281#	tap*	virtual Ethernet device
282#	tun*	network tunnel driver
283#	twa	3ware Apache control interface
284#	twe	3ware Escalade control interface
285#	uk*	unknown SCSI device
286#	veriexec verified executable fingerprint loader
287#	vmegen*	generic VME access
288#	view*	generic interface to graphic displays (Amiga)
289#	wsfont*	console font control
290#	wsmux*	wscons event multiplexor
291#	xenevt	Xen event interface
292
293
294#
295# Apart from a few lines right at the end, this file should consist
296# entirely of function definitions.
297#
298# This file is used both as a standalone script (via "sh ./MAKEDEV all"
299# or similar), and as a function library (via "MAKEDEV_AS_LIBRARY=1 .
300# MAKEDEV" from MAKEDEV.local).
301#
302
303get_opts() {
304	opts="$*"
305	shift $((${OPTIND}-1))
306	opts="${opts%$*}"
307}
308
309usage()
310{
311	cat 1>&2 << _USAGE_
312Usage: ${0##*/} [-f] [-m mknod] [-s]  special [...]
313	Create listed special devices.  Options:
314	-f		Force permissions to be updated on existing devices.
315	-m mknod	Name of mknod(8) program.  [\$TOOL_MKNOD or mknod]
316	-s		Generate mtree(8) specfile instead of creating devices.
317
318_USAGE_
319	exit 1
320}
321
322# zeropad width number
323#	display number with a zero (`0') padding of width digits.
324#
325zeropad()
326{
327	case $(($1 - ${#2})) in
328	5)	echo 00000$2;;
329	4)	echo 0000$2;;
330	3)	echo 000$2;;
331	2)	echo 00$2;;
332	1)	echo 0$2;;
333	0)	echo $2;;
334	*)	echo "$0: bad padding" 1>&2; exit 1;;
335	esac
336}
337
338# hexprint number
339#	display (base10) number as hexadecimal
340#
341hexprint()
342{
343	val="$(($1 + 0))"
344	hex=
345	set -- 0 1 2 3 4 5 6 7 8 9 a b c d e f
346	while [ "$val" -gt 0 ]; do
347		eval hex=\$$(($val % 16 + 1))\$hex
348		val="$(($val / 16))"
349	done
350	echo "${hex:-0}"
351}
352
353setup()
354{
355	PATH=/sbin:/usr/sbin:/bin:/usr/bin:/rescue
356
357	do_force=false
358	do_specfile=false
359	while getopts fm:s ch; do
360		case ${ch} in
361		f)	do_force=true ;;
362		m)	TOOL_MKNOD=${OPTARG} ;;
363		s)	do_specfile=true ;;
364		*)	usage ;;
365		esac
366	done
367
368	opts=
369	get_opts "$@"
370	shift $((${OPTIND} - 1))
371	[ $# -gt 0 ] || usage
372
373	MKNOD="${TOOL_MKNOD:-mknod} -F netbsd"
374	if $do_force; then
375		MKNOD="${MKNOD} -R"
376	else
377		MKNOD="${MKNOD} -r"
378	fi
379
380	u_root="%uid_root%"
381	u_uucp="%uid_uucp%"
382	g_kmem="%gid_kmem%"
383	g_ntpd="%gid_ntpd%"
384	g_operator="%gid_operator%"
385	g_wheel="%gid_wheel%"
386	dialin=0
387	dialout=524288
388	callunit=262144
389
390	# only allow read&write for owner by default
391	umask 077
392
393	# Check if we have fdesc mounted
394	if [ -d fd ]; then
395		case "$(df fd)" in
396		*fdesc*)	nofdesc=false;;
397		*)		nofdesc=true;;
398		esac
399	else
400		nofdesc=true
401	fi
402
403	if $do_specfile; then
404		echo ". type=dir"
405	fi
406}
407
408#
409# functions available to create nodes:
410#
411# mkdev name [b|c] major minor [mode{=600} [gid{=0} [uid{=0}]]]
412#	create device node `name' with the appropriate permissions
413#
414# lndev src target
415#	create a symlink from src to target
416#
417# makedir dir mode
418#	create directory with appropriate mode
419#
420
421mkdev()
422{
423	if [ -n "$count_nodes" ]; then
424		count_nodes=$((count_nodes + 1))
425		return
426	fi
427	if $do_specfile; then
428		case $2 in
429		b)	type=block ;;
430		c)	type=char ;;
431		esac
432		echo "./$1 type=${type} device=netbsd,$3,$4 mode=${5:-600} gid=${6:-$g_wheel} uid=${7:-$u_root}"
433	else
434		${MKNOD} -m ${5:-600} -g \#${6:-$g_wheel} -u \#${7:-$u_root} $1 $2 $3 $4
435	fi
436}
437
438lndev()
439{
440	if [ -n "$count_nodes" ]; then
441		count_nodes=$((count_nodes + 1))
442		return
443	fi
444	if $do_specfile; then
445		echo "./$2 type=link link=$1 mode=0700 gid=$g_wheel uid=$u_root"
446	else
447		ln -f -s $1 $2
448	fi
449}
450
451makedir()
452{
453	if [ -n "$count_nodes" ]; then
454		count_nodes=$((count_nodes + 1))
455		return
456	fi
457	if $do_specfile; then
458		echo "./$1 type=dir mode=$2 gid=$g_wheel uid=$u_root"
459	else
460		mkdir $1 2>/dev/null
461		chmod $2 $1
462	fi
463}
464
465warn()
466{
467	echo 1>&2 "$0: $*"
468}
469
470# makedev special [...]
471#	the main loop
472#
473makedev()
474{
475
476for i
477do
478
479case $i in
480
481%MD_DEVICES%
482
483all)
484	makedev all_md
485	makedev std fd ptm pty0 pty1 pty2 pty3
486	makedev ccd0 ccd1 ccd2 ccd3
487	makedev cgd0 cgd1 cgd2 cgd3
488	makedev fss0 fss1 fss2 fss3
489	makedev md0 md1
490	makedev raid0 raid1 raid2 raid3 raid4 raid5 raid6 raid7
491	makedev vnd0 vnd1 vnd2 vnd3
492	makedev bpf
493	makedev tun0 tun1 tun2 tun3
494	makedev ipl pf crypto random systrace
495	makedev lkm lockstat clockctl
496	makedev atabus0 atabus1 atabus2 atabus3
497	makedev tap tap0 tap1 tap2 tap3
498	makedev gpio gpio0 gpio1 gpio2 gpio3 gpio4 gpio5 gpio6 gpio7
499	makedev bthub
500	makedev puffs
501	makedev local # do this last
502	;;
503
504init)
505	# unless overridden by MD entry, this is equal to 'all'
506	makedev all
507	;;
508
509%MI_DEVICES_BEGIN%
510audio)
511	makedev audio0 audio1 audio2 audio3
512	lndev sound0 sound
513	lndev audio0 audio
514	lndev mixer0 mixer
515	lndev audioctl0 audioctl
516	;;
517
518gpio)
519	makedev gpio0 gpio1 gpio2 gpio3 gpio4 gpio5 gpio6 gpio7
520	lndev gpio0 gpio
521	;;
522
523radio)
524	makedev radio0 radio1
525	lndev radio0 radio
526	;;
527
528ramdisk)
529	makedev floppy md0
530	;;
531
532usbs)
533	makedev usb usb0 usb1 usb2 usb3 usb4 usb5 usb6 usb7
534	makedev uhid0 uhid1 uhid2 uhid3
535	makedev ulpt0 ulpt1
536	makedev ttyU0 ttyU1
537	makedev ttyY0 ttyY1
538	makedev urio0
539	makedev uscanner0 uscanner1
540	makedev utoppy0 utoppy1
541	makedev ugen0
542	;;
543
544isdns)
545	makedev isdn isdnctl isdnbchan0 isdnbchan1 isdntel0 isdntel1 isdnteld0 isdnteld1 isdntrc0 isdntrc1
546	;;
547
548std)
549	mkdev		console	c %cons_chr% 0	600
550	mkdev		constty	c %cons_chr% 1	600
551	mkdev		drum	c %swap_chr% 0	640 $g_kmem
552	mkdev		kmem	c %mem_chr% 1	640 $g_kmem
553	mkdev		mem	c %mem_chr% 0	640 $g_kmem
554	mkdev		null	c %mem_chr% 2	666
555	mkdev		zero	c %mem_chr% 12	666
556	mkdev		klog	c %log_chr% 0	600
557	mkdev		ksyms	c %ksyms_chr% 0	444
558	if $nofdesc; then
559		mkdev	tty	c %ctty_chr% 0		666
560		mkdev	stdin	c %filedesc_chr% 0	666
561		mkdev	stdout	c %filedesc_chr% 1	666
562		mkdev	stderr	c %filedesc_chr% 2	666
563	fi
564	;;
565
566usb)
567	mkdev usb c %usb_chr% 255 444
568	;;
569
570usb*)
571	unit=${i#usb}
572	usb=usb$unit
573	mkdev usb$unit c %usb_chr% $unit
574	;;
575
576uhid*)
577	unit=${i#uhid}
578	mkdev uhid$unit c %uhid_chr% $unit 666
579	;;
580
581ulpt*)
582	unit=${i#ulpt}
583	mkdev ulpt$unit c %ulpt_chr% $unit
584	mkdev ulpn$unit c %ulpt_chr% $(($unit + 64))
585	;;
586
587urio*)
588	unit=${i#urio}
589	mkdev urio$unit c %urio_chr% $unit 666
590	;;
591
592uscanner*)
593	unit=${i#uscanner}
594	mkdev uscanner$unit c %uscanner_chr% $unit
595	;;
596
597utoppy*)
598	unit=${i#utoppy}
599	mkdev utoppy$unit c %utoppy_chr% $unit
600	;;
601
602ttyY*)
603	unit=${i#ttyY}
604	mkdev ttyY$unit c %ucycom_chr% $(($unit + $dialin  )) "" "" $u_uucp
605	mkdev dtyY$unit c %ucycom_chr% $(($unit + $dialout )) "" "" $u_uucp
606	mkdev ctyY$unit c %ucycom_chr% $(($unit + $callunit)) "" "" $u_uucp
607	;;
608
609ttyU*)
610	unit=${i#ttyU}
611	mkdev ttyU$unit c %ucom_chr% $(($unit + $dialin  )) "" "" $u_uucp
612	mkdev dtyU$unit c %ucom_chr% $(($unit + $dialout )) "" "" $u_uucp
613	mkdev ctyU$unit c %ucom_chr% $(($unit + $callunit)) "" "" $u_uucp
614	;;
615
616ugen*)
617	unit=${i#ugen}
618	for j in 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
619	do
620		mkdev ugen$unit.$j c %ugen_chr% $(($unit * 16 + ${j#0}))
621	done
622	;;
623
624wscons)
625	makedev ttyE0 ttyE1 ttyE2 ttyE3 ttyE4 ttyE5 ttyE6 ttyE7
626	makedev wsmouse0 wsmouse1 wsmouse2 wsmouse3
627	makedev wskbd0 wskbd1 wskbd2 wskbd3
628	makedev wsmux0 wsmux1 wsmux2 wsmux3
629	makedev wsmouse wskbd
630	makedev ttyEcfg ttyEstat
631	makedev wsfont
632	;;
633
634wsmouse)
635	mkdev wsmouse c %wsmux_chr% 0
636	;;
637
638wskbd)
639	mkdev wskbd c %wsmux_chr% 1
640	;;
641
642wsmux*)
643	unit=${i#wsmux}
644	mkdev wsmux$unit    c %wsmux_chr% $unit
645	mkdev wsmuxctl$unit c %wsmux_chr% $(($unit + 128)) 200
646	;;
647
648xenevt)
649	mkdev xenevt c %xenevt_chr% 0
650	;;
651
652xsd_kva)
653	mkdev xsd_kva c %xenevt_chr% 1
654	;;
655
656xencons)
657	mkdev xencons c %xencons_chr% 0
658	;;
659
660ttyEstat)
661	mkdev ttyEstat c %wsdisplay_chr% 254
662	;;
663
664ttyEcfg)
665	mkdev ttyEcfg c %wsdisplay_chr% 255
666	;;
667
668ttyE*)
669	unit=${i#ttyE}
670	mkdev ttyE$unit c %wsdisplay_chr% $unit
671	;;
672
673wsmouse*)
674	unit=${i#wsmouse}
675	mkdev wsmouse$unit c %wsmouse_chr% $unit
676	;;
677
678wskbd*)
679	unit=${i#wskbd}
680	mkdev wskbd$unit c %wskbd_chr% $unit
681	;;
682
683fd)
684	if $nofdesc; then
685		makedir fd 755
686		n=0
687		while [ $n -lt 64 ]
688		do
689			mkdev fd/$n c %filedesc_chr% $n 666
690			n=$(($n + 1))
691		done
692	fi
693	;;
694
695wt*)
696	case $i in
697	wt*) name=wt;  unit=${i#wt};	chr=%wt_chr%;	blk=%wt_blk%;;
698	esac
699	for sub in $unit $(($unit+8)) $(($unit+16))
700	do
701		mkdev $name$sub		b $blk $(($sub + 0)) 660 $g_operator
702		mkdev n$name$sub	b $blk $(($sub + 4)) 660 $g_operator
703		mkdev r$name$sub	c $chr $(($sub + 0)) 660 $g_operator
704		mkdev nr$name$sub	c $chr $(($sub + 4)) 660 $g_operator
705	done
706	;;
707
708md*)
709	makedisk_minimal md ${i#md} %md_blk% %md_chr%
710	;;
711
712fss*)
713	case $i in
714	fss*) name=fss; unit=${i#fss};	blk=%fss_blk%;	chr=%fss_chr%
715	esac
716	mkdev $name$unit	b $blk $unit 660 $g_operator
717	mkdev r$name$unit	c $chr $unit 660 $g_operator
718	;;
719
720ss*)
721	case $i in
722	ss*) name=ss;	unit=${i#ss};	chr=%ss_chr%;;
723	esac
724	mkdev $name$unit	c $chr $(($unit * 16 + 0)) 640 $g_operator
725	mkdev n$name$unit	c $chr $(($unit * 16 + 1)) 640 $g_operator
726	mkdev en$name$unit	c $chr $(($unit * 16 + 3)) 640 $g_operator
727	;;
728
729ccd*|cgd*|raid*|vnd*)
730	case $i in
731	ccd*)	name=ccd;	unit=${i#ccd};	blk=%ccd_blk%;	chr=%ccd_chr%;;
732	cgd*)	name=cgd;	unit=${i#cgd};	blk=%cgd_blk%;	chr=%cgd_chr%;;
733	raid*)	name=raid;	unit=${i#raid}; blk=%raid_blk%; chr=%raid_chr%;;
734	vnd*)	name=vnd;	unit=${i#vnd};	blk=%vnd_blk%;	chr=%vnd_chr%;;
735	esac
736	%MKDISK% $name $unit $blk $chr
737	;;
738
739sd*)
740	name=sd; unit=${i#sd};	blk=%sd_blk%;	chr=%sd_chr%
741	%MKDISK% $name $unit $blk $chr
742	;;
743
744wd*)
745	name=wd; unit=${i#wd}; blk=%wd_blk%; chr=%wd_chr%
746	%MKDISK% $name $unit $blk $chr
747	;;
748
749fd*)
750	name=fd; unit=${i#fd}; blk=%fd_blk%; chr=%fd_chr%
751	%MKDISK% $name $unit $blk $chr
752	;;
753
754ld*)
755	name=ld; unit=${i#ld}; blk=%ld_blk%; chr=%ld_chr%
756	%MKDISK% $name $unit $blk $chr
757	;;
758
759ed*)
760	name=ed; unit=${i#ed}; blk=%ed_blk%; chr=%ed_chr%
761	%MKDISK% $name $unit $blk $chr
762	;;
763
764ofdisk*)
765	name=ofdisk; unit=${i#ofdisk}; blk=%ofdisk_blk%; chr=%ofdisk_chr%
766	%MKDISK% $name $unit $blk $chr
767	;;
768
769xbd*)
770	name=xbd; unit=${i#xbd}; blk=%xbd_blk%; chr=%xbd_chr%
771	%MKDISK% $name $unit $blk $chr
772	;;
773
774dk*)
775	name=dk; unit=${i#dk}; blk=%dk_blk%; chr=%dk_chr%
776	minor=0 
777	while [ $minor -le ${i#dk} ]
778	do
779		mkdev r$name$minor c $chr $minor 0640 $g_operator
780		mkdev $name$minor b $blk  $minor 0640 $g_operator
781		minor=$(($minor + 1))
782	done
783	;;
784	
785ttyCY*)
786	name=tyCY; chr=%cy_chr%; off=32
787	unit=${i#t${name}}
788	minor=$(($unit * $off))
789	eminor=$(($minor + $off))
790	while [ $minor -lt $eminor ]
791	do
792		nminor=000$minor
793		nminor=${nminor#${nminor%???}}
794		mkdev t$name$nminor c $chr $(($minor + $dialin )) "" "" $u_uucp
795		mkdev d$name$nminor c $chr $(($minor + $dialout)) "" "" $u_uucp
796		minor=$(($minor + 1))
797	done
798	;;
799
800ttyCZ*)
801	name=tyCZ; chr=%cz_chr%; off=64
802	unit=${i#t${name}}
803	minor=$(($unit * $off))
804	eminor=$(($minor + $off))
805	while [ $minor -lt $eminor ]
806	do
807		nminor=0000$minor
808		nminor=${nminor#${nminor%????}}
809		mkdev t$name$nminor c $chr $(($minor + $dialin )) "" "" $u_uucp
810		mkdev d$name$nminor c $chr $(($minor + $dialout)) "" "" $u_uucp
811		minor=$(($minor + 1))
812	done
813	;;
814
815
816tty[0-9]|tty0[0-9])
817	# some archs have built-in zstty (major %zstty_chr%) instead
818	# of NS16550; create ttyZ* and hardlink as [dt]ty0*; this
819	# needs to be before com entry, for archs which have both
820	unit=${i#tty}
821	unit=$(($unit + 0))
822	makedev ttyZ${unit}
823	lndev ttyZ$unit tty0${unit}
824	lndev dtyZ$unit dty0${unit}
825	;;
826
827tty0*|tty1*|tty[0-9])
828	unit=${i#tty}
829	ounit=00$unit
830	ounit=${ounit#${ounit%??}}
831	mkdev tty$ounit c %com_chr% $(($unit + $dialin )) "" "" $u_uucp
832	mkdev dty$ounit c %com_chr% $(($unit + $dialout)) "" "" $u_uucp
833	;;
834
835ttyC*)
836		# some archs call com_chr ttyC traditionally
837	unit=${i#ttyC}; name=ttyC; dname=dtyC; chr=%com_chr%
838	mkdev  $name$unit c $chr $(($unit + $dialin )) "" "" $u_uucp
839	mkdev $dname$unit c $chr $(($unit + $dialout)) "" "" $u_uucp
840	;;
841
842ttyh*)
843	unit=${i#ttyh}; name=ttyh; dname=dtyh; chr=%sabtty_chr%
844	mkdev  $name$unit c $chr $(($unit + $dialin )) "" "" $u_uucp
845	mkdev $dname$unit c $chr $(($unit + $dialout)) "" "" $u_uucp
846	;;
847
848ttyTX*)
849	unit=${i#ttyTX}; name=ttyTX0; dname=dtyTX0; chr=%txcom_chr%
850	mkdev  $name$unit c $chr $(($unit + $dialin )) "" "" $u_uucp
851	mkdev $dname$unit c $chr $(($unit + $dialout)) "" "" $u_uucp
852	;;
853
854ttyZ*)
855	unit=${i#ttyZ}; name=ttyZ; dname=dtyZ; chr=%zstty_chr%
856	mkdev  $name$unit c $chr $(($unit + $dialin )) "" "" $u_uucp
857	mkdev $dname$unit c $chr $(($unit + $dialout)) "" "" $u_uucp
858	;;
859
860opty)
861	for j in 0 1 2 3 4 5 6 7 8 9 a b c d e f
862	do
863		case $j in
864		[0-9])	jn=$j ;;
865		a)	jn=10 ;;
866		b)	jn=11 ;;
867		c)	jn=12 ;;
868		d)	jn=13 ;;
869		e)	jn=14 ;;
870		f)	jn=15 ;;
871		esac
872		mkdev ttyp$j c %pts_chr% $jn 666
873		mkdev ptyp$j c %ptc_chr% $jn 666
874	done
875	;;
876
877pty*)
878	class=${i#pty}
879	d1="p q r s t u v w x y z P Q R S T"
880	if [ "$class" -ge 64 ]
881	then
882		warn "$i: pty unit must be between 0 and 63"
883		continue
884	elif [ "$class" -lt 16 ]
885	then
886		offset=0
887		mult=0
888		d2="0 1 2 3 4 5 6 7 8 9 a b c d e f"
889	else
890		class=$(($class - 16))
891		offset=256
892		mult=2
893		d2="g h i j k l m n o p q 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 Y Z"
894	fi
895	start=$(($class * 16))
896	set -- $d2
897	nt=$#
898	s1=$(($start / $nt))
899	set -- $d1
900	shift $s1
901	t1=$1
902	if [ "$t1" = v ]; then
903		warn "$i: pty unit conflicts with console ttyv0 device"
904		continue
905	fi
906	s2=$(($start % ($nt - $s1 * $mult)))
907	set -- $d2
908	shift $s2
909	t2=$1
910	unit=$(($start + $offset - $s1 * $mult))
911	end=$(($unit + 16))
912	while [ "$unit" -lt "$end" ]
913	do
914		mkdev tty$t1$t2 c %pts_chr% $unit 666
915		mkdev pty$t1$t2 c %ptc_chr% $unit 666
916		shift
917		t2=$1
918		if [ -z "$t2" ]
919		then
920			break
921		fi
922		unit=$(($unit + 1))
923	done
924	;;
925
926stic*)
927	unit=${i#stic}
928	mkdev stic$unit c %stic_chr% $unit
929	;;
930
931st*)
932	case $i in
933	st*) name=st;	unit=${i#st};	chr=%st_chr%;	blk=%st_blk%;;
934	esac
935	mkdev $name$unit	b $blk $(($unit * 16 + 0)) 660 $g_operator
936	mkdev n$name$unit	b $blk $(($unit * 16 + 1)) 660 $g_operator
937	mkdev e$name$unit	b $blk $(($unit * 16 + 2)) 660 $g_operator
938	mkdev en$name$unit	b $blk $(($unit * 16 + 3)) 660 $g_operator
939	mkdev r$name$unit	c $chr $(($unit * 16 + 0)) 660 $g_operator
940	mkdev nr$name$unit	c $chr $(($unit * 16 + 1)) 660 $g_operator
941	mkdev er$name$unit	c $chr $(($unit * 16 + 2)) 660 $g_operator
942	mkdev enr$name$unit	c $chr $(($unit * 16 + 3)) 660 $g_operator
943	;;
944
945ses*|ch*|uk*)
946	case $i in
947	ch*)	name=ch;	unit=${i#ch};	chr=%ch_chr%;;
948	uk*)	name=uk;	unit=${i#uk};	chr=%uk_chr%;;
949	ses*)	name=ses;	unit=${i#ses};	chr=%ses_chr%;;
950	esac
951	mkdev $name$unit c $chr $unit 640 $g_operator
952	;;
953
954cd*)
955	makedisk_minimal cd ${i#cd} %cd_blk% %cd_chr% %
956	;;
957
958mcd*)
959	makedisk_minimal mcd ${i#mcd} %mcd_blk% %mcd_chr%
960	;;
961
962gdrom*)
963	makedisk_minimal gdrom ${i#gdrom} %gdrom_blk% %gdrom_chr%
964	;;
965
966lpt*|lpa*)
967	case $i in
968	lpt*) name=lpt;	unit=${i#lpt};	chr=%lpt_chr%;	flags=0;;
969	lpa*) name=lpa;	unit=${i#lpa};	chr=%lpt_chr%;	flags=128;;
970	esac
971	mkdev $name$unit c $chr $(($unit + $flags))
972	mkdev lpt${unit}ctl c $chr $(($unit + 256))
973	;;
974
975bpf)
976	mkdev bpf	c %bpf_chr% 0
977	lndev bpf bpf0
978	;;
979
980bthub)
981	mkdev bthub c %bthub_chr% 0
982	;;
983
984tun*)
985	unit=${i#tun}
986	mkdev tun$unit c %tun_chr% $unit
987	;;
988
989joy*)
990	unit=${i#joy}
991	mkdev joy$unit c %joy_chr% $unit
992	;;
993
994ipl)
995	mkdev ipl	c %ipl_chr% 0
996	mkdev ipnat	c %ipl_chr% 1
997	mkdev ipstate	c %ipl_chr% 2
998	mkdev ipauth	c %ipl_chr% 3
999	mkdev ipsync	c %ipl_chr% 4
1000	mkdev ipscan	c %ipl_chr% 5
1001	mkdev iplookup	c %ipl_chr% 6
1002	;;
1003
1004pf)
1005	mkdev pf c %pf_chr% 0
1006	;;
1007
1008crypto)
1009	mkdev crypto c %crypto_chr% 0 666
1010	;;
1011
1012cmos)
1013	mkdev cmos c %cmos_chr% 0 644
1014	;;
1015
1016speaker)
1017	mkdev speaker c %spkr_chr% 0
1018	;;
1019
1020lkm)
1021	mkdev lkm c %lkm_chr% 0 640 $g_kmem
1022	;;
1023
1024lockstat)
1025	mkdev lockstat c %lockstat_chr% 0
1026	;;
1027
1028audio*)
1029	unit=${i#audio}
1030	audio=audio$unit
1031	sound=sound$unit
1032	mixer=mixer$unit
1033	audioctl=audioctl$unit
1034	: ${unit:-0}
1035	mkdev $sound    c %audio_chr% $(($unit + 0))	666
1036	mkdev $audio    c %audio_chr% $(($unit + 128))	666
1037	mkdev $mixer    c %audio_chr% $(($unit + 16))	666
1038	mkdev $audioctl c %audio_chr% $(($unit + 192))	666
1039	;;
1040
1041gpio*)
1042	unit=${i#gpio}
1043	mkdev gpio$unit c %gpio_chr% $unit 644
1044	;;
1045
1046rmidi*)
1047	unit=${i#rmidi}
1048	mkdev rmidi$unit c %midi_chr% $unit 666
1049	;;
1050
1051music*)
1052	unit=${i#music}
1053	: ${unit:-0}
1054	mkdev music$unit     c %sequencer_chr% $(($unit + 0))	666
1055	mkdev sequencer$unit c %sequencer_chr% $(($unit + 128))	666
1056	;;
1057
1058radio*)
1059	unit=${i#radio}
1060	: ${unit:-0}
1061	mkdev radio$unit c %radio_chr% $unit 666
1062	;;
1063
1064amr*)
1065	unit=${i#amr}
1066	mkdev amr$unit c %amr_chr% $unit
1067	;;
1068
1069apm)
1070	mkdev apm	c %apm_chr% 0 644
1071	mkdev apmctl	c %apm_chr% 8 644
1072	;;
1073
1074apm)
1075		# hpcmips uses `apmdev_chr' instead of `apm_chr'
1076	mkdev apm	c %apmdev_chr% 0 644
1077	mkdev apmctl	c %apmdev_chr% 8 644
1078	;;
1079
1080satlink*)
1081	unit=${i#satlink}
1082	mkdev satlink$unit c %satlink_chr% $unit 444
1083	;;
1084
1085random)
1086	mkdev random	c %rnd_chr% 0 444
1087	mkdev urandom	c %rnd_chr% 1 644
1088	;;
1089
1090cfs*)
1091	unit=${i#cfs}
1092	mkdev cfs$unit c %vcoda_chr% $unit
1093	;;
1094
1095sysmon)
1096	mkdev sysmon	c %sysmon_chr% 0 644
1097	mkdev watchdog	c %sysmon_chr% 1 644
1098	mkdev power	c %sysmon_chr% 2 640
1099	;;
1100
1101scsibus*)
1102	unit=${i#scsibus}
1103	mkdev scsibus$unit c %scsibus_chr% $unit 644
1104	;;
1105
1106bktr)
1107	makedev bktr0 bktr1
1108	lndev	bktr0	bktr
1109	lndev	tuner0	tuner
1110	lndev	vbi0	vbi
1111	;;
1112
1113bktr*)
1114	unit=${i#bktr}
1115	mkdev bktr$unit		c %bktr_chr% $(($unit + 0))	444
1116	mkdev tuner$unit	c %bktr_chr% $(($unit + 16))	444
1117	mkdev vbi$unit		c %bktr_chr% $(($unit + 32))	444
1118	;;
1119
1120io)
1121	mkdev		io	c %mem_chr% 14	600
1122	;;
1123
1124iop*)
1125	unit=${i#iop}
1126	mkdev iop$unit c %iop_chr% $unit
1127	;;
1128
1129mlx*)
1130	unit=${i#mlx}
1131	mkdev mlx$unit c %mlx_chr% $unit
1132	;;
1133
1134mly*)
1135	unit=${i#mly}
1136	mkdev mly$unit c %mly_chr% $unit
1137	;;
1138
1139twa*)
1140	unit=${i#twa}
1141	mkdev twa$unit c %twa_chr% $unit
1142	;;
1143
1144twe*)
1145	unit=${i#twe}
1146	mkdev twe$unit c %twe_chr% $unit
1147	;;
1148
1149icp*)
1150	unit=${i#icp}
1151	mkdev icp$unit c %icp_chr% $unit
1152	;;
1153
1154agp*)
1155	unit=${i#agp}
1156	mkdev agp$unit c %agp_chr% $unit 644
1157	if [ "$unit" = "0" ]; then
1158		lndev agp$unit agpgart
1159	fi
1160	;;
1161
1162pci*)
1163	unit=${i#pci}
1164	mkdev pci$unit c %pci_chr% $unit 644
1165	;;
1166
1167dpti*)
1168	unit=${i#dpti}
1169	mkdev dpti$unit c %dpti_chr% $unit
1170	;;
1171
1172dpt*)
1173	unit=${i#dpt}
1174	mkdev dpt$unit c %dpt_chr% $unit
1175	;;
1176
1177altq)
1178	makedir altq 755
1179	unit=0
1180	for dev in altq cbq wfq afm fifoq red rio localq hfsc cdnr blue priq
1181	do
1182		mkdev altq/$dev c %altq_chr% $unit 644
1183		unit=$(($unit + 1))
1184	done
1185	;;
1186
1187isdn)
1188	mkdev isdn c %isdn_chr% 0
1189	;;
1190
1191isdnctl)
1192	mkdev isdnctl c %isdnctl_chr% 0
1193	;;
1194
1195isdnbchan*)
1196	unit=${i#isdnbchan}
1197	mkdev isdnbchan$unit c %isdnbchan_chr% $unit
1198	;;
1199
1200isdnteld*)
1201	unit=${i#isdnteld}
1202	mkdev isdnteld$unit c %isdntel_chr% $(($unit + 64))
1203	;;
1204
1205isdntel*)
1206	unit=${i#isdntel}
1207	mkdev isdntel$unit c %isdntel_chr% $unit
1208	;;
1209
1210isdntrc*)
1211	unit=${i#isdntrc}
1212	mkdev isdntrc$unit c %isdntrc_chr% $unit
1213	;;
1214
1215vmegen)
1216	makedev vmegen0 vmegen1 vmegen2 vmegen3
1217	;;
1218
1219vmegen*)
1220	unit=${i#vmegen}
1221	mkdev vmegen$unit c %vmegeneric_chr% $(($unit * 16 + 0))
1222	;;
1223
1224wsfont)
1225	mkdev wsfont c %wsfont_chr% 0
1226	;;
1227
1228cir*)
1229	unit=${i#cir}
1230	mkdev cir$unit c %cir_chr% $unit 666
1231	;;
1232
1233irframe*)
1234	unit=${i#irframe}
1235	mkdev irframe$unit c %irframe_chr% $unit
1236	;;
1237
1238fcom*)
1239	unit=${i#fcom}
1240	mkdev fcom$unit c %fcom_chr% $unit "" "" $u_uucp
1241	;;
1242
1243openfirm)
1244	mkdev openfirm c %openfirm_chr% 0 444
1245	;;
1246
1247nvram)
1248	mkdev nvram c %nvram_chr% 0 644
1249	;;
1250
1251rtc)
1252	mkdev rtc c %rtc_chr% 0 644
1253	;;
1254
1255clockctl)
1256	mkdev clockctl c %clockctl_chr% 0 660 $g_ntpd
1257	;;
1258
1259nsmb)
1260	makedev nsmb0 nsmb1 nsmb2 nsmb3
1261	;;
1262
1263nsmb*)
1264	unit=${i#nsmb}
1265	mkdev nsmb$unit c %nsmb_chr% $unit 644
1266	;;
1267
1268systrace)
1269	mkdev systrace c %systrace_chr% 0 644
1270	;;
1271
1272kttcp)
1273	mkdev kttcp c %kttcp_chr% 0
1274	;;
1275
1276dmoverio)
1277	mkdev dmoverio c %dmoverio_chr% 0 644
1278	;;
1279
1280veriexec)
1281	mkdev veriexec c %veriexec_chr% 0 600
1282	;;
1283
1284ttyv*)
1285	unit=${i#ttyv}
1286	mkdev ttyv$unit c %pc_chr% $unit
1287	;;
1288
1289# arm, acorn32
1290ttyv*)
1291	unit=${i#ttyv}
1292	mkdev ttyv$unit c %physcon_chr% $unit
1293	;;
1294
1295arcpp*)
1296	unit=${i#arcpp}
1297	mkdev arcpp$unit c %arcpp_chr% $unit
1298	;;
1299
1300par*)
1301	unit=${i#par}
1302	case $unit in
1303	0)
1304		mkdev par$unit c %par_chr% $unit
1305		;;
1306	*)
1307		warn "bad unit for par in: $i"
1308		;;
1309	esac
1310	;;
1311
1312ite*|ttye*)
1313	case $i in
1314	ite*)	unit=${i#ite};;
1315	ttye*)	unit=${i#ttye};;
1316	esac
1317	mkdev ttye$unit	c %ite_chr% $unit
1318	;;
1319
1320pms*)
1321	unit=${i#pms}
1322	mkdev pms$unit c %opms_chr% $unit
1323	;;
1324
1325qms*)
1326	unit=${i#qms}
1327	mkdev qms$unit c %qms_chr% $unit
1328	;;
1329
1330lms*)
1331	unit=${i#lms}
1332	mkdev lms$unit c %lms_chr% $unit
1333	;;
1334
1335mms*)
1336	unit=${i#mms}
1337	mkdev mms$unit c %mms_chr% $unit
1338	;;
1339
1340mouse-*)
1341	case $i in
1342	mouse-pms*) name=pms ;;
1343	mouse-qms*) name=qms ;;
1344	esac
1345	unit=${i#mouse-${name}}
1346	lndev $name$unit mouse
1347	;;
1348
1349kbd)
1350	mkdev kbd c %kbd_chr% 0
1351	;;
1352
1353kbdctl)
1354	mkdev kbdctl c %kbd_chr% 1
1355	;;
1356
1357vidcconsole0)
1358	mkdev vidcconsole0 c %vidcconsole_chr% 0 640
1359	;;
1360
1361view*)
1362	unit=${i#view}
1363	mkdev view$unit	c %view_chr% $unit 666
1364	;;
1365
1366mouse*)
1367	unit=${i#mouse}
1368	case $unit in
1369	0|1)
1370		mkdev mouse$unit c %ms_chr% $unit 666
1371		if [ $unit = 0 ]; then
1372			lndev mouse$unit mouse
1373		fi
1374		;;
1375	*)
1376		warn "bad unit for mouse in: $i"
1377		;;
1378	esac
1379	;;
1380
1381panel)
1382	mkdev panel0 c %panel_chr% 0 660
1383	;;
1384
1385tslcd)
1386	mkdev tslcd0 c %tslcd_chr% 0 660
1387	;;
1388
1389ipty)
1390	mkdev ttyp0 c %pts_chr% 0 666
1391	mkdev ttyp1 c %pts_chr% 1 666
1392	mkdev ptyp0 c %ptc_chr% 0 666
1393	mkdev ptyp1 c %ptc_chr% 1 666
1394	;;
1395
1396ptm)
1397	mkdev ptmx c %ptm_chr% 0 666
1398	mkdev ptm c %ptm_chr% 1 666
1399	;;
1400
1401grf*)
1402	unit=${i#grf}
1403	mkdev grf$unit c %grf_chr% $unit 666
1404	;;
1405
1406etvme)
1407	mkdev etvme c %et_chr% 0
1408	;;
1409
1410leo*)
1411	unit=${i#leo}
1412	mkdev leo$unit c %leo_chr% $unit
1413	;;
1414
1415scif*)
1416	unit=${i#scif}
1417	mkdev scif$unit c %scif_chr% $unit "" "" $u_uucp
1418	;;
1419
1420sci*)
1421	unit=${i#sci}
1422	mkdev sci$unit c %sci_chr% $unit "" "" $u_uucp
1423	;;
1424
1425maple*)
1426	case $i in
1427	mapleA*) name="mapleA"; unit=0;;
1428	mapleB*) name="mapleB"; unit=1;;
1429	mapleC*) name="mapleC"; unit=2;;
1430	mapleD*) name="mapleD"; unit=3;;
1431	esac
1432	subunit=${i#$name}
1433	mkdev $name$subunit c %maple_chr% $(($unit * 8 + 0$subunit))
1434	;;
1435
1436mmem*)
1437	unit=${i#mmem}
1438	for pt in 0	# 1 2 3 4 ... 255
1439	do
1440#		mkdev mmem${unit}.${pt}a  b %mmem_blk% $(($unit * 4096 + $pt * 16 + 0)) 640 $g_operator
1441		mkdev mmem${unit}.${pt}c  b %mmem_blk% $(($unit * 4096 + $pt * 16 + 2)) 640 $g_operator
1442#		mkdev rmmem${unit}.${pt}a c %mmem_chr% $(($unit * 4096 + $pt * 16 + 0)) 640 $g_operator
1443		mkdev rmmem${unit}.${pt}c c %mmem_chr% $(($unit * 4096 + $pt * 16 + 2)) 640 $g_operator
1444	done
1445	;;
1446
1447mlcd*)
1448	unit=${i#mlcd}
1449	for pt in 0	# 1 2 3 4 ... 255
1450	do
1451		mkdev mlcd${unit}.${pt} c %mlcd_chr% $(($unit * 256 + $pt)) 640 $g_operator
1452	done
1453	;;
1454
1455ixpcom*)
1456	unit=${i#ixpcom}
1457	mkdev ixpcom$unit c %ixpcom_chr% $unit "" "" $u_uucp
1458	;;
1459
1460epcom*)
1461	unit=${i#epcom}
1462	mkdev epcom$unit c %epcom_chr% $unit "" "" $u_uucp
1463	;;
1464
1465ucbsnd)
1466	mkdev ucbsnd c %ucbsnd_chr% 0 666
1467	;;
1468
1469adb)
1470	mkdev adb c %aed_chr% 0 666
1471	;;
1472
1473asc*)
1474	unit=${i#asc}
1475	mkdev asc$unit c %asc_chr% $unit 666
1476	;;
1477
1478bwtwo*)
1479	unit=${i#bwtwo}
1480	mkdev bwtwo$unit c %bwtwo_chr% $unit 666
1481	;;
1482
1483cgtwo*)
1484	unit=${i#cgtwo}
1485	mkdev cgtwo$unit c %cgtwo_chr% $unit 666
1486	;;
1487
1488cgthree*)
1489	unit=${i#cgthree}
1490	mkdev cgthree$unit c %cgthree_chr% $unit 666
1491	;;
1492
1493cgfour*)
1494	unit=${i#cgfour}
1495	mkdev cgfour$unit c %cgfour_chr% $unit 666
1496	;;
1497
1498cgsix*)
1499	unit=${i#cgsix}
1500	mkdev cgsix$unit c %cgsix_chr% $unit 666
1501	;;
1502
1503cgeight*)
1504	unit=${i#cgeight}
1505	mkdev cgeight$unit c %cgeight_chr% $unit 666
1506	;;
1507
1508tcx*)
1509	unit=${i#tcx}
1510	mkdev tcx$unit c %tcx_chr% $unit 666
1511	;;
1512
1513xd*|xy*)
1514	case $i in
1515	xd*)	name=xd; unit=${i#xd}; blk=%xd_blk%;	chr=%xd_chr%;;
1516	xy*)	name=xy; unit=${i#xy}; blk=%xy_blk%;	chr=%xy_chr%;;
1517	esac
1518	%MKDISK% $name $unit $blk $chr
1519	;;
1520
1521magma*)
1522	unit=${i#magma}
1523	if [ 0$unit -gt 3 ]; then
1524		warn "bad unit for $i: $unit"
1525		break
1526	fi
1527	for j in 0 1 2 3 4 5 6 7 8 9 a b c d e f
1528	do
1529		case $j in
1530		[0-9])	jn=$j ;;
1531		a)	jn=10 ;;
1532		b)	jn=11 ;;
1533		c)	jn=12 ;;
1534		d)	jn=13 ;;
1535		e)	jn=14 ;;
1536		f)	jn=15 ;;
1537		esac
1538		mkdev tty$unit$j c %mtty_chr% $(($unit * 64 + $jn))
1539	done
1540	mkdev bpp${unit}0 c %mbpp_chr% $(($unit * 64 + 0))
1541	mkdev bpp${unit}1 c %mbpp_chr% $(($unit * 64 + 1))
1542	;;
1543
1544clcd*)
1545	unit=${i#clcd}
1546	if [ 0$unit -gt 7 ]; then
1547		warn "bad unit for $i: $unit"
1548		break
1549	fi
1550	for j in 0 1 2 3 4 5 6 7
1551	do
1552		mkdev ttyA$unit$j c %clcd_chr% $(($unit * 8 + $j + $dialin)) "" "" $u_uucp
1553		mkdev dtyA$unit$j c %clcd_chr% $(($unit * 8 + $j + $dialout)) "" "" $u_uucp
1554	done
1555	;;
1556
1557spif*)
1558	unit=${i#spif}
1559	if [ 0$unit -gt 3 ]; then
1560		warn "bad unit for $i: $unit"
1561		break
1562	fi
1563	for j in 0 1 2 3 4 5 6 7; do
1564		mkdev ttyS$unit$j c 102 $(($unit * 64 + $j)) "" "" $u_uucp
1565	done
1566	mkdev bppS${unit}0 c 103 $(($unit * 64 + 0))
1567	mkdev bppS${unit}1 c 103 $(($unit * 64 + 1))
1568	;;
1569
1570bpp*)
1571	unit=${i#bpp}
1572	mkdev bpp$unit c %bpp_chr% $(($unit + 0))
1573	;;
1574
1575tctrl*)
1576	unit=${i#tctrl}
1577	mkdev tctrl$unit c %tctrl_chr% $unit 666
1578	;;
1579
1580bmd*)
1581	unit=${i#bmd}
1582	mkdev bmd${unit}a  b %bmd_blk% $(($unit * 8 + 0)) 640 $g_operator
1583	mkdev bmd${unit}c  b %bmd_blk% $(($unit * 8 + 2)) 640 $g_operator
1584	mkdev rbmd${unit}a c %bmd_chr% $(($unit * 8 + 0)) 640 $g_operator
1585	mkdev rbmd${unit}c c %bmd_chr% $(($unit * 8 + 2)) 640 $g_operator
1586	;;
1587
1588sram)
1589	mkdev sram c %sram_chr% 0 644
1590	;;
1591
1592pow*)
1593	unit=${i#pow}
1594	case $unit in
1595	0|1)
1596		mkdev pow${unit} c %pow_chr% ${unit} 644
1597		if [ $unit = 0 ]; then
1598			lndev pow${unit} pow
1599		fi
1600		;;
1601	*)
1602		warn "bad unit for pow in: $i"
1603		;;
1604	esac
1605	;;
1606
1607ttyS*)
1608	unit=${i#ttyS}
1609	mkdev ttyS$unit c %sacom_chr% $(($unit + $dialin )) "" "" $u_uucp
1610	mkdev dtyS$unit c %sacom_chr% $(($unit + $dialout)) "" "" $u_uucp
1611	;;
1612
1613atabus*)
1614	unit=${i#atabus}
1615	mkdev atabus$unit c %atabus_chr% $unit 644
1616	;;
1617
1618drvctl)
1619	mkdev drvctl c %drvctl_chr% 0 644
1620	;;
1621
1622tap*)
1623	unit=${i#tap}
1624	case "$unit" in
1625	[0-9]*)
1626		mkdev tap${unit} c %tap_chr% ${unit} 600
1627		;;
1628	*)
1629		mkdev tap c %tap_chr% 0xfffff 600
1630		;;
1631	esac
1632	;;
1633
1634fw*)
1635	unit=${i#fw}
1636	for j in 0 1 2 3
1637	do
1638		mkdev fw${unit}.${j} c %fw_chr% $((${unit} * 256 + ${j})) 660 ${g_operator}
1639		mkdev fwmem${unit}.${j} c %fw_chr% $((65536 + ${unit} * 256 + ${j})) 660 ${g_operator}
1640	done
1641	;;
1642
1643puffs)
1644	mkdev puffs c %puffs_chr% 0x7ffff 600
1645	;;
1646
1647midevend)
1648%MI_DEVICES_END%
1649local)
1650	if [ -n "$count_nodes" ]; then
1651	if [ -f "$0.local" ]; then
1652		umask 0
1653		sh "$0.local" $opts all
1654		umask 077
1655	else
1656		warn "missing $0.local"
1657	fi
1658	fi
1659	;;
1660
1661*)
1662	warn "$i: unknown device"
1663	;;
1664
1665esac
1666done
1667
1668}
1669
1670
1671# three variants of disk partitions - max 8, max 16, max 16 with highpartoffset
1672# hack; only the one used by port is retained in final MAKEDEV script
1673# routine is called as:
1674# makedisk name unit blk chr
1675makedisk_p8()
1676{
1677	name="$1"; unit="$2"; blk="$3"; chr="$4"
1678
1679	mkdev ${name}${unit}a	b $blk $(($unit * 8 + 0))	640 $g_operator
1680	mkdev ${name}${unit}b	b $blk $(($unit * 8 + 1))	640 $g_operator
1681	mkdev ${name}${unit}c	b $blk $(($unit * 8 + 2))	640 $g_operator
1682	mkdev ${name}${unit}d	b $blk $(($unit * 8 + 3))	640 $g_operator
1683	mkdev ${name}${unit}e	b $blk $(($unit * 8 + 4))	640 $g_operator
1684	mkdev ${name}${unit}f	b $blk $(($unit * 8 + 5))	640 $g_operator
1685	mkdev ${name}${unit}g	b $blk $(($unit * 8 + 6))	640 $g_operator
1686	mkdev ${name}${unit}h	b $blk $(($unit * 8 + 7))	640 $g_operator
1687	mkdev r${name}${unit}a	c $chr $(($unit * 8 + 0))	640 $g_operator
1688	mkdev r${name}${unit}b	c $chr $(($unit * 8 + 1))	640 $g_operator
1689	mkdev r${name}${unit}c	c $chr $(($unit * 8 + 2))	640 $g_operator
1690	mkdev r${name}${unit}d	c $chr $(($unit * 8 + 3))	640 $g_operator
1691	mkdev r${name}${unit}e	c $chr $(($unit * 8 + 4))	640 $g_operator
1692	mkdev r${name}${unit}f	c $chr $(($unit * 8 + 5))	640 $g_operator
1693	mkdev r${name}${unit}g	c $chr $(($unit * 8 + 6))	640 $g_operator
1694	mkdev r${name}${unit}h	c $chr $(($unit * 8 + 7))	640 $g_operator
1695}
1696
1697makedisk_p16()
1698{
1699	name="$1"; unit="$2"; blk="$3"; chr="$4"
1700
1701	mkdev ${name}${unit}a	b $blk $(($unit * 16 + 0))	640 $g_operator
1702	mkdev ${name}${unit}b	b $blk $(($unit * 16 + 1))	640 $g_operator
1703	mkdev ${name}${unit}c	b $blk $(($unit * 16 + 2))	640 $g_operator
1704	mkdev ${name}${unit}d	b $blk $(($unit * 16 + 3))	640 $g_operator
1705	mkdev ${name}${unit}e	b $blk $(($unit * 16 + 4))	640 $g_operator
1706	mkdev ${name}${unit}f	b $blk $(($unit * 16 + 5))	640 $g_operator
1707	mkdev ${name}${unit}g	b $blk $(($unit * 16 + 6))	640 $g_operator
1708	mkdev ${name}${unit}h	b $blk $(($unit * 16 + 7))	640 $g_operator
1709	mkdev ${name}${unit}i	b $blk $(($unit * 16 + 8))	640 $g_operator
1710	mkdev ${name}${unit}j	b $blk $(($unit * 16 + 9))	640 $g_operator
1711	mkdev ${name}${unit}k	b $blk $(($unit * 16 + 10))	640 $g_operator
1712	mkdev ${name}${unit}l	b $blk $(($unit * 16 + 11))	640 $g_operator
1713	mkdev ${name}${unit}m	b $blk $(($unit * 16 + 12))	640 $g_operator
1714	mkdev ${name}${unit}n	b $blk $(($unit * 16 + 13))	640 $g_operator
1715	mkdev ${name}${unit}o	b $blk $(($unit * 16 + 14))	640 $g_operator
1716	mkdev ${name}${unit}p	b $blk $(($unit * 16 + 15))	640 $g_operator
1717	mkdev r${name}${unit}a	c $chr $(($unit * 16 + 0))	640 $g_operator
1718	mkdev r${name}${unit}b	c $chr $(($unit * 16 + 1))	640 $g_operator
1719	mkdev r${name}${unit}c	c $chr $(($unit * 16 + 2))	640 $g_operator
1720	mkdev r${name}${unit}d	c $chr $(($unit * 16 + 3))	640 $g_operator
1721	mkdev r${name}${unit}e	c $chr $(($unit * 16 + 4))	640 $g_operator
1722	mkdev r${name}${unit}f	c $chr $(($unit * 16 + 5))	640 $g_operator
1723	mkdev r${name}${unit}g	c $chr $(($unit * 16 + 6))	640 $g_operator
1724	mkdev r${name}${unit}h	c $chr $(($unit * 16 + 7))	640 $g_operator
1725	mkdev r${name}${unit}i	c $chr $(($unit * 16 + 8))	640 $g_operator
1726	mkdev r${name}${unit}j	c $chr $(($unit * 16 + 9))	640 $g_operator
1727	mkdev r${name}${unit}k	c $chr $(($unit * 16 + 10))	640 $g_operator
1728	mkdev r${name}${unit}l	c $chr $(($unit * 16 + 11))	640 $g_operator
1729	mkdev r${name}${unit}m	c $chr $(($unit * 16 + 12))	640 $g_operator
1730	mkdev r${name}${unit}n	c $chr $(($unit * 16 + 13))	640 $g_operator
1731	mkdev r${name}${unit}o	c $chr $(($unit * 16 + 14))	640 $g_operator
1732	mkdev r${name}${unit}p	c $chr $(($unit * 16 + 15))	640 $g_operator
1733}
1734
1735makedisk_p16high()
1736{
1737	ho=524280	# offset for partition 9 to 16
1738	name="$1"; unit="$2"; blk="$3"; chr="$4"
1739
1740	mkdev ${name}${unit}a	b $blk $(($unit * 8 + 0))	640 $g_operator
1741	mkdev ${name}${unit}b	b $blk $(($unit * 8 + 1))	640 $g_operator
1742	mkdev ${name}${unit}c	b $blk $(($unit * 8 + 2))	640 $g_operator
1743	mkdev ${name}${unit}d	b $blk $(($unit * 8 + 3))	640 $g_operator
1744	mkdev ${name}${unit}e	b $blk $(($unit * 8 + 4))	640 $g_operator
1745	mkdev ${name}${unit}f	b $blk $(($unit * 8 + 5))	640 $g_operator
1746	mkdev ${name}${unit}g	b $blk $(($unit * 8 + 6))	640 $g_operator
1747	mkdev ${name}${unit}h	b $blk $(($unit * 8 + 7))	640 $g_operator
1748	mkdev ${name}${unit}i	b $blk $(($unit * 8 + $ho + 8))	640 $g_operator
1749	mkdev ${name}${unit}j	b $blk $(($unit * 8 + $ho + 9))	640 $g_operator
1750	mkdev ${name}${unit}k	b $blk $(($unit * 8 + $ho + 10)) 640 $g_operator
1751	mkdev ${name}${unit}l	b $blk $(($unit * 8 + $ho + 11)) 640 $g_operator
1752	mkdev ${name}${unit}m	b $blk $(($unit * 8 + $ho + 12)) 640 $g_operator
1753	mkdev ${name}${unit}n	b $blk $(($unit * 8 + $ho + 13)) 640 $g_operator
1754	mkdev ${name}${unit}o	b $blk $(($unit * 8 + $ho + 14)) 640 $g_operator
1755	mkdev ${name}${unit}p	b $blk $(($unit * 8 + $ho + 15)) 640 $g_operator
1756	mkdev r${name}${unit}a	c $chr $(($unit * 8 + 0))	640 $g_operator
1757	mkdev r${name}${unit}b	c $chr $(($unit * 8 + 1))	640 $g_operator
1758	mkdev r${name}${unit}c	c $chr $(($unit * 8 + 2))	640 $g_operator
1759	mkdev r${name}${unit}d	c $chr $(($unit * 8 + 3))	640 $g_operator
1760	mkdev r${name}${unit}e	c $chr $(($unit * 8 + 4))	640 $g_operator
1761	mkdev r${name}${unit}f	c $chr $(($unit * 8 + 5))	640 $g_operator
1762	mkdev r${name}${unit}g	c $chr $(($unit * 8 + 6))	640 $g_operator
1763	mkdev r${name}${unit}h	c $chr $(($unit * 8 + 7))	640 $g_operator
1764	mkdev r${name}${unit}i	c $chr $(($unit * 8 + $ho + 8))	640 $g_operator
1765	mkdev r${name}${unit}j	c $chr $(($unit * 8 + $ho + 9))	640 $g_operator
1766	mkdev r${name}${unit}k	c $chr $(($unit * 8 + $ho + 10)) 640 $g_operator
1767	mkdev r${name}${unit}l	c $chr $(($unit * 8 + $ho + 11)) 640 $g_operator
1768	mkdev r${name}${unit}m	c $chr $(($unit * 8 + $ho + 12)) 640 $g_operator
1769	mkdev r${name}${unit}n	c $chr $(($unit * 8 + $ho + 13)) 640 $g_operator
1770	mkdev r${name}${unit}o	c $chr $(($unit * 8 + $ho + 14)) 640 $g_operator
1771	mkdev r${name}${unit}p	c $chr $(($unit * 8 + $ho + 15)) 640 $g_operator
1772}
1773
1774# make only the very few basic disk device nodes - 'a' partition
1775# and raw partition
1776makedisk_minimal()
1777{
1778	name=$1; unit=$2; blk=$3; chr=$4
1779	doff=%DISKMINOROFFSET%
1780	ro=%RAWDISK_OFF%
1781	rn=%RAWDISK_NAME%
1782
1783	mkdev ${name}${unit}a	b $blk $(($unit * $doff + 0))	640 $g_operator
1784	mkdev ${name}${unit}$rn	b $blk $(($unit * $doff + $ro))	640 $g_operator
1785	mkdev r${name}${unit}a	c $chr $(($unit * $doff + 0))	640 $g_operator
1786	mkdev r${name}${unit}$rn c $chr $(($unit * $doff + $ro)) 640 $g_operator
1787}
1788
1789create_mfs_dev()
1790{
1791	ninode=$((${1-1200} * 11 / 10))
1792	fs_size=$((8192 + 2 * 8192 + 4096 + ninode*(128+18) + 8192))
1793	fs_size=$((fs_size/512))
1794	
1795	dev_mountpoint=${PWD:-/dev}
1796	mount_mfs -b 4096 -f 512 -s $fs_size -n $ninode -p 07555 -o union swap $dev_mountpoint
1797      
1798	cd $dev_mountpoint
1799	mknod -m 600 -g 0 -u 0 temp_console c %CONSOLE_CMAJOR% 0
1800	exec >temp_console 2>&1
1801	rm temp_console
1802	echo "Created mfs $dev_mountpoint ($fs_size blocks, $ninode inodes)"
1803}       
1804
1805# We don't want to pass -M to MAKEDEV.local
1806if [ "$1" = -M ]; then
1807        do_create_mfs=true
1808        shift
1809else
1810        do_create_mfs=false
1811fi
1812
1813#
1814# MAIN: If MAKEDEV_AS_LIBRARY is set, then we are being used as a
1815# function library, so just return.  Otherwise, call the setup function
1816# to parse command line args and set some other variables; then call the
1817# makedev function to create requested devices.
1818#
1819[ -n "${MAKEDEV_AS_LIBRARY}" ] && return
1820
1821setup ${1+"$@"}
1822shift $((${OPTIND}-1))
1823
1824if $do_create_mfs; then
1825	count_nodes=0
1826	makedev ${1+"$@"}
1827	create_mfs_dev $count_nodes
1828	unset count_nodes
1829fi
1830
1831makedev ${1+"$@"}
1832