summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorMartin Roth <martinroth@google.com>2015-11-24 12:34:16 -0700
committerMartin Roth <martinroth@google.com>2016-08-08 19:14:33 +0200
commit3205170a2e4f9d1c99f36a469ce1d228ed3b50cf (patch)
treea3a75255dec3fd7162c7cdb43c8089c85a464acc /util
parent052a9955678eb514067efb5ccc4de907faa248e1 (diff)
sconfig: pass in devicetree filename
Instead of forcing the hardcoded 'devicetree.cb' filename under the mainboard directory, this allows mainboards to select a filename for the devicetree file. This allows mainboard variants that need to use different devicetree files to live under the same directory. Change-Id: I761e676ba5d5f70d1fb86656b528f63db169fcef Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/12529 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'util')
-rw-r--r--util/sconfig/main.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/util/sconfig/main.c b/util/sconfig/main.c
index a398c0b3d7..316431341a 100644
--- a/util/sconfig/main.c
+++ b/util/sconfig/main.c
@@ -551,7 +551,7 @@ static void inherit_subsystem_ids(FILE *file, struct device *dev)
static void usage(void)
{
- printf("usage: sconfig vendor/mainboard outputdir [-{s|b|k} outputfile]\n");
+ printf("usage: sconfig vendor/mainboard outputdir devicetree [-{s|b|k} outputfile]\n");
printf("\t-s file\tcreate ramstage static device map\n");
printf("\t-b file\tcreate bootblock init_mainboard()\n");
printf("\t-k file\tcreate Kconfig devicetree section\n");
@@ -559,27 +559,39 @@ static void usage(void)
exit (1);
}
+enum {
+ VENDOR_MAINBOARD_ARG = 1,
+ OUTPUTDIR_ARG,
+ DEVICEFILE_ARG,
+ OUTPUTTYPE_ARG,
+ OUTPUTFILE_ARG
+};
+
+#define MIN_ARGS 4
+#define MAX_ARGS 6
int main(int argc, char** argv) {
- if (argc != 3 && argc != 5)
+ if (argc != MIN_ARGS && argc != MAX_ARGS)
usage();
- char *mainboard=argv[1];
- char *outputdir=argv[2];
- char *devtree=malloc(strlen(mainboard)+30);
- sprintf(devtree, "src/mainboard/%s/devicetree.cb", mainboard);
+ char *mainboard = argv[VENDOR_MAINBOARD_ARG];
+ char *outputdir = argv[OUTPUTDIR_ARG];
+ char *devfile = argv[DEVICEFILE_ARG];
+ char *devtree = malloc(strlen(mainboard) + strlen(devfile) + 30);
+ sprintf(devtree, "src/mainboard/%s/%s", mainboard, devfile);
char *outputc;
- if (argc == 3) {
+ if (argc == MIN_ARGS) {
scan_mode = STATIC_MODE;
outputc=malloc(strlen(outputdir)+20);
sprintf(outputc, "%s/static.c", outputdir);
- } else if (argc == 5) {
- if ((argv[3][0] != '-') || (argv[3][2] == 0)) {
+ } else if (argc == MAX_ARGS) {
+ if ((argv[OUTPUTTYPE_ARG][0] != '-') ||
+ (argv[OUTPUTTYPE_ARG][2] == 0)) {
usage();
}
- switch (argv[3][1]) {
+ switch (argv[OUTPUTTYPE_ARG][1]) {
case 's':
scan_mode = STATIC_MODE;
break;
@@ -593,7 +605,7 @@ int main(int argc, char** argv) {
usage();
break;
}
- char *outputfile=argv[4];
+ char *outputfile = argv[OUTPUTFILE_ARG];
outputc=malloc(strlen(outputdir)+strlen(outputfile)+2);
sprintf(outputc, "%s/%s", outputdir, outputfile);