Kernel config utility: add new specification to assign

logical signals to pins. like 'signal "LED_KERNEL" pin RA0'.
This commit is contained in:
Serge Vakulenko
2015-09-19 17:09:40 -07:00
parent bf92da35b8
commit 976bf303cc
41 changed files with 234 additions and 379 deletions

View File

@@ -149,6 +149,16 @@ struct opt {
struct opt *op_next;
} *opt, *mkopt;
/*
* Mapping of signal names to pins.
*/
struct signal {
char *sig_name;
int sig_pin;
int sig_invert;
struct signal *sig_next;
} *siglist;
char *board;
char *ldscript;

View File

@@ -22,6 +22,7 @@
%token EQUALS
%token FLAGS
%token HZ
%token INVERT
%token LDSCRIPT
%token MAJOR
%token MAXUSERS
@@ -33,6 +34,7 @@
%token PINS
%token PRIORITY
%token SERVICE
%token SIGNAL
%token ROOT
%token SEMICOLON
%token SEQUENTIAL
@@ -53,6 +55,7 @@
%type <lst> Id_list
%type <val> optional_size
%type <val> optional_sflag
%type <val> optional_invert
%type <str> device_name
%type <val> major_minor
%type <val> root_device_spec
@@ -167,6 +170,16 @@ Config_spec:
LDSCRIPT ID
= { ldscript = strdup($2); }
|
SIGNAL ID PINS PIN optional_invert
= {
struct signal *s = (struct signal*) malloc(sizeof(struct signal));
s->sig_name = strdup($2);
s->sig_next = siglist;
s->sig_pin = $4;
s->sig_invert = $5;
siglist = s;
}
|
System_spec
|
TIMEZONE NUMBER
@@ -337,6 +350,14 @@ optional_sflag:
= { $$ = 0; }
;
optional_invert:
INVERT
= { $$ = 1; }
|
/* empty */
= { $$ = 0; }
;
device_name:
Save_id
= { $$ = $1; }
@@ -808,7 +829,7 @@ void checksystemspec(fl)
if (minor(dev) & 07) {
sprintf(buf,
"Warning, swap defaulted to 'b' partition with root on '%c' partition",
(minor(dev) & 07) + 'a');
(minor(dev) & 07) + 'a' - 1);
yyerror(buf);
}
swap->f_swapdev =

View File

@@ -52,7 +52,9 @@ struct kt {
static struct kt key_words[] = {
{ "and", AND },
{ "architecture", ARCHITECTURE },
{ "at", AT },
{ "board", BOARD },
{ "config", CONFIG },
{ "controller", CONTROLLER },
{ "cpu", CPU },
@@ -62,9 +64,8 @@ static struct kt key_words[] = {
{ "dst", DST },
{ "dumps", DUMPS },
{ "flags", FLAGS },
{ "board", BOARD },
{ "invert", INVERT },
{ "ldscript", LDSCRIPT },
{ "architecture", ARCHITECTURE },
{ "major", MAJOR },
{ "makeoptions", MAKEOPTIONS },
{ "maxusers", MAXUSERS },
@@ -77,6 +78,7 @@ static struct kt key_words[] = {
{ "root", ROOT },
{ "sequential", SEQUENTIAL },
{ "service", SERVICE },
{ "signal", SIGNAL },
{ "size", SIZE },
{ "swap", SWAP },
{ "tape", DEVICE },

View File

@@ -409,6 +409,7 @@ void makefile()
FILE *ifp, *ofp;
char line[BUFSIZ];
struct opt *op;
struct signal *sig;
struct cputype *cp;
struct device *dp;
@@ -442,6 +443,20 @@ void makefile()
if (dp->d_type == SERVICE && dp->d_slave > 0)
fprintf(ofp, "PARAM += -D%s_NUNITS=%d\n", raise(dp->d_name), dp->d_slave);
}
for (sig = siglist; sig; sig = sig->sig_next) {
int bit = sig->sig_pin & 0xff;
int port = sig->sig_pin >> 8;
if (bit > 15 || port < 1 || port > 7) {
printf("%s: invalid pin name R%c%u\n",
sig->sig_name, 'A'+port-1, bit);
exit(1);
}
fprintf(ofp, "PARAM += -D%s_PORT=TRIS%c -D%s_PIN=%d",
sig->sig_name, 'A'+port-1, sig->sig_name, bit);
if (sig->sig_invert)
fprintf(ofp, " -D%s_INVERT", sig->sig_name);
fprintf(ofp, "\n");
}
for (op = opt; op; op = op->op_next) {
if (op->op_value)
fprintf(ofp, "PARAM += -D%s=\"%s\"\n", op->op_name, op->op_value);