aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/config
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2000-06-13 22:28:50 +0000
committerPeter Wemm <peter@FreeBSD.org>2000-06-13 22:28:50 +0000
commitf71c01cc52475d4d03347c3019afa928ae46edb1 (patch)
tree1edf0aa73ed3b2b01a5ffc721bb1cd7ac9936a83 /usr.sbin/config
parente19c49c532f803ae7cef2744b53c8b570777abf1 (diff)
downloadsrc-f71c01cc52475d4d03347c3019afa928ae46edb1.tar.gz
src-f71c01cc52475d4d03347c3019afa928ae46edb1.zip
Borrow phk's axe and apply the next stage of config(8)'s evolution.
Use Warner Losh's "hint" driver to decode ascii strings to fill the resource table at boot time. config(8) no longer generates an ioconf.c table - ie: the configuration no longer has to be compiled into the kernel. You can reconfigure your isa devices with the likes of this at loader(8) time: set hint.ed.0.port=0x320 userconfig will be rewritten to use this style interface one day and will move to /boot/userconfig.4th or something like that. It is still possible to statically compile in a set of hints into a kernel if you do not wish to use loader(8). See the "hints" directive in GENERIC as an example. All device wiring has been moved out of config(8). There is a set of helper scripts (see i386/conf/gethints.pl, and the same for alpha and pc98) that extract the 'at isa? port foo irq bar' from the old files and produces a hints file. If you install this file as /boot/device.hints (and update /boot/defaults/loader.conf - You can do a build/install in sys/boot) then loader will load it automatically for you. You can also compile in the hints directly with: hints "device.hints" as well. There are a few things that I'm not too happy with yet. Under this scheme, things like LINT would no longer be useful as "documentation" of settings. I have renamed this file to 'NOTES' and stored the example hints strings in it. However... this is not something that config(8) understands, so there is a script that extracts the build-specific data from the documentation file (NOTES) to produce a LINT that can be config'ed and built. A stack of man4 pages will need updating. :-/ Also, since there is no longer a difference between 'device' and 'pseudo-device' I collapsed the two together, and the resulting 'device' takes a 'number of units' for devices that still have it statically allocated. eg: 'device fe 4' will compile the fe driver with NFE set to 4. You can then set hints for 4 units (0 - 3). Also note that 'device fe0' will be interpreted as "zero units of 'fe'" which would be bad, so there is a config warning for this. This is only needed for old drivers that still have static limits on numbers of units. All the statically limited drivers that I could find were marked. Please exercise EXTREME CAUTION when transitioning! Moral support by: phk, msmith, dfr, asmodai, imp, and others
Notes
Notes: svn path=/head/; revision=61640
Diffstat (limited to 'usr.sbin/config')
-rw-r--r--usr.sbin/config/Makefile2
-rw-r--r--usr.sbin/config/config.h41
-rw-r--r--usr.sbin/config/config.y251
-rw-r--r--usr.sbin/config/configvers.h2
-rw-r--r--usr.sbin/config/lang.l44
-rw-r--r--usr.sbin/config/main.c38
-rw-r--r--usr.sbin/config/mkheaders.c60
-rw-r--r--usr.sbin/config/mkioconf.c200
-rw-r--r--usr.sbin/config/mkmakefile.c169
-rw-r--r--usr.sbin/config/mkoptions.c24
10 files changed, 192 insertions, 639 deletions
diff --git a/usr.sbin/config/Makefile b/usr.sbin/config/Makefile
index cd47fc4e6815..5388abc5ae16 100644
--- a/usr.sbin/config/Makefile
+++ b/usr.sbin/config/Makefile
@@ -4,7 +4,7 @@
PROG= config
CFLAGS+=-I. -I${.CURDIR}
CFLAGS+=-Wall -Wunused -Wmissing-prototypes -Wredundant-decls
-SRCS= config.y main.c lang.l mkioconf.c mkmakefile.c mkheaders.c \
+SRCS= config.y main.c lang.l mkmakefile.c mkheaders.c \
mkoptions.c y.tab.h
MAN8= config.8
DPADD= ${LIBL}
diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h
index 41a00b139733..1779dc5a37b1 100644
--- a/usr.sbin/config/config.h
+++ b/usr.sbin/config/config.h
@@ -76,25 +76,10 @@ struct file_list {
struct device {
int d_type; /* DEVICE, bus adaptor */
- char *d_conn; /* what it is connected to */
- int d_connunit; /* unit of connection */
char *d_name; /* name of device (e.g. rk11) */
- int d_unit; /* unit number */
- int d_drive; /* drive number */
- int d_target; /* target number */
- int d_lun; /* unit number */
- int d_bus; /* controller bus number */
- int d_count; /* pseudo-device count */
+ int d_count; /* device count */
#define QUES -1 /* -1 means '?' */
#define UNKNOWN -2 /* -2 means not set yet */
- int d_flags; /* flags for device init */
- int d_disabled; /* nonzero to skip probe/attach */
- char *d_port; /* io port base manifest constant */
- int d_portn; /* io port base (if number not manifest) */
- 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 */
};
@@ -144,20 +129,20 @@ struct opt_list {
} *otab;
extern char *ident;
+extern char *hints;
extern int do_trace;
-char *get_word __P((FILE *));
-char *get_quoted_word __P((FILE *));
-char *path __P((char *));
-char *raisestr __P((char *));
-void moveifchanged __P((const char *, const char *));
-void init_dev __P((struct device *));
-void newbus_ioconf __P((void));
-int yyparse __P((void));
-int yylex __P((void));
-void options __P((void));
-void makefile __P((void));
-void headers __P((void));
+char *get_word(FILE *);
+char *get_quoted_word(FILE *);
+char *path(char *);
+char *raisestr(char *);
+void moveifchanged(const char *, const char *);
+void newbus_ioconf(void);
+int yyparse(void);
+int yylex(void);
+void options(void);
+void makefile(void);
+void headers(void);
extern struct device *dtab;
diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y
index 018be5b3e7a1..0de3e913aa20 100644
--- a/usr.sbin/config/config.y
+++ b/usr.sbin/config/config.y
@@ -4,48 +4,25 @@
struct file_list *file;
}
-%token ANY
%token ARCH
-%token AT
-%token BUS
%token COMMA
%token CONFIG
-%token CONFLICTS
-%token CONTROLLER
%token CPU
%token DEVICE
-%token DISABLE
-%token DISK
-%token DRIVE
-%token DRQ
%token EQUALS
-%token FLAGS
+%token HINTS
%token IDENT
-%token IOMEM
-%token IOSIZ
-%token IRQ
%token MAXUSERS
-%token MINUS
-%token NEXUS
%token OPTIONS
%token MAKEOPTIONS
-%token PORT
-%token PSEUDO_DEVICE
%token SEMICOLON
-%token TAPE
-%token TARGET
-%token TTY
-%token UNIT
-%token VECTOR
%token <str> ID
%token <val> NUMBER
-%token <val> FPNUMBER
%type <str> Save_id
%type <str> Opt_value
%type <str> Dev
-%type <str> device_name
%{
@@ -97,6 +74,7 @@ static struct device *curp = 0;
struct device *dtab;
char *ident;
+char *hints;
int yyline;
struct file_list *ftab;
char errbuf[80];
@@ -104,8 +82,7 @@ int maxusers;
#define ns(s) strdup(s)
-static int connect __P((char *, int));
-static void yyerror __P((char *s));
+static void yyerror(char *s);
%}
@@ -163,7 +140,9 @@ Config_spec:
System_spec
|
MAXUSERS NUMBER
- = { maxusers = $2; };
+ = { maxusers = $2; } |
+ HINTS ID
+ = { hints = $2; };
System_spec:
CONFIG System_id System_parameter_list
@@ -190,41 +169,6 @@ System_parameter_list:
| ID
;
-device_name:
- Save_id
- = { $$ = $1; }
- | Save_id NUMBER
- = {
- char buf[80];
-
- (void) snprintf(buf, sizeof(buf), "%s%d", $1, $2);
- $$ = ns(buf); free($1);
- }
- | Save_id NUMBER ID
- = {
- char buf[80];
-
- (void) snprintf(buf, sizeof(buf), "%s%d%s", $1, $2, $3);
- $$ = ns(buf); free($1);
- }
- | Save_id NUMBER ID NUMBER
- = {
- char buf[80];
-
- (void) snprintf(buf, sizeof(buf), "%s%d%s%d",
- $1, $2, $3, $4);
- $$ = ns(buf); free($1);
- }
- | Save_id NUMBER ID NUMBER ID
- = {
- char buf[80];
-
- (void) snprintf(buf, sizeof(buf), "%s%d%s%d%s",
- $1, $2, $3, $4, $5);
- $$ = ns(buf); free($1);
- }
- ;
-
Opt_list:
Opt_list COMMA Option
|
@@ -304,111 +248,25 @@ Dev:
;
Device_spec:
- DEVICE Dev_spec
- = { cur.d_type = DEVICE; } |
- DISK Dev_spec
- = {
- warnx("line %d: Obsolete keyword 'disk' found - use 'device'", yyline);
- cur.d_type = DEVICE;
- } |
- TAPE Dev_spec
+ DEVICE Dev
= {
- warnx("line %d: Obsolete keyword 'tape' found - use 'device'", yyline);
cur.d_type = DEVICE;
- } |
- CONTROLLER Dev_spec
- = {
- warnx("line %d: Obsolete keyword 'controller' found - use 'device'", yyline);
- cur.d_type = DEVICE;
- } |
- 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_count = $4;
- } ;
-
-Dev_spec:
- Init_dev Dev
- = {
cur.d_name = $2;
- cur.d_unit = UNKNOWN;
+ cur.d_count = UNKNOWN;
} |
- Init_dev Dev NUMBER Dev_info
+ DEVICE Dev NUMBER
= {
+ cur.d_type = DEVICE;
cur.d_name = $2;
- cur.d_unit = $3;
- };
-
-Init_dev:
- /* lambda */
- = { init_dev(&cur); };
-
-Dev_info:
- Con_info Info_list
- |
- /* lambda */
- ;
-
-Con_info:
- AT Dev NUMBER
- = {
- connect($2, $3);
- cur.d_conn = $2;
- cur.d_connunit = $3;
- } |
- AT NEXUS NUMBER
- = {
- cur.d_conn = "nexus";
- cur.d_connunit = 0;
- };
-
-Info_list:
- Info_list Info
- |
- /* lambda */
- ;
-
-Info:
- BUS NUMBER /* device scbus1 at ahc0 bus 1 - twin channel */
- = { cur.d_bus = $2; } |
- TARGET NUMBER
- = { cur.d_target = $2; } |
- UNIT NUMBER
- = { cur.d_lun = $2; } |
- DRIVE NUMBER
- = { cur.d_drive = $2; } |
- 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 = $2; } |
- PORT NUMBER
- = { cur.d_portn = $2; } |
- FLAGS NUMBER
- = { cur.d_flags = $2; } |
- DISABLE
- = { cur.d_disabled = 1; } |
- CONFLICTS
- = {
- warnx("line %d: Obsolete keyword 'conflicts' found", yyline);
- };
+ cur.d_count = $3;
+ if (cur.d_count == 0)
+ warnx("line %d: devices with zero units are not likely to be correct", yyline);
+ } ;
%%
static void
-yyerror(s)
- char *s;
+yyerror(char *s)
{
warnx("line %d: %s", yyline + 1, s);
@@ -418,23 +276,16 @@ yyerror(s)
* add a device to the list of devices
*/
static void
-newdev(dp)
- register struct device *dp;
+newdev(struct device *dp)
{
- register struct device *np, *xp;
-
- if (dp->d_unit >= 0) {
- for (xp = dtab; xp != 0; xp = xp->d_next) {
- if ((xp->d_unit == dp->d_unit) &&
- eq(xp->d_name, dp->d_name)) {
- warnx("line %d: already seen device %s%d",
- yyline, xp->d_name, xp->d_unit);
- }
- }
- }
+ struct device *np;
+
np = (struct device *) malloc(sizeof *np);
memset(np, 0, sizeof(*np));
*np = *dp;
+ np->d_name = dp->d_name;
+ np->d_type = dp->d_type;
+ np->d_count = dp->d_count;
np->d_next = 0;
if (curp == 0)
dtab = np;
@@ -442,63 +293,3 @@ newdev(dp)
curp->d_next = np;
curp = np;
}
-
-
-/*
- * find the pointer to connect to the given device and number.
- * returns 0 if no such device and prints an error message
- */
-static int
-connect(dev, num)
- register char *dev;
- register int num;
-{
- register struct device *dp;
-
- if (num == QUES) {
- for (dp = dtab; dp != 0; dp = dp->d_next)
- if (eq(dp->d_name, dev))
- break;
- if (dp == 0) {
- (void) snprintf(errbuf, sizeof(errbuf),
- "no %s's to wildcard", dev);
- yyerror(errbuf);
- return (0);
- }
- return (1);
- }
- for (dp = dtab; dp != 0; dp = dp->d_next) {
- if ((num != dp->d_unit) || !eq(dev, dp->d_name))
- continue;
- if (dp->d_type != DEVICE) {
- (void) snprintf(errbuf, sizeof(errbuf),
- "%s connected to non-device", dev);
- yyerror(errbuf);
- return (0);
- }
- return (1);
- }
- (void) snprintf(errbuf, sizeof(errbuf), "%s %d not defined", dev, num);
- yyerror(errbuf);
- return (0);
-}
-
-void
-init_dev(dp)
- register struct device *dp;
-{
-
- dp->d_name = "OHNO!!!";
- dp->d_type = DEVICE;
- dp->d_conn = 0;
- dp->d_disabled = 0;
- dp->d_flags = 0;
- dp->d_bus = dp->d_lun = dp->d_target = dp->d_drive = dp->d_unit = \
- dp->d_count = UNKNOWN;
- dp->d_port = (char *)0;
- dp->d_portn = -1;
- dp->d_irq = -1;
- dp->d_drq = -1;
- dp->d_maddr = 0;
- dp->d_msize = 0;
-}
diff --git a/usr.sbin/config/configvers.h b/usr.sbin/config/configvers.h
index 99226d952cc3..7a398f5c712f 100644
--- a/usr.sbin/config/configvers.h
+++ b/usr.sbin/config/configvers.h
@@ -8,4 +8,4 @@
*
* $FreeBSD$
*/
-#define CONFIGVERS 500001
+#define CONFIGVERS 500002
diff --git a/usr.sbin/config/lang.l b/usr.sbin/config/lang.l
index 3a512a6fcd34..c64add73ce6e 100644
--- a/usr.sbin/config/lang.l
+++ b/usr.sbin/config/lang.l
@@ -50,40 +50,23 @@ struct kt {
char *kt_name;
int kt_val;
} key_words[] = {
- { "at", AT },
- { "bus", BUS },
- { "conflicts", CONFLICTS },
{ "config", CONFIG },
- { "controller", CONTROLLER },
{ "cpu", CPU },
{ "device", DEVICE },
- { "disable", DISABLE },
- { "disk", DISK },
- { "drive", DRIVE },
- { "drq", DRQ },
- { "flags", FLAGS },
+ { "hints", HINTS },
{ "ident", IDENT },
- { "iomem", IOMEM },
- { "iosiz", IOSIZ },
- { "irq", IRQ },
{ "machine", ARCH }, /* MACHINE is defined in /sys/param.h */
{ "makeoptions", MAKEOPTIONS },
{ "maxusers", MAXUSERS },
- { "nexus", NEXUS },
{ "option", OPTIONS },
{ "options", OPTIONS },
- { "port", PORT },
- { "pseudo-device",PSEUDO_DEVICE },
- { "tape", TAPE },
- { "target", TARGET },
- { "unit", UNIT },
{ 0, 0 },
};
-int kw_lookup __P((char *));
-int octal __P((char *));
-int hex __P((char *));
+int kw_lookup(char *);
+int octal(char *);
+int hex(char *);
%}
WORD [A-Za-z_][-A-Za-z_]*
@@ -106,8 +89,7 @@ ID [A-Za-z_][-A-Za-z_0-9]*
if ((i = kw_lookup(yytext)) == -1)
REJECT;
- if (i == CONTROLLER || i == DEVICE || i == DISK || i == TAPE ||
- i == PSEUDO_DEVICE || i == AT)
+ if (i == DEVICE)
BEGIN NONUM;
return i;
}
@@ -146,10 +128,6 @@ ID [A-Za-z_][-A-Za-z_0-9]*
yylval.val = atoi(yytext);
return NUMBER;
}
-[0-9]"."[0-9]* {
- yylval.val = (int) (60 * atof(yytext) + 0.5);
- return FPNUMBER;
- }
"?" {
yylval.val = -1;
return NUMBER;
@@ -166,7 +144,6 @@ ID [A-Za-z_][-A-Za-z_0-9]*
";" { return SEMICOLON; }
"," { return COMMA; }
"=" { BEGIN TOEOL; return EQUALS; }
-"@" { return AT; }
. { return yytext[0]; }
%%
@@ -177,10 +154,9 @@ ID [A-Za-z_][-A-Za-z_0-9]*
*/
int
-kw_lookup(word)
-register char *word;
+kw_lookup(char *word)
{
- register struct kt *kp;
+ struct kt *kp;
for (kp = key_words; kp->kt_name != 0; kp++)
if (eq(word, kp->kt_name))
@@ -193,8 +169,7 @@ register char *word;
*/
int
-octal(str)
-char *str;
+octal(char *str)
{
int num;
@@ -203,8 +178,7 @@ char *str;
}
int
-hex(str)
-char *str;
+hex(char *str)
{
int num;
diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c
index 4a0748efdf6f..318d0d5d6f81 100644
--- a/usr.sbin/config/main.c
+++ b/usr.sbin/config/main.c
@@ -76,18 +76,16 @@ static int no_config_clobber = TRUE;
int debugging;
int profiling;
-static void configfile __P((void));
-static void get_srcdir __P((void));
-static void usage __P((void));
+static void configfile(void);
+static void get_srcdir(void);
+static void usage(void);
/*
* 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;
+main(int argc, char **argv)
{
struct stat buf;
@@ -170,7 +168,6 @@ main(argc, argv)
case MACHINE_I386:
case MACHINE_PC98:
case MACHINE_ALPHA:
- newbus_ioconf(); /* Print ioconf.c */
break;
default:
@@ -206,7 +203,7 @@ main(argc, argv)
* and save that in srcdir.
*/
static void
-get_srcdir()
+get_srcdir(void)
{
int i;
char *p;
@@ -225,7 +222,7 @@ get_srcdir()
}
static void
-usage()
+usage(void)
{
fprintf(stderr, "usage: config [-gpr] [-d destdir] sysname\n");
exit(1);
@@ -238,12 +235,11 @@ usage()
* pointer to the word otherwise
*/
char *
-get_word(fp)
- register FILE *fp;
+get_word(FILE *fp)
{
static char line[80];
- register int ch;
- register char *cp;
+ int ch;
+ char *cp;
int escaped_nl = 0;
begin:
@@ -284,12 +280,11 @@ begin:
* (to allow embedded spaces).
*/
char *
-get_quoted_word(fp)
- register FILE *fp;
+get_quoted_word(FILE *fp)
{
static char line[256];
- register int ch;
- register char *cp;
+ int ch;
+ char *cp;
int escaped_nl = 0;
begin:
@@ -312,7 +307,7 @@ begin:
}
cp = line;
if (ch == '"' || ch == '\'') {
- register int quote = ch;
+ int quote = ch;
while ((ch = getc(fp)) != EOF) {
if (ch == quote)
@@ -345,10 +340,9 @@ begin:
* prepend the path to a filename
*/
char *
-path(file)
- char *file;
+path(char *file)
{
- register char *cp;
+ char *cp;
cp = malloc((size_t)(strlen(destdir) + (file ? strlen(file) : 0) + 2));
(void) strcpy(cp, destdir);
@@ -360,7 +354,7 @@ path(file)
}
static void
-configfile()
+configfile(void)
{
FILE *fi, *fo;
char *p;
diff --git a/usr.sbin/config/mkheaders.c b/usr.sbin/config/mkheaders.c
index 5ba6503e554f..c2d477d63f44 100644
--- a/usr.sbin/config/mkheaders.c
+++ b/usr.sbin/config/mkheaders.c
@@ -50,24 +50,22 @@ static const char rcsid[] =
#include "config.h"
#include "y.tab.h"
-static void do_header __P((char *, int));
-static void do_count __P((char *));
-static char *toheader __P((char *));
-static char *tomacro __P((char *));
+static void do_header(char *, int);
+static void do_count(char *);
+static char *toheader(char *);
+static char *tomacro(char *);
void
-headers()
+headers(void)
{
- register struct file_list *fl;
+ struct file_list *fl;
struct device *dp;
for (fl = ftab; fl != 0; fl = fl->f_next) {
if (fl->f_needs != 0) {
for (dp = dtab; dp != 0; dp = dp->d_next) {
if (eq(dp->d_name, fl->f_needs)) {
- if ((dp->d_type & TYPEMASK) == PSEUDO_DEVICE)
- dp->d_type |= DEVDONE;
- else if ((dp->d_type & TYPEMASK) == DEVICE)
+ if ((dp->d_type & TYPEMASK) == DEVICE)
dp->d_type |= DEVDONE;
}
}
@@ -76,11 +74,6 @@ headers()
}
}
for (dp = dtab; dp != 0; dp = dp->d_next) {
- if ((dp->d_type & TYPEMASK) == PSEUDO_DEVICE) {
- if (!(dp->d_type & DEVDONE))
- printf("Warning: pseudo-device \"%s\" is unknown\n",
- dp->d_name);
- }
if ((dp->d_type & TYPEMASK) == DEVICE) {
if (!(dp->d_type & DEVDONE))
printf("Warning: device \"%s\" is unknown\n",
@@ -94,11 +87,10 @@ headers()
* whatever the device is connected to
*/
static void
-do_count(dev)
- register char *dev;
+do_count(char *dev)
{
- register struct device *dp;
- register int count, hicount;
+ struct device *dp;
+ int count, hicount;
/*
* After this loop, "count" will be the actual number of units,
@@ -106,29 +98,17 @@ do_count(dev)
* 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 & TYPEMASK) == PSEUDO_DEVICE) {
- count =
- dp->d_count != UNKNOWN ? dp->d_count : 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 (eq(dp->d_name, dev)) {
+ count =
+ dp->d_count != UNKNOWN ? dp->d_count : 1;
+ break;
}
}
- do_header(dev, count > hicount ? count : hicount);
+ do_header(dev, count);
}
static void
-do_header(dev, count)
- char *dev;
- int count;
+do_header(char *dev, int count)
{
char *file, *name, *inw;
struct file_list *fl, *fl_head, *tflp;
@@ -207,8 +187,7 @@ do_header(dev, count)
* convert a dev name to a .h file name
*/
static char *
-toheader(dev)
- char *dev;
+toheader(char *dev)
{
static char hbuf[80];
@@ -221,11 +200,10 @@ toheader(dev)
* convert a dev name to a macro name
*/
static char *
-tomacro(dev)
- register char *dev;
+tomacro(char *dev)
{
static char mbuf[20];
- register char *cp;
+ char *cp;
cp = mbuf;
*cp++ = 'N';
diff --git a/usr.sbin/config/mkioconf.c b/usr.sbin/config/mkioconf.c
deleted file mode 100644
index 6eabd49d5a08..000000000000
--- a/usr.sbin/config/mkioconf.c
+++ /dev/null
@@ -1,200 +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.
- */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)mkioconf.c 8.2 (Berkeley) 1/21/94";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <err.h>
-#include <stdio.h>
-#include "y.tab.h"
-#include "config.h"
-
-/*
- * build the ioconf.c file
- */
-
-static char *
-devstr(struct device *dp)
-{
- static char buf[100];
-
- if (dp->d_unit >= 0) {
- snprintf(buf, sizeof(buf), "%s%d", dp->d_name, dp->d_unit);
- return buf;
- } else
- return dp->d_name;
-}
-
-static void
-write_device_resources(FILE *fp, struct device *dp)
-{
- int count = 0;
- char buf[80];
-
- fprintf(fp, "struct config_resource %s_resources[] = {\n", devstr(dp));
- if (dp->d_conn) {
- if (dp->d_connunit >= 0)
- snprintf(buf, sizeof(buf), "%s%d", dp->d_conn, dp->d_connunit);
- else
- snprintf(buf, sizeof(buf), "%s", dp->d_conn);
- fprintf(fp, "\t{ \"at\",\tRES_STRING,\t{ (long)\"%s\" }},\n", buf);
- count++;
- }
- if (dp->d_drive != -2) {
- fprintf(fp, "\t{ \"drive\",\tRES_INT,\t{ %d }},\n", dp->d_drive);
- count++;
- }
- if (dp->d_target != -2) {
- fprintf(fp, "\t{ \"target\",\tRES_INT,\t{ %d }},\n", dp->d_target);
- count++;
- }
- if (dp->d_lun != -2) {
- fprintf(fp, "\t{ \"lun\",\tRES_INT,\t{ %d }},\n", dp->d_lun);
- count++;
- }
- if (dp->d_bus != -2) {
- fprintf(fp, "\t{ \"bus\",\tRES_INT,\t{ %d }},\n", dp->d_bus);
- count++;
- }
- if (dp->d_flags) {
- fprintf(fp, "\t{ \"flags\",\tRES_INT,\t{ 0x%x }},\n", dp->d_flags);
- count++;
- }
- if (dp->d_disabled) {
- fprintf(fp, "\t{ \"disabled\",\tRES_INT,\t{ %d }},\n", dp->d_disabled);
- count++;
- }
- if (dp->d_port) {
- fprintf(fp, "\t{ \"port\",\tRES_INT,\t { %s }},\n", dp->d_port);
- count++;
- }
- if (dp->d_portn > 0) {
- fprintf(fp, "\t{ \"port\",\tRES_INT,\t{ 0x%x }},\n", dp->d_portn);
- count++;
- }
- if (dp->d_maddr > 0) {
- fprintf(fp, "\t{ \"maddr\",\tRES_INT,\t{ 0x%x }},\n", dp->d_maddr);
- count++;
- }
- if (dp->d_msize > 0) {
- fprintf(fp, "\t{ \"msize\",\tRES_INT,\t{ 0x%x }},\n", dp->d_msize);
- count++;
- }
- if (dp->d_drq >= 0) {
- fprintf(fp, "\t{ \"drq\",\tRES_INT,\t{ %d }},\n", dp->d_drq);
- count++;
- }
- if (dp->d_irq > 0) {
- fprintf(fp, "\t{ \"irq\",\tRES_INT,\t{ %d }},\n", dp->d_irq);
- count++;
- }
- fprintf(fp, "};\n");
- fprintf(fp, "#define %s_count %d\n", devstr(dp), count);
-}
-
-static void
-write_all_device_resources(FILE *fp)
-{
- struct device *dp;
-
- for (dp = dtab; dp != 0; dp = dp->d_next) {
- if (dp->d_type != DEVICE)
- continue;
- if (dp->d_unit == UNKNOWN)
- continue;
- write_device_resources(fp, dp);
- }
-}
-
-static void
-write_devtab(FILE *fp)
-{
- struct device *dp;
- int count;
-
- write_all_device_resources(fp);
-
- count = 0;
- fprintf(fp, "struct config_device config_devtab[] = {\n");
- for (dp = dtab; dp != 0; dp = dp->d_next) {
- char* n = devstr(dp);
- if (dp->d_type != DEVICE)
- continue;
- if (dp->d_unit == UNKNOWN)
- continue;
- fprintf(fp, "\t{ \"%s\",\t%d,\t%s_count,\t%s_resources },\n",
- dp->d_name, dp->d_unit, n, n);
- count++;
- }
- fprintf(fp, "};\n");
- fprintf(fp, "int devtab_count = %d;\n", count);
-}
-
-void
-newbus_ioconf()
-{
- FILE *fp;
-
- fp = fopen(path("ioconf.c.new"), "w");
- if (fp == 0)
- err(1, "%s", path("ioconf.c.new"));
- fprintf(fp, "/*\n");
- fprintf(fp, " * I/O configuration.\n");
- fprintf(fp, " * DO NOT EDIT-- this file is automatically generated.\n");
- fprintf(fp, " */\n");
- fprintf(fp, "\n");
- fprintf(fp, "#include <sys/param.h>\n");
- fprintf(fp, "\n");
- fprintf(fp, "/*\n");
- fprintf(fp, " * New bus architecture devices.\n");
- fprintf(fp, " */\n");
- fprintf(fp, "\n");
- fprintf(fp, "#include <sys/queue.h>\n");
- fprintf(fp, "#include <sys/sysctl.h>\n");
- if (machine == MACHINE_PC98)
- fprintf(fp, "#include <pc98/pc98/pc98.h>\n");
- else
- fprintf(fp, "#include <isa/isareg.h>\n");
- fprintf(fp, "#include <sys/bus_private.h>\n");
- fprintf(fp, "\n");
-
- write_devtab(fp);
-
- (void) fclose(fp);
- moveifchanged(path("ioconf.c.new"), path("ioconf.c"));
-}
diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c
index 516b225e59a8..f0107ed8fcbb 100644
--- a/usr.sbin/config/mkmakefile.c
+++ b/usr.sbin/config/mkmakefile.c
@@ -54,14 +54,14 @@ static const char rcsid[] =
#include "configvers.h"
#define next_word(fp, wd) \
- { register char *word = get_word(fp); \
+ { 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); \
+ { char *word = get_quoted_word(fp); \
if (word == (char *)EOF) \
return; \
else \
@@ -70,25 +70,24 @@ static const char rcsid[] =
static struct file_list *fcur;
-static char *tail __P((char *));
-static void do_clean __P((FILE *));
-static void do_rules __P((FILE *));
-static void do_sfiles __P((FILE *));
-static void do_mfiles __P((FILE *));
-static void do_cfiles __P((FILE *));
-static void do_objs __P((FILE *));
-static void do_before_depend __P((FILE *));
-static int opteq __P((char *, char *));
-static void read_files __P((void));
+static char *tail(char *);
+static void do_clean(FILE *);
+static void do_rules(FILE *);
+static void do_sfiles(FILE *);
+static void do_mfiles(FILE *);
+static void do_cfiles(FILE *);
+static void do_objs(FILE *);
+static void do_before_depend(FILE *);
+static int opteq(char *, char *);
+static void read_files(void);
/*
* Lookup a file, by name.
*/
static struct file_list *
-fl_lookup(file)
- register char *file;
+fl_lookup(char *file)
{
- register struct file_list *fp;
+ struct file_list *fp;
for (fp = ftab ; fp != 0; fp = fp->f_next) {
if (eq(fp->f_fn, file))
@@ -101,10 +100,9 @@ fl_lookup(file)
* Lookup a file, by final component name.
*/
static struct file_list *
-fltail_lookup(file)
- register char *file;
+fltail_lookup(char *file)
{
- register struct file_list *fp;
+ struct file_list *fp;
for (fp = ftab ; fp != 0; fp = fp->f_next) {
if (eq(tail(fp->f_fn), tail(file)))
@@ -117,9 +115,9 @@ fltail_lookup(file)
* Make a new file list entry
*/
static struct file_list *
-new_fent()
+new_fent(void)
{
- register struct file_list *fp;
+ struct file_list *fp;
fp = (struct file_list *) malloc(sizeof *fp);
bzero(fp, sizeof *fp);
@@ -135,12 +133,13 @@ new_fent()
* Build the makefile from the skeleton
*/
void
-makefile()
+makefile(void)
{
FILE *ifp, *ofp;
char line[BUFSIZ];
struct opt *op;
int versreq;
+ char *s;
read_files();
snprintf(line, sizeof(line), "../../conf/Makefile.%s", machinename);
@@ -216,6 +215,54 @@ makefile()
(void) fclose(ofp);
moveifchanged(path("Makefile.new"), path("Makefile"));
+ if (hints) {
+ ifp = fopen(hints, "r");
+ if (ifp == NULL)
+ err(1, "%s", hints);
+ } else {
+ ifp = NULL;
+ }
+ ofp = fopen(path("hints.c.new"), "w");
+ if (ofp == NULL)
+ err(1, "%s", path("hints.c.new"));
+ fprintf(ofp, "char static_hints[] = {\n");
+ if (ifp) {
+ while (fgets(line, BUFSIZ, ifp) != 0) {
+ /* zap trailing CR and/or LF */
+ while ((s = rindex(line, '\n')) != NULL)
+ *s = '\0';
+ while ((s = rindex(line, '\r')) != NULL)
+ *s = '\0';
+ /* remove # comments */
+ s = index(line, '#');
+ if (s)
+ *s = '\0';
+ /* remove any whitespace and " characters */
+ s = line;
+ while (*s) {
+ if (*s == ' ' || *s == '\t' || *s == '"') {
+ while (*s) {
+ s[0] = s[1];
+ s++;
+ }
+ /* start over */
+ s = line;
+ continue;
+ }
+ s++;
+ }
+ /* anything left? */
+ if (*line == '\0')
+ break;
+ fprintf(ofp, "\"%s\\0\"\n", line);
+ }
+ }
+ fprintf(ofp, "\"\\0\"\n};\n");
+ if (ifp)
+ fclose(ifp);
+ fclose(ofp);
+ moveifchanged(path("hints.c.new"), path("hints.c"));
+
printf("Don't forget to do a ``make depend''\n");
}
@@ -224,13 +271,13 @@ makefile()
* Store it in the ftab linked list.
*/
static void
-read_files()
+read_files(void)
{
FILE *fp;
- register struct file_list *tp, *pf;
- register struct device *dp;
+ struct file_list *tp, *pf;
+ struct device *dp;
struct device *save_dp;
- register struct opt *op;
+ struct opt *op;
char *wd, *this, *needs, *special, *depends, *clean, *warn;
char fname[80];
int ddwarned = 0;
@@ -250,7 +297,7 @@ openit:
err(1, "%s", fname);
next:
/*
- * filename [ standard | mandatory | optional | count]
+ * filename [ standard | mandatory | optional | count ]
* [ config-dependent ]
* [ dev* | profiling-routine ] [ no-obj ]
* [ compile-with "compile rule" [no-implicit-rule] ]
@@ -428,7 +475,7 @@ nextparam:
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 &&
+ if (std && dp->d_type == DEVICE &&
dp->d_count <= 0)
dp->d_count = 1;
goto nextparam;
@@ -441,9 +488,8 @@ nextparam:
if (std) {
dp = (struct device *) malloc(sizeof *dp);
bzero(dp, sizeof *dp);
- init_dev(dp);
+ dp->d_type = DEVICE;
dp->d_name = ns(wd);
- dp->d_type = PSEUDO_DEVICE;
dp->d_count = 1;
save_dp->d_next = dp;
goto nextparam;
@@ -517,8 +563,7 @@ doneparam:
}
static int
-opteq(cp, dp)
- char *cp, *dp;
+opteq(char *cp, char *dp)
{
char c, d;
@@ -535,11 +580,10 @@ opteq(cp, dp)
}
static void
-do_before_depend(fp)
- FILE *fp;
+do_before_depend(FILE *fp)
{
- register struct file_list *tp;
- register int lpos, len;
+ struct file_list *tp;
+ int lpos, len;
fputs("BEFORE_DEPEND=", fp);
lpos = 15;
@@ -561,12 +605,11 @@ do_before_depend(fp)
}
static void
-do_objs(fp)
- FILE *fp;
+do_objs(FILE *fp)
{
- register struct file_list *tp;
- register int lpos, len;
- register char *cp, och, *sp;
+ struct file_list *tp;
+ int lpos, len;
+ char *cp, och, *sp;
fprintf(fp, "OBJS=");
lpos = 6;
@@ -590,11 +633,10 @@ do_objs(fp)
}
static void
-do_cfiles(fp)
- FILE *fp;
+do_cfiles(FILE *fp)
{
- register struct file_list *tp;
- register int lpos, len;
+ struct file_list *tp;
+ int lpos, len;
fputs("CFILES=", fp);
lpos = 8;
@@ -619,11 +661,10 @@ do_cfiles(fp)
}
static void
-do_mfiles(fp)
- FILE *fp;
+do_mfiles(FILE *fp)
{
- register struct file_list *tp;
- register int lpos, len;
+ struct file_list *tp;
+ int lpos, len;
fputs("MFILES=", fp);
lpos = 8;
@@ -644,11 +685,10 @@ do_mfiles(fp)
}
static void
-do_sfiles(fp)
- FILE *fp;
+do_sfiles(FILE *fp)
{
- register struct file_list *tp;
- register int lpos, len;
+ struct file_list *tp;
+ int lpos, len;
fputs("SFILES=", fp);
lpos = 8;
@@ -668,12 +708,10 @@ do_sfiles(fp)
putc('\n', fp);
}
-
static char *
-tail(fn)
- char *fn;
+tail(char *fn)
{
- register char *cp;
+ char *cp;
cp = rindex(fn, '/');
if (cp == 0)
@@ -689,11 +727,10 @@ tail(fn)
* (e.g. for the VAX); assembler files are processed by as.
*/
static void
-do_rules(f)
- FILE *f;
+do_rules(FILE *f)
{
- register char *cp, *np, och, *tp;
- register struct file_list *ftp;
+ char *cp, *np, och, *tp;
+ struct file_list *ftp;
char *special;
for (ftp = ftab; ftp != 0; ftp = ftp->f_next) {
@@ -755,11 +792,10 @@ do_rules(f)
}
static void
-do_clean(fp)
- FILE *fp;
+do_clean(FILE *fp)
{
- register struct file_list *tp;
- register int lpos, len;
+ struct file_list *tp;
+ int lpos, len;
fputs("CLEAN=", fp);
lpos = 7;
@@ -778,10 +814,9 @@ do_clean(fp)
}
char *
-raisestr(str)
- register char *str;
+raisestr(char *str)
{
- register char *cp = str;
+ char *cp = str;
while (*str) {
if (islower(*str))
diff --git a/usr.sbin/config/mkoptions.c b/usr.sbin/config/mkoptions.c
index f66333108b64..25bbeccac3ca 100644
--- a/usr.sbin/config/mkoptions.c
+++ b/usr.sbin/config/mkoptions.c
@@ -62,13 +62,13 @@ static struct users {
};
#define NUSERS (sizeof (users) / sizeof (users[0]))
-static char *lower __P((char *));
-static void read_options __P((void));
-static void do_option __P((char *));
-static char *tooption __P((char *));
+static char *lower(char *);
+static void read_options(void);
+static void do_option(char *);
+static char *tooption(char *);
void
-options()
+options(void)
{
char buf[40];
struct cputype *cp;
@@ -126,8 +126,7 @@ options()
*/
static void
-do_option(name)
- char *name;
+do_option(char *name)
{
char *basefile, *file, *inw;
struct opt_list *ol;
@@ -272,8 +271,7 @@ do_option(name)
* Find the filename to store the option spec into.
*/
static char *
-tooption(name)
- char *name;
+tooption(char *name)
{
static char hbuf[80];
char nbuf[80];
@@ -297,7 +295,7 @@ tooption(name)
* read the options and options.<machine> files
*/
static void
-read_options()
+read_options(void)
{
FILE *fp;
char fname[80];
@@ -378,10 +376,9 @@ next:
}
static char *
-lower(str)
- register char *str;
+lower(char *str)
{
- register char *cp = str;
+ char *cp = str;
while (*str) {
if (isupper(*str))
@@ -390,4 +387,3 @@ lower(str)
}
return (cp);
}
-