Date: Mon, 27 Jan 1997 16:44:28 +0900 (JST) From: hosokawa@mt.cs.keio.ac.jp (HOSOKAWA Tatsumi) To: config@freebsd.org Subject: kerenl config language (pseudo code sample) Message-ID: <199701270744.QAA15364@lenlen.mt.cs.keio.ac.jp>
next in thread | raw e-mail | index | archive | help
I wrote a basic idea of new kernel config language. yacc spec (not tested), and sample config (part of LINT) follows. Please make comments: yacc spec --------------------------------------------------------------BEGIN /* * pseudo-yacc code for FreeBSD kernel configuration language * Tatsumi Hosokawa <hosokawa@jp.FreeBSD.org> */ config.list : config.list config | config ; config : config.group | config.select | machine | options | pseudodevice | device | controller ; config.group : 'group' string.list '{' group '}' ';' ; group : /* empty */ | description | config.list ; /* * "select" can be expressed as "exclude" options, but it forces tree * structure for dependency graph. If the dependency graph can't * be mapped onto tree structure, please use "exclude" option. */ config.select : 'select' string.list '{' select '}' ';' ; select : /* empty */ | description | config.list ; machine : 'machine' '{' machine.decl.list '}' ; machine.decl.list : machine.decl.list machine.decl | machine.decl ; machine.decl : cpu.decl | maxusers.decl | appearance | description | kernel ; cpu.decl : 'cpu' string.list cpu.option ';' ; cpu.options : /* empty */ | '{' cpu.option.list '}' ; cpu.option.list : cpu.option.list cpu.option ; cpu.option : /* empty */ | description | appearance ; maxusers.decl : 'maxusers' numeric.variable maxuser.options ';' ; maxuser.options : /* empty */ | '{' maxuser.option.list '}' ; maxuser.option.list : maxuser.option.list maxuser.option | maxuser.option ; maxuser.option : /* empty */ | description ; kernel : 'config' kernel.name kernel.options ; kernel.options : /* empty */ | '{' kernel.option.list '}' ; kernel.option.list : kernel.option.list kernel.option | kernel.option ; kernel.option : /* empty */ | root.on | dumps.on | description | appearance ; root.on : 'rooton' variable root.on.options ';' ; root.on.options : /* empty */ | '{' root.on.option.list '}' ; root.on.option.list : root.on.option.list root.on.option | root.on.option ; root.on.option : /* empty */ | description ; dumps.on : 'dumpson' variable dumps.on.options ';' ; dumps.on.options : /* empty */ | '{' dumps.on.option.list '}' ; dumps.on.option.list : dumps.on.option.list dumps.on.option | dumps.on.option ; dumps.on.option : /* empty */ | description ; options : 'options' string.list options.options ';' ; options.options | /* empty */ : '{' options.option.list '}' ; options.option.list : options.option.list options.option | options.option ; options.option : /* empty */ | description | dependency | headers | files | manref | options.value | appearance | section ; dependency : requires | excludes ; requires : 'requires' '{' conditional.list '}' ';' | 'requires' conditional ';' ; excludes : 'excludes' '{' conditional.list '}' | 'excludes' conditional ';' ; conditional.list : conditional conditional.list | conditional ; conditional : option.conditioal | pseudodevice.conditional | device.conditional | controller.conditional | machine.conditional | cpu.conditional ; option.conditional : 'option' string.list ';' ; pseudodevice.conditional : 'pseudodevice' string.list ';' ; device.conditional : 'device' string.list ';' ; controller.conditional : 'controller' string.list ';' ; machine.conditional : 'machine' string.list ';' ; cpu.conditional : 'cpu' string.list ';' ; pseudodevice : 'pseudodevice" string.list pseudodevice.options ';' ; pseudodevice.options : /* empty */ | '{' pseudodevice.option.list '}' ; pseudodevice.option.list : pseudodevice.option.list pseudodevice.option | pseudodevice.option ; pseudodevice.option : /* empty */ | pseudodevice.number | description | section ; pseudodevice.number : 'number' number ';' ; device : 'device' string.list device.options ';' ; device.options : /* empty */ | '{' device.option.list '}' ; device.option.list : device.option.list device.option | device.option ; device.option : /* empty */ | description | files | headers | manref | device.flag | device.vector | device.bus | device.iosize | device.priority | section | device.instance ; device.flag : 'flag' '{' device.flag.option.list '}' ';' ; device.flag.option.list : device.flag.option.list device.flag.option | device.flag.option ; device.flag.option : device.flag.mask | device.flag.value | description ; device.flag.mask : 'mask' number ';' ; device.flag.value : 'value' variable ';' ; device.vector : 'vector' string.list ';' ; device.bus : 'bus' string.list ';' ; device.iosize : 'iosize' number ';' ; device.priority : 'priority' device.priority.unix ';' ; device.priority.unix : 'tty' | 'bio' | 'net' ; device.instance : 'instance' '(' device.instance.arg.list ')' device.instance.values ';' ; device.instance.arg.list : device.instance.arg.list ',' device.instance.arg | device.instance.arg ; device.instance.arg : 'ioaddr' | 'irq' | 'flags' | 'disabled' ; device.instance.values : /* empty */ | '{' device.instance.value.list '}' ; device.instance.value.list : device.instance.value.list device.instance.vaule | device.instance.value ; device.instance.value : device.instance.condition device.instance.number device.instance.value.elements ; device.instance.condition : 'default' | 'in' appearance.condition ; device.instance.number : /* empty */ | number ; device.instance.value.elements : device.instance.value.element | '{' device.instance.value.element.list '}' ; device.instance.value.element.list : device.instance.value.element.list device.instance.value.element | device.instance.value.element ; device.instance.value.element : '(' device.instance.value.element.arg.list ')' ; device.instance.value.element.arg.list : device.instance.value.element.arg.list ',' device.instance.value.element.arg | device.instance.value.element.arg ; device.instance.value.element.arg : number | string.list ; description : 'description' string.list ';' ; files : 'files' string.list ';' ; headers : 'headers' string.list ';' ; manref : 'manref' string.list ';' ; options.value : 'value' variable ';' ; appearance : 'appear' appearance.condition appear.as.comment ';' ; appearance.condition : 'generic' | 'lint' /* if lint == default */ | string.list ; appear.as.comment : /* empty */ | 'comment' ; section : 'section' string.list ';' ; string.list : string.list string | string ; variable : condition.variable | '{' variable.list '}' variable.list : variable.list condition.variable | condition.variable ; condition.variable : /* empty: default = 1 */ | 'default' variable.value ';' | 'in' appearance.condition variable.value ';' ; variable.value : string.list | number | 'disappear' ; string : /* definition of ".......string........" */ ; number : /* decimal, octal, hexadecimal */ ; constant.number : /* definition of constant term (ex.: (128*1024)) */ ; yacc spec ----------------------------------------------------------------END sample config ---------------------------------------------------------BEGIN /* * sample definition file for FreeBSD kernel configuration language * Tatsumi Hosokawa <hosokawa@jp.FreeBSD.org> */ #include <i386/isa/isaparam.h> #include <i386/eisa/eisaparam.h> #include <pci/pciparam.h> #define DISABLED 1 /* i386 PC architecuture */ machine "i386" { description "This directive is mandatory; it defines the" "architecture to be configured for; in this case, the" "386 family. You must also specify at least one CPU" "(the one you intend to run on); deleting the" "specification for CPUs you don't need to use may make" "parts of the system run faster. This is especially" "true removing I386_CPU."; appear generic; /* i386 family */ cpu "I386_CPU" { appear generic; }; cpu "I486_CPU" { appear generic; }; cpu "I586_CPU" { appear generic; description "aka Pentium(tm)"; }; cpu "I686_CPU" { appear generic; description "aka Pentium Pro(tm)"; }; /* maxuser definition */ maxusers default "10" { description "The `maxusers' parameter controls the static" "sizing of a number of internal system tables" "by a complicated formula defined in param.c."; }; }; options "CHILD_MAX" { description "Under some circumstances it is convenient to increase" "the defaults for the maximum number of processes per" "user and the maximum number of open files files per" "user. E.g., (1) in a large news server, user `news'" "may need more than 100 concurrent processes. (2) a" "user may need lots of windows under X. In both cases," "it may be inconvenient to start all the processes from" "a parent whose soft rlimit on the number of processes" "is large enough. The following options work by" "changing the soft rlimits for init."; value default 128; section "PARAMS"; }; options "OPEN_MAX" { description "Under some circumstances it is convenient to increase" "the defaults for the maximum number of processes per" "user and the maximum number of open files files per" "user. E.g., (1) in a large news server, user `news'" "may need more than 100 concurrent processes. (2) a" "user may need lots of windows under X. In both cases," "it may be inconvenient to start all the processes from" "a parent whose soft rlimit on the number of processes" "is large enough. The following options work by" "changing the soft rlimits for init."; value default 128; section "PARAMS"; }; options "MAXDSIZ" { description "Certain applications can grow to be larger than the" "128M limit that FreeBSD initially imposes. Below are" "some options to allow that limit to grow to 256MB, and" "can be increased further with changing the parameters." "MAXDSIZ is the maximum that the limit can be set to," "and the DFLDSIZ is the default value for the limit." "You might want to set the default lower than the max," "and explicitly set the maximum with a shell command" "for processes that regularly exceed the limit like" "INND."; value default "(256*1024*1024)"; section "PARAMS"; }; options "DFLDSIZ" { description "Certain applications can grow to be larger than the" "128M limit that FreeBSD initially imposes. Below are" "some options to allow that limit to grow to 256MB, and" "can be increased further with changing the parameters." "MAXDSIZ is the maximum that the limit can be set to," "and the DFLDSIZ is the default value for the limit." "You might want to set the default lower than the max," "and explicitly set the maximum with a shell command" "for processes that regularly exceed the limit like" "INND."; value default "(256*1024*1024)"; section "PARAMS"; }; options "EXTRAVNODES" { description "Under some circumstances it is useful to have an extra" "number of vnode data structures allocated at boot" "time. In particular, usenet news servers can benefit" "if there are enough vnodes to cache the busiest" "newsgroup and overview directories. Beware that this" "is an expensive option, it consumes physical" "non-pageable ram. A busy news server may benefit from" "10,000 extra vnodes or so."; value default 1; section "PARAMS"; }; /* FPU emulators */ select "FPU_EMULATORS" { description "A math emulator is mandatory if you wish to run on" "hardware which does not have a floating-point" "processor. Pick either the original, bogus (but" "freely-distributable) math emulator, or a much more" "fully-featured but GPL-licensed emulator taken from Linux."; options "MATH_EMULATE" { appear generic; description "Support for x87 emulation"; #ifdef notyet headers "...."; files "...."; #endif } options "GPL_MATH_EMULATE" { appear generic comment; description "Support for x87 emulation via new math emulator"; #ifdef notyet headers "...."; files "...."; #endif }; section "FPUEMUL"; }; options "FAILSAFE" { description "When this is set, be extra conservative in various" "parts of the kernel and choose functionality over" "speed (on the widest variety of systems)."; appear generic; #ifdef notyet headers "...."; files "...."; #endif section "PARAMS"; }; config "kernel" { rooton { default "wd0"; }; dumpson { in lint "wd0"; default disappear; }; }; options "COMPAT_43" { description "Implement system calls compatible with 4.3BSD and" "older versions of FreeBSD. You probably do NOT want" "to remove this as much current code still relies on" "the 4.3 emulation."; appear generic; section "COMPAT"; }; options "USER_LDT" { description "Allow user-mode programs to manipulate their local" "descriptor tables. This option is required for the" "WINE Windows(tm) emulator, and is not used by anything" "else (that we know of)."; #ifdef notyet headers "...."; files "...."; #endif requires machine "i386"; section "I386"; }; group "MIT_SHM" { description "These three options provide support for System V" "Interface Definition-style interprocess communication," "in the form of shared memory, semaphores, and message" "queues, respectively."; options "SYSVSHM" { #ifdef notyet headers "...."; files "...."; #endif }; options "SYSVSEM" { #ifdef notyet headers "...."; files "...."; #endif }; options "SYSVMSG" { #ifdef notyet headers "...."; files "...."; #endif }; appear generic; section "COMPAT"; }; options "DDB" { description "Enable the kernel debugger."; manref "ddb(4)"; #ifdef notyet headers "...."; files "...."; #endif section "DEVEL"; }; options "DDB_UNATTENDED" { description "Don't drop into DDB for a panic. Intended for" "unattended operation where you may want to drop to DDB" "from the console, but still want the machine to" "recover from a panic "; requires options "DDB"; #ifdef notyet headers "...."; files "...."; #endif section "DEVEL"; }; options "KTRACE" { description "KTRACE enables the system-call tracing facility ktrace(2)"; manref "ktrace(2)"; #ifdef notyet headers "...."; files "...."; #endif section "DEVEL"; }; options "DIAGNOSTIC" { description "The DIAGNOSTIC option is used in a number of source" "files to enable extra sanity checking of internal" "structures. This support is not enabled by default" "because of the extra time it would take to check for" "these conditions, which can only occur as a result of" "programming errors."; section "DEVEL"; }; options "PERFMON" { description "PERFMON causes the driver for Pentium/Pentium Pro" "performance counters to be compiled. See perfmon(4)" "for more information. "; manref "perfmon(4)"; section "DEVEL"; }; options "UCONSOLE" { description "Allow ordinary users to take the console - this is" "useful for X."; section "PARAMS"; }; /* userconfig options */ options "USERCONFIG" { description "boot -c editor"; appear generic; section "CONFIG"; }; options "USERCONFIG_BOOT" { description "imply -c and parse info area"; requires options "USERCONFIG"; section "CONFIG"; }; options "VISUAL_USERCONFIG" { description "visual boot -c editor"; requires options "USERCONFIG"; appear generic; section "CONFIG"; }; /* networking options */ options "INET" { description "Internet communications protocols"; appear generic; section "NETOPT"; }; options "IPX" { description "IPX/SPX communications protocols"; section "NETOPT"; }; options "IPXIP" { description "IPX in IP encapsulation (not available)"; requires { options "INET"; options "IPX"; }; section "NETOPT"; }; options "IPTUNNEL" { description "IP in IPX encapsulation (not available)"; requires { options "INET"; options "IPX"; }; section "NETOPT"; }; options "IPXPRINTFS" { description "IPX/SPX Console Debugging Information"; requires { options "IPX"; }; value default 0; section "NETOPT"; }; options "IPXERRPRINTFS" { description "IPX/SPX Console Debugging Information"; requires { options "IPX"; }; value default 0; section "NETOPT"; }; options "NETATALK" { description "Appletalk communications protocols"; section "NETOPT"; }; group "NET_BROKEN" { description "These are currently broken but are shipped due to interest."; options "NS" { description "Xerox NS protocols"; }; section "NETOPT"; }; group "NET_BROKEN_NOINTEREST" { description "These are currently broken and are no longer shipped" "due to lack of interest."; options "CCITT" { description "X.25 network layer"; } options "ISO"; options "TPIP" { description "ISO TP class 4 over IP"; requires options "ISO"; } options "TPCONS" { description "ISO TP class 0 over X.25"; requires options "ISO"; } options "LLC" { description "X.25 link layer for Ethernets"; } options "HDLC" { description "X.25 link layer for serial lines"; } options "EON" { description "ISO CLNP over IP"; requires { options "INET"; options "ISO"; } } options "NSIP" { description "XNS over IP"; requires { options "INET"; options "NS"; } } appear lint comment; section "NETOPT"; }; /* network interfaces */ pseudodevice "ether" { description "Generic Ethernet"; appear generic; section "NETOPT"; }; pseudodevice "fddi" { description "Generic FDDI"; section "NETOPT"; }; pseudodevice "sppp" { description "Generic Synchronous PPP"; section "NETOPT"; }; pseudodevice "loop" { description "Network loopback device"; section "NETOPT"; }; pseudodevice "sl" { description "Serial Line IP"; number 2; requires options "INET"; appear generic; section "NETOPT"; }; pseudodevice "ppp" { description "Point-to-point protocol"; number 2; appear generic; section "NETOPT"; }; pseudodevice "bpfilter" { description "Berkeley packet filter"; number 4; section "NETOPT"; }; pseudodevice "disc" { description "Discard device"; section "NETOPT"; }; pseudodevice "tun" { description "Tunnel driver(user process ppp)"; number 1; appear generic; section "NETOPT"; }; /* Internet family options*/ options "TCP_COMPAT_42" { description "emulate 4.2BSD TCP bugs"; requires options "INET"; section "INETOPT"; }; options "MROUTING" { description "Multicast routing"; requires options "INET"; section "INETOPT"; }; options "IPFIREWALL" { description "firewall"; requires options "INET"; section "INETOPT"; }; options "IPFIREWALL_VERBOSE" { description "print information about dropped packets"; requires options "IPFIREWALL"; section "INETOPT"; }; options "IPFIREWALL_VERBOSE_LIMIT" { description "limit verbosity"; requires options "IPFIREWALL_VERBOSE"; value default 100; section "INETOPT"; }; options "IPDIVERT" { description "divert socket"; requires options "IPFIREWALL"; section "INETOPT"; }; device "sio" { description "Serial driver for 8250/16x50 UARTs"; #ifdef notyet files i386/isa/sio.c; headers i386/isa/sioreg.h; headers i386/isa/ic/ns16550.h; headers i386/isa/ic/esp.h; #endif manref "sio(4)"; flag { mask 0x0001; value default 0; description "enable shared IRQ"; }; flag { mask 0x0002; value default 0; description "disable FIFO"; }; flag { mask 0x0004; value default 0; description "has AST/4 compatible IRQ control register"; }; flag { mask 0x0008; value default 0; description "fast recovery from lost output interrupts"; }; flag { mask 0x0080; value default 0; description "enable probe diagnostics"; }; flag { mask 0xff00; value default 0x00; description "device number of master port"; }; vector "siointr"; bus "isa"; iosize 8; priority tty; section "SERIAL"; instance (ioaddr, irq, flags, disabled) { in generic 4 { (IO_COM1, 4), (IO_COM2, 3), (IO_COM3, 5, 0, DISABLED), (IO_COM4, 9, 0, DISABLED), }; in lint (IO_COM1, 4); }; }; options "COMCONSOLE" { description "prefer serial console to video console"; requires device "sio"; section "SERIAL"; section "CONFIG"; }; options "COM_ESP" { description "code for Hayes ESP"; requires device "sio"; section "SERIAL"; }; options "COM_MULTIPORT" { description "code for DSI Softmodems"; requires device "sio"; section "SERIAL"; }; options "BREAK_TO_DEBUGGER" { description "a BREAK on a comconsole goes to DDB, if available"; requires { device "sio"; options "COMCONSOLE"; options "DDB"; } section "SERIAL"; }; sample config -----------------------------------------------------------END -- HOSOKAWA, Tatsumi hosokawa@mt.cs.keio.ac.jp hosokawa@jp.FreeBSD.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199701270744.QAA15364>