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