MAKEDEV.mi revision 1.76
1define(COMM,`#')dnl 2include(MAKEDEV.sub)dnl 3dnl 4vers(a, {-$OpenBSD: MAKEDEV.mi,v 1.76 2005/10/04 18:33:52 otto Exp $-})dnl 5dnl 6divert(1)dnl 7{-#-} 8{-#-} Copyright (c) 2001-2004 Todd T. Fries <todd@OpenBSD.org> 9{-#-} 10{-#-} Permission to use, copy, modify, and distribute this software for any 11{-#-} purpose with or without fee is hereby granted, provided that the above 12{-#-} copyright notice and this permission notice appear in all copies. 13{-#-} 14{-#-} THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 15{-#-} WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 16{-#-} MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 17{-#-} ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 18{-#-} WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 19{-#-} ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 20{-#-} OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21{-#-} 22define(quote,{-"$1" -})dnl 23include(MAKEDEV.common)dnl 24dnl 25__devtitle(make, {-Device "make" file. Valid arguments-})dnl 26__devitem({-all-}, {-all-}, {-makes all known devices{-,-} including local devices. 27{-#-} Tries to make the ``standard'' number of each type.-})dnl 28__devitem(std,{-std-},Standard devices)dnl 29__devitem(local,local,Configuration specific devices)dnl 30dnl 31dnl _std 32dnl 33dnl $1: tty 34dnl $2: memstuff 35dnl $3: ksyms 36dnl $4: drum 37dnl $5: klog 38dnl 39define({-_std-},{-dnl 40std) 41 M console c 0 0 600 42 M tty c $1 0 43 M mem c $2 0 640 kmem 44 M kmem c $2 1 640 kmem 45 M null c $2 2 46 M zero c $2 12 47 M stdin c major_fdesc_c 0 48 M stdout c major_fdesc_c 1 49 M stderr c major_fdesc_c 2 50 M ksyms c $3 0 640 kmem 51 M drum c $4 0 640 kmem 52 M klog c $5 0 600-})dnl 53dnl 54divert(1)dnl 55define(__mddivert,7)dnl 56include(etc.MACHINE/MAKEDEV.md)dnl 57dnl 58dnl 59divert(0)dnl 60#!/bin/sh - 61# 62# THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. 63# generated from: 64# 65show_vers()dnl <-- now that all files are included, show versions 66# 67dnl 68divert(2)dnl 69PATH=/sbin:/usr/sbin:/bin:/usr/bin 70T=$0 71 72# set this to echo for Echo-Only debugging 73[ "$eo" ] || eo= 74 75hex() 76{ 77 case ${--}1 in 78 [0-9]) echo -n {-$-}1;; 79 10) echo -n a;; 80 11) echo -n b;; 81 12) echo -n c;; 82 13) echo -n d;; 83 14) echo -n e;; 84 15) echo -n f;; 85 esac 86} 87 88alph2d() 89{ 90 local t="$1" 91 local p="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 92 local sub=${p%${t}*} 93 echo ${#sub} 94} 95 96h2d() 97{ 98 local s="$1" 99 local f=${s%*[0-9a-f]} n=${s#[0-9a-f]*} 100 101 echo $(($(_h2d $f)*16+ $(_h2d $n) )) 102} 103 104_h2d() 105{ 106 case $1 in 107 [0-9]) echo -n $1;; 108 a) echo -n 10;; 109 b) echo -n 11;; 110 c) echo -n 12;; 111 d) echo -n 13;; 112 e) echo -n 14;; 113 f) echo -n 15;; 114 esac 115} 116 117unt() 118{ 119 # XXX pdksh can't seem to deal with locally scoped variables 120 # in ${foo#$bar} expansions 121 arg="{-$-}1" 122 tmp="${arg#[a-zA-Z]*}" 123 tmp="${tmp%*[a-zA-Z]}" 124 while [ "$tmp" != "$arg" ] 125 do 126 arg=$tmp 127 tmp="${arg#[a-zA-Z]*}" 128 tmp="${tmp%*[a-zA-Z]}" 129 done 130 echo $arg 131} 132dnl 133dnl dodisk(name, unit, blkmaj, chrmaj, unit, off[, stepping]) 134dnl arg: 1 2 3 4 5 6 7 135dnl 136 137dodisk() 138{ 139 [ "$DEBUG" ] && set -x 140 n=Add(Mult(${5}, ${7:-16}), ${6}) count=0 141 [ 0$7 -ne 8 ] && l="i j k l m n o p" 142 for d in a b c d e f g h $l 143 do 144 M {-$-}1{-$-}2$d b {-$-}3 Add($n, $count) 640 operator 145 M r{-$-}1{-$-}2$d c {-$-}4 Add($n, $count) 640 operator 146 let count=count+1 147 done 148} 149dnl 150dnl dodisk2(name, unit, blkmaj, chrmaj, unit, off[, stepping]) 151dnl 152dnl 1. name - prefix name of the device 153dnl 2. unit - beginning unit number for block devices 154dnl 3. blkmaj - block device major number 155dnl 4. chrmaj - character device major number 156dnl 5. unit - beginning unit number for character devices 157dnl 6. off - offset from 0 for all minor numbers (see svnd for an example) 158dnl 7. step - optional, defaults to 16, number of partitions per device 159dnl 160 161dodisk2() 162{ 163 n=Add(Mult({-$-}5, ${7:-16}), {-$-}6) 164 M {-$-}1{-$-}2a b {-$-}3 $n 640 operator 165 M r{-$-}1{-$-}2a c {-$-}4 $n 640 operator 166 n=Add($n, 2) 167 M {-$-}1{-$-}2c b {-$-}3 $n 640 operator 168 M r{-$-}1{-$-}2c c {-$-}4 $n 640 operator 169} 170 171# M name b/c major minor [mode] [group] 172RMlist="rm -f" 173MKlist=":" 174 175mkl() { 176dnl 177dnl uncomment if multi mknod happens 178dnl 179ifelse(1, 0, 180[ "${mklist[{-$-}1]}" ] && mklist[{-$-}1]="${mklist[{-$-}1]} {-$-}2 {-$-}3 {-$-}4 {-$-}5" || { 181 mklist[{-$-}1]="mknod -m {-$-}1 {-$-}2 {-$-}3 {-$-}4 {-$-}5" 182 modes="$modes {-$-}1" 183 }, 184dnl 185dnl non multi mknod 186dnl 187 [ "${mklist[{-$-}1]}" ] && { 188 mklist[{-$-}1]="${mklist[{-$-}1]};mknod -m {-$-}1 {-$-}2 {-$-}3 {-$-}4 {-$-}5" 189 } || { 190 mklist[{-$-}1]="mknod -m {-$-}1 {-$-}2 {-$-}3 {-$-}4 {-$-}5" 191 modes="$modes {-$-}1" 192 }) 193} 194 195M() { 196 RMlist="$RMlist {-$-}1" 197 mkl ${5-666} {-$-}1 {-$-}2 {-$-}3 {-$-}4 198 G={-$-}{6:-wheel} 199 [ "{-$-}7" ] && { 200 MKlist="$MKlist;chown {-$-}7:{-$-}G {-$-}1" 201 } || { 202 case $G in 203 wheel)g=0;;kmem)g=2;;operator)g=5;;tty)g=4;;dialer)g=117;;_lkm)g=61;; 204 esac 205 [ "${grplist[$g]}" ] && { 206 grplist[$g]="${grplist[$g]} {-$-}1" 207 } || { 208 groups="$groups $g" 209 grplist[$g]="chgrp $G {-$-}1" 210 } 211 } 212 return 0 213} 214divert(7)dnl 215dnl 216dnl there is no blank line at the end of etc.arch/MAKEDEV.md files, so add one 217dnl on the following line: 218 219show_devs()dnl 220dnl 221divert(9)dnl 222*) 223 echo $i: unknown device 224 ;; 225esac 226done 227} 228_recurse "$@" 229list="$RMlist" 230for mode in $modes; do 231 list="$list;${mklist[$mode]}" 232done 233for group in $groups; do 234 list="$list;${grplist[$group]}" 235done 236list="$list;$MKlist" 237if [ "$eo" = "echo" ]; then 238 $eo "$list" 239else 240 echo "$list" | sh 241fi 242divert(3)dnl 243dnl 244 245R() { 246[ "$DEBUG" ] && set -x 247for i in "$@" 248do 249U=`unt $i` 250[ "$U" ] || U=0 251 252case $i in 253dnl 254