From c4e86a1a125c01884e3e90a460dea66af697d79d Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Mon, 1 Jun 2015 17:19:20 -0700 Subject: [PATCH 1/8] Sources of kernel config utility imported from LiteBSD. --- tools/kconfig/Makefile | 12 + tools/kconfig/config.8 | 174 ++++++ tools/kconfig/config.h | 231 ++++++++ tools/kconfig/config.y | 1121 ++++++++++++++++++++++++++++++++++ tools/kconfig/lang.l | 221 +++++++ tools/kconfig/main.c | 265 +++++++++ tools/kconfig/mkglue.c | 403 +++++++++++++ tools/kconfig/mkheaders.c | 207 +++++++ tools/kconfig/mkioconf.c | 1154 ++++++++++++++++++++++++++++++++++++ tools/kconfig/mkmakefile.c | 628 ++++++++++++++++++++ tools/kconfig/mkswapconf.c | 217 +++++++ tools/kconfig/mkubglue.c | 196 ++++++ 12 files changed, 4829 insertions(+) create mode 100644 tools/kconfig/Makefile create mode 100644 tools/kconfig/config.8 create mode 100644 tools/kconfig/config.h create mode 100644 tools/kconfig/config.y create mode 100644 tools/kconfig/lang.l create mode 100644 tools/kconfig/main.c create mode 100644 tools/kconfig/mkglue.c create mode 100644 tools/kconfig/mkheaders.c create mode 100644 tools/kconfig/mkioconf.c create mode 100644 tools/kconfig/mkmakefile.c create mode 100644 tools/kconfig/mkswapconf.c create mode 100644 tools/kconfig/mkubglue.c diff --git a/tools/kconfig/Makefile b/tools/kconfig/Makefile new file mode 100644 index 0000000..fa710fa --- /dev/null +++ b/tools/kconfig/Makefile @@ -0,0 +1,12 @@ +# @(#)Makefile 8.1 (Berkeley) 6/6/93 + +PROG= config +CFLAGS+=-I. -I${.CURDIR} +SRCS= config.c main.c lang.c mkioconf.c mkmakefile.c mkglue.c mkheaders.c \ + mkswapconf.c +MAN8= config.0 +DPADD= ${LIBL} +LDADD= -ll +CLEANFILES+=y.tab.h lang.c config.c y.tab.c config.0 + +.include diff --git a/tools/kconfig/config.8 b/tools/kconfig/config.8 new file mode 100644 index 0000000..aef26a2 --- /dev/null +++ b/tools/kconfig/config.8 @@ -0,0 +1,174 @@ +.\" Copyright (c) 1980, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)config.8 8.2 (Berkeley) 4/19/94 +.\" +.Dd April 19, 1994 +.Dt CONFIG 8 +.Os BSD 4 +.Sh NAME +.Nm config +.Nd build system configuration files +.Sh SYNOPSIS +.Nm config +.Op Fl p +.Ar system_name +.Sh DESCRIPTION +.Pp +This is the old version of the +.Nm config +program. +It understands the old autoconfiguration scheme +used on the HP300, DECstation, and derivative platforms. +The new version of config is used with the +SPARC and i386 platforms. +Only the version of +.Nm config +applicable to the architecture that you are running +will be installed on your machine. +.Pp +.Nm Config +builds a set of system configuration files from the file +.Ar SYSTEM_NAME +which describes +the system to configure. +A second file +tells +.Nm config +what files are needed to generate a system and +can be augmented by configuration specific set of files +that give alternate files for a specific machine. +(see the +.Sx FILES +section below) +.Pp +Available option and operand: +.Pp +.Bl -tag -width SYSTEM_NAME +.It Fl p +If the +.Fl p +option is supplied, +.Nm config +will configure a system for profiling; for example, +.Xr kgmon 8 +and +.Xr gprof 1 . +.It Ar SYSTEM_NAME +specifies the name of the system configuration file +containing device specifications, configuration options +and other system parameters for one system configuration. +.El +.Pp +.Nm Config +should be run from the +.Pa conf +subdirectory of the system source (usually +.Pa /sys/conf ) . +.Nm Config +assumes the directory +.Pa ../SYSTEM_NAME +exists and places all output files there. +The output of +.Nm config +consists of a number of files; for the +.Tn VAX , +they are: +.Pa ioconf.c , +a description +of what I/O devices are attached to the system; +.Pa ubglue.s , +a set of interrupt service routines for devices +attached to the +.Tn UNIBUS ; +.Pa ubvec.s , +offsets into a structure used for counting per-device interrupts; +.Pa Makefile , +used by +.Xr make 1 +in building the system; +header files, +definitions of +the number of various devices that will be compiled into the system; +swap configuration files, +definitions for +the disk areas to be used for swapping, the root file system, +argument processing, and system dumps. +.Pp +After running +.Nm config , +it is necessary to run +.Dq Li make depend +in the directory where the new makefile +was created. +.Nm Config +prints a reminder of this when it completes. +.Pp +If any other error messages are produced by +.Nm config , +the problems in the configuration file should be corrected and +.Nm config +should be run again. +Attempts to compile a system that had configuration errors +are likely to fail. +.Sh FILES +.Bl -tag -width /sys/conf/Makefile.vax -compact +.It Pa /sys/conf/Makefile.vax +generic makefile for the +.Tn VAX +.It Pa /sys/conf/files +list of common files system is built from +.It Pa /sys/conf/files.vax +list of +.Tn VAX +specific files +.It Pa /sys/conf/devices.vax +name to major device mapping file for the +.Tn VAX +.It Pa /sys/conf/files. Ns Em ERNIE +list of files specific to +.Em ERNIE +system +.El +.Sh SEE ALSO +The SYNOPSIS portion of each device in section 4. +.Rs +.%T "Building 4.3 BSD UNIX System with Config" +.Re +.sp +.Xr config.new 8 +.Sh BUGS +The line numbers reported in error messages are usually off by one. +.Sh HISTORY +The +.Nm +command appeared in +.Bx 4.1 . diff --git a/tools/kconfig/config.h b/tools/kconfig/config.h new file mode 100644 index 0000000..f801e3d --- /dev/null +++ b/tools/kconfig/config.h @@ -0,0 +1,231 @@ +/* + * Copyright (c) 1980, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)config.h 8.1 (Berkeley) 6/6/93 + */ + +/* + * Config. + */ +#include +#include +#include + +#define NODEV ((dev_t)-1) + +struct file_list { + struct file_list *f_next; + char *f_fn; /* the name */ + u_char f_type; /* see below */ + u_char f_flags; /* see below */ + char *f_special; /* special make rule if present */ + char *f_needs; + /* + * Random values: + * swap space parameters for swap areas + * root device, etc. for system specifications + */ + union { + struct { /* when swap specification */ + dev_t fuw_swapdev; + int fuw_swapsize; + int fuw_swapflag; + } fuw; + struct { /* when system specification */ + dev_t fus_rootdev; + dev_t fus_dumpdev; + } fus; + struct { /* when component dev specification */ + dev_t fup_compdev; + int fup_compinfo; + } fup; + } fun; +#define f_swapdev fun.fuw.fuw_swapdev +#define f_swapsize fun.fuw.fuw_swapsize +#define f_swapflag fun.fuw.fuw_swapflag +#define f_rootdev fun.fus.fus_rootdev +#define f_dumpdev fun.fus.fus_dumpdev +#define f_compdev fun.fup.fup_compdev +#define f_compinfo fun.fup.fup_compinfo +}; + +/* + * Types. + */ +#define DRIVER 1 +#define NORMAL 2 +#define INVISIBLE 3 +#define PROFILING 4 +#define SYSTEMSPEC 5 +#define SWAPSPEC 6 +#define COMPDEVICE 7 +#define COMPSPEC 8 + +/* + * Attributes (flags). + */ +#define CONFIGDEP 1 + +struct idlst { + char *id; + struct idlst *id_next; +}; + +struct device { + int d_type; /* CONTROLLER, DEVICE, bus adaptor */ + struct device *d_conn; /* what it is connected to */ + char *d_name; /* name of device (e.g. rk11) */ + struct idlst *d_vec; /* interrupt vectors */ + int d_pri; /* interrupt priority */ + int d_addr; /* address of csr */ + int d_unit; /* unit number */ + int d_drive; /* drive number */ + int d_slave; /* slave number */ +#define QUES -1 /* -1 means '?' */ +#define UNKNOWN -2 /* -2 means not set yet */ + int d_dk; /* if init 1 set to number for iostat */ + int d_flags; /* flags for device init */ + char *d_port; /* io port base manifest constant */ + int d_portn; /* io port base (if number not manifest) */ + char *d_mask; /* interrupt mask */ + int d_maddr; /* io memory base */ + int d_msize; /* io memory size */ + int d_drq; /* DMA request */ + int d_irq; /* interrupt request */ + struct device *d_next; /* Next one in list */ +}; +#define TO_NEXUS (struct device *)-1 +#define TO_VBA (struct device *)-2 + +struct config { + char *c_dev; + char *s_sysname; +}; + +/* + * Config has a global notion of which machine type is + * being used. It uses the name of the machine in choosing + * files and directories. Thus if the name of the machine is ``vax'', + * it will build from ``Makefile.vax'' and use ``../vax/inline'' + * in the makerules, etc. + */ +int machine; +char *machinename; +#define MACHINE_VAX 1 +#define MACHINE_TAHOE 2 +#define MACHINE_HP300 3 +#define MACHINE_I386 4 +#define MACHINE_MIPS 5 +#define MACHINE_PMAX 6 +#define MACHINE_LUNA68K 7 +#define MACHINE_NEWS3400 8 +#define MACHINE_PIC32 9 + +/* + * For each machine, a set of CPU's may be specified as supported. + * These and the options (below) are put in the C flags in the makefile. + */ +struct cputype { + char *cpu_name; + struct cputype *cpu_next; +} *cputype; + +/* + * A set of options may also be specified which are like CPU types, + * but which may also specify values for the options. + * A separate set of options may be defined for make-style options. + */ +struct opt { + char *op_name; + char *op_value; + struct opt *op_next; +} *opt, *mkopt; + +char *ident; +char *ldscript; +char *ns(); +char *tc(); +char *qu(); +char *get_word(); +char *get_quoted_word(); +char *path(); +char *raise(); + +int do_trace; + +#if MACHINE_VAX +int seen_mba, seen_uba; +#endif +#if MACHINE_TAHOE +int seen_vba; +#endif +#if MACHINE_I386 +int seen_isa; +#endif +int seen_cd; + +struct device *connect(); +struct device *dtab; +dev_t nametodev(); +char *devtoname(); + +char errbuf[80]; +int yyline; + +struct file_list *ftab, *conf_list, **confp, *comp_list, **compp; + +int zone, hadtz; +int dst; +int hz; +int profiling; +int debugging; + +int maxusers; + +#define eq(a,b) (!strcmp(a,b)) + +void init_dev(register struct device *dp); +int yyparse(void); +void vax_ioconf(void); +void tahoe_ioconf(void); +void hp300_ioconf(void); +void i386_ioconf(void); +void pmax_ioconf(void); +void pic32_ioconf(void); +void news_ioconf(void); +void ubglue(void); +void vbglue(void); +void hpglue(void); +void vector(void); +void makefile(void); +void headers(void); +void swapconf(void); diff --git a/tools/kconfig/config.y b/tools/kconfig/config.y new file mode 100644 index 0000000..0998289 --- /dev/null +++ b/tools/kconfig/config.y @@ -0,0 +1,1121 @@ +%union { + char *str; + int val; + struct file_list *file; + struct idlst *lst; +} + +%token AND +%token ANY +%token ARGS +%token AT +%token BIO +%token COMMA +%token CONFIG +%token CONTROLLER +%token CPU +%token CSR +%token DEVICE +%token DISK +%token DRIVE +%token DRQ +%token DST +%token DUMPS +%token EQUALS +%token FLAGS +%token HZ +%token IDENT +%token INTERLEAVE +%token IOMEM +%token IOSIZ +%token IRQ +%token LDSCRIPT +%token MACHINE +%token MAJOR +%token MASTER +%token MAXUSERS +%token MINOR +%token MINUS +%token NET +%token NEXUS +%token ON +%token OPTIONS +%token MAKEOPTIONS +%token PORT +%token PRIORITY +%token PSEUDO_DEVICE +%token ROOT +%token SEMICOLON +%token SEQUENTIAL +%token SIZE +%token SLAVE +%token SWAP +%token TIMEZONE +%token TTY +%token TRACE +%token VECTOR + +%token ID +%token NUMBER +%token FPNUMBER + +%type Save_id +%type Opt_value +%type Dev +%type Id_list +%type optional_size +%type optional_sflag +%type device_name +%type major_minor +%type arg_device_spec +%type root_device_spec +%type dump_device_spec +%type swap_device_spec +%type comp_device_spec + +%{ + +/* + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)config.y 8.1 (Berkeley) 6/6/93 + */ + +#include "config.h" +#include +#include + +struct device cur; +struct device *curp = 0; +char *temp_id; +char *val_id; + +int yylex(void); +int finddev(dev_t dev); +void deverror(char *systemname, char *devtype); +int alreadychecked(dev_t dev, dev_t list[], dev_t *last); + +%} +%% +Configuration: + Many_specs + = { verifysystemspecs(); } + ; + +Many_specs: + Many_specs Spec + | + /* lambda */ + ; + +Spec: + Device_spec SEMICOLON + = { newdev(&cur); } | + Config_spec SEMICOLON + | + TRACE SEMICOLON + = { do_trace = !do_trace; } | + SEMICOLON + | + error SEMICOLON + ; + +Config_spec: + MACHINE Save_id + = { + if (!strcmp($2, "vax")) { + machine = MACHINE_VAX; + machinename = "vax"; + } else if (!strcmp($2, "tahoe")) { + machine = MACHINE_TAHOE; + machinename = "tahoe"; + } else if (!strcmp($2, "hp300")) { + machine = MACHINE_HP300; + machinename = "hp300"; + } else if (!strcmp($2, "i386")) { + machine = MACHINE_I386; + machinename = "i386"; + } else if (!strcmp($2, "mips")) { + machine = MACHINE_MIPS; + machinename = "mips"; + } else if (!strcmp($2, "pmax")) { + machine = MACHINE_PMAX; + machinename = "pmax"; + } else if (!strcmp($2, "pic32")) { + machine = MACHINE_PIC32; + machinename = "pic32"; + } else if (!strcmp($2, "luna68k")) { + machine = MACHINE_LUNA68K; + machinename = "luna68k"; + } else if (!strcmp($2, "news3400")) { + machine = MACHINE_NEWS3400; + machinename = "news3400"; + } else + yyerror("Unknown machine type"); + } | + CPU Save_id + = { + struct cputype *cp = + (struct cputype *)malloc(sizeof (struct cputype)); + cp->cpu_name = ns($2); + cp->cpu_next = cputype; + cputype = cp; + free(temp_id); + } | + OPTIONS Opt_list + | + MAKEOPTIONS Mkopt_list + | + IDENT ID + = { ident = ns($2); } | + LDSCRIPT ID + = { ldscript = ns($2); } | + System_spec + | + HZ NUMBER + = { hz = $2; }| + TIMEZONE NUMBER + = { zone = 60 * $2; check_tz(); } | + TIMEZONE NUMBER DST NUMBER + = { zone = 60 * $2; dst = $4; check_tz(); } | + TIMEZONE NUMBER DST + = { zone = 60 * $2; dst = 1; check_tz(); } | + TIMEZONE FPNUMBER + = { zone = $2; check_tz(); } | + TIMEZONE FPNUMBER DST NUMBER + = { zone = $2; dst = $4; check_tz(); } | + TIMEZONE FPNUMBER DST + = { zone = $2; dst = 1; check_tz(); } | + TIMEZONE MINUS NUMBER + = { zone = -60 * $3; check_tz(); } | + TIMEZONE MINUS NUMBER DST NUMBER + = { zone = -60 * $3; dst = $5; check_tz(); } | + TIMEZONE MINUS NUMBER DST + = { zone = -60 * $3; dst = 1; check_tz(); } | + TIMEZONE MINUS FPNUMBER + = { zone = -$3; check_tz(); } | + TIMEZONE MINUS FPNUMBER DST NUMBER + = { zone = -$3; dst = $5; check_tz(); } | + TIMEZONE MINUS FPNUMBER DST + = { zone = -$3; dst = 1; check_tz(); } | + MAXUSERS NUMBER + = { maxusers = $2; }; + +System_spec: + System_id System_parameter_list + = { checksystemspec(*confp); } + ; + +System_id: + CONFIG Save_id + = { mkconf($2); } + ; + +System_parameter_list: + System_parameter_list System_parameter + | System_parameter + ; + +System_parameter: + swap_spec + | root_spec + | dump_spec + | arg_spec + ; + +swap_spec: + SWAP optional_on swap_device_list + ; + +swap_device_list: + swap_device_list AND swap_device + | swap_device + ; + +swap_device: + swap_device_spec optional_size optional_sflag + = { mkswap(*confp, $1, $2, $3); } + ; + +swap_device_spec: + device_name + = { + struct file_list *fl = newflist(SWAPSPEC); + + if (eq($1, "generic")) + fl->f_fn = $1; + else { + fl->f_swapdev = nametodev($1, 0, 'b'); + fl->f_fn = devtoname(fl->f_swapdev); + } + $$ = fl; + } + | major_minor + = { + struct file_list *fl = newflist(SWAPSPEC); + + fl->f_swapdev = $1; + fl->f_fn = devtoname($1); + $$ = fl; + } + ; + +root_spec: + ROOT optional_on root_device_spec + = { + struct file_list *fl = *confp; + + if (fl && fl->f_rootdev != NODEV) + yyerror("extraneous root device specification"); + else + fl->f_rootdev = $3; + } + ; + +root_device_spec: + device_name + = { $$ = nametodev($1, 0, 'a'); } + | major_minor + ; + +dump_spec: + DUMPS optional_on dump_device_spec + = { + struct file_list *fl = *confp; + + if (fl && fl->f_dumpdev != NODEV) + yyerror("extraneous dump device specification"); + else + fl->f_dumpdev = $3; + } + + ; + +dump_device_spec: + device_name + = { $$ = nametodev($1, 0, 'b'); } + | major_minor + ; + +arg_spec: + ARGS optional_on arg_device_spec + = { yyerror("arg device specification obsolete, ignored"); } + ; + +arg_device_spec: + device_name + = { $$ = nametodev($1, 0, 'b'); } + | major_minor + ; + +major_minor: + MAJOR NUMBER MINOR NUMBER + = { $$ = makedev($2, $4); } + ; + +optional_on: + ON + | /* empty */ + ; + +optional_size: + SIZE NUMBER + = { $$ = $2; } + | /* empty */ + = { $$ = 0; } + ; + +optional_sflag: + SEQUENTIAL + = { $$ = 2; } + | /* empty */ + = { $$ = 0; } + ; + +device_name: + Save_id + = { $$ = $1; } + | Save_id NUMBER + = { + char buf[80]; + + (void) sprintf(buf, "%s%d", $1, $2); + $$ = ns(buf); free($1); + } + | Save_id NUMBER ID + = { + char buf[80]; + + (void) sprintf(buf, "%s%d%s", $1, $2, $3); + $$ = ns(buf); free($1); + } + ; + +Opt_list: + Opt_list COMMA Option + | + Option + ; + +Option: + Save_id + = { + struct opt *op = (struct opt *)malloc(sizeof (struct opt)); + op->op_name = ns($1); + op->op_next = opt; + op->op_value = 0; + opt = op; + free(temp_id); + } | + Save_id EQUALS Opt_value + = { + struct opt *op = (struct opt *)malloc(sizeof (struct opt)); + op->op_name = ns($1); + op->op_next = opt; + op->op_value = ns($3); + opt = op; + free(temp_id); + free(val_id); + } ; + +Opt_value: + ID + = { $$ = val_id = ns($1); } | + NUMBER + = { + char nb[16]; + (void) sprintf(nb, "%d", $1); + $$ = val_id = ns(nb); + } ; + + +Save_id: + ID + = { $$ = temp_id = ns($1); } + ; + +Mkopt_list: + Mkopt_list COMMA Mkoption + | + Mkoption + ; + +Mkoption: + Save_id EQUALS Opt_value + = { + struct opt *op = (struct opt *)malloc(sizeof (struct opt)); + op->op_name = ns($1); + op->op_next = mkopt; + op->op_value = ns($3); + mkopt = op; + free(temp_id); + free(val_id); + } ; + +Dev: + ID + = { $$ = ns($1); } + ; + +Device_spec: + DEVICE Dev_name Dev_info Int_spec + = { cur.d_type = DEVICE; } | + MASTER Dev_name Dev_info Int_spec + = { cur.d_type = MASTER; } | + DISK Dev_name Dev_info Int_spec + = { cur.d_dk = 1; cur.d_type = DEVICE; } | + CONTROLLER Dev_name Dev_info Int_spec + = { cur.d_type = CONTROLLER; } | + PSEUDO_DEVICE Init_dev Dev + = { + cur.d_name = $3; + cur.d_type = PSEUDO_DEVICE; + } | + PSEUDO_DEVICE Init_dev Dev NUMBER + = { + cur.d_name = $3; + cur.d_type = PSEUDO_DEVICE; + cur.d_slave = $4; + } | + PSEUDO_DEVICE Dev_name Cdev_init Cdev_info + = { + if (!eq(cur.d_name, "cd")) + yyerror("improper spec for pseudo-device"); + seen_cd = 1; + cur.d_type = DEVICE; + verifycomp(*compp); + }; + +Cdev_init: + /* lambda */ + = { mkcomp(&cur); }; + +Cdev_info: + optional_on comp_device_list comp_option_list + ; + +comp_device_list: + comp_device_list AND comp_device + | comp_device + ; + +comp_device: + comp_device_spec + = { addcomp(*compp, $1); } + ; + +comp_device_spec: + device_name + = { + struct file_list *fl = newflist(COMPSPEC); + + fl->f_compdev = nametodev($1, 0, 'c'); + fl->f_fn = devtoname(fl->f_compdev); + $$ = fl; + } + | major_minor + = { + struct file_list *fl = newflist(COMPSPEC); + + fl->f_compdev = $1; + fl->f_fn = devtoname($1); + $$ = fl; + } + ; + +comp_option_list: + comp_option_list comp_option + | + /* lambda */ + ; + +comp_option: + INTERLEAVE NUMBER + = { cur.d_pri = $2; } | + FLAGS NUMBER + = { cur.d_flags = $2; }; + +Dev_name: + Init_dev Dev NUMBER + = { + cur.d_name = $2; + if (eq($2, "mba")) + seen_mba = 1; + else if (eq($2, "uba")) + seen_uba = 1; + else if (eq($2, "vba")) + seen_vba = 1; + else if (eq($2, "isa")) + seen_isa = 1; + cur.d_unit = $3; + }; + +Init_dev: + /* lambda */ + = { init_dev(&cur); }; + +Dev_info: + Con_info Info_list + | + Info_list + | + /* lambda */ + ; + +Con_info: + AT Dev NUMBER + = { + if (eq(cur.d_name, "mba") || eq(cur.d_name, "uba")) { + (void) sprintf(errbuf, + "%s must be connected to a nexus", cur.d_name); + yyerror(errbuf); + } + cur.d_conn = connect($2, $3); + } | + AT NEXUS NUMBER + = { check_nexus(&cur, $3); cur.d_conn = TO_NEXUS; }; + +Info_list: + Info_list Info + | + /* lambda */ + ; + +Info: + CSR NUMBER + = { cur.d_addr = $2; } | + DRIVE NUMBER + = { cur.d_drive = $2; } | + SLAVE NUMBER + = { + if (cur.d_conn != 0 && cur.d_conn != TO_NEXUS && + cur.d_conn->d_type == MASTER) + cur.d_slave = $2; + else + yyerror("can't specify slave--not to master"); + } | + IRQ NUMBER + = { cur.d_irq = $2; } | + DRQ NUMBER + = { cur.d_drq = $2; } | + IOMEM NUMBER + = { cur.d_maddr = $2; } | + IOSIZ NUMBER + = { cur.d_msize = $2; } | + PORT device_name + = { cur.d_port = ns($2); } | + PORT NUMBER + = { cur.d_portn = $2; } | + TTY + = { cur.d_mask = "tty"; } | + BIO + = { cur.d_mask = "bio"; } | + NET + = { cur.d_mask = "net"; } | + FLAGS NUMBER + = { cur.d_flags = $2; }; + +Int_spec: + VECTOR Id_list + = { cur.d_vec = $2; } | + PRIORITY NUMBER + = { cur.d_pri = $2; } | + /* lambda */ + ; + +Id_list: + Save_id + = { + struct idlst *a = (struct idlst *)malloc(sizeof(struct idlst)); + a->id = $1; a->id_next = 0; $$ = a; + } | + Save_id Id_list = + { + struct idlst *a = (struct idlst *)malloc(sizeof(struct idlst)); + a->id = $1; a->id_next = $2; $$ = a; + }; + +%% + +void yyerror(s) + char *s; +{ + + fprintf(stderr, "config: line %d: %s\n", yyline + 1, s); +} + +/* + * return the passed string in a new space + */ +char * +ns(str) + register char *str; +{ + register char *cp; + + cp = malloc((unsigned)(strlen(str)+1)); + (void) strcpy(cp, str); + return (cp); +} + +/* + * add a device to the list of devices + */ +void newdev(dp) + register struct device *dp; +{ + register struct device *np; + + np = (struct device *) malloc(sizeof *np); + *np = *dp; + np->d_next = 0; + if (curp == 0) + dtab = np; + else + curp->d_next = np; + curp = np; +} + +/* + * note that a configuration should be made + */ +void mkconf(sysname) + char *sysname; +{ + register struct file_list *fl, **flp; + + fl = (struct file_list *) malloc(sizeof *fl); + fl->f_type = SYSTEMSPEC; + fl->f_needs = sysname; + fl->f_rootdev = NODEV; + fl->f_dumpdev = NODEV; + fl->f_fn = 0; + fl->f_next = 0; + for (flp = confp; *flp; flp = &(*flp)->f_next) + ; + *flp = fl; + confp = flp; +} + +struct file_list * +newflist(ftype) + u_char ftype; +{ + struct file_list *fl = (struct file_list *)malloc(sizeof (*fl)); + + fl->f_type = ftype; + fl->f_next = 0; + fl->f_swapdev = NODEV; + fl->f_swapsize = 0; + fl->f_needs = 0; + fl->f_fn = 0; + return (fl); +} + +/* + * Add a swap device to the system's configuration + */ +void mkswap(system, fl, size, flag) + struct file_list *system, *fl; + int size, flag; +{ + register struct file_list **flp; + char name[80]; + + if (system == 0 || system->f_type != SYSTEMSPEC) { + yyerror("\"swap\" spec precedes \"config\" specification"); + return; + } + if (size < 0) { + yyerror("illegal swap partition size"); + return; + } + /* + * Append swap description to the end of the list. + */ + flp = &system->f_next; + for (; *flp && (*flp)->f_type == SWAPSPEC; flp = &(*flp)->f_next) + ; + fl->f_next = *flp; + *flp = fl; + fl->f_swapsize = size; + fl->f_swapflag = flag; + /* + * If first swap device for this system, + * set up f_fn field to insure swap + * files are created with unique names. + */ + if (system->f_fn) + return; + if (eq(fl->f_fn, "generic")) + system->f_fn = ns(fl->f_fn); + else + system->f_fn = ns(system->f_needs); +} + +void mkcomp(dp) + register struct device *dp; +{ + register struct file_list *fl, **flp; + char buf[80]; + + fl = (struct file_list *) malloc(sizeof *fl); + fl->f_type = COMPDEVICE; + fl->f_compinfo = dp->d_unit; + fl->f_fn = ns(dp->d_name); + (void) sprintf(buf, "%s%d", dp->d_name, dp->d_unit); + fl->f_needs = ns(buf); + fl->f_next = 0; + for (flp = compp; *flp; flp = &(*flp)->f_next) + ; + *flp = fl; + compp = flp; +} + +void addcomp(compdev, fl) + struct file_list *compdev, *fl; +{ + register struct file_list **flp; + char name[80]; + + if (compdev == 0 || compdev->f_type != COMPDEVICE) { + yyerror("component spec precedes device specification"); + return; + } + /* + * Append description to the end of the list. + */ + flp = &compdev->f_next; + for (; *flp && (*flp)->f_type == COMPSPEC; flp = &(*flp)->f_next) + ; + fl->f_next = *flp; + *flp = fl; +} + +/* + * find the pointer to connect to the given device and number. + * returns 0 if no such device and prints an error message + */ +struct device * +connect(dev, num) + register char *dev; + register int num; +{ + register struct device *dp; + struct device *huhcon(); + + if (num == QUES) + return (huhcon(dev)); + for (dp = dtab; dp != 0; dp = dp->d_next) { + if ((num != dp->d_unit) || !eq(dev, dp->d_name)) + continue; + if (dp->d_type != CONTROLLER && dp->d_type != MASTER) { + (void) sprintf(errbuf, + "%s connected to non-controller", dev); + yyerror(errbuf); + return (0); + } + return (dp); + } + (void) sprintf(errbuf, "%s %d not defined", dev, num); + yyerror(errbuf); + return (0); +} + +/* + * connect to an unspecific thing + */ +struct device * +huhcon(dev) + register char *dev; +{ + register struct device *dp, *dcp; + struct device rdev; + int oldtype; + + /* + * First make certain that there are some of these to wildcard on + */ + for (dp = dtab; dp != 0; dp = dp->d_next) + if (eq(dp->d_name, dev)) + break; + if (dp == 0) { + (void) sprintf(errbuf, "no %s's to wildcard", dev); + yyerror(errbuf); + return (0); + } + oldtype = dp->d_type; + dcp = dp->d_conn; + /* + * Now see if there is already a wildcard entry for this device + * (e.g. Search for a "uba ?") + */ + for (; dp != 0; dp = dp->d_next) + if (eq(dev, dp->d_name) && dp->d_unit == -1) + break; + /* + * If there isn't, make one because everything needs to be connected + * to something. + */ + if (dp == 0) { + dp = &rdev; + init_dev(dp); + dp->d_unit = QUES; + dp->d_name = ns(dev); + dp->d_type = oldtype; + newdev(dp); + dp = curp; + /* + * Connect it to the same thing that other similar things are + * connected to, but make sure it is a wildcard unit + * (e.g. up connected to sc ?, here we make connect sc? to a + * uba?). If other things like this are on the NEXUS or + * if they aren't connected to anything, then make the same + * connection, else call ourself to connect to another + * unspecific device. + */ + if (dcp == TO_NEXUS || dcp == 0) + dp->d_conn = dcp; + else + dp->d_conn = connect(dcp->d_name, QUES); + } + return (dp); +} + +void init_dev(dp) + register struct device *dp; +{ + + dp->d_name = "OHNO!!!"; + dp->d_type = DEVICE; + dp->d_conn = 0; + dp->d_vec = 0; + dp->d_addr = dp->d_flags = dp->d_dk = 0; + dp->d_pri = -1; + dp->d_slave = dp->d_drive = dp->d_unit = UNKNOWN; + dp->d_port = (char *)0; + dp->d_portn = 0; + dp->d_irq = -1; + dp->d_drq = -1; + dp->d_maddr = 0; + dp->d_msize = 0; + dp->d_mask = "null"; +} + +/* + * make certain that this is a reasonable type of thing to connect to a nexus + */ +void check_nexus(dev, num) + register struct device *dev; + int num; +{ + + switch (machine) { + + case MACHINE_VAX: + if (!eq(dev->d_name, "uba") && !eq(dev->d_name, "mba") && + !eq(dev->d_name, "bi")) + yyerror("only uba's, mba's, and bi's should be connected to the nexus"); + if (num != QUES) + yyerror("can't give specific nexus numbers"); + break; + + case MACHINE_TAHOE: + if (!eq(dev->d_name, "vba")) + yyerror("only vba's should be connected to the nexus"); + break; + + case MACHINE_HP300: + case MACHINE_LUNA68K: + if (num != QUES) + dev->d_addr = num; + break; + + case MACHINE_I386: + if (!eq(dev->d_name, "isa")) + yyerror("only isa's should be connected to the nexus"); + break; + + case MACHINE_NEWS3400: + if (!eq(dev->d_name, "iop") && !eq(dev->d_name, "hb") && + !eq(dev->d_name, "vme")) + yyerror("only iop's, hb's and vme's should be connected to the nexus"); + break; + } +} + +/* + * Check the timezone to make certain it is sensible + */ +void check_tz() +{ + if (abs(zone) > 12 * 60) + yyerror("timezone is unreasonable"); + else + hadtz = 1; +} + +/* + * Check system specification and apply defaulting + * rules on root, argument, dump, and swap devices. + */ +void checksystemspec(fl) + register struct file_list *fl; +{ + char buf[BUFSIZ]; + register struct file_list *swap; + int generic; + + if (fl == 0 || fl->f_type != SYSTEMSPEC) { + yyerror("internal error, bad system specification"); + exit(1); + } + swap = fl->f_next; + generic = swap && swap->f_type == SWAPSPEC && eq(swap->f_fn, "generic"); + if (fl->f_rootdev == NODEV && !generic) { + yyerror("no root device specified"); + exit(1); + } + /* + * Default swap area to be in 'b' partition of root's + * device. If root specified to be other than on 'a' + * partition, give warning, something probably amiss. + */ + if (swap == 0 || swap->f_type != SWAPSPEC) { + dev_t dev; + + swap = newflist(SWAPSPEC); + dev = fl->f_rootdev; + if (minor(dev) & 07) { + (void) sprintf(buf, +"Warning, swap defaulted to 'b' partition with root on '%c' partition", + (minor(dev) & 07) + 'a'); + yyerror(buf); + } + swap->f_swapdev = + makedev(major(dev), (minor(dev) &~ 07) | ('b' - 'a')); + swap->f_fn = devtoname(swap->f_swapdev); + mkswap(fl, swap, 0, 0); + } + /* + * Make sure a generic swap isn't specified, along with + * other stuff (user must really be confused). + */ + if (generic) { + if (fl->f_rootdev != NODEV) + yyerror("root device specified with generic swap"); + if (fl->f_dumpdev != NODEV) + yyerror("dump device specified with generic swap"); + return; + } + /* + * Default dump device and warn if place is not a + * swap area. + */ + if (fl->f_dumpdev == NODEV) + fl->f_dumpdev = swap->f_swapdev; + if (fl->f_dumpdev != swap->f_swapdev) { + struct file_list *p = swap->f_next; + + for (; p && p->f_type == SWAPSPEC; p = p->f_next) + if (fl->f_dumpdev == p->f_swapdev) + return; + (void) sprintf(buf, + "Warning: dump device is not a swap partition"); + yyerror(buf); + } +} + +/* + * Verify all devices specified in the system specification + * are present in the device specifications. + */ +void verifysystemspecs() +{ + register struct file_list *fl; + dev_t checked[50], *verifyswap(); + register dev_t *pchecked = checked; + + for (fl = conf_list; fl; fl = fl->f_next) { + if (fl->f_type != SYSTEMSPEC) + continue; + if (!finddev(fl->f_rootdev)) + deverror(fl->f_needs, "root"); + *pchecked++ = fl->f_rootdev; + pchecked = verifyswap(fl->f_next, checked, pchecked); +#define samedev(dev1, dev2) \ + ((minor(dev1) &~ 07) != (minor(dev2) &~ 07)) + if (!alreadychecked(fl->f_dumpdev, checked, pchecked)) { + if (!finddev(fl->f_dumpdev)) + deverror(fl->f_needs, "dump"); + *pchecked++ = fl->f_dumpdev; + } + } +} + +/* + * Do as above, but for swap devices. + */ +dev_t * +verifyswap(fl, checked, pchecked) + register struct file_list *fl; + dev_t checked[]; + register dev_t *pchecked; +{ + + for (;fl && fl->f_type == SWAPSPEC; fl = fl->f_next) { + if (eq(fl->f_fn, "generic")) + continue; + if (alreadychecked(fl->f_swapdev, checked, pchecked)) + continue; + if (!finddev(fl->f_swapdev)) + fprintf(stderr, + "config: swap device %s not configured", fl->f_fn); + *pchecked++ = fl->f_swapdev; + } + return (pchecked); +} + +/* + * Verify that components of a compound device have themselves been config'ed + */ +void verifycomp(fl) + register struct file_list *fl; +{ + char *dname = fl->f_needs; + + for (fl = fl->f_next; fl; fl = fl->f_next) { + if (fl->f_type != COMPSPEC || finddev(fl->f_compdev)) + continue; + fprintf(stderr, + "config: %s: component device %s not configured\n", + dname, fl->f_needs); + } +} + +/* + * Has a device already been checked + * for it's existence in the configuration? + */ +int alreadychecked(dev, list, last) + dev_t dev, list[]; + register dev_t *last; +{ + register dev_t *p; + + for (p = list; p < last; p++) + if (samedev(*p, dev)) + return (1); + return (0); +} + +void deverror(systemname, devtype) + char *systemname, *devtype; +{ + + fprintf(stderr, "config: %s: %s device not configured\n", + systemname, devtype); +} + +/* + * Look for the device in the list of + * configured hardware devices. Must + * take into account stuff wildcarded. + */ +/*ARGSUSED*/ +int finddev(dev) + dev_t dev; +{ + + /* punt on this right now */ + return (1); +} diff --git a/tools/kconfig/lang.l b/tools/kconfig/lang.l new file mode 100644 index 0000000..802dd9b --- /dev/null +++ b/tools/kconfig/lang.l @@ -0,0 +1,221 @@ +%{ +/*- + * Copyright (c) 1980, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)lang.l 8.1 (Berkeley) 6/6/93 + */ + +#include +#include "y.tab.h" +#include "config.h" + +#define tprintf if (do_trace) printf + +/* + * Key word table + */ + +struct kt { + char *kt_name; + int kt_val; +} key_words[] = { + { "and", AND }, + { "args", ARGS }, + { "at", AT }, +#if MACHINE_I386 + { "bio", BIO }, +#endif + { "config", CONFIG }, + { "controller", CONTROLLER }, + { "cpu", CPU }, + { "csr", CSR }, + { "device", DEVICE }, + { "disk", DISK }, + { "drive", DRIVE }, +#if MACHINE_I386 + { "drq", DRQ }, +#endif + { "dst", DST }, + { "dumps", DUMPS }, + { "flags", FLAGS }, + { "hz", HZ }, + { "ident", IDENT }, + { "interleave", INTERLEAVE }, +#if MACHINE_I386 + { "iomem", IOMEM }, + { "iosiz", IOSIZ }, + { "irq", IRQ }, +#endif + { "ldscript", LDSCRIPT }, + { "machine", MACHINE }, + { "major", MAJOR }, + { "makeoptions", MAKEOPTIONS }, + { "master", MASTER }, + { "maxusers", MAXUSERS }, + { "minor", MINOR }, +#if MACHINE_I386 + { "net", NET }, +#endif + { "nexus", NEXUS }, + { "on", ON }, + { "options", OPTIONS }, +#if MACHINE_I386 + { "port", PORT }, +#endif + { "priority", PRIORITY }, + { "pseudo-device",PSEUDO_DEVICE }, + { "root", ROOT }, +#if MACHINE_HP300 || MACHINE_LUNA68K + { "scode", NEXUS }, +#endif + { "sequential", SEQUENTIAL }, + { "size", SIZE }, + { "slave", SLAVE }, + { "swap", SWAP }, + { "tape", DEVICE }, +#if MACHINE_I386 + { "tty", TTY }, +#endif + { "timezone", TIMEZONE }, + { "trace", TRACE }, + { "vector", VECTOR }, + { 0, 0 }, +}; + +int kw_lookup(char *word); +int octal(char *str); +int hex(char *str); +%} +WORD [A-Za-z_][-A-Za-z_]* +%% +{WORD} { + int i; + + if ((i = kw_lookup(yytext)) == -1) + { + yylval.str = yytext; + tprintf("id(%s) ", yytext); + return ID; + } + tprintf("(%s) ", yytext); + return i; + } +\"[^"]+\" { + yytext[strlen(yytext)-1] = '\0'; + yylval.str = yytext + 1; + return ID; + } +0[0-7]* { + yylval.val = octal(yytext); + tprintf("#O:%o ", yylval.val); + return NUMBER; + } +0x[0-9a-fA-F]+ { + yylval.val = hex(yytext); + tprintf("#X:%x ", yylval.val); + return NUMBER; + } +[1-9][0-9]* { + yylval.val = atoi(yytext); + tprintf("#D:%d ", yylval.val); + return NUMBER; + } +[0-9]"."[0-9]* { + double atof(); + yylval.val = (int) (60 * atof(yytext) + 0.5); + return FPNUMBER; + } +"-" { + return MINUS; + } +"?" { + yylval.val = -1; + tprintf("? "); + return NUMBER; + } +\n/[ \t] { + yyline++; + tprintf("\n... "); + } +\n { + yyline++; + tprintf("\n"); + return SEMICOLON; + } +#.* { /* Ignored (comment) */; } +[ \t]* { /* Ignored (white space) */; } +";" { return SEMICOLON; } +"," { return COMMA; } +"=" { return EQUALS; } +"@" { return AT; } +. { return yytext[0]; } + +%% +/* + * kw_lookup + * Look up a string in the keyword table. Returns a -1 if the + * string is not a keyword otherwise it returns the keyword number + */ +int +kw_lookup(word) +register char *word; +{ + register struct kt *kp; + + for (kp = key_words; kp->kt_name != 0; kp++) + if (eq(word, kp->kt_name)) + return kp->kt_val; + return -1; +} + +/* + * Number conversion routines + */ +int +octal(str) +char *str; +{ + int num; + + (void) sscanf(str, "%o", &num); + return num; +} + +int +hex(str) +char *str; +{ + int num; + + (void) sscanf(str+2, "%x", &num); + return num; +} diff --git a/tools/kconfig/main.c b/tools/kconfig/main.c new file mode 100644 index 0000000..8d04b76 --- /dev/null +++ b/tools/kconfig/main.c @@ -0,0 +1,265 @@ +/* + * Copyright (c) 1980, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char copyright[] = +"@(#) Copyright (c) 1980, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93"; +#endif /* not lint */ + +#include +#include +#include +#include +#include +#include +#include "y.tab.h" +#include "config.h" + +static char *PREFIX; + +/* + * Config builds a set of files for building a UNIX + * system given a description of the desired system. + */ +int main(argc, argv) + int argc; + char **argv; +{ + + extern char *optarg; + extern int optind; + struct stat buf; + int ch; + char *p; + + while ((ch = getopt(argc, argv, "gp")) != EOF) + switch (ch) { + case 'g': + debugging++; + break; + case 'p': + profiling++; + break; + case '?': + default: + goto usage; + } + argc -= optind; + argv += optind; + + if (argc != 1) { +usage: fputs("usage: config [-gp] sysname\n", stderr); + exit(1); + } + + if (freopen(PREFIX = *argv, "r", stdin) == NULL) { +fprintf(stderr, "--- PREFIX\n"); + perror(PREFIX); + exit(2); + } + mkdir("../../compile", 0777); + if (stat(p = path((char *)NULL), &buf)) { + if (mkdir(p, 0777)) { +fprintf(stderr, "--- mkdir path\n"); + perror(p); + exit(2); + } + } + else if ((buf.st_mode & S_IFMT) != S_IFDIR) { + fprintf(stderr, "config: %s isn't a directory.\n", p); + exit(2); + } + + dtab = NULL; + confp = &conf_list; + compp = &comp_list; + if (yyparse()) + exit(3); + switch (machine) { + + case MACHINE_VAX: + vax_ioconf(); /* Print ioconf.c */ + ubglue(); /* Create ubglue.s */ + break; + + case MACHINE_TAHOE: + tahoe_ioconf(); + vbglue(); + break; + + case MACHINE_HP300: + case MACHINE_LUNA68K: + hp300_ioconf(); + hpglue(); + break; + + case MACHINE_I386: + i386_ioconf(); /* Print ioconf.c */ + vector(); /* Create vector.s */ + break; + + case MACHINE_MIPS: + case MACHINE_PMAX: + pmax_ioconf(); + break; + + case MACHINE_PIC32: + pic32_ioconf(); + break; + + case MACHINE_NEWS3400: + news_ioconf(); + break; + + default: + printf("Specify machine type, e.g. ``machine vax''\n"); + exit(1); + } + makefile(); /* build Makefile */ + headers(); /* make a lot of .h files */ + swapconf(); /* swap config files */ + printf("Don't forget to run \"make depend\"\n"); + exit(0); +} + +/* + * get_word + * returns EOF on end of file + * NULL on end of line + * pointer to the word otherwise + */ +char * +get_word(fp) + register FILE *fp; +{ + static char line[80]; + register int ch; + register char *cp; + + while ((ch = getc(fp)) != EOF) + if (ch != ' ' && ch != '\t') + break; + if (ch == EOF) + return ((char *)EOF); + if (ch == '\n') + return (NULL); + cp = line; + *cp++ = ch; + while ((ch = getc(fp)) != EOF) { + if (isspace(ch)) + break; + *cp++ = ch; + } + *cp = 0; + if (ch == EOF) + return ((char *)EOF); + (void) ungetc(ch, fp); + return (line); +} + +/* + * get_quoted_word + * like get_word but will accept something in double or single quotes + * (to allow embedded spaces). + */ +char * +get_quoted_word(fp) + register FILE *fp; +{ + static char line[256]; + register int ch; + register char *cp; + + while ((ch = getc(fp)) != EOF) + if (ch != ' ' && ch != '\t') + break; + if (ch == EOF) + return ((char *)EOF); + if (ch == '\n') + return (NULL); + cp = line; + if (ch == '"' || ch == '\'') { + register int quote = ch; + + while ((ch = getc(fp)) != EOF) { + if (ch == quote) + break; + if (ch == '\n') { + *cp = 0; + printf("config: missing quote reading `%s'\n", + line); + exit(2); + } + *cp++ = ch; + } + } else { + *cp++ = ch; + while ((ch = getc(fp)) != EOF) { + if (isspace(ch)) + break; + *cp++ = ch; + } + if (ch != EOF) + (void) ungetc(ch, fp); + } + *cp = 0; + if (ch == EOF) + return ((char *)EOF); + return (line); +} + +/* + * prepend the path to a filename + */ +char * +path(file) + char *file; +{ + register char *cp; + +#define CDIR "../../compile/" + cp = malloc((unsigned int)(sizeof(CDIR) + strlen(PREFIX) + + (file ? strlen(file) : 0) + 2)); + (void) strcpy(cp, CDIR); + (void) strcat(cp, PREFIX); + if (file) { + (void) strcat(cp, "/"); + (void) strcat(cp, file); + } + return (cp); +} diff --git a/tools/kconfig/mkglue.c b/tools/kconfig/mkglue.c new file mode 100644 index 0000000..a94c1cd --- /dev/null +++ b/tools/kconfig/mkglue.c @@ -0,0 +1,403 @@ +/* + * Copyright (c) 1980, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)mkglue.c 8.1 (Berkeley) 6/6/93"; +#endif /* not lint */ + +/* + * Make the bus adaptor interrupt glue files. + */ +#include +#include "config.h" +#include "y.tab.h" +#include + +static int cntcnt = 0; /* number of interrupt counters allocated */ + +/* + * Print a UNIBUS interrupt vector. + */ +void dump_ubavec(fp, vector, number) + register FILE *fp; + char *vector; + int number; +{ + char nbuf[80]; + register char *v = nbuf; + + (void) sprintf(v, "%s%d", vector, number); + fprintf(fp, "\t.globl\t_X%s\n\t.align\t2\n_X%s:\n\tpushr\t$0x3f\n", + v, v); + fprintf(fp, "\tincl\t_fltintrcnt+(4*%d)\n", cntcnt++); + if (strncmp(vector, "dzx", 3) == 0) + fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdzdma\n\n", number); + else if (strncmp(vector, "dpx", 3) == 0) + fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdpxdma\n\n", number); + else if (strncmp(vector, "dpr", 3) == 0) + fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdprdma\n\n", number); + else { + if (strncmp(vector, "uur", 3) == 0) { + fprintf(fp, "#ifdef UUDMA\n"); + fprintf(fp, "\tmovl\t$%d,r0\n\tjsb\tuudma\n", number); + fprintf(fp, "#endif\n"); + } + fprintf(fp, "\tpushl\t$%d\n", number); + fprintf(fp, "\tcalls\t$1,_%s\n\tpopr\t$0x3f\n", vector); + fprintf(fp, "\tincl\t_cnt+V_INTR\n\trei\n\n"); + } +} + +static char *vaxinames[] = { + "clock", "cnr", "cnx", "tur", "tux", + "mba0", "mba1", "mba2", "mba3", + "uba0", "uba1", "uba2", "uba3" +}; + +static char *tahoeinames[] = { + "clock", "cnr", "cnx", "rmtr", "rmtx", "buserr", +}; + +static struct stdintrs { + char **si_names; /* list of standard interrupt names */ + int si_n; /* number of such names */ +} stdintrs[] = { + { vaxinames, sizeof (vaxinames) / sizeof (vaxinames[0]) }, + { tahoeinames, (sizeof (tahoeinames) / sizeof (tahoeinames[0])) } +}; + +/* + * Start the interrupt name table with the names + * of the standard vectors not directly associated + * with a bus. Also, dump the defines needed to + * reference the associated counters into a separate + * file which is prepended to locore.s. + */ +void dump_std(fp, gp) + register FILE *fp, *gp; +{ + register struct stdintrs *si = &stdintrs[machine-1]; + register char **cpp; + register int i; + + fprintf(fp, "\n\t.globl\t_intrnames\n"); + fprintf(fp, "\n\t.globl\t_eintrnames\n"); + fprintf(fp, "\t.data\n"); + fprintf(fp, "_intrnames:\n"); + cpp = si->si_names; + for (i = 0; i < si->si_n; i++) { + register char *cp, *tp; + char buf[80]; + + cp = *cpp; + if (cp[0] == 'i' && cp[1] == 'n' && cp[2] == 't') { + cp += 3; + if (*cp == 'r') + cp++; + } + for (tp = buf; *cp; cp++) + if (islower(*cp)) + *tp++ = toupper(*cp); + else + *tp++ = *cp; + *tp = '\0'; + fprintf(gp, "#define\tI_%s\t%d\n", buf, i * (int)sizeof (long)); + fprintf(fp, "\t.asciz\t\"%s\"\n", *cpp); + cpp++; + } +} + +void dump_intname(fp, vector, number) + register FILE *fp; + char *vector; + int number; +{ + register char *cp = vector; + + fprintf(fp, "\t.asciz\t\""); + /* + * Skip any "int" or "intr" in the name. + */ + while (*cp) + if (cp[0] == 'i' && cp[1] == 'n' && cp[2] == 't') { + cp += 3; + if (*cp == 'r') + cp++; + } else { + putc(*cp, fp); + cp++; + } + fprintf(fp, "%d\"\n", number); +} + +/* + * Reserve space for the interrupt counters. + */ +void dump_ctrs(fp) + register FILE *fp; +{ + struct stdintrs *si = &stdintrs[machine-1]; + + fprintf(fp, "_eintrnames:\n"); + fprintf(fp, "\n\t.globl\t_intrcnt\n"); + fprintf(fp, "\n\t.globl\t_eintrcnt\n"); + fprintf(fp, "\t.align 2\n"); + fprintf(fp, "_intrcnt:\n"); + fprintf(fp, "\t.space\t4 * %d\n", si->si_n); + fprintf(fp, "_fltintrcnt:\n"); + fprintf(fp, "\t.space\t4 * %d\n", cntcnt); + fprintf(fp, "_eintrcnt:\n\n"); + fprintf(fp, "\t.text\n"); +} + +/* + * Create the UNIBUS interrupt vector glue file. + */ +void ubglue() +{ + register FILE *fp, *gp; + register struct device *dp, *mp; + + fp = fopen(path("ubglue.s"), "w"); + if (fp == 0) { + perror(path("ubglue.s")); + exit(1); + } + gp = fopen(path("ubvec.s"), "w"); + if (gp == 0) { + perror(path("ubvec.s")); + exit(1); + } + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (mp != 0 && mp != (struct device *)-1 && + !eq(mp->d_name, "mba")) { + struct idlst *id, *id2; + + for (id = dp->d_vec; id; id = id->id_next) { + for (id2 = dp->d_vec; id2; id2 = id2->id_next) { + if (id2 == id) { + dump_ubavec(fp, id->id, + dp->d_unit); + break; + } + if (!strcmp(id->id, id2->id)) + break; + } + } + } + } + dump_std(fp, gp); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (mp != 0 && mp != (struct device *)-1 && + !eq(mp->d_name, "mba")) { + struct idlst *id, *id2; + + for (id = dp->d_vec; id; id = id->id_next) { + for (id2 = dp->d_vec; id2; id2 = id2->id_next) { + if (id2 == id) { + dump_intname(fp, id->id, + dp->d_unit); + break; + } + if (!strcmp(id->id, id2->id)) + break; + } + } + } + } + dump_ctrs(fp); + (void) fclose(fp); + (void) fclose(gp); +} + +/* + * Print a VERSAbus interrupt vector + */ +void dump_vbavec(fp, vector, number) + register FILE *fp; + char *vector; + int number; +{ + char nbuf[80]; + register char *v = nbuf; + + (void) sprintf(v, "%s%d", vector, number); + fprintf(fp, "SCBVEC(%s):\n", v); + fprintf(fp, "\tCHECK_SFE(4)\n"); + fprintf(fp, "\tSAVE_FPSTAT(4)\n"); + fprintf(fp, "\tPUSHR\n"); + fprintf(fp, "\tincl\t_fltintrcnt+(4*%d)\n", cntcnt++); + fprintf(fp, "\tpushl\t$%d\n", number); + fprintf(fp, "\tcallf\t$8,_%s\n", vector); + fprintf(fp, "\tincl\t_cnt+V_INTR\n"); + fprintf(fp, "\tPOPR\n"); + fprintf(fp, "\tREST_FPSTAT\n"); + fprintf(fp, "\trei\n\n"); +} + +/* + * Create the VERSAbus interrupt vector glue file. + */ +void vbglue() +{ + register FILE *fp, *gp; + register struct device *dp, *mp; + + fp = fopen(path("vbglue.s"), "w"); + if (fp == 0) { + perror(path("vbglue.s")); + exit(1); + } + gp = fopen(path("vbvec.s"), "w"); + if (gp == 0) { + perror(path("vbvec.s")); + exit(1); + } + for (dp = dtab; dp != 0; dp = dp->d_next) { + struct idlst *id, *id2; + + mp = dp->d_conn; + if (mp == 0 || mp == (struct device *)-1 || + eq(mp->d_name, "mba")) + continue; + for (id = dp->d_vec; id; id = id->id_next) + for (id2 = dp->d_vec; id2; id2 = id2->id_next) { + if (id == id2) { + dump_vbavec(fp, id->id, dp->d_unit); + break; + } + if (eq(id->id, id2->id)) + break; + } + } + dump_std(fp, gp); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (mp != 0 && mp != (struct device *)-1 && + !eq(mp->d_name, "mba")) { + struct idlst *id, *id2; + + for (id = dp->d_vec; id; id = id->id_next) { + for (id2 = dp->d_vec; id2; id2 = id2->id_next) { + if (id2 == id) { + dump_intname(fp, id->id, + dp->d_unit); + break; + } + if (eq(id->id, id2->id)) + break; + } + } + } + } + dump_ctrs(fp); + (void) fclose(fp); + (void) fclose(gp); +} + +/* + * HP9000/300 interrupts are auto-vectored. + * Code is hardwired in locore.s + */ +void hpglue() {} + +/* + * Create the ISA interrupt vector glue file. + */ +void vector() { + register FILE *fp, *gp; + register struct device *dp, *mp; + int count; + + fp = fopen(path("vector.s"), "w"); + if (fp == 0) { + perror(path("vector.s")); + exit(1); + } + fprintf(fp,"\ +/*\n\ + * AT/386\n\ + * Interrupt vector routines\n\ + * Generated by config program\n\ + */ \n\ +\n\ +#include \"i386/isa/isa.h\"\n\ +#include \"i386/isa/icu.h\"\n\ +\n\ +#define VEC(name) .align 4; .globl _V/**/name; _V/**/name:\n\n"); + + fprintf(fp,"\ + .globl _hardclock\n\ +VEC(clk)\n\ + INTR1(0, _highmask, 0)\n\ + call _hardclock \n\ + INTREXIT1\n\n\n"); + + count=0; + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (mp != 0 && /* mp != (struct device *)-1 &&*/ + eq(mp->d_name, "isa")) { + struct idlst *id, *id2; + + for (id = dp->d_vec; id; id = id->id_next) { + for (id2 = dp->d_vec; id2; id2 = id2->id_next) { + if (id2 == id) { + if(dp->d_irq == -1) continue; + fprintf(fp,"\t.globl _%s, _%s%dmask\n\t.data\n", + id->id, dp->d_name, dp->d_unit); + fprintf(fp,"_%s%dmask:\t.long 0\n\t.text\n", + dp->d_name, dp->d_unit); + fprintf(fp,"VEC(%s%d)\n\tINTR%d(%d, ", + dp->d_name, dp->d_unit, + dp->d_irq / 8 + 1, dp->d_unit); + if(eq(dp->d_mask,"null")) + fprintf(fp,"_%s%dmask, ", + dp->d_name, dp->d_unit); + else + fprintf(fp,"_%smask, ", + dp->d_mask); + fprintf(fp,"%d)\n\tcall\t_%s\n\tINTREXIT%d\n\n\n", + ++count, id->id, (dp->d_irq > 7)?2:1); + break; + } + if (!strcmp(id->id, id2->id)) + break; + } + } + } + } + (void) fclose(fp); +} diff --git a/tools/kconfig/mkheaders.c b/tools/kconfig/mkheaders.c new file mode 100644 index 0000000..7c93587 --- /dev/null +++ b/tools/kconfig/mkheaders.c @@ -0,0 +1,207 @@ +/* + * Copyright (c) 1980, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)mkheaders.c 8.1 (Berkeley) 6/6/93"; +#endif /* not lint */ + +/* + * Make all the .h files for the optional entries + */ + +#include +#include +#include "config.h" +#include "y.tab.h" + +void do_header(dev, hname, count) + char *dev, *hname; + int count; +{ + char *file, *name, *inw, *toheader(), *tomacro(); + struct file_list *fl, *fl_head, *tflp; + FILE *inf, *outf; + int inc, oldcount; + + file = toheader(hname); + name = tomacro(dev); + inf = fopen(file, "r"); + oldcount = -1; + if (inf == 0) { + outf = fopen(file, "w"); + if (outf == 0) { + perror(file); + exit(1); + } + fprintf(outf, "#define %s %d\n", name, count); + (void) fclose(outf); + return; + } + fl_head = NULL; + for (;;) { + char *cp; + if ((inw = get_word(inf)) == 0 || inw == (char *)EOF) + break; + if ((inw = get_word(inf)) == 0 || inw == (char *)EOF) + break; + inw = ns(inw); + cp = get_word(inf); + if (cp == 0 || cp == (char *)EOF) + break; + inc = atoi(cp); + if (eq(inw, name)) { + oldcount = inc; + inc = count; + } + cp = get_word(inf); + if (cp == (char *)EOF) + break; + fl = (struct file_list *) malloc(sizeof *fl); + bzero(fl, sizeof(*fl)); + fl->f_fn = inw; + fl->f_type = inc; + fl->f_next = fl_head; + fl_head = fl; + } + (void) fclose(inf); + if (count == oldcount) { + for (fl = fl_head; fl != NULL; fl = tflp) { + tflp = fl->f_next; + free(fl); + } + return; + } + if (oldcount == -1) { + fl = (struct file_list *) malloc(sizeof *fl); + bzero(fl, sizeof(*fl)); + fl->f_fn = name; + fl->f_type = count; + fl->f_next = fl_head; + fl_head = fl; + } + outf = fopen(file, "w"); + if (outf == 0) { + perror(file); + exit(1); + } + for (fl = fl_head; fl != NULL; fl = tflp) { + fprintf(outf, + "#define %s %u\n", fl->f_fn, count ? fl->f_type : 0); + tflp = fl->f_next; + free(fl); + } + (void) fclose(outf); +} + +/* + * count all the devices of a certain type and recurse to count + * whatever the device is connected to + */ +void do_count(dev, hname, search) + register char *dev, *hname; + int search; +{ + register struct device *dp, *mp; + register int count, hicount; + + /* + * After this loop, "count" will be the actual number of units, + * and "hicount" will be the highest unit declared. do_header() + * must use this higher of these values. + */ + for (hicount = count = 0, dp = dtab; dp != 0; dp = dp->d_next) + if (dp->d_unit != -1 && eq(dp->d_name, dev)) { + if (dp->d_type == PSEUDO_DEVICE) { + count = + dp->d_slave != UNKNOWN ? dp->d_slave : 1; + break; + } + count++; + /* + * Allow holes in unit numbering, + * assumption is unit numbering starts + * at zero. + */ + if (dp->d_unit + 1 > hicount) + hicount = dp->d_unit + 1; + if (search) { + mp = dp->d_conn; + if (mp != 0 && mp != TO_NEXUS && + mp->d_conn != 0 && mp->d_conn != TO_NEXUS) { + do_count(mp->d_name, hname, 0); + search = 0; + } + } + } + do_header(dev, hname, count > hicount ? count : hicount); +} + +void headers() +{ + register struct file_list *fl; + + for (fl = ftab; fl != 0; fl = fl->f_next) + if (fl->f_needs != 0) + do_count(fl->f_needs, fl->f_needs, 1); +} + +/* + * convert a dev name to a .h file name + */ +char * +toheader(dev) + char *dev; +{ + static char hbuf[80]; + + (void) strcpy(hbuf, path(dev)); + (void) strcat(hbuf, ".h"); + return (hbuf); +} + +/* + * convert a dev name to a macro name + */ +char *tomacro(dev) + register char *dev; +{ + static char mbuf[20]; + register char *cp; + + cp = mbuf; + *cp++ = 'N'; + while (*dev) + *cp++ = islower(*dev) ? toupper(*dev++) : *dev++; + *cp++ = 0; + return (mbuf); +} diff --git a/tools/kconfig/mkioconf.c b/tools/kconfig/mkioconf.c new file mode 100644 index 0000000..313cf53 --- /dev/null +++ b/tools/kconfig/mkioconf.c @@ -0,0 +1,1154 @@ +/* + * Copyright (c) 1980, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)mkioconf.c 8.2 (Berkeley) 1/21/94"; +#endif /* not lint */ + +#include +#include "y.tab.h" +#include "config.h" + +/* + * build the ioconf.c file + */ +char *qu(); +char *intv(); +char *wnum(); +void pseudo_ioconf(); + +#if MACHINE_VAX +void vax_ioconf() +{ + register struct device *dp, *mp, *np; + register int uba_n, slave; + FILE *fp; + + fp = fopen(path("ioconf.c"), "w"); + if (fp == 0) { + perror(path("ioconf.c")); + exit(1); + } + fprintf(fp, "#include \"vax/include/pte.h\"\n"); + fprintf(fp, "#include \"sys/param.h\"\n"); + fprintf(fp, "#include \"sys/buf.h\"\n"); + fprintf(fp, "#include \"sys/map.h\"\n"); + fprintf(fp, "\n"); + fprintf(fp, "#include \"vax/mba/mbavar.h\"\n"); + fprintf(fp, "#include \"vax/uba/ubavar.h\"\n\n"); + fprintf(fp, "\n"); + fprintf(fp, "#define C (caddr_t)\n\n"); + /* + * First print the mba initialization structures + */ + if (seen_mba) { + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (mp == 0 || mp == TO_NEXUS || + !eq(mp->d_name, "mba")) + continue; + fprintf(fp, "extern struct mba_driver %sdriver;\n", + dp->d_name); + } + fprintf(fp, "\nstruct mba_device mbdinit[] = {\n"); + fprintf(fp, "\t/* Device, Unit, Mba, Drive, Dk */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_unit == QUES || mp == 0 || + mp == TO_NEXUS || !eq(mp->d_name, "mba")) + continue; + if (dp->d_addr) { + printf("can't specify csr address on mba for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_vec != 0) { + printf("can't specify vector for %s%d on mba\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_drive == UNKNOWN) { + printf("drive not specified for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_slave != UNKNOWN) { + printf("can't specify slave number for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + fprintf(fp, "\t{ &%sdriver, %d, %s,", + dp->d_name, dp->d_unit, qu(mp->d_unit)); + fprintf(fp, " %s, %d },\n", + qu(dp->d_drive), dp->d_dk); + } + fprintf(fp, "\t0\n};\n\n"); + /* + * Print the mbsinit structure + * Driver Controller Unit Slave + */ + fprintf(fp, "struct mba_slave mbsinit [] = {\n"); + fprintf(fp, "\t/* Driver, Ctlr, Unit, Slave */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + /* + * All slaves are connected to something which + * is connected to the massbus. + */ + if ((mp = dp->d_conn) == 0 || mp == TO_NEXUS) + continue; + np = mp->d_conn; + if (np == 0 || np == TO_NEXUS || + !eq(np->d_name, "mba")) + continue; + fprintf(fp, "\t{ &%sdriver, %s", + mp->d_name, qu(mp->d_unit)); + fprintf(fp, ", %2d, %s },\n", + dp->d_unit, qu(dp->d_slave)); + } + fprintf(fp, "\t0\n};\n\n"); + } + /* + * Now generate interrupt vectors for the unibus + */ + for (dp = dtab; dp != 0; dp = dp->d_next) { + if (dp->d_vec != 0) { + struct idlst *ip; + mp = dp->d_conn; + if (mp == 0 || mp == TO_NEXUS || + (!eq(mp->d_name, "uba") && !eq(mp->d_name, "bi"))) + continue; + fprintf(fp, + "extern struct uba_driver %sdriver;\n", + dp->d_name); + fprintf(fp, "extern "); + ip = dp->d_vec; + for (;;) { + fprintf(fp, "X%s%d()", ip->id, dp->d_unit); + ip = ip->id_next; + if (ip == 0) + break; + fprintf(fp, ", "); + } + fprintf(fp, ";\n"); + fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name, + dp->d_unit); + ip = dp->d_vec; + for (;;) { + fprintf(fp, "X%s%d", ip->id, dp->d_unit); + ip = ip->id_next; + if (ip == 0) + break; + fprintf(fp, ", "); + } + fprintf(fp, ", 0 } ;\n"); + } + } + fprintf(fp, "\nstruct uba_ctlr ubminit[] = {\n"); + fprintf(fp, "/*\t driver,\tctlr,\tubanum,\talive,\tintr,\taddr */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 || + !eq(mp->d_name, "uba")) + continue; + if (dp->d_vec == 0) { + printf("must specify vector for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_addr == 0) { + printf("must specify csr address for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { + printf("drives need their own entries; dont "); + printf("specify drive or slave for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_flags) { + printf("controllers (e.g. %s%d) ", + dp->d_name, dp->d_unit); + printf("don't have flags, only devices do\n"); + continue; + } + fprintf(fp, + "\t{ &%sdriver,\t%d,\t%s,\t0,\t%sint%d, C 0%o },\n", + dp->d_name, dp->d_unit, qu(mp->d_unit), + dp->d_name, dp->d_unit, dp->d_addr); + } + fprintf(fp, "\t0\n};\n"); +/* unibus devices */ + fprintf(fp, "\nstruct uba_device ubdinit[] = {\n"); + fprintf(fp, +"\t/* driver, unit, ctlr, ubanum, slave, intr, addr, dk, flags*/\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || + mp == TO_NEXUS || mp->d_type == MASTER || + eq(mp->d_name, "mba")) + continue; + np = mp->d_conn; + if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba")) + continue; + np = 0; + if (eq(mp->d_name, "uba")) { + if (dp->d_vec == 0) { + printf("must specify vector for device %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_addr == 0) { + printf("must specify csr for device %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { + printf("drives/slaves can be specified "); + printf("only for controllers, "); + printf("not for device %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + uba_n = mp->d_unit; + slave = QUES; + } else { + if ((np = mp->d_conn) == 0) { + printf("%s%d isn't connected to anything ", + mp->d_name, mp->d_unit); + printf(", so %s%d is unattached\n", + dp->d_name, dp->d_unit); + continue; + } + uba_n = np->d_unit; + if (dp->d_drive == UNKNOWN) { + printf("must specify ``drive number'' "); + printf("for %s%d\n", dp->d_name, dp->d_unit); + continue; + } + /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */ + /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ + if (dp->d_slave != UNKNOWN) { + printf("slave numbers should be given only "); + printf("for massbus tapes, not for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_vec != 0) { + printf("interrupt vectors should not be "); + printf("given for drive %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_addr != 0) { + printf("csr addresses should be given only "); + printf("on controllers, not on %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + slave = dp->d_drive; + } + fprintf(fp, "\t{ &%sdriver, %2d, %s,", + eq(mp->d_name, "uba") ? dp->d_name : mp->d_name, dp->d_unit, + eq(mp->d_name, "uba") ? " -1" : qu(mp->d_unit)); + fprintf(fp, " %s, %2d, %s, C 0%-6o, %d, 0x%x },\n", + qu(uba_n), slave, intv(dp), dp->d_addr, dp->d_dk, + dp->d_flags); + } + fprintf(fp, "\t0\n};\n"); + pseudo_ioconf(fp); + (void) fclose(fp); +} +#endif + +#if MACHINE_TAHOE +void tahoe_ioconf() +{ + register struct device *dp, *mp, *np; + register int vba_n, slave; + FILE *fp; + + fp = fopen(path("ioconf.c"), "w"); + if (fp == 0) { + perror(path("ioconf.c")); + exit(1); + } + fprintf(fp, "#include \"sys/param.h\"\n"); + fprintf(fp, "#include \"tahoe/include/pte.h\"\n"); + fprintf(fp, "#include \"sys/buf.h\"\n"); + fprintf(fp, "#include \"sys/map.h\"\n"); + fprintf(fp, "\n"); + fprintf(fp, "#include \"tahoe/vba/vbavar.h\"\n"); + fprintf(fp, "\n"); + fprintf(fp, "#define C (caddr_t)\n\n"); + /* + * Now generate interrupt vectors for the versabus + */ + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (mp == 0 || mp == TO_NEXUS || !eq(mp->d_name, "vba")) + continue; + if (dp->d_vec != 0) { + struct idlst *ip; + fprintf(fp, + "extern struct vba_driver %sdriver;\n", + dp->d_name); + fprintf(fp, "extern "); + ip = dp->d_vec; + for (;;) { + fprintf(fp, "X%s%d()", ip->id, dp->d_unit); + ip = ip->id_next; + if (ip == 0) + break; + fprintf(fp, ", "); + } + fprintf(fp, ";\n"); + fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name, + dp->d_unit); + ip = dp->d_vec; + for (;;) { + fprintf(fp, "X%s%d", ip->id, dp->d_unit); + ip = ip->id_next; + if (ip == 0) + break; + fprintf(fp, ", "); + } + fprintf(fp, ", 0 } ;\n"); + } else if (dp->d_type == DRIVER) /* devices w/o interrupts */ + fprintf(fp, + "extern struct vba_driver %sdriver;\n", + dp->d_name); + } + fprintf(fp, "\nstruct vba_ctlr vbminit[] = {\n"); + fprintf(fp, "/*\t driver,\tctlr,\tvbanum,\talive,\tintr,\taddr */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 || + !eq(mp->d_name, "vba")) + continue; + if (dp->d_vec == 0) { + printf("must specify vector for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_addr == 0) { + printf("must specify csr address for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { + printf("drives need their own entries; dont "); + printf("specify drive or slave for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_flags) { + printf("controllers (e.g. %s%d) ", + dp->d_name, dp->d_unit); + printf("don't have flags, only devices do\n"); + continue; + } + fprintf(fp, + "\t{ &%sdriver,\t%d,\t%s,\t0,\t%sint%d, C 0x%x },\n", + dp->d_name, dp->d_unit, qu(mp->d_unit), + dp->d_name, dp->d_unit, dp->d_addr); + } + fprintf(fp, "\t0\n};\n"); +/* versabus devices */ + fprintf(fp, "\nstruct vba_device vbdinit[] = {\n"); + fprintf(fp, +"\t/* driver, unit, ctlr, vbanum, slave, intr, addr, dk, flags*/\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || + mp == TO_NEXUS || mp->d_type == MASTER || + eq(mp->d_name, "mba")) + continue; + np = mp->d_conn; + if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba")) + continue; + np = 0; + if (eq(mp->d_name, "vba")) { + if (dp->d_vec == 0) + printf( + "Warning, no interrupt vector specified for device %s%d\n", + dp->d_name, dp->d_unit); + if (dp->d_addr == 0) { + printf("must specify csr for device %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { + printf("drives/slaves can be specified "); + printf("only for controllers, "); + printf("not for device %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + vba_n = mp->d_unit; + slave = QUES; + } else { + if ((np = mp->d_conn) == 0) { + printf("%s%d isn't connected to anything ", + mp->d_name, mp->d_unit); + printf(", so %s%d is unattached\n", + dp->d_name, dp->d_unit); + continue; + } + vba_n = np->d_unit; + if (dp->d_drive == UNKNOWN) { + printf("must specify ``drive number'' "); + printf("for %s%d\n", dp->d_name, dp->d_unit); + continue; + } + /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */ + /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ + if (dp->d_slave != UNKNOWN) { + printf("slave numbers should be given only "); + printf("for massbus tapes, not for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_vec != 0) { + printf("interrupt vectors should not be "); + printf("given for drive %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_addr != 0) { + printf("csr addresses should be given only "); + printf("on controllers, not on %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + slave = dp->d_drive; + } + fprintf(fp, "\t{ &%sdriver, %2d, %s,", + eq(mp->d_name, "vba") ? dp->d_name : mp->d_name, dp->d_unit, + eq(mp->d_name, "vba") ? " -1" : qu(mp->d_unit)); + fprintf(fp, " %s, %2d, %s, C 0x%-6x, %d, 0x%x },\n", + qu(vba_n), slave, intv(dp), dp->d_addr, dp->d_dk, + dp->d_flags); + } + fprintf(fp, "\t0\n};\n"); + pseudo_ioconf(fp); + (void) fclose(fp); +} +#endif + +#if MACHINE_HP300 || MACHINE_LUNA68K + +#define ishpibdev(n) (eq(n,"rd") || eq(n,"ct") || eq(n,"mt") || eq(n,"ppi")) +#define isscsidev(n) (eq(n,"sd") || eq(n,"st") || eq(n,"ac")) + +int hpbadslave(mp, dp) + register struct device *dp, *mp; +{ + + if ((mp == TO_NEXUS && ishpibdev(dp->d_name)) || + (mp != TO_NEXUS && eq(mp->d_name, "hpib") && + !ishpibdev(dp->d_name))) { + printf("%s%s must be attached to an hpib\n", + dp->d_name, wnum(dp->d_unit)); + return (1); + } + if ((mp == TO_NEXUS && isscsidev(dp->d_name)) || + (mp != TO_NEXUS && eq(mp->d_name, "scsi") && + !isscsidev(dp->d_name))) { + printf("%s%s must be attached to a scsi\n", + dp->d_name, wnum(dp->d_unit)); + return (1); + } + return (0); +} + +void hp300_ioconf() +{ + register struct device *dp, *mp; + register int hpib, slave; + FILE *fp; + + fp = fopen(path("ioconf.c"), "w"); + if (fp == 0) { + perror(path("ioconf.c")); + exit(1); + } + fprintf(fp, "#include \"sys/param.h\"\n"); + fprintf(fp, "#include \"sys/buf.h\"\n"); + fprintf(fp, "#include \"sys/map.h\"\n"); + fprintf(fp, "\n"); + if (machine == MACHINE_HP300) + fprintf(fp, "#include \"hp/dev/device.h\"\n\n"); + else + fprintf(fp, "#include \"luna68k/dev/device.h\"\n\n"); + fprintf(fp, "\n"); + fprintf(fp, "#define C (caddr_t)\n"); + fprintf(fp, "#define D (struct driver *)\n\n"); + /* + * First print the hpib controller initialization structures + */ + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_unit == QUES || mp == 0) + continue; + fprintf(fp, "extern struct driver %sdriver;\n", dp->d_name); + } + fprintf(fp, "\nstruct hp_ctlr hp_cinit[] = {\n"); + fprintf(fp, "/*\tdriver,\t\tunit,\talive,\taddr,\tflags */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_unit == QUES || + (dp->d_type != MASTER && dp->d_type != CONTROLLER)) + continue; + if (mp != TO_NEXUS) { + printf("%s%s must be attached to an sc (nexus)\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { + printf("can't specify drive/slave for %s%s\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + fprintf(fp, + "\t{ &%sdriver,\t%d,\t0,\tC 0x%x,\t0x%x },\n", + dp->d_name, dp->d_unit, dp->d_addr, dp->d_flags); + } + fprintf(fp, "\t0\n};\n"); +/* devices */ + fprintf(fp, "\nstruct hp_device hp_dinit[] = {\n"); + fprintf(fp, + "/*driver,\tcdriver,\tunit,\tctlr,\tslave,\taddr,\tdk,\tflags*/\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (mp == 0 || dp->d_type != DEVICE || hpbadslave(mp, dp)) + continue; + if (mp == TO_NEXUS) { + if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { + printf("can't specify drive/slave for %s%s\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + slave = QUES; + hpib = QUES; + } else { + if (dp->d_addr != 0) { + printf("can't specify sc for device %s%s\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + if (mp->d_type == CONTROLLER) { + if (dp->d_drive == UNKNOWN) { + printf("must specify drive for %s%s\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + slave = dp->d_drive; + } else { + if (dp->d_slave == UNKNOWN) { + printf("must specify slave for %s%s\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + slave = dp->d_slave; + } + hpib = mp->d_unit; + } + fprintf(fp, "{ &%sdriver,\t", dp->d_name); + if (mp == TO_NEXUS) + fprintf(fp, "D 0x0,\t"); + else + fprintf(fp, "&%sdriver,", mp->d_name); + fprintf(fp, "\t%d,\t%d,\t%d,\tC 0x%x,\t%d,\t0x%x },\n", + dp->d_unit, hpib, slave, + dp->d_addr, dp->d_dk, dp->d_flags); + } + fprintf(fp, "0\n};\n"); + pseudo_ioconf(fp); + (void) fclose(fp); +} +#endif + +#if MACHINE_I386 +char *sirq(int); + +void i386_ioconf() +{ + register struct device *dp, *mp, *np; + register int uba_n, slave; + FILE *fp; + + fp = fopen(path("ioconf.c"), "w"); + if (fp == 0) { + perror(path("ioconf.c")); + exit(1); + } + fprintf(fp, "/*\n"); + fprintf(fp, " * ioconf.c \n"); + fprintf(fp, " * Generated by config program\n"); + fprintf(fp, " */\n\n"); + fprintf(fp, "#include \"machine/pte.h\"\n"); + fprintf(fp, "#include \"sys/param.h\"\n"); + fprintf(fp, "#include \"sys/buf.h\"\n"); + fprintf(fp, "#include \"sys/map.h\"\n"); + fprintf(fp, "\n"); + fprintf(fp, "#define V(s) __CONCAT(V,s)\n"); + fprintf(fp, "#define C (caddr_t)\n\n"); + /* + * First print the isa initialization structures + */ + if (seen_isa) { + + fprintf(fp, "/*\n"); + fprintf(fp, " * ISA devices\n"); + fprintf(fp, " */\n\n"); + fprintf(fp, "#include \"i386/isa/isa_device.h\"\n"); + fprintf(fp, "#include \"i386/isa/isa.h\"\n"); + fprintf(fp, "#include \"i386/isa/icu.h\"\n\n"); + + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (mp == 0 || mp == TO_NEXUS || + !eq(mp->d_name, "isa")) + continue; + fprintf(fp, +"extern struct isa_driver %sdriver; extern V(%s%d)();\n", + dp->d_name, dp->d_name, dp->d_unit); + } + fprintf(fp, "\nstruct isa_device isa_devtab_bio[] = {\n"); + fprintf(fp, "\ +/* driver iobase irq drq maddr msiz intr unit */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_unit == QUES || mp == 0 || + mp == TO_NEXUS || !eq(mp->d_name, "isa")) + continue; + if (!eq(dp->d_mask, "bio")) continue; + if (dp->d_port) + fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); + else + fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); + fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", + sirq(dp->d_irq), dp->d_drq, dp->d_maddr, + dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); + } + fprintf(fp, "0\n};\n"); + + fprintf(fp, "struct isa_device isa_devtab_tty[] = {\n"); + fprintf(fp, "\ +/* driver iobase irq drq maddr msiz intr unit */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_unit == QUES || mp == 0 || + mp == TO_NEXUS || !eq(mp->d_name, "isa")) + continue; + if (!eq(dp->d_mask, "tty")) continue; + if (dp->d_port) + fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); + else + fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); + fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", + sirq(dp->d_irq), dp->d_drq, dp->d_maddr, + dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); + } + fprintf(fp, "0\n};\n\n"); + + fprintf(fp, "struct isa_device isa_devtab_net[] = {\n"); + fprintf(fp, "\ +/* driver iobase irq drq maddr msiz intr unit */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_unit == QUES || mp == 0 || + mp == TO_NEXUS || !eq(mp->d_name, "isa")) + continue; + if (!eq(dp->d_mask, "net")) continue; + if (dp->d_port) + fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); + else + fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); + fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", + sirq(dp->d_irq), dp->d_drq, dp->d_maddr, + dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); + } + fprintf(fp, "0\n};\n\n"); + + fprintf(fp, "struct isa_device isa_devtab_null[] = {\n"); + fprintf(fp, "\ +/* driver iobase irq drq maddr msiz intr unit */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_unit == QUES || mp == 0 || + mp == TO_NEXUS || !eq(mp->d_name, "isa")) + continue; + if (!eq(dp->d_mask, "null")) continue; + if (dp->d_port) + fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); + else + fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); + fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", + sirq(dp->d_irq), dp->d_drq, dp->d_maddr, + dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); + } + fprintf(fp, "0\n};\n\n"); + } + pseudo_ioconf(fp); + (void) fclose(fp); +} + +char * +sirq(num) +{ + + if (num == -1) + return ("0"); + sprintf(errbuf, "IRQ%d", num); + return (errbuf); +} +#endif + +#if MACHINE_PMAX +void pmax_ioconf() +{ + register struct device *dp, *mp; + FILE *fp; + + fp = fopen(path("ioconf.c"), "w"); + if (fp == 0) { + perror(path("ioconf.c")); + exit(1); + } + fprintf(fp, "#include \"sys/types.h\"\n"); + fprintf(fp, "#include \"sys/time.h\"\n"); + fprintf(fp, "#include \"mips/dev/device.h\"\n\n"); + fprintf(fp, "#define C (char *)\n\n"); + + /* print controller initialization structures */ + for (dp = dtab; dp != 0; dp = dp->d_next) { + if (dp->d_type == PSEUDO_DEVICE) + continue; + fprintf(fp, "extern struct driver %sdriver;\n", dp->d_name); + } + fprintf(fp, "\nstruct mips_ctlr mips_cinit[] = {\n"); + fprintf(fp, "/*\tdriver,\t\tunit,\taddr,\t\tpri,\tflags */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + if (dp->d_type != CONTROLLER && dp->d_type != MASTER) + continue; + if (dp->d_conn != TO_NEXUS) { + printf("%s%s must be attached to a nexus (internal bus)\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { + printf("can't specify drive/slave for %s%s\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + if (dp->d_unit == UNKNOWN || dp->d_unit == QUES) + dp->d_unit = 0; + fprintf(fp, + "\t{ &%sdriver,\t%d,\tC 0x%x,\t%d,\t0x%x },\n", + dp->d_name, dp->d_unit, dp->d_addr, dp->d_pri, + dp->d_flags); + } + fprintf(fp, "\t0\n};\n"); + + /* print devices connected to other controllers */ + fprintf(fp, "\nstruct scsi_device scsi_dinit[] = {\n"); + fprintf(fp, + "/*driver,\tcdriver,\tunit,\tctlr,\tdrive,\tslave,\tdk,\tflags*/\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + if (dp->d_type == CONTROLLER || dp->d_type == MASTER || + dp->d_type == PSEUDO_DEVICE) + continue; + mp = dp->d_conn; + if (mp == 0 || + (!eq(mp->d_name, "asc") && !eq(mp->d_name, "sii"))) { + printf("%s%s: devices must be attached to a SCSI (asc or sii) controller\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + if ((unsigned)dp->d_drive > 6) { + printf("%s%s: SCSI drive must be in the range 0..6\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + /* may want to allow QUES later */ + if ((unsigned)dp->d_slave > 7) { + printf("%s%s: SCSI slave (LUN) must be in the range 0..7\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + fprintf(fp, "{ &%sdriver,\t&%sdriver,", dp->d_name, mp->d_name); + fprintf(fp, "\t%d,\t%d,\t%d,\t%d,\t%d,\t0x%x },\n", + dp->d_unit, mp->d_unit, dp->d_drive, dp->d_slave, + dp->d_dk, dp->d_flags); + } + fprintf(fp, "0\n};\n"); + pseudo_ioconf(fp); + (void) fclose(fp); +} +#endif + +#if MACHINE_PIC32 +void pic32_ioconf() +{ + register struct device *dp, *mp; + FILE *fp; + + fp = fopen(path("ioconf.c"), "w"); + if (fp == 0) { + perror(path("ioconf.c")); + exit(1); + } + fprintf(fp, "#include \"sys/types.h\"\n"); + fprintf(fp, "#include \"sys/time.h\"\n"); + fprintf(fp, "#include \"mips/dev/device.h\"\n\n"); + fprintf(fp, "#define C (char *)\n\n"); + + /* print controller initialization structures */ + for (dp = dtab; dp != 0; dp = dp->d_next) { + if (dp->d_type == PSEUDO_DEVICE) + continue; + fprintf(fp, "extern struct driver %sdriver;\n", dp->d_name); + } + fprintf(fp, "\nstruct conf_ctlr conf_cinit[] = {\n"); + fprintf(fp, "/*\tdriver,\t\tunit,\taddr,\t\tpri,\tflags */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + if (dp->d_type != CONTROLLER && dp->d_type != MASTER) + continue; + if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { + printf("can't specify drive/slave for %s%s\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + if (dp->d_unit == UNKNOWN || dp->d_unit == QUES) + dp->d_unit = 0; + fprintf(fp, + "\t{ &%sdriver,\t%d,\tC 0x%08x,\t%d,\t0x%x },\n", + dp->d_name, dp->d_unit, dp->d_addr, dp->d_pri, + dp->d_flags); + } + fprintf(fp, "\t{ 0 }\n};\n"); + + /* print devices connected to other controllers */ + fprintf(fp, "\nstruct conf_device conf_dinit[] = {\n"); + fprintf(fp, + "/*driver,\tcdriver,\tunit,\tctlr,\tdrive,\tslave,\tdk,\tflags*/\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + if (dp->d_type == CONTROLLER || dp->d_type == MASTER || + dp->d_type == PSEUDO_DEVICE) + continue; + + mp = dp->d_conn; + fprintf(fp, "{ &%sdriver,\t", dp->d_name); + if (mp) { + fprintf(fp, "&%sdriver,\t%d,\t%d,\t", + mp->d_name, dp->d_unit, mp->d_unit); + } else { + fprintf(fp, "0,\t\t%d,\t0,\t", + dp->d_unit); + } + fprintf(fp, "%d,\t%d,\t%d,\t0x%x },\n", + dp->d_drive, dp->d_slave, dp->d_dk, dp->d_flags); + } + fprintf(fp, "{ 0 }\n};\n"); + pseudo_ioconf(fp); + (void) fclose(fp); +} +#endif + +#if MACHINE_NEWS3400 +int have_iop = 0; +int have_hb = 0; +int have_vme = 0; + +void news_ioconf() +{ + register struct device *dp, *mp; + register int slave; + FILE *fp; + + fp = fopen(path("ioconf.c"), "w"); + if (fp == 0) { + perror(path("ioconf.c")); + exit(1); + } + fprintf(fp, "#include \"sys/param.h\"\n"); + fprintf(fp, "#include \"sys/buf.h\"\n"); + fprintf(fp, "#include \"sys/map.h\"\n"); + fprintf(fp, "#include \"vm/vm.h\"\n"); + fprintf(fp, "#include \"iop.h\"\n"); + fprintf(fp, "#include \"hb.h\"\n"); + fprintf(fp, "\n"); + fprintf(fp, "#if NIOP > 0\n"); + fprintf(fp, "#include \"news3400/iop/iopvar.h\"\n"); + fprintf(fp, "#endif\n"); + fprintf(fp, "#if NHB > 0\n"); + fprintf(fp, "#include \"news3400/hbdev/hbvar.h\"\n"); + fprintf(fp, "#endif\n"); + fprintf(fp, "\n"); + fprintf(fp, "#define C (caddr_t)\n\n"); + fprintf(fp, "\n"); + +/* BEGIN HB */ + fprintf(fp, "#if NHB > 0\n"); + /* + * Now generate interrupt vectors for the HYPER-BUS + */ + for (dp = dtab; dp != 0; dp = dp->d_next) { + if (dp->d_pri >= 0) { + mp = dp->d_conn; + if (mp == 0 || mp == TO_NEXUS || + !eq(mp->d_name, "hb")) + continue; + fprintf(fp, "extern struct hb_driver %sdriver;\n", + dp->d_name); + have_hb++; + } + } + /* + * Now spew forth the hb_cinfo structure + */ + fprintf(fp, "\nstruct hb_ctlr hminit[] = {\n"); + fprintf(fp, "/*\t driver,\tctlr,\talive,\taddr,\tintpri */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if ((dp->d_type != MASTER && dp->d_type != CONTROLLER) + || mp == TO_NEXUS || mp == 0 || + !eq(mp->d_name, "hb")) + continue; + if (dp->d_pri < 0) { + printf("must specify priority for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { + printf("drives need their own entries; "); + printf("dont specify drive or slave for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_flags) { + printf("controllers (e.g. %s%d) don't have flags, " + "only devices do\n", + dp->d_name, dp->d_unit); + continue; + } + fprintf(fp, "\t{ &%sdriver,\t%d,\t0,\tC 0x%x,\t%d },\n", + dp->d_name, dp->d_unit, dp->d_addr, dp->d_pri); + } + fprintf(fp, "\t0\n};\n"); + /* + * Now we go for the hb_device stuff + */ + fprintf(fp, "\nstruct hb_device hdinit[] = {\n"); + fprintf(fp, +"\t/* driver, unit, ctlr, slave, addr, pri, dk, flags*/\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || + mp == TO_NEXUS || /* mp->d_type == MASTER || */ + eq(mp->d_name, "iop") || eq(mp->d_name, "vme")) + continue; + if (eq(mp->d_name, "hb")) { + if (dp->d_pri < 0) { + printf("must specify vector for device %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { + printf("drives/slaves can be specified only "); + printf("for controllers, not for device %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + slave = QUES; + } else { + if (mp->d_conn == 0) { + printf("%s%d isn't connected to anything, ", + mp->d_name, mp->d_unit); + printf("so %s%d is unattached\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_drive == UNKNOWN) { + printf("must specify ``drive number'' for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + /* NOTE THAT ON THE IOP ``drive'' IS STORED IN */ + /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ + if (dp->d_slave != UNKNOWN) { + printf("slave numbers should be given only "); + printf("for massbus tapes, not for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_pri >= 0) { + printf("interrupt priority should not be "); + printf("given for drive %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_addr != 0) { + printf("csr addresses should be given only"); + printf("on controllers, not on %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + slave = dp->d_drive; + } + fprintf(fp, +"\t{ &%sdriver, %2d, %s, %2d, C 0x%x, %d, %d, 0x%x },\n", + eq(mp->d_name, "hb") ? dp->d_name : mp->d_name, dp->d_unit, + eq(mp->d_name, "hb") ? " -1" : qu(mp->d_unit), + slave, dp->d_addr, dp->d_pri, dp->d_dk, dp->d_flags); + } + fprintf(fp, "\t0\n};\n\n"); + fprintf(fp, "#endif\n\n"); +/* END HB */ + pseudo_ioconf(fp); + (void) fclose(fp); +} +#endif + +char * +intv(dev) + register struct device *dev; +{ + static char buf[20]; + + if (dev->d_vec == 0) + return (" 0"); + (void) sprintf(buf, "%sint%d", dev->d_name, dev->d_unit); + return (buf); +} + +char * +qu(num) +{ + + if (num == QUES) + return ("'?'"); + if (num == UNKNOWN) + return (" -1"); + (void) sprintf(errbuf, "%3d", num); + return (errbuf); +} + +char * +wnum(num) +{ + + if (num == QUES || num == UNKNOWN) + return ("?"); + (void) sprintf(errbuf, "%d", num); + return (errbuf); +} + +void comp_config(fp) + FILE *fp; +{ + register struct file_list *fl; + register struct device *dp; + + fprintf(fp, "\n#include \"dev/cdvar.h\"\n"); + fprintf(fp, "\nstruct cddevice cddevice[] = {\n"); + fprintf(fp, "/*\tunit\tileave\tflags\tdk\tdevs\t\t\t\t*/\n"); + + fl = comp_list; + while (fl) { + if (fl->f_type != COMPDEVICE) { + fl = fl->f_next; + continue; + } + for (dp = dtab; dp != 0; dp = dp->d_next) + if (dp->d_type == DEVICE && + eq(dp->d_name, fl->f_fn) && + dp->d_unit == fl->f_compinfo) + break; + if (dp == 0) + continue; + fprintf(fp, "\t%d,\t%d,\t%d,\t%d,\t{", + dp->d_unit, dp->d_pri < 0 ? 0 : dp->d_pri, + dp->d_flags, 1); + for (fl = fl->f_next; fl->f_type == COMPSPEC; fl = fl->f_next) + fprintf(fp, " 0x%x,", (unsigned) fl->f_compdev); + fprintf(fp, " NODEV },\n"); + } + fprintf(fp, "\t-1,\t0,\t0,\t0,\t{ 0 },\n};\n"); +} + +void +pseudo_ioconf(fp) + register FILE *fp; +{ + register struct device *dp; + + (void)fprintf(fp, "\n#include \n\n"); + for (dp = dtab; dp != NULL; dp = dp->d_next) + if (dp->d_type == PSEUDO_DEVICE) + (void)fprintf(fp, "extern void %sattach __P((int));\n", + dp->d_name); + /* + * XXX concatonated disks are pseudo-devices but appear as DEVICEs + * since they don't adhere to normal pseudo-device conventions + * (i.e. one entry with total count in d_slave). + */ + if (seen_cd) + (void)fprintf(fp, "extern void cdattach __P((int));\n"); + /* XXX temporary for HP300, others */ + (void)fprintf(fp, "\n#include /* XXX */\n"); + (void)fprintf(fp, "#define etherattach (void (*)__P((int)))nullop\n"); + (void)fprintf(fp, "#define iteattach (void (*) __P((int)))nullop\n"); + (void)fprintf(fp, "\nstruct pdevinit pdevinit[] = {\n"); + for (dp = dtab; dp != NULL; dp = dp->d_next) + if (dp->d_type == PSEUDO_DEVICE) + (void)fprintf(fp, "\t{ %sattach, %d },\n", dp->d_name, + dp->d_slave > 0 ? dp->d_slave : 1); + /* + * XXX count up cds and put out an entry + */ + if (seen_cd) { + struct file_list *fl; + int cdmax = -1; + + for (fl = comp_list; fl != NULL; fl = fl->f_next) + if (fl->f_type == COMPDEVICE && fl->f_compinfo > cdmax) + cdmax = fl->f_compinfo; + (void)fprintf(fp, "\t{ cdattach, %d },\n", cdmax+1); + } + (void)fprintf(fp, "\t{ 0, 0 }\n};\n"); + if (seen_cd) + comp_config(fp); +} diff --git a/tools/kconfig/mkmakefile.c b/tools/kconfig/mkmakefile.c new file mode 100644 index 0000000..14307c4 --- /dev/null +++ b/tools/kconfig/mkmakefile.c @@ -0,0 +1,628 @@ +/* + * Copyright (c) 1993, 19801990 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)mkmakefile.c 8.1 (Berkeley) 6/6/93"; +#endif /* not lint */ + +/* + * Build the makefile for the system, from + * the information in the files files and the + * additional files for the machine being compiled to. + */ + +#include +#include +#include "y.tab.h" +#include "config.h" + +#define next_word(fp, wd) \ + { register char *word = get_word(fp); \ + if (word == (char *)EOF) \ + return; \ + else \ + wd = word; \ + } +#define next_quoted_word(fp, wd) \ + { register char *word = get_quoted_word(fp); \ + if (word == (char *)EOF) \ + return; \ + else \ + wd = word; \ + } + +static struct file_list *fcur; +char *tail(); + +/* + * Lookup a file, by name. + */ +struct file_list * +fl_lookup(file) + register char *file; +{ + register struct file_list *fp; + + for (fp = ftab ; fp != 0; fp = fp->f_next) { + if (eq(fp->f_fn, file)) + return (fp); + } + return (0); +} + +/* + * Lookup a file, by final component name. + */ +struct file_list * +fltail_lookup(file) + register char *file; +{ + register struct file_list *fp; + + for (fp = ftab ; fp != 0; fp = fp->f_next) { + if (eq(tail(fp->f_fn), tail(file))) + return (fp); + } + return (0); +} + +/* + * Make a new file list entry + */ +struct file_list * +new_fent() +{ + register struct file_list *fp; + + fp = (struct file_list *) malloc(sizeof *fp); + bzero(fp, sizeof *fp); + if (fcur == 0) + fcur = ftab = fp; + else + fcur->f_next = fp; + fcur = fp; + return (fp); +} + +static struct users { + int u_default; + int u_min; + int u_max; +} users[] = { + { 24, 8, 1024 }, /* MACHINE_VAX */ + { 4, 2, 128 }, /* MACHINE_TAHOE */ + { 8, 2, 64 }, /* MACHINE_HP300 */ + { 8, 2, 64 }, /* MACHINE_I386 */ + { 8, 2, 64 }, /* MACHINE_MIPS */ + { 8, 2, 64 }, /* MACHINE_PMAX */ + { 8, 2, 64 }, /* MACHINE_LUNA68K */ + { 8, 2, 64 }, /* MACHINE_NEWS3400 */ + { 2, 1, 16 }, /* MACHINE_PIC32 */ +}; +#define NUSERS (sizeof (users) / sizeof (users[0])) + +int opteq(cp, dp) + char *cp, *dp; +{ + char c, d; + + for (; ; cp++, dp++) { + if (*cp != *dp) { + c = isupper(*cp) ? tolower(*cp) : *cp; + d = isupper(*dp) ? tolower(*dp) : *dp; + if (c != d) + return (0); + } + if (*cp == 0) + return (1); + } +} + +/* + * Read in the information about files used in making the system. + * Store it in the ftab linked list. + */ +void read_files() +{ + FILE *fp; + register struct file_list *tp, *pf; + register struct device *dp; + struct device *save_dp; + register struct opt *op; + char *wd, *this, *needs, *special; + char fname[32]; + int nreqs, first = 1, configdep, isdup, std, filetype; + + ftab = 0; + (void) strcpy(fname, "../../conf/files"); +openit: + fp = fopen(fname, "r"); + if (fp == 0) { + perror(fname); + exit(1); + } +next: + /* + * filename [ standard | optional ] [ config-dependent ] + * [ dev* | profiling-routine ] [ device-driver] + * [ compile-with "compile rule" ] + */ + wd = get_word(fp); + if (wd == (char *)EOF) { + (void) fclose(fp); + if (first == 1) { + (void) sprintf(fname, "files.%s", machinename); + first++; + goto openit; + } + if (first == 2) { + (void) sprintf(fname, "files.%s", raise(ident)); + first++; + fp = fopen(fname, "r"); + if (fp != 0) + goto next; + } + return; + } + if (wd == 0) + goto next; + this = ns(wd); + next_word(fp, wd); + if (wd == 0) { + printf("%s: No type for %s.\n", + fname, this); + exit(1); + } + if ((pf = fl_lookup(this)) && (pf->f_type != INVISIBLE || pf->f_flags)) + isdup = 1; + else + isdup = 0; + tp = 0; + if (first == 3 && (tp = fltail_lookup(this)) != 0) + printf("%s: Local file %s overrides %s.\n", + fname, this, tp->f_fn); + nreqs = 0; + special = 0; + configdep = 0; + needs = 0; + std = 0; + filetype = NORMAL; + if (eq(wd, "standard")) + std = 1; + else if (!eq(wd, "optional")) { + printf("%s: %s must be optional or standard\n", fname, this); + exit(1); + } +nextparam: + next_word(fp, wd); + if (wd == 0) + goto doneparam; + if (eq(wd, "config-dependent")) { + configdep++; + goto nextparam; + } + if (eq(wd, "compile-with")) { + next_quoted_word(fp, wd); + if (wd == 0) { + printf("%s: missing compile command string.\n", + fname); + exit(1); + } + special = ns(wd); + goto nextparam; + } + nreqs++; + if (eq(wd, "device-driver")) { + filetype = DRIVER; + goto nextparam; + } + if (eq(wd, "profiling-routine")) { + filetype = PROFILING; + goto nextparam; + } + if (needs == 0 && nreqs == 1) + needs = ns(wd); + if (isdup) + goto invis; + for (dp = dtab; dp != 0; save_dp = dp, dp = dp->d_next) + if (eq(dp->d_name, wd)) { + if (std && dp->d_type == PSEUDO_DEVICE && + dp->d_slave <= 0) + dp->d_slave = 1; + goto nextparam; + } + if (std) { + dp = (struct device *) malloc(sizeof *dp); + init_dev(dp); + dp->d_name = ns(wd); + dp->d_type = PSEUDO_DEVICE; + dp->d_slave = 1; + save_dp->d_next = dp; + goto nextparam; + } + for (op = opt; op != 0; op = op->op_next) + if (op->op_value == 0 && opteq(op->op_name, wd)) { + if (nreqs == 1) { + free(needs); + needs = 0; + } + goto nextparam; + } +invis: + while ((wd = get_word(fp)) != 0) + ; + if (tp == 0) + tp = new_fent(); + tp->f_fn = this; + tp->f_type = INVISIBLE; + tp->f_needs = needs; + tp->f_flags = isdup; + tp->f_special = special; + goto next; + +doneparam: + if (std == 0 && nreqs == 0) { + printf("%s: what is %s optional on?\n", + fname, this); + exit(1); + } + +save: + if (wd) { + printf("%s: syntax error describing %s\n", + fname, this); + exit(1); + } + if (filetype == PROFILING && profiling == 0) + goto next; + if (tp == 0) + tp = new_fent(); + tp->f_fn = this; + tp->f_type = filetype; + tp->f_flags = 0; + if (configdep) + tp->f_flags |= CONFIGDEP; + tp->f_needs = needs; + tp->f_special = special; + if (pf && pf->f_type == INVISIBLE) + pf->f_flags = 1; /* mark as duplicate */ + goto next; +} + +void do_objs(fp) + FILE *fp; +{ + register struct file_list *tp, *fl; + register int lpos, len; + register char *cp, och, *sp; + char swapname[32]; + + fprintf(fp, "OBJS="); + lpos = 6; + for (tp = ftab; tp != 0; tp = tp->f_next) { + if (tp->f_type == INVISIBLE) + continue; + sp = tail(tp->f_fn); + for (fl = conf_list; fl; fl = fl->f_next) { + if (fl->f_type != SWAPSPEC) + continue; + (void) sprintf(swapname, "swap%s.c", fl->f_fn); + if (eq(sp, swapname)) + goto cont; + } + cp = sp + (len = strlen(sp)) - 1; + och = *cp; + *cp = 'o'; + if (len + lpos > 72) { + lpos = 8; + fprintf(fp, "\\\n\t"); + } + fprintf(fp, "%s ", sp); + lpos += len + 1; + *cp = och; +cont: + ; + } + if (lpos != 8) + putc('\n', fp); +} + +void do_cfiles(fp) + FILE *fp; +{ + register struct file_list *tp, *fl; + register int lpos, len; + char swapname[32]; + + fputs("CFILES=", fp); + lpos = 8; + for (tp = ftab; tp; tp = tp->f_next) + if (tp->f_type != INVISIBLE) { + len = strlen(tp->f_fn); + if (tp->f_fn[len - 1] != 'c') + continue; + if ((len = 3 + len) + lpos > 72) { + lpos = 8; + fputs("\\\n\t", fp); + } + fprintf(fp, "$S/%s ", tp->f_fn); + lpos += len + 1; + } + for (fl = conf_list; fl; fl = fl->f_next) + if (fl->f_type == SYSTEMSPEC) { + (void) sprintf(swapname, "swap%s.c", fl->f_fn); + if ((len = 3 + strlen(swapname)) + lpos > 72) { + lpos = 8; + fputs("\\\n\t", fp); + } + if (eq(fl->f_fn, "generic")) + fprintf(fp, "$A/%s/%s ", + machinename, swapname); + else + fprintf(fp, "%s ", swapname); + lpos += len + 1; + } + if (lpos != 8) + putc('\n', fp); +} + +/* + * Create the makerules for each file + * which is part of the system. + * Devices are processed with the special c2 option -i + * which avoids any problem areas with i/o addressing + * (e.g. for the VAX); assembler files are processed by as. + */ +void do_rules(f) + FILE *f; +{ + register char *cp, *np, och, *tp; + register struct file_list *ftp; + char *special; + + for (ftp = ftab; ftp != 0; ftp = ftp->f_next) { + if (ftp->f_type == INVISIBLE) + continue; + cp = (np = ftp->f_fn) + strlen(ftp->f_fn) - 1; + och = *cp; + *cp = '\0'; + if (och == 'o') { + fprintf(f, "%so:\n\t-cp $S/%so .\n\n", tail(np), np); + continue; + } + fprintf(f, "%so: $S/%s%c\n", tail(np), np, och); + tp = tail(np); + special = ftp->f_special; + if (special == 0) { + char *ftype; + static char cmd[128]; + + switch (ftp->f_type) { + + case NORMAL: + ftype = "NORMAL"; + break; + + case DRIVER: + ftype = "DRIVER"; + break; + + case PROFILING: + if (!profiling) + continue; + ftype = "PROFILE"; + break; + + default: + printf("config: don't know rules for %s\n", np); + break; + } + (void)sprintf(cmd, "${%s_%c%s}", ftype, toupper(och), + ftp->f_flags & CONFIGDEP? "_C" : ""); + special = cmd; + } + *cp = och; + fprintf(f, "\t%s\n\n", special); + } +} + +/* + * Create the load strings + */ +void do_load(f) + register FILE *f; +{ + register struct file_list *fl; + register int first; + struct file_list *do_systemspec(); + + for (first = 1, fl = conf_list; fl; first = 0) + fl = fl->f_type == SYSTEMSPEC ? + do_systemspec(f, fl, first) : fl->f_next; + fputs("all:", f); + for (fl = conf_list; fl; fl = fl->f_next) + if (fl->f_type == SYSTEMSPEC) + fprintf(f, " %s.elf", fl->f_needs); + putc('\n', f); +} + +/* + * Build the makefile from the skeleton + */ +void makefile() +{ + FILE *ifp, *ofp; + char line[BUFSIZ]; + struct opt *op; + struct users *up; + + read_files(); + strcpy(line, "Makefile."); + (void) strcat(line, machinename); + ifp = fopen(line, "r"); + if (ifp == 0) { + perror(line); + exit(1); + } + ofp = fopen(path("Makefile"), "w"); + if (ofp == 0) { + perror(path("Makefile")); + exit(1); + } + fprintf(ofp, "IDENT=-D%s", raise(ident)); + if (profiling) + fprintf(ofp, " -DGPROF"); + if (cputype == 0) { + printf("cpu type must be specified\n"); + exit(1); + } + { struct cputype *cp; + for (cp = cputype; cp; cp = cp->cpu_next) + fprintf(ofp, " -D%s", cp->cpu_name); + } + for (op = opt; op; op = op->op_next) + if (op->op_value) + fprintf(ofp, " -D%s=\"%s\"", op->op_name, op->op_value); + else + fprintf(ofp, " -D%s", op->op_name); + fprintf(ofp, "\n"); + if (ldscript) + fprintf(ofp, "LDSCRIPT=\"%s\"\n", ldscript); + if (hadtz == 0) + printf("timezone not specified; gmt assumed\n"); + if ((unsigned)machine > NUSERS) { + printf("maxusers config info isn't present, using vax\n"); + up = &users[MACHINE_VAX-1]; + } else + up = &users[machine-1]; + if (maxusers == 0) { + printf("maxusers not specified; %d assumed\n", up->u_default); + maxusers = up->u_default; + } else if (maxusers < up->u_min) { + printf("minimum of %d maxusers assumed\n", up->u_min); + maxusers = up->u_min; + } else if (maxusers > up->u_max) + printf("warning: maxusers > %d (%d)\n", up->u_max, maxusers); + fprintf(ofp, "PARAM=-DTIMEZONE=%d -DDST=%d -DMAXUSERS=%d", + zone, dst, maxusers); + if (hz > 0) + fprintf(ofp, " -DHZ=%d", hz); + fprintf(ofp, "\n"); + for (op = mkopt; op; op = op->op_next) + fprintf(ofp, "%s=%s\n", op->op_name, op->op_value); + if (debugging) + fprintf(ofp, "DEBUG=-g\n"); + if (profiling) + fprintf(ofp, "PROF=-pg\n"); + while (fgets(line, BUFSIZ, ifp) != 0) { + if (*line != '%') { + fprintf(ofp, "%s", line); + continue; + } + if (eq(line, "%OBJS\n")) + do_objs(ofp); + else if (eq(line, "%CFILES\n")) + do_cfiles(ofp); + else if (eq(line, "%RULES\n")) + do_rules(ofp); + else if (eq(line, "%LOAD\n")) + do_load(ofp); + else + fprintf(stderr, + "Unknown %% construct in generic makefile: %s", + line); + } + (void) fclose(ifp); + (void) fclose(ofp); +} + +char * +tail(fn) + char *fn; +{ + register char *cp; + + cp = rindex(fn, '/'); + if (cp == 0) + return (fn); + return (cp+1); +} + +void do_swapspec(f, name) + FILE *f; + register char *name; +{ + + if (!eq(name, "generic")) + fprintf(f, "swap%s.o: swap%s.c\n", name, name); + else + fprintf(f, "swapgeneric.o: $A/%s/swapgeneric.c\n", + machinename); + fprintf(f, "\t${NORMAL_C}\n\n"); +} + +struct file_list * +do_systemspec(f, fl, first) + FILE *f; + register struct file_list *fl; + int first; +{ + + fprintf(f, "%s.elf: ${SYSTEM_DEP} swap%s.o", fl->f_needs, fl->f_fn); + // Don't use newvers target. + // A preferred way is to run newvers.sh from SYSTEM_LD_HEAD macro. + //if (first) + // fprintf(f, " newvers"); + fprintf(f, "\n\t${SYSTEM_LD_HEAD}\n"); + fprintf(f, "\t${SYSTEM_LD} swap%s.o\n", fl->f_fn); + fprintf(f, "\t${SYSTEM_LD_TAIL}\n\n"); + do_swapspec(f, fl->f_fn); + for (fl = fl->f_next; fl; fl = fl->f_next) + if (fl->f_type != SWAPSPEC) + break; + return (fl); +} + +char * +raise(str) + register char *str; +{ + register char *cp = str; + + while (*str) { + if (islower(*str)) + *str = toupper(*str); + str++; + } + return (cp); +} diff --git a/tools/kconfig/mkswapconf.c b/tools/kconfig/mkswapconf.c new file mode 100644 index 0000000..2915654 --- /dev/null +++ b/tools/kconfig/mkswapconf.c @@ -0,0 +1,217 @@ +/* + * Copyright (c) 1980, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)mkswapconf.c 8.1 (Berkeley) 6/6/93"; +#endif /* not lint */ + +/* + * Build a swap configuration file. + */ +#include "config.h" + +#include +#include +#include + +void swapconf() +{ + register struct file_list *fl; + struct file_list *do_swap(); + + fl = conf_list; + while (fl) { + if (fl->f_type != SYSTEMSPEC) { + fl = fl->f_next; + continue; + } + fl = do_swap(fl); + } +} + +struct file_list * +do_swap(fl) + register struct file_list *fl; +{ + FILE *fp; + char swapname[80]; + register struct file_list *swap; + dev_t dev; + + if (eq(fl->f_fn, "generic")) { + fl = fl->f_next; + return (fl->f_next); + } + (void) sprintf(swapname, "swap%s.c", fl->f_fn); + fp = fopen(path(swapname), "w"); + if (fp == 0) { + perror(path(swapname)); + exit(1); + } + fprintf(fp, "#include \"sys/param.h\"\n"); + fprintf(fp, "#include \"sys/conf.h\"\n"); + fprintf(fp, "\n"); + /* + * If there aren't any swap devices + * specified, just return, the error + * has already been noted. + */ + swap = fl->f_next; + if (swap == 0 || swap->f_type != SWAPSPEC) { + (void) unlink(path(swapname)); + fclose(fp); + return (swap); + } + fprintf(fp, "dev_t\trootdev = makedev(%d, %d);\n", + major(fl->f_rootdev), minor(fl->f_rootdev)); + fprintf(fp, "dev_t\tdumpdev = makedev(%d, %d);\n", + major(fl->f_dumpdev), minor(fl->f_dumpdev)); + fprintf(fp, "\n"); + fprintf(fp, "struct\tswdevt swdevt[] = {\n"); + do { + dev = swap->f_swapdev; + fprintf(fp, "\t{ makedev(%d, %d),\t%d,\t%d },\t/* %s */\n", + major(dev), minor(dev), swap->f_swapflag, + swap->f_swapsize, swap->f_fn); + swap = swap->f_next; + } while (swap && swap->f_type == SWAPSPEC); + fprintf(fp, "\t{ NODEV, 0, 0 }\n"); + fprintf(fp, "};\n"); + fclose(fp); + return (swap); +} + +static int devtablenotread = 1; +static struct devdescription { + char *dev_name; + int dev_major; + struct devdescription *dev_next; +} *devtable; + +void initdevtable() +{ + char buf[BUFSIZ]; + int maj; + register struct devdescription **dp = &devtable; + FILE *fp; + + (void) sprintf(buf, "../conf/devices.%s", machinename); + fp = fopen(buf, "r"); + if (fp == NULL) { + fprintf(stderr, "config: can't open %s\n", buf); + exit(1); + } + while (fscanf(fp, "%s\t%d\n", buf, &maj) == 2) { + *dp = (struct devdescription *)malloc(sizeof (**dp)); + (*dp)->dev_name = ns(buf); + (*dp)->dev_major = maj; + dp = &(*dp)->dev_next; + } + *dp = 0; + fclose(fp); + devtablenotread = 0; +} + +/* + * Given a device name specification figure out: + * major device number + * partition + * device name + * unit number + * This is a hack, but the system still thinks in + * terms of major/minor instead of string names. + */ +dev_t +nametodev(name, defunit, defpartition) + char *name; + int defunit; + char defpartition; +{ + char *cp, partition; + int unit; + register struct devdescription *dp; + + cp = name; + if (cp == 0) { + fprintf(stderr, "config: internal error, nametodev\n"); + exit(1); + } + while (*cp && !isdigit(*cp)) + cp++; + unit = *cp ? atoi(cp) : defunit; + if (unit < 0 || unit > 31) { + fprintf(stderr, +"config: %s: invalid device specification, unit out of range\n", name); + unit = defunit; /* carry on more checking */ + } + if (*cp) { + *cp++ = '\0'; + while (*cp && isdigit(*cp)) + cp++; + } + partition = *cp ? *cp : defpartition; + if (partition < 'a' || partition > 'h') { + fprintf(stderr, +"config: %c: invalid device specification, bad partition\n", *cp); + partition = defpartition; /* carry on */ + } + if (devtablenotread) + initdevtable(); + for (dp = devtable; dp; dp = dp->dev_next) + if (eq(name, dp->dev_name)) + break; + if (dp == 0) { + fprintf(stderr, "config: %s: unknown device\n", name); + return (NODEV); + } + return (makedev(dp->dev_major, (unit << 3) + (partition - 'a'))); +} + +char * +devtoname(dev) + dev_t dev; +{ + char buf[80]; + register struct devdescription *dp; + + if (devtablenotread) + initdevtable(); + for (dp = devtable; dp; dp = dp->dev_next) + if (major(dev) == dp->dev_major) + break; + if (dp == 0) + dp = devtable; + (void) sprintf(buf, "%s%d%c", dp->dev_name, + minor(dev) >> 3, (minor(dev) & 07) + 'a'); + return (ns(buf)); +} diff --git a/tools/kconfig/mkubglue.c b/tools/kconfig/mkubglue.c new file mode 100644 index 0000000..7d2b3d4 --- /dev/null +++ b/tools/kconfig/mkubglue.c @@ -0,0 +1,196 @@ +/*- + * Copyright (c) 1980, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)mkubglue.c 8.1 (Berkeley) 6/6/93"; +#endif /* not lint */ + +/* + * Make the uba interrupt file ubglue.s + */ +#include +#include "config.h" +#include "y.tab.h" + +ubglue() +{ + register FILE *fp; + register struct device *dp, *mp; + + fp = fopen(path("ubglue.s"), "w"); + if (fp == 0) { + perror(path("ubglue.s")); + exit(1); + } + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (mp != 0 && mp != (struct device *)-1 && + !eq(mp->d_name, "mba")) { + struct idlst *id, *id2; + + for (id = dp->d_vec; id; id = id->id_next) { + for (id2 = dp->d_vec; id2; id2 = id2->id_next) { + if (id2 == id) { + dump_vec(fp, id->id, dp->d_unit); + break; + } + if (!strcmp(id->id, id2->id)) + break; + } + } + } + } + dump_std(fp); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (mp != 0 && mp != (struct device *)-1 && + !eq(mp->d_name, "mba")) { + struct idlst *id, *id2; + + for (id = dp->d_vec; id; id = id->id_next) { + for (id2 = dp->d_vec; id2; id2 = id2->id_next) { + if (id2 == id) { + dump_intname(fp, id->id, + dp->d_unit); + break; + } + if (!strcmp(id->id, id2->id)) + break; + } + } + } + } + dump_ctrs(fp); + (void) fclose(fp); +} + +static int cntcnt = 0; /* number of interrupt counters allocated */ + +/* + * print an interrupt vector + */ +dump_vec(fp, vector, number) + register FILE *fp; + char *vector; + int number; +{ + char nbuf[80]; + register char *v = nbuf; + + (void) sprintf(v, "%s%d", vector, number); + fprintf(fp, "\t.globl\t_X%s\n\t.align\t2\n_X%s:\n\tpushr\t$0x3f\n", + v, v); + fprintf(fp, "\tincl\t_fltintrcnt+(4*%d)\n", cntcnt++); + if (strncmp(vector, "dzx", 3) == 0) + fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdzdma\n\n", number); + else if (strncmp(vector, "dpx", 3) == 0) + fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdpxdma\n\n", number); + else if (strncmp(vector, "dpr", 3) == 0) + fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdprdma\n\n", number); + else { + if (strncmp(vector, "uur", 3) == 0) { + fprintf(fp, "#ifdef UUDMA\n"); + fprintf(fp, "\tmovl\t$%d,r0\n\tjsb\tuudma\n", number); + fprintf(fp, "#endif\n"); + } + fprintf(fp, "\tpushl\t$%d\n", number); + fprintf(fp, "\tcalls\t$1,_%s\n\tpopr\t$0x3f\n", vector); + fprintf(fp, "\tincl\t_cnt+V_INTR\n\trei\n\n"); + } +} + +/* + * Start the interrupt name table with the names + * of the standard vectors not on the unibus. + * The number and order of these names should correspond + * with the definitions in scb.s. + */ +dump_std(fp) + register FILE *fp; +{ + fprintf(fp, "\n\t.globl\t_intrnames\n"); + fprintf(fp, "\n\t.globl\t_eintrnames\n"); + fprintf(fp, "\t.data\n"); + fprintf(fp, "_intrnames:\n"); + fprintf(fp, "\t.asciz\t\"clock\"\n"); + fprintf(fp, "\t.asciz\t\"cnr\"\n"); + fprintf(fp, "\t.asciz\t\"cnx\"\n"); + fprintf(fp, "\t.asciz\t\"tur\"\n"); + fprintf(fp, "\t.asciz\t\"tux\"\n"); + fprintf(fp, "\t.asciz\t\"mba0\"\n"); + fprintf(fp, "\t.asciz\t\"mba1\"\n"); + fprintf(fp, "\t.asciz\t\"mba2\"\n"); + fprintf(fp, "\t.asciz\t\"mba3\"\n"); + fprintf(fp, "\t.asciz\t\"uba0\"\n"); + fprintf(fp, "\t.asciz\t\"uba1\"\n"); + fprintf(fp, "\t.asciz\t\"uba2\"\n"); + fprintf(fp, "\t.asciz\t\"uba3\"\n"); +#define I_FIXED 13 /* number of names above */ +} + +dump_intname(fp, vector, number) + register FILE *fp; + char *vector; + int number; +{ + register char *cp = vector; + + fprintf(fp, "\t.asciz\t\""); + /* + * Skip any "int" or "intr" in the name. + */ + while (*cp) + if (cp[0] == 'i' && cp[1] == 'n' && cp[2] == 't') { + cp += 3; + if (*cp == 'r') + cp++; + } else { + putc(*cp, fp); + cp++; + } + fprintf(fp, "%d\"\n", number); +} + +dump_ctrs(fp) + register FILE *fp; +{ + fprintf(fp, "_eintrnames:\n"); + fprintf(fp, "\n\t.globl\t_intrcnt\n"); + fprintf(fp, "\n\t.globl\t_eintrcnt\n"); + fprintf(fp, "_intrcnt:\n", I_FIXED); + fprintf(fp, "\t.space\t4 * %d\n", I_FIXED); + fprintf(fp, "_fltintrcnt:\n", cntcnt); + fprintf(fp, "\t.space\t4 * %d\n", cntcnt); + fprintf(fp, "_eintrcnt:\n\n"); + fprintf(fp, "\t.text\n"); +} From b72cfc52f9354cb999b52f752143ee5474071d93 Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Mon, 1 Jun 2015 17:35:25 -0700 Subject: [PATCH 2/8] Kconfig compiled clean. --- tools/kconfig/Makefile | 25 +++++++++++++++---------- tools/kconfig/Makefile-bsd | 12 ++++++++++++ tools/kconfig/config.y | 2 -- tools/kconfig/lang.l | 3 +++ tools/kconfig/main.c | 11 ----------- tools/kconfig/mkglue.c | 13 ++++++------- tools/kconfig/mkheaders.c | 4 ---- tools/kconfig/mkioconf.c | 7 +------ tools/kconfig/mkmakefile.c | 13 ++++--------- tools/kconfig/mkswapconf.c | 4 ---- tools/kconfig/mkubglue.c | 4 ---- 11 files changed, 41 insertions(+), 57 deletions(-) create mode 100644 tools/kconfig/Makefile-bsd diff --git a/tools/kconfig/Makefile b/tools/kconfig/Makefile index fa710fa..96fe255 100644 --- a/tools/kconfig/Makefile +++ b/tools/kconfig/Makefile @@ -1,12 +1,17 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 +CC = gcc -g +CFLAGS = -O -Wall +YACC = byacc -d +DESTDIR = /usr/local +OBJS = config.o main.o lang.o mkioconf.o mkmakefile.o mkglue.o mkheaders.o \ + mkswapconf.o +PROG = kconfig -PROG= config -CFLAGS+=-I. -I${.CURDIR} -SRCS= config.c main.c lang.c mkioconf.c mkmakefile.c mkglue.c mkheaders.c \ - mkswapconf.c -MAN8= config.0 -DPADD= ${LIBL} -LDADD= -ll -CLEANFILES+=y.tab.h lang.c config.c y.tab.c config.0 +all: $(PROG) -.include +install: $(PROG) + install -s $(PROG) ${DESTDIR}/bin/$(PROG) +clean: + rm -rf *~ *.o *.lst *.dis $(PROG) $(PROG).dSYM y.tab.[ch] lang.c config.c + +$(PROG): $(OBJS) + $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) diff --git a/tools/kconfig/Makefile-bsd b/tools/kconfig/Makefile-bsd new file mode 100644 index 0000000..fa710fa --- /dev/null +++ b/tools/kconfig/Makefile-bsd @@ -0,0 +1,12 @@ +# @(#)Makefile 8.1 (Berkeley) 6/6/93 + +PROG= config +CFLAGS+=-I. -I${.CURDIR} +SRCS= config.c main.c lang.c mkioconf.c mkmakefile.c mkglue.c mkheaders.c \ + mkswapconf.c +MAN8= config.0 +DPADD= ${LIBL} +LDADD= -ll +CLEANFILES+=y.tab.h lang.c config.c y.tab.c config.0 + +.include diff --git a/tools/kconfig/config.y b/tools/kconfig/config.y index 0998289..9093296 100644 --- a/tools/kconfig/config.y +++ b/tools/kconfig/config.y @@ -709,7 +709,6 @@ void mkswap(system, fl, size, flag) int size, flag; { register struct file_list **flp; - char name[80]; if (system == 0 || system->f_type != SYSTEMSPEC) { yyerror("\"swap\" spec precedes \"config\" specification"); @@ -765,7 +764,6 @@ void addcomp(compdev, fl) struct file_list *compdev, *fl; { register struct file_list **flp; - char name[80]; if (compdev == 0 || compdev->f_type != COMPDEVICE) { yyerror("component spec precedes device specification"); diff --git a/tools/kconfig/lang.l b/tools/kconfig/lang.l index 802dd9b..12431d1 100644 --- a/tools/kconfig/lang.l +++ b/tools/kconfig/lang.l @@ -1,3 +1,6 @@ +%option noinput +%option nounput +%option noyywrap %{ /*- * Copyright (c) 1980, 1993 diff --git a/tools/kconfig/main.c b/tools/kconfig/main.c index 8d04b76..82569b0 100644 --- a/tools/kconfig/main.c +++ b/tools/kconfig/main.c @@ -30,17 +30,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1980, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - #include #include #include diff --git a/tools/kconfig/mkglue.c b/tools/kconfig/mkglue.c index a94c1cd..81ab74f 100644 --- a/tools/kconfig/mkglue.c +++ b/tools/kconfig/mkglue.c @@ -31,10 +31,6 @@ * SUCH DAMAGE. */ -#ifndef lint -static char sccsid[] = "@(#)mkglue.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - /* * Make the bus adaptor interrupt glue files. */ @@ -331,13 +327,16 @@ void vbglue() * HP9000/300 interrupts are auto-vectored. * Code is hardwired in locore.s */ -void hpglue() {} +void hpglue() +{ +} /* * Create the ISA interrupt vector glue file. */ -void vector() { - register FILE *fp, *gp; +void vector() +{ + register FILE *fp; register struct device *dp, *mp; int count; diff --git a/tools/kconfig/mkheaders.c b/tools/kconfig/mkheaders.c index 7c93587..b86a481 100644 --- a/tools/kconfig/mkheaders.c +++ b/tools/kconfig/mkheaders.c @@ -31,10 +31,6 @@ * SUCH DAMAGE. */ -#ifndef lint -static char sccsid[] = "@(#)mkheaders.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - /* * Make all the .h files for the optional entries */ diff --git a/tools/kconfig/mkioconf.c b/tools/kconfig/mkioconf.c index 313cf53..ef77297 100644 --- a/tools/kconfig/mkioconf.c +++ b/tools/kconfig/mkioconf.c @@ -31,10 +31,6 @@ * SUCH DAMAGE. */ -#ifndef lint -static char sccsid[] = "@(#)mkioconf.c 8.2 (Berkeley) 1/21/94"; -#endif /* not lint */ - #include #include "y.tab.h" #include "config.h" @@ -604,8 +600,7 @@ char *sirq(int); void i386_ioconf() { - register struct device *dp, *mp, *np; - register int uba_n, slave; + register struct device *dp, *mp; FILE *fp; fp = fopen(path("ioconf.c"), "w"); diff --git a/tools/kconfig/mkmakefile.c b/tools/kconfig/mkmakefile.c index 14307c4..dc3f6d4 100644 --- a/tools/kconfig/mkmakefile.c +++ b/tools/kconfig/mkmakefile.c @@ -31,10 +31,6 @@ * SUCH DAMAGE. */ -#ifndef lint -static char sccsid[] = "@(#)mkmakefile.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - /* * Build the makefile for the system, from * the information in the files files and the @@ -157,7 +153,7 @@ void read_files() FILE *fp; register struct file_list *tp, *pf; register struct device *dp; - struct device *save_dp; + struct device *save_dp = 0; register struct opt *op; char *wd, *this, *needs, *special; char fname[32]; @@ -267,7 +263,8 @@ nextparam: dp->d_name = ns(wd); dp->d_type = PSEUDO_DEVICE; dp->d_slave = 1; - save_dp->d_next = dp; + if (save_dp) + save_dp->d_next = dp; goto nextparam; } for (op = opt; op != 0; op = op->op_next) @@ -297,7 +294,6 @@ doneparam: exit(1); } -save: if (wd) { printf("%s: syntax error describing %s\n", fname, this); @@ -406,7 +402,7 @@ void do_cfiles(fp) void do_rules(f) FILE *f; { - register char *cp, *np, och, *tp; + register char *cp, *np, och; register struct file_list *ftp; char *special; @@ -421,7 +417,6 @@ void do_rules(f) continue; } fprintf(f, "%so: $S/%s%c\n", tail(np), np, och); - tp = tail(np); special = ftp->f_special; if (special == 0) { char *ftype; diff --git a/tools/kconfig/mkswapconf.c b/tools/kconfig/mkswapconf.c index 2915654..89bb92d 100644 --- a/tools/kconfig/mkswapconf.c +++ b/tools/kconfig/mkswapconf.c @@ -31,10 +31,6 @@ * SUCH DAMAGE. */ -#ifndef lint -static char sccsid[] = "@(#)mkswapconf.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - /* * Build a swap configuration file. */ diff --git a/tools/kconfig/mkubglue.c b/tools/kconfig/mkubglue.c index 7d2b3d4..51ea8ae 100644 --- a/tools/kconfig/mkubglue.c +++ b/tools/kconfig/mkubglue.c @@ -31,10 +31,6 @@ * SUCH DAMAGE. */ -#ifndef lint -static char sccsid[] = "@(#)mkubglue.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - /* * Make the uba interrupt file ubglue.s */ From ff8175118896088b7f1624aba5b7d021db33e6e4 Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Mon, 1 Jun 2015 17:58:14 -0700 Subject: [PATCH 3/8] Kconfig reindented to 4 spaces. --- tools/kconfig/config.h | 226 ++-- tools/kconfig/config.y | 1698 +++++++++++++++--------------- tools/kconfig/lang.l | 254 ++--- tools/kconfig/main.c | 331 +++--- tools/kconfig/mkglue.c | 536 +++++----- tools/kconfig/mkheaders.c | 258 ++--- tools/kconfig/mkioconf.c | 2002 ++++++++++++++++++------------------ tools/kconfig/mkmakefile.c | 920 ++++++++--------- tools/kconfig/mkswapconf.c | 282 ++--- tools/kconfig/mkubglue.c | 242 ++--- 10 files changed, 3413 insertions(+), 3336 deletions(-) diff --git a/tools/kconfig/config.h b/tools/kconfig/config.h index f801e3d..9bf8ea2 100644 --- a/tools/kconfig/config.h +++ b/tools/kconfig/config.h @@ -1,6 +1,6 @@ /* * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -12,8 +12,8 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. + * This product includes software developed by the University of + * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)config.h 8.1 (Berkeley) 6/6/93 + * @(#)config.h 8.1 (Berkeley) 6/6/93 */ /* @@ -40,95 +40,95 @@ #include #include -#define NODEV ((dev_t)-1) +#define NODEV ((dev_t)-1) struct file_list { - struct file_list *f_next; - char *f_fn; /* the name */ - u_char f_type; /* see below */ - u_char f_flags; /* see below */ - char *f_special; /* special make rule if present */ - char *f_needs; - /* - * Random values: - * swap space parameters for swap areas - * root device, etc. for system specifications - */ - union { - struct { /* when swap specification */ - dev_t fuw_swapdev; - int fuw_swapsize; - int fuw_swapflag; - } fuw; - struct { /* when system specification */ - dev_t fus_rootdev; - dev_t fus_dumpdev; - } fus; - struct { /* when component dev specification */ - dev_t fup_compdev; - int fup_compinfo; - } fup; - } fun; -#define f_swapdev fun.fuw.fuw_swapdev -#define f_swapsize fun.fuw.fuw_swapsize -#define f_swapflag fun.fuw.fuw_swapflag -#define f_rootdev fun.fus.fus_rootdev -#define f_dumpdev fun.fus.fus_dumpdev -#define f_compdev fun.fup.fup_compdev -#define f_compinfo fun.fup.fup_compinfo + struct file_list *f_next; + char *f_fn; /* the name */ + u_char f_type; /* see below */ + u_char f_flags; /* see below */ + char *f_special; /* special make rule if present */ + char *f_needs; + /* + * Random values: + * swap space parameters for swap areas + * root device, etc. for system specifications + */ + union { + struct { /* when swap specification */ + dev_t fuw_swapdev; + int fuw_swapsize; + int fuw_swapflag; + } fuw; + struct { /* when system specification */ + dev_t fus_rootdev; + dev_t fus_dumpdev; + } fus; + struct { /* when component dev specification */ + dev_t fup_compdev; + int fup_compinfo; + } fup; + } fun; +#define f_swapdev fun.fuw.fuw_swapdev +#define f_swapsize fun.fuw.fuw_swapsize +#define f_swapflag fun.fuw.fuw_swapflag +#define f_rootdev fun.fus.fus_rootdev +#define f_dumpdev fun.fus.fus_dumpdev +#define f_compdev fun.fup.fup_compdev +#define f_compinfo fun.fup.fup_compinfo }; /* * Types. */ -#define DRIVER 1 -#define NORMAL 2 -#define INVISIBLE 3 -#define PROFILING 4 -#define SYSTEMSPEC 5 -#define SWAPSPEC 6 -#define COMPDEVICE 7 -#define COMPSPEC 8 +#define DRIVER 1 +#define NORMAL 2 +#define INVISIBLE 3 +#define PROFILING 4 +#define SYSTEMSPEC 5 +#define SWAPSPEC 6 +#define COMPDEVICE 7 +#define COMPSPEC 8 /* * Attributes (flags). */ -#define CONFIGDEP 1 +#define CONFIGDEP 1 -struct idlst { - char *id; - struct idlst *id_next; +struct idlst { + char *id; + struct idlst *id_next; }; struct device { - int d_type; /* CONTROLLER, DEVICE, bus adaptor */ - struct device *d_conn; /* what it is connected to */ - char *d_name; /* name of device (e.g. rk11) */ - struct idlst *d_vec; /* interrupt vectors */ - int d_pri; /* interrupt priority */ - int d_addr; /* address of csr */ - int d_unit; /* unit number */ - int d_drive; /* drive number */ - int d_slave; /* slave number */ -#define QUES -1 /* -1 means '?' */ -#define UNKNOWN -2 /* -2 means not set yet */ - int d_dk; /* if init 1 set to number for iostat */ - int d_flags; /* flags for device init */ - char *d_port; /* io port base manifest constant */ - int d_portn; /* io port base (if number not manifest) */ - char *d_mask; /* interrupt mask */ - int d_maddr; /* io memory base */ - int d_msize; /* io memory size */ - int d_drq; /* DMA request */ - int d_irq; /* interrupt request */ - struct device *d_next; /* Next one in list */ + int d_type; /* CONTROLLER, DEVICE, bus adaptor */ + struct device *d_conn; /* what it is connected to */ + char *d_name; /* name of device (e.g. rk11) */ + struct idlst *d_vec; /* interrupt vectors */ + int d_pri; /* interrupt priority */ + int d_addr; /* address of csr */ + int d_unit; /* unit number */ + int d_drive; /* drive number */ + int d_slave; /* slave number */ +#define QUES -1 /* -1 means '?' */ +#define UNKNOWN -2 /* -2 means not set yet */ + int d_dk; /* if init 1 set to number for iostat */ + int d_flags; /* flags for device init */ + char *d_port; /* io port base manifest constant */ + int d_portn; /* io port base (if number not manifest) */ + char *d_mask; /* interrupt mask */ + int d_maddr; /* io memory base */ + int d_msize; /* io memory size */ + int d_drq; /* DMA request */ + int d_irq; /* interrupt request */ + struct device *d_next; /* Next one in list */ }; -#define TO_NEXUS (struct device *)-1 -#define TO_VBA (struct device *)-2 +#define TO_NEXUS (struct device *)-1 +#define TO_VBA (struct device *)-2 struct config { - char *c_dev; - char *s_sysname; + char *c_dev; + char *s_sysname; }; /* @@ -138,12 +138,12 @@ struct config { * it will build from ``Makefile.vax'' and use ``../vax/inline'' * in the makerules, etc. */ -int machine; -char *machinename; -#define MACHINE_VAX 1 -#define MACHINE_TAHOE 2 +int machine; +char *machinename; +#define MACHINE_VAX 1 +#define MACHINE_TAHOE 2 #define MACHINE_HP300 3 -#define MACHINE_I386 4 +#define MACHINE_I386 4 #define MACHINE_MIPS 5 #define MACHINE_PMAX 6 #define MACHINE_LUNA68K 7 @@ -155,8 +155,8 @@ char *machinename; * These and the options (below) are put in the C flags in the makefile. */ struct cputype { - char *cpu_name; - struct cputype *cpu_next; + char *cpu_name; + struct cputype *cpu_next; } *cputype; /* @@ -165,53 +165,53 @@ struct cputype { * A separate set of options may be defined for make-style options. */ struct opt { - char *op_name; - char *op_value; - struct opt *op_next; + char *op_name; + char *op_value; + struct opt *op_next; } *opt, *mkopt; -char *ident; -char *ldscript; -char *ns(); -char *tc(); -char *qu(); -char *get_word(); -char *get_quoted_word(); -char *path(); -char *raise(); +char *ident; +char *ldscript; +char *ns(); +char *tc(); +char *qu(); +char *get_word(); +char *get_quoted_word(); +char *path(); +char *raise(); -int do_trace; +int do_trace; #if MACHINE_VAX -int seen_mba, seen_uba; +int seen_mba, seen_uba; #endif #if MACHINE_TAHOE -int seen_vba; +int seen_vba; #endif #if MACHINE_I386 -int seen_isa; +int seen_isa; #endif -int seen_cd; +int seen_cd; -struct device *connect(); -struct device *dtab; -dev_t nametodev(); -char *devtoname(); +struct device *connect(); +struct device *dtab; +dev_t nametodev(); +char *devtoname(); -char errbuf[80]; -int yyline; +char errbuf[80]; +int yyline; -struct file_list *ftab, *conf_list, **confp, *comp_list, **compp; +struct file_list *ftab, *conf_list, **confp, *comp_list, **compp; -int zone, hadtz; -int dst; -int hz; -int profiling; -int debugging; +int zone, hadtz; +int dst; +int hz; +int profiling; +int debugging; -int maxusers; +int maxusers; -#define eq(a,b) (!strcmp(a,b)) +#define eq(a,b) (!strcmp(a,b)) void init_dev(register struct device *dp); int yyparse(void); diff --git a/tools/kconfig/config.y b/tools/kconfig/config.y index 9093296..8382695 100644 --- a/tools/kconfig/config.y +++ b/tools/kconfig/config.y @@ -1,83 +1,83 @@ %union { - char *str; - int val; - struct file_list *file; - struct idlst *lst; + char *str; + int val; + struct file_list *file; + struct idlst *lst; } -%token AND -%token ANY -%token ARGS -%token AT -%token BIO -%token COMMA -%token CONFIG -%token CONTROLLER -%token CPU -%token CSR -%token DEVICE -%token DISK -%token DRIVE -%token DRQ -%token DST -%token DUMPS -%token EQUALS -%token FLAGS -%token HZ -%token IDENT -%token INTERLEAVE -%token IOMEM -%token IOSIZ -%token IRQ -%token LDSCRIPT -%token MACHINE -%token MAJOR -%token MASTER -%token MAXUSERS -%token MINOR -%token MINUS -%token NET -%token NEXUS -%token ON -%token OPTIONS -%token MAKEOPTIONS -%token PORT -%token PRIORITY -%token PSEUDO_DEVICE -%token ROOT -%token SEMICOLON -%token SEQUENTIAL -%token SIZE -%token SLAVE -%token SWAP -%token TIMEZONE -%token TTY -%token TRACE -%token VECTOR +%token AND +%token ANY +%token ARGS +%token AT +%token BIO +%token COMMA +%token CONFIG +%token CONTROLLER +%token CPU +%token CSR +%token DEVICE +%token DISK +%token DRIVE +%token DRQ +%token DST +%token DUMPS +%token EQUALS +%token FLAGS +%token HZ +%token IDENT +%token INTERLEAVE +%token IOMEM +%token IOSIZ +%token IRQ +%token LDSCRIPT +%token MACHINE +%token MAJOR +%token MASTER +%token MAXUSERS +%token MINOR +%token MINUS +%token NET +%token NEXUS +%token ON +%token OPTIONS +%token MAKEOPTIONS +%token PORT +%token PRIORITY +%token PSEUDO_DEVICE +%token ROOT +%token SEMICOLON +%token SEQUENTIAL +%token SIZE +%token SLAVE +%token SWAP +%token TIMEZONE +%token TTY +%token TRACE +%token VECTOR -%token ID -%token NUMBER -%token FPNUMBER +%token ID +%token NUMBER +%token FPNUMBER -%type Save_id -%type Opt_value -%type Dev -%type Id_list -%type optional_size -%type optional_sflag -%type device_name -%type major_minor -%type arg_device_spec -%type root_device_spec -%type dump_device_spec -%type swap_device_spec -%type comp_device_spec +%type Save_id +%type Opt_value +%type Dev +%type Id_list +%type optional_size +%type optional_sflag +%type device_name +%type major_minor +%type arg_device_spec +%type root_device_spec +%type dump_device_spec +%type swap_device_spec +%type comp_device_spec %{ /* * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -89,8 +89,8 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. + * This product includes software developed by the University of + * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -107,17 +107,17 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)config.y 8.1 (Berkeley) 6/6/93 + * @(#)config.y 8.1 (Berkeley) 6/6/93 */ #include "config.h" #include #include -struct device cur; -struct device *curp = 0; -char *temp_id; -char *val_id; +struct device cur; +struct device *curp = 0; +char *temp_id; +char *val_id; int yylex(void); int finddev(dev_t dev); @@ -127,510 +127,577 @@ int alreadychecked(dev_t dev, dev_t list[], dev_t *last); %} %% Configuration: - Many_specs - = { verifysystemspecs(); } - ; + Many_specs + = { verifysystemspecs(); } + ; Many_specs: - Many_specs Spec - | - /* lambda */ - ; + Many_specs Spec + | + /* lambda */ + ; Spec: - Device_spec SEMICOLON - = { newdev(&cur); } | - Config_spec SEMICOLON - | - TRACE SEMICOLON - = { do_trace = !do_trace; } | - SEMICOLON - | - error SEMICOLON - ; + Device_spec SEMICOLON + = { newdev(&cur); } + | + Config_spec SEMICOLON + | + TRACE SEMICOLON + = { do_trace = !do_trace; } + | + SEMICOLON + | + error SEMICOLON + ; Config_spec: - MACHINE Save_id - = { - if (!strcmp($2, "vax")) { - machine = MACHINE_VAX; - machinename = "vax"; - } else if (!strcmp($2, "tahoe")) { - machine = MACHINE_TAHOE; - machinename = "tahoe"; - } else if (!strcmp($2, "hp300")) { - machine = MACHINE_HP300; - machinename = "hp300"; - } else if (!strcmp($2, "i386")) { - machine = MACHINE_I386; - machinename = "i386"; - } else if (!strcmp($2, "mips")) { - machine = MACHINE_MIPS; - machinename = "mips"; - } else if (!strcmp($2, "pmax")) { - machine = MACHINE_PMAX; - machinename = "pmax"; - } else if (!strcmp($2, "pic32")) { - machine = MACHINE_PIC32; - machinename = "pic32"; - } else if (!strcmp($2, "luna68k")) { - machine = MACHINE_LUNA68K; - machinename = "luna68k"; - } else if (!strcmp($2, "news3400")) { - machine = MACHINE_NEWS3400; - machinename = "news3400"; - } else - yyerror("Unknown machine type"); - } | - CPU Save_id - = { - struct cputype *cp = - (struct cputype *)malloc(sizeof (struct cputype)); - cp->cpu_name = ns($2); - cp->cpu_next = cputype; - cputype = cp; - free(temp_id); - } | - OPTIONS Opt_list - | - MAKEOPTIONS Mkopt_list - | - IDENT ID - = { ident = ns($2); } | - LDSCRIPT ID - = { ldscript = ns($2); } | - System_spec - | - HZ NUMBER - = { hz = $2; }| - TIMEZONE NUMBER - = { zone = 60 * $2; check_tz(); } | - TIMEZONE NUMBER DST NUMBER - = { zone = 60 * $2; dst = $4; check_tz(); } | - TIMEZONE NUMBER DST - = { zone = 60 * $2; dst = 1; check_tz(); } | - TIMEZONE FPNUMBER - = { zone = $2; check_tz(); } | - TIMEZONE FPNUMBER DST NUMBER - = { zone = $2; dst = $4; check_tz(); } | - TIMEZONE FPNUMBER DST - = { zone = $2; dst = 1; check_tz(); } | - TIMEZONE MINUS NUMBER - = { zone = -60 * $3; check_tz(); } | - TIMEZONE MINUS NUMBER DST NUMBER - = { zone = -60 * $3; dst = $5; check_tz(); } | - TIMEZONE MINUS NUMBER DST - = { zone = -60 * $3; dst = 1; check_tz(); } | - TIMEZONE MINUS FPNUMBER - = { zone = -$3; check_tz(); } | - TIMEZONE MINUS FPNUMBER DST NUMBER - = { zone = -$3; dst = $5; check_tz(); } | - TIMEZONE MINUS FPNUMBER DST - = { zone = -$3; dst = 1; check_tz(); } | - MAXUSERS NUMBER - = { maxusers = $2; }; + MACHINE Save_id + = { + if (!strcmp($2, "vax")) { + machine = MACHINE_VAX; + machinename = "vax"; + } else if (!strcmp($2, "tahoe")) { + machine = MACHINE_TAHOE; + machinename = "tahoe"; + } else if (!strcmp($2, "hp300")) { + machine = MACHINE_HP300; + machinename = "hp300"; + } else if (!strcmp($2, "i386")) { + machine = MACHINE_I386; + machinename = "i386"; + } else if (!strcmp($2, "mips")) { + machine = MACHINE_MIPS; + machinename = "mips"; + } else if (!strcmp($2, "pmax")) { + machine = MACHINE_PMAX; + machinename = "pmax"; + } else if (!strcmp($2, "pic32")) { + machine = MACHINE_PIC32; + machinename = "pic32"; + } else if (!strcmp($2, "luna68k")) { + machine = MACHINE_LUNA68K; + machinename = "luna68k"; + } else if (!strcmp($2, "news3400")) { + machine = MACHINE_NEWS3400; + machinename = "news3400"; + } else + yyerror("Unknown machine type"); + } + | + CPU Save_id + = { + struct cputype *cp = + (struct cputype *)malloc(sizeof (struct cputype)); + cp->cpu_name = ns($2); + cp->cpu_next = cputype; + cputype = cp; + free(temp_id); + } + | + OPTIONS Opt_list + | + MAKEOPTIONS Mkopt_list + | + IDENT ID + = { ident = ns($2); } + | + LDSCRIPT ID + = { ldscript = ns($2); } + | + System_spec + | + HZ NUMBER + = { hz = $2; } + | + TIMEZONE NUMBER + = { zone = 60 * $2; check_tz(); } + | + TIMEZONE NUMBER DST NUMBER + = { zone = 60 * $2; dst = $4; check_tz(); } + | + TIMEZONE NUMBER DST + = { zone = 60 * $2; dst = 1; check_tz(); } + | + TIMEZONE FPNUMBER + = { zone = $2; check_tz(); } + | + TIMEZONE FPNUMBER DST NUMBER + = { zone = $2; dst = $4; check_tz(); } + | + TIMEZONE FPNUMBER DST + = { zone = $2; dst = 1; check_tz(); } + | + TIMEZONE MINUS NUMBER + = { zone = -60 * $3; check_tz(); } + | + TIMEZONE MINUS NUMBER DST NUMBER + = { zone = -60 * $3; dst = $5; check_tz(); } + | + TIMEZONE MINUS NUMBER DST + = { zone = -60 * $3; dst = 1; check_tz(); } + | + TIMEZONE MINUS FPNUMBER + = { zone = -$3; check_tz(); } + | + TIMEZONE MINUS FPNUMBER DST NUMBER + = { zone = -$3; dst = $5; check_tz(); } + | + TIMEZONE MINUS FPNUMBER DST + = { zone = -$3; dst = 1; check_tz(); } + | + MAXUSERS NUMBER + = { maxusers = $2; } + ; System_spec: - System_id System_parameter_list - = { checksystemspec(*confp); } - ; + System_id System_parameter_list + = { checksystemspec(*confp); } + ; System_id: - CONFIG Save_id - = { mkconf($2); } - ; + CONFIG Save_id + = { mkconf($2); } + ; System_parameter_list: - System_parameter_list System_parameter - | System_parameter - ; + System_parameter_list System_parameter + | + System_parameter + ; System_parameter: - swap_spec - | root_spec - | dump_spec - | arg_spec - ; + swap_spec + | + root_spec + | + dump_spec + | + arg_spec + ; swap_spec: - SWAP optional_on swap_device_list - ; + SWAP optional_on swap_device_list + ; swap_device_list: - swap_device_list AND swap_device - | swap_device - ; + swap_device_list AND swap_device + | + swap_device + ; swap_device: - swap_device_spec optional_size optional_sflag - = { mkswap(*confp, $1, $2, $3); } - ; + swap_device_spec optional_size optional_sflag + = { mkswap(*confp, $1, $2, $3); } + ; swap_device_spec: - device_name - = { - struct file_list *fl = newflist(SWAPSPEC); + device_name + = { + struct file_list *fl = newflist(SWAPSPEC); - if (eq($1, "generic")) - fl->f_fn = $1; - else { - fl->f_swapdev = nametodev($1, 0, 'b'); - fl->f_fn = devtoname(fl->f_swapdev); - } - $$ = fl; - } - | major_minor - = { - struct file_list *fl = newflist(SWAPSPEC); + if (eq($1, "generic")) + fl->f_fn = $1; + else { + fl->f_swapdev = nametodev($1, 0, 'b'); + fl->f_fn = devtoname(fl->f_swapdev); + } + $$ = fl; + } + | + major_minor + = { + struct file_list *fl = newflist(SWAPSPEC); - fl->f_swapdev = $1; - fl->f_fn = devtoname($1); - $$ = fl; - } - ; + fl->f_swapdev = $1; + fl->f_fn = devtoname($1); + $$ = fl; + } + ; root_spec: - ROOT optional_on root_device_spec - = { - struct file_list *fl = *confp; + ROOT optional_on root_device_spec + = { + struct file_list *fl = *confp; - if (fl && fl->f_rootdev != NODEV) - yyerror("extraneous root device specification"); - else - fl->f_rootdev = $3; - } - ; + if (fl && fl->f_rootdev != NODEV) + yyerror("extraneous root device specification"); + else + fl->f_rootdev = $3; + } + ; root_device_spec: - device_name - = { $$ = nametodev($1, 0, 'a'); } - | major_minor - ; + device_name + = { $$ = nametodev($1, 0, 'a'); } + | + major_minor + ; dump_spec: - DUMPS optional_on dump_device_spec - = { - struct file_list *fl = *confp; + DUMPS optional_on dump_device_spec + = { + struct file_list *fl = *confp; - if (fl && fl->f_dumpdev != NODEV) - yyerror("extraneous dump device specification"); - else - fl->f_dumpdev = $3; - } - - ; + if (fl && fl->f_dumpdev != NODEV) + yyerror("extraneous dump device specification"); + else + fl->f_dumpdev = $3; + } + ; dump_device_spec: - device_name - = { $$ = nametodev($1, 0, 'b'); } - | major_minor - ; + device_name + = { $$ = nametodev($1, 0, 'b'); } + | + major_minor + ; arg_spec: - ARGS optional_on arg_device_spec - = { yyerror("arg device specification obsolete, ignored"); } - ; + ARGS optional_on arg_device_spec + = { yyerror("arg device specification obsolete, ignored"); } + ; arg_device_spec: - device_name - = { $$ = nametodev($1, 0, 'b'); } - | major_minor - ; + device_name + = { $$ = nametodev($1, 0, 'b'); } + | + major_minor + ; major_minor: - MAJOR NUMBER MINOR NUMBER - = { $$ = makedev($2, $4); } - ; + MAJOR NUMBER MINOR NUMBER + = { $$ = makedev($2, $4); } + ; optional_on: - ON - | /* empty */ - ; + ON + | + /* empty */ + ; optional_size: - SIZE NUMBER - = { $$ = $2; } - | /* empty */ - = { $$ = 0; } - ; + SIZE NUMBER + = { $$ = $2; } + | + /* empty */ + = { $$ = 0; } + ; optional_sflag: - SEQUENTIAL - = { $$ = 2; } - | /* empty */ - = { $$ = 0; } - ; + SEQUENTIAL + = { $$ = 2; } + | + /* empty */ + = { $$ = 0; } + ; device_name: - Save_id - = { $$ = $1; } - | Save_id NUMBER - = { - char buf[80]; + Save_id + = { $$ = $1; } + | + Save_id NUMBER + = { + char buf[80]; - (void) sprintf(buf, "%s%d", $1, $2); - $$ = ns(buf); free($1); - } - | Save_id NUMBER ID - = { - char buf[80]; + (void) sprintf(buf, "%s%d", $1, $2); + $$ = ns(buf); free($1); + } + | + Save_id NUMBER ID + = { + char buf[80]; - (void) sprintf(buf, "%s%d%s", $1, $2, $3); - $$ = ns(buf); free($1); - } - ; + (void) sprintf(buf, "%s%d%s", $1, $2, $3); + $$ = ns(buf); free($1); + } + ; Opt_list: - Opt_list COMMA Option - | - Option - ; + Opt_list COMMA Option + | + Option + ; Option: - Save_id - = { - struct opt *op = (struct opt *)malloc(sizeof (struct opt)); - op->op_name = ns($1); - op->op_next = opt; - op->op_value = 0; - opt = op; - free(temp_id); - } | - Save_id EQUALS Opt_value - = { - struct opt *op = (struct opt *)malloc(sizeof (struct opt)); - op->op_name = ns($1); - op->op_next = opt; - op->op_value = ns($3); - opt = op; - free(temp_id); - free(val_id); - } ; + Save_id + = { + struct opt *op = (struct opt *)malloc(sizeof (struct opt)); + op->op_name = ns($1); + op->op_next = opt; + op->op_value = 0; + opt = op; + free(temp_id); + } + | + Save_id EQUALS Opt_value + = { + struct opt *op = (struct opt *)malloc(sizeof (struct opt)); + op->op_name = ns($1); + op->op_next = opt; + op->op_value = ns($3); + opt = op; + free(temp_id); + free(val_id); + } + ; Opt_value: - ID - = { $$ = val_id = ns($1); } | - NUMBER - = { - char nb[16]; - (void) sprintf(nb, "%d", $1); - $$ = val_id = ns(nb); - } ; - + ID + = { $$ = val_id = ns($1); } + | + NUMBER + = { + char nb[16]; + (void) sprintf(nb, "%d", $1); + $$ = val_id = ns(nb); + } + ; Save_id: - ID - = { $$ = temp_id = ns($1); } - ; + ID + = { $$ = temp_id = ns($1); } + ; Mkopt_list: - Mkopt_list COMMA Mkoption - | - Mkoption - ; + Mkopt_list COMMA Mkoption + | + Mkoption + ; Mkoption: - Save_id EQUALS Opt_value - = { - struct opt *op = (struct opt *)malloc(sizeof (struct opt)); - op->op_name = ns($1); - op->op_next = mkopt; - op->op_value = ns($3); - mkopt = op; - free(temp_id); - free(val_id); - } ; + Save_id EQUALS Opt_value + = { + struct opt *op = (struct opt *)malloc(sizeof (struct opt)); + op->op_name = ns($1); + op->op_next = mkopt; + op->op_value = ns($3); + mkopt = op; + free(temp_id); + free(val_id); + } + ; Dev: - ID - = { $$ = ns($1); } - ; + ID + = { $$ = ns($1); } + ; Device_spec: - DEVICE Dev_name Dev_info Int_spec - = { cur.d_type = DEVICE; } | - MASTER Dev_name Dev_info Int_spec - = { cur.d_type = MASTER; } | - DISK Dev_name Dev_info Int_spec - = { cur.d_dk = 1; cur.d_type = DEVICE; } | - CONTROLLER Dev_name Dev_info Int_spec - = { cur.d_type = CONTROLLER; } | - PSEUDO_DEVICE Init_dev Dev - = { - cur.d_name = $3; - cur.d_type = PSEUDO_DEVICE; - } | - PSEUDO_DEVICE Init_dev Dev NUMBER - = { - cur.d_name = $3; - cur.d_type = PSEUDO_DEVICE; - cur.d_slave = $4; - } | - PSEUDO_DEVICE Dev_name Cdev_init Cdev_info - = { - if (!eq(cur.d_name, "cd")) - yyerror("improper spec for pseudo-device"); - seen_cd = 1; - cur.d_type = DEVICE; - verifycomp(*compp); - }; + DEVICE Dev_name Dev_info Int_spec + = { cur.d_type = DEVICE; } + | + MASTER Dev_name Dev_info Int_spec + = { cur.d_type = MASTER; } + | + DISK Dev_name Dev_info Int_spec + = { cur.d_dk = 1; cur.d_type = DEVICE; } + | + CONTROLLER Dev_name Dev_info Int_spec + = { cur.d_type = CONTROLLER; } + | + PSEUDO_DEVICE Init_dev Dev + = { + cur.d_name = $3; + cur.d_type = PSEUDO_DEVICE; + } + | + PSEUDO_DEVICE Init_dev Dev NUMBER + = { + cur.d_name = $3; + cur.d_type = PSEUDO_DEVICE; + cur.d_slave = $4; + } + | + PSEUDO_DEVICE Dev_name Cdev_init Cdev_info + = { + if (!eq(cur.d_name, "cd")) + yyerror("improper spec for pseudo-device"); + seen_cd = 1; + cur.d_type = DEVICE; + verifycomp(*compp); + } + ; Cdev_init: - /* lambda */ - = { mkcomp(&cur); }; + /* lambda */ + = { mkcomp(&cur); }; Cdev_info: - optional_on comp_device_list comp_option_list - ; + optional_on comp_device_list comp_option_list + ; comp_device_list: - comp_device_list AND comp_device - | comp_device - ; + comp_device_list AND comp_device + | + comp_device + ; comp_device: - comp_device_spec - = { addcomp(*compp, $1); } - ; + comp_device_spec + = { addcomp(*compp, $1); } + ; comp_device_spec: - device_name - = { - struct file_list *fl = newflist(COMPSPEC); + device_name + = { + struct file_list *fl = newflist(COMPSPEC); - fl->f_compdev = nametodev($1, 0, 'c'); - fl->f_fn = devtoname(fl->f_compdev); - $$ = fl; - } - | major_minor - = { - struct file_list *fl = newflist(COMPSPEC); + fl->f_compdev = nametodev($1, 0, 'c'); + fl->f_fn = devtoname(fl->f_compdev); + $$ = fl; + } + | + major_minor + = { + struct file_list *fl = newflist(COMPSPEC); - fl->f_compdev = $1; - fl->f_fn = devtoname($1); - $$ = fl; - } - ; + fl->f_compdev = $1; + fl->f_fn = devtoname($1); + $$ = fl; + } + ; comp_option_list: - comp_option_list comp_option - | - /* lambda */ - ; + comp_option_list comp_option + | + /* lambda */ + ; comp_option: - INTERLEAVE NUMBER - = { cur.d_pri = $2; } | - FLAGS NUMBER - = { cur.d_flags = $2; }; + INTERLEAVE NUMBER + = { cur.d_pri = $2; } + | + FLAGS NUMBER + = { cur.d_flags = $2; } + ; Dev_name: - Init_dev Dev NUMBER - = { - cur.d_name = $2; - if (eq($2, "mba")) - seen_mba = 1; - else if (eq($2, "uba")) - seen_uba = 1; - else if (eq($2, "vba")) - seen_vba = 1; - else if (eq($2, "isa")) - seen_isa = 1; - cur.d_unit = $3; - }; + Init_dev Dev NUMBER + = { + cur.d_name = $2; + if (eq($2, "mba")) + seen_mba = 1; + else if (eq($2, "uba")) + seen_uba = 1; + else if (eq($2, "vba")) + seen_vba = 1; + else if (eq($2, "isa")) + seen_isa = 1; + cur.d_unit = $3; + } + ; Init_dev: - /* lambda */ - = { init_dev(&cur); }; + /* lambda */ + = { init_dev(&cur); } + ; Dev_info: - Con_info Info_list - | - Info_list - | - /* lambda */ - ; + Con_info Info_list + | + Info_list + | + /* lambda */ + ; Con_info: - AT Dev NUMBER - = { - if (eq(cur.d_name, "mba") || eq(cur.d_name, "uba")) { - (void) sprintf(errbuf, - "%s must be connected to a nexus", cur.d_name); - yyerror(errbuf); - } - cur.d_conn = connect($2, $3); - } | - AT NEXUS NUMBER - = { check_nexus(&cur, $3); cur.d_conn = TO_NEXUS; }; + AT Dev NUMBER + = { + if (eq(cur.d_name, "mba") || eq(cur.d_name, "uba")) { + (void) sprintf(errbuf, + "%s must be connected to a nexus", cur.d_name); + yyerror(errbuf); + } + cur.d_conn = connect($2, $3); + } + | + AT NEXUS NUMBER + = { check_nexus(&cur, $3); cur.d_conn = TO_NEXUS; } + ; Info_list: - Info_list Info - | - /* lambda */ - ; + Info_list Info + | + /* lambda */ + ; Info: - CSR NUMBER - = { cur.d_addr = $2; } | - DRIVE NUMBER - = { cur.d_drive = $2; } | - SLAVE NUMBER - = { - if (cur.d_conn != 0 && cur.d_conn != TO_NEXUS && - cur.d_conn->d_type == MASTER) - cur.d_slave = $2; - else - yyerror("can't specify slave--not to master"); - } | - IRQ NUMBER - = { cur.d_irq = $2; } | - DRQ NUMBER - = { cur.d_drq = $2; } | - IOMEM NUMBER - = { cur.d_maddr = $2; } | - IOSIZ NUMBER - = { cur.d_msize = $2; } | - PORT device_name - = { cur.d_port = ns($2); } | - PORT NUMBER - = { cur.d_portn = $2; } | - TTY - = { cur.d_mask = "tty"; } | - BIO - = { cur.d_mask = "bio"; } | - NET - = { cur.d_mask = "net"; } | - FLAGS NUMBER - = { cur.d_flags = $2; }; + CSR NUMBER + = { cur.d_addr = $2; } + | + DRIVE NUMBER + = { cur.d_drive = $2; } + | + SLAVE NUMBER + = { + if (cur.d_conn != 0 && cur.d_conn != TO_NEXUS && + cur.d_conn->d_type == MASTER) + cur.d_slave = $2; + else + yyerror("can't specify slave--not to master"); + } + | + IRQ NUMBER + = { cur.d_irq = $2; } + | + DRQ NUMBER + = { cur.d_drq = $2; } + | + IOMEM NUMBER + = { cur.d_maddr = $2; } + | + IOSIZ NUMBER + = { cur.d_msize = $2; } + | + PORT device_name + = { cur.d_port = ns($2); } + | + PORT NUMBER + = { cur.d_portn = $2; } + | + TTY + = { cur.d_mask = "tty"; } + | + BIO + = { cur.d_mask = "bio"; } + | + NET + = { cur.d_mask = "net"; } + | + FLAGS NUMBER + = { cur.d_flags = $2; } + ; Int_spec: - VECTOR Id_list - = { cur.d_vec = $2; } | - PRIORITY NUMBER - = { cur.d_pri = $2; } | - /* lambda */ - ; + VECTOR Id_list + = { cur.d_vec = $2; } + | + PRIORITY NUMBER + = { cur.d_pri = $2; } + | + /* lambda */ + ; Id_list: - Save_id - = { - struct idlst *a = (struct idlst *)malloc(sizeof(struct idlst)); - a->id = $1; a->id_next = 0; $$ = a; - } | - Save_id Id_list = - { - struct idlst *a = (struct idlst *)malloc(sizeof(struct idlst)); - a->id = $1; a->id_next = $2; $$ = a; - }; - + Save_id + = { + struct idlst *a = (struct idlst *)malloc(sizeof(struct idlst)); + a->id = $1; a->id_next = 0; $$ = a; + } + | + Save_id Id_list = + { + struct idlst *a = (struct idlst *)malloc(sizeof(struct idlst)); + a->id = $1; a->id_next = $2; $$ = a; + } + ; %% void yyerror(s) - char *s; + char *s; { - - fprintf(stderr, "config: line %d: %s\n", yyline + 1, s); + fprintf(stderr, "config: line %d: %s\n", yyline + 1, s); } /* @@ -638,145 +705,147 @@ void yyerror(s) */ char * ns(str) - register char *str; + register char *str; { - register char *cp; + register char *cp; - cp = malloc((unsigned)(strlen(str)+1)); - (void) strcpy(cp, str); - return (cp); + cp = malloc((unsigned)(strlen(str)+1)); + (void) strcpy(cp, str); + return (cp); } /* * add a device to the list of devices */ void newdev(dp) - register struct device *dp; + register struct device *dp; { - register struct device *np; + register struct device *np; - np = (struct device *) malloc(sizeof *np); - *np = *dp; - np->d_next = 0; - if (curp == 0) - dtab = np; - else - curp->d_next = np; - curp = np; + np = (struct device *) malloc(sizeof *np); + *np = *dp; + np->d_next = 0; + if (curp == 0) + dtab = np; + else + curp->d_next = np; + curp = np; } /* * note that a configuration should be made */ void mkconf(sysname) - char *sysname; + char *sysname; { - register struct file_list *fl, **flp; + register struct file_list *fl, **flp; - fl = (struct file_list *) malloc(sizeof *fl); - fl->f_type = SYSTEMSPEC; - fl->f_needs = sysname; - fl->f_rootdev = NODEV; - fl->f_dumpdev = NODEV; - fl->f_fn = 0; - fl->f_next = 0; - for (flp = confp; *flp; flp = &(*flp)->f_next) - ; - *flp = fl; - confp = flp; + fl = (struct file_list *) malloc(sizeof *fl); + fl->f_type = SYSTEMSPEC; + fl->f_needs = sysname; + fl->f_rootdev = NODEV; + fl->f_dumpdev = NODEV; + fl->f_fn = 0; + fl->f_next = 0; + for (flp = confp; *flp; flp = &(*flp)->f_next) + ; + *flp = fl; + confp = flp; } struct file_list * newflist(ftype) - u_char ftype; + u_char ftype; { - struct file_list *fl = (struct file_list *)malloc(sizeof (*fl)); + struct file_list *fl = (struct file_list *)malloc(sizeof (*fl)); - fl->f_type = ftype; - fl->f_next = 0; - fl->f_swapdev = NODEV; - fl->f_swapsize = 0; - fl->f_needs = 0; - fl->f_fn = 0; - return (fl); + fl->f_type = ftype; + fl->f_next = 0; + fl->f_swapdev = NODEV; + fl->f_swapsize = 0; + fl->f_needs = 0; + fl->f_fn = 0; + return (fl); } /* * Add a swap device to the system's configuration */ void mkswap(system, fl, size, flag) - struct file_list *system, *fl; - int size, flag; + struct file_list *system, *fl; + int size, flag; { - register struct file_list **flp; + register struct file_list **flp; - if (system == 0 || system->f_type != SYSTEMSPEC) { - yyerror("\"swap\" spec precedes \"config\" specification"); - return; - } - if (size < 0) { - yyerror("illegal swap partition size"); - return; - } - /* - * Append swap description to the end of the list. - */ - flp = &system->f_next; - for (; *flp && (*flp)->f_type == SWAPSPEC; flp = &(*flp)->f_next) - ; - fl->f_next = *flp; - *flp = fl; - fl->f_swapsize = size; - fl->f_swapflag = flag; - /* - * If first swap device for this system, - * set up f_fn field to insure swap - * files are created with unique names. - */ - if (system->f_fn) - return; - if (eq(fl->f_fn, "generic")) - system->f_fn = ns(fl->f_fn); - else - system->f_fn = ns(system->f_needs); + if (system == 0 || system->f_type != SYSTEMSPEC) { + yyerror("\"swap\" spec precedes \"config\" specification"); + return; + } + if (size < 0) { + yyerror("illegal swap partition size"); + return; + } + /* + * Append swap description to the end of the list. + */ + flp = &system->f_next; + for (; *flp && (*flp)->f_type == SWAPSPEC; flp = &(*flp)->f_next) + ; + fl->f_next = *flp; + *flp = fl; + fl->f_swapsize = size; + fl->f_swapflag = flag; + + /* + * If first swap device for this system, + * set up f_fn field to insure swap + * files are created with unique names. + */ + if (system->f_fn) + return; + if (eq(fl->f_fn, "generic")) + system->f_fn = ns(fl->f_fn); + else + system->f_fn = ns(system->f_needs); } void mkcomp(dp) - register struct device *dp; + register struct device *dp; { - register struct file_list *fl, **flp; - char buf[80]; + register struct file_list *fl, **flp; + char buf[80]; - fl = (struct file_list *) malloc(sizeof *fl); - fl->f_type = COMPDEVICE; - fl->f_compinfo = dp->d_unit; - fl->f_fn = ns(dp->d_name); - (void) sprintf(buf, "%s%d", dp->d_name, dp->d_unit); - fl->f_needs = ns(buf); - fl->f_next = 0; - for (flp = compp; *flp; flp = &(*flp)->f_next) - ; - *flp = fl; - compp = flp; + fl = (struct file_list *) malloc(sizeof *fl); + fl->f_type = COMPDEVICE; + fl->f_compinfo = dp->d_unit; + fl->f_fn = ns(dp->d_name); + (void) sprintf(buf, "%s%d", dp->d_name, dp->d_unit); + fl->f_needs = ns(buf); + fl->f_next = 0; + for (flp = compp; *flp; flp = &(*flp)->f_next) + ; + *flp = fl; + compp = flp; } void addcomp(compdev, fl) - struct file_list *compdev, *fl; + struct file_list *compdev, *fl; { - register struct file_list **flp; + register struct file_list **flp; - if (compdev == 0 || compdev->f_type != COMPDEVICE) { - yyerror("component spec precedes device specification"); - return; - } - /* - * Append description to the end of the list. - */ - flp = &compdev->f_next; - for (; *flp && (*flp)->f_type == COMPSPEC; flp = &(*flp)->f_next) - ; - fl->f_next = *flp; - *flp = fl; + if (compdev == 0 || compdev->f_type != COMPDEVICE) { + yyerror("component spec precedes device specification"); + return; + } + + /* + * Append description to the end of the list. + */ + flp = &compdev->f_next; + for (; *flp && (*flp)->f_type == COMPSPEC; flp = &(*flp)->f_next) + ; + fl->f_next = *flp; + *flp = fl; } /* @@ -785,28 +854,28 @@ void addcomp(compdev, fl) */ struct device * connect(dev, num) - register char *dev; - register int num; + register char *dev; + register int num; { - register struct device *dp; - struct device *huhcon(); + register struct device *dp; + struct device *huhcon(); - if (num == QUES) - return (huhcon(dev)); - for (dp = dtab; dp != 0; dp = dp->d_next) { - if ((num != dp->d_unit) || !eq(dev, dp->d_name)) - continue; - if (dp->d_type != CONTROLLER && dp->d_type != MASTER) { - (void) sprintf(errbuf, - "%s connected to non-controller", dev); - yyerror(errbuf); - return (0); - } - return (dp); - } - (void) sprintf(errbuf, "%s %d not defined", dev, num); - yyerror(errbuf); - return (0); + if (num == QUES) + return (huhcon(dev)); + for (dp = dtab; dp != 0; dp = dp->d_next) { + if ((num != dp->d_unit) || !eq(dev, dp->d_name)) + continue; + if (dp->d_type != CONTROLLER && dp->d_type != MASTER) { + (void) sprintf(errbuf, + "%s connected to non-controller", dev); + yyerror(errbuf); + return (0); + } + return (dp); + } + (void) sprintf(errbuf, "%s %d not defined", dev, num); + yyerror(errbuf); + return (0); } /* @@ -814,121 +883,121 @@ connect(dev, num) */ struct device * huhcon(dev) - register char *dev; + register char *dev; { - register struct device *dp, *dcp; - struct device rdev; - int oldtype; + register struct device *dp, *dcp; + struct device rdev; + int oldtype; - /* - * First make certain that there are some of these to wildcard on - */ - for (dp = dtab; dp != 0; dp = dp->d_next) - if (eq(dp->d_name, dev)) - break; - if (dp == 0) { - (void) sprintf(errbuf, "no %s's to wildcard", dev); - yyerror(errbuf); - return (0); - } - oldtype = dp->d_type; - dcp = dp->d_conn; - /* - * Now see if there is already a wildcard entry for this device - * (e.g. Search for a "uba ?") - */ - for (; dp != 0; dp = dp->d_next) - if (eq(dev, dp->d_name) && dp->d_unit == -1) - break; - /* - * If there isn't, make one because everything needs to be connected - * to something. - */ - if (dp == 0) { - dp = &rdev; - init_dev(dp); - dp->d_unit = QUES; - dp->d_name = ns(dev); - dp->d_type = oldtype; - newdev(dp); - dp = curp; - /* - * Connect it to the same thing that other similar things are - * connected to, but make sure it is a wildcard unit - * (e.g. up connected to sc ?, here we make connect sc? to a - * uba?). If other things like this are on the NEXUS or - * if they aren't connected to anything, then make the same - * connection, else call ourself to connect to another - * unspecific device. - */ - if (dcp == TO_NEXUS || dcp == 0) - dp->d_conn = dcp; - else - dp->d_conn = connect(dcp->d_name, QUES); - } - return (dp); + /* + * First make certain that there are some of these to wildcard on + */ + for (dp = dtab; dp != 0; dp = dp->d_next) + if (eq(dp->d_name, dev)) + break; + if (dp == 0) { + (void) sprintf(errbuf, "no %s's to wildcard", dev); + yyerror(errbuf); + return (0); + } + oldtype = dp->d_type; + dcp = dp->d_conn; + + /* + * Now see if there is already a wildcard entry for this device + * (e.g. Search for a "uba ?") + */ + for (; dp != 0; dp = dp->d_next) + if (eq(dev, dp->d_name) && dp->d_unit == -1) + break; + /* + * If there isn't, make one because everything needs to be connected + * to something. + */ + if (dp == 0) { + dp = &rdev; + init_dev(dp); + dp->d_unit = QUES; + dp->d_name = ns(dev); + dp->d_type = oldtype; + newdev(dp); + dp = curp; + + /* + * Connect it to the same thing that other similar things are + * connected to, but make sure it is a wildcard unit + * (e.g. up connected to sc ?, here we make connect sc? to a + * uba?). If other things like this are on the NEXUS or + * if they aren't connected to anything, then make the same + * connection, else call ourself to connect to another + * unspecific device. + */ + if (dcp == TO_NEXUS || dcp == 0) + dp->d_conn = dcp; + else + dp->d_conn = connect(dcp->d_name, QUES); + } + return (dp); } void init_dev(dp) - register struct device *dp; + register struct device *dp; { - - dp->d_name = "OHNO!!!"; - dp->d_type = DEVICE; - dp->d_conn = 0; - dp->d_vec = 0; - dp->d_addr = dp->d_flags = dp->d_dk = 0; - dp->d_pri = -1; - dp->d_slave = dp->d_drive = dp->d_unit = UNKNOWN; - dp->d_port = (char *)0; - dp->d_portn = 0; - dp->d_irq = -1; - dp->d_drq = -1; - dp->d_maddr = 0; - dp->d_msize = 0; - dp->d_mask = "null"; + dp->d_name = "OHNO!!!"; + dp->d_type = DEVICE; + dp->d_conn = 0; + dp->d_vec = 0; + dp->d_addr = dp->d_flags = dp->d_dk = 0; + dp->d_pri = -1; + dp->d_slave = dp->d_drive = dp->d_unit = UNKNOWN; + dp->d_port = (char *)0; + dp->d_portn = 0; + dp->d_irq = -1; + dp->d_drq = -1; + dp->d_maddr = 0; + dp->d_msize = 0; + dp->d_mask = "null"; } /* * make certain that this is a reasonable type of thing to connect to a nexus */ void check_nexus(dev, num) - register struct device *dev; - int num; + register struct device *dev; + int num; { + switch (machine) { - switch (machine) { + case MACHINE_VAX: + if (!eq(dev->d_name, "uba") && !eq(dev->d_name, "mba") && + !eq(dev->d_name, "bi")) + yyerror("only uba's, mba's, and bi's should be connected to the nexus"); + if (num != QUES) + yyerror("can't give specific nexus numbers"); + break; - case MACHINE_VAX: - if (!eq(dev->d_name, "uba") && !eq(dev->d_name, "mba") && - !eq(dev->d_name, "bi")) - yyerror("only uba's, mba's, and bi's should be connected to the nexus"); - if (num != QUES) - yyerror("can't give specific nexus numbers"); - break; + case MACHINE_TAHOE: + if (!eq(dev->d_name, "vba")) + yyerror("only vba's should be connected to the nexus"); + break; - case MACHINE_TAHOE: - if (!eq(dev->d_name, "vba")) - yyerror("only vba's should be connected to the nexus"); - break; + case MACHINE_HP300: + case MACHINE_LUNA68K: + if (num != QUES) + dev->d_addr = num; + break; - case MACHINE_HP300: - case MACHINE_LUNA68K: - if (num != QUES) - dev->d_addr = num; - break; + case MACHINE_I386: + if (!eq(dev->d_name, "isa")) + yyerror("only isa's should be connected to the nexus"); + break; - case MACHINE_I386: - if (!eq(dev->d_name, "isa")) - yyerror("only isa's should be connected to the nexus"); - break; - - case MACHINE_NEWS3400: - if (!eq(dev->d_name, "iop") && !eq(dev->d_name, "hb") && - !eq(dev->d_name, "vme")) - yyerror("only iop's, hb's and vme's should be connected to the nexus"); - break; - } + case MACHINE_NEWS3400: + if (!eq(dev->d_name, "iop") && !eq(dev->d_name, "hb") && + !eq(dev->d_name, "vme")) + yyerror("only iop's, hb's and vme's should be connected to the nexus"); + break; + } } /* @@ -936,10 +1005,10 @@ void check_nexus(dev, num) */ void check_tz() { - if (abs(zone) > 12 * 60) - yyerror("timezone is unreasonable"); - else - hadtz = 1; + if (abs(zone) > 12 * 60) + yyerror("timezone is unreasonable"); + else + hadtz = 1; } /* @@ -947,70 +1016,73 @@ void check_tz() * rules on root, argument, dump, and swap devices. */ void checksystemspec(fl) - register struct file_list *fl; + register struct file_list *fl; { - char buf[BUFSIZ]; - register struct file_list *swap; - int generic; + char buf[BUFSIZ]; + register struct file_list *swap; + int generic; - if (fl == 0 || fl->f_type != SYSTEMSPEC) { - yyerror("internal error, bad system specification"); - exit(1); - } - swap = fl->f_next; - generic = swap && swap->f_type == SWAPSPEC && eq(swap->f_fn, "generic"); - if (fl->f_rootdev == NODEV && !generic) { - yyerror("no root device specified"); - exit(1); - } - /* - * Default swap area to be in 'b' partition of root's - * device. If root specified to be other than on 'a' - * partition, give warning, something probably amiss. - */ - if (swap == 0 || swap->f_type != SWAPSPEC) { - dev_t dev; + if (fl == 0 || fl->f_type != SYSTEMSPEC) { + yyerror("internal error, bad system specification"); + exit(1); + } + swap = fl->f_next; + generic = swap && swap->f_type == SWAPSPEC && eq(swap->f_fn, "generic"); + if (fl->f_rootdev == NODEV && !generic) { + yyerror("no root device specified"); + exit(1); + } - swap = newflist(SWAPSPEC); - dev = fl->f_rootdev; - if (minor(dev) & 07) { - (void) sprintf(buf, -"Warning, swap defaulted to 'b' partition with root on '%c' partition", - (minor(dev) & 07) + 'a'); - yyerror(buf); - } - swap->f_swapdev = - makedev(major(dev), (minor(dev) &~ 07) | ('b' - 'a')); - swap->f_fn = devtoname(swap->f_swapdev); - mkswap(fl, swap, 0, 0); - } - /* - * Make sure a generic swap isn't specified, along with - * other stuff (user must really be confused). - */ - if (generic) { - if (fl->f_rootdev != NODEV) - yyerror("root device specified with generic swap"); - if (fl->f_dumpdev != NODEV) - yyerror("dump device specified with generic swap"); - return; - } - /* - * Default dump device and warn if place is not a - * swap area. - */ - if (fl->f_dumpdev == NODEV) - fl->f_dumpdev = swap->f_swapdev; - if (fl->f_dumpdev != swap->f_swapdev) { - struct file_list *p = swap->f_next; + /* + * Default swap area to be in 'b' partition of root's + * device. If root specified to be other than on 'a' + * partition, give warning, something probably amiss. + */ + if (swap == 0 || swap->f_type != SWAPSPEC) { + dev_t dev; - for (; p && p->f_type == SWAPSPEC; p = p->f_next) - if (fl->f_dumpdev == p->f_swapdev) - return; - (void) sprintf(buf, - "Warning: dump device is not a swap partition"); - yyerror(buf); - } + swap = newflist(SWAPSPEC); + dev = fl->f_rootdev; + if (minor(dev) & 07) { + sprintf(buf, + "Warning, swap defaulted to 'b' partition with root on '%c' partition", + (minor(dev) & 07) + 'a'); + yyerror(buf); + } + swap->f_swapdev = + makedev(major(dev), (minor(dev) &~ 07) | ('b' - 'a')); + swap->f_fn = devtoname(swap->f_swapdev); + mkswap(fl, swap, 0, 0); + } + + /* + * Make sure a generic swap isn't specified, along with + * other stuff (user must really be confused). + */ + if (generic) { + if (fl->f_rootdev != NODEV) + yyerror("root device specified with generic swap"); + if (fl->f_dumpdev != NODEV) + yyerror("dump device specified with generic swap"); + return; + } + + /* + * Default dump device and warn if place is not a + * swap area. + */ + if (fl->f_dumpdev == NODEV) + fl->f_dumpdev = swap->f_swapdev; + if (fl->f_dumpdev != swap->f_swapdev) { + struct file_list *p = swap->f_next; + + for (; p && p->f_type == SWAPSPEC; p = p->f_next) + if (fl->f_dumpdev == p->f_swapdev) + return; + (void) sprintf(buf, + "Warning: dump device is not a swap partition"); + yyerror(buf); + } } /* @@ -1019,25 +1091,27 @@ void checksystemspec(fl) */ void verifysystemspecs() { - register struct file_list *fl; - dev_t checked[50], *verifyswap(); - register dev_t *pchecked = checked; + register struct file_list *fl; + dev_t checked[50], *verifyswap(); + register dev_t *pchecked = checked; - for (fl = conf_list; fl; fl = fl->f_next) { - if (fl->f_type != SYSTEMSPEC) - continue; - if (!finddev(fl->f_rootdev)) - deverror(fl->f_needs, "root"); - *pchecked++ = fl->f_rootdev; - pchecked = verifyswap(fl->f_next, checked, pchecked); -#define samedev(dev1, dev2) \ - ((minor(dev1) &~ 07) != (minor(dev2) &~ 07)) - if (!alreadychecked(fl->f_dumpdev, checked, pchecked)) { - if (!finddev(fl->f_dumpdev)) - deverror(fl->f_needs, "dump"); - *pchecked++ = fl->f_dumpdev; - } - } + for (fl = conf_list; fl; fl = fl->f_next) { + if (fl->f_type != SYSTEMSPEC) + continue; + if (!finddev(fl->f_rootdev)) + deverror(fl->f_needs, "root"); + *pchecked++ = fl->f_rootdev; + pchecked = verifyswap(fl->f_next, checked, pchecked); + +#define samedev(dev1, dev2) \ + ((minor(dev1) &~ 07) != (minor(dev2) &~ 07)) + + if (!alreadychecked(fl->f_dumpdev, checked, pchecked)) { + if (!finddev(fl->f_dumpdev)) + deverror(fl->f_needs, "dump"); + *pchecked++ = fl->f_dumpdev; + } + } } /* @@ -1045,39 +1119,38 @@ void verifysystemspecs() */ dev_t * verifyswap(fl, checked, pchecked) - register struct file_list *fl; - dev_t checked[]; - register dev_t *pchecked; + register struct file_list *fl; + dev_t checked[]; + register dev_t *pchecked; { - - for (;fl && fl->f_type == SWAPSPEC; fl = fl->f_next) { - if (eq(fl->f_fn, "generic")) - continue; - if (alreadychecked(fl->f_swapdev, checked, pchecked)) - continue; - if (!finddev(fl->f_swapdev)) - fprintf(stderr, - "config: swap device %s not configured", fl->f_fn); - *pchecked++ = fl->f_swapdev; - } - return (pchecked); + for (;fl && fl->f_type == SWAPSPEC; fl = fl->f_next) { + if (eq(fl->f_fn, "generic")) + continue; + if (alreadychecked(fl->f_swapdev, checked, pchecked)) + continue; + if (!finddev(fl->f_swapdev)) + fprintf(stderr, + "config: swap device %s not configured", fl->f_fn); + *pchecked++ = fl->f_swapdev; + } + return (pchecked); } /* * Verify that components of a compound device have themselves been config'ed */ void verifycomp(fl) - register struct file_list *fl; + register struct file_list *fl; { - char *dname = fl->f_needs; + char *dname = fl->f_needs; - for (fl = fl->f_next; fl; fl = fl->f_next) { - if (fl->f_type != COMPSPEC || finddev(fl->f_compdev)) - continue; - fprintf(stderr, - "config: %s: component device %s not configured\n", - dname, fl->f_needs); - } + for (fl = fl->f_next; fl; fl = fl->f_next) { + if (fl->f_type != COMPSPEC || finddev(fl->f_compdev)) + continue; + fprintf(stderr, + "config: %s: component device %s not configured\n", + dname, fl->f_needs); + } } /* @@ -1085,23 +1158,23 @@ void verifycomp(fl) * for it's existence in the configuration? */ int alreadychecked(dev, list, last) - dev_t dev, list[]; - register dev_t *last; + dev_t dev, list[]; + register dev_t *last; { - register dev_t *p; + register dev_t *p; - for (p = list; p < last; p++) - if (samedev(*p, dev)) - return (1); - return (0); + for (p = list; p < last; p++) + if (samedev(*p, dev)) + return (1); + return (0); } void deverror(systemname, devtype) - char *systemname, *devtype; + char *systemname, *devtype; { - fprintf(stderr, "config: %s: %s device not configured\n", - systemname, devtype); + fprintf(stderr, "config: %s: %s device not configured\n", + systemname, devtype); } /* @@ -1111,9 +1184,8 @@ void deverror(systemname, devtype) */ /*ARGSUSED*/ int finddev(dev) - dev_t dev; + dev_t dev; { - - /* punt on this right now */ - return (1); + /* punt on this right now */ + return (1); } diff --git a/tools/kconfig/lang.l b/tools/kconfig/lang.l index 12431d1..51f3322 100644 --- a/tools/kconfig/lang.l +++ b/tools/kconfig/lang.l @@ -4,7 +4,7 @@ %{ /*- * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -16,8 +16,8 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. + * This product includes software developed by the University of + * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -34,7 +34,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)lang.l 8.1 (Berkeley) 6/6/93 + * @(#)lang.l 8.1 (Berkeley) 6/6/93 */ #include @@ -48,156 +48,156 @@ */ struct kt { - char *kt_name; - int kt_val; + char *kt_name; + int kt_val; } key_words[] = { - { "and", AND }, - { "args", ARGS }, - { "at", AT }, + { "and", AND }, + { "args", ARGS }, + { "at", AT }, #if MACHINE_I386 - { "bio", BIO }, + { "bio", BIO }, #endif - { "config", CONFIG }, - { "controller", CONTROLLER }, - { "cpu", CPU }, - { "csr", CSR }, - { "device", DEVICE }, - { "disk", DISK }, - { "drive", DRIVE }, + { "config", CONFIG }, + { "controller", CONTROLLER }, + { "cpu", CPU }, + { "csr", CSR }, + { "device", DEVICE }, + { "disk", DISK }, + { "drive", DRIVE }, #if MACHINE_I386 - { "drq", DRQ }, + { "drq", DRQ }, #endif - { "dst", DST }, - { "dumps", DUMPS }, - { "flags", FLAGS }, - { "hz", HZ }, - { "ident", IDENT }, - { "interleave", INTERLEAVE }, + { "dst", DST }, + { "dumps", DUMPS }, + { "flags", FLAGS }, + { "hz", HZ }, + { "ident", IDENT }, + { "interleave", INTERLEAVE }, #if MACHINE_I386 - { "iomem", IOMEM }, - { "iosiz", IOSIZ }, - { "irq", IRQ }, + { "iomem", IOMEM }, + { "iosiz", IOSIZ }, + { "irq", IRQ }, #endif - { "ldscript", LDSCRIPT }, - { "machine", MACHINE }, - { "major", MAJOR }, - { "makeoptions", MAKEOPTIONS }, - { "master", MASTER }, - { "maxusers", MAXUSERS }, - { "minor", MINOR }, + { "ldscript", LDSCRIPT }, + { "machine", MACHINE }, + { "major", MAJOR }, + { "makeoptions", MAKEOPTIONS }, + { "master", MASTER }, + { "maxusers", MAXUSERS }, + { "minor", MINOR }, #if MACHINE_I386 - { "net", NET }, + { "net", NET }, #endif - { "nexus", NEXUS }, - { "on", ON }, - { "options", OPTIONS }, + { "nexus", NEXUS }, + { "on", ON }, + { "options", OPTIONS }, #if MACHINE_I386 - { "port", PORT }, + { "port", PORT }, #endif - { "priority", PRIORITY }, - { "pseudo-device",PSEUDO_DEVICE }, - { "root", ROOT }, + { "priority", PRIORITY }, + { "pseudo-device", PSEUDO_DEVICE }, + { "root", ROOT }, #if MACHINE_HP300 || MACHINE_LUNA68K - { "scode", NEXUS }, + { "scode", NEXUS }, #endif - { "sequential", SEQUENTIAL }, - { "size", SIZE }, - { "slave", SLAVE }, - { "swap", SWAP }, - { "tape", DEVICE }, + { "sequential", SEQUENTIAL }, + { "size", SIZE }, + { "slave", SLAVE }, + { "swap", SWAP }, + { "tape", DEVICE }, #if MACHINE_I386 - { "tty", TTY }, + { "tty", TTY }, #endif - { "timezone", TIMEZONE }, - { "trace", TRACE }, - { "vector", VECTOR }, - { 0, 0 }, + { "timezone", TIMEZONE }, + { "trace", TRACE }, + { "vector", VECTOR }, + { 0, 0 }, }; int kw_lookup(char *word); int octal(char *str); int hex(char *str); %} -WORD [A-Za-z_][-A-Za-z_]* +WORD [A-Za-z_][-A-Za-z_]* %% -{WORD} { - int i; +{WORD} { + int i; - if ((i = kw_lookup(yytext)) == -1) - { - yylval.str = yytext; - tprintf("id(%s) ", yytext); - return ID; - } - tprintf("(%s) ", yytext); - return i; - } -\"[^"]+\" { - yytext[strlen(yytext)-1] = '\0'; - yylval.str = yytext + 1; - return ID; - } -0[0-7]* { - yylval.val = octal(yytext); - tprintf("#O:%o ", yylval.val); - return NUMBER; - } -0x[0-9a-fA-F]+ { - yylval.val = hex(yytext); - tprintf("#X:%x ", yylval.val); - return NUMBER; - } -[1-9][0-9]* { - yylval.val = atoi(yytext); - tprintf("#D:%d ", yylval.val); - return NUMBER; - } -[0-9]"."[0-9]* { - double atof(); - yylval.val = (int) (60 * atof(yytext) + 0.5); - return FPNUMBER; - } -"-" { - return MINUS; - } -"?" { - yylval.val = -1; - tprintf("? "); - return NUMBER; - } -\n/[ \t] { - yyline++; - tprintf("\n... "); - } -\n { - yyline++; - tprintf("\n"); - return SEMICOLON; - } -#.* { /* Ignored (comment) */; } -[ \t]* { /* Ignored (white space) */; } -";" { return SEMICOLON; } -"," { return COMMA; } -"=" { return EQUALS; } -"@" { return AT; } -. { return yytext[0]; } + if ((i = kw_lookup(yytext)) == -1) + { + yylval.str = yytext; + tprintf("id(%s) ", yytext); + return ID; + } + tprintf("(%s) ", yytext); + return i; + } +\"[^"]+\" { + yytext[strlen(yytext)-1] = '\0'; + yylval.str = yytext + 1; + return ID; + } +0[0-7]* { + yylval.val = octal(yytext); + tprintf("#O:%o ", yylval.val); + return NUMBER; + } +0x[0-9a-fA-F]+ { + yylval.val = hex(yytext); + tprintf("#X:%x ", yylval.val); + return NUMBER; + } +[1-9][0-9]* { + yylval.val = atoi(yytext); + tprintf("#D:%d ", yylval.val); + return NUMBER; + } +[0-9]"."[0-9]* { + double atof(); + yylval.val = (int) (60 * atof(yytext) + 0.5); + return FPNUMBER; + } +"-" { + return MINUS; + } +"?" { + yylval.val = -1; + tprintf("? "); + return NUMBER; + } +\n/[ \t] { + yyline++; + tprintf("\n... "); + } +\n { + yyline++; + tprintf("\n"); + return SEMICOLON; + } +#.* { /* Ignored (comment) */; } +[ \t]* { /* Ignored (white space) */; } +";" { return SEMICOLON; } +"," { return COMMA; } +"=" { return EQUALS; } +"@" { return AT; } +. { return yytext[0]; } %% /* * kw_lookup - * Look up a string in the keyword table. Returns a -1 if the - * string is not a keyword otherwise it returns the keyword number + * Look up a string in the keyword table. Returns a -1 if the + * string is not a keyword otherwise it returns the keyword number */ int kw_lookup(word) register char *word; { - register struct kt *kp; + register struct kt *kp; - for (kp = key_words; kp->kt_name != 0; kp++) - if (eq(word, kp->kt_name)) - return kp->kt_val; - return -1; + for (kp = key_words; kp->kt_name != 0; kp++) + if (eq(word, kp->kt_name)) + return kp->kt_val; + return -1; } /* @@ -207,18 +207,18 @@ int octal(str) char *str; { - int num; + int num; - (void) sscanf(str, "%o", &num); - return num; + (void) sscanf(str, "%o", &num); + return num; } int hex(str) char *str; { - int num; + int num; - (void) sscanf(str+2, "%x", &num); - return num; + (void) sscanf(str+2, "%x", &num); + return num; } diff --git a/tools/kconfig/main.c b/tools/kconfig/main.c index 82569b0..99e83fc 100644 --- a/tools/kconfig/main.c +++ b/tools/kconfig/main.c @@ -1,6 +1,6 @@ /* * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -12,8 +12,8 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. + * This product includes software developed by the University of + * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -46,190 +46,188 @@ static char *PREFIX; * system given a description of the desired system. */ int main(argc, argv) - int argc; - char **argv; + int argc; + char **argv; { - extern char *optarg; - extern int optind; - struct stat buf; - int ch; - char *p; + extern char *optarg; + extern int optind; + struct stat buf; + int ch; + char *p; - while ((ch = getopt(argc, argv, "gp")) != EOF) - switch (ch) { - case 'g': - debugging++; - break; - case 'p': - profiling++; - break; - case '?': - default: - goto usage; - } - argc -= optind; - argv += optind; + while ((ch = getopt(argc, argv, "gp")) != EOF) + switch (ch) { + case 'g': + debugging++; + break; + case 'p': + profiling++; + break; + case '?': + default: + goto usage; + } + argc -= optind; + argv += optind; - if (argc != 1) { -usage: fputs("usage: config [-gp] sysname\n", stderr); - exit(1); - } + if (argc != 1) { +usage: fputs("usage: config [-gp] sysname\n", stderr); + exit(1); + } - if (freopen(PREFIX = *argv, "r", stdin) == NULL) { -fprintf(stderr, "--- PREFIX\n"); - perror(PREFIX); - exit(2); - } - mkdir("../../compile", 0777); - if (stat(p = path((char *)NULL), &buf)) { - if (mkdir(p, 0777)) { -fprintf(stderr, "--- mkdir path\n"); - perror(p); - exit(2); - } - } - else if ((buf.st_mode & S_IFMT) != S_IFDIR) { - fprintf(stderr, "config: %s isn't a directory.\n", p); - exit(2); - } + if (freopen(PREFIX = *argv, "r", stdin) == NULL) { + perror(PREFIX); + exit(2); + } + mkdir("../../compile", 0777); + if (stat(p = path((char *)NULL), &buf)) { + if (mkdir(p, 0777)) { + perror(p); + exit(2); + } + } + else if ((buf.st_mode & S_IFMT) != S_IFDIR) { + fprintf(stderr, "config: %s isn't a directory.\n", p); + exit(2); + } - dtab = NULL; - confp = &conf_list; - compp = &comp_list; - if (yyparse()) - exit(3); - switch (machine) { + dtab = NULL; + confp = &conf_list; + compp = &comp_list; + if (yyparse()) + exit(3); + switch (machine) { - case MACHINE_VAX: - vax_ioconf(); /* Print ioconf.c */ - ubglue(); /* Create ubglue.s */ - break; + case MACHINE_VAX: + vax_ioconf(); /* Print ioconf.c */ + ubglue(); /* Create ubglue.s */ + break; - case MACHINE_TAHOE: - tahoe_ioconf(); - vbglue(); - break; + case MACHINE_TAHOE: + tahoe_ioconf(); + vbglue(); + break; - case MACHINE_HP300: - case MACHINE_LUNA68K: - hp300_ioconf(); - hpglue(); - break; + case MACHINE_HP300: + case MACHINE_LUNA68K: + hp300_ioconf(); + hpglue(); + break; - case MACHINE_I386: - i386_ioconf(); /* Print ioconf.c */ - vector(); /* Create vector.s */ - break; + case MACHINE_I386: + i386_ioconf(); /* Print ioconf.c */ + vector(); /* Create vector.s */ + break; - case MACHINE_MIPS: - case MACHINE_PMAX: - pmax_ioconf(); - break; + case MACHINE_MIPS: + case MACHINE_PMAX: + pmax_ioconf(); + break; - case MACHINE_PIC32: - pic32_ioconf(); - break; + case MACHINE_PIC32: + pic32_ioconf(); + break; - case MACHINE_NEWS3400: - news_ioconf(); - break; + case MACHINE_NEWS3400: + news_ioconf(); + break; - default: - printf("Specify machine type, e.g. ``machine vax''\n"); - exit(1); - } - makefile(); /* build Makefile */ - headers(); /* make a lot of .h files */ - swapconf(); /* swap config files */ - printf("Don't forget to run \"make depend\"\n"); - exit(0); + default: + printf("Specify machine type, e.g. ``machine vax''\n"); + exit(1); + } + makefile(); /* build Makefile */ + headers(); /* make a lot of .h files */ + swapconf(); /* swap config files */ + printf("Don't forget to run \"make depend\"\n"); + exit(0); } /* * get_word - * returns EOF on end of file - * NULL on end of line - * pointer to the word otherwise + * returns EOF on end of file + * NULL on end of line + * pointer to the word otherwise */ char * get_word(fp) - register FILE *fp; + register FILE *fp; { - static char line[80]; - register int ch; - register char *cp; + static char line[80]; + register int ch; + register char *cp; - while ((ch = getc(fp)) != EOF) - if (ch != ' ' && ch != '\t') - break; - if (ch == EOF) - return ((char *)EOF); - if (ch == '\n') - return (NULL); - cp = line; - *cp++ = ch; - while ((ch = getc(fp)) != EOF) { - if (isspace(ch)) - break; - *cp++ = ch; - } - *cp = 0; - if (ch == EOF) - return ((char *)EOF); - (void) ungetc(ch, fp); - return (line); + while ((ch = getc(fp)) != EOF) + if (ch != ' ' && ch != '\t') + break; + if (ch == EOF) + return ((char *)EOF); + if (ch == '\n') + return (NULL); + cp = line; + *cp++ = ch; + while ((ch = getc(fp)) != EOF) { + if (isspace(ch)) + break; + *cp++ = ch; + } + *cp = 0; + if (ch == EOF) + return ((char *)EOF); + (void) ungetc(ch, fp); + return (line); } /* * get_quoted_word - * like get_word but will accept something in double or single quotes - * (to allow embedded spaces). + * like get_word but will accept something in double or single quotes + * (to allow embedded spaces). */ char * get_quoted_word(fp) - register FILE *fp; + register FILE *fp; { - static char line[256]; - register int ch; - register char *cp; + static char line[256]; + register int ch; + register char *cp; - while ((ch = getc(fp)) != EOF) - if (ch != ' ' && ch != '\t') - break; - if (ch == EOF) - return ((char *)EOF); - if (ch == '\n') - return (NULL); - cp = line; - if (ch == '"' || ch == '\'') { - register int quote = ch; + while ((ch = getc(fp)) != EOF) + if (ch != ' ' && ch != '\t') + break; + if (ch == EOF) + return ((char *)EOF); + if (ch == '\n') + return (NULL); + cp = line; + if (ch == '"' || ch == '\'') { + register int quote = ch; - while ((ch = getc(fp)) != EOF) { - if (ch == quote) - break; - if (ch == '\n') { - *cp = 0; - printf("config: missing quote reading `%s'\n", - line); - exit(2); - } - *cp++ = ch; - } - } else { - *cp++ = ch; - while ((ch = getc(fp)) != EOF) { - if (isspace(ch)) - break; - *cp++ = ch; - } - if (ch != EOF) - (void) ungetc(ch, fp); - } - *cp = 0; - if (ch == EOF) - return ((char *)EOF); - return (line); + while ((ch = getc(fp)) != EOF) { + if (ch == quote) + break; + if (ch == '\n') { + *cp = 0; + printf("config: missing quote reading `%s'\n", + line); + exit(2); + } + *cp++ = ch; + } + } else { + *cp++ = ch; + while ((ch = getc(fp)) != EOF) { + if (isspace(ch)) + break; + *cp++ = ch; + } + if (ch != EOF) + (void) ungetc(ch, fp); + } + *cp = 0; + if (ch == EOF) + return ((char *)EOF); + return (line); } /* @@ -237,18 +235,19 @@ get_quoted_word(fp) */ char * path(file) - char *file; + char *file; { - register char *cp; + register char *cp; -#define CDIR "../../compile/" - cp = malloc((unsigned int)(sizeof(CDIR) + strlen(PREFIX) + - (file ? strlen(file) : 0) + 2)); - (void) strcpy(cp, CDIR); - (void) strcat(cp, PREFIX); - if (file) { - (void) strcat(cp, "/"); - (void) strcat(cp, file); - } - return (cp); +#define CDIR "../../compile/" + + cp = malloc((unsigned int)(sizeof(CDIR) + strlen(PREFIX) + + (file ? strlen(file) : 0) + 2)); + (void) strcpy(cp, CDIR); + (void) strcat(cp, PREFIX); + if (file) { + (void) strcat(cp, "/"); + (void) strcat(cp, file); + } + return (cp); } diff --git a/tools/kconfig/mkglue.c b/tools/kconfig/mkglue.c index 81ab74f..7b1f308 100644 --- a/tools/kconfig/mkglue.c +++ b/tools/kconfig/mkglue.c @@ -1,6 +1,6 @@ /* * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -12,8 +12,8 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. + * This product includes software developed by the University of + * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -39,57 +39,57 @@ #include "y.tab.h" #include -static int cntcnt = 0; /* number of interrupt counters allocated */ +static int cntcnt = 0; /* number of interrupt counters allocated */ /* * Print a UNIBUS interrupt vector. */ void dump_ubavec(fp, vector, number) - register FILE *fp; - char *vector; - int number; + register FILE *fp; + char *vector; + int number; { - char nbuf[80]; - register char *v = nbuf; + char nbuf[80]; + register char *v = nbuf; - (void) sprintf(v, "%s%d", vector, number); - fprintf(fp, "\t.globl\t_X%s\n\t.align\t2\n_X%s:\n\tpushr\t$0x3f\n", - v, v); - fprintf(fp, "\tincl\t_fltintrcnt+(4*%d)\n", cntcnt++); - if (strncmp(vector, "dzx", 3) == 0) - fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdzdma\n\n", number); - else if (strncmp(vector, "dpx", 3) == 0) - fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdpxdma\n\n", number); - else if (strncmp(vector, "dpr", 3) == 0) - fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdprdma\n\n", number); - else { - if (strncmp(vector, "uur", 3) == 0) { - fprintf(fp, "#ifdef UUDMA\n"); - fprintf(fp, "\tmovl\t$%d,r0\n\tjsb\tuudma\n", number); - fprintf(fp, "#endif\n"); - } - fprintf(fp, "\tpushl\t$%d\n", number); - fprintf(fp, "\tcalls\t$1,_%s\n\tpopr\t$0x3f\n", vector); - fprintf(fp, "\tincl\t_cnt+V_INTR\n\trei\n\n"); - } + (void) sprintf(v, "%s%d", vector, number); + fprintf(fp, "\t.globl\t_X%s\n\t.align\t2\n_X%s:\n\tpushr\t$0x3f\n", + v, v); + fprintf(fp, "\tincl\t_fltintrcnt+(4*%d)\n", cntcnt++); + if (strncmp(vector, "dzx", 3) == 0) + fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdzdma\n\n", number); + else if (strncmp(vector, "dpx", 3) == 0) + fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdpxdma\n\n", number); + else if (strncmp(vector, "dpr", 3) == 0) + fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdprdma\n\n", number); + else { + if (strncmp(vector, "uur", 3) == 0) { + fprintf(fp, "#ifdef UUDMA\n"); + fprintf(fp, "\tmovl\t$%d,r0\n\tjsb\tuudma\n", number); + fprintf(fp, "#endif\n"); + } + fprintf(fp, "\tpushl\t$%d\n", number); + fprintf(fp, "\tcalls\t$1,_%s\n\tpopr\t$0x3f\n", vector); + fprintf(fp, "\tincl\t_cnt+V_INTR\n\trei\n\n"); + } } -static char *vaxinames[] = { - "clock", "cnr", "cnx", "tur", "tux", - "mba0", "mba1", "mba2", "mba3", - "uba0", "uba1", "uba2", "uba3" +static char *vaxinames[] = { + "clock", "cnr", "cnx", "tur", "tux", + "mba0", "mba1", "mba2", "mba3", + "uba0", "uba1", "uba2", "uba3" }; -static char *tahoeinames[] = { - "clock", "cnr", "cnx", "rmtr", "rmtx", "buserr", +static char *tahoeinames[] = { + "clock", "cnr", "cnx", "rmtr", "rmtx", "buserr", }; -static struct stdintrs { - char **si_names; /* list of standard interrupt names */ - int si_n; /* number of such names */ +static struct stdintrs { + char **si_names; /* list of standard interrupt names */ + int si_n; /* number of such names */ } stdintrs[] = { - { vaxinames, sizeof (vaxinames) / sizeof (vaxinames[0]) }, - { tahoeinames, (sizeof (tahoeinames) / sizeof (tahoeinames[0])) } + { vaxinames, sizeof (vaxinames) / sizeof (vaxinames[0]) }, + { tahoeinames, (sizeof (tahoeinames) / sizeof (tahoeinames[0])) } }; /* @@ -100,80 +100,80 @@ static struct stdintrs { * file which is prepended to locore.s. */ void dump_std(fp, gp) - register FILE *fp, *gp; + register FILE *fp, *gp; { - register struct stdintrs *si = &stdintrs[machine-1]; - register char **cpp; - register int i; + register struct stdintrs *si = &stdintrs[machine-1]; + register char **cpp; + register int i; - fprintf(fp, "\n\t.globl\t_intrnames\n"); - fprintf(fp, "\n\t.globl\t_eintrnames\n"); - fprintf(fp, "\t.data\n"); - fprintf(fp, "_intrnames:\n"); - cpp = si->si_names; - for (i = 0; i < si->si_n; i++) { - register char *cp, *tp; - char buf[80]; + fprintf(fp, "\n\t.globl\t_intrnames\n"); + fprintf(fp, "\n\t.globl\t_eintrnames\n"); + fprintf(fp, "\t.data\n"); + fprintf(fp, "_intrnames:\n"); + cpp = si->si_names; + for (i = 0; i < si->si_n; i++) { + register char *cp, *tp; + char buf[80]; - cp = *cpp; - if (cp[0] == 'i' && cp[1] == 'n' && cp[2] == 't') { - cp += 3; - if (*cp == 'r') - cp++; - } - for (tp = buf; *cp; cp++) - if (islower(*cp)) - *tp++ = toupper(*cp); - else - *tp++ = *cp; - *tp = '\0'; - fprintf(gp, "#define\tI_%s\t%d\n", buf, i * (int)sizeof (long)); - fprintf(fp, "\t.asciz\t\"%s\"\n", *cpp); - cpp++; - } + cp = *cpp; + if (cp[0] == 'i' && cp[1] == 'n' && cp[2] == 't') { + cp += 3; + if (*cp == 'r') + cp++; + } + for (tp = buf; *cp; cp++) + if (islower(*cp)) + *tp++ = toupper(*cp); + else + *tp++ = *cp; + *tp = '\0'; + fprintf(gp, "#define\tI_%s\t%d\n", buf, i * (int)sizeof (long)); + fprintf(fp, "\t.asciz\t\"%s\"\n", *cpp); + cpp++; + } } void dump_intname(fp, vector, number) - register FILE *fp; - char *vector; - int number; + register FILE *fp; + char *vector; + int number; { - register char *cp = vector; + register char *cp = vector; - fprintf(fp, "\t.asciz\t\""); - /* - * Skip any "int" or "intr" in the name. - */ - while (*cp) - if (cp[0] == 'i' && cp[1] == 'n' && cp[2] == 't') { - cp += 3; - if (*cp == 'r') - cp++; - } else { - putc(*cp, fp); - cp++; - } - fprintf(fp, "%d\"\n", number); + fprintf(fp, "\t.asciz\t\""); + /* + * Skip any "int" or "intr" in the name. + */ + while (*cp) + if (cp[0] == 'i' && cp[1] == 'n' && cp[2] == 't') { + cp += 3; + if (*cp == 'r') + cp++; + } else { + putc(*cp, fp); + cp++; + } + fprintf(fp, "%d\"\n", number); } /* * Reserve space for the interrupt counters. */ void dump_ctrs(fp) - register FILE *fp; + register FILE *fp; { - struct stdintrs *si = &stdintrs[machine-1]; + struct stdintrs *si = &stdintrs[machine-1]; - fprintf(fp, "_eintrnames:\n"); - fprintf(fp, "\n\t.globl\t_intrcnt\n"); - fprintf(fp, "\n\t.globl\t_eintrcnt\n"); - fprintf(fp, "\t.align 2\n"); - fprintf(fp, "_intrcnt:\n"); - fprintf(fp, "\t.space\t4 * %d\n", si->si_n); - fprintf(fp, "_fltintrcnt:\n"); - fprintf(fp, "\t.space\t4 * %d\n", cntcnt); - fprintf(fp, "_eintrcnt:\n\n"); - fprintf(fp, "\t.text\n"); + fprintf(fp, "_eintrnames:\n"); + fprintf(fp, "\n\t.globl\t_intrcnt\n"); + fprintf(fp, "\n\t.globl\t_eintrcnt\n"); + fprintf(fp, "\t.align 2\n"); + fprintf(fp, "_intrcnt:\n"); + fprintf(fp, "\t.space\t4 * %d\n", si->si_n); + fprintf(fp, "_fltintrcnt:\n"); + fprintf(fp, "\t.space\t4 * %d\n", cntcnt); + fprintf(fp, "_eintrcnt:\n\n"); + fprintf(fp, "\t.text\n"); } /* @@ -181,86 +181,86 @@ void dump_ctrs(fp) */ void ubglue() { - register FILE *fp, *gp; - register struct device *dp, *mp; + register FILE *fp, *gp; + register struct device *dp, *mp; - fp = fopen(path("ubglue.s"), "w"); - if (fp == 0) { - perror(path("ubglue.s")); - exit(1); - } - gp = fopen(path("ubvec.s"), "w"); - if (gp == 0) { - perror(path("ubvec.s")); - exit(1); - } - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (mp != 0 && mp != (struct device *)-1 && - !eq(mp->d_name, "mba")) { - struct idlst *id, *id2; + fp = fopen(path("ubglue.s"), "w"); + if (fp == 0) { + perror(path("ubglue.s")); + exit(1); + } + gp = fopen(path("ubvec.s"), "w"); + if (gp == 0) { + perror(path("ubvec.s")); + exit(1); + } + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (mp != 0 && mp != (struct device *)-1 && + !eq(mp->d_name, "mba")) { + struct idlst *id, *id2; - for (id = dp->d_vec; id; id = id->id_next) { - for (id2 = dp->d_vec; id2; id2 = id2->id_next) { - if (id2 == id) { - dump_ubavec(fp, id->id, - dp->d_unit); - break; - } - if (!strcmp(id->id, id2->id)) - break; - } - } - } - } - dump_std(fp, gp); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (mp != 0 && mp != (struct device *)-1 && - !eq(mp->d_name, "mba")) { - struct idlst *id, *id2; + for (id = dp->d_vec; id; id = id->id_next) { + for (id2 = dp->d_vec; id2; id2 = id2->id_next) { + if (id2 == id) { + dump_ubavec(fp, id->id, + dp->d_unit); + break; + } + if (!strcmp(id->id, id2->id)) + break; + } + } + } + } + dump_std(fp, gp); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (mp != 0 && mp != (struct device *)-1 && + !eq(mp->d_name, "mba")) { + struct idlst *id, *id2; - for (id = dp->d_vec; id; id = id->id_next) { - for (id2 = dp->d_vec; id2; id2 = id2->id_next) { - if (id2 == id) { - dump_intname(fp, id->id, - dp->d_unit); - break; - } - if (!strcmp(id->id, id2->id)) - break; - } - } - } - } - dump_ctrs(fp); - (void) fclose(fp); - (void) fclose(gp); + for (id = dp->d_vec; id; id = id->id_next) { + for (id2 = dp->d_vec; id2; id2 = id2->id_next) { + if (id2 == id) { + dump_intname(fp, id->id, + dp->d_unit); + break; + } + if (!strcmp(id->id, id2->id)) + break; + } + } + } + } + dump_ctrs(fp); + (void) fclose(fp); + (void) fclose(gp); } /* * Print a VERSAbus interrupt vector */ void dump_vbavec(fp, vector, number) - register FILE *fp; - char *vector; - int number; + register FILE *fp; + char *vector; + int number; { - char nbuf[80]; - register char *v = nbuf; + char nbuf[80]; + register char *v = nbuf; - (void) sprintf(v, "%s%d", vector, number); - fprintf(fp, "SCBVEC(%s):\n", v); - fprintf(fp, "\tCHECK_SFE(4)\n"); - fprintf(fp, "\tSAVE_FPSTAT(4)\n"); - fprintf(fp, "\tPUSHR\n"); - fprintf(fp, "\tincl\t_fltintrcnt+(4*%d)\n", cntcnt++); - fprintf(fp, "\tpushl\t$%d\n", number); - fprintf(fp, "\tcallf\t$8,_%s\n", vector); - fprintf(fp, "\tincl\t_cnt+V_INTR\n"); - fprintf(fp, "\tPOPR\n"); - fprintf(fp, "\tREST_FPSTAT\n"); - fprintf(fp, "\trei\n\n"); + (void) sprintf(v, "%s%d", vector, number); + fprintf(fp, "SCBVEC(%s):\n", v); + fprintf(fp, "\tCHECK_SFE(4)\n"); + fprintf(fp, "\tSAVE_FPSTAT(4)\n"); + fprintf(fp, "\tPUSHR\n"); + fprintf(fp, "\tincl\t_fltintrcnt+(4*%d)\n", cntcnt++); + fprintf(fp, "\tpushl\t$%d\n", number); + fprintf(fp, "\tcallf\t$8,_%s\n", vector); + fprintf(fp, "\tincl\t_cnt+V_INTR\n"); + fprintf(fp, "\tPOPR\n"); + fprintf(fp, "\tREST_FPSTAT\n"); + fprintf(fp, "\trei\n\n"); } /* @@ -268,59 +268,59 @@ void dump_vbavec(fp, vector, number) */ void vbglue() { - register FILE *fp, *gp; - register struct device *dp, *mp; + register FILE *fp, *gp; + register struct device *dp, *mp; - fp = fopen(path("vbglue.s"), "w"); - if (fp == 0) { - perror(path("vbglue.s")); - exit(1); - } - gp = fopen(path("vbvec.s"), "w"); - if (gp == 0) { - perror(path("vbvec.s")); - exit(1); - } - for (dp = dtab; dp != 0; dp = dp->d_next) { - struct idlst *id, *id2; + fp = fopen(path("vbglue.s"), "w"); + if (fp == 0) { + perror(path("vbglue.s")); + exit(1); + } + gp = fopen(path("vbvec.s"), "w"); + if (gp == 0) { + perror(path("vbvec.s")); + exit(1); + } + for (dp = dtab; dp != 0; dp = dp->d_next) { + struct idlst *id, *id2; - mp = dp->d_conn; - if (mp == 0 || mp == (struct device *)-1 || - eq(mp->d_name, "mba")) - continue; - for (id = dp->d_vec; id; id = id->id_next) - for (id2 = dp->d_vec; id2; id2 = id2->id_next) { - if (id == id2) { - dump_vbavec(fp, id->id, dp->d_unit); - break; - } - if (eq(id->id, id2->id)) - break; - } - } - dump_std(fp, gp); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (mp != 0 && mp != (struct device *)-1 && - !eq(mp->d_name, "mba")) { - struct idlst *id, *id2; + mp = dp->d_conn; + if (mp == 0 || mp == (struct device *)-1 || + eq(mp->d_name, "mba")) + continue; + for (id = dp->d_vec; id; id = id->id_next) + for (id2 = dp->d_vec; id2; id2 = id2->id_next) { + if (id == id2) { + dump_vbavec(fp, id->id, dp->d_unit); + break; + } + if (eq(id->id, id2->id)) + break; + } + } + dump_std(fp, gp); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (mp != 0 && mp != (struct device *)-1 && + !eq(mp->d_name, "mba")) { + struct idlst *id, *id2; - for (id = dp->d_vec; id; id = id->id_next) { - for (id2 = dp->d_vec; id2; id2 = id2->id_next) { - if (id2 == id) { - dump_intname(fp, id->id, - dp->d_unit); - break; - } - if (eq(id->id, id2->id)) - break; - } - } - } - } - dump_ctrs(fp); - (void) fclose(fp); - (void) fclose(gp); + for (id = dp->d_vec; id; id = id->id_next) { + for (id2 = dp->d_vec; id2; id2 = id2->id_next) { + if (id2 == id) { + dump_intname(fp, id->id, + dp->d_unit); + break; + } + if (eq(id->id, id2->id)) + break; + } + } + } + } + dump_ctrs(fp); + (void) fclose(fp); + (void) fclose(gp); } /* @@ -336,67 +336,67 @@ void hpglue() */ void vector() { - register FILE *fp; - register struct device *dp, *mp; - int count; + register FILE *fp; + register struct device *dp, *mp; + int count; - fp = fopen(path("vector.s"), "w"); - if (fp == 0) { - perror(path("vector.s")); - exit(1); - } - fprintf(fp,"\ + fp = fopen(path("vector.s"), "w"); + if (fp == 0) { + perror(path("vector.s")); + exit(1); + } + fprintf(fp,"\ /*\n\ * AT/386\n\ * Interrupt vector routines\n\ * Generated by config program\n\ */ \n\ \n\ -#include \"i386/isa/isa.h\"\n\ -#include \"i386/isa/icu.h\"\n\ +#include \"i386/isa/isa.h\"\n\ +#include \"i386/isa/icu.h\"\n\ \n\ -#define VEC(name) .align 4; .globl _V/**/name; _V/**/name:\n\n"); +#define VEC(name) .align 4; .globl _V/**/name; _V/**/name:\n\n"); - fprintf(fp,"\ - .globl _hardclock\n\ + fprintf(fp,"\ + .globl _hardclock\n\ VEC(clk)\n\ - INTR1(0, _highmask, 0)\n\ - call _hardclock \n\ - INTREXIT1\n\n\n"); + INTR1(0, _highmask, 0)\n\ + call _hardclock \n\ + INTREXIT1\n\n\n"); - count=0; - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (mp != 0 && /* mp != (struct device *)-1 &&*/ - eq(mp->d_name, "isa")) { - struct idlst *id, *id2; + count=0; + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (mp != 0 && /* mp != (struct device *)-1 &&*/ + eq(mp->d_name, "isa")) { + struct idlst *id, *id2; - for (id = dp->d_vec; id; id = id->id_next) { - for (id2 = dp->d_vec; id2; id2 = id2->id_next) { - if (id2 == id) { - if(dp->d_irq == -1) continue; - fprintf(fp,"\t.globl _%s, _%s%dmask\n\t.data\n", - id->id, dp->d_name, dp->d_unit); - fprintf(fp,"_%s%dmask:\t.long 0\n\t.text\n", - dp->d_name, dp->d_unit); - fprintf(fp,"VEC(%s%d)\n\tINTR%d(%d, ", - dp->d_name, dp->d_unit, - dp->d_irq / 8 + 1, dp->d_unit); - if(eq(dp->d_mask,"null")) - fprintf(fp,"_%s%dmask, ", - dp->d_name, dp->d_unit); - else - fprintf(fp,"_%smask, ", - dp->d_mask); - fprintf(fp,"%d)\n\tcall\t_%s\n\tINTREXIT%d\n\n\n", - ++count, id->id, (dp->d_irq > 7)?2:1); - break; - } - if (!strcmp(id->id, id2->id)) - break; - } - } - } - } - (void) fclose(fp); + for (id = dp->d_vec; id; id = id->id_next) { + for (id2 = dp->d_vec; id2; id2 = id2->id_next) { + if (id2 == id) { + if(dp->d_irq == -1) continue; + fprintf(fp,"\t.globl _%s, _%s%dmask\n\t.data\n", + id->id, dp->d_name, dp->d_unit); + fprintf(fp,"_%s%dmask:\t.long 0\n\t.text\n", + dp->d_name, dp->d_unit); + fprintf(fp,"VEC(%s%d)\n\tINTR%d(%d, ", + dp->d_name, dp->d_unit, + dp->d_irq / 8 + 1, dp->d_unit); + if(eq(dp->d_mask,"null")) + fprintf(fp,"_%s%dmask, ", + dp->d_name, dp->d_unit); + else + fprintf(fp,"_%smask, ", + dp->d_mask); + fprintf(fp,"%d)\n\tcall\t_%s\n\tINTREXIT%d\n\n\n", + ++count, id->id, (dp->d_irq > 7)?2:1); + break; + } + if (!strcmp(id->id, id2->id)) + break; + } + } + } + } + (void) fclose(fp); } diff --git a/tools/kconfig/mkheaders.c b/tools/kconfig/mkheaders.c index b86a481..3d12540 100644 --- a/tools/kconfig/mkheaders.c +++ b/tools/kconfig/mkheaders.c @@ -1,6 +1,6 @@ /* * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -12,8 +12,8 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. + * This product includes software developed by the University of + * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -41,82 +41,82 @@ #include "y.tab.h" void do_header(dev, hname, count) - char *dev, *hname; - int count; + char *dev, *hname; + int count; { - char *file, *name, *inw, *toheader(), *tomacro(); - struct file_list *fl, *fl_head, *tflp; - FILE *inf, *outf; - int inc, oldcount; + char *file, *name, *inw, *toheader(), *tomacro(); + struct file_list *fl, *fl_head, *tflp; + FILE *inf, *outf; + int inc, oldcount; - file = toheader(hname); - name = tomacro(dev); - inf = fopen(file, "r"); - oldcount = -1; - if (inf == 0) { - outf = fopen(file, "w"); - if (outf == 0) { - perror(file); - exit(1); - } - fprintf(outf, "#define %s %d\n", name, count); - (void) fclose(outf); - return; - } - fl_head = NULL; - for (;;) { - char *cp; - if ((inw = get_word(inf)) == 0 || inw == (char *)EOF) - break; - if ((inw = get_word(inf)) == 0 || inw == (char *)EOF) - break; - inw = ns(inw); - cp = get_word(inf); - if (cp == 0 || cp == (char *)EOF) - break; - inc = atoi(cp); - if (eq(inw, name)) { - oldcount = inc; - inc = count; - } - cp = get_word(inf); - if (cp == (char *)EOF) - break; - fl = (struct file_list *) malloc(sizeof *fl); - bzero(fl, sizeof(*fl)); - fl->f_fn = inw; - fl->f_type = inc; - fl->f_next = fl_head; - fl_head = fl; - } - (void) fclose(inf); - if (count == oldcount) { - for (fl = fl_head; fl != NULL; fl = tflp) { - tflp = fl->f_next; - free(fl); - } - return; - } - if (oldcount == -1) { - fl = (struct file_list *) malloc(sizeof *fl); - bzero(fl, sizeof(*fl)); - fl->f_fn = name; - fl->f_type = count; - fl->f_next = fl_head; - fl_head = fl; - } - outf = fopen(file, "w"); - if (outf == 0) { - perror(file); - exit(1); - } - for (fl = fl_head; fl != NULL; fl = tflp) { - fprintf(outf, - "#define %s %u\n", fl->f_fn, count ? fl->f_type : 0); - tflp = fl->f_next; - free(fl); - } - (void) fclose(outf); + file = toheader(hname); + name = tomacro(dev); + inf = fopen(file, "r"); + oldcount = -1; + if (inf == 0) { + outf = fopen(file, "w"); + if (outf == 0) { + perror(file); + exit(1); + } + fprintf(outf, "#define %s %d\n", name, count); + (void) fclose(outf); + return; + } + fl_head = NULL; + for (;;) { + char *cp; + if ((inw = get_word(inf)) == 0 || inw == (char *)EOF) + break; + if ((inw = get_word(inf)) == 0 || inw == (char *)EOF) + break; + inw = ns(inw); + cp = get_word(inf); + if (cp == 0 || cp == (char *)EOF) + break; + inc = atoi(cp); + if (eq(inw, name)) { + oldcount = inc; + inc = count; + } + cp = get_word(inf); + if (cp == (char *)EOF) + break; + fl = (struct file_list *) malloc(sizeof *fl); + bzero(fl, sizeof(*fl)); + fl->f_fn = inw; + fl->f_type = inc; + fl->f_next = fl_head; + fl_head = fl; + } + (void) fclose(inf); + if (count == oldcount) { + for (fl = fl_head; fl != NULL; fl = tflp) { + tflp = fl->f_next; + free(fl); + } + return; + } + if (oldcount == -1) { + fl = (struct file_list *) malloc(sizeof *fl); + bzero(fl, sizeof(*fl)); + fl->f_fn = name; + fl->f_type = count; + fl->f_next = fl_head; + fl_head = fl; + } + outf = fopen(file, "w"); + if (outf == 0) { + perror(file); + exit(1); + } + for (fl = fl_head; fl != NULL; fl = tflp) { + fprintf(outf, + "#define %s %u\n", fl->f_fn, count ? fl->f_type : 0); + tflp = fl->f_next; + free(fl); + } + (void) fclose(outf); } /* @@ -124,51 +124,51 @@ void do_header(dev, hname, count) * whatever the device is connected to */ void do_count(dev, hname, search) - register char *dev, *hname; - int search; + register char *dev, *hname; + int search; { - register struct device *dp, *mp; - register int count, hicount; + register struct device *dp, *mp; + register int count, hicount; - /* - * After this loop, "count" will be the actual number of units, - * and "hicount" will be the highest unit declared. do_header() - * must use this higher of these values. - */ - for (hicount = count = 0, dp = dtab; dp != 0; dp = dp->d_next) - if (dp->d_unit != -1 && eq(dp->d_name, dev)) { - if (dp->d_type == PSEUDO_DEVICE) { - count = - dp->d_slave != UNKNOWN ? dp->d_slave : 1; - break; - } - count++; - /* - * Allow holes in unit numbering, - * assumption is unit numbering starts - * at zero. - */ - if (dp->d_unit + 1 > hicount) - hicount = dp->d_unit + 1; - if (search) { - mp = dp->d_conn; - if (mp != 0 && mp != TO_NEXUS && - mp->d_conn != 0 && mp->d_conn != TO_NEXUS) { - do_count(mp->d_name, hname, 0); - search = 0; - } - } - } - do_header(dev, hname, count > hicount ? count : hicount); + /* + * After this loop, "count" will be the actual number of units, + * and "hicount" will be the highest unit declared. do_header() + * must use this higher of these values. + */ + for (hicount = count = 0, dp = dtab; dp != 0; dp = dp->d_next) + if (dp->d_unit != -1 && eq(dp->d_name, dev)) { + if (dp->d_type == PSEUDO_DEVICE) { + count = + dp->d_slave != UNKNOWN ? dp->d_slave : 1; + break; + } + count++; + /* + * Allow holes in unit numbering, + * assumption is unit numbering starts + * at zero. + */ + if (dp->d_unit + 1 > hicount) + hicount = dp->d_unit + 1; + if (search) { + mp = dp->d_conn; + if (mp != 0 && mp != TO_NEXUS && + mp->d_conn != 0 && mp->d_conn != TO_NEXUS) { + do_count(mp->d_name, hname, 0); + search = 0; + } + } + } + do_header(dev, hname, count > hicount ? count : hicount); } void headers() { - register struct file_list *fl; + register struct file_list *fl; - for (fl = ftab; fl != 0; fl = fl->f_next) - if (fl->f_needs != 0) - do_count(fl->f_needs, fl->f_needs, 1); + for (fl = ftab; fl != 0; fl = fl->f_next) + if (fl->f_needs != 0) + do_count(fl->f_needs, fl->f_needs, 1); } /* @@ -176,28 +176,28 @@ void headers() */ char * toheader(dev) - char *dev; + char *dev; { - static char hbuf[80]; + static char hbuf[80]; - (void) strcpy(hbuf, path(dev)); - (void) strcat(hbuf, ".h"); - return (hbuf); + (void) strcpy(hbuf, path(dev)); + (void) strcat(hbuf, ".h"); + return (hbuf); } /* * convert a dev name to a macro name */ char *tomacro(dev) - register char *dev; + register char *dev; { - static char mbuf[20]; - register char *cp; + static char mbuf[20]; + register char *cp; - cp = mbuf; - *cp++ = 'N'; - while (*dev) - *cp++ = islower(*dev) ? toupper(*dev++) : *dev++; - *cp++ = 0; - return (mbuf); + cp = mbuf; + *cp++ = 'N'; + while (*dev) + *cp++ = islower(*dev) ? toupper(*dev++) : *dev++; + *cp++ = 0; + return (mbuf); } diff --git a/tools/kconfig/mkioconf.c b/tools/kconfig/mkioconf.c index ef77297..0642600 100644 --- a/tools/kconfig/mkioconf.c +++ b/tools/kconfig/mkioconf.c @@ -1,6 +1,6 @@ /* * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -12,8 +12,8 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. + * This product includes software developed by the University of + * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -38,427 +38,429 @@ /* * build the ioconf.c file */ -char *qu(); -char *intv(); -char *wnum(); -void pseudo_ioconf(); +char *qu(); +char *intv(); +char *wnum(); +void pseudo_ioconf(); #if MACHINE_VAX void vax_ioconf() { - register struct device *dp, *mp, *np; - register int uba_n, slave; - FILE *fp; + register struct device *dp, *mp, *np; + register int uba_n, slave; + FILE *fp; - fp = fopen(path("ioconf.c"), "w"); - if (fp == 0) { - perror(path("ioconf.c")); - exit(1); - } - fprintf(fp, "#include \"vax/include/pte.h\"\n"); - fprintf(fp, "#include \"sys/param.h\"\n"); - fprintf(fp, "#include \"sys/buf.h\"\n"); - fprintf(fp, "#include \"sys/map.h\"\n"); - fprintf(fp, "\n"); - fprintf(fp, "#include \"vax/mba/mbavar.h\"\n"); - fprintf(fp, "#include \"vax/uba/ubavar.h\"\n\n"); - fprintf(fp, "\n"); - fprintf(fp, "#define C (caddr_t)\n\n"); - /* - * First print the mba initialization structures - */ - if (seen_mba) { - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (mp == 0 || mp == TO_NEXUS || - !eq(mp->d_name, "mba")) - continue; - fprintf(fp, "extern struct mba_driver %sdriver;\n", - dp->d_name); - } - fprintf(fp, "\nstruct mba_device mbdinit[] = {\n"); - fprintf(fp, "\t/* Device, Unit, Mba, Drive, Dk */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_unit == QUES || mp == 0 || - mp == TO_NEXUS || !eq(mp->d_name, "mba")) - continue; - if (dp->d_addr) { - printf("can't specify csr address on mba for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_vec != 0) { - printf("can't specify vector for %s%d on mba\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_drive == UNKNOWN) { - printf("drive not specified for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_slave != UNKNOWN) { - printf("can't specify slave number for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - fprintf(fp, "\t{ &%sdriver, %d, %s,", - dp->d_name, dp->d_unit, qu(mp->d_unit)); - fprintf(fp, " %s, %d },\n", - qu(dp->d_drive), dp->d_dk); - } - fprintf(fp, "\t0\n};\n\n"); - /* - * Print the mbsinit structure - * Driver Controller Unit Slave - */ - fprintf(fp, "struct mba_slave mbsinit [] = {\n"); - fprintf(fp, "\t/* Driver, Ctlr, Unit, Slave */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - /* - * All slaves are connected to something which - * is connected to the massbus. - */ - if ((mp = dp->d_conn) == 0 || mp == TO_NEXUS) - continue; - np = mp->d_conn; - if (np == 0 || np == TO_NEXUS || - !eq(np->d_name, "mba")) - continue; - fprintf(fp, "\t{ &%sdriver, %s", - mp->d_name, qu(mp->d_unit)); - fprintf(fp, ", %2d, %s },\n", - dp->d_unit, qu(dp->d_slave)); - } - fprintf(fp, "\t0\n};\n\n"); - } - /* - * Now generate interrupt vectors for the unibus - */ - for (dp = dtab; dp != 0; dp = dp->d_next) { - if (dp->d_vec != 0) { - struct idlst *ip; - mp = dp->d_conn; - if (mp == 0 || mp == TO_NEXUS || - (!eq(mp->d_name, "uba") && !eq(mp->d_name, "bi"))) - continue; - fprintf(fp, - "extern struct uba_driver %sdriver;\n", - dp->d_name); - fprintf(fp, "extern "); - ip = dp->d_vec; - for (;;) { - fprintf(fp, "X%s%d()", ip->id, dp->d_unit); - ip = ip->id_next; - if (ip == 0) - break; - fprintf(fp, ", "); - } - fprintf(fp, ";\n"); - fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name, - dp->d_unit); - ip = dp->d_vec; - for (;;) { - fprintf(fp, "X%s%d", ip->id, dp->d_unit); - ip = ip->id_next; - if (ip == 0) - break; - fprintf(fp, ", "); - } - fprintf(fp, ", 0 } ;\n"); - } - } - fprintf(fp, "\nstruct uba_ctlr ubminit[] = {\n"); - fprintf(fp, "/*\t driver,\tctlr,\tubanum,\talive,\tintr,\taddr */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 || - !eq(mp->d_name, "uba")) - continue; - if (dp->d_vec == 0) { - printf("must specify vector for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_addr == 0) { - printf("must specify csr address for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { - printf("drives need their own entries; dont "); - printf("specify drive or slave for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_flags) { - printf("controllers (e.g. %s%d) ", - dp->d_name, dp->d_unit); - printf("don't have flags, only devices do\n"); - continue; - } - fprintf(fp, - "\t{ &%sdriver,\t%d,\t%s,\t0,\t%sint%d, C 0%o },\n", - dp->d_name, dp->d_unit, qu(mp->d_unit), - dp->d_name, dp->d_unit, dp->d_addr); - } - fprintf(fp, "\t0\n};\n"); + fp = fopen(path("ioconf.c"), "w"); + if (fp == 0) { + perror(path("ioconf.c")); + exit(1); + } + fprintf(fp, "#include \"vax/include/pte.h\"\n"); + fprintf(fp, "#include \"sys/param.h\"\n"); + fprintf(fp, "#include \"sys/buf.h\"\n"); + fprintf(fp, "#include \"sys/map.h\"\n"); + fprintf(fp, "\n"); + fprintf(fp, "#include \"vax/mba/mbavar.h\"\n"); + fprintf(fp, "#include \"vax/uba/ubavar.h\"\n\n"); + fprintf(fp, "\n"); + fprintf(fp, "#define C (caddr_t)\n\n"); + + /* + * First print the mba initialization structures + */ + if (seen_mba) { + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (mp == 0 || mp == TO_NEXUS || + !eq(mp->d_name, "mba")) + continue; + fprintf(fp, "extern struct mba_driver %sdriver;\n", + dp->d_name); + } + fprintf(fp, "\nstruct mba_device mbdinit[] = {\n"); + fprintf(fp, "\t/* Device, Unit, Mba, Drive, Dk */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_unit == QUES || mp == 0 || + mp == TO_NEXUS || !eq(mp->d_name, "mba")) + continue; + if (dp->d_addr) { + printf("can't specify csr address on mba for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_vec != 0) { + printf("can't specify vector for %s%d on mba\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_drive == UNKNOWN) { + printf("drive not specified for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_slave != UNKNOWN) { + printf("can't specify slave number for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + fprintf(fp, "\t{ &%sdriver, %d, %s,", + dp->d_name, dp->d_unit, qu(mp->d_unit)); + fprintf(fp, " %s, %d },\n", + qu(dp->d_drive), dp->d_dk); + } + fprintf(fp, "\t0\n};\n\n"); + /* + * Print the mbsinit structure + * Driver Controller Unit Slave + */ + fprintf(fp, "struct mba_slave mbsinit [] = {\n"); + fprintf(fp, "\t/* Driver, Ctlr, Unit, Slave */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + /* + * All slaves are connected to something which + * is connected to the massbus. + */ + if ((mp = dp->d_conn) == 0 || mp == TO_NEXUS) + continue; + np = mp->d_conn; + if (np == 0 || np == TO_NEXUS || + !eq(np->d_name, "mba")) + continue; + fprintf(fp, "\t{ &%sdriver, %s", + mp->d_name, qu(mp->d_unit)); + fprintf(fp, ", %2d, %s },\n", + dp->d_unit, qu(dp->d_slave)); + } + fprintf(fp, "\t0\n};\n\n"); + } + /* + * Now generate interrupt vectors for the unibus + */ + for (dp = dtab; dp != 0; dp = dp->d_next) { + if (dp->d_vec != 0) { + struct idlst *ip; + mp = dp->d_conn; + if (mp == 0 || mp == TO_NEXUS || + (!eq(mp->d_name, "uba") && !eq(mp->d_name, "bi"))) + continue; + fprintf(fp, + "extern struct uba_driver %sdriver;\n", + dp->d_name); + fprintf(fp, "extern "); + ip = dp->d_vec; + for (;;) { + fprintf(fp, "X%s%d()", ip->id, dp->d_unit); + ip = ip->id_next; + if (ip == 0) + break; + fprintf(fp, ", "); + } + fprintf(fp, ";\n"); + fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name, + dp->d_unit); + ip = dp->d_vec; + for (;;) { + fprintf(fp, "X%s%d", ip->id, dp->d_unit); + ip = ip->id_next; + if (ip == 0) + break; + fprintf(fp, ", "); + } + fprintf(fp, ", 0 } ;\n"); + } + } + fprintf(fp, "\nstruct uba_ctlr ubminit[] = {\n"); + fprintf(fp, "/*\t driver,\tctlr,\tubanum,\talive,\tintr,\taddr */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 || + !eq(mp->d_name, "uba")) + continue; + if (dp->d_vec == 0) { + printf("must specify vector for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_addr == 0) { + printf("must specify csr address for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { + printf("drives need their own entries; dont "); + printf("specify drive or slave for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_flags) { + printf("controllers (e.g. %s%d) ", + dp->d_name, dp->d_unit); + printf("don't have flags, only devices do\n"); + continue; + } + fprintf(fp, + "\t{ &%sdriver,\t%d,\t%s,\t0,\t%sint%d, C 0%o },\n", + dp->d_name, dp->d_unit, qu(mp->d_unit), + dp->d_name, dp->d_unit, dp->d_addr); + } + fprintf(fp, "\t0\n};\n"); /* unibus devices */ - fprintf(fp, "\nstruct uba_device ubdinit[] = {\n"); - fprintf(fp, -"\t/* driver, unit, ctlr, ubanum, slave, intr, addr, dk, flags*/\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || - mp == TO_NEXUS || mp->d_type == MASTER || - eq(mp->d_name, "mba")) - continue; - np = mp->d_conn; - if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba")) - continue; - np = 0; - if (eq(mp->d_name, "uba")) { - if (dp->d_vec == 0) { - printf("must specify vector for device %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_addr == 0) { - printf("must specify csr for device %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { - printf("drives/slaves can be specified "); - printf("only for controllers, "); - printf("not for device %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - uba_n = mp->d_unit; - slave = QUES; - } else { - if ((np = mp->d_conn) == 0) { - printf("%s%d isn't connected to anything ", - mp->d_name, mp->d_unit); - printf(", so %s%d is unattached\n", - dp->d_name, dp->d_unit); - continue; - } - uba_n = np->d_unit; - if (dp->d_drive == UNKNOWN) { - printf("must specify ``drive number'' "); - printf("for %s%d\n", dp->d_name, dp->d_unit); - continue; - } - /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */ - /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ - if (dp->d_slave != UNKNOWN) { - printf("slave numbers should be given only "); - printf("for massbus tapes, not for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_vec != 0) { - printf("interrupt vectors should not be "); - printf("given for drive %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_addr != 0) { - printf("csr addresses should be given only "); - printf("on controllers, not on %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - slave = dp->d_drive; - } - fprintf(fp, "\t{ &%sdriver, %2d, %s,", - eq(mp->d_name, "uba") ? dp->d_name : mp->d_name, dp->d_unit, - eq(mp->d_name, "uba") ? " -1" : qu(mp->d_unit)); - fprintf(fp, " %s, %2d, %s, C 0%-6o, %d, 0x%x },\n", - qu(uba_n), slave, intv(dp), dp->d_addr, dp->d_dk, - dp->d_flags); - } - fprintf(fp, "\t0\n};\n"); - pseudo_ioconf(fp); - (void) fclose(fp); + fprintf(fp, "\nstruct uba_device ubdinit[] = {\n"); + fprintf(fp, + "\t/* driver, unit, ctlr, ubanum, slave, intr, addr, dk, flags*/\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || + mp == TO_NEXUS || mp->d_type == MASTER || + eq(mp->d_name, "mba")) + continue; + np = mp->d_conn; + if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba")) + continue; + np = 0; + if (eq(mp->d_name, "uba")) { + if (dp->d_vec == 0) { + printf("must specify vector for device %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_addr == 0) { + printf("must specify csr for device %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { + printf("drives/slaves can be specified "); + printf("only for controllers, "); + printf("not for device %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + uba_n = mp->d_unit; + slave = QUES; + } else { + if ((np = mp->d_conn) == 0) { + printf("%s%d isn't connected to anything ", + mp->d_name, mp->d_unit); + printf(", so %s%d is unattached\n", + dp->d_name, dp->d_unit); + continue; + } + uba_n = np->d_unit; + if (dp->d_drive == UNKNOWN) { + printf("must specify ``drive number'' "); + printf("for %s%d\n", dp->d_name, dp->d_unit); + continue; + } + /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */ + /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ + if (dp->d_slave != UNKNOWN) { + printf("slave numbers should be given only "); + printf("for massbus tapes, not for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_vec != 0) { + printf("interrupt vectors should not be "); + printf("given for drive %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_addr != 0) { + printf("csr addresses should be given only "); + printf("on controllers, not on %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + slave = dp->d_drive; + } + fprintf(fp, "\t{ &%sdriver, %2d, %s,", + eq(mp->d_name, "uba") ? dp->d_name : mp->d_name, dp->d_unit, + eq(mp->d_name, "uba") ? " -1" : qu(mp->d_unit)); + fprintf(fp, " %s, %2d, %s, C 0%-6o, %d, 0x%x },\n", + qu(uba_n), slave, intv(dp), dp->d_addr, dp->d_dk, + dp->d_flags); + } + fprintf(fp, "\t0\n};\n"); + pseudo_ioconf(fp); + (void) fclose(fp); } #endif #if MACHINE_TAHOE void tahoe_ioconf() { - register struct device *dp, *mp, *np; - register int vba_n, slave; - FILE *fp; + register struct device *dp, *mp, *np; + register int vba_n, slave; + FILE *fp; - fp = fopen(path("ioconf.c"), "w"); - if (fp == 0) { - perror(path("ioconf.c")); - exit(1); - } - fprintf(fp, "#include \"sys/param.h\"\n"); - fprintf(fp, "#include \"tahoe/include/pte.h\"\n"); - fprintf(fp, "#include \"sys/buf.h\"\n"); - fprintf(fp, "#include \"sys/map.h\"\n"); - fprintf(fp, "\n"); - fprintf(fp, "#include \"tahoe/vba/vbavar.h\"\n"); - fprintf(fp, "\n"); - fprintf(fp, "#define C (caddr_t)\n\n"); - /* - * Now generate interrupt vectors for the versabus - */ - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (mp == 0 || mp == TO_NEXUS || !eq(mp->d_name, "vba")) - continue; - if (dp->d_vec != 0) { - struct idlst *ip; - fprintf(fp, - "extern struct vba_driver %sdriver;\n", - dp->d_name); - fprintf(fp, "extern "); - ip = dp->d_vec; - for (;;) { - fprintf(fp, "X%s%d()", ip->id, dp->d_unit); - ip = ip->id_next; - if (ip == 0) - break; - fprintf(fp, ", "); - } - fprintf(fp, ";\n"); - fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name, - dp->d_unit); - ip = dp->d_vec; - for (;;) { - fprintf(fp, "X%s%d", ip->id, dp->d_unit); - ip = ip->id_next; - if (ip == 0) - break; - fprintf(fp, ", "); - } - fprintf(fp, ", 0 } ;\n"); - } else if (dp->d_type == DRIVER) /* devices w/o interrupts */ - fprintf(fp, - "extern struct vba_driver %sdriver;\n", - dp->d_name); - } - fprintf(fp, "\nstruct vba_ctlr vbminit[] = {\n"); - fprintf(fp, "/*\t driver,\tctlr,\tvbanum,\talive,\tintr,\taddr */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 || - !eq(mp->d_name, "vba")) - continue; - if (dp->d_vec == 0) { - printf("must specify vector for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_addr == 0) { - printf("must specify csr address for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { - printf("drives need their own entries; dont "); - printf("specify drive or slave for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_flags) { - printf("controllers (e.g. %s%d) ", - dp->d_name, dp->d_unit); - printf("don't have flags, only devices do\n"); - continue; - } - fprintf(fp, - "\t{ &%sdriver,\t%d,\t%s,\t0,\t%sint%d, C 0x%x },\n", - dp->d_name, dp->d_unit, qu(mp->d_unit), - dp->d_name, dp->d_unit, dp->d_addr); - } - fprintf(fp, "\t0\n};\n"); -/* versabus devices */ - fprintf(fp, "\nstruct vba_device vbdinit[] = {\n"); - fprintf(fp, -"\t/* driver, unit, ctlr, vbanum, slave, intr, addr, dk, flags*/\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || - mp == TO_NEXUS || mp->d_type == MASTER || - eq(mp->d_name, "mba")) - continue; - np = mp->d_conn; - if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba")) - continue; - np = 0; - if (eq(mp->d_name, "vba")) { - if (dp->d_vec == 0) - printf( - "Warning, no interrupt vector specified for device %s%d\n", - dp->d_name, dp->d_unit); - if (dp->d_addr == 0) { - printf("must specify csr for device %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { - printf("drives/slaves can be specified "); - printf("only for controllers, "); - printf("not for device %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - vba_n = mp->d_unit; - slave = QUES; - } else { - if ((np = mp->d_conn) == 0) { - printf("%s%d isn't connected to anything ", - mp->d_name, mp->d_unit); - printf(", so %s%d is unattached\n", - dp->d_name, dp->d_unit); - continue; - } - vba_n = np->d_unit; - if (dp->d_drive == UNKNOWN) { - printf("must specify ``drive number'' "); - printf("for %s%d\n", dp->d_name, dp->d_unit); - continue; - } - /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */ - /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ - if (dp->d_slave != UNKNOWN) { - printf("slave numbers should be given only "); - printf("for massbus tapes, not for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_vec != 0) { - printf("interrupt vectors should not be "); - printf("given for drive %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_addr != 0) { - printf("csr addresses should be given only "); - printf("on controllers, not on %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - slave = dp->d_drive; - } - fprintf(fp, "\t{ &%sdriver, %2d, %s,", - eq(mp->d_name, "vba") ? dp->d_name : mp->d_name, dp->d_unit, - eq(mp->d_name, "vba") ? " -1" : qu(mp->d_unit)); - fprintf(fp, " %s, %2d, %s, C 0x%-6x, %d, 0x%x },\n", - qu(vba_n), slave, intv(dp), dp->d_addr, dp->d_dk, - dp->d_flags); - } - fprintf(fp, "\t0\n};\n"); - pseudo_ioconf(fp); - (void) fclose(fp); + fp = fopen(path("ioconf.c"), "w"); + if (fp == 0) { + perror(path("ioconf.c")); + exit(1); + } + fprintf(fp, "#include \"sys/param.h\"\n"); + fprintf(fp, "#include \"tahoe/include/pte.h\"\n"); + fprintf(fp, "#include \"sys/buf.h\"\n"); + fprintf(fp, "#include \"sys/map.h\"\n"); + fprintf(fp, "\n"); + fprintf(fp, "#include \"tahoe/vba/vbavar.h\"\n"); + fprintf(fp, "\n"); + fprintf(fp, "#define C (caddr_t)\n\n"); + /* + * Now generate interrupt vectors for the versabus + */ + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (mp == 0 || mp == TO_NEXUS || !eq(mp->d_name, "vba")) + continue; + if (dp->d_vec != 0) { + struct idlst *ip; + fprintf(fp, + "extern struct vba_driver %sdriver;\n", + dp->d_name); + fprintf(fp, "extern "); + ip = dp->d_vec; + for (;;) { + fprintf(fp, "X%s%d()", ip->id, dp->d_unit); + ip = ip->id_next; + if (ip == 0) + break; + fprintf(fp, ", "); + } + fprintf(fp, ";\n"); + fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name, + dp->d_unit); + ip = dp->d_vec; + for (;;) { + fprintf(fp, "X%s%d", ip->id, dp->d_unit); + ip = ip->id_next; + if (ip == 0) + break; + fprintf(fp, ", "); + } + fprintf(fp, ", 0 } ;\n"); + } else if (dp->d_type == DRIVER) /* devices w/o interrupts */ + fprintf(fp, + "extern struct vba_driver %sdriver;\n", + dp->d_name); + } + fprintf(fp, "\nstruct vba_ctlr vbminit[] = {\n"); + fprintf(fp, "/*\t driver,\tctlr,\tvbanum,\talive,\tintr,\taddr */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 || + !eq(mp->d_name, "vba")) + continue; + if (dp->d_vec == 0) { + printf("must specify vector for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_addr == 0) { + printf("must specify csr address for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { + printf("drives need their own entries; dont "); + printf("specify drive or slave for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_flags) { + printf("controllers (e.g. %s%d) ", + dp->d_name, dp->d_unit); + printf("don't have flags, only devices do\n"); + continue; + } + fprintf(fp, + "\t{ &%sdriver,\t%d,\t%s,\t0,\t%sint%d, C 0x%x },\n", + dp->d_name, dp->d_unit, qu(mp->d_unit), + dp->d_name, dp->d_unit, dp->d_addr); + } + fprintf(fp, "\t0\n};\n"); + + /* versabus devices */ + fprintf(fp, "\nstruct vba_device vbdinit[] = {\n"); + fprintf(fp, + "\t/* driver, unit, ctlr, vbanum, slave, intr, addr, dk, flags*/\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || + mp == TO_NEXUS || mp->d_type == MASTER || + eq(mp->d_name, "mba")) + continue; + np = mp->d_conn; + if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba")) + continue; + np = 0; + if (eq(mp->d_name, "vba")) { + if (dp->d_vec == 0) + printf( + "Warning, no interrupt vector specified for device %s%d\n", + dp->d_name, dp->d_unit); + if (dp->d_addr == 0) { + printf("must specify csr for device %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { + printf("drives/slaves can be specified "); + printf("only for controllers, "); + printf("not for device %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + vba_n = mp->d_unit; + slave = QUES; + } else { + if ((np = mp->d_conn) == 0) { + printf("%s%d isn't connected to anything ", + mp->d_name, mp->d_unit); + printf(", so %s%d is unattached\n", + dp->d_name, dp->d_unit); + continue; + } + vba_n = np->d_unit; + if (dp->d_drive == UNKNOWN) { + printf("must specify ``drive number'' "); + printf("for %s%d\n", dp->d_name, dp->d_unit); + continue; + } + /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */ + /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ + if (dp->d_slave != UNKNOWN) { + printf("slave numbers should be given only "); + printf("for massbus tapes, not for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_vec != 0) { + printf("interrupt vectors should not be "); + printf("given for drive %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_addr != 0) { + printf("csr addresses should be given only "); + printf("on controllers, not on %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + slave = dp->d_drive; + } + fprintf(fp, "\t{ &%sdriver, %2d, %s,", + eq(mp->d_name, "vba") ? dp->d_name : mp->d_name, dp->d_unit, + eq(mp->d_name, "vba") ? " -1" : qu(mp->d_unit)); + fprintf(fp, " %s, %2d, %s, C 0x%-6x, %d, 0x%x },\n", + qu(vba_n), slave, intv(dp), dp->d_addr, dp->d_dk, + dp->d_flags); + } + fprintf(fp, "\t0\n};\n"); + pseudo_ioconf(fp); + (void) fclose(fp); } #endif @@ -468,130 +470,131 @@ void tahoe_ioconf() #define isscsidev(n) (eq(n,"sd") || eq(n,"st") || eq(n,"ac")) int hpbadslave(mp, dp) - register struct device *dp, *mp; + register struct device *dp, *mp; { - if ((mp == TO_NEXUS && ishpibdev(dp->d_name)) || - (mp != TO_NEXUS && eq(mp->d_name, "hpib") && - !ishpibdev(dp->d_name))) { - printf("%s%s must be attached to an hpib\n", - dp->d_name, wnum(dp->d_unit)); - return (1); - } - if ((mp == TO_NEXUS && isscsidev(dp->d_name)) || - (mp != TO_NEXUS && eq(mp->d_name, "scsi") && - !isscsidev(dp->d_name))) { - printf("%s%s must be attached to a scsi\n", - dp->d_name, wnum(dp->d_unit)); - return (1); - } - return (0); + if ((mp == TO_NEXUS && ishpibdev(dp->d_name)) || + (mp != TO_NEXUS && eq(mp->d_name, "hpib") && + !ishpibdev(dp->d_name))) { + printf("%s%s must be attached to an hpib\n", + dp->d_name, wnum(dp->d_unit)); + return (1); + } + if ((mp == TO_NEXUS && isscsidev(dp->d_name)) || + (mp != TO_NEXUS && eq(mp->d_name, "scsi") && + !isscsidev(dp->d_name))) { + printf("%s%s must be attached to a scsi\n", + dp->d_name, wnum(dp->d_unit)); + return (1); + } + return (0); } void hp300_ioconf() { - register struct device *dp, *mp; - register int hpib, slave; - FILE *fp; + register struct device *dp, *mp; + register int hpib, slave; + FILE *fp; - fp = fopen(path("ioconf.c"), "w"); - if (fp == 0) { - perror(path("ioconf.c")); - exit(1); - } - fprintf(fp, "#include \"sys/param.h\"\n"); - fprintf(fp, "#include \"sys/buf.h\"\n"); - fprintf(fp, "#include \"sys/map.h\"\n"); - fprintf(fp, "\n"); - if (machine == MACHINE_HP300) - fprintf(fp, "#include \"hp/dev/device.h\"\n\n"); - else - fprintf(fp, "#include \"luna68k/dev/device.h\"\n\n"); - fprintf(fp, "\n"); - fprintf(fp, "#define C (caddr_t)\n"); - fprintf(fp, "#define D (struct driver *)\n\n"); - /* - * First print the hpib controller initialization structures - */ - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_unit == QUES || mp == 0) - continue; - fprintf(fp, "extern struct driver %sdriver;\n", dp->d_name); - } - fprintf(fp, "\nstruct hp_ctlr hp_cinit[] = {\n"); - fprintf(fp, "/*\tdriver,\t\tunit,\talive,\taddr,\tflags */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_unit == QUES || - (dp->d_type != MASTER && dp->d_type != CONTROLLER)) - continue; - if (mp != TO_NEXUS) { - printf("%s%s must be attached to an sc (nexus)\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { - printf("can't specify drive/slave for %s%s\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - fprintf(fp, - "\t{ &%sdriver,\t%d,\t0,\tC 0x%x,\t0x%x },\n", - dp->d_name, dp->d_unit, dp->d_addr, dp->d_flags); - } - fprintf(fp, "\t0\n};\n"); -/* devices */ - fprintf(fp, "\nstruct hp_device hp_dinit[] = {\n"); - fprintf(fp, - "/*driver,\tcdriver,\tunit,\tctlr,\tslave,\taddr,\tdk,\tflags*/\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (mp == 0 || dp->d_type != DEVICE || hpbadslave(mp, dp)) - continue; - if (mp == TO_NEXUS) { - if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { - printf("can't specify drive/slave for %s%s\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - slave = QUES; - hpib = QUES; - } else { - if (dp->d_addr != 0) { - printf("can't specify sc for device %s%s\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - if (mp->d_type == CONTROLLER) { - if (dp->d_drive == UNKNOWN) { - printf("must specify drive for %s%s\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - slave = dp->d_drive; - } else { - if (dp->d_slave == UNKNOWN) { - printf("must specify slave for %s%s\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - slave = dp->d_slave; - } - hpib = mp->d_unit; - } - fprintf(fp, "{ &%sdriver,\t", dp->d_name); - if (mp == TO_NEXUS) - fprintf(fp, "D 0x0,\t"); - else - fprintf(fp, "&%sdriver,", mp->d_name); - fprintf(fp, "\t%d,\t%d,\t%d,\tC 0x%x,\t%d,\t0x%x },\n", - dp->d_unit, hpib, slave, - dp->d_addr, dp->d_dk, dp->d_flags); - } - fprintf(fp, "0\n};\n"); - pseudo_ioconf(fp); - (void) fclose(fp); + fp = fopen(path("ioconf.c"), "w"); + if (fp == 0) { + perror(path("ioconf.c")); + exit(1); + } + fprintf(fp, "#include \"sys/param.h\"\n"); + fprintf(fp, "#include \"sys/buf.h\"\n"); + fprintf(fp, "#include \"sys/map.h\"\n"); + fprintf(fp, "\n"); + if (machine == MACHINE_HP300) + fprintf(fp, "#include \"hp/dev/device.h\"\n\n"); + else + fprintf(fp, "#include \"luna68k/dev/device.h\"\n\n"); + fprintf(fp, "\n"); + fprintf(fp, "#define C (caddr_t)\n"); + fprintf(fp, "#define D (struct driver *)\n\n"); + /* + * First print the hpib controller initialization structures + */ + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_unit == QUES || mp == 0) + continue; + fprintf(fp, "extern struct driver %sdriver;\n", dp->d_name); + } + fprintf(fp, "\nstruct hp_ctlr hp_cinit[] = {\n"); + fprintf(fp, "/*\tdriver,\t\tunit,\talive,\taddr,\tflags */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_unit == QUES || + (dp->d_type != MASTER && dp->d_type != CONTROLLER)) + continue; + if (mp != TO_NEXUS) { + printf("%s%s must be attached to an sc (nexus)\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { + printf("can't specify drive/slave for %s%s\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + fprintf(fp, + "\t{ &%sdriver,\t%d,\t0,\tC 0x%x,\t0x%x },\n", + dp->d_name, dp->d_unit, dp->d_addr, dp->d_flags); + } + fprintf(fp, "\t0\n};\n"); + + /* devices */ + fprintf(fp, "\nstruct hp_device hp_dinit[] = {\n"); + fprintf(fp, + "/*driver,\tcdriver,\tunit,\tctlr,\tslave,\taddr,\tdk,\tflags*/\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (mp == 0 || dp->d_type != DEVICE || hpbadslave(mp, dp)) + continue; + if (mp == TO_NEXUS) { + if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { + printf("can't specify drive/slave for %s%s\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + slave = QUES; + hpib = QUES; + } else { + if (dp->d_addr != 0) { + printf("can't specify sc for device %s%s\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + if (mp->d_type == CONTROLLER) { + if (dp->d_drive == UNKNOWN) { + printf("must specify drive for %s%s\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + slave = dp->d_drive; + } else { + if (dp->d_slave == UNKNOWN) { + printf("must specify slave for %s%s\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + slave = dp->d_slave; + } + hpib = mp->d_unit; + } + fprintf(fp, "{ &%sdriver,\t", dp->d_name); + if (mp == TO_NEXUS) + fprintf(fp, "D 0x0,\t"); + else + fprintf(fp, "&%sdriver,", mp->d_name); + fprintf(fp, "\t%d,\t%d,\t%d,\tC 0x%x,\t%d,\t0x%x },\n", + dp->d_unit, hpib, slave, + dp->d_addr, dp->d_dk, dp->d_flags); + } + fprintf(fp, "0\n};\n"); + pseudo_ioconf(fp); + (void) fclose(fp); } #endif @@ -600,285 +603,285 @@ char *sirq(int); void i386_ioconf() { - register struct device *dp, *mp; - FILE *fp; + register struct device *dp, *mp; + FILE *fp; - fp = fopen(path("ioconf.c"), "w"); - if (fp == 0) { - perror(path("ioconf.c")); - exit(1); - } - fprintf(fp, "/*\n"); - fprintf(fp, " * ioconf.c \n"); - fprintf(fp, " * Generated by config program\n"); - fprintf(fp, " */\n\n"); - fprintf(fp, "#include \"machine/pte.h\"\n"); - fprintf(fp, "#include \"sys/param.h\"\n"); - fprintf(fp, "#include \"sys/buf.h\"\n"); - fprintf(fp, "#include \"sys/map.h\"\n"); - fprintf(fp, "\n"); - fprintf(fp, "#define V(s) __CONCAT(V,s)\n"); - fprintf(fp, "#define C (caddr_t)\n\n"); - /* - * First print the isa initialization structures - */ - if (seen_isa) { + fp = fopen(path("ioconf.c"), "w"); + if (fp == 0) { + perror(path("ioconf.c")); + exit(1); + } + fprintf(fp, "/*\n"); + fprintf(fp, " * ioconf.c \n"); + fprintf(fp, " * Generated by config program\n"); + fprintf(fp, " */\n\n"); + fprintf(fp, "#include \"machine/pte.h\"\n"); + fprintf(fp, "#include \"sys/param.h\"\n"); + fprintf(fp, "#include \"sys/buf.h\"\n"); + fprintf(fp, "#include \"sys/map.h\"\n"); + fprintf(fp, "\n"); + fprintf(fp, "#define V(s) __CONCAT(V,s)\n"); + fprintf(fp, "#define C (caddr_t)\n\n"); + /* + * First print the isa initialization structures + */ + if (seen_isa) { - fprintf(fp, "/*\n"); - fprintf(fp, " * ISA devices\n"); - fprintf(fp, " */\n\n"); - fprintf(fp, "#include \"i386/isa/isa_device.h\"\n"); - fprintf(fp, "#include \"i386/isa/isa.h\"\n"); - fprintf(fp, "#include \"i386/isa/icu.h\"\n\n"); + fprintf(fp, "/*\n"); + fprintf(fp, " * ISA devices\n"); + fprintf(fp, " */\n\n"); + fprintf(fp, "#include \"i386/isa/isa_device.h\"\n"); + fprintf(fp, "#include \"i386/isa/isa.h\"\n"); + fprintf(fp, "#include \"i386/isa/icu.h\"\n\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (mp == 0 || mp == TO_NEXUS || - !eq(mp->d_name, "isa")) - continue; - fprintf(fp, -"extern struct isa_driver %sdriver; extern V(%s%d)();\n", - dp->d_name, dp->d_name, dp->d_unit); - } - fprintf(fp, "\nstruct isa_device isa_devtab_bio[] = {\n"); - fprintf(fp, "\ -/* driver iobase irq drq maddr msiz intr unit */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_unit == QUES || mp == 0 || - mp == TO_NEXUS || !eq(mp->d_name, "isa")) - continue; - if (!eq(dp->d_mask, "bio")) continue; - if (dp->d_port) - fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); - else - fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); - fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", - sirq(dp->d_irq), dp->d_drq, dp->d_maddr, - dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); - } - fprintf(fp, "0\n};\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (mp == 0 || mp == TO_NEXUS || + !eq(mp->d_name, "isa")) + continue; + fprintf(fp, + "extern struct isa_driver %sdriver; extern V(%s%d)();\n", + dp->d_name, dp->d_name, dp->d_unit); + } + fprintf(fp, "\nstruct isa_device isa_devtab_bio[] = {\n"); + fprintf(fp, "\ +/* driver iobase irq drq maddr msiz intr unit */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_unit == QUES || mp == 0 || + mp == TO_NEXUS || !eq(mp->d_name, "isa")) + continue; + if (!eq(dp->d_mask, "bio")) continue; + if (dp->d_port) + fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); + else + fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); + fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", + sirq(dp->d_irq), dp->d_drq, dp->d_maddr, + dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); + } + fprintf(fp, "0\n};\n"); - fprintf(fp, "struct isa_device isa_devtab_tty[] = {\n"); - fprintf(fp, "\ -/* driver iobase irq drq maddr msiz intr unit */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_unit == QUES || mp == 0 || - mp == TO_NEXUS || !eq(mp->d_name, "isa")) - continue; - if (!eq(dp->d_mask, "tty")) continue; - if (dp->d_port) - fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); - else - fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); - fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", - sirq(dp->d_irq), dp->d_drq, dp->d_maddr, - dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); - } - fprintf(fp, "0\n};\n\n"); + fprintf(fp, "struct isa_device isa_devtab_tty[] = {\n"); + fprintf(fp, "\ +/* driver iobase irq drq maddr msiz intr unit */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_unit == QUES || mp == 0 || + mp == TO_NEXUS || !eq(mp->d_name, "isa")) + continue; + if (!eq(dp->d_mask, "tty")) continue; + if (dp->d_port) + fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); + else + fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); + fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", + sirq(dp->d_irq), dp->d_drq, dp->d_maddr, + dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); + } + fprintf(fp, "0\n};\n\n"); - fprintf(fp, "struct isa_device isa_devtab_net[] = {\n"); - fprintf(fp, "\ -/* driver iobase irq drq maddr msiz intr unit */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_unit == QUES || mp == 0 || - mp == TO_NEXUS || !eq(mp->d_name, "isa")) - continue; - if (!eq(dp->d_mask, "net")) continue; - if (dp->d_port) - fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); - else - fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); - fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", - sirq(dp->d_irq), dp->d_drq, dp->d_maddr, - dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); - } - fprintf(fp, "0\n};\n\n"); + fprintf(fp, "struct isa_device isa_devtab_net[] = {\n"); + fprintf(fp, "\ +/* driver iobase irq drq maddr msiz intr unit */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_unit == QUES || mp == 0 || + mp == TO_NEXUS || !eq(mp->d_name, "isa")) + continue; + if (!eq(dp->d_mask, "net")) continue; + if (dp->d_port) + fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); + else + fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); + fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", + sirq(dp->d_irq), dp->d_drq, dp->d_maddr, + dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); + } + fprintf(fp, "0\n};\n\n"); - fprintf(fp, "struct isa_device isa_devtab_null[] = {\n"); - fprintf(fp, "\ -/* driver iobase irq drq maddr msiz intr unit */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_unit == QUES || mp == 0 || - mp == TO_NEXUS || !eq(mp->d_name, "isa")) - continue; - if (!eq(dp->d_mask, "null")) continue; - if (dp->d_port) - fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); - else - fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); - fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", - sirq(dp->d_irq), dp->d_drq, dp->d_maddr, - dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); - } - fprintf(fp, "0\n};\n\n"); - } - pseudo_ioconf(fp); - (void) fclose(fp); + fprintf(fp, "struct isa_device isa_devtab_null[] = {\n"); + fprintf(fp, "\ +/* driver iobase irq drq maddr msiz intr unit */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_unit == QUES || mp == 0 || + mp == TO_NEXUS || !eq(mp->d_name, "isa")) + continue; + if (!eq(dp->d_mask, "null")) continue; + if (dp->d_port) + fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); + else + fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); + fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", + sirq(dp->d_irq), dp->d_drq, dp->d_maddr, + dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); + } + fprintf(fp, "0\n};\n\n"); + } + pseudo_ioconf(fp); + (void) fclose(fp); } char * sirq(num) { - if (num == -1) - return ("0"); - sprintf(errbuf, "IRQ%d", num); - return (errbuf); + if (num == -1) + return ("0"); + sprintf(errbuf, "IRQ%d", num); + return (errbuf); } #endif #if MACHINE_PMAX void pmax_ioconf() { - register struct device *dp, *mp; - FILE *fp; + register struct device *dp, *mp; + FILE *fp; - fp = fopen(path("ioconf.c"), "w"); - if (fp == 0) { - perror(path("ioconf.c")); - exit(1); - } - fprintf(fp, "#include \"sys/types.h\"\n"); - fprintf(fp, "#include \"sys/time.h\"\n"); - fprintf(fp, "#include \"mips/dev/device.h\"\n\n"); - fprintf(fp, "#define C (char *)\n\n"); + fp = fopen(path("ioconf.c"), "w"); + if (fp == 0) { + perror(path("ioconf.c")); + exit(1); + } + fprintf(fp, "#include \"sys/types.h\"\n"); + fprintf(fp, "#include \"sys/time.h\"\n"); + fprintf(fp, "#include \"mips/dev/device.h\"\n\n"); + fprintf(fp, "#define C (char *)\n\n"); - /* print controller initialization structures */ - for (dp = dtab; dp != 0; dp = dp->d_next) { - if (dp->d_type == PSEUDO_DEVICE) - continue; - fprintf(fp, "extern struct driver %sdriver;\n", dp->d_name); - } - fprintf(fp, "\nstruct mips_ctlr mips_cinit[] = {\n"); - fprintf(fp, "/*\tdriver,\t\tunit,\taddr,\t\tpri,\tflags */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - if (dp->d_type != CONTROLLER && dp->d_type != MASTER) - continue; - if (dp->d_conn != TO_NEXUS) { - printf("%s%s must be attached to a nexus (internal bus)\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { - printf("can't specify drive/slave for %s%s\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - if (dp->d_unit == UNKNOWN || dp->d_unit == QUES) - dp->d_unit = 0; - fprintf(fp, - "\t{ &%sdriver,\t%d,\tC 0x%x,\t%d,\t0x%x },\n", - dp->d_name, dp->d_unit, dp->d_addr, dp->d_pri, - dp->d_flags); - } - fprintf(fp, "\t0\n};\n"); + /* print controller initialization structures */ + for (dp = dtab; dp != 0; dp = dp->d_next) { + if (dp->d_type == PSEUDO_DEVICE) + continue; + fprintf(fp, "extern struct driver %sdriver;\n", dp->d_name); + } + fprintf(fp, "\nstruct mips_ctlr mips_cinit[] = {\n"); + fprintf(fp, "/*\tdriver,\t\tunit,\taddr,\t\tpri,\tflags */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + if (dp->d_type != CONTROLLER && dp->d_type != MASTER) + continue; + if (dp->d_conn != TO_NEXUS) { + printf("%s%s must be attached to a nexus (internal bus)\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { + printf("can't specify drive/slave for %s%s\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + if (dp->d_unit == UNKNOWN || dp->d_unit == QUES) + dp->d_unit = 0; + fprintf(fp, + "\t{ &%sdriver,\t%d,\tC 0x%x,\t%d,\t0x%x },\n", + dp->d_name, dp->d_unit, dp->d_addr, dp->d_pri, + dp->d_flags); + } + fprintf(fp, "\t0\n};\n"); - /* print devices connected to other controllers */ - fprintf(fp, "\nstruct scsi_device scsi_dinit[] = {\n"); - fprintf(fp, - "/*driver,\tcdriver,\tunit,\tctlr,\tdrive,\tslave,\tdk,\tflags*/\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - if (dp->d_type == CONTROLLER || dp->d_type == MASTER || - dp->d_type == PSEUDO_DEVICE) - continue; - mp = dp->d_conn; - if (mp == 0 || - (!eq(mp->d_name, "asc") && !eq(mp->d_name, "sii"))) { - printf("%s%s: devices must be attached to a SCSI (asc or sii) controller\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - if ((unsigned)dp->d_drive > 6) { - printf("%s%s: SCSI drive must be in the range 0..6\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - /* may want to allow QUES later */ - if ((unsigned)dp->d_slave > 7) { - printf("%s%s: SCSI slave (LUN) must be in the range 0..7\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - fprintf(fp, "{ &%sdriver,\t&%sdriver,", dp->d_name, mp->d_name); - fprintf(fp, "\t%d,\t%d,\t%d,\t%d,\t%d,\t0x%x },\n", - dp->d_unit, mp->d_unit, dp->d_drive, dp->d_slave, - dp->d_dk, dp->d_flags); - } - fprintf(fp, "0\n};\n"); - pseudo_ioconf(fp); - (void) fclose(fp); + /* print devices connected to other controllers */ + fprintf(fp, "\nstruct scsi_device scsi_dinit[] = {\n"); + fprintf(fp, + "/*driver,\tcdriver,\tunit,\tctlr,\tdrive,\tslave,\tdk,\tflags*/\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + if (dp->d_type == CONTROLLER || dp->d_type == MASTER || + dp->d_type == PSEUDO_DEVICE) + continue; + mp = dp->d_conn; + if (mp == 0 || + (!eq(mp->d_name, "asc") && !eq(mp->d_name, "sii"))) { + printf("%s%s: devices must be attached to a SCSI (asc or sii) controller\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + if ((unsigned)dp->d_drive > 6) { + printf("%s%s: SCSI drive must be in the range 0..6\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + /* may want to allow QUES later */ + if ((unsigned)dp->d_slave > 7) { + printf("%s%s: SCSI slave (LUN) must be in the range 0..7\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + fprintf(fp, "{ &%sdriver,\t&%sdriver,", dp->d_name, mp->d_name); + fprintf(fp, "\t%d,\t%d,\t%d,\t%d,\t%d,\t0x%x },\n", + dp->d_unit, mp->d_unit, dp->d_drive, dp->d_slave, + dp->d_dk, dp->d_flags); + } + fprintf(fp, "0\n};\n"); + pseudo_ioconf(fp); + (void) fclose(fp); } #endif #if MACHINE_PIC32 void pic32_ioconf() { - register struct device *dp, *mp; - FILE *fp; + register struct device *dp, *mp; + FILE *fp; - fp = fopen(path("ioconf.c"), "w"); - if (fp == 0) { - perror(path("ioconf.c")); - exit(1); - } - fprintf(fp, "#include \"sys/types.h\"\n"); - fprintf(fp, "#include \"sys/time.h\"\n"); - fprintf(fp, "#include \"mips/dev/device.h\"\n\n"); - fprintf(fp, "#define C (char *)\n\n"); + fp = fopen(path("ioconf.c"), "w"); + if (fp == 0) { + perror(path("ioconf.c")); + exit(1); + } + fprintf(fp, "#include \"sys/types.h\"\n"); + fprintf(fp, "#include \"sys/time.h\"\n"); + fprintf(fp, "#include \"mips/dev/device.h\"\n\n"); + fprintf(fp, "#define C (char *)\n\n"); - /* print controller initialization structures */ - for (dp = dtab; dp != 0; dp = dp->d_next) { - if (dp->d_type == PSEUDO_DEVICE) - continue; - fprintf(fp, "extern struct driver %sdriver;\n", dp->d_name); - } - fprintf(fp, "\nstruct conf_ctlr conf_cinit[] = {\n"); - fprintf(fp, "/*\tdriver,\t\tunit,\taddr,\t\tpri,\tflags */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - if (dp->d_type != CONTROLLER && dp->d_type != MASTER) - continue; - if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { - printf("can't specify drive/slave for %s%s\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - if (dp->d_unit == UNKNOWN || dp->d_unit == QUES) - dp->d_unit = 0; - fprintf(fp, - "\t{ &%sdriver,\t%d,\tC 0x%08x,\t%d,\t0x%x },\n", - dp->d_name, dp->d_unit, dp->d_addr, dp->d_pri, - dp->d_flags); - } - fprintf(fp, "\t{ 0 }\n};\n"); + /* print controller initialization structures */ + for (dp = dtab; dp != 0; dp = dp->d_next) { + if (dp->d_type == PSEUDO_DEVICE) + continue; + fprintf(fp, "extern struct driver %sdriver;\n", dp->d_name); + } + fprintf(fp, "\nstruct conf_ctlr conf_cinit[] = {\n"); + fprintf(fp, "/*\tdriver,\t\tunit,\taddr,\t\tpri,\tflags */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + if (dp->d_type != CONTROLLER && dp->d_type != MASTER) + continue; + if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { + printf("can't specify drive/slave for %s%s\n", + dp->d_name, wnum(dp->d_unit)); + continue; + } + if (dp->d_unit == UNKNOWN || dp->d_unit == QUES) + dp->d_unit = 0; + fprintf(fp, + "\t{ &%sdriver,\t%d,\tC 0x%08x,\t%d,\t0x%x },\n", + dp->d_name, dp->d_unit, dp->d_addr, dp->d_pri, + dp->d_flags); + } + fprintf(fp, "\t{ 0 }\n};\n"); - /* print devices connected to other controllers */ - fprintf(fp, "\nstruct conf_device conf_dinit[] = {\n"); - fprintf(fp, - "/*driver,\tcdriver,\tunit,\tctlr,\tdrive,\tslave,\tdk,\tflags*/\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - if (dp->d_type == CONTROLLER || dp->d_type == MASTER || - dp->d_type == PSEUDO_DEVICE) - continue; + /* print devices connected to other controllers */ + fprintf(fp, "\nstruct conf_device conf_dinit[] = {\n"); + fprintf(fp, + "/*driver,\tcdriver,\tunit,\tctlr,\tdrive,\tslave,\tdk,\tflags*/\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + if (dp->d_type == CONTROLLER || dp->d_type == MASTER || + dp->d_type == PSEUDO_DEVICE) + continue; - mp = dp->d_conn; - fprintf(fp, "{ &%sdriver,\t", dp->d_name); - if (mp) { - fprintf(fp, "&%sdriver,\t%d,\t%d,\t", - mp->d_name, dp->d_unit, mp->d_unit); - } else { - fprintf(fp, "0,\t\t%d,\t0,\t", - dp->d_unit); - } - fprintf(fp, "%d,\t%d,\t%d,\t0x%x },\n", - dp->d_drive, dp->d_slave, dp->d_dk, dp->d_flags); - } - fprintf(fp, "{ 0 }\n};\n"); - pseudo_ioconf(fp); - (void) fclose(fp); + mp = dp->d_conn; + fprintf(fp, "{ &%sdriver,\t", dp->d_name); + if (mp) { + fprintf(fp, "&%sdriver,\t%d,\t%d,\t", + mp->d_name, dp->d_unit, mp->d_unit); + } else { + fprintf(fp, "0,\t\t%d,\t0,\t", + dp->d_unit); + } + fprintf(fp, "%d,\t%d,\t%d,\t0x%x },\n", + dp->d_drive, dp->d_slave, dp->d_dk, dp->d_flags); + } + fprintf(fp, "{ 0 }\n};\n"); + pseudo_ioconf(fp); + (void) fclose(fp); } #endif @@ -889,261 +892,262 @@ int have_vme = 0; void news_ioconf() { - register struct device *dp, *mp; - register int slave; - FILE *fp; + register struct device *dp, *mp; + register int slave; + FILE *fp; - fp = fopen(path("ioconf.c"), "w"); - if (fp == 0) { - perror(path("ioconf.c")); - exit(1); - } - fprintf(fp, "#include \"sys/param.h\"\n"); - fprintf(fp, "#include \"sys/buf.h\"\n"); - fprintf(fp, "#include \"sys/map.h\"\n"); - fprintf(fp, "#include \"vm/vm.h\"\n"); - fprintf(fp, "#include \"iop.h\"\n"); - fprintf(fp, "#include \"hb.h\"\n"); - fprintf(fp, "\n"); - fprintf(fp, "#if NIOP > 0\n"); - fprintf(fp, "#include \"news3400/iop/iopvar.h\"\n"); - fprintf(fp, "#endif\n"); - fprintf(fp, "#if NHB > 0\n"); - fprintf(fp, "#include \"news3400/hbdev/hbvar.h\"\n"); - fprintf(fp, "#endif\n"); - fprintf(fp, "\n"); - fprintf(fp, "#define C (caddr_t)\n\n"); - fprintf(fp, "\n"); + fp = fopen(path("ioconf.c"), "w"); + if (fp == 0) { + perror(path("ioconf.c")); + exit(1); + } + fprintf(fp, "#include \"sys/param.h\"\n"); + fprintf(fp, "#include \"sys/buf.h\"\n"); + fprintf(fp, "#include \"sys/map.h\"\n"); + fprintf(fp, "#include \"vm/vm.h\"\n"); + fprintf(fp, "#include \"iop.h\"\n"); + fprintf(fp, "#include \"hb.h\"\n"); + fprintf(fp, "\n"); + fprintf(fp, "#if NIOP > 0\n"); + fprintf(fp, "#include \"news3400/iop/iopvar.h\"\n"); + fprintf(fp, "#endif\n"); + fprintf(fp, "#if NHB > 0\n"); + fprintf(fp, "#include \"news3400/hbdev/hbvar.h\"\n"); + fprintf(fp, "#endif\n"); + fprintf(fp, "\n"); + fprintf(fp, "#define C (caddr_t)\n\n"); + fprintf(fp, "\n"); -/* BEGIN HB */ - fprintf(fp, "#if NHB > 0\n"); - /* - * Now generate interrupt vectors for the HYPER-BUS - */ - for (dp = dtab; dp != 0; dp = dp->d_next) { - if (dp->d_pri >= 0) { - mp = dp->d_conn; - if (mp == 0 || mp == TO_NEXUS || - !eq(mp->d_name, "hb")) - continue; - fprintf(fp, "extern struct hb_driver %sdriver;\n", - dp->d_name); - have_hb++; - } - } - /* - * Now spew forth the hb_cinfo structure - */ - fprintf(fp, "\nstruct hb_ctlr hminit[] = {\n"); - fprintf(fp, "/*\t driver,\tctlr,\talive,\taddr,\tintpri */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if ((dp->d_type != MASTER && dp->d_type != CONTROLLER) - || mp == TO_NEXUS || mp == 0 || - !eq(mp->d_name, "hb")) - continue; - if (dp->d_pri < 0) { - printf("must specify priority for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { - printf("drives need their own entries; "); - printf("dont specify drive or slave for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_flags) { - printf("controllers (e.g. %s%d) don't have flags, " - "only devices do\n", - dp->d_name, dp->d_unit); - continue; - } - fprintf(fp, "\t{ &%sdriver,\t%d,\t0,\tC 0x%x,\t%d },\n", - dp->d_name, dp->d_unit, dp->d_addr, dp->d_pri); - } - fprintf(fp, "\t0\n};\n"); - /* - * Now we go for the hb_device stuff - */ - fprintf(fp, "\nstruct hb_device hdinit[] = {\n"); - fprintf(fp, -"\t/* driver, unit, ctlr, slave, addr, pri, dk, flags*/\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || - mp == TO_NEXUS || /* mp->d_type == MASTER || */ - eq(mp->d_name, "iop") || eq(mp->d_name, "vme")) - continue; - if (eq(mp->d_name, "hb")) { - if (dp->d_pri < 0) { - printf("must specify vector for device %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { - printf("drives/slaves can be specified only "); - printf("for controllers, not for device %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - slave = QUES; - } else { - if (mp->d_conn == 0) { - printf("%s%d isn't connected to anything, ", - mp->d_name, mp->d_unit); - printf("so %s%d is unattached\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_drive == UNKNOWN) { - printf("must specify ``drive number'' for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - /* NOTE THAT ON THE IOP ``drive'' IS STORED IN */ - /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ - if (dp->d_slave != UNKNOWN) { - printf("slave numbers should be given only "); - printf("for massbus tapes, not for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_pri >= 0) { - printf("interrupt priority should not be "); - printf("given for drive %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_addr != 0) { - printf("csr addresses should be given only"); - printf("on controllers, not on %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - slave = dp->d_drive; - } - fprintf(fp, -"\t{ &%sdriver, %2d, %s, %2d, C 0x%x, %d, %d, 0x%x },\n", - eq(mp->d_name, "hb") ? dp->d_name : mp->d_name, dp->d_unit, - eq(mp->d_name, "hb") ? " -1" : qu(mp->d_unit), - slave, dp->d_addr, dp->d_pri, dp->d_dk, dp->d_flags); - } - fprintf(fp, "\t0\n};\n\n"); - fprintf(fp, "#endif\n\n"); -/* END HB */ - pseudo_ioconf(fp); - (void) fclose(fp); + /* BEGIN HB */ + fprintf(fp, "#if NHB > 0\n"); + /* + * Now generate interrupt vectors for the HYPER-BUS + */ + for (dp = dtab; dp != 0; dp = dp->d_next) { + if (dp->d_pri >= 0) { + mp = dp->d_conn; + if (mp == 0 || mp == TO_NEXUS || + !eq(mp->d_name, "hb")) + continue; + fprintf(fp, "extern struct hb_driver %sdriver;\n", + dp->d_name); + have_hb++; + } + } + /* + * Now spew forth the hb_cinfo structure + */ + fprintf(fp, "\nstruct hb_ctlr hminit[] = {\n"); + fprintf(fp, "/*\t driver,\tctlr,\talive,\taddr,\tintpri */\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if ((dp->d_type != MASTER && dp->d_type != CONTROLLER) + || mp == TO_NEXUS || mp == 0 || + !eq(mp->d_name, "hb")) + continue; + if (dp->d_pri < 0) { + printf("must specify priority for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { + printf("drives need their own entries; "); + printf("dont specify drive or slave for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_flags) { + printf("controllers (e.g. %s%d) don't have flags, " + "only devices do\n", + dp->d_name, dp->d_unit); + continue; + } + fprintf(fp, "\t{ &%sdriver,\t%d,\t0,\tC 0x%x,\t%d },\n", + dp->d_name, dp->d_unit, dp->d_addr, dp->d_pri); + } + fprintf(fp, "\t0\n};\n"); + /* + * Now we go for the hb_device stuff + */ + fprintf(fp, "\nstruct hb_device hdinit[] = {\n"); + fprintf(fp, + "\t/* driver, unit, ctlr, slave, addr, pri, dk, flags*/\n"); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || + mp == TO_NEXUS || /* mp->d_type == MASTER || */ + eq(mp->d_name, "iop") || eq(mp->d_name, "vme")) + continue; + if (eq(mp->d_name, "hb")) { + if (dp->d_pri < 0) { + printf("must specify vector for device %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { + printf("drives/slaves can be specified only "); + printf("for controllers, not for device %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + slave = QUES; + } else { + if (mp->d_conn == 0) { + printf("%s%d isn't connected to anything, ", + mp->d_name, mp->d_unit); + printf("so %s%d is unattached\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_drive == UNKNOWN) { + printf("must specify ``drive number'' for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + /* NOTE THAT ON THE IOP ``drive'' IS STORED IN */ + /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ + if (dp->d_slave != UNKNOWN) { + printf("slave numbers should be given only "); + printf("for massbus tapes, not for %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_pri >= 0) { + printf("interrupt priority should not be "); + printf("given for drive %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + if (dp->d_addr != 0) { + printf("csr addresses should be given only"); + printf("on controllers, not on %s%d\n", + dp->d_name, dp->d_unit); + continue; + } + slave = dp->d_drive; + } + fprintf(fp, + "\t{ &%sdriver, %2d, %s, %2d, C 0x%x, %d, %d, 0x%x },\n", + eq(mp->d_name, "hb") ? dp->d_name : mp->d_name, dp->d_unit, + eq(mp->d_name, "hb") ? " -1" : qu(mp->d_unit), + slave, dp->d_addr, dp->d_pri, dp->d_dk, dp->d_flags); + } + fprintf(fp, "\t0\n};\n\n"); + fprintf(fp, "#endif\n\n"); + /* END HB */ + + pseudo_ioconf(fp); + (void) fclose(fp); } #endif char * intv(dev) - register struct device *dev; + register struct device *dev; { - static char buf[20]; + static char buf[20]; - if (dev->d_vec == 0) - return (" 0"); - (void) sprintf(buf, "%sint%d", dev->d_name, dev->d_unit); - return (buf); + if (dev->d_vec == 0) + return (" 0"); + (void) sprintf(buf, "%sint%d", dev->d_name, dev->d_unit); + return (buf); } char * qu(num) { - if (num == QUES) - return ("'?'"); - if (num == UNKNOWN) - return (" -1"); - (void) sprintf(errbuf, "%3d", num); - return (errbuf); + if (num == QUES) + return ("'?'"); + if (num == UNKNOWN) + return (" -1"); + (void) sprintf(errbuf, "%3d", num); + return (errbuf); } char * wnum(num) { - if (num == QUES || num == UNKNOWN) - return ("?"); - (void) sprintf(errbuf, "%d", num); - return (errbuf); + if (num == QUES || num == UNKNOWN) + return ("?"); + (void) sprintf(errbuf, "%d", num); + return (errbuf); } void comp_config(fp) - FILE *fp; + FILE *fp; { - register struct file_list *fl; - register struct device *dp; + register struct file_list *fl; + register struct device *dp; - fprintf(fp, "\n#include \"dev/cdvar.h\"\n"); - fprintf(fp, "\nstruct cddevice cddevice[] = {\n"); - fprintf(fp, "/*\tunit\tileave\tflags\tdk\tdevs\t\t\t\t*/\n"); + fprintf(fp, "\n#include \"dev/cdvar.h\"\n"); + fprintf(fp, "\nstruct cddevice cddevice[] = {\n"); + fprintf(fp, "/*\tunit\tileave\tflags\tdk\tdevs\t\t\t\t*/\n"); - fl = comp_list; - while (fl) { - if (fl->f_type != COMPDEVICE) { - fl = fl->f_next; - continue; - } - for (dp = dtab; dp != 0; dp = dp->d_next) - if (dp->d_type == DEVICE && - eq(dp->d_name, fl->f_fn) && - dp->d_unit == fl->f_compinfo) - break; - if (dp == 0) - continue; - fprintf(fp, "\t%d,\t%d,\t%d,\t%d,\t{", - dp->d_unit, dp->d_pri < 0 ? 0 : dp->d_pri, - dp->d_flags, 1); - for (fl = fl->f_next; fl->f_type == COMPSPEC; fl = fl->f_next) - fprintf(fp, " 0x%x,", (unsigned) fl->f_compdev); - fprintf(fp, " NODEV },\n"); - } - fprintf(fp, "\t-1,\t0,\t0,\t0,\t{ 0 },\n};\n"); + fl = comp_list; + while (fl) { + if (fl->f_type != COMPDEVICE) { + fl = fl->f_next; + continue; + } + for (dp = dtab; dp != 0; dp = dp->d_next) + if (dp->d_type == DEVICE && + eq(dp->d_name, fl->f_fn) && + dp->d_unit == fl->f_compinfo) + break; + if (dp == 0) + continue; + fprintf(fp, "\t%d,\t%d,\t%d,\t%d,\t{", + dp->d_unit, dp->d_pri < 0 ? 0 : dp->d_pri, + dp->d_flags, 1); + for (fl = fl->f_next; fl->f_type == COMPSPEC; fl = fl->f_next) + fprintf(fp, " 0x%x,", (unsigned) fl->f_compdev); + fprintf(fp, " NODEV },\n"); + } + fprintf(fp, "\t-1,\t0,\t0,\t0,\t{ 0 },\n};\n"); } void pseudo_ioconf(fp) - register FILE *fp; + register FILE *fp; { - register struct device *dp; + register struct device *dp; - (void)fprintf(fp, "\n#include \n\n"); - for (dp = dtab; dp != NULL; dp = dp->d_next) - if (dp->d_type == PSEUDO_DEVICE) - (void)fprintf(fp, "extern void %sattach __P((int));\n", - dp->d_name); - /* - * XXX concatonated disks are pseudo-devices but appear as DEVICEs - * since they don't adhere to normal pseudo-device conventions - * (i.e. one entry with total count in d_slave). - */ - if (seen_cd) - (void)fprintf(fp, "extern void cdattach __P((int));\n"); - /* XXX temporary for HP300, others */ - (void)fprintf(fp, "\n#include /* XXX */\n"); - (void)fprintf(fp, "#define etherattach (void (*)__P((int)))nullop\n"); - (void)fprintf(fp, "#define iteattach (void (*) __P((int)))nullop\n"); - (void)fprintf(fp, "\nstruct pdevinit pdevinit[] = {\n"); - for (dp = dtab; dp != NULL; dp = dp->d_next) - if (dp->d_type == PSEUDO_DEVICE) - (void)fprintf(fp, "\t{ %sattach, %d },\n", dp->d_name, - dp->d_slave > 0 ? dp->d_slave : 1); - /* - * XXX count up cds and put out an entry - */ - if (seen_cd) { - struct file_list *fl; - int cdmax = -1; + (void)fprintf(fp, "\n#include \n\n"); + for (dp = dtab; dp != NULL; dp = dp->d_next) + if (dp->d_type == PSEUDO_DEVICE) + (void)fprintf(fp, "extern void %sattach __P((int));\n", + dp->d_name); + /* + * XXX concatonated disks are pseudo-devices but appear as DEVICEs + * since they don't adhere to normal pseudo-device conventions + * (i.e. one entry with total count in d_slave). + */ + if (seen_cd) + (void)fprintf(fp, "extern void cdattach __P((int));\n"); + /* XXX temporary for HP300, others */ + (void)fprintf(fp, "\n#include /* XXX */\n"); + (void)fprintf(fp, "#define etherattach (void (*)__P((int)))nullop\n"); + (void)fprintf(fp, "#define iteattach (void (*) __P((int)))nullop\n"); + (void)fprintf(fp, "\nstruct pdevinit pdevinit[] = {\n"); + for (dp = dtab; dp != NULL; dp = dp->d_next) + if (dp->d_type == PSEUDO_DEVICE) + (void)fprintf(fp, "\t{ %sattach, %d },\n", dp->d_name, + dp->d_slave > 0 ? dp->d_slave : 1); + /* + * XXX count up cds and put out an entry + */ + if (seen_cd) { + struct file_list *fl; + int cdmax = -1; - for (fl = comp_list; fl != NULL; fl = fl->f_next) - if (fl->f_type == COMPDEVICE && fl->f_compinfo > cdmax) - cdmax = fl->f_compinfo; - (void)fprintf(fp, "\t{ cdattach, %d },\n", cdmax+1); - } - (void)fprintf(fp, "\t{ 0, 0 }\n};\n"); - if (seen_cd) - comp_config(fp); + for (fl = comp_list; fl != NULL; fl = fl->f_next) + if (fl->f_type == COMPDEVICE && fl->f_compinfo > cdmax) + cdmax = fl->f_compinfo; + (void)fprintf(fp, "\t{ cdattach, %d },\n", cdmax+1); + } + (void)fprintf(fp, "\t{ 0, 0 }\n};\n"); + if (seen_cd) + comp_config(fp); } diff --git a/tools/kconfig/mkmakefile.c b/tools/kconfig/mkmakefile.c index dc3f6d4..2f7da3a 100644 --- a/tools/kconfig/mkmakefile.c +++ b/tools/kconfig/mkmakefile.c @@ -1,6 +1,6 @@ /* * Copyright (c) 1993, 19801990 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -12,8 +12,8 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. + * This product includes software developed by the University of + * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -43,21 +43,21 @@ #include "config.h" #define next_word(fp, wd) \ - { register char *word = get_word(fp); \ - if (word == (char *)EOF) \ - return; \ - else \ - wd = word; \ - } + { register char *word = get_word(fp); \ + if (word == (char *)EOF) \ + return; \ + else \ + wd = word; \ + } #define next_quoted_word(fp, wd) \ - { register char *word = get_quoted_word(fp); \ - if (word == (char *)EOF) \ - return; \ - else \ - wd = word; \ - } + { register char *word = get_quoted_word(fp); \ + if (word == (char *)EOF) \ + return; \ + else \ + wd = word; \ + } -static struct file_list *fcur; +static struct file_list *fcur; char *tail(); /* @@ -65,15 +65,15 @@ char *tail(); */ struct file_list * fl_lookup(file) - register char *file; + register char *file; { - register struct file_list *fp; + register struct file_list *fp; - for (fp = ftab ; fp != 0; fp = fp->f_next) { - if (eq(fp->f_fn, file)) - return (fp); - } - return (0); + for (fp = ftab ; fp != 0; fp = fp->f_next) { + if (eq(fp->f_fn, file)) + return (fp); + } + return (0); } /* @@ -81,15 +81,15 @@ fl_lookup(file) */ struct file_list * fltail_lookup(file) - register char *file; + register char *file; { - register struct file_list *fp; + register struct file_list *fp; - for (fp = ftab ; fp != 0; fp = fp->f_next) { - if (eq(tail(fp->f_fn), tail(file))) - return (fp); - } - return (0); + for (fp = ftab ; fp != 0; fp = fp->f_next) { + if (eq(tail(fp->f_fn), tail(file))) + return (fp); + } + return (0); } /* @@ -98,50 +98,50 @@ fltail_lookup(file) struct file_list * new_fent() { - register struct file_list *fp; + register struct file_list *fp; - fp = (struct file_list *) malloc(sizeof *fp); - bzero(fp, sizeof *fp); - if (fcur == 0) - fcur = ftab = fp; - else - fcur->f_next = fp; - fcur = fp; - return (fp); + fp = (struct file_list *) malloc(sizeof *fp); + bzero(fp, sizeof *fp); + if (fcur == 0) + fcur = ftab = fp; + else + fcur->f_next = fp; + fcur = fp; + return (fp); } -static struct users { - int u_default; - int u_min; - int u_max; +static struct users { + int u_default; + int u_min; + int u_max; } users[] = { - { 24, 8, 1024 }, /* MACHINE_VAX */ - { 4, 2, 128 }, /* MACHINE_TAHOE */ - { 8, 2, 64 }, /* MACHINE_HP300 */ - { 8, 2, 64 }, /* MACHINE_I386 */ - { 8, 2, 64 }, /* MACHINE_MIPS */ - { 8, 2, 64 }, /* MACHINE_PMAX */ - { 8, 2, 64 }, /* MACHINE_LUNA68K */ - { 8, 2, 64 }, /* MACHINE_NEWS3400 */ - { 2, 1, 16 }, /* MACHINE_PIC32 */ + { 24, 8, 1024 }, /* MACHINE_VAX */ + { 4, 2, 128 }, /* MACHINE_TAHOE */ + { 8, 2, 64 }, /* MACHINE_HP300 */ + { 8, 2, 64 }, /* MACHINE_I386 */ + { 8, 2, 64 }, /* MACHINE_MIPS */ + { 8, 2, 64 }, /* MACHINE_PMAX */ + { 8, 2, 64 }, /* MACHINE_LUNA68K */ + { 8, 2, 64 }, /* MACHINE_NEWS3400 */ + { 2, 1, 16 }, /* MACHINE_PIC32 */ }; -#define NUSERS (sizeof (users) / sizeof (users[0])) +#define NUSERS (sizeof (users) / sizeof (users[0])) int opteq(cp, dp) - char *cp, *dp; + char *cp, *dp; { - char c, d; + char c, d; - for (; ; cp++, dp++) { - if (*cp != *dp) { - c = isupper(*cp) ? tolower(*cp) : *cp; - d = isupper(*dp) ? tolower(*dp) : *dp; - if (c != d) - return (0); - } - if (*cp == 0) - return (1); - } + for (; ; cp++, dp++) { + if (*cp != *dp) { + c = isupper(*cp) ? tolower(*cp) : *cp; + d = isupper(*dp) ? tolower(*dp) : *dp; + if (c != d) + return (0); + } + if (*cp == 0) + return (1); + } } /* @@ -150,246 +150,246 @@ int opteq(cp, dp) */ void read_files() { - FILE *fp; - register struct file_list *tp, *pf; - register struct device *dp; - struct device *save_dp = 0; - register struct opt *op; - char *wd, *this, *needs, *special; - char fname[32]; - int nreqs, first = 1, configdep, isdup, std, filetype; + FILE *fp; + register struct file_list *tp, *pf; + register struct device *dp; + struct device *save_dp = 0; + register struct opt *op; + char *wd, *this, *needs, *special; + char fname[32]; + int nreqs, first = 1, configdep, isdup, std, filetype; - ftab = 0; - (void) strcpy(fname, "../../conf/files"); + ftab = 0; + (void) strcpy(fname, "../../conf/files"); openit: - fp = fopen(fname, "r"); - if (fp == 0) { - perror(fname); - exit(1); - } + fp = fopen(fname, "r"); + if (fp == 0) { + perror(fname); + exit(1); + } next: - /* - * filename [ standard | optional ] [ config-dependent ] - * [ dev* | profiling-routine ] [ device-driver] - * [ compile-with "compile rule" ] - */ - wd = get_word(fp); - if (wd == (char *)EOF) { - (void) fclose(fp); - if (first == 1) { - (void) sprintf(fname, "files.%s", machinename); - first++; - goto openit; - } - if (first == 2) { - (void) sprintf(fname, "files.%s", raise(ident)); - first++; - fp = fopen(fname, "r"); - if (fp != 0) - goto next; - } - return; - } - if (wd == 0) - goto next; - this = ns(wd); - next_word(fp, wd); - if (wd == 0) { - printf("%s: No type for %s.\n", - fname, this); - exit(1); - } - if ((pf = fl_lookup(this)) && (pf->f_type != INVISIBLE || pf->f_flags)) - isdup = 1; - else - isdup = 0; - tp = 0; - if (first == 3 && (tp = fltail_lookup(this)) != 0) - printf("%s: Local file %s overrides %s.\n", - fname, this, tp->f_fn); - nreqs = 0; - special = 0; - configdep = 0; - needs = 0; - std = 0; - filetype = NORMAL; - if (eq(wd, "standard")) - std = 1; - else if (!eq(wd, "optional")) { - printf("%s: %s must be optional or standard\n", fname, this); - exit(1); - } + /* + * filename [ standard | optional ] [ config-dependent ] + * [ dev* | profiling-routine ] [ device-driver] + * [ compile-with "compile rule" ] + */ + wd = get_word(fp); + if (wd == (char *)EOF) { + (void) fclose(fp); + if (first == 1) { + (void) sprintf(fname, "files.%s", machinename); + first++; + goto openit; + } + if (first == 2) { + (void) sprintf(fname, "files.%s", raise(ident)); + first++; + fp = fopen(fname, "r"); + if (fp != 0) + goto next; + } + return; + } + if (wd == 0) + goto next; + this = ns(wd); + next_word(fp, wd); + if (wd == 0) { + printf("%s: No type for %s.\n", + fname, this); + exit(1); + } + if ((pf = fl_lookup(this)) && (pf->f_type != INVISIBLE || pf->f_flags)) + isdup = 1; + else + isdup = 0; + tp = 0; + if (first == 3 && (tp = fltail_lookup(this)) != 0) + printf("%s: Local file %s overrides %s.\n", + fname, this, tp->f_fn); + nreqs = 0; + special = 0; + configdep = 0; + needs = 0; + std = 0; + filetype = NORMAL; + if (eq(wd, "standard")) + std = 1; + else if (!eq(wd, "optional")) { + printf("%s: %s must be optional or standard\n", fname, this); + exit(1); + } nextparam: - next_word(fp, wd); - if (wd == 0) - goto doneparam; - if (eq(wd, "config-dependent")) { - configdep++; - goto nextparam; - } - if (eq(wd, "compile-with")) { - next_quoted_word(fp, wd); - if (wd == 0) { - printf("%s: missing compile command string.\n", - fname); - exit(1); - } - special = ns(wd); - goto nextparam; - } - nreqs++; - if (eq(wd, "device-driver")) { - filetype = DRIVER; - goto nextparam; - } - if (eq(wd, "profiling-routine")) { - filetype = PROFILING; - goto nextparam; - } - if (needs == 0 && nreqs == 1) - needs = ns(wd); - if (isdup) - goto invis; - for (dp = dtab; dp != 0; save_dp = dp, dp = dp->d_next) - if (eq(dp->d_name, wd)) { - if (std && dp->d_type == PSEUDO_DEVICE && - dp->d_slave <= 0) - dp->d_slave = 1; - goto nextparam; - } - if (std) { - dp = (struct device *) malloc(sizeof *dp); - init_dev(dp); - dp->d_name = ns(wd); - dp->d_type = PSEUDO_DEVICE; - dp->d_slave = 1; - if (save_dp) - save_dp->d_next = dp; - goto nextparam; - } - for (op = opt; op != 0; op = op->op_next) - if (op->op_value == 0 && opteq(op->op_name, wd)) { - if (nreqs == 1) { - free(needs); - needs = 0; - } - goto nextparam; - } + next_word(fp, wd); + if (wd == 0) + goto doneparam; + if (eq(wd, "config-dependent")) { + configdep++; + goto nextparam; + } + if (eq(wd, "compile-with")) { + next_quoted_word(fp, wd); + if (wd == 0) { + printf("%s: missing compile command string.\n", + fname); + exit(1); + } + special = ns(wd); + goto nextparam; + } + nreqs++; + if (eq(wd, "device-driver")) { + filetype = DRIVER; + goto nextparam; + } + if (eq(wd, "profiling-routine")) { + filetype = PROFILING; + goto nextparam; + } + if (needs == 0 && nreqs == 1) + needs = ns(wd); + if (isdup) + goto invis; + for (dp = dtab; dp != 0; save_dp = dp, dp = dp->d_next) + if (eq(dp->d_name, wd)) { + if (std && dp->d_type == PSEUDO_DEVICE && + dp->d_slave <= 0) + dp->d_slave = 1; + goto nextparam; + } + if (std) { + dp = (struct device *) malloc(sizeof *dp); + init_dev(dp); + dp->d_name = ns(wd); + dp->d_type = PSEUDO_DEVICE; + dp->d_slave = 1; + if (save_dp) + save_dp->d_next = dp; + goto nextparam; + } + for (op = opt; op != 0; op = op->op_next) + if (op->op_value == 0 && opteq(op->op_name, wd)) { + if (nreqs == 1) { + free(needs); + needs = 0; + } + goto nextparam; + } invis: - while ((wd = get_word(fp)) != 0) - ; - if (tp == 0) - tp = new_fent(); - tp->f_fn = this; - tp->f_type = INVISIBLE; - tp->f_needs = needs; - tp->f_flags = isdup; - tp->f_special = special; - goto next; + while ((wd = get_word(fp)) != 0) + ; + if (tp == 0) + tp = new_fent(); + tp->f_fn = this; + tp->f_type = INVISIBLE; + tp->f_needs = needs; + tp->f_flags = isdup; + tp->f_special = special; + goto next; doneparam: - if (std == 0 && nreqs == 0) { - printf("%s: what is %s optional on?\n", - fname, this); - exit(1); - } + if (std == 0 && nreqs == 0) { + printf("%s: what is %s optional on?\n", + fname, this); + exit(1); + } - if (wd) { - printf("%s: syntax error describing %s\n", - fname, this); - exit(1); - } - if (filetype == PROFILING && profiling == 0) - goto next; - if (tp == 0) - tp = new_fent(); - tp->f_fn = this; - tp->f_type = filetype; - tp->f_flags = 0; - if (configdep) - tp->f_flags |= CONFIGDEP; - tp->f_needs = needs; - tp->f_special = special; - if (pf && pf->f_type == INVISIBLE) - pf->f_flags = 1; /* mark as duplicate */ - goto next; + if (wd) { + printf("%s: syntax error describing %s\n", + fname, this); + exit(1); + } + if (filetype == PROFILING && profiling == 0) + goto next; + if (tp == 0) + tp = new_fent(); + tp->f_fn = this; + tp->f_type = filetype; + tp->f_flags = 0; + if (configdep) + tp->f_flags |= CONFIGDEP; + tp->f_needs = needs; + tp->f_special = special; + if (pf && pf->f_type == INVISIBLE) + pf->f_flags = 1; /* mark as duplicate */ + goto next; } void do_objs(fp) - FILE *fp; + FILE *fp; { - register struct file_list *tp, *fl; - register int lpos, len; - register char *cp, och, *sp; - char swapname[32]; + register struct file_list *tp, *fl; + register int lpos, len; + register char *cp, och, *sp; + char swapname[32]; - fprintf(fp, "OBJS="); - lpos = 6; - for (tp = ftab; tp != 0; tp = tp->f_next) { - if (tp->f_type == INVISIBLE) - continue; - sp = tail(tp->f_fn); - for (fl = conf_list; fl; fl = fl->f_next) { - if (fl->f_type != SWAPSPEC) - continue; - (void) sprintf(swapname, "swap%s.c", fl->f_fn); - if (eq(sp, swapname)) - goto cont; - } - cp = sp + (len = strlen(sp)) - 1; - och = *cp; - *cp = 'o'; - if (len + lpos > 72) { - lpos = 8; - fprintf(fp, "\\\n\t"); - } - fprintf(fp, "%s ", sp); - lpos += len + 1; - *cp = och; + fprintf(fp, "OBJS="); + lpos = 6; + for (tp = ftab; tp != 0; tp = tp->f_next) { + if (tp->f_type == INVISIBLE) + continue; + sp = tail(tp->f_fn); + for (fl = conf_list; fl; fl = fl->f_next) { + if (fl->f_type != SWAPSPEC) + continue; + (void) sprintf(swapname, "swap%s.c", fl->f_fn); + if (eq(sp, swapname)) + goto cont; + } + cp = sp + (len = strlen(sp)) - 1; + och = *cp; + *cp = 'o'; + if (len + lpos > 72) { + lpos = 8; + fprintf(fp, "\\\n\t"); + } + fprintf(fp, "%s ", sp); + lpos += len + 1; + *cp = och; cont: - ; - } - if (lpos != 8) - putc('\n', fp); + ; + } + if (lpos != 8) + putc('\n', fp); } void do_cfiles(fp) - FILE *fp; + FILE *fp; { - register struct file_list *tp, *fl; - register int lpos, len; - char swapname[32]; + register struct file_list *tp, *fl; + register int lpos, len; + char swapname[32]; - fputs("CFILES=", fp); - lpos = 8; - for (tp = ftab; tp; tp = tp->f_next) - if (tp->f_type != INVISIBLE) { - len = strlen(tp->f_fn); - if (tp->f_fn[len - 1] != 'c') - continue; - if ((len = 3 + len) + lpos > 72) { - lpos = 8; - fputs("\\\n\t", fp); - } - fprintf(fp, "$S/%s ", tp->f_fn); - lpos += len + 1; - } - for (fl = conf_list; fl; fl = fl->f_next) - if (fl->f_type == SYSTEMSPEC) { - (void) sprintf(swapname, "swap%s.c", fl->f_fn); - if ((len = 3 + strlen(swapname)) + lpos > 72) { - lpos = 8; - fputs("\\\n\t", fp); - } - if (eq(fl->f_fn, "generic")) - fprintf(fp, "$A/%s/%s ", - machinename, swapname); - else - fprintf(fp, "%s ", swapname); - lpos += len + 1; - } - if (lpos != 8) - putc('\n', fp); + fputs("CFILES=", fp); + lpos = 8; + for (tp = ftab; tp; tp = tp->f_next) + if (tp->f_type != INVISIBLE) { + len = strlen(tp->f_fn); + if (tp->f_fn[len - 1] != 'c') + continue; + if ((len = 3 + len) + lpos > 72) { + lpos = 8; + fputs("\\\n\t", fp); + } + fprintf(fp, "$S/%s ", tp->f_fn); + lpos += len + 1; + } + for (fl = conf_list; fl; fl = fl->f_next) + if (fl->f_type == SYSTEMSPEC) { + (void) sprintf(swapname, "swap%s.c", fl->f_fn); + if ((len = 3 + strlen(swapname)) + lpos > 72) { + lpos = 8; + fputs("\\\n\t", fp); + } + if (eq(fl->f_fn, "generic")) + fprintf(fp, "$A/%s/%s ", + machinename, swapname); + else + fprintf(fp, "%s ", swapname); + lpos += len + 1; + } + if (lpos != 8) + putc('\n', fp); } /* @@ -400,75 +400,75 @@ void do_cfiles(fp) * (e.g. for the VAX); assembler files are processed by as. */ void do_rules(f) - FILE *f; + FILE *f; { - register char *cp, *np, och; - register struct file_list *ftp; - char *special; + register char *cp, *np, och; + register struct file_list *ftp; + char *special; - for (ftp = ftab; ftp != 0; ftp = ftp->f_next) { - if (ftp->f_type == INVISIBLE) - continue; - cp = (np = ftp->f_fn) + strlen(ftp->f_fn) - 1; - och = *cp; - *cp = '\0'; - if (och == 'o') { - fprintf(f, "%so:\n\t-cp $S/%so .\n\n", tail(np), np); - continue; - } - fprintf(f, "%so: $S/%s%c\n", tail(np), np, och); - special = ftp->f_special; - if (special == 0) { - char *ftype; - static char cmd[128]; + for (ftp = ftab; ftp != 0; ftp = ftp->f_next) { + if (ftp->f_type == INVISIBLE) + continue; + cp = (np = ftp->f_fn) + strlen(ftp->f_fn) - 1; + och = *cp; + *cp = '\0'; + if (och == 'o') { + fprintf(f, "%so:\n\t-cp $S/%so .\n\n", tail(np), np); + continue; + } + fprintf(f, "%so: $S/%s%c\n", tail(np), np, och); + special = ftp->f_special; + if (special == 0) { + char *ftype; + static char cmd[128]; - switch (ftp->f_type) { + switch (ftp->f_type) { - case NORMAL: - ftype = "NORMAL"; - break; + case NORMAL: + ftype = "NORMAL"; + break; - case DRIVER: - ftype = "DRIVER"; - break; + case DRIVER: + ftype = "DRIVER"; + break; - case PROFILING: - if (!profiling) - continue; - ftype = "PROFILE"; - break; + case PROFILING: + if (!profiling) + continue; + ftype = "PROFILE"; + break; - default: - printf("config: don't know rules for %s\n", np); - break; - } - (void)sprintf(cmd, "${%s_%c%s}", ftype, toupper(och), - ftp->f_flags & CONFIGDEP? "_C" : ""); - special = cmd; - } - *cp = och; - fprintf(f, "\t%s\n\n", special); - } + default: + printf("config: don't know rules for %s\n", np); + break; + } + (void)sprintf(cmd, "${%s_%c%s}", ftype, toupper(och), + ftp->f_flags & CONFIGDEP? "_C" : ""); + special = cmd; + } + *cp = och; + fprintf(f, "\t%s\n\n", special); + } } /* * Create the load strings */ void do_load(f) - register FILE *f; + register FILE *f; { - register struct file_list *fl; - register int first; - struct file_list *do_systemspec(); + register struct file_list *fl; + register int first; + struct file_list *do_systemspec(); - for (first = 1, fl = conf_list; fl; first = 0) - fl = fl->f_type == SYSTEMSPEC ? - do_systemspec(f, fl, first) : fl->f_next; - fputs("all:", f); - for (fl = conf_list; fl; fl = fl->f_next) - if (fl->f_type == SYSTEMSPEC) - fprintf(f, " %s.elf", fl->f_needs); - putc('\n', f); + for (first = 1, fl = conf_list; fl; first = 0) + fl = fl->f_type == SYSTEMSPEC ? + do_systemspec(f, fl, first) : fl->f_next; + fputs("all:", f); + for (fl = conf_list; fl; fl = fl->f_next) + if (fl->f_type == SYSTEMSPEC) + fprintf(f, " %s.elf", fl->f_needs); + putc('\n', f); } /* @@ -476,148 +476,148 @@ void do_load(f) */ void makefile() { - FILE *ifp, *ofp; - char line[BUFSIZ]; - struct opt *op; - struct users *up; + FILE *ifp, *ofp; + char line[BUFSIZ]; + struct opt *op; + struct users *up; - read_files(); - strcpy(line, "Makefile."); - (void) strcat(line, machinename); - ifp = fopen(line, "r"); - if (ifp == 0) { - perror(line); - exit(1); - } - ofp = fopen(path("Makefile"), "w"); - if (ofp == 0) { - perror(path("Makefile")); - exit(1); - } - fprintf(ofp, "IDENT=-D%s", raise(ident)); - if (profiling) - fprintf(ofp, " -DGPROF"); - if (cputype == 0) { - printf("cpu type must be specified\n"); - exit(1); - } - { struct cputype *cp; - for (cp = cputype; cp; cp = cp->cpu_next) - fprintf(ofp, " -D%s", cp->cpu_name); - } - for (op = opt; op; op = op->op_next) - if (op->op_value) - fprintf(ofp, " -D%s=\"%s\"", op->op_name, op->op_value); - else - fprintf(ofp, " -D%s", op->op_name); - fprintf(ofp, "\n"); - if (ldscript) - fprintf(ofp, "LDSCRIPT=\"%s\"\n", ldscript); - if (hadtz == 0) - printf("timezone not specified; gmt assumed\n"); - if ((unsigned)machine > NUSERS) { - printf("maxusers config info isn't present, using vax\n"); - up = &users[MACHINE_VAX-1]; - } else - up = &users[machine-1]; - if (maxusers == 0) { - printf("maxusers not specified; %d assumed\n", up->u_default); - maxusers = up->u_default; - } else if (maxusers < up->u_min) { - printf("minimum of %d maxusers assumed\n", up->u_min); - maxusers = up->u_min; - } else if (maxusers > up->u_max) - printf("warning: maxusers > %d (%d)\n", up->u_max, maxusers); - fprintf(ofp, "PARAM=-DTIMEZONE=%d -DDST=%d -DMAXUSERS=%d", - zone, dst, maxusers); - if (hz > 0) - fprintf(ofp, " -DHZ=%d", hz); - fprintf(ofp, "\n"); - for (op = mkopt; op; op = op->op_next) - fprintf(ofp, "%s=%s\n", op->op_name, op->op_value); - if (debugging) - fprintf(ofp, "DEBUG=-g\n"); - if (profiling) - fprintf(ofp, "PROF=-pg\n"); - while (fgets(line, BUFSIZ, ifp) != 0) { - if (*line != '%') { - fprintf(ofp, "%s", line); - continue; - } - if (eq(line, "%OBJS\n")) - do_objs(ofp); - else if (eq(line, "%CFILES\n")) - do_cfiles(ofp); - else if (eq(line, "%RULES\n")) - do_rules(ofp); - else if (eq(line, "%LOAD\n")) - do_load(ofp); - else - fprintf(stderr, - "Unknown %% construct in generic makefile: %s", - line); - } - (void) fclose(ifp); - (void) fclose(ofp); + read_files(); + strcpy(line, "Makefile."); + (void) strcat(line, machinename); + ifp = fopen(line, "r"); + if (ifp == 0) { + perror(line); + exit(1); + } + ofp = fopen(path("Makefile"), "w"); + if (ofp == 0) { + perror(path("Makefile")); + exit(1); + } + fprintf(ofp, "IDENT=-D%s", raise(ident)); + if (profiling) + fprintf(ofp, " -DGPROF"); + if (cputype == 0) { + printf("cpu type must be specified\n"); + exit(1); + } + { struct cputype *cp; + for (cp = cputype; cp; cp = cp->cpu_next) + fprintf(ofp, " -D%s", cp->cpu_name); + } + for (op = opt; op; op = op->op_next) + if (op->op_value) + fprintf(ofp, " -D%s=\"%s\"", op->op_name, op->op_value); + else + fprintf(ofp, " -D%s", op->op_name); + fprintf(ofp, "\n"); + if (ldscript) + fprintf(ofp, "LDSCRIPT=\"%s\"\n", ldscript); + if (hadtz == 0) + printf("timezone not specified; gmt assumed\n"); + if ((unsigned)machine > NUSERS) { + printf("maxusers config info isn't present, using vax\n"); + up = &users[MACHINE_VAX-1]; + } else + up = &users[machine-1]; + if (maxusers == 0) { + printf("maxusers not specified; %d assumed\n", up->u_default); + maxusers = up->u_default; + } else if (maxusers < up->u_min) { + printf("minimum of %d maxusers assumed\n", up->u_min); + maxusers = up->u_min; + } else if (maxusers > up->u_max) + printf("warning: maxusers > %d (%d)\n", up->u_max, maxusers); + fprintf(ofp, "PARAM=-DTIMEZONE=%d -DDST=%d -DMAXUSERS=%d", + zone, dst, maxusers); + if (hz > 0) + fprintf(ofp, " -DHZ=%d", hz); + fprintf(ofp, "\n"); + for (op = mkopt; op; op = op->op_next) + fprintf(ofp, "%s=%s\n", op->op_name, op->op_value); + if (debugging) + fprintf(ofp, "DEBUG=-g\n"); + if (profiling) + fprintf(ofp, "PROF=-pg\n"); + while (fgets(line, BUFSIZ, ifp) != 0) { + if (*line != '%') { + fprintf(ofp, "%s", line); + continue; + } + if (eq(line, "%OBJS\n")) + do_objs(ofp); + else if (eq(line, "%CFILES\n")) + do_cfiles(ofp); + else if (eq(line, "%RULES\n")) + do_rules(ofp); + else if (eq(line, "%LOAD\n")) + do_load(ofp); + else + fprintf(stderr, + "Unknown %% construct in generic makefile: %s", + line); + } + (void) fclose(ifp); + (void) fclose(ofp); } char * tail(fn) - char *fn; + char *fn; { - register char *cp; + register char *cp; - cp = rindex(fn, '/'); - if (cp == 0) - return (fn); - return (cp+1); + cp = rindex(fn, '/'); + if (cp == 0) + return (fn); + return (cp+1); } void do_swapspec(f, name) - FILE *f; - register char *name; + FILE *f; + register char *name; { - if (!eq(name, "generic")) - fprintf(f, "swap%s.o: swap%s.c\n", name, name); - else - fprintf(f, "swapgeneric.o: $A/%s/swapgeneric.c\n", - machinename); - fprintf(f, "\t${NORMAL_C}\n\n"); + if (!eq(name, "generic")) + fprintf(f, "swap%s.o: swap%s.c\n", name, name); + else + fprintf(f, "swapgeneric.o: $A/%s/swapgeneric.c\n", + machinename); + fprintf(f, "\t${NORMAL_C}\n\n"); } struct file_list * do_systemspec(f, fl, first) - FILE *f; - register struct file_list *fl; - int first; + FILE *f; + register struct file_list *fl; + int first; { - fprintf(f, "%s.elf: ${SYSTEM_DEP} swap%s.o", fl->f_needs, fl->f_fn); - // Don't use newvers target. - // A preferred way is to run newvers.sh from SYSTEM_LD_HEAD macro. - //if (first) - // fprintf(f, " newvers"); - fprintf(f, "\n\t${SYSTEM_LD_HEAD}\n"); - fprintf(f, "\t${SYSTEM_LD} swap%s.o\n", fl->f_fn); - fprintf(f, "\t${SYSTEM_LD_TAIL}\n\n"); - do_swapspec(f, fl->f_fn); - for (fl = fl->f_next; fl; fl = fl->f_next) - if (fl->f_type != SWAPSPEC) - break; - return (fl); + fprintf(f, "%s.elf: ${SYSTEM_DEP} swap%s.o", fl->f_needs, fl->f_fn); + // Don't use newvers target. + // A preferred way is to run newvers.sh from SYSTEM_LD_HEAD macro. + //if (first) + // fprintf(f, " newvers"); + fprintf(f, "\n\t${SYSTEM_LD_HEAD}\n"); + fprintf(f, "\t${SYSTEM_LD} swap%s.o\n", fl->f_fn); + fprintf(f, "\t${SYSTEM_LD_TAIL}\n\n"); + do_swapspec(f, fl->f_fn); + for (fl = fl->f_next; fl; fl = fl->f_next) + if (fl->f_type != SWAPSPEC) + break; + return (fl); } char * raise(str) - register char *str; + register char *str; { - register char *cp = str; + register char *cp = str; - while (*str) { - if (islower(*str)) - *str = toupper(*str); - str++; - } - return (cp); + while (*str) { + if (islower(*str)) + *str = toupper(*str); + str++; + } + return (cp); } diff --git a/tools/kconfig/mkswapconf.c b/tools/kconfig/mkswapconf.c index 89bb92d..dd5fa14 100644 --- a/tools/kconfig/mkswapconf.c +++ b/tools/kconfig/mkswapconf.c @@ -1,6 +1,6 @@ /* * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -12,8 +12,8 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. + * This product includes software developed by the University of + * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -42,172 +42,174 @@ void swapconf() { - register struct file_list *fl; - struct file_list *do_swap(); + register struct file_list *fl; + struct file_list *do_swap(); - fl = conf_list; - while (fl) { - if (fl->f_type != SYSTEMSPEC) { - fl = fl->f_next; - continue; - } - fl = do_swap(fl); - } + fl = conf_list; + while (fl) { + if (fl->f_type != SYSTEMSPEC) { + fl = fl->f_next; + continue; + } + fl = do_swap(fl); + } } struct file_list * do_swap(fl) - register struct file_list *fl; + register struct file_list *fl; { - FILE *fp; - char swapname[80]; - register struct file_list *swap; - dev_t dev; + FILE *fp; + char swapname[80]; + register struct file_list *swap; + dev_t dev; - if (eq(fl->f_fn, "generic")) { - fl = fl->f_next; - return (fl->f_next); - } - (void) sprintf(swapname, "swap%s.c", fl->f_fn); - fp = fopen(path(swapname), "w"); - if (fp == 0) { - perror(path(swapname)); - exit(1); - } - fprintf(fp, "#include \"sys/param.h\"\n"); - fprintf(fp, "#include \"sys/conf.h\"\n"); - fprintf(fp, "\n"); - /* - * If there aren't any swap devices - * specified, just return, the error - * has already been noted. - */ - swap = fl->f_next; - if (swap == 0 || swap->f_type != SWAPSPEC) { - (void) unlink(path(swapname)); - fclose(fp); - return (swap); - } - fprintf(fp, "dev_t\trootdev = makedev(%d, %d);\n", - major(fl->f_rootdev), minor(fl->f_rootdev)); - fprintf(fp, "dev_t\tdumpdev = makedev(%d, %d);\n", - major(fl->f_dumpdev), minor(fl->f_dumpdev)); - fprintf(fp, "\n"); - fprintf(fp, "struct\tswdevt swdevt[] = {\n"); - do { - dev = swap->f_swapdev; - fprintf(fp, "\t{ makedev(%d, %d),\t%d,\t%d },\t/* %s */\n", - major(dev), minor(dev), swap->f_swapflag, - swap->f_swapsize, swap->f_fn); - swap = swap->f_next; - } while (swap && swap->f_type == SWAPSPEC); - fprintf(fp, "\t{ NODEV, 0, 0 }\n"); - fprintf(fp, "};\n"); - fclose(fp); - return (swap); + if (eq(fl->f_fn, "generic")) { + fl = fl->f_next; + return (fl->f_next); + } + (void) sprintf(swapname, "swap%s.c", fl->f_fn); + fp = fopen(path(swapname), "w"); + if (fp == 0) { + perror(path(swapname)); + exit(1); + } + fprintf(fp, "#include \"sys/param.h\"\n"); + fprintf(fp, "#include \"sys/conf.h\"\n"); + fprintf(fp, "\n"); + /* + * If there aren't any swap devices + * specified, just return, the error + * has already been noted. + */ + swap = fl->f_next; + if (swap == 0 || swap->f_type != SWAPSPEC) { + (void) unlink(path(swapname)); + fclose(fp); + return (swap); + } + fprintf(fp, "dev_t\trootdev = makedev(%d, %d);\n", + major(fl->f_rootdev), minor(fl->f_rootdev)); + fprintf(fp, "dev_t\tdumpdev = makedev(%d, %d);\n", + major(fl->f_dumpdev), minor(fl->f_dumpdev)); + fprintf(fp, "\n"); + fprintf(fp, "struct\tswdevt swdevt[] = {\n"); + do { + dev = swap->f_swapdev; + fprintf(fp, "\t{ makedev(%d, %d),\t%d,\t%d },\t/* %s */\n", + major(dev), minor(dev), swap->f_swapflag, + swap->f_swapsize, swap->f_fn); + swap = swap->f_next; + } while (swap && swap->f_type == SWAPSPEC); + fprintf(fp, "\t{ NODEV, 0, 0 }\n"); + fprintf(fp, "};\n"); + fclose(fp); + return (swap); } -static int devtablenotread = 1; -static struct devdescription { - char *dev_name; - int dev_major; - struct devdescription *dev_next; +static int devtablenotread = 1; + +static struct devdescription { + char *dev_name; + int dev_major; + struct devdescription *dev_next; } *devtable; void initdevtable() { - char buf[BUFSIZ]; - int maj; - register struct devdescription **dp = &devtable; - FILE *fp; + char buf[BUFSIZ]; + int maj; + register struct devdescription **dp = &devtable; + FILE *fp; - (void) sprintf(buf, "../conf/devices.%s", machinename); - fp = fopen(buf, "r"); - if (fp == NULL) { - fprintf(stderr, "config: can't open %s\n", buf); - exit(1); - } - while (fscanf(fp, "%s\t%d\n", buf, &maj) == 2) { - *dp = (struct devdescription *)malloc(sizeof (**dp)); - (*dp)->dev_name = ns(buf); - (*dp)->dev_major = maj; - dp = &(*dp)->dev_next; - } - *dp = 0; - fclose(fp); - devtablenotread = 0; + (void) sprintf(buf, "../conf/devices.%s", machinename); + fp = fopen(buf, "r"); + if (fp == NULL) { + fprintf(stderr, "config: can't open %s\n", buf); + exit(1); + } + while (fscanf(fp, "%s\t%d\n", buf, &maj) == 2) { + *dp = (struct devdescription *)malloc(sizeof (**dp)); + (*dp)->dev_name = ns(buf); + (*dp)->dev_major = maj; + dp = &(*dp)->dev_next; + } + *dp = 0; + fclose(fp); + devtablenotread = 0; } /* * Given a device name specification figure out: - * major device number - * partition - * device name - * unit number + * major device number + * partition + * device name + * unit number * This is a hack, but the system still thinks in * terms of major/minor instead of string names. */ dev_t nametodev(name, defunit, defpartition) - char *name; - int defunit; - char defpartition; + char *name; + int defunit; + char defpartition; { - char *cp, partition; - int unit; - register struct devdescription *dp; + char *cp, partition; + int unit; + register struct devdescription *dp; - cp = name; - if (cp == 0) { - fprintf(stderr, "config: internal error, nametodev\n"); - exit(1); - } - while (*cp && !isdigit(*cp)) - cp++; - unit = *cp ? atoi(cp) : defunit; - if (unit < 0 || unit > 31) { - fprintf(stderr, -"config: %s: invalid device specification, unit out of range\n", name); - unit = defunit; /* carry on more checking */ - } - if (*cp) { - *cp++ = '\0'; - while (*cp && isdigit(*cp)) - cp++; - } - partition = *cp ? *cp : defpartition; - if (partition < 'a' || partition > 'h') { - fprintf(stderr, -"config: %c: invalid device specification, bad partition\n", *cp); - partition = defpartition; /* carry on */ - } - if (devtablenotread) - initdevtable(); - for (dp = devtable; dp; dp = dp->dev_next) - if (eq(name, dp->dev_name)) - break; - if (dp == 0) { - fprintf(stderr, "config: %s: unknown device\n", name); - return (NODEV); - } - return (makedev(dp->dev_major, (unit << 3) + (partition - 'a'))); + cp = name; + if (cp == 0) { + fprintf(stderr, "config: internal error, nametodev\n"); + exit(1); + } + while (*cp && !isdigit(*cp)) + cp++; + unit = *cp ? atoi(cp) : defunit; + if (unit < 0 || unit > 31) { + fprintf(stderr, + "config: %s: invalid device specification, unit out of range\n", + name); + unit = defunit; /* carry on more checking */ + } + if (*cp) { + *cp++ = '\0'; + while (*cp && isdigit(*cp)) + cp++; + } + partition = *cp ? *cp : defpartition; + if (partition < 'a' || partition > 'h') { + fprintf(stderr, + "config: %c: invalid device specification, bad partition\n", *cp); + partition = defpartition; /* carry on */ + } + if (devtablenotread) + initdevtable(); + for (dp = devtable; dp; dp = dp->dev_next) + if (eq(name, dp->dev_name)) + break; + if (dp == 0) { + fprintf(stderr, "config: %s: unknown device\n", name); + return (NODEV); + } + return (makedev(dp->dev_major, (unit << 3) + (partition - 'a'))); } char * devtoname(dev) - dev_t dev; + dev_t dev; { - char buf[80]; - register struct devdescription *dp; + char buf[80]; + register struct devdescription *dp; - if (devtablenotread) - initdevtable(); - for (dp = devtable; dp; dp = dp->dev_next) - if (major(dev) == dp->dev_major) - break; - if (dp == 0) - dp = devtable; - (void) sprintf(buf, "%s%d%c", dp->dev_name, - minor(dev) >> 3, (minor(dev) & 07) + 'a'); - return (ns(buf)); + if (devtablenotread) + initdevtable(); + for (dp = devtable; dp; dp = dp->dev_next) + if (major(dev) == dp->dev_major) + break; + if (dp == 0) + dp = devtable; + (void) sprintf(buf, "%s%d%c", dp->dev_name, + minor(dev) >> 3, (minor(dev) & 07) + 'a'); + return (ns(buf)); } diff --git a/tools/kconfig/mkubglue.c b/tools/kconfig/mkubglue.c index 51ea8ae..88ffa49 100644 --- a/tools/kconfig/mkubglue.c +++ b/tools/kconfig/mkubglue.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -12,8 +12,8 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. + * This product includes software developed by the University of + * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -40,89 +40,89 @@ ubglue() { - register FILE *fp; - register struct device *dp, *mp; + register FILE *fp; + register struct device *dp, *mp; - fp = fopen(path("ubglue.s"), "w"); - if (fp == 0) { - perror(path("ubglue.s")); - exit(1); - } - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (mp != 0 && mp != (struct device *)-1 && - !eq(mp->d_name, "mba")) { - struct idlst *id, *id2; + fp = fopen(path("ubglue.s"), "w"); + if (fp == 0) { + perror(path("ubglue.s")); + exit(1); + } + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (mp != 0 && mp != (struct device *)-1 && + !eq(mp->d_name, "mba")) { + struct idlst *id, *id2; - for (id = dp->d_vec; id; id = id->id_next) { - for (id2 = dp->d_vec; id2; id2 = id2->id_next) { - if (id2 == id) { - dump_vec(fp, id->id, dp->d_unit); - break; - } - if (!strcmp(id->id, id2->id)) - break; - } - } - } - } - dump_std(fp); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (mp != 0 && mp != (struct device *)-1 && - !eq(mp->d_name, "mba")) { - struct idlst *id, *id2; + for (id = dp->d_vec; id; id = id->id_next) { + for (id2 = dp->d_vec; id2; id2 = id2->id_next) { + if (id2 == id) { + dump_vec(fp, id->id, dp->d_unit); + break; + } + if (!strcmp(id->id, id2->id)) + break; + } + } + } + } + dump_std(fp); + for (dp = dtab; dp != 0; dp = dp->d_next) { + mp = dp->d_conn; + if (mp != 0 && mp != (struct device *)-1 && + !eq(mp->d_name, "mba")) { + struct idlst *id, *id2; - for (id = dp->d_vec; id; id = id->id_next) { - for (id2 = dp->d_vec; id2; id2 = id2->id_next) { - if (id2 == id) { - dump_intname(fp, id->id, - dp->d_unit); - break; - } - if (!strcmp(id->id, id2->id)) - break; - } - } - } - } - dump_ctrs(fp); - (void) fclose(fp); + for (id = dp->d_vec; id; id = id->id_next) { + for (id2 = dp->d_vec; id2; id2 = id2->id_next) { + if (id2 == id) { + dump_intname(fp, id->id, + dp->d_unit); + break; + } + if (!strcmp(id->id, id2->id)) + break; + } + } + } + } + dump_ctrs(fp); + (void) fclose(fp); } -static int cntcnt = 0; /* number of interrupt counters allocated */ +static int cntcnt = 0; /* number of interrupt counters allocated */ /* * print an interrupt vector */ dump_vec(fp, vector, number) - register FILE *fp; - char *vector; - int number; + register FILE *fp; + char *vector; + int number; { - char nbuf[80]; - register char *v = nbuf; + char nbuf[80]; + register char *v = nbuf; - (void) sprintf(v, "%s%d", vector, number); - fprintf(fp, "\t.globl\t_X%s\n\t.align\t2\n_X%s:\n\tpushr\t$0x3f\n", - v, v); - fprintf(fp, "\tincl\t_fltintrcnt+(4*%d)\n", cntcnt++); - if (strncmp(vector, "dzx", 3) == 0) - fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdzdma\n\n", number); - else if (strncmp(vector, "dpx", 3) == 0) - fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdpxdma\n\n", number); - else if (strncmp(vector, "dpr", 3) == 0) - fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdprdma\n\n", number); - else { - if (strncmp(vector, "uur", 3) == 0) { - fprintf(fp, "#ifdef UUDMA\n"); - fprintf(fp, "\tmovl\t$%d,r0\n\tjsb\tuudma\n", number); - fprintf(fp, "#endif\n"); - } - fprintf(fp, "\tpushl\t$%d\n", number); - fprintf(fp, "\tcalls\t$1,_%s\n\tpopr\t$0x3f\n", vector); - fprintf(fp, "\tincl\t_cnt+V_INTR\n\trei\n\n"); - } + (void) sprintf(v, "%s%d", vector, number); + fprintf(fp, "\t.globl\t_X%s\n\t.align\t2\n_X%s:\n\tpushr\t$0x3f\n", + v, v); + fprintf(fp, "\tincl\t_fltintrcnt+(4*%d)\n", cntcnt++); + if (strncmp(vector, "dzx", 3) == 0) + fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdzdma\n\n", number); + else if (strncmp(vector, "dpx", 3) == 0) + fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdpxdma\n\n", number); + else if (strncmp(vector, "dpr", 3) == 0) + fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdprdma\n\n", number); + else { + if (strncmp(vector, "uur", 3) == 0) { + fprintf(fp, "#ifdef UUDMA\n"); + fprintf(fp, "\tmovl\t$%d,r0\n\tjsb\tuudma\n", number); + fprintf(fp, "#endif\n"); + } + fprintf(fp, "\tpushl\t$%d\n", number); + fprintf(fp, "\tcalls\t$1,_%s\n\tpopr\t$0x3f\n", vector); + fprintf(fp, "\tincl\t_cnt+V_INTR\n\trei\n\n"); + } } /* @@ -132,61 +132,61 @@ dump_vec(fp, vector, number) * with the definitions in scb.s. */ dump_std(fp) - register FILE *fp; + register FILE *fp; { - fprintf(fp, "\n\t.globl\t_intrnames\n"); - fprintf(fp, "\n\t.globl\t_eintrnames\n"); - fprintf(fp, "\t.data\n"); - fprintf(fp, "_intrnames:\n"); - fprintf(fp, "\t.asciz\t\"clock\"\n"); - fprintf(fp, "\t.asciz\t\"cnr\"\n"); - fprintf(fp, "\t.asciz\t\"cnx\"\n"); - fprintf(fp, "\t.asciz\t\"tur\"\n"); - fprintf(fp, "\t.asciz\t\"tux\"\n"); - fprintf(fp, "\t.asciz\t\"mba0\"\n"); - fprintf(fp, "\t.asciz\t\"mba1\"\n"); - fprintf(fp, "\t.asciz\t\"mba2\"\n"); - fprintf(fp, "\t.asciz\t\"mba3\"\n"); - fprintf(fp, "\t.asciz\t\"uba0\"\n"); - fprintf(fp, "\t.asciz\t\"uba1\"\n"); - fprintf(fp, "\t.asciz\t\"uba2\"\n"); - fprintf(fp, "\t.asciz\t\"uba3\"\n"); -#define I_FIXED 13 /* number of names above */ + fprintf(fp, "\n\t.globl\t_intrnames\n"); + fprintf(fp, "\n\t.globl\t_eintrnames\n"); + fprintf(fp, "\t.data\n"); + fprintf(fp, "_intrnames:\n"); + fprintf(fp, "\t.asciz\t\"clock\"\n"); + fprintf(fp, "\t.asciz\t\"cnr\"\n"); + fprintf(fp, "\t.asciz\t\"cnx\"\n"); + fprintf(fp, "\t.asciz\t\"tur\"\n"); + fprintf(fp, "\t.asciz\t\"tux\"\n"); + fprintf(fp, "\t.asciz\t\"mba0\"\n"); + fprintf(fp, "\t.asciz\t\"mba1\"\n"); + fprintf(fp, "\t.asciz\t\"mba2\"\n"); + fprintf(fp, "\t.asciz\t\"mba3\"\n"); + fprintf(fp, "\t.asciz\t\"uba0\"\n"); + fprintf(fp, "\t.asciz\t\"uba1\"\n"); + fprintf(fp, "\t.asciz\t\"uba2\"\n"); + fprintf(fp, "\t.asciz\t\"uba3\"\n"); +#define I_FIXED 13 /* number of names above */ } dump_intname(fp, vector, number) - register FILE *fp; - char *vector; - int number; + register FILE *fp; + char *vector; + int number; { - register char *cp = vector; + register char *cp = vector; - fprintf(fp, "\t.asciz\t\""); - /* - * Skip any "int" or "intr" in the name. - */ - while (*cp) - if (cp[0] == 'i' && cp[1] == 'n' && cp[2] == 't') { - cp += 3; - if (*cp == 'r') - cp++; - } else { - putc(*cp, fp); - cp++; - } - fprintf(fp, "%d\"\n", number); + fprintf(fp, "\t.asciz\t\""); + /* + * Skip any "int" or "intr" in the name. + */ + while (*cp) + if (cp[0] == 'i' && cp[1] == 'n' && cp[2] == 't') { + cp += 3; + if (*cp == 'r') + cp++; + } else { + putc(*cp, fp); + cp++; + } + fprintf(fp, "%d\"\n", number); } dump_ctrs(fp) - register FILE *fp; + register FILE *fp; { - fprintf(fp, "_eintrnames:\n"); - fprintf(fp, "\n\t.globl\t_intrcnt\n"); - fprintf(fp, "\n\t.globl\t_eintrcnt\n"); - fprintf(fp, "_intrcnt:\n", I_FIXED); - fprintf(fp, "\t.space\t4 * %d\n", I_FIXED); - fprintf(fp, "_fltintrcnt:\n", cntcnt); - fprintf(fp, "\t.space\t4 * %d\n", cntcnt); - fprintf(fp, "_eintrcnt:\n\n"); - fprintf(fp, "\t.text\n"); + fprintf(fp, "_eintrnames:\n"); + fprintf(fp, "\n\t.globl\t_intrcnt\n"); + fprintf(fp, "\n\t.globl\t_eintrcnt\n"); + fprintf(fp, "_intrcnt:\n", I_FIXED); + fprintf(fp, "\t.space\t4 * %d\n", I_FIXED); + fprintf(fp, "_fltintrcnt:\n", cntcnt); + fprintf(fp, "\t.space\t4 * %d\n", cntcnt); + fprintf(fp, "_eintrcnt:\n\n"); + fprintf(fp, "\t.text\n"); } From 31caa114fe18624e0ace23023b010236609ed892 Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Mon, 1 Jun 2015 18:33:49 -0700 Subject: [PATCH 4/8] Kconfig: all outdated stuff removed. --- tools/kconfig/Makefile | 2 +- tools/kconfig/config.8 | 50 +- tools/kconfig/config.h | 36 +- tools/kconfig/config.y | 120 +--- tools/kconfig/lang.l | 25 - tools/kconfig/main.c | 33 +- tools/kconfig/mkglue.c | 402 ------------- tools/kconfig/mkheaders.c | 3 +- tools/kconfig/mkioconf.c | 1103 +++--------------------------------- tools/kconfig/mkmakefile.c | 15 +- tools/kconfig/mkubglue.c | 192 ------- 11 files changed, 103 insertions(+), 1878 deletions(-) delete mode 100644 tools/kconfig/mkglue.c delete mode 100644 tools/kconfig/mkubglue.c diff --git a/tools/kconfig/Makefile b/tools/kconfig/Makefile index 96fe255..106e16f 100644 --- a/tools/kconfig/Makefile +++ b/tools/kconfig/Makefile @@ -2,7 +2,7 @@ CC = gcc -g CFLAGS = -O -Wall YACC = byacc -d DESTDIR = /usr/local -OBJS = config.o main.o lang.o mkioconf.o mkmakefile.o mkglue.o mkheaders.o \ +OBJS = config.o main.o lang.o mkioconf.o mkmakefile.o mkheaders.o \ mkswapconf.o PROG = kconfig diff --git a/tools/kconfig/config.8 b/tools/kconfig/config.8 index aef26a2..3a2794c 100644 --- a/tools/kconfig/config.8 +++ b/tools/kconfig/config.8 @@ -35,34 +35,22 @@ .Dt CONFIG 8 .Os BSD 4 .Sh NAME -.Nm config +.Nm kconfig .Nd build system configuration files .Sh SYNOPSIS -.Nm config +.Nm kconfig .Op Fl p .Ar system_name .Sh DESCRIPTION .Pp -This is the old version of the -.Nm config -program. -It understands the old autoconfiguration scheme -used on the HP300, DECstation, and derivative platforms. -The new version of config is used with the -SPARC and i386 platforms. -Only the version of -.Nm config -applicable to the architecture that you are running -will be installed on your machine. -.Pp -.Nm Config +.Nm Kconfig builds a set of system configuration files from the file .Ar SYSTEM_NAME which describes the system to configure. A second file tells -.Nm config +.Nm kconfig what files are needed to generate a system and can be augmented by configuration specific set of files that give alternate files for a specific machine. @@ -76,8 +64,8 @@ Available option and operand: .It Fl p If the .Fl p -option is supplied, -.Nm config +option is supplied, +.Nm kconfig will configure a system for profiling; for example, .Xr kgmon 8 and @@ -96,19 +84,15 @@ subdirectory of the system source (usually .Nm Config assumes the directory .Pa ../SYSTEM_NAME -exists and places all output files there. +exists and places all output files there. The output of -.Nm config +.Nm kconfig consists of a number of files; for the .Tn VAX , they are: .Pa ioconf.c , a description of what I/O devices are attached to the system; -.Pa ubglue.s , -a set of interrupt service routines for devices -attached to the -.Tn UNIBUS ; .Pa ubvec.s , offsets into a structure used for counting per-device interrupts; .Pa Makefile , @@ -124,7 +108,7 @@ the disk areas to be used for swapping, the root file system, argument processing, and system dumps. .Pp After running -.Nm config , +.Nm kconfig , it is necessary to run .Dq Li make depend in the directory where the new makefile @@ -133,24 +117,24 @@ was created. prints a reminder of this when it completes. .Pp If any other error messages are produced by -.Nm config , +.Nm kconfig , the problems in the configuration file should be corrected and -.Nm config +.Nm kconfig should be run again. Attempts to compile a system that had configuration errors are likely to fail. .Sh FILES -.Bl -tag -width /sys/conf/Makefile.vax -compact -.It Pa /sys/conf/Makefile.vax +.Bl -tag -width /sys/conf/Makefile.pic32 -compact +.It Pa /sys/conf/Makefile.pic32 generic makefile for the .Tn VAX .It Pa /sys/conf/files list of common files system is built from -.It Pa /sys/conf/files.vax +.It Pa /sys/conf/files.pic32 list of .Tn VAX specific files -.It Pa /sys/conf/devices.vax +.It Pa /sys/conf/devices.pic32 name to major device mapping file for the .Tn VAX .It Pa /sys/conf/files. Ns Em ERNIE @@ -161,10 +145,8 @@ system .Sh SEE ALSO The SYNOPSIS portion of each device in section 4. .Rs -.%T "Building 4.3 BSD UNIX System with Config" +.%T "Building RetroBSD Kernel with kconfig" .Re -.sp -.Xr config.new 8 .Sh BUGS The line numbers reported in error messages are usually off by one. .Sh HISTORY diff --git a/tools/kconfig/config.h b/tools/kconfig/config.h index 9bf8ea2..dca3f9c 100644 --- a/tools/kconfig/config.h +++ b/tools/kconfig/config.h @@ -123,8 +123,6 @@ struct device { int d_irq; /* interrupt request */ struct device *d_next; /* Next one in list */ }; -#define TO_NEXUS (struct device *)-1 -#define TO_VBA (struct device *)-2 struct config { char *c_dev; @@ -133,22 +131,11 @@ struct config { /* * Config has a global notion of which machine type is - * being used. It uses the name of the machine in choosing - * files and directories. Thus if the name of the machine is ``vax'', - * it will build from ``Makefile.vax'' and use ``../vax/inline'' - * in the makerules, etc. + * being used. */ int machine; char *machinename; -#define MACHINE_VAX 1 -#define MACHINE_TAHOE 2 -#define MACHINE_HP300 3 -#define MACHINE_I386 4 -#define MACHINE_MIPS 5 -#define MACHINE_PMAX 6 -#define MACHINE_LUNA68K 7 -#define MACHINE_NEWS3400 8 -#define MACHINE_PIC32 9 +#define MACHINE_PIC32 1 /* * For each machine, a set of CPU's may be specified as supported. @@ -182,15 +169,6 @@ char *raise(); int do_trace; -#if MACHINE_VAX -int seen_mba, seen_uba; -#endif -#if MACHINE_TAHOE -int seen_vba; -#endif -#if MACHINE_I386 -int seen_isa; -#endif int seen_cd; struct device *connect(); @@ -215,17 +193,7 @@ int maxusers; void init_dev(register struct device *dp); int yyparse(void); -void vax_ioconf(void); -void tahoe_ioconf(void); -void hp300_ioconf(void); -void i386_ioconf(void); -void pmax_ioconf(void); void pic32_ioconf(void); -void news_ioconf(void); -void ubglue(void); -void vbglue(void); -void hpglue(void); -void vector(void); void makefile(void); void headers(void); void swapconf(void); diff --git a/tools/kconfig/config.y b/tools/kconfig/config.y index 8382695..c7bb148 100644 --- a/tools/kconfig/config.y +++ b/tools/kconfig/config.y @@ -7,9 +7,7 @@ %token AND %token ANY -%token ARGS %token AT -%token BIO %token COMMA %token CONFIG %token CONTROLLER @@ -18,7 +16,6 @@ %token DEVICE %token DISK %token DRIVE -%token DRQ %token DST %token DUMPS %token EQUALS @@ -26,9 +23,6 @@ %token HZ %token IDENT %token INTERLEAVE -%token IOMEM -%token IOSIZ -%token IRQ %token LDSCRIPT %token MACHINE %token MAJOR @@ -36,12 +30,9 @@ %token MAXUSERS %token MINOR %token MINUS -%token NET -%token NEXUS %token ON %token OPTIONS %token MAKEOPTIONS -%token PORT %token PRIORITY %token PSEUDO_DEVICE %token ROOT @@ -51,7 +42,6 @@ %token SLAVE %token SWAP %token TIMEZONE -%token TTY %token TRACE %token VECTOR @@ -154,33 +144,9 @@ Spec: Config_spec: MACHINE Save_id = { - if (!strcmp($2, "vax")) { - machine = MACHINE_VAX; - machinename = "vax"; - } else if (!strcmp($2, "tahoe")) { - machine = MACHINE_TAHOE; - machinename = "tahoe"; - } else if (!strcmp($2, "hp300")) { - machine = MACHINE_HP300; - machinename = "hp300"; - } else if (!strcmp($2, "i386")) { - machine = MACHINE_I386; - machinename = "i386"; - } else if (!strcmp($2, "mips")) { - machine = MACHINE_MIPS; - machinename = "mips"; - } else if (!strcmp($2, "pmax")) { - machine = MACHINE_PMAX; - machinename = "pmax"; - } else if (!strcmp($2, "pic32")) { + if (strcmp($2, "pic32") == 0) { machine = MACHINE_PIC32; machinename = "pic32"; - } else if (!strcmp($2, "luna68k")) { - machine = MACHINE_LUNA68K; - machinename = "luna68k"; - } else if (!strcmp($2, "news3400")) { - machine = MACHINE_NEWS3400; - machinename = "news3400"; } else yyerror("Unknown machine type"); } @@ -272,12 +238,10 @@ System_parameter: root_spec | dump_spec - | - arg_spec ; swap_spec: - SWAP optional_on swap_device_list + SWAP optional_on swap_device_list ; swap_device_list: @@ -353,11 +317,6 @@ dump_device_spec: major_minor ; -arg_spec: - ARGS optional_on arg_device_spec - = { yyerror("arg device specification obsolete, ignored"); } - ; - arg_device_spec: device_name = { $$ = nametodev($1, 0, 'b'); } @@ -576,14 +535,6 @@ Dev_name: Init_dev Dev NUMBER = { cur.d_name = $2; - if (eq($2, "mba")) - seen_mba = 1; - else if (eq($2, "uba")) - seen_uba = 1; - else if (eq($2, "vba")) - seen_vba = 1; - else if (eq($2, "isa")) - seen_isa = 1; cur.d_unit = $3; } ; @@ -611,9 +562,6 @@ Con_info: } cur.d_conn = connect($2, $3); } - | - AT NEXUS NUMBER - = { check_nexus(&cur, $3); cur.d_conn = TO_NEXUS; } ; Info_list: @@ -631,40 +579,13 @@ Info: | SLAVE NUMBER = { - if (cur.d_conn != 0 && cur.d_conn != TO_NEXUS && + if (cur.d_conn != 0 && cur.d_conn->d_type == MASTER) cur.d_slave = $2; else yyerror("can't specify slave--not to master"); } | - IRQ NUMBER - = { cur.d_irq = $2; } - | - DRQ NUMBER - = { cur.d_drq = $2; } - | - IOMEM NUMBER - = { cur.d_maddr = $2; } - | - IOSIZ NUMBER - = { cur.d_msize = $2; } - | - PORT device_name - = { cur.d_port = ns($2); } - | - PORT NUMBER - = { cur.d_portn = $2; } - | - TTY - = { cur.d_mask = "tty"; } - | - BIO - = { cur.d_mask = "bio"; } - | - NET - = { cur.d_mask = "net"; } - | FLAGS NUMBER = { cur.d_flags = $2; } ; @@ -927,12 +848,12 @@ huhcon(dev) * Connect it to the same thing that other similar things are * connected to, but make sure it is a wildcard unit * (e.g. up connected to sc ?, here we make connect sc? to a - * uba?). If other things like this are on the NEXUS or - * if they aren't connected to anything, then make the same + * uba?). If other things like this + * aren't connected to anything, then make the same * connection, else call ourself to connect to another * unspecific device. */ - if (dcp == TO_NEXUS || dcp == 0) + if (dcp == 0) dp->d_conn = dcp; else dp->d_conn = connect(dcp->d_name, QUES); @@ -968,34 +889,7 @@ void check_nexus(dev, num) { switch (machine) { - case MACHINE_VAX: - if (!eq(dev->d_name, "uba") && !eq(dev->d_name, "mba") && - !eq(dev->d_name, "bi")) - yyerror("only uba's, mba's, and bi's should be connected to the nexus"); - if (num != QUES) - yyerror("can't give specific nexus numbers"); - break; - - case MACHINE_TAHOE: - if (!eq(dev->d_name, "vba")) - yyerror("only vba's should be connected to the nexus"); - break; - - case MACHINE_HP300: - case MACHINE_LUNA68K: - if (num != QUES) - dev->d_addr = num; - break; - - case MACHINE_I386: - if (!eq(dev->d_name, "isa")) - yyerror("only isa's should be connected to the nexus"); - break; - - case MACHINE_NEWS3400: - if (!eq(dev->d_name, "iop") && !eq(dev->d_name, "hb") && - !eq(dev->d_name, "vme")) - yyerror("only iop's, hb's and vme's should be connected to the nexus"); + case MACHINE_PIC32: break; } } diff --git a/tools/kconfig/lang.l b/tools/kconfig/lang.l index 51f3322..be4276e 100644 --- a/tools/kconfig/lang.l +++ b/tools/kconfig/lang.l @@ -52,11 +52,7 @@ struct kt { int kt_val; } key_words[] = { { "and", AND }, - { "args", ARGS }, { "at", AT }, -#if MACHINE_I386 - { "bio", BIO }, -#endif { "config", CONFIG }, { "controller", CONTROLLER }, { "cpu", CPU }, @@ -64,20 +60,12 @@ struct kt { { "device", DEVICE }, { "disk", DISK }, { "drive", DRIVE }, -#if MACHINE_I386 - { "drq", DRQ }, -#endif { "dst", DST }, { "dumps", DUMPS }, { "flags", FLAGS }, { "hz", HZ }, { "ident", IDENT }, { "interleave", INTERLEAVE }, -#if MACHINE_I386 - { "iomem", IOMEM }, - { "iosiz", IOSIZ }, - { "irq", IRQ }, -#endif { "ldscript", LDSCRIPT }, { "machine", MACHINE }, { "major", MAJOR }, @@ -85,29 +73,16 @@ struct kt { { "master", MASTER }, { "maxusers", MAXUSERS }, { "minor", MINOR }, -#if MACHINE_I386 - { "net", NET }, -#endif - { "nexus", NEXUS }, { "on", ON }, { "options", OPTIONS }, -#if MACHINE_I386 - { "port", PORT }, -#endif { "priority", PRIORITY }, { "pseudo-device", PSEUDO_DEVICE }, { "root", ROOT }, -#if MACHINE_HP300 || MACHINE_LUNA68K - { "scode", NEXUS }, -#endif { "sequential", SEQUENTIAL }, { "size", SIZE }, { "slave", SLAVE }, { "swap", SWAP }, { "tape", DEVICE }, -#if MACHINE_I386 - { "tty", TTY }, -#endif { "timezone", TIMEZONE }, { "trace", TRACE }, { "vector", VECTOR }, diff --git a/tools/kconfig/main.c b/tools/kconfig/main.c index 99e83fc..065d755 100644 --- a/tools/kconfig/main.c +++ b/tools/kconfig/main.c @@ -97,44 +97,15 @@ usage: fputs("usage: config [-gp] sysname\n", stderr); compp = &comp_list; if (yyparse()) exit(3); + switch (machine) { - case MACHINE_VAX: - vax_ioconf(); /* Print ioconf.c */ - ubglue(); /* Create ubglue.s */ - break; - - case MACHINE_TAHOE: - tahoe_ioconf(); - vbglue(); - break; - - case MACHINE_HP300: - case MACHINE_LUNA68K: - hp300_ioconf(); - hpglue(); - break; - - case MACHINE_I386: - i386_ioconf(); /* Print ioconf.c */ - vector(); /* Create vector.s */ - break; - - case MACHINE_MIPS: - case MACHINE_PMAX: - pmax_ioconf(); - break; - case MACHINE_PIC32: pic32_ioconf(); break; - case MACHINE_NEWS3400: - news_ioconf(); - break; - default: - printf("Specify machine type, e.g. ``machine vax''\n"); + printf("Specify machine type, e.g. ``machine pic32''\n"); exit(1); } makefile(); /* build Makefile */ diff --git a/tools/kconfig/mkglue.c b/tools/kconfig/mkglue.c deleted file mode 100644 index 7b1f308..0000000 --- a/tools/kconfig/mkglue.c +++ /dev/null @@ -1,402 +0,0 @@ -/* - * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Make the bus adaptor interrupt glue files. - */ -#include -#include "config.h" -#include "y.tab.h" -#include - -static int cntcnt = 0; /* number of interrupt counters allocated */ - -/* - * Print a UNIBUS interrupt vector. - */ -void dump_ubavec(fp, vector, number) - register FILE *fp; - char *vector; - int number; -{ - char nbuf[80]; - register char *v = nbuf; - - (void) sprintf(v, "%s%d", vector, number); - fprintf(fp, "\t.globl\t_X%s\n\t.align\t2\n_X%s:\n\tpushr\t$0x3f\n", - v, v); - fprintf(fp, "\tincl\t_fltintrcnt+(4*%d)\n", cntcnt++); - if (strncmp(vector, "dzx", 3) == 0) - fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdzdma\n\n", number); - else if (strncmp(vector, "dpx", 3) == 0) - fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdpxdma\n\n", number); - else if (strncmp(vector, "dpr", 3) == 0) - fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdprdma\n\n", number); - else { - if (strncmp(vector, "uur", 3) == 0) { - fprintf(fp, "#ifdef UUDMA\n"); - fprintf(fp, "\tmovl\t$%d,r0\n\tjsb\tuudma\n", number); - fprintf(fp, "#endif\n"); - } - fprintf(fp, "\tpushl\t$%d\n", number); - fprintf(fp, "\tcalls\t$1,_%s\n\tpopr\t$0x3f\n", vector); - fprintf(fp, "\tincl\t_cnt+V_INTR\n\trei\n\n"); - } -} - -static char *vaxinames[] = { - "clock", "cnr", "cnx", "tur", "tux", - "mba0", "mba1", "mba2", "mba3", - "uba0", "uba1", "uba2", "uba3" -}; - -static char *tahoeinames[] = { - "clock", "cnr", "cnx", "rmtr", "rmtx", "buserr", -}; - -static struct stdintrs { - char **si_names; /* list of standard interrupt names */ - int si_n; /* number of such names */ -} stdintrs[] = { - { vaxinames, sizeof (vaxinames) / sizeof (vaxinames[0]) }, - { tahoeinames, (sizeof (tahoeinames) / sizeof (tahoeinames[0])) } -}; - -/* - * Start the interrupt name table with the names - * of the standard vectors not directly associated - * with a bus. Also, dump the defines needed to - * reference the associated counters into a separate - * file which is prepended to locore.s. - */ -void dump_std(fp, gp) - register FILE *fp, *gp; -{ - register struct stdintrs *si = &stdintrs[machine-1]; - register char **cpp; - register int i; - - fprintf(fp, "\n\t.globl\t_intrnames\n"); - fprintf(fp, "\n\t.globl\t_eintrnames\n"); - fprintf(fp, "\t.data\n"); - fprintf(fp, "_intrnames:\n"); - cpp = si->si_names; - for (i = 0; i < si->si_n; i++) { - register char *cp, *tp; - char buf[80]; - - cp = *cpp; - if (cp[0] == 'i' && cp[1] == 'n' && cp[2] == 't') { - cp += 3; - if (*cp == 'r') - cp++; - } - for (tp = buf; *cp; cp++) - if (islower(*cp)) - *tp++ = toupper(*cp); - else - *tp++ = *cp; - *tp = '\0'; - fprintf(gp, "#define\tI_%s\t%d\n", buf, i * (int)sizeof (long)); - fprintf(fp, "\t.asciz\t\"%s\"\n", *cpp); - cpp++; - } -} - -void dump_intname(fp, vector, number) - register FILE *fp; - char *vector; - int number; -{ - register char *cp = vector; - - fprintf(fp, "\t.asciz\t\""); - /* - * Skip any "int" or "intr" in the name. - */ - while (*cp) - if (cp[0] == 'i' && cp[1] == 'n' && cp[2] == 't') { - cp += 3; - if (*cp == 'r') - cp++; - } else { - putc(*cp, fp); - cp++; - } - fprintf(fp, "%d\"\n", number); -} - -/* - * Reserve space for the interrupt counters. - */ -void dump_ctrs(fp) - register FILE *fp; -{ - struct stdintrs *si = &stdintrs[machine-1]; - - fprintf(fp, "_eintrnames:\n"); - fprintf(fp, "\n\t.globl\t_intrcnt\n"); - fprintf(fp, "\n\t.globl\t_eintrcnt\n"); - fprintf(fp, "\t.align 2\n"); - fprintf(fp, "_intrcnt:\n"); - fprintf(fp, "\t.space\t4 * %d\n", si->si_n); - fprintf(fp, "_fltintrcnt:\n"); - fprintf(fp, "\t.space\t4 * %d\n", cntcnt); - fprintf(fp, "_eintrcnt:\n\n"); - fprintf(fp, "\t.text\n"); -} - -/* - * Create the UNIBUS interrupt vector glue file. - */ -void ubglue() -{ - register FILE *fp, *gp; - register struct device *dp, *mp; - - fp = fopen(path("ubglue.s"), "w"); - if (fp == 0) { - perror(path("ubglue.s")); - exit(1); - } - gp = fopen(path("ubvec.s"), "w"); - if (gp == 0) { - perror(path("ubvec.s")); - exit(1); - } - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (mp != 0 && mp != (struct device *)-1 && - !eq(mp->d_name, "mba")) { - struct idlst *id, *id2; - - for (id = dp->d_vec; id; id = id->id_next) { - for (id2 = dp->d_vec; id2; id2 = id2->id_next) { - if (id2 == id) { - dump_ubavec(fp, id->id, - dp->d_unit); - break; - } - if (!strcmp(id->id, id2->id)) - break; - } - } - } - } - dump_std(fp, gp); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (mp != 0 && mp != (struct device *)-1 && - !eq(mp->d_name, "mba")) { - struct idlst *id, *id2; - - for (id = dp->d_vec; id; id = id->id_next) { - for (id2 = dp->d_vec; id2; id2 = id2->id_next) { - if (id2 == id) { - dump_intname(fp, id->id, - dp->d_unit); - break; - } - if (!strcmp(id->id, id2->id)) - break; - } - } - } - } - dump_ctrs(fp); - (void) fclose(fp); - (void) fclose(gp); -} - -/* - * Print a VERSAbus interrupt vector - */ -void dump_vbavec(fp, vector, number) - register FILE *fp; - char *vector; - int number; -{ - char nbuf[80]; - register char *v = nbuf; - - (void) sprintf(v, "%s%d", vector, number); - fprintf(fp, "SCBVEC(%s):\n", v); - fprintf(fp, "\tCHECK_SFE(4)\n"); - fprintf(fp, "\tSAVE_FPSTAT(4)\n"); - fprintf(fp, "\tPUSHR\n"); - fprintf(fp, "\tincl\t_fltintrcnt+(4*%d)\n", cntcnt++); - fprintf(fp, "\tpushl\t$%d\n", number); - fprintf(fp, "\tcallf\t$8,_%s\n", vector); - fprintf(fp, "\tincl\t_cnt+V_INTR\n"); - fprintf(fp, "\tPOPR\n"); - fprintf(fp, "\tREST_FPSTAT\n"); - fprintf(fp, "\trei\n\n"); -} - -/* - * Create the VERSAbus interrupt vector glue file. - */ -void vbglue() -{ - register FILE *fp, *gp; - register struct device *dp, *mp; - - fp = fopen(path("vbglue.s"), "w"); - if (fp == 0) { - perror(path("vbglue.s")); - exit(1); - } - gp = fopen(path("vbvec.s"), "w"); - if (gp == 0) { - perror(path("vbvec.s")); - exit(1); - } - for (dp = dtab; dp != 0; dp = dp->d_next) { - struct idlst *id, *id2; - - mp = dp->d_conn; - if (mp == 0 || mp == (struct device *)-1 || - eq(mp->d_name, "mba")) - continue; - for (id = dp->d_vec; id; id = id->id_next) - for (id2 = dp->d_vec; id2; id2 = id2->id_next) { - if (id == id2) { - dump_vbavec(fp, id->id, dp->d_unit); - break; - } - if (eq(id->id, id2->id)) - break; - } - } - dump_std(fp, gp); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (mp != 0 && mp != (struct device *)-1 && - !eq(mp->d_name, "mba")) { - struct idlst *id, *id2; - - for (id = dp->d_vec; id; id = id->id_next) { - for (id2 = dp->d_vec; id2; id2 = id2->id_next) { - if (id2 == id) { - dump_intname(fp, id->id, - dp->d_unit); - break; - } - if (eq(id->id, id2->id)) - break; - } - } - } - } - dump_ctrs(fp); - (void) fclose(fp); - (void) fclose(gp); -} - -/* - * HP9000/300 interrupts are auto-vectored. - * Code is hardwired in locore.s - */ -void hpglue() -{ -} - -/* - * Create the ISA interrupt vector glue file. - */ -void vector() -{ - register FILE *fp; - register struct device *dp, *mp; - int count; - - fp = fopen(path("vector.s"), "w"); - if (fp == 0) { - perror(path("vector.s")); - exit(1); - } - fprintf(fp,"\ -/*\n\ - * AT/386\n\ - * Interrupt vector routines\n\ - * Generated by config program\n\ - */ \n\ -\n\ -#include \"i386/isa/isa.h\"\n\ -#include \"i386/isa/icu.h\"\n\ -\n\ -#define VEC(name) .align 4; .globl _V/**/name; _V/**/name:\n\n"); - - fprintf(fp,"\ - .globl _hardclock\n\ -VEC(clk)\n\ - INTR1(0, _highmask, 0)\n\ - call _hardclock \n\ - INTREXIT1\n\n\n"); - - count=0; - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (mp != 0 && /* mp != (struct device *)-1 &&*/ - eq(mp->d_name, "isa")) { - struct idlst *id, *id2; - - for (id = dp->d_vec; id; id = id->id_next) { - for (id2 = dp->d_vec; id2; id2 = id2->id_next) { - if (id2 == id) { - if(dp->d_irq == -1) continue; - fprintf(fp,"\t.globl _%s, _%s%dmask\n\t.data\n", - id->id, dp->d_name, dp->d_unit); - fprintf(fp,"_%s%dmask:\t.long 0\n\t.text\n", - dp->d_name, dp->d_unit); - fprintf(fp,"VEC(%s%d)\n\tINTR%d(%d, ", - dp->d_name, dp->d_unit, - dp->d_irq / 8 + 1, dp->d_unit); - if(eq(dp->d_mask,"null")) - fprintf(fp,"_%s%dmask, ", - dp->d_name, dp->d_unit); - else - fprintf(fp,"_%smask, ", - dp->d_mask); - fprintf(fp,"%d)\n\tcall\t_%s\n\tINTREXIT%d\n\n\n", - ++count, id->id, (dp->d_irq > 7)?2:1); - break; - } - if (!strcmp(id->id, id2->id)) - break; - } - } - } - } - (void) fclose(fp); -} diff --git a/tools/kconfig/mkheaders.c b/tools/kconfig/mkheaders.c index 3d12540..9cf7191 100644 --- a/tools/kconfig/mkheaders.c +++ b/tools/kconfig/mkheaders.c @@ -152,8 +152,7 @@ void do_count(dev, hname, search) hicount = dp->d_unit + 1; if (search) { mp = dp->d_conn; - if (mp != 0 && mp != TO_NEXUS && - mp->d_conn != 0 && mp->d_conn != TO_NEXUS) { + if (mp != 0 && mp->d_conn != 0) { do_count(mp->d_name, hname, 0); search = 0; } diff --git a/tools/kconfig/mkioconf.c b/tools/kconfig/mkioconf.c index 0642600..3b763b1 100644 --- a/tools/kconfig/mkioconf.c +++ b/tools/kconfig/mkioconf.c @@ -35,787 +35,95 @@ #include "y.tab.h" #include "config.h" +static void +comp_config(fp) + FILE *fp; +{ + register struct file_list *fl; + register struct device *dp; + + fprintf(fp, "\n#include \"dev/cdvar.h\"\n"); + fprintf(fp, "\nstruct cddevice cddevice[] = {\n"); + fprintf(fp, "/*\tunit\tileave\tflags\tdk\tdevs\t\t\t\t*/\n"); + + fl = comp_list; + while (fl) { + if (fl->f_type != COMPDEVICE) { + fl = fl->f_next; + continue; + } + for (dp = dtab; dp != 0; dp = dp->d_next) + if (dp->d_type == DEVICE && + eq(dp->d_name, fl->f_fn) && + dp->d_unit == fl->f_compinfo) + break; + if (dp == 0) + continue; + fprintf(fp, "\t%d,\t%d,\t%d,\t%d,\t{", + dp->d_unit, dp->d_pri < 0 ? 0 : dp->d_pri, + dp->d_flags, 1); + for (fl = fl->f_next; fl->f_type == COMPSPEC; fl = fl->f_next) + fprintf(fp, " 0x%x,", (unsigned) fl->f_compdev); + fprintf(fp, " NODEV },\n"); + } + fprintf(fp, "\t-1,\t0,\t0,\t0,\t{ 0 },\n};\n"); +} + /* * build the ioconf.c file */ -char *qu(); -char *intv(); -char *wnum(); -void pseudo_ioconf(); - -#if MACHINE_VAX -void vax_ioconf() +static void +pseudo_ioconf(fp) + register FILE *fp; { - register struct device *dp, *mp, *np; - register int uba_n, slave; - FILE *fp; + register struct device *dp; - fp = fopen(path("ioconf.c"), "w"); - if (fp == 0) { - perror(path("ioconf.c")); - exit(1); - } - fprintf(fp, "#include \"vax/include/pte.h\"\n"); - fprintf(fp, "#include \"sys/param.h\"\n"); - fprintf(fp, "#include \"sys/buf.h\"\n"); - fprintf(fp, "#include \"sys/map.h\"\n"); - fprintf(fp, "\n"); - fprintf(fp, "#include \"vax/mba/mbavar.h\"\n"); - fprintf(fp, "#include \"vax/uba/ubavar.h\"\n\n"); - fprintf(fp, "\n"); - fprintf(fp, "#define C (caddr_t)\n\n"); - - /* - * First print the mba initialization structures - */ - if (seen_mba) { - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (mp == 0 || mp == TO_NEXUS || - !eq(mp->d_name, "mba")) - continue; - fprintf(fp, "extern struct mba_driver %sdriver;\n", + (void)fprintf(fp, "\n#include \n\n"); + for (dp = dtab; dp != NULL; dp = dp->d_next) + if (dp->d_type == PSEUDO_DEVICE) + (void)fprintf(fp, "extern void %sattach __P((int));\n", dp->d_name); - } - fprintf(fp, "\nstruct mba_device mbdinit[] = {\n"); - fprintf(fp, "\t/* Device, Unit, Mba, Drive, Dk */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_unit == QUES || mp == 0 || - mp == TO_NEXUS || !eq(mp->d_name, "mba")) - continue; - if (dp->d_addr) { - printf("can't specify csr address on mba for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_vec != 0) { - printf("can't specify vector for %s%d on mba\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_drive == UNKNOWN) { - printf("drive not specified for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_slave != UNKNOWN) { - printf("can't specify slave number for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - fprintf(fp, "\t{ &%sdriver, %d, %s,", - dp->d_name, dp->d_unit, qu(mp->d_unit)); - fprintf(fp, " %s, %d },\n", - qu(dp->d_drive), dp->d_dk); - } - fprintf(fp, "\t0\n};\n\n"); - /* - * Print the mbsinit structure - * Driver Controller Unit Slave - */ - fprintf(fp, "struct mba_slave mbsinit [] = {\n"); - fprintf(fp, "\t/* Driver, Ctlr, Unit, Slave */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - /* - * All slaves are connected to something which - * is connected to the massbus. - */ - if ((mp = dp->d_conn) == 0 || mp == TO_NEXUS) - continue; - np = mp->d_conn; - if (np == 0 || np == TO_NEXUS || - !eq(np->d_name, "mba")) - continue; - fprintf(fp, "\t{ &%sdriver, %s", - mp->d_name, qu(mp->d_unit)); - fprintf(fp, ", %2d, %s },\n", - dp->d_unit, qu(dp->d_slave)); - } - fprintf(fp, "\t0\n};\n\n"); - } /* - * Now generate interrupt vectors for the unibus + * XXX concatonated disks are pseudo-devices but appear as DEVICEs + * since they don't adhere to normal pseudo-device conventions + * (i.e. one entry with total count in d_slave). */ - for (dp = dtab; dp != 0; dp = dp->d_next) { - if (dp->d_vec != 0) { - struct idlst *ip; - mp = dp->d_conn; - if (mp == 0 || mp == TO_NEXUS || - (!eq(mp->d_name, "uba") && !eq(mp->d_name, "bi"))) - continue; - fprintf(fp, - "extern struct uba_driver %sdriver;\n", - dp->d_name); - fprintf(fp, "extern "); - ip = dp->d_vec; - for (;;) { - fprintf(fp, "X%s%d()", ip->id, dp->d_unit); - ip = ip->id_next; - if (ip == 0) - break; - fprintf(fp, ", "); - } - fprintf(fp, ";\n"); - fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name, - dp->d_unit); - ip = dp->d_vec; - for (;;) { - fprintf(fp, "X%s%d", ip->id, dp->d_unit); - ip = ip->id_next; - if (ip == 0) - break; - fprintf(fp, ", "); - } - fprintf(fp, ", 0 } ;\n"); - } - } - fprintf(fp, "\nstruct uba_ctlr ubminit[] = {\n"); - fprintf(fp, "/*\t driver,\tctlr,\tubanum,\talive,\tintr,\taddr */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 || - !eq(mp->d_name, "uba")) - continue; - if (dp->d_vec == 0) { - printf("must specify vector for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_addr == 0) { - printf("must specify csr address for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { - printf("drives need their own entries; dont "); - printf("specify drive or slave for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_flags) { - printf("controllers (e.g. %s%d) ", - dp->d_name, dp->d_unit); - printf("don't have flags, only devices do\n"); - continue; - } - fprintf(fp, - "\t{ &%sdriver,\t%d,\t%s,\t0,\t%sint%d, C 0%o },\n", - dp->d_name, dp->d_unit, qu(mp->d_unit), - dp->d_name, dp->d_unit, dp->d_addr); - } - fprintf(fp, "\t0\n};\n"); -/* unibus devices */ - fprintf(fp, "\nstruct uba_device ubdinit[] = {\n"); - fprintf(fp, - "\t/* driver, unit, ctlr, ubanum, slave, intr, addr, dk, flags*/\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || - mp == TO_NEXUS || mp->d_type == MASTER || - eq(mp->d_name, "mba")) - continue; - np = mp->d_conn; - if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba")) - continue; - np = 0; - if (eq(mp->d_name, "uba")) { - if (dp->d_vec == 0) { - printf("must specify vector for device %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_addr == 0) { - printf("must specify csr for device %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { - printf("drives/slaves can be specified "); - printf("only for controllers, "); - printf("not for device %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - uba_n = mp->d_unit; - slave = QUES; - } else { - if ((np = mp->d_conn) == 0) { - printf("%s%d isn't connected to anything ", - mp->d_name, mp->d_unit); - printf(", so %s%d is unattached\n", - dp->d_name, dp->d_unit); - continue; - } - uba_n = np->d_unit; - if (dp->d_drive == UNKNOWN) { - printf("must specify ``drive number'' "); - printf("for %s%d\n", dp->d_name, dp->d_unit); - continue; - } - /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */ - /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ - if (dp->d_slave != UNKNOWN) { - printf("slave numbers should be given only "); - printf("for massbus tapes, not for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_vec != 0) { - printf("interrupt vectors should not be "); - printf("given for drive %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_addr != 0) { - printf("csr addresses should be given only "); - printf("on controllers, not on %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - slave = dp->d_drive; - } - fprintf(fp, "\t{ &%sdriver, %2d, %s,", - eq(mp->d_name, "uba") ? dp->d_name : mp->d_name, dp->d_unit, - eq(mp->d_name, "uba") ? " -1" : qu(mp->d_unit)); - fprintf(fp, " %s, %2d, %s, C 0%-6o, %d, 0x%x },\n", - qu(uba_n), slave, intv(dp), dp->d_addr, dp->d_dk, - dp->d_flags); - } - fprintf(fp, "\t0\n};\n"); - pseudo_ioconf(fp); - (void) fclose(fp); -} -#endif - -#if MACHINE_TAHOE -void tahoe_ioconf() -{ - register struct device *dp, *mp, *np; - register int vba_n, slave; - FILE *fp; - - fp = fopen(path("ioconf.c"), "w"); - if (fp == 0) { - perror(path("ioconf.c")); - exit(1); - } - fprintf(fp, "#include \"sys/param.h\"\n"); - fprintf(fp, "#include \"tahoe/include/pte.h\"\n"); - fprintf(fp, "#include \"sys/buf.h\"\n"); - fprintf(fp, "#include \"sys/map.h\"\n"); - fprintf(fp, "\n"); - fprintf(fp, "#include \"tahoe/vba/vbavar.h\"\n"); - fprintf(fp, "\n"); - fprintf(fp, "#define C (caddr_t)\n\n"); + if (seen_cd) + (void)fprintf(fp, "extern void cdattach __P((int));\n"); + /* XXX temporary for HP300, others */ + (void)fprintf(fp, "\n#include /* XXX */\n"); + (void)fprintf(fp, "#define etherattach (void (*)__P((int)))nullop\n"); + (void)fprintf(fp, "#define iteattach (void (*) __P((int)))nullop\n"); + (void)fprintf(fp, "\nstruct pdevinit pdevinit[] = {\n"); + for (dp = dtab; dp != NULL; dp = dp->d_next) + if (dp->d_type == PSEUDO_DEVICE) + (void)fprintf(fp, "\t{ %sattach, %d },\n", dp->d_name, + dp->d_slave > 0 ? dp->d_slave : 1); /* - * Now generate interrupt vectors for the versabus + * XXX count up cds and put out an entry */ - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (mp == 0 || mp == TO_NEXUS || !eq(mp->d_name, "vba")) - continue; - if (dp->d_vec != 0) { - struct idlst *ip; - fprintf(fp, - "extern struct vba_driver %sdriver;\n", - dp->d_name); - fprintf(fp, "extern "); - ip = dp->d_vec; - for (;;) { - fprintf(fp, "X%s%d()", ip->id, dp->d_unit); - ip = ip->id_next; - if (ip == 0) - break; - fprintf(fp, ", "); - } - fprintf(fp, ";\n"); - fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name, - dp->d_unit); - ip = dp->d_vec; - for (;;) { - fprintf(fp, "X%s%d", ip->id, dp->d_unit); - ip = ip->id_next; - if (ip == 0) - break; - fprintf(fp, ", "); - } - fprintf(fp, ", 0 } ;\n"); - } else if (dp->d_type == DRIVER) /* devices w/o interrupts */ - fprintf(fp, - "extern struct vba_driver %sdriver;\n", - dp->d_name); - } - fprintf(fp, "\nstruct vba_ctlr vbminit[] = {\n"); - fprintf(fp, "/*\t driver,\tctlr,\tvbanum,\talive,\tintr,\taddr */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 || - !eq(mp->d_name, "vba")) - continue; - if (dp->d_vec == 0) { - printf("must specify vector for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_addr == 0) { - printf("must specify csr address for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { - printf("drives need their own entries; dont "); - printf("specify drive or slave for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_flags) { - printf("controllers (e.g. %s%d) ", - dp->d_name, dp->d_unit); - printf("don't have flags, only devices do\n"); - continue; - } - fprintf(fp, - "\t{ &%sdriver,\t%d,\t%s,\t0,\t%sint%d, C 0x%x },\n", - dp->d_name, dp->d_unit, qu(mp->d_unit), - dp->d_name, dp->d_unit, dp->d_addr); - } - fprintf(fp, "\t0\n};\n"); + if (seen_cd) { + struct file_list *fl; + int cdmax = -1; - /* versabus devices */ - fprintf(fp, "\nstruct vba_device vbdinit[] = {\n"); - fprintf(fp, - "\t/* driver, unit, ctlr, vbanum, slave, intr, addr, dk, flags*/\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || - mp == TO_NEXUS || mp->d_type == MASTER || - eq(mp->d_name, "mba")) - continue; - np = mp->d_conn; - if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba")) - continue; - np = 0; - if (eq(mp->d_name, "vba")) { - if (dp->d_vec == 0) - printf( - "Warning, no interrupt vector specified for device %s%d\n", - dp->d_name, dp->d_unit); - if (dp->d_addr == 0) { - printf("must specify csr for device %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { - printf("drives/slaves can be specified "); - printf("only for controllers, "); - printf("not for device %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - vba_n = mp->d_unit; - slave = QUES; - } else { - if ((np = mp->d_conn) == 0) { - printf("%s%d isn't connected to anything ", - mp->d_name, mp->d_unit); - printf(", so %s%d is unattached\n", - dp->d_name, dp->d_unit); - continue; - } - vba_n = np->d_unit; - if (dp->d_drive == UNKNOWN) { - printf("must specify ``drive number'' "); - printf("for %s%d\n", dp->d_name, dp->d_unit); - continue; - } - /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */ - /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ - if (dp->d_slave != UNKNOWN) { - printf("slave numbers should be given only "); - printf("for massbus tapes, not for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_vec != 0) { - printf("interrupt vectors should not be "); - printf("given for drive %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_addr != 0) { - printf("csr addresses should be given only "); - printf("on controllers, not on %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - slave = dp->d_drive; - } - fprintf(fp, "\t{ &%sdriver, %2d, %s,", - eq(mp->d_name, "vba") ? dp->d_name : mp->d_name, dp->d_unit, - eq(mp->d_name, "vba") ? " -1" : qu(mp->d_unit)); - fprintf(fp, " %s, %2d, %s, C 0x%-6x, %d, 0x%x },\n", - qu(vba_n), slave, intv(dp), dp->d_addr, dp->d_dk, - dp->d_flags); + for (fl = comp_list; fl != NULL; fl = fl->f_next) + if (fl->f_type == COMPDEVICE && fl->f_compinfo > cdmax) + cdmax = fl->f_compinfo; + (void)fprintf(fp, "\t{ cdattach, %d },\n", cdmax+1); } - fprintf(fp, "\t0\n};\n"); - pseudo_ioconf(fp); - (void) fclose(fp); -} -#endif - -#if MACHINE_HP300 || MACHINE_LUNA68K - -#define ishpibdev(n) (eq(n,"rd") || eq(n,"ct") || eq(n,"mt") || eq(n,"ppi")) -#define isscsidev(n) (eq(n,"sd") || eq(n,"st") || eq(n,"ac")) - -int hpbadslave(mp, dp) - register struct device *dp, *mp; -{ - - if ((mp == TO_NEXUS && ishpibdev(dp->d_name)) || - (mp != TO_NEXUS && eq(mp->d_name, "hpib") && - !ishpibdev(dp->d_name))) { - printf("%s%s must be attached to an hpib\n", - dp->d_name, wnum(dp->d_unit)); - return (1); - } - if ((mp == TO_NEXUS && isscsidev(dp->d_name)) || - (mp != TO_NEXUS && eq(mp->d_name, "scsi") && - !isscsidev(dp->d_name))) { - printf("%s%s must be attached to a scsi\n", - dp->d_name, wnum(dp->d_unit)); - return (1); - } - return (0); + (void)fprintf(fp, "\t{ 0, 0 }\n};\n"); + if (seen_cd) + comp_config(fp); } -void hp300_ioconf() +static char * +wnum(num) { - register struct device *dp, *mp; - register int hpib, slave; - FILE *fp; - - fp = fopen(path("ioconf.c"), "w"); - if (fp == 0) { - perror(path("ioconf.c")); - exit(1); - } - fprintf(fp, "#include \"sys/param.h\"\n"); - fprintf(fp, "#include \"sys/buf.h\"\n"); - fprintf(fp, "#include \"sys/map.h\"\n"); - fprintf(fp, "\n"); - if (machine == MACHINE_HP300) - fprintf(fp, "#include \"hp/dev/device.h\"\n\n"); - else - fprintf(fp, "#include \"luna68k/dev/device.h\"\n\n"); - fprintf(fp, "\n"); - fprintf(fp, "#define C (caddr_t)\n"); - fprintf(fp, "#define D (struct driver *)\n\n"); - /* - * First print the hpib controller initialization structures - */ - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_unit == QUES || mp == 0) - continue; - fprintf(fp, "extern struct driver %sdriver;\n", dp->d_name); - } - fprintf(fp, "\nstruct hp_ctlr hp_cinit[] = {\n"); - fprintf(fp, "/*\tdriver,\t\tunit,\talive,\taddr,\tflags */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_unit == QUES || - (dp->d_type != MASTER && dp->d_type != CONTROLLER)) - continue; - if (mp != TO_NEXUS) { - printf("%s%s must be attached to an sc (nexus)\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { - printf("can't specify drive/slave for %s%s\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - fprintf(fp, - "\t{ &%sdriver,\t%d,\t0,\tC 0x%x,\t0x%x },\n", - dp->d_name, dp->d_unit, dp->d_addr, dp->d_flags); - } - fprintf(fp, "\t0\n};\n"); - - /* devices */ - fprintf(fp, "\nstruct hp_device hp_dinit[] = {\n"); - fprintf(fp, - "/*driver,\tcdriver,\tunit,\tctlr,\tslave,\taddr,\tdk,\tflags*/\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (mp == 0 || dp->d_type != DEVICE || hpbadslave(mp, dp)) - continue; - if (mp == TO_NEXUS) { - if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { - printf("can't specify drive/slave for %s%s\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - slave = QUES; - hpib = QUES; - } else { - if (dp->d_addr != 0) { - printf("can't specify sc for device %s%s\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - if (mp->d_type == CONTROLLER) { - if (dp->d_drive == UNKNOWN) { - printf("must specify drive for %s%s\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - slave = dp->d_drive; - } else { - if (dp->d_slave == UNKNOWN) { - printf("must specify slave for %s%s\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - slave = dp->d_slave; - } - hpib = mp->d_unit; - } - fprintf(fp, "{ &%sdriver,\t", dp->d_name); - if (mp == TO_NEXUS) - fprintf(fp, "D 0x0,\t"); - else - fprintf(fp, "&%sdriver,", mp->d_name); - fprintf(fp, "\t%d,\t%d,\t%d,\tC 0x%x,\t%d,\t0x%x },\n", - dp->d_unit, hpib, slave, - dp->d_addr, dp->d_dk, dp->d_flags); - } - fprintf(fp, "0\n};\n"); - pseudo_ioconf(fp); - (void) fclose(fp); -} -#endif - -#if MACHINE_I386 -char *sirq(int); - -void i386_ioconf() -{ - register struct device *dp, *mp; - FILE *fp; - - fp = fopen(path("ioconf.c"), "w"); - if (fp == 0) { - perror(path("ioconf.c")); - exit(1); - } - fprintf(fp, "/*\n"); - fprintf(fp, " * ioconf.c \n"); - fprintf(fp, " * Generated by config program\n"); - fprintf(fp, " */\n\n"); - fprintf(fp, "#include \"machine/pte.h\"\n"); - fprintf(fp, "#include \"sys/param.h\"\n"); - fprintf(fp, "#include \"sys/buf.h\"\n"); - fprintf(fp, "#include \"sys/map.h\"\n"); - fprintf(fp, "\n"); - fprintf(fp, "#define V(s) __CONCAT(V,s)\n"); - fprintf(fp, "#define C (caddr_t)\n\n"); - /* - * First print the isa initialization structures - */ - if (seen_isa) { - - fprintf(fp, "/*\n"); - fprintf(fp, " * ISA devices\n"); - fprintf(fp, " */\n\n"); - fprintf(fp, "#include \"i386/isa/isa_device.h\"\n"); - fprintf(fp, "#include \"i386/isa/isa.h\"\n"); - fprintf(fp, "#include \"i386/isa/icu.h\"\n\n"); - - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (mp == 0 || mp == TO_NEXUS || - !eq(mp->d_name, "isa")) - continue; - fprintf(fp, - "extern struct isa_driver %sdriver; extern V(%s%d)();\n", - dp->d_name, dp->d_name, dp->d_unit); - } - fprintf(fp, "\nstruct isa_device isa_devtab_bio[] = {\n"); - fprintf(fp, "\ -/* driver iobase irq drq maddr msiz intr unit */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_unit == QUES || mp == 0 || - mp == TO_NEXUS || !eq(mp->d_name, "isa")) - continue; - if (!eq(dp->d_mask, "bio")) continue; - if (dp->d_port) - fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); - else - fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); - fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", - sirq(dp->d_irq), dp->d_drq, dp->d_maddr, - dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); - } - fprintf(fp, "0\n};\n"); - - fprintf(fp, "struct isa_device isa_devtab_tty[] = {\n"); - fprintf(fp, "\ -/* driver iobase irq drq maddr msiz intr unit */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_unit == QUES || mp == 0 || - mp == TO_NEXUS || !eq(mp->d_name, "isa")) - continue; - if (!eq(dp->d_mask, "tty")) continue; - if (dp->d_port) - fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); - else - fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); - fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", - sirq(dp->d_irq), dp->d_drq, dp->d_maddr, - dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); - } - fprintf(fp, "0\n};\n\n"); - - fprintf(fp, "struct isa_device isa_devtab_net[] = {\n"); - fprintf(fp, "\ -/* driver iobase irq drq maddr msiz intr unit */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_unit == QUES || mp == 0 || - mp == TO_NEXUS || !eq(mp->d_name, "isa")) - continue; - if (!eq(dp->d_mask, "net")) continue; - if (dp->d_port) - fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); - else - fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); - fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", - sirq(dp->d_irq), dp->d_drq, dp->d_maddr, - dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); - } - fprintf(fp, "0\n};\n\n"); - - fprintf(fp, "struct isa_device isa_devtab_null[] = {\n"); - fprintf(fp, "\ -/* driver iobase irq drq maddr msiz intr unit */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_unit == QUES || mp == 0 || - mp == TO_NEXUS || !eq(mp->d_name, "isa")) - continue; - if (!eq(dp->d_mask, "null")) continue; - if (dp->d_port) - fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); - else - fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); - fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", - sirq(dp->d_irq), dp->d_drq, dp->d_maddr, - dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); - } - fprintf(fp, "0\n};\n\n"); - } - pseudo_ioconf(fp); - (void) fclose(fp); -} - -char * -sirq(num) -{ - - if (num == -1) - return ("0"); - sprintf(errbuf, "IRQ%d", num); + if (num == QUES || num == UNKNOWN) + return ("?"); + (void) sprintf(errbuf, "%d", num); return (errbuf); } -#endif - -#if MACHINE_PMAX -void pmax_ioconf() -{ - register struct device *dp, *mp; - FILE *fp; - - fp = fopen(path("ioconf.c"), "w"); - if (fp == 0) { - perror(path("ioconf.c")); - exit(1); - } - fprintf(fp, "#include \"sys/types.h\"\n"); - fprintf(fp, "#include \"sys/time.h\"\n"); - fprintf(fp, "#include \"mips/dev/device.h\"\n\n"); - fprintf(fp, "#define C (char *)\n\n"); - - /* print controller initialization structures */ - for (dp = dtab; dp != 0; dp = dp->d_next) { - if (dp->d_type == PSEUDO_DEVICE) - continue; - fprintf(fp, "extern struct driver %sdriver;\n", dp->d_name); - } - fprintf(fp, "\nstruct mips_ctlr mips_cinit[] = {\n"); - fprintf(fp, "/*\tdriver,\t\tunit,\taddr,\t\tpri,\tflags */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - if (dp->d_type != CONTROLLER && dp->d_type != MASTER) - continue; - if (dp->d_conn != TO_NEXUS) { - printf("%s%s must be attached to a nexus (internal bus)\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { - printf("can't specify drive/slave for %s%s\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - if (dp->d_unit == UNKNOWN || dp->d_unit == QUES) - dp->d_unit = 0; - fprintf(fp, - "\t{ &%sdriver,\t%d,\tC 0x%x,\t%d,\t0x%x },\n", - dp->d_name, dp->d_unit, dp->d_addr, dp->d_pri, - dp->d_flags); - } - fprintf(fp, "\t0\n};\n"); - - /* print devices connected to other controllers */ - fprintf(fp, "\nstruct scsi_device scsi_dinit[] = {\n"); - fprintf(fp, - "/*driver,\tcdriver,\tunit,\tctlr,\tdrive,\tslave,\tdk,\tflags*/\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - if (dp->d_type == CONTROLLER || dp->d_type == MASTER || - dp->d_type == PSEUDO_DEVICE) - continue; - mp = dp->d_conn; - if (mp == 0 || - (!eq(mp->d_name, "asc") && !eq(mp->d_name, "sii"))) { - printf("%s%s: devices must be attached to a SCSI (asc or sii) controller\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - if ((unsigned)dp->d_drive > 6) { - printf("%s%s: SCSI drive must be in the range 0..6\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - /* may want to allow QUES later */ - if ((unsigned)dp->d_slave > 7) { - printf("%s%s: SCSI slave (LUN) must be in the range 0..7\n", - dp->d_name, wnum(dp->d_unit)); - continue; - } - fprintf(fp, "{ &%sdriver,\t&%sdriver,", dp->d_name, mp->d_name); - fprintf(fp, "\t%d,\t%d,\t%d,\t%d,\t%d,\t0x%x },\n", - dp->d_unit, mp->d_unit, dp->d_drive, dp->d_slave, - dp->d_dk, dp->d_flags); - } - fprintf(fp, "0\n};\n"); - pseudo_ioconf(fp); - (void) fclose(fp); -} -#endif #if MACHINE_PIC32 void pic32_ioconf() @@ -884,270 +192,3 @@ void pic32_ioconf() (void) fclose(fp); } #endif - -#if MACHINE_NEWS3400 -int have_iop = 0; -int have_hb = 0; -int have_vme = 0; - -void news_ioconf() -{ - register struct device *dp, *mp; - register int slave; - FILE *fp; - - fp = fopen(path("ioconf.c"), "w"); - if (fp == 0) { - perror(path("ioconf.c")); - exit(1); - } - fprintf(fp, "#include \"sys/param.h\"\n"); - fprintf(fp, "#include \"sys/buf.h\"\n"); - fprintf(fp, "#include \"sys/map.h\"\n"); - fprintf(fp, "#include \"vm/vm.h\"\n"); - fprintf(fp, "#include \"iop.h\"\n"); - fprintf(fp, "#include \"hb.h\"\n"); - fprintf(fp, "\n"); - fprintf(fp, "#if NIOP > 0\n"); - fprintf(fp, "#include \"news3400/iop/iopvar.h\"\n"); - fprintf(fp, "#endif\n"); - fprintf(fp, "#if NHB > 0\n"); - fprintf(fp, "#include \"news3400/hbdev/hbvar.h\"\n"); - fprintf(fp, "#endif\n"); - fprintf(fp, "\n"); - fprintf(fp, "#define C (caddr_t)\n\n"); - fprintf(fp, "\n"); - - /* BEGIN HB */ - fprintf(fp, "#if NHB > 0\n"); - /* - * Now generate interrupt vectors for the HYPER-BUS - */ - for (dp = dtab; dp != 0; dp = dp->d_next) { - if (dp->d_pri >= 0) { - mp = dp->d_conn; - if (mp == 0 || mp == TO_NEXUS || - !eq(mp->d_name, "hb")) - continue; - fprintf(fp, "extern struct hb_driver %sdriver;\n", - dp->d_name); - have_hb++; - } - } - /* - * Now spew forth the hb_cinfo structure - */ - fprintf(fp, "\nstruct hb_ctlr hminit[] = {\n"); - fprintf(fp, "/*\t driver,\tctlr,\talive,\taddr,\tintpri */\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if ((dp->d_type != MASTER && dp->d_type != CONTROLLER) - || mp == TO_NEXUS || mp == 0 || - !eq(mp->d_name, "hb")) - continue; - if (dp->d_pri < 0) { - printf("must specify priority for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { - printf("drives need their own entries; "); - printf("dont specify drive or slave for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_flags) { - printf("controllers (e.g. %s%d) don't have flags, " - "only devices do\n", - dp->d_name, dp->d_unit); - continue; - } - fprintf(fp, "\t{ &%sdriver,\t%d,\t0,\tC 0x%x,\t%d },\n", - dp->d_name, dp->d_unit, dp->d_addr, dp->d_pri); - } - fprintf(fp, "\t0\n};\n"); - /* - * Now we go for the hb_device stuff - */ - fprintf(fp, "\nstruct hb_device hdinit[] = {\n"); - fprintf(fp, - "\t/* driver, unit, ctlr, slave, addr, pri, dk, flags*/\n"); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || - mp == TO_NEXUS || /* mp->d_type == MASTER || */ - eq(mp->d_name, "iop") || eq(mp->d_name, "vme")) - continue; - if (eq(mp->d_name, "hb")) { - if (dp->d_pri < 0) { - printf("must specify vector for device %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { - printf("drives/slaves can be specified only "); - printf("for controllers, not for device %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - slave = QUES; - } else { - if (mp->d_conn == 0) { - printf("%s%d isn't connected to anything, ", - mp->d_name, mp->d_unit); - printf("so %s%d is unattached\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_drive == UNKNOWN) { - printf("must specify ``drive number'' for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - /* NOTE THAT ON THE IOP ``drive'' IS STORED IN */ - /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ - if (dp->d_slave != UNKNOWN) { - printf("slave numbers should be given only "); - printf("for massbus tapes, not for %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_pri >= 0) { - printf("interrupt priority should not be "); - printf("given for drive %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - if (dp->d_addr != 0) { - printf("csr addresses should be given only"); - printf("on controllers, not on %s%d\n", - dp->d_name, dp->d_unit); - continue; - } - slave = dp->d_drive; - } - fprintf(fp, - "\t{ &%sdriver, %2d, %s, %2d, C 0x%x, %d, %d, 0x%x },\n", - eq(mp->d_name, "hb") ? dp->d_name : mp->d_name, dp->d_unit, - eq(mp->d_name, "hb") ? " -1" : qu(mp->d_unit), - slave, dp->d_addr, dp->d_pri, dp->d_dk, dp->d_flags); - } - fprintf(fp, "\t0\n};\n\n"); - fprintf(fp, "#endif\n\n"); - /* END HB */ - - pseudo_ioconf(fp); - (void) fclose(fp); -} -#endif - -char * -intv(dev) - register struct device *dev; -{ - static char buf[20]; - - if (dev->d_vec == 0) - return (" 0"); - (void) sprintf(buf, "%sint%d", dev->d_name, dev->d_unit); - return (buf); -} - -char * -qu(num) -{ - - if (num == QUES) - return ("'?'"); - if (num == UNKNOWN) - return (" -1"); - (void) sprintf(errbuf, "%3d", num); - return (errbuf); -} - -char * -wnum(num) -{ - - if (num == QUES || num == UNKNOWN) - return ("?"); - (void) sprintf(errbuf, "%d", num); - return (errbuf); -} - -void comp_config(fp) - FILE *fp; -{ - register struct file_list *fl; - register struct device *dp; - - fprintf(fp, "\n#include \"dev/cdvar.h\"\n"); - fprintf(fp, "\nstruct cddevice cddevice[] = {\n"); - fprintf(fp, "/*\tunit\tileave\tflags\tdk\tdevs\t\t\t\t*/\n"); - - fl = comp_list; - while (fl) { - if (fl->f_type != COMPDEVICE) { - fl = fl->f_next; - continue; - } - for (dp = dtab; dp != 0; dp = dp->d_next) - if (dp->d_type == DEVICE && - eq(dp->d_name, fl->f_fn) && - dp->d_unit == fl->f_compinfo) - break; - if (dp == 0) - continue; - fprintf(fp, "\t%d,\t%d,\t%d,\t%d,\t{", - dp->d_unit, dp->d_pri < 0 ? 0 : dp->d_pri, - dp->d_flags, 1); - for (fl = fl->f_next; fl->f_type == COMPSPEC; fl = fl->f_next) - fprintf(fp, " 0x%x,", (unsigned) fl->f_compdev); - fprintf(fp, " NODEV },\n"); - } - fprintf(fp, "\t-1,\t0,\t0,\t0,\t{ 0 },\n};\n"); -} - -void -pseudo_ioconf(fp) - register FILE *fp; -{ - register struct device *dp; - - (void)fprintf(fp, "\n#include \n\n"); - for (dp = dtab; dp != NULL; dp = dp->d_next) - if (dp->d_type == PSEUDO_DEVICE) - (void)fprintf(fp, "extern void %sattach __P((int));\n", - dp->d_name); - /* - * XXX concatonated disks are pseudo-devices but appear as DEVICEs - * since they don't adhere to normal pseudo-device conventions - * (i.e. one entry with total count in d_slave). - */ - if (seen_cd) - (void)fprintf(fp, "extern void cdattach __P((int));\n"); - /* XXX temporary for HP300, others */ - (void)fprintf(fp, "\n#include /* XXX */\n"); - (void)fprintf(fp, "#define etherattach (void (*)__P((int)))nullop\n"); - (void)fprintf(fp, "#define iteattach (void (*) __P((int)))nullop\n"); - (void)fprintf(fp, "\nstruct pdevinit pdevinit[] = {\n"); - for (dp = dtab; dp != NULL; dp = dp->d_next) - if (dp->d_type == PSEUDO_DEVICE) - (void)fprintf(fp, "\t{ %sattach, %d },\n", dp->d_name, - dp->d_slave > 0 ? dp->d_slave : 1); - /* - * XXX count up cds and put out an entry - */ - if (seen_cd) { - struct file_list *fl; - int cdmax = -1; - - for (fl = comp_list; fl != NULL; fl = fl->f_next) - if (fl->f_type == COMPDEVICE && fl->f_compinfo > cdmax) - cdmax = fl->f_compinfo; - (void)fprintf(fp, "\t{ cdattach, %d },\n", cdmax+1); - } - (void)fprintf(fp, "\t{ 0, 0 }\n};\n"); - if (seen_cd) - comp_config(fp); -} diff --git a/tools/kconfig/mkmakefile.c b/tools/kconfig/mkmakefile.c index 2f7da3a..de13b1b 100644 --- a/tools/kconfig/mkmakefile.c +++ b/tools/kconfig/mkmakefile.c @@ -115,14 +115,6 @@ static struct users { int u_min; int u_max; } users[] = { - { 24, 8, 1024 }, /* MACHINE_VAX */ - { 4, 2, 128 }, /* MACHINE_TAHOE */ - { 8, 2, 64 }, /* MACHINE_HP300 */ - { 8, 2, 64 }, /* MACHINE_I386 */ - { 8, 2, 64 }, /* MACHINE_MIPS */ - { 8, 2, 64 }, /* MACHINE_PMAX */ - { 8, 2, 64 }, /* MACHINE_LUNA68K */ - { 8, 2, 64 }, /* MACHINE_NEWS3400 */ { 2, 1, 16 }, /* MACHINE_PIC32 */ }; #define NUSERS (sizeof (users) / sizeof (users[0])) @@ -395,9 +387,6 @@ void do_cfiles(fp) /* * Create the makerules for each file * which is part of the system. - * Devices are processed with the special c2 option -i - * which avoids any problem areas with i/o addressing - * (e.g. for the VAX); assembler files are processed by as. */ void do_rules(f) FILE *f; @@ -516,8 +505,8 @@ void makefile() if (hadtz == 0) printf("timezone not specified; gmt assumed\n"); if ((unsigned)machine > NUSERS) { - printf("maxusers config info isn't present, using vax\n"); - up = &users[MACHINE_VAX-1]; + printf("maxusers config info isn't present, using pic32\n"); + up = &users[MACHINE_PIC32-1]; } else up = &users[machine-1]; if (maxusers == 0) { diff --git a/tools/kconfig/mkubglue.c b/tools/kconfig/mkubglue.c deleted file mode 100644 index 88ffa49..0000000 --- a/tools/kconfig/mkubglue.c +++ /dev/null @@ -1,192 +0,0 @@ -/*- - * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Make the uba interrupt file ubglue.s - */ -#include -#include "config.h" -#include "y.tab.h" - -ubglue() -{ - register FILE *fp; - register struct device *dp, *mp; - - fp = fopen(path("ubglue.s"), "w"); - if (fp == 0) { - perror(path("ubglue.s")); - exit(1); - } - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (mp != 0 && mp != (struct device *)-1 && - !eq(mp->d_name, "mba")) { - struct idlst *id, *id2; - - for (id = dp->d_vec; id; id = id->id_next) { - for (id2 = dp->d_vec; id2; id2 = id2->id_next) { - if (id2 == id) { - dump_vec(fp, id->id, dp->d_unit); - break; - } - if (!strcmp(id->id, id2->id)) - break; - } - } - } - } - dump_std(fp); - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (mp != 0 && mp != (struct device *)-1 && - !eq(mp->d_name, "mba")) { - struct idlst *id, *id2; - - for (id = dp->d_vec; id; id = id->id_next) { - for (id2 = dp->d_vec; id2; id2 = id2->id_next) { - if (id2 == id) { - dump_intname(fp, id->id, - dp->d_unit); - break; - } - if (!strcmp(id->id, id2->id)) - break; - } - } - } - } - dump_ctrs(fp); - (void) fclose(fp); -} - -static int cntcnt = 0; /* number of interrupt counters allocated */ - -/* - * print an interrupt vector - */ -dump_vec(fp, vector, number) - register FILE *fp; - char *vector; - int number; -{ - char nbuf[80]; - register char *v = nbuf; - - (void) sprintf(v, "%s%d", vector, number); - fprintf(fp, "\t.globl\t_X%s\n\t.align\t2\n_X%s:\n\tpushr\t$0x3f\n", - v, v); - fprintf(fp, "\tincl\t_fltintrcnt+(4*%d)\n", cntcnt++); - if (strncmp(vector, "dzx", 3) == 0) - fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdzdma\n\n", number); - else if (strncmp(vector, "dpx", 3) == 0) - fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdpxdma\n\n", number); - else if (strncmp(vector, "dpr", 3) == 0) - fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdprdma\n\n", number); - else { - if (strncmp(vector, "uur", 3) == 0) { - fprintf(fp, "#ifdef UUDMA\n"); - fprintf(fp, "\tmovl\t$%d,r0\n\tjsb\tuudma\n", number); - fprintf(fp, "#endif\n"); - } - fprintf(fp, "\tpushl\t$%d\n", number); - fprintf(fp, "\tcalls\t$1,_%s\n\tpopr\t$0x3f\n", vector); - fprintf(fp, "\tincl\t_cnt+V_INTR\n\trei\n\n"); - } -} - -/* - * Start the interrupt name table with the names - * of the standard vectors not on the unibus. - * The number and order of these names should correspond - * with the definitions in scb.s. - */ -dump_std(fp) - register FILE *fp; -{ - fprintf(fp, "\n\t.globl\t_intrnames\n"); - fprintf(fp, "\n\t.globl\t_eintrnames\n"); - fprintf(fp, "\t.data\n"); - fprintf(fp, "_intrnames:\n"); - fprintf(fp, "\t.asciz\t\"clock\"\n"); - fprintf(fp, "\t.asciz\t\"cnr\"\n"); - fprintf(fp, "\t.asciz\t\"cnx\"\n"); - fprintf(fp, "\t.asciz\t\"tur\"\n"); - fprintf(fp, "\t.asciz\t\"tux\"\n"); - fprintf(fp, "\t.asciz\t\"mba0\"\n"); - fprintf(fp, "\t.asciz\t\"mba1\"\n"); - fprintf(fp, "\t.asciz\t\"mba2\"\n"); - fprintf(fp, "\t.asciz\t\"mba3\"\n"); - fprintf(fp, "\t.asciz\t\"uba0\"\n"); - fprintf(fp, "\t.asciz\t\"uba1\"\n"); - fprintf(fp, "\t.asciz\t\"uba2\"\n"); - fprintf(fp, "\t.asciz\t\"uba3\"\n"); -#define I_FIXED 13 /* number of names above */ -} - -dump_intname(fp, vector, number) - register FILE *fp; - char *vector; - int number; -{ - register char *cp = vector; - - fprintf(fp, "\t.asciz\t\""); - /* - * Skip any "int" or "intr" in the name. - */ - while (*cp) - if (cp[0] == 'i' && cp[1] == 'n' && cp[2] == 't') { - cp += 3; - if (*cp == 'r') - cp++; - } else { - putc(*cp, fp); - cp++; - } - fprintf(fp, "%d\"\n", number); -} - -dump_ctrs(fp) - register FILE *fp; -{ - fprintf(fp, "_eintrnames:\n"); - fprintf(fp, "\n\t.globl\t_intrcnt\n"); - fprintf(fp, "\n\t.globl\t_eintrcnt\n"); - fprintf(fp, "_intrcnt:\n", I_FIXED); - fprintf(fp, "\t.space\t4 * %d\n", I_FIXED); - fprintf(fp, "_fltintrcnt:\n", cntcnt); - fprintf(fp, "\t.space\t4 * %d\n", cntcnt); - fprintf(fp, "_eintrcnt:\n\n"); - fprintf(fp, "\t.text\n"); -} From 47988903ae62c9993485af4ba530e41fe3fe547c Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Mon, 1 Jun 2015 19:14:27 -0700 Subject: [PATCH 5/8] Kconfig is able to parse max32 configuration script. --- tools/kconfig/.gitignore | 2 + tools/kconfig/Makefile | 2 +- tools/kconfig/Makefile.kconf | 149 +++++++++++++++++++++++++++++ tools/kconfig/config.y | 54 ++++------- tools/kconfig/devices.kconf | 1 + tools/kconfig/files.kconf | 179 +++++++++++++++++++++++++++++++++++ tools/kconfig/main.c | 25 ++--- tools/kconfig/max32/MAX32 | 74 +++++++++++++++ tools/kconfig/mkheaders.c | 2 +- tools/kconfig/mkmakefile.c | 20 ++-- tools/kconfig/mkswapconf.c | 6 +- 11 files changed, 452 insertions(+), 62 deletions(-) create mode 100644 tools/kconfig/.gitignore create mode 100644 tools/kconfig/Makefile.kconf create mode 100644 tools/kconfig/devices.kconf create mode 100644 tools/kconfig/files.kconf create mode 100644 tools/kconfig/max32/MAX32 diff --git a/tools/kconfig/.gitignore b/tools/kconfig/.gitignore new file mode 100644 index 0000000..393baec --- /dev/null +++ b/tools/kconfig/.gitignore @@ -0,0 +1,2 @@ +y.tab.h +kconfig diff --git a/tools/kconfig/Makefile b/tools/kconfig/Makefile index 106e16f..1b5becc 100644 --- a/tools/kconfig/Makefile +++ b/tools/kconfig/Makefile @@ -1,5 +1,5 @@ CC = gcc -g -CFLAGS = -O -Wall +CFLAGS = -O -Wall -Werror YACC = byacc -d DESTDIR = /usr/local OBJS = config.o main.o lang.o mkioconf.o mkmakefile.o mkheaders.o \ diff --git a/tools/kconfig/Makefile.kconf b/tools/kconfig/Makefile.kconf new file mode 100644 index 0000000..3b587c4 --- /dev/null +++ b/tools/kconfig/Makefile.kconf @@ -0,0 +1,149 @@ +# +# Makefile for 4.4 BSD, pic32 target +# +# This makefile is constructed from a machine description: +# config machineid +# Most changes should be made in the machine description +# /sys/conf/``machineid'' +# after which you should do +# config machineid +# Machine generic makefile changes should be made in +# /sys/conf/Makefile.``machinetype'' +# after which config should be rerun for all machines of that type. +# +# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE +# IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING +# +# -DTRACE compile in kernel tracing hooks +# -DQUOTA compile in file system quotas +# +# DEBUG is set to -g by config if debugging is requested (config -g). +# PROF is set to -pg by config if profiling is requested (config -p). + +.if exists(${MIPS_GCC_ROOT}/bin/mips-sde-elf-gcc) +MIPS_GCC_PREFIX ?= ${MIPS_GCC_ROOT}/bin/mips-sde-elf- +.endif +.if exists(${MIPS_GCC_ROOT}/bin/mips-elf-gcc) +MIPS_GCC_PREFIX ?= ${MIPS_GCC_ROOT}/bin/mips-elf- +.endif + +AS= ${MIPS_GCC_PREFIX}as ${DEBUG} -mips32r2 -EL +CC= ${MIPS_GCC_PREFIX}gcc ${DEBUG} -mips32r2 -EL -msoft-float -nostdinc -fno-builtin -Werror -Wall +CPP= ${MIPS_GCC_PREFIX}cpp +LD= ${MIPS_GCC_PREFIX}gcc -mips32r2 -EL +LDFLAGS= -nostdlib -T $A/${LDSCRIPT} -Wl,-Map=vmunix.map +SIZE= ${MIPS_GCC_PREFIX}size +OBJCOPY= ${MIPS_GCC_PREFIX}objcopy +OBJDUMP= ${MIPS_GCC_PREFIX}objdump + +.if exists(${MIPS_GCC_ROOT}/bin/mips-elf-gcc) +LDFLAGS+= -Wl,--oformat=elf32-littlemips +.endif + +# source tree is located via $S relative to the compilation directory +S= ../.. +A= $S/mips + +COPTS= -I. -I$S ${IDENT} -DKERNEL +CFLAGS= -O ${COPTS} + +# compile rules: rules are named ${TYPE}_${SUFFIX}${CONFIG_DEP} +# where TYPE is NORMAL, DRIVER, or PROFILE}; SUFFIX is the file suffix, +# capitalized (e.g. C for a .c file), and CONFIG_DEP is _C if the file +# is marked as config-dependent. + +NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} $< +NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $< + +DRIVER_C= ${CC} -c ${CFLAGS} ${PROF} $< +DRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $< + +PROFILE_C= ${CC} -p -c ${COPTS} $< + +NORMAL_S= ${CPP} ${COPTS} $< | ${AS} -o $@ +NORMAL_S_C= ${CPP} ${COPTS} ${PARAM} $< | ${AS} -o $@ + +%OBJS + +%CFILES + +# load lines for config "xxx" will be emitted as: +# xxx: ${SYSTEM_DEP} swapxxx.o +# ${SYSTEM_LD_HEAD} +# ${SYSTEM_LD} swapxxx.o +# ${SYSTEM_LD_TAIL} +SYSTEM_OBJ= locore.o ${OBJS} param.o ioconf.o vnode_if.o +SYSTEM_DEP= Makefile ${SYSTEM_OBJ} $S/libkern/libkern.a +SYSTEM_LD_HEAD= sh $S/conf/newvers.sh; ${CC} $(CFLAGS) -c vers.c; rm -f $@ +SYSTEM_LD= -@echo ${LD} ${LDFLAGS} '$${SYSTEM_OBJ}' vers.o -L$S/libkern -lkern -o vmunix.elf; \ + ${LD} ${LDFLAGS} ${SYSTEM_OBJ} vers.o -L$S/libkern -lkern -o vmunix.elf +SYSTEM_LD_TAIL= ${SIZE} vmunix.elf; \ + $(OBJCOPY) -O ihex --change-addresses=0x80000000 $@ vmunix.hex; \ + $(OBJDUMP) -d -S vmunix.elf > vmunix.dis + +%LOAD + +$S/libkern/libkern.a: + cd $S/libkern && ${MAKE} all + +clean: + rm -f eddep *vmunix.elf vmunix.gdb tags *.o locore.i [a-z]*.s \ + Errs errs linterrs makelinks + +lint: /tmp param.c + @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} ${PARAM} -UKGDB \ + $A/pic32/Locore.c ${CFILES} $A/pic32/swapgeneric.c \ + ioconf.c param.c + +symbols.sort: $A/pic32/symbols.raw + grep -v '^#' $A/pic32/symbols.raw \ + | sed 's/^ //' | sort -u > symbols.sort + +locore.o: $A/pic32/locore.s $A/include/machAsmDefs.h \ + $A/include/machConst.h $A/include/reg.h $A/include/assym.h + ${CPP} ${COPTS} ${PARAM} -DLOCORE $A/pic32/locore.s | \ + ${AS} -o locore.o + +# the following is necessary because autoconf.o depends on #if GENERIC +autoconf.o: Makefile + +# the following are necessary because the files depend on the types of +# cpu's included in the system configuration +clock.o machdep.o autoconf.o conf.o: Makefile + +# depend on network configuration +uipc_proto.o vfs_conf.o: Makefile + +machine: + ln -s $A/include $@ + +depend: machine param.c vnode_if.h + mkdep ${COPTS} ${CFILES} ioconf.c param.c + +links: + egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ + sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink + echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ + sort -u | comm -23 - dontlink | \ + sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks + sh makelinks && rm -f dontlink + +tags: + @echo "see $S/kern/Makefile for tags" + +ioconf.o: ioconf.c + ${CC} -c ${CFLAGS} ioconf.c + +param.c: $S/conf/param.c + rm -f param.c + cp $S/conf/param.c . + +param.o: param.c Makefile + ${CC} -c ${CFLAGS} ${PARAM} param.c + +vnode_if.c: $S/kern/vnode_if.sh $S/kern/vnode_if.src + sh $S/kern/vnode_if.sh $S/kern/vnode_if.src +vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src + sh $S/kern/vnode_if.sh $S/kern/vnode_if.src + +%RULES diff --git a/tools/kconfig/config.y b/tools/kconfig/config.y index c7bb148..aa89a34 100644 --- a/tools/kconfig/config.y +++ b/tools/kconfig/config.y @@ -155,7 +155,7 @@ Config_spec: = { struct cputype *cp = (struct cputype *)malloc(sizeof (struct cputype)); - cp->cpu_name = ns($2); + cp->cpu_name = strdup($2); cp->cpu_next = cputype; cputype = cp; free(temp_id); @@ -166,10 +166,10 @@ Config_spec: MAKEOPTIONS Mkopt_list | IDENT ID - = { ident = ns($2); } + = { ident = strdup($2); } | LDSCRIPT ID - = { ldscript = ns($2); } + = { ldscript = strdup($2); } | System_spec | @@ -360,7 +360,8 @@ device_name: char buf[80]; (void) sprintf(buf, "%s%d", $1, $2); - $$ = ns(buf); free($1); + $$ = strdup(buf); + free($1); } | Save_id NUMBER ID @@ -368,7 +369,8 @@ device_name: char buf[80]; (void) sprintf(buf, "%s%d%s", $1, $2, $3); - $$ = ns(buf); free($1); + $$ = strdup(buf); + free($1); } ; @@ -382,7 +384,7 @@ Option: Save_id = { struct opt *op = (struct opt *)malloc(sizeof (struct opt)); - op->op_name = ns($1); + op->op_name = strdup($1); op->op_next = opt; op->op_value = 0; opt = op; @@ -392,9 +394,9 @@ Option: Save_id EQUALS Opt_value = { struct opt *op = (struct opt *)malloc(sizeof (struct opt)); - op->op_name = ns($1); + op->op_name = strdup($1); op->op_next = opt; - op->op_value = ns($3); + op->op_value = strdup($3); opt = op; free(temp_id); free(val_id); @@ -403,19 +405,19 @@ Option: Opt_value: ID - = { $$ = val_id = ns($1); } + = { $$ = val_id = strdup($1); } | NUMBER = { char nb[16]; (void) sprintf(nb, "%d", $1); - $$ = val_id = ns(nb); + $$ = val_id = strdup(nb); } ; Save_id: ID - = { $$ = temp_id = ns($1); } + = { $$ = temp_id = strdup($1); } ; Mkopt_list: @@ -428,9 +430,9 @@ Mkoption: Save_id EQUALS Opt_value = { struct opt *op = (struct opt *)malloc(sizeof (struct opt)); - op->op_name = ns($1); + op->op_name = strdup($1); op->op_next = mkopt; - op->op_value = ns($3); + op->op_value = strdup($3); mkopt = op; free(temp_id); free(val_id); @@ -439,7 +441,7 @@ Mkoption: Dev: ID - = { $$ = ns($1); } + = { $$ = strdup($1); } ; Device_spec: @@ -621,20 +623,6 @@ void yyerror(s) fprintf(stderr, "config: line %d: %s\n", yyline + 1, s); } -/* - * return the passed string in a new space - */ -char * -ns(str) - register char *str; -{ - register char *cp; - - cp = malloc((unsigned)(strlen(str)+1)); - (void) strcpy(cp, str); - return (cp); -} - /* * add a device to the list of devices */ @@ -725,9 +713,9 @@ void mkswap(system, fl, size, flag) if (system->f_fn) return; if (eq(fl->f_fn, "generic")) - system->f_fn = ns(fl->f_fn); + system->f_fn = strdup(fl->f_fn); else - system->f_fn = ns(system->f_needs); + system->f_fn = strdup(system->f_needs); } void mkcomp(dp) @@ -739,9 +727,9 @@ void mkcomp(dp) fl = (struct file_list *) malloc(sizeof *fl); fl->f_type = COMPDEVICE; fl->f_compinfo = dp->d_unit; - fl->f_fn = ns(dp->d_name); + fl->f_fn = strdup(dp->d_name); (void) sprintf(buf, "%s%d", dp->d_name, dp->d_unit); - fl->f_needs = ns(buf); + fl->f_needs = strdup(buf); fl->f_next = 0; for (flp = compp; *flp; flp = &(*flp)->f_next) ; @@ -839,7 +827,7 @@ huhcon(dev) dp = &rdev; init_dev(dp); dp->d_unit = QUES; - dp->d_name = ns(dev); + dp->d_name = strdup(dev); dp->d_type = oldtype; newdev(dp); dp = curp; diff --git a/tools/kconfig/devices.kconf b/tools/kconfig/devices.kconf new file mode 100644 index 0000000..20f486e --- /dev/null +++ b/tools/kconfig/devices.kconf @@ -0,0 +1 @@ +sd 0 diff --git a/tools/kconfig/files.kconf b/tools/kconfig/files.kconf new file mode 100644 index 0000000..42db771 --- /dev/null +++ b/tools/kconfig/files.kconf @@ -0,0 +1,179 @@ +isofs/cd9660/cd9660_bmap.c optional cd9660 +isofs/cd9660/cd9660_lookup.c optional cd9660 +isofs/cd9660/cd9660_node.c optional cd9660 +isofs/cd9660/cd9660_rrip.c optional cd9660 +isofs/cd9660/cd9660_util.c optional cd9660 +isofs/cd9660/cd9660_vfsops.c optional cd9660 +isofs/cd9660/cd9660_vnops.c optional cd9660 +kern/init_main.c standard +kern/init_sysent.c standard +kern/kern_acct.c standard +kern/kern_clock.c standard +kern/kern_descrip.c standard +kern/kern_exec.c standard +kern/kern_exit.c standard +kern/kern_fork.c standard +kern/kern_ktrace.c standard +kern/kern_malloc.c standard +kern/kern_physio.c standard +kern/kern_proc.c standard +kern/kern_prot.c standard +kern/kern_resource.c standard +kern/kern_sig.c standard +kern/kern_subr.c standard +kern/kern_synch.c standard +kern/kern_sysctl.c standard +kern/kern_time.c standard +kern/kern_xxx.c standard +kern/kern_lock.c standard +kern/subr_log.c standard +kern/subr_prf.c standard +kern/subr_prof.c standard +kern/subr_rmap.c standard +kern/subr_xxx.c standard +kern/sys_generic.c standard +kern/sys_process.c standard +kern/sys_socket.c standard +kern/sysv_shm.c optional sysvshm +kern/tty.c standard +kern/tty_compat.c standard +kern/tty_conf.c standard +kern/tty_pty.c optional pty +kern/tty_subr.c standard +kern/tty_tb.c optional tb +kern/tty_tty.c standard +kern/uipc_domain.c standard +kern/uipc_mbuf.c standard +kern/uipc_proto.c standard +kern/uipc_socket.c standard +kern/uipc_socket2.c standard +kern/uipc_syscalls.c standard +kern/uipc_usrreq.c standard +kern/vfs_bio.c standard +kern/vfs_cache.c standard +kern/vfs_cluster.c standard +kern/vfs_conf.c standard +kern/vfs_init.c standard +kern/vfs_lookup.c standard +kern/vfs_subr.c standard +kern/vfs_syscalls.c standard +kern/vfs_vnops.c standard +miscfs/deadfs/dead_vnops.c standard +miscfs/fdesc/fdesc_vfsops.c optional fdesc +miscfs/fdesc/fdesc_vnops.c optional fdesc +miscfs/fifofs/fifo_vnops.c optional fifo +miscfs/kernfs/kernfs_vfsops.c optional kernfs +miscfs/kernfs/kernfs_vnops.c optional kernfs +miscfs/nullfs/null_subr.c optional nullfs +miscfs/nullfs/null_vfsops.c optional nullfs +miscfs/nullfs/null_vnops.c optional nullfs +miscfs/portal/portal_vfsops.c optional portal +miscfs/portal/portal_vnops.c optional portal +miscfs/procfs/procfs_subr.c optional procfs +miscfs/procfs/procfs_vnops.c optional procfs +miscfs/procfs/procfs_vfsops.c optional procfs +miscfs/procfs/procfs_note.c optional procfs +miscfs/procfs/procfs_mem.c optional procfs +miscfs/procfs/procfs_ctl.c optional procfs +miscfs/procfs/procfs_status.c optional procfs +miscfs/procfs/procfs_regs.c optional procfs +miscfs/procfs/procfs_fpregs.c optional procfs +miscfs/specfs/spec_vnops.c standard +miscfs/umapfs/umap_subr.c optional umapfs +miscfs/umapfs/umap_vfsops.c optional umapfs +miscfs/umapfs/umap_vnops.c optional umapfs +miscfs/union/union_subr.c optional union +miscfs/union/union_vfsops.c optional union +miscfs/union/union_vnops.c optional union +net/bpf.c optional bpfilter +net/bpf_filter.c optional bpfilter +net/if.c standard +net/if_ethersubr.c optional ether +net/if_loop.c optional loop +net/if_sl.c optional sl +net/radix.c standard +net/raw_cb.c standard +net/raw_usrreq.c standard +net/route.c standard +net/rtsock.c standard +net/slcompress.c optional sl +netinet/if_ether.c optional ether +netinet/igmp.c optional inet +netinet/in.c optional inet +netinet/in_pcb.c optional inet +netinet/in_proto.c optional inet +netinet/ip_icmp.c optional inet +netinet/ip_input.c optional inet +netinet/ip_mroute.c optional inet mrouting +netinet/ip_output.c optional inet +netinet/raw_ip.c optional inet +netinet/tcp_debug.c optional inet +netinet/tcp_input.c optional inet +netinet/tcp_output.c optional inet +netinet/tcp_subr.c optional inet +netinet/tcp_timer.c optional inet +netinet/tcp_usrreq.c optional inet +netinet/udp_usrreq.c optional inet +nfs/nfs_bio.c optional nfs +nfs/nfs_node.c optional nfs +nfs/nfs_nqlease.c optional nfs +nfs/nfs_serv.c optional nfs +nfs/nfs_socket.c optional nfs +nfs/nfs_srvcache.c optional nfs +nfs/nfs_subs.c optional nfs +nfs/nfs_syscalls.c optional nfs +nfs/nfs_vfsops.c optional nfs +nfs/nfs_vnops.c optional nfs +ufs/ffs/ffs_alloc.c optional ffs +ufs/ffs/ffs_alloc.c optional mfs +ufs/ffs/ffs_balloc.c optional ffs +ufs/ffs/ffs_balloc.c optional mfs +ufs/ffs/ffs_inode.c optional ffs +ufs/ffs/ffs_inode.c optional mfs +ufs/ffs/ffs_subr.c optional ffs +ufs/ffs/ffs_subr.c optional mfs +ufs/ffs/ffs_tables.c optional ffs +ufs/ffs/ffs_tables.c optional mfs +ufs/ffs/ffs_vfsops.c optional ffs +ufs/ffs/ffs_vfsops.c optional mfs +ufs/ffs/ffs_vnops.c optional ffs +ufs/ffs/ffs_vnops.c optional mfs +ufs/lfs/lfs_alloc.c optional lfs +ufs/lfs/lfs_bio.c optional lfs +ufs/lfs/lfs_balloc.c optional lfs +ufs/lfs/lfs_cksum.c optional lfs +ufs/lfs/lfs_debug.c optional lfs +ufs/lfs/lfs_inode.c optional lfs +ufs/lfs/lfs_segment.c optional lfs +ufs/lfs/lfs_subr.c optional lfs +ufs/lfs/lfs_syscalls.c optional lfs +ufs/lfs/lfs_vfsops.c optional lfs +ufs/lfs/lfs_vnops.c optional lfs +ufs/mfs/mfs_vfsops.c optional mfs +ufs/mfs/mfs_vnops.c optional mfs +ufs/ufs/ufs_bmap.c standard +ufs/ufs/ufs_disksubr.c standard +ufs/ufs/ufs_ihash.c standard +ufs/ufs/ufs_inode.c standard +ufs/ufs/ufs_lockf.c standard +ufs/ufs/ufs_lookup.c standard +ufs/ufs/ufs_quota.c standard +ufs/ufs/ufs_vfsops.c standard +ufs/ufs/ufs_vnops.c standard +vm/device_pager.c optional devpager +vm/swap_pager.c optional swappager +vm/vm_fault.c standard +vm/vm_glue.c standard +vm/vm_init.c standard +vm/vm_kern.c standard +vm/vm_map.c standard +vm/vm_meter.c standard +vm/vm_mmap.c standard +vm/vm_object.c standard +vm/vm_page.c standard +vm/vm_pageout.c standard +vm/vm_pager.c standard +vm/vm_swap.c standard +vm/vm_unix.c standard +vm/vm_user.c standard +vm/vnode_pager.c optional vnodepager diff --git a/tools/kconfig/main.c b/tools/kconfig/main.c index 065d755..6ad3ae2 100644 --- a/tools/kconfig/main.c +++ b/tools/kconfig/main.c @@ -49,12 +49,7 @@ int main(argc, argv) int argc; char **argv; { - - extern char *optarg; - extern int optind; - struct stat buf; int ch; - char *p; while ((ch = getopt(argc, argv, "gp")) != EOF) switch (ch) { @@ -72,25 +67,29 @@ int main(argc, argv) argv += optind; if (argc != 1) { -usage: fputs("usage: config [-gp] sysname\n", stderr); +usage: fputs("usage: kconfig [-gp] sysname\n", stderr); exit(1); } - if (freopen(PREFIX = *argv, "r", stdin) == NULL) { + PREFIX = *argv; + if (! freopen(PREFIX, "r", stdin)) { perror(PREFIX); exit(2); } +#if 0 mkdir("../../compile", 0777); - if (stat(p = path((char *)NULL), &buf)) { - if (mkdir(p, 0777)) { + char *p = path((char *)NULL); + struct stat buf; + if (stat(p, &buf) < 0) { + if (mkdir(p, 0777) < 0) { perror(p); exit(2); } - } - else if ((buf.st_mode & S_IFMT) != S_IFDIR) { + } else if ((buf.st_mode & S_IFMT) != S_IFDIR) { fprintf(stderr, "config: %s isn't a directory.\n", p); exit(2); } +#endif dtab = NULL; confp = &conf_list; @@ -208,6 +207,9 @@ char * path(file) char *file; { +#if 1 + return file; +#else register char *cp; #define CDIR "../../compile/" @@ -221,4 +223,5 @@ path(file) (void) strcat(cp, file); } return (cp); +#endif } diff --git a/tools/kconfig/max32/MAX32 b/tools/kconfig/max32/MAX32 new file mode 100644 index 0000000..b36951d --- /dev/null +++ b/tools/kconfig/max32/MAX32 @@ -0,0 +1,74 @@ +# +# chipKIT Max32 board +# +# To build the kernel, use: +# cd sys/pic32/max32 +# kconfig MAX32 +# make clean depend +# make depend +# make +# +machine "pic32" + +cpu "PIC32MX" +ident CHIPKIT-MAX + +# Linker script +ldscript "pic32/bootloader-max32.ld" + +# Need to set locally +timezone 8 dst +maxusers 2 + +# Standard system options +options "CPU_KHZ=80000" # Oscillator frequency of CPU core +options "HZ=100" # Frequency of clock interrupt + +# Root filesystem at /dev/sd0a, swap at /dev/sd0b +config unix root on major 0 minor 1 + swap on major 0 minor 2 + dumps on major 0 minor 2 + +# UART ports +device uart1 flags 0x614f # pins rx=RD14, tx=RD15 - logical 39/40 +device uart4 flags 0x6268 # pins rx=RF2, tx=RF8 - serial-to-USB converter + +# Use UART4 as console +options "CONS_MAJOR=17" # UART device +options "CONS_MINOR=3" # UART4 - chipKIT WiFire board + +# SPI ports +controller spi2 flags 0x2a34 # pins sdi=RB10, sdo=RC4 - SD card + +# microSD card +disk sd0 at spi2 drive 0 flags 0x33 # select pin RC3 +options "SD_LED=0x7f" # LED4 is G15 + +# General purpose I/O ports +# Flags define a mask of available pins +# The following pins excluded: +# D14, D15 - uart1 +# F2, F8 - uart4 +# C1, D1, F1, - spi1 +# D11, F0, G6 - spi2, LED1 +# B10, B14, C3, C4 - spi3, SD card +# A15, D9, D10, F4, F5, G0, G1 - spi4, Wi-Fi +# B12 - 1/11 of input voltage +# B13 - potentiometer +#device gpio0 flags 0x46ff # port A +#device gpio1 flags 0x8bff # port B +#device gpio2 flags 0xf004 # port C +#device gpio3 flags 0x303d # port D +#device gpio4 flags 0x03ff # port E +#device gpio5 flags 0x3008 # port F +#device gpio6 flags 0xf380 # port G + +#device adc +#device pwm +#device skel + +# Buttons +options "BUTTON1=0x15" # button 1 at pin RA5 +options "BUTTON2=0x14" # button 2 at pin RA4 + +#pseudo-device pty 4 # pseudo ptys diff --git a/tools/kconfig/mkheaders.c b/tools/kconfig/mkheaders.c index 9cf7191..4dd31f3 100644 --- a/tools/kconfig/mkheaders.c +++ b/tools/kconfig/mkheaders.c @@ -70,7 +70,7 @@ void do_header(dev, hname, count) break; if ((inw = get_word(inf)) == 0 || inw == (char *)EOF) break; - inw = ns(inw); + inw = strdup(inw); cp = get_word(inf); if (cp == 0 || cp == (char *)EOF) break; diff --git a/tools/kconfig/mkmakefile.c b/tools/kconfig/mkmakefile.c index de13b1b..752ef29 100644 --- a/tools/kconfig/mkmakefile.c +++ b/tools/kconfig/mkmakefile.c @@ -152,8 +152,7 @@ void read_files() int nreqs, first = 1, configdep, isdup, std, filetype; ftab = 0; - (void) strcpy(fname, "../../conf/files"); -openit: + (void) strcpy(fname, "../files.kconf"); fp = fopen(fname, "r"); if (fp == 0) { perror(fname); @@ -169,11 +168,6 @@ next: if (wd == (char *)EOF) { (void) fclose(fp); if (first == 1) { - (void) sprintf(fname, "files.%s", machinename); - first++; - goto openit; - } - if (first == 2) { (void) sprintf(fname, "files.%s", raise(ident)); first++; fp = fopen(fname, "r"); @@ -184,7 +178,7 @@ next: } if (wd == 0) goto next; - this = ns(wd); + this = strdup(wd); next_word(fp, wd); if (wd == 0) { printf("%s: No type for %s.\n", @@ -226,7 +220,7 @@ nextparam: fname); exit(1); } - special = ns(wd); + special = strdup(wd); goto nextparam; } nreqs++; @@ -239,7 +233,7 @@ nextparam: goto nextparam; } if (needs == 0 && nreqs == 1) - needs = ns(wd); + needs = strdup(wd); if (isdup) goto invis; for (dp = dtab; dp != 0; save_dp = dp, dp = dp->d_next) @@ -252,7 +246,7 @@ nextparam: if (std) { dp = (struct device *) malloc(sizeof *dp); init_dev(dp); - dp->d_name = ns(wd); + dp->d_name = strdup(wd); dp->d_type = PSEUDO_DEVICE; dp->d_slave = 1; if (save_dp) @@ -471,8 +465,8 @@ void makefile() struct users *up; read_files(); - strcpy(line, "Makefile."); - (void) strcat(line, machinename); + strcpy(line, "../Makefile.kconf"); + //(void) strcat(line, machinename); ifp = fopen(line, "r"); if (ifp == 0) { perror(line); diff --git a/tools/kconfig/mkswapconf.c b/tools/kconfig/mkswapconf.c index dd5fa14..0aff12d 100644 --- a/tools/kconfig/mkswapconf.c +++ b/tools/kconfig/mkswapconf.c @@ -122,7 +122,7 @@ void initdevtable() register struct devdescription **dp = &devtable; FILE *fp; - (void) sprintf(buf, "../conf/devices.%s", machinename); + (void) sprintf(buf, "../devices.kconf"); fp = fopen(buf, "r"); if (fp == NULL) { fprintf(stderr, "config: can't open %s\n", buf); @@ -130,7 +130,7 @@ void initdevtable() } while (fscanf(fp, "%s\t%d\n", buf, &maj) == 2) { *dp = (struct devdescription *)malloc(sizeof (**dp)); - (*dp)->dev_name = ns(buf); + (*dp)->dev_name = strdup(buf); (*dp)->dev_major = maj; dp = &(*dp)->dev_next; } @@ -211,5 +211,5 @@ devtoname(dev) dp = devtable; (void) sprintf(buf, "%s%d%c", dp->dev_name, minor(dev) >> 3, (minor(dev) & 07) + 'a'); - return (ns(buf)); + return strdup(buf); } From ce8371152f135e914d1fbb1c13e5a7a9977aaa83 Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Mon, 1 Jun 2015 19:48:56 -0700 Subject: [PATCH 6/8] Kconfig: fixed function declarations. --- tools/kconfig/Makefile | 6 +++++ tools/kconfig/config.h | 28 ++++++++++------------ tools/kconfig/lang.l | 6 ++--- tools/kconfig/main.c | 48 ++------------------------------------ tools/kconfig/mkheaders.c | 4 +--- tools/kconfig/mkioconf.c | 10 ++------ tools/kconfig/mkmakefile.c | 6 ++--- tools/kconfig/mkswapconf.c | 7 +++--- 8 files changed, 31 insertions(+), 84 deletions(-) diff --git a/tools/kconfig/Makefile b/tools/kconfig/Makefile index 1b5becc..3553bae 100644 --- a/tools/kconfig/Makefile +++ b/tools/kconfig/Makefile @@ -15,3 +15,9 @@ clean: $(PROG): $(OBJS) $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) + +main.o: main.c y.tab.h config.h +mkheaders.o: mkheaders.c config.h y.tab.h +mkioconf.o: mkioconf.c y.tab.h config.h +mkmakefile.o: mkmakefile.c y.tab.h config.h +mkswapconf.o: mkswapconf.c config.h diff --git a/tools/kconfig/config.h b/tools/kconfig/config.h index dca3f9c..7a42a11 100644 --- a/tools/kconfig/config.h +++ b/tools/kconfig/config.h @@ -39,6 +39,7 @@ #include #include #include +#include #define NODEV ((dev_t)-1) @@ -159,22 +160,12 @@ struct opt { char *ident; char *ldscript; -char *ns(); -char *tc(); -char *qu(); -char *get_word(); -char *get_quoted_word(); -char *path(); -char *raise(); int do_trace; int seen_cd; -struct device *connect(); struct device *dtab; -dev_t nametodev(); -char *devtoname(); char errbuf[80]; int yyline; @@ -191,9 +182,14 @@ int maxusers; #define eq(a,b) (!strcmp(a,b)) -void init_dev(register struct device *dp); -int yyparse(void); -void pic32_ioconf(void); -void makefile(void); -void headers(void); -void swapconf(void); +char *get_word(FILE *); +char *get_quoted_word(FILE *); +char *raise(char *); +dev_t nametodev(char *, int, char); +char *devtoname(dev_t); +void init_dev(struct device *); +int yyparse(void); +void pic32_ioconf(void); +void makefile(void); +void headers(void); +void swapconf(void); diff --git a/tools/kconfig/lang.l b/tools/kconfig/lang.l index be4276e..4e38c00 100644 --- a/tools/kconfig/lang.l +++ b/tools/kconfig/lang.l @@ -165,7 +165,7 @@ WORD [A-Za-z_][-A-Za-z_]* */ int kw_lookup(word) -register char *word; + register char *word; { register struct kt *kp; @@ -180,7 +180,7 @@ register char *word; */ int octal(str) -char *str; + char *str; { int num; @@ -190,7 +190,7 @@ char *str; int hex(str) -char *str; + char *str; { int num; diff --git a/tools/kconfig/main.c b/tools/kconfig/main.c index 6ad3ae2..ee5d6c5 100644 --- a/tools/kconfig/main.c +++ b/tools/kconfig/main.c @@ -33,14 +33,11 @@ #include #include #include -#include #include #include #include "y.tab.h" #include "config.h" -static char *PREFIX; - /* * Config builds a set of files for building a UNIX * system given a description of the desired system. @@ -71,25 +68,10 @@ usage: fputs("usage: kconfig [-gp] sysname\n", stderr); exit(1); } - PREFIX = *argv; - if (! freopen(PREFIX, "r", stdin)) { - perror(PREFIX); + if (! freopen(*argv, "r", stdin)) { + perror(*argv); exit(2); } -#if 0 - mkdir("../../compile", 0777); - char *p = path((char *)NULL); - struct stat buf; - if (stat(p, &buf) < 0) { - if (mkdir(p, 0777) < 0) { - perror(p); - exit(2); - } - } else if ((buf.st_mode & S_IFMT) != S_IFDIR) { - fprintf(stderr, "config: %s isn't a directory.\n", p); - exit(2); - } -#endif dtab = NULL; confp = &conf_list; @@ -199,29 +181,3 @@ get_quoted_word(fp) return ((char *)EOF); return (line); } - -/* - * prepend the path to a filename - */ -char * -path(file) - char *file; -{ -#if 1 - return file; -#else - register char *cp; - -#define CDIR "../../compile/" - - cp = malloc((unsigned int)(sizeof(CDIR) + strlen(PREFIX) + - (file ? strlen(file) : 0) + 2)); - (void) strcpy(cp, CDIR); - (void) strcat(cp, PREFIX); - if (file) { - (void) strcat(cp, "/"); - (void) strcat(cp, file); - } - return (cp); -#endif -} diff --git a/tools/kconfig/mkheaders.c b/tools/kconfig/mkheaders.c index 4dd31f3..76eec47 100644 --- a/tools/kconfig/mkheaders.c +++ b/tools/kconfig/mkheaders.c @@ -34,8 +34,6 @@ /* * Make all the .h files for the optional entries */ - -#include #include #include "config.h" #include "y.tab.h" @@ -179,7 +177,7 @@ toheader(dev) { static char hbuf[80]; - (void) strcpy(hbuf, path(dev)); + (void) strcpy(hbuf, dev); (void) strcat(hbuf, ".h"); return (hbuf); } diff --git a/tools/kconfig/mkioconf.c b/tools/kconfig/mkioconf.c index 3b763b1..b56e11b 100644 --- a/tools/kconfig/mkioconf.c +++ b/tools/kconfig/mkioconf.c @@ -30,8 +30,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -#include #include "y.tab.h" #include "config.h" @@ -90,10 +88,6 @@ pseudo_ioconf(fp) */ if (seen_cd) (void)fprintf(fp, "extern void cdattach __P((int));\n"); - /* XXX temporary for HP300, others */ - (void)fprintf(fp, "\n#include /* XXX */\n"); - (void)fprintf(fp, "#define etherattach (void (*)__P((int)))nullop\n"); - (void)fprintf(fp, "#define iteattach (void (*) __P((int)))nullop\n"); (void)fprintf(fp, "\nstruct pdevinit pdevinit[] = {\n"); for (dp = dtab; dp != NULL; dp = dp->d_next) if (dp->d_type == PSEUDO_DEVICE) @@ -131,9 +125,9 @@ void pic32_ioconf() register struct device *dp, *mp; FILE *fp; - fp = fopen(path("ioconf.c"), "w"); + fp = fopen("ioconf.c", "w"); if (fp == 0) { - perror(path("ioconf.c")); + perror("ioconf.c"); exit(1); } fprintf(fp, "#include \"sys/types.h\"\n"); diff --git a/tools/kconfig/mkmakefile.c b/tools/kconfig/mkmakefile.c index 752ef29..88538e4 100644 --- a/tools/kconfig/mkmakefile.c +++ b/tools/kconfig/mkmakefile.c @@ -36,8 +36,6 @@ * the information in the files files and the * additional files for the machine being compiled to. */ - -#include #include #include "y.tab.h" #include "config.h" @@ -472,9 +470,9 @@ void makefile() perror(line); exit(1); } - ofp = fopen(path("Makefile"), "w"); + ofp = fopen("Makefile", "w"); if (ofp == 0) { - perror(path("Makefile")); + perror("Makefile"); exit(1); } fprintf(ofp, "IDENT=-D%s", raise(ident)); diff --git a/tools/kconfig/mkswapconf.c b/tools/kconfig/mkswapconf.c index 0aff12d..c7cfefd 100644 --- a/tools/kconfig/mkswapconf.c +++ b/tools/kconfig/mkswapconf.c @@ -36,7 +36,6 @@ */ #include "config.h" -#include #include #include @@ -69,9 +68,9 @@ do_swap(fl) return (fl->f_next); } (void) sprintf(swapname, "swap%s.c", fl->f_fn); - fp = fopen(path(swapname), "w"); + fp = fopen(swapname, "w"); if (fp == 0) { - perror(path(swapname)); + perror(swapname); exit(1); } fprintf(fp, "#include \"sys/param.h\"\n"); @@ -84,7 +83,7 @@ do_swap(fl) */ swap = fl->f_next; if (swap == 0 || swap->f_type != SWAPSPEC) { - (void) unlink(path(swapname)); + (void) unlink(swapname); fclose(fp); return (swap); } From 428764c187f6e10191b670885992828f08ad9177 Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Mon, 1 Jun 2015 21:43:57 -0700 Subject: [PATCH 7/8] SD diag utility moved to tools. Makefile for Retro 1 kernel modified to get rid of file drivers.mk. --- sys/pic32/devcfg.c | 20 -------------- sys/pic32/drivers.mk | 43 ------------------------------ sys/pic32/retroone/Makefile | 41 +++++++++++----------------- sys/pic32/retroone/README | 2 ++ {sys/pic32 => tools}/diag/Makefile | 26 +----------------- {sys/pic32 => tools}/diag/main.c | 0 6 files changed, 19 insertions(+), 113 deletions(-) delete mode 100644 sys/pic32/devcfg.c delete mode 100644 sys/pic32/drivers.mk create mode 100644 sys/pic32/retroone/README rename {sys/pic32 => tools}/diag/Makefile (85%) rename {sys/pic32 => tools}/diag/main.c (100%) diff --git a/sys/pic32/devcfg.c b/sys/pic32/devcfg.c deleted file mode 100644 index 5418445..0000000 --- a/sys/pic32/devcfg.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Chip configuration. - */ -#include "machine/pic32mx.h" - -PIC32_DEVCFG ( - 0| DC0_DEBUG | DC0_ICE, - - 0| DC1_FNOSC | DC1_SOSC | DC1_IESO | DC1_POSCMOD | - DC1_OSCIOFNC | DC1_PBDIV | DC1_CKM | DC1_CKS | - DC1_WDTPS | DC1_WDTEN, - - 0| DC2_PLLIDIV | DC2_PLLMUL | DC2_UPLLIDIV | DC2_UPLL | - DC2_PLLODIV, - - 0| DEVCFG3_USERID(DC3_USERID) | DC3_SRS | DC3_MII | - DC3_ETH | DC3_CAN | DC3_USBID | DC3_VBUSON -); - - diff --git a/sys/pic32/drivers.mk b/sys/pic32/drivers.mk deleted file mode 100644 index 7729900..0000000 --- a/sys/pic32/drivers.mk +++ /dev/null @@ -1,43 +0,0 @@ -ifeq ($(DRIVER_GPIO),yes) - KERNOBJ += gpio.o - DEFS += -DGPIO_ENABLED -endif - -ifeq ($(DRIVER_POWER),yes) - KERNOBJ += power_control.o - POWER_LED_PORT ?= TRISG - POWER_LED_PIN ?= 14 - POWER_SWITCH_PORT ?= TRISE - POWER_SWITCH_PIN ?= 9 - POWER_CONTROL_PORT ?= TRISE - POWER_CONTROL_PIN ?= 9 - DEFS += -DPOWER_ENABLED -DPOWER_LED_PORT=$(POWER_LED_PORT) -DPOWER_LED_PIN=$(POWER_LED_PIN) - DEFS += -DPOWER_SWITCH_PORT=$(POWER_SWITCH_PORT) -DPOWER_SWITCH_PIN=$(POWER_SWITCH_PIN) - DEFS += -DPOWER_CONTROL_PORT=$(POWER_CONTROL_PORT) -DPOWER_CONTROL_PIN=$(POWER_CONTROL_PIN) -endif - -ifeq ($(DRIVER_ADC),yes) - KERNOBJ += adc.o - DEFS += -DADC_ENABLED -endif - -ifeq ($(DRIVER_SPI),yes) - KERNOBJ += spi.o - DEFS += -DSPI_ENABLED -endif - -ifeq ($(DRIVER_GLCD),yes) - KERNOBJ += glcd.o - DEFS += -DGLCD_ENABLED -endif - -ifeq ($(DRIVER_PWM),yes) - KERNOBJ += pwm.o - DEFS += -DPWM_ENABLED -endif - -ifeq ($(DRIVER_SDRAMP),yes) - NEEDS_FEATURE_KERNEL_EXECUTABLE_RAM = yes - KERNOBJ += sdram.o rd_sdramp.o - DEFS += -DSDRAMP_ENABLED -endif diff --git a/sys/pic32/retroone/Makefile b/sys/pic32/retroone/Makefile index 6933f26..c08ebdd 100644 --- a/sys/pic32/retroone/Makefile +++ b/sys/pic32/retroone/Makefile @@ -14,7 +14,7 @@ DEFS += -DGLOBAL_DEBUG # CPU frequency 80 MHz. DEFS += -DCPU_KHZ=80000 -DEFS += -DBUS_KHZ=80000 +DEFS += -DBUS_KHZ=80000 -DBUS_DIV=1 # # Basic pic32mx795f512l chip with internal oscillator @@ -32,28 +32,6 @@ DEFS += -DLED_KERNEL_PORT=TRISB -DLED_KERNEL_PIN=8 DEFS += -DLED_TTY_PORT=TRISB -DLED_TTY_PIN=9 DEFS += -DLED_AUX_PORT=TRISA -DLED_AUX_PIN=9 -# Include or exclude drivers - -# General Purpose I/O -DRIVER_GPIO = yes - -# Basic ADC interface -DRIVER_ADC = yes - -# Power control (power LED, and soft power-off by button) -# requires supported PSU (ATX) -DRIVER_POWER = no - -DRIVER_GLCD = yes -DRIVER_PWM = yes - -POWER_LED_PORT = TRISG -POWER_LED_PIN = 12 -POWER_SWITCH_PORT = TRISG -POWER_SWITCH_PIN = 0 -POWER_CONTROL_PORT = TRISE -POWER_CONTROL_PIN = 9 - DEPFLAGS = -MT $@ -MD -MP -MF .deps/$*.dep CFLAGS = -O $(DEFS) $(DEPFLAGS) ASFLAGS = $(DEFS) $(DEPFLAGS) @@ -97,8 +75,21 @@ KERNOBJ += vers.o devcfg.o # Include any local specific configuration overrides -include Makefile.local -# This makefile does the work including the right files and options for the drivers -include ../drivers.mk +# GPIO driver +KERNOBJ += gpio.o +DEFS += -DGPIO_ENABLED + +# ADC driver +KERNOBJ += adc.o +DEFS += -DADC_ENABLED + +# GLCD driver +KERNOBJ += glcd.o +DEFS += -DGLCD_ENABLED + +# PWM driver +KERNOBJ += pwm.o +DEFS += -DPWM_ENABLED all: .deps sys machine unix.elf $(SIZE) unix.elf diff --git a/sys/pic32/retroone/README b/sys/pic32/retroone/README new file mode 100644 index 0000000..c648880 --- /dev/null +++ b/sys/pic32/retroone/README @@ -0,0 +1,2 @@ +This directory contains an example of RetroBSD kernel build +using plain Makefile (no configsys or kconfig tools). diff --git a/sys/pic32/diag/Makefile b/tools/diag/Makefile similarity index 85% rename from sys/pic32/diag/Makefile rename to tools/diag/Makefile index ff2b8d6..0744184 100644 --- a/sys/pic32/diag/Makefile +++ b/tools/diag/Makefile @@ -12,7 +12,7 @@ DEFS += -I. -I$(H) -DKERNEL -DPIC32MX7 # CPU frequency 80 MHz. DEFS += -DCPU_KHZ=80000 -DEFS += -DBUS_KHZ=80000 +DEFS += -DBUS_KHZ=80000 -DBUS_DIV=1 # # Ethernet/USB Starter Kit with I/O Expansion board @@ -54,27 +54,6 @@ DEFS += -DLED_DISK_PORT=TRISE -DLED_DISK_PIN=1 -DLED_DISK_INVERT DEFS += -DLED_KERNEL_PORT=TRISE -DLED_KERNEL_PIN=2 -DLED_KERNEL_INVERT DEFS += -DLED_TTY_PORT=TRISE -DLED_TTY_PIN=3 -DLED_TTY_INVERT -# -# Include or exclude drivers -# - -# General Purpose I/O -DRIVER_GPIO = no - -# Basic ADC interface -DRIVER_ADC = no - -# Power control (power LED, and soft power-off by button) -# requires supported PSU (ATX) -DRIVER_POWER = no - -POWER_LED_PORT = TRISG -POWER_LED_PIN = 12 -POWER_SWITCH_PORT = TRISG -POWER_SWITCH_PIN = 0 -POWER_CONTROL_PORT = TRISE -POWER_CONTROL_PIN = 9 - DEPFLAGS = -MT $@ -MD -MP -MF .deps/$*.dep CFLAGS = -O $(DEFS) $(DEPFLAGS) ASFLAGS = $(DEFS) $(DEPFLAGS) @@ -101,9 +80,6 @@ KERNOBJ += rdisk.o rd_sd.o spi_bus.o # Include any local specific configuration overrides -include Makefile.local -# This makefile does the work including the right files and options for the drivers -include ../drivers.mk - all: .deps sys machine diag.elf $(SIZE) diag.elf diff --git a/sys/pic32/diag/main.c b/tools/diag/main.c similarity index 100% rename from sys/pic32/diag/main.c rename to tools/diag/main.c From 21ddf7fa5ab1a9a0b18267ad71afeed5c29b639b Mon Sep 17 00:00:00 2001 From: vak Date: Tue, 2 Jun 2015 00:16:15 -0700 Subject: [PATCH 8/8] Kconfig updated. --- tools/kconfig/Makefile | 8 +- tools/kconfig/config.8 | 156 -------------------------- tools/kconfig/config.h | 6 +- tools/kconfig/config.y | 146 +----------------------- tools/kconfig/kconfig.8 | 102 +++++++++++++++++ tools/kconfig/lang.l | 68 ++++------- tools/kconfig/max32/{MAX32 => Config} | 6 +- tools/kconfig/mkioconf.c | 80 +++---------- tools/kconfig/mkswapconf.c | 31 ++--- 9 files changed, 169 insertions(+), 434 deletions(-) delete mode 100644 tools/kconfig/config.8 create mode 100644 tools/kconfig/kconfig.8 rename tools/kconfig/max32/{MAX32 => Config} (93%) diff --git a/tools/kconfig/Makefile b/tools/kconfig/Makefile index 3553bae..57f981f 100644 --- a/tools/kconfig/Makefile +++ b/tools/kconfig/Makefile @@ -6,12 +6,16 @@ OBJS = config.o main.o lang.o mkioconf.o mkmakefile.o mkheaders.o \ mkswapconf.o PROG = kconfig -all: $(PROG) +all: $(PROG) $(PROG).0 install: $(PROG) install -s $(PROG) ${DESTDIR}/bin/$(PROG) + +$(PROG).0: $(PROG).8 + nroff -man $< > $@ + clean: - rm -rf *~ *.o *.lst *.dis $(PROG) $(PROG).dSYM y.tab.[ch] lang.c config.c + rm -rf *~ *.o *.lst *.dis $(PROG) $(PROG).0 $(PROG).dSYM y.tab.[ch] lang.c config.c $(PROG): $(OBJS) $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) diff --git a/tools/kconfig/config.8 b/tools/kconfig/config.8 deleted file mode 100644 index 3a2794c..0000000 --- a/tools/kconfig/config.8 +++ /dev/null @@ -1,156 +0,0 @@ -.\" Copyright (c) 1980, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)config.8 8.2 (Berkeley) 4/19/94 -.\" -.Dd April 19, 1994 -.Dt CONFIG 8 -.Os BSD 4 -.Sh NAME -.Nm kconfig -.Nd build system configuration files -.Sh SYNOPSIS -.Nm kconfig -.Op Fl p -.Ar system_name -.Sh DESCRIPTION -.Pp -.Nm Kconfig -builds a set of system configuration files from the file -.Ar SYSTEM_NAME -which describes -the system to configure. -A second file -tells -.Nm kconfig -what files are needed to generate a system and -can be augmented by configuration specific set of files -that give alternate files for a specific machine. -(see the -.Sx FILES -section below) -.Pp -Available option and operand: -.Pp -.Bl -tag -width SYSTEM_NAME -.It Fl p -If the -.Fl p -option is supplied, -.Nm kconfig -will configure a system for profiling; for example, -.Xr kgmon 8 -and -.Xr gprof 1 . -.It Ar SYSTEM_NAME -specifies the name of the system configuration file -containing device specifications, configuration options -and other system parameters for one system configuration. -.El -.Pp -.Nm Config -should be run from the -.Pa conf -subdirectory of the system source (usually -.Pa /sys/conf ) . -.Nm Config -assumes the directory -.Pa ../SYSTEM_NAME -exists and places all output files there. -The output of -.Nm kconfig -consists of a number of files; for the -.Tn VAX , -they are: -.Pa ioconf.c , -a description -of what I/O devices are attached to the system; -.Pa ubvec.s , -offsets into a structure used for counting per-device interrupts; -.Pa Makefile , -used by -.Xr make 1 -in building the system; -header files, -definitions of -the number of various devices that will be compiled into the system; -swap configuration files, -definitions for -the disk areas to be used for swapping, the root file system, -argument processing, and system dumps. -.Pp -After running -.Nm kconfig , -it is necessary to run -.Dq Li make depend -in the directory where the new makefile -was created. -.Nm Config -prints a reminder of this when it completes. -.Pp -If any other error messages are produced by -.Nm kconfig , -the problems in the configuration file should be corrected and -.Nm kconfig -should be run again. -Attempts to compile a system that had configuration errors -are likely to fail. -.Sh FILES -.Bl -tag -width /sys/conf/Makefile.pic32 -compact -.It Pa /sys/conf/Makefile.pic32 -generic makefile for the -.Tn VAX -.It Pa /sys/conf/files -list of common files system is built from -.It Pa /sys/conf/files.pic32 -list of -.Tn VAX -specific files -.It Pa /sys/conf/devices.pic32 -name to major device mapping file for the -.Tn VAX -.It Pa /sys/conf/files. Ns Em ERNIE -list of files specific to -.Em ERNIE -system -.El -.Sh SEE ALSO -The SYNOPSIS portion of each device in section 4. -.Rs -.%T "Building RetroBSD Kernel with kconfig" -.Re -.Sh BUGS -The line numbers reported in error messages are usually off by one. -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.1 . diff --git a/tools/kconfig/config.h b/tools/kconfig/config.h index 7a42a11..c08ff50 100644 --- a/tools/kconfig/config.h +++ b/tools/kconfig/config.h @@ -88,8 +88,6 @@ struct file_list { #define PROFILING 4 #define SYSTEMSPEC 5 #define SWAPSPEC 6 -#define COMPDEVICE 7 -#define COMPSPEC 8 /* * Attributes (flags). @@ -163,8 +161,6 @@ char *ldscript; int do_trace; -int seen_cd; - struct device *dtab; char errbuf[80]; @@ -185,7 +181,7 @@ int maxusers; char *get_word(FILE *); char *get_quoted_word(FILE *); char *raise(char *); -dev_t nametodev(char *, int, char); +dev_t nametodev(char *, int); char *devtoname(dev_t); void init_dev(struct device *); int yyparse(void); diff --git a/tools/kconfig/config.y b/tools/kconfig/config.y index aa89a34..e72f9c2 100644 --- a/tools/kconfig/config.y +++ b/tools/kconfig/config.y @@ -22,7 +22,6 @@ %token FLAGS %token HZ %token IDENT -%token INTERLEAVE %token LDSCRIPT %token MACHINE %token MAJOR @@ -57,11 +56,9 @@ %type optional_sflag %type device_name %type major_minor -%type arg_device_spec %type root_device_spec %type dump_device_spec %type swap_device_spec -%type comp_device_spec %{ @@ -263,7 +260,7 @@ swap_device_spec: if (eq($1, "generic")) fl->f_fn = $1; else { - fl->f_swapdev = nametodev($1, 0, 'b'); + fl->f_swapdev = nametodev($1, 0); fl->f_fn = devtoname(fl->f_swapdev); } $$ = fl; @@ -293,7 +290,7 @@ root_spec: root_device_spec: device_name - = { $$ = nametodev($1, 0, 'a'); } + = { $$ = nametodev($1, 0); } | major_minor ; @@ -312,14 +309,7 @@ dump_spec: dump_device_spec: device_name - = { $$ = nametodev($1, 0, 'b'); } - | - major_minor - ; - -arg_device_spec: - device_name - = { $$ = nametodev($1, 0, 'b'); } + = { $$ = nametodev($1, 0); } | major_minor ; @@ -469,68 +459,6 @@ Device_spec: cur.d_type = PSEUDO_DEVICE; cur.d_slave = $4; } - | - PSEUDO_DEVICE Dev_name Cdev_init Cdev_info - = { - if (!eq(cur.d_name, "cd")) - yyerror("improper spec for pseudo-device"); - seen_cd = 1; - cur.d_type = DEVICE; - verifycomp(*compp); - } - ; - -Cdev_init: - /* lambda */ - = { mkcomp(&cur); }; - -Cdev_info: - optional_on comp_device_list comp_option_list - ; - -comp_device_list: - comp_device_list AND comp_device - | - comp_device - ; - -comp_device: - comp_device_spec - = { addcomp(*compp, $1); } - ; - -comp_device_spec: - device_name - = { - struct file_list *fl = newflist(COMPSPEC); - - fl->f_compdev = nametodev($1, 0, 'c'); - fl->f_fn = devtoname(fl->f_compdev); - $$ = fl; - } - | - major_minor - = { - struct file_list *fl = newflist(COMPSPEC); - - fl->f_compdev = $1; - fl->f_fn = devtoname($1); - $$ = fl; - } - ; - -comp_option_list: - comp_option_list comp_option - | - /* lambda */ - ; - -comp_option: - INTERLEAVE NUMBER - = { cur.d_pri = $2; } - | - FLAGS NUMBER - = { cur.d_flags = $2; } ; Dev_name: @@ -556,14 +484,7 @@ Dev_info: Con_info: AT Dev NUMBER - = { - if (eq(cur.d_name, "mba") || eq(cur.d_name, "uba")) { - (void) sprintf(errbuf, - "%s must be connected to a nexus", cur.d_name); - yyerror(errbuf); - } - cur.d_conn = connect($2, $3); - } + = { cur.d_conn = connect($2, $3); } ; Info_list: @@ -712,51 +633,13 @@ void mkswap(system, fl, size, flag) */ if (system->f_fn) return; + if (eq(fl->f_fn, "generic")) system->f_fn = strdup(fl->f_fn); else system->f_fn = strdup(system->f_needs); } -void mkcomp(dp) - register struct device *dp; -{ - register struct file_list *fl, **flp; - char buf[80]; - - fl = (struct file_list *) malloc(sizeof *fl); - fl->f_type = COMPDEVICE; - fl->f_compinfo = dp->d_unit; - fl->f_fn = strdup(dp->d_name); - (void) sprintf(buf, "%s%d", dp->d_name, dp->d_unit); - fl->f_needs = strdup(buf); - fl->f_next = 0; - for (flp = compp; *flp; flp = &(*flp)->f_next) - ; - *flp = fl; - compp = flp; -} - -void addcomp(compdev, fl) - struct file_list *compdev, *fl; -{ - register struct file_list **flp; - - if (compdev == 0 || compdev->f_type != COMPDEVICE) { - yyerror("component spec precedes device specification"); - return; - } - - /* - * Append description to the end of the list. - */ - flp = &compdev->f_next; - for (; *flp && (*flp)->f_type == COMPSPEC; flp = &(*flp)->f_next) - ; - fl->f_next = *flp; - *flp = fl; -} - /* * find the pointer to connect to the given device and number. * returns 0 if no such device and prints an error message @@ -932,7 +815,7 @@ void checksystemspec(fl) yyerror(buf); } swap->f_swapdev = - makedev(major(dev), (minor(dev) &~ 07) | ('b' - 'a')); + makedev(major(dev), (minor(dev) &~ 07) | ('b' - 'a' + 1)); swap->f_fn = devtoname(swap->f_swapdev); mkswap(fl, swap, 0, 0); } @@ -1018,23 +901,6 @@ verifyswap(fl, checked, pchecked) return (pchecked); } -/* - * Verify that components of a compound device have themselves been config'ed - */ -void verifycomp(fl) - register struct file_list *fl; -{ - char *dname = fl->f_needs; - - for (fl = fl->f_next; fl; fl = fl->f_next) { - if (fl->f_type != COMPSPEC || finddev(fl->f_compdev)) - continue; - fprintf(stderr, - "config: %s: component device %s not configured\n", - dname, fl->f_needs); - } -} - /* * Has a device already been checked * for it's existence in the configuration? diff --git a/tools/kconfig/kconfig.8 b/tools/kconfig/kconfig.8 new file mode 100644 index 0000000..cb9f9c4 --- /dev/null +++ b/tools/kconfig/kconfig.8 @@ -0,0 +1,102 @@ +.Dd June 1, 2015 +.Dt CONFIG 8 +.Os RetroBSD +.Sh NAME +.Nm kconfig +.Nd build kernel configuration files +.Sh SYNOPSIS +.Nm kconfig +.Op Fl p +.Ar system_name +.Sh DESCRIPTION +.Pp +.Nm Kconfig +builds a set of kernel configuration files from the file +.Ar SYSTEM_NAME +which describes the kernel to configure. +A second file tells +.Nm kconfig +what files are needed to generate a kernel and +can be augmented by configuration specific set of files +that give alternate files for a specific machine. +(see the +.Sx FILES +section below) +.Pp +Available option and operand: +.Pp +.Bl -tag -width SYSTEM_NAME +.It Fl p +If the +.Fl p +option is supplied, +.Nm kconfig +will configure a kernel for profiling; for example, +.Xr kgmon 8 +and +.Xr gprof 1 . +.It Ar SYSTEM_NAME +specifies the name of the kernel configuration file +containing device specifications, configuration options +and other system parameters for one kernel configuration. +.El +.Pp +.Nm Kconfig +should be run from the machine and board specific +subdirectory of the system source (like +.Pa sys/pic32/max32 ) . +.Nm Kconfig +places all output files in the current directory. +The output of +.Nm kconfig +consists of a number of files: +.Pa ioconf.c , +a description +of what I/O devices are attached to the system; +.Pa Makefile , +used by +.Xr make 1 +in building the kernel; +header files, definitions of +the number of various devices that will be compiled into the kernel; +swap configuration files, definitions for +the disk areas to be used for swapping, the root file system, +argument processing, and kernel dumps. +.Pp +After running +.Nm kconfig , +it is necessary to run +.Dq Li make depend +in the directory where the new makefile +was created (current directory). +.Nm Kconfig +prints a reminder of this when it completes. +.Pp +If any other error messages are produced by +.Nm kconfig , +the problems in the configuration file should be corrected and +.Nm kconfig +should be run again. +Attempts to compile a kernel that had configuration errors +are likely to fail. +.Sh FILES +.Bl -tag -width ../Makefile.kconf -compact +.It Pa ../Makefile.kconf +generic makefile for the platform +.It Pa ../files.kconf +list of files kernel is built from +.It Pa ../devices.kconf +name to major device mapping file +.El +.Sh SEE ALSO +The SYNOPSIS portion of each device in section 4. +.Rs +.%T "Building RetroBSD Kernel with kconfig" +.Re +.Sh BUGS +The line numbers reported in error messages are usually off by one. +.Sh HISTORY +The +.Nm +command appeared in +.Bx 4.1 . diff --git a/tools/kconfig/lang.l b/tools/kconfig/lang.l index 4e38c00..08e5bd2 100644 --- a/tools/kconfig/lang.l +++ b/tools/kconfig/lang.l @@ -36,7 +36,6 @@ * * @(#)lang.l 8.1 (Berkeley) 6/6/93 */ - #include #include "y.tab.h" #include "config.h" @@ -46,11 +45,12 @@ /* * Key word table */ - struct kt { char *kt_name; int kt_val; -} key_words[] = { +}; + +static struct kt key_words[] = { { "and", AND }, { "at", AT }, { "config", CONFIG }, @@ -65,7 +65,6 @@ struct kt { { "flags", FLAGS }, { "hz", HZ }, { "ident", IDENT }, - { "interleave", INTERLEAVE }, { "ldscript", LDSCRIPT }, { "machine", MACHINE }, { "major", MAJOR }, @@ -89,9 +88,21 @@ struct kt { { 0, 0 }, }; -int kw_lookup(char *word); -int octal(char *str); -int hex(char *str); +/* + * Look up a string in the keyword table. Returns a -1 if the + * string is not a keyword otherwise it returns the keyword number + */ +static int +kw_lookup(word) + register char *word; +{ + register struct kt *kp; + + for (kp = key_words; kp->kt_name != 0; kp++) + if (eq(word, kp->kt_name)) + return kp->kt_val; + return -1; +} %} WORD [A-Za-z_][-A-Za-z_]* %% @@ -113,12 +124,12 @@ WORD [A-Za-z_][-A-Za-z_]* return ID; } 0[0-7]* { - yylval.val = octal(yytext); + yylval.val = strtoul(yytext, 0, 8); tprintf("#O:%o ", yylval.val); return NUMBER; } 0x[0-9a-fA-F]+ { - yylval.val = hex(yytext); + yylval.val = strtoul(yytext, 0, 16); tprintf("#X:%x ", yylval.val); return NUMBER; } @@ -158,42 +169,3 @@ WORD [A-Za-z_][-A-Za-z_]* . { return yytext[0]; } %% -/* - * kw_lookup - * Look up a string in the keyword table. Returns a -1 if the - * string is not a keyword otherwise it returns the keyword number - */ -int -kw_lookup(word) - register char *word; -{ - register struct kt *kp; - - for (kp = key_words; kp->kt_name != 0; kp++) - if (eq(word, kp->kt_name)) - return kp->kt_val; - return -1; -} - -/* - * Number conversion routines - */ -int -octal(str) - char *str; -{ - int num; - - (void) sscanf(str, "%o", &num); - return num; -} - -int -hex(str) - char *str; -{ - int num; - - (void) sscanf(str+2, "%x", &num); - return num; -} diff --git a/tools/kconfig/max32/MAX32 b/tools/kconfig/max32/Config similarity index 93% rename from tools/kconfig/max32/MAX32 rename to tools/kconfig/max32/Config index b36951d..7a8656d 100644 --- a/tools/kconfig/max32/MAX32 +++ b/tools/kconfig/max32/Config @@ -25,9 +25,9 @@ options "CPU_KHZ=80000" # Oscillator frequency of CPU core options "HZ=100" # Frequency of clock interrupt # Root filesystem at /dev/sd0a, swap at /dev/sd0b -config unix root on major 0 minor 1 - swap on major 0 minor 2 - dumps on major 0 minor 2 +config unix root on sd0a + swap on sd0b + dumps on sd0b # UART ports device uart1 flags 0x614f # pins rx=RD14, tx=RD15 - logical 39/40 diff --git a/tools/kconfig/mkioconf.c b/tools/kconfig/mkioconf.c index b56e11b..c01ec62 100644 --- a/tools/kconfig/mkioconf.c +++ b/tools/kconfig/mkioconf.c @@ -33,40 +33,6 @@ #include "y.tab.h" #include "config.h" -static void -comp_config(fp) - FILE *fp; -{ - register struct file_list *fl; - register struct device *dp; - - fprintf(fp, "\n#include \"dev/cdvar.h\"\n"); - fprintf(fp, "\nstruct cddevice cddevice[] = {\n"); - fprintf(fp, "/*\tunit\tileave\tflags\tdk\tdevs\t\t\t\t*/\n"); - - fl = comp_list; - while (fl) { - if (fl->f_type != COMPDEVICE) { - fl = fl->f_next; - continue; - } - for (dp = dtab; dp != 0; dp = dp->d_next) - if (dp->d_type == DEVICE && - eq(dp->d_name, fl->f_fn) && - dp->d_unit == fl->f_compinfo) - break; - if (dp == 0) - continue; - fprintf(fp, "\t%d,\t%d,\t%d,\t%d,\t{", - dp->d_unit, dp->d_pri < 0 ? 0 : dp->d_pri, - dp->d_flags, 1); - for (fl = fl->f_next; fl->f_type == COMPSPEC; fl = fl->f_next) - fprintf(fp, " 0x%x,", (unsigned) fl->f_compdev); - fprintf(fp, " NODEV },\n"); - } - fprintf(fp, "\t-1,\t0,\t0,\t0,\t{ 0 },\n};\n"); -} - /* * build the ioconf.c file */ @@ -76,38 +42,18 @@ pseudo_ioconf(fp) { register struct device *dp; - (void)fprintf(fp, "\n#include \n\n"); for (dp = dtab; dp != NULL; dp = dp->d_next) if (dp->d_type == PSEUDO_DEVICE) - (void)fprintf(fp, "extern void %sattach __P((int));\n", + fprintf(fp, "extern void %sattach __P((int));\n", dp->d_name); - /* - * XXX concatonated disks are pseudo-devices but appear as DEVICEs - * since they don't adhere to normal pseudo-device conventions - * (i.e. one entry with total count in d_slave). - */ - if (seen_cd) - (void)fprintf(fp, "extern void cdattach __P((int));\n"); - (void)fprintf(fp, "\nstruct pdevinit pdevinit[] = {\n"); + + fprintf(fp, "\nstruct conf_pdev conf_pdinit[] = {\n"); for (dp = dtab; dp != NULL; dp = dp->d_next) if (dp->d_type == PSEUDO_DEVICE) - (void)fprintf(fp, "\t{ %sattach, %d },\n", dp->d_name, + fprintf(fp, " { %sattach, %d },\n", dp->d_name, dp->d_slave > 0 ? dp->d_slave : 1); - /* - * XXX count up cds and put out an entry - */ - if (seen_cd) { - struct file_list *fl; - int cdmax = -1; - for (fl = comp_list; fl != NULL; fl = fl->f_next) - if (fl->f_type == COMPDEVICE && fl->f_compinfo > cdmax) - cdmax = fl->f_compinfo; - (void)fprintf(fp, "\t{ cdattach, %d },\n", cdmax+1); - } - (void)fprintf(fp, "\t{ 0, 0 }\n};\n"); - if (seen_cd) - comp_config(fp); + fprintf(fp, " { 0, 0 }\n};\n"); } static char * @@ -115,7 +61,7 @@ wnum(num) { if (num == QUES || num == UNKNOWN) return ("?"); - (void) sprintf(errbuf, "%d", num); + sprintf(errbuf, "%d", num); return (errbuf); } @@ -142,7 +88,7 @@ void pic32_ioconf() fprintf(fp, "extern struct driver %sdriver;\n", dp->d_name); } fprintf(fp, "\nstruct conf_ctlr conf_cinit[] = {\n"); - fprintf(fp, "/*\tdriver,\t\tunit,\taddr,\t\tpri,\tflags */\n"); + fprintf(fp, " /* driver,\t\tunit,\taddr,\t\tpri,\tflags */\n"); for (dp = dtab; dp != 0; dp = dp->d_next) { if (dp->d_type != CONTROLLER && dp->d_type != MASTER) continue; @@ -154,23 +100,23 @@ void pic32_ioconf() if (dp->d_unit == UNKNOWN || dp->d_unit == QUES) dp->d_unit = 0; fprintf(fp, - "\t{ &%sdriver,\t%d,\tC 0x%08x,\t%d,\t0x%x },\n", + " { &%sdriver,\t%d,\tC 0x%08x,\t%d,\t0x%x },\n", dp->d_name, dp->d_unit, dp->d_addr, dp->d_pri, dp->d_flags); } - fprintf(fp, "\t{ 0 }\n};\n"); + fprintf(fp, " { 0 }\n};\n"); /* print devices connected to other controllers */ fprintf(fp, "\nstruct conf_device conf_dinit[] = {\n"); fprintf(fp, - "/*driver,\tcdriver,\tunit,\tctlr,\tdrive,\tslave,\tdk,\tflags*/\n"); + " /* driver,\t\tctlr driver,\tunit,\tctlr,\tdrive,\tslave,\tdk,\tflags */\n"); for (dp = dtab; dp != 0; dp = dp->d_next) { if (dp->d_type == CONTROLLER || dp->d_type == MASTER || dp->d_type == PSEUDO_DEVICE) continue; mp = dp->d_conn; - fprintf(fp, "{ &%sdriver,\t", dp->d_name); + fprintf(fp, " { &%sdriver,\t", dp->d_name); if (mp) { fprintf(fp, "&%sdriver,\t%d,\t%d,\t", mp->d_name, dp->d_unit, mp->d_unit); @@ -181,8 +127,8 @@ void pic32_ioconf() fprintf(fp, "%d,\t%d,\t%d,\t0x%x },\n", dp->d_drive, dp->d_slave, dp->d_dk, dp->d_flags); } - fprintf(fp, "{ 0 }\n};\n"); + fprintf(fp, " { 0 }\n};\n"); pseudo_ioconf(fp); - (void) fclose(fp); + fclose(fp); } #endif diff --git a/tools/kconfig/mkswapconf.c b/tools/kconfig/mkswapconf.c index c7cfefd..e680528 100644 --- a/tools/kconfig/mkswapconf.c +++ b/tools/kconfig/mkswapconf.c @@ -87,15 +87,17 @@ do_swap(fl) fclose(fp); return (swap); } - fprintf(fp, "dev_t\trootdev = makedev(%d, %d);\n", - major(fl->f_rootdev), minor(fl->f_rootdev)); - fprintf(fp, "dev_t\tdumpdev = makedev(%d, %d);\n", - major(fl->f_dumpdev), minor(fl->f_dumpdev)); + fprintf(fp, "dev_t\trootdev = makedev(%d, %d);\t/* %s */\n", + major(fl->f_rootdev), minor(fl->f_rootdev), + devtoname(fl->f_rootdev)); + fprintf(fp, "dev_t\tdumpdev = makedev(%d, %d);\t/* %s */\n", + major(fl->f_dumpdev), minor(fl->f_dumpdev), + devtoname(fl->f_dumpdev)); fprintf(fp, "\n"); fprintf(fp, "struct\tswdevt swdevt[] = {\n"); do { dev = swap->f_swapdev; - fprintf(fp, "\t{ makedev(%d, %d),\t%d,\t%d },\t/* %s */\n", + fprintf(fp, "\t{ makedev(%d, %d), %d, %d },\t/* %s */\n", major(dev), minor(dev), swap->f_swapflag, swap->f_swapsize, swap->f_fn); swap = swap->f_next; @@ -148,10 +150,9 @@ void initdevtable() * terms of major/minor instead of string names. */ dev_t -nametodev(name, defunit, defpartition) +nametodev(name, defunit) char *name; int defunit; - char defpartition; { char *cp, partition; int unit; @@ -176,11 +177,11 @@ nametodev(name, defunit, defpartition) while (*cp && isdigit(*cp)) cp++; } - partition = *cp ? *cp : defpartition; - if (partition < 'a' || partition > 'h') { + partition = *cp ? *cp : '`'; + if (partition < '`' || partition > 'd') { fprintf(stderr, "config: %c: invalid device specification, bad partition\n", *cp); - partition = defpartition; /* carry on */ + partition = 'a'; /* carry on */ } if (devtablenotread) initdevtable(); @@ -191,7 +192,7 @@ nametodev(name, defunit, defpartition) fprintf(stderr, "config: %s: unknown device\n", name); return (NODEV); } - return (makedev(dp->dev_major, (unit << 3) + (partition - 'a'))); + return (makedev(dp->dev_major, (unit << 3) + (partition - '`'))); } char * @@ -208,7 +209,11 @@ devtoname(dev) break; if (dp == 0) dp = devtable; - (void) sprintf(buf, "%s%d%c", dp->dev_name, - minor(dev) >> 3, (minor(dev) & 07) + 'a'); + + if (minor(dev) == 0) + sprintf(buf, "%s%d", dp->dev_name, minor(dev) >> 3); + else + sprintf(buf, "%s%d%c", dp->dev_name, minor(dev) >> 3, + (minor(dev) & 07) + 'a' - 1); return strdup(buf); }