Files
retrobsd/tools/kconfig/mkioconf.c
Serge Vakulenko 94c02410e4 Kconfig: rename machine to architecture, ident to board.
Make timezone and maxusers parameters optional.

Enable kernel options UCB_METER, EXEC_AOUT, EXEC_ELF and EXEC_SCRIPT
by default.
2015-09-03 12:51:56 -07:00

135 lines
4.8 KiB
C

/*
* 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.
*/
#include "y.tab.h"
#include "config.h"
/*
* build the ioconf.c file
*/
static void
pseudo_ioconf(fp)
register FILE *fp;
{
register struct device *dp;
for (dp = dtab; dp != NULL; dp = dp->d_next)
if (dp->d_type == PSEUDO_DEVICE)
fprintf(fp, "extern void %sattach __P((int));\n",
dp->d_name);
fprintf(fp, "\nstruct conf_pdev conf_pdinit[] = {\n");
for (dp = dtab; dp != NULL; dp = dp->d_next)
if (dp->d_type == PSEUDO_DEVICE)
fprintf(fp, " { %sattach, %d },\n", dp->d_name,
dp->d_slave > 0 ? dp->d_slave : 1);
fprintf(fp, " { 0, 0 }\n};\n");
}
static char *
wnum(num)
{
if (num == QUES || num == UNKNOWN)
return ("?");
sprintf(errbuf, "%d", num);
return (errbuf);
}
#if ARCH_PIC32
void pic32_ioconf()
{
register struct device *dp, *mp;
FILE *fp;
fp = fopen("ioconf.c", "w");
if (fp == 0) {
perror("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, " /* 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;
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,
" { &%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, " { 0 }\n};\n");
/* print devices connected to other controllers */
fprintf(fp, "\nstruct conf_device conf_dinit[] = {\n");
fprintf(fp,
" /* 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);
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);
fclose(fp);
}
#endif