summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2014-12-08 13:24:33 +0100
committerMarcin Bukat <marcin.bukat@gmail.com>2015-01-12 11:28:52 +0100
commitbbd7d1dba39ab1a89b4cc0c18352e35349e66faa (patch)
tree5f18435669b21fb34c8a18f32c483acbbed7443c
parent89ba7e818c0d96b779b02bc7b31c0c6a19294a46 (diff)
downloadrockbox-bbd7d1dba39ab1a89b4cc0c18352e35349e66faa.tar.gz
rockbox-bbd7d1dba39ab1a89b4cc0c18352e35349e66faa.zip
regtools/headergen: Make generator more flexible
Change-Id: I2328ec021ed990a40257d4ce6f4fc5b3db2ba998
-rw-r--r--utils/regtools/headergen.cpp209
1 files changed, 126 insertions, 83 deletions
diff --git a/utils/regtools/headergen.cpp b/utils/regtools/headergen.cpp
index 804f7e0a3a..046e8b2fd8 100644
--- a/utils/regtools/headergen.cpp
+++ b/utils/regtools/headergen.cpp
@@ -76,9 +76,12 @@ std::string to_hex(const T& v)
76 76
77typedef std::pair< std::string, std::string > xml_ver_t; 77typedef std::pair< std::string, std::string > xml_ver_t;
78 78
79void fprint_copyright(FILE *f, const std::vector< xml_ver_t >& versions) 79void fprint_copyright(FILE *f, const std::vector< xml_ver_t >& versions, char const *author)
80{ 80{
81 std::ostringstream ver; 81 std::ostringstream ver;
82 time_t t = time(NULL);
83 struct tm tm = *localtime(&t);
84
82 for(size_t i = 0; i < versions.size(); i++) 85 for(size_t i = 0; i < versions.size(); i++)
83 ver << " " << versions[i].first << ":" << versions[i].second; 86 ver << " " << versions[i].first << ":" << versions[i].second;
84 87
@@ -96,7 +99,9 @@ void fprint_copyright(FILE *f, const std::vector< xml_ver_t >& versions)
96 fprintf(f, " * XML versions:%s\n", ver.str().c_str()); 99 fprintf(f, " * XML versions:%s\n", ver.str().c_str());
97 fprintf(f,"\ 100 fprintf(f,"\
98 *\n\ 101 *\n\
99 * Copyright (C) 2013 by Amaury Pouly\n\ 102 * Copyright (C) ");
103 fprintf(f, "%d by %s\n", 1900+tm.tm_year, author);
104 fprintf(f,"\
100 *\n\ 105 *\n\
101 * This program is free software; you can redistribute it and/or\n\ 106 * This program is free software; you can redistribute it and/or\n\
102 * modify it under the terms of the GNU General Public License\n\ 107 * modify it under the terms of the GNU General Public License\n\
@@ -109,14 +114,14 @@ void fprint_copyright(FILE *f, const std::vector< xml_ver_t >& versions)
109 ****************************************************************************/\n"); 114 ****************************************************************************/\n");
110} 115}
111 116
112void fprint_copyright(FILE *f, const xml_ver_t& version) 117void fprint_copyright(FILE *f, const xml_ver_t& version, char const *author)
113{ 118{
114 fprint_copyright(f, std::vector< xml_ver_t >(1, version)); 119 fprint_copyright(f, std::vector< xml_ver_t >(1, version), author);
115} 120}
116 121
117void fprint_copyright(FILE *f) 122void fprint_copyright(FILE *f, char const *author)
118{ 123{
119 fprint_copyright(f, std::vector< xml_ver_t >()); 124 fprint_copyright(f, std::vector< xml_ver_t >(), author);
120} 125}
121 126
122void fprint_include_guard_ex(FILE *f, bool begin, const std::string& name) 127void fprint_include_guard_ex(FILE *f, bool begin, const std::string& name)
@@ -280,15 +285,16 @@ void gen_soc_field(define_align_context_t& ctx, bool multidev, bool multireg, co
280 ctx.add("BF_" + prefix + "_V(v)", "((BV_" + prefix + "__##v" + " << " + to_str(field.first_bit) + ") & 0x" + to_hex(field.bitmask()) + ")"); 285 ctx.add("BF_" + prefix + "_V(v)", "((BV_" + prefix + "__##v" + " << " + to_str(field.first_bit) + ") & 0x" + to_hex(field.bitmask()) + ")");
281} 286}
282 287
283void gen_soc_reg(FILE *f, bool multidev, const soc_reg_t& reg) 288void gen_soc_reg(FILE *f, bool multidev, const soc_reg_t& reg, char const *author, char const *hwprefix)
284{ 289{
285 bool multireg = reg.addr.size() > 1; 290 bool multireg = reg.addr.size() > 1;
286 291
287 static const char *suffix[] = {"", "_SET", "_CLR", "_TOG"}; 292 static const char *suffix[] = {"", "_SET", "_CLR", "_TOG"};
288 bool sct = !!(reg.flags & REG_HAS_SCT); 293 bool sct = !!(reg.flags & REG_HAS_SCT);
289 294
295 // comment generator
290 fprintf(f, "/**\n"); 296 fprintf(f, "/**\n");
291 fprintf(f, " * Register: HW_%s_%s\n", g_soc_dev.c_str(), g_soc_reg.c_str()); 297 fprintf(f, " * Register: %s%s_%s\n", hwprefix, g_soc_dev.c_str(), g_soc_reg.c_str());
292 fprintf(f, " * Address:"); 298 fprintf(f, " * Address:");
293 if(multireg && reg.formula.type == REG_FORMULA_STRING) 299 if(multireg && reg.formula.type == REG_FORMULA_STRING)
294 { 300 {
@@ -307,47 +313,68 @@ void gen_soc_reg(FILE *f, bool multidev, const soc_reg_t& reg)
307 313
308 define_align_context_t ctx; 314 define_align_context_t ctx;
309 315
310 for(int i = 0; i < (sct ? 4 : 1); i++) 316 if (multireg && reg.formula.type != REG_FORMULA_STRING)
311 { 317 {
312 std::ostringstream name; 318 for(int i=0; i < (int)reg.addr.size(); i++)
313 name << "HW_" << g_soc_dev << "_" << g_soc_reg << suffix[i];
314 if(multidev || multireg)
315 { 319 {
316 name << "("; 320 std::ostringstream name, value;
317 if(multidev) 321 name << hwprefix << g_soc_dev << "_" << reg.addr[i].name;
318 name << "d"; 322 if (multidev)
319 if(multidev && multireg) 323 {
320 name << ","; 324 name << "(d)";
321 if(multireg) 325 }
322 name << "n"; 326 value << "(*(volatile unsigned long *)(" << g_soc_dev_regs_base;
323 name << ")"; 327 if (multidev)
328 {
329 value << "(d)";
330 }
331 value << " + 0x" << std::hex << reg.addr[i].addr << "))";
332
333 ctx.add(name.str(), value.str());
324 } 334 }
325 std::ostringstream value; 335 }
326 value << "(*(volatile unsigned long *)(" << g_soc_dev_regs_base; 336 else
327 if(multidev) 337 {
328 value << "(d)"; 338 for(int i = 0; i < (sct ? 4 : 1); i++)
329 value << " + ";
330 if(multireg)
331 { 339 {
332 if(reg.formula.type != REG_FORMULA_STRING) 340 std::ostringstream name;
333 printf("Warning: register HW_%s_%s has no formula !\n", g_soc_dev.c_str(), g_soc_reg.c_str()); 341 name << hwprefix << g_soc_dev << "_" << g_soc_reg << suffix[i];
334 std::string formula = reg.formula.string.c_str(); 342 if(multidev || multireg)
335 size_t pos = formula.find("n");
336 while(pos != std::string::npos)
337 { 343 {
338 formula.replace(pos, 1, "(n)"); 344 name << "(";
339 pos = formula.find("n", pos + 2); 345 if(multidev)
346 name << "d";
347 if(multidev && multireg)
348 name << ",";
349 if(multireg)
350 name << "n";
351 name << ")";
340 } 352 }
341 value << formula; 353 std::ostringstream value;
342 } 354 value << "(*(volatile unsigned long *)(" << g_soc_dev_regs_base;
343 else 355 if(multidev)
344 value << "0x" << std::hex << reg.addr[0].addr; 356 value << "(d)";
357 value << " + ";
358 if(multireg)
359 {
360 std::string formula = reg.formula.string.c_str();
361 size_t pos = formula.find("n");
362 while(pos != std::string::npos)
363 {
364 formula.replace(pos, 1, "(n)");
365 pos = formula.find("n", pos + 2);
366 }
367 value << formula;
368 }
369 else
370 value << "0x" << std::hex << reg.addr[0].addr;
345 371
346 if(sct) 372 if(sct)
347 value << " + 0x" << std::hex << (i * 4); 373 value << " + 0x" << std::hex << (i * 4);
348 value << "))"; 374 value << "))";
349 375
350 ctx.add(name.str(), value.str()); 376 ctx.add(name.str(), value.str());
377 }
351 } 378 }
352 379
353 for(size_t i = 0; i < reg.field.size(); i++) 380 for(size_t i = 0; i < reg.field.size(); i++)
@@ -361,7 +388,8 @@ void gen_soc_reg(FILE *f, bool multidev, const soc_reg_t& reg)
361 fprintf(f, "\n"); 388 fprintf(f, "\n");
362} 389}
363 390
364void gen_soc_dev_header(const std::string& filename, const xml_ver_t& ver, const soc_dev_t& dev) 391void gen_soc_dev_header(const std::string& filename, const xml_ver_t& ver, const soc_dev_t& dev,
392 char const *author, char const *hwprefix)
365{ 393{
366 /* 394 /*
367 printf("Generate headers for soc %s, dev %s: use file %s\n", g_soc_name.c_str(), 395 printf("Generate headers for soc %s, dev %s: use file %s\n", g_soc_name.c_str(),
@@ -373,7 +401,7 @@ void gen_soc_dev_header(const std::string& filename, const xml_ver_t& ver, const
373 printf("Cannot open %s for writing: %m\n", filename.c_str()); 401 printf("Cannot open %s for writing: %m\n", filename.c_str());
374 return; 402 return;
375 } 403 }
376 fprint_copyright(f, ver); 404 fprint_copyright(f, ver, author);
377 fprint_include_guard(f, true); 405 fprint_include_guard(f, true);
378 if(g_macro_filename.size() > 0) 406 if(g_macro_filename.size() > 0)
379 fprintf(f, "#include \"%s\"\n", g_macro_filename.c_str()); 407 fprintf(f, "#include \"%s\"\n", g_macro_filename.c_str());
@@ -400,14 +428,14 @@ void gen_soc_dev_header(const std::string& filename, const xml_ver_t& ver, const
400 for(size_t i = 0; i < dev.reg.size(); i++) 428 for(size_t i = 0; i < dev.reg.size(); i++)
401 { 429 {
402 g_soc_reg = dev.reg[i].name; 430 g_soc_reg = dev.reg[i].name;
403 gen_soc_reg(f, dev.addr.size() > 1, dev.reg[i]); 431 gen_soc_reg(f, dev.addr.size() > 1, dev.reg[i], author, hwprefix);
404 } 432 }
405 433
406 fprint_include_guard(f, false); 434 fprint_include_guard(f, false);
407 fclose(f); 435 fclose(f);
408} 436}
409 437
410void gen_soc_headers(const std::string& prefix, const soc_t& soc) 438void gen_soc_headers(const std::string& prefix, const soc_t& soc, char const *author, char const *hwprefix)
411{ 439{
412 printf("Generate headers for soc %s: use directory %s\n", soc.name.c_str(), 440 printf("Generate headers for soc %s: use directory %s\n", soc.name.c_str(),
413 prefix.c_str()); 441 prefix.c_str());
@@ -417,11 +445,11 @@ void gen_soc_headers(const std::string& prefix, const soc_t& soc)
417 { 445 {
418 g_soc_dev = soc.dev[i].name; 446 g_soc_dev = soc.dev[i].name;
419 xml_ver_t ver(soc.name, soc.dev[i].version); 447 xml_ver_t ver(soc.name, soc.dev[i].version);
420 gen_soc_dev_header(prefix + "/regs-" + tolower(g_soc_dev.c_str()) + ".h", ver, soc.dev[i]); 448 gen_soc_dev_header(prefix + "/regs-" + tolower(g_soc_dev.c_str()) + ".h", ver, soc.dev[i], author, hwprefix);
421 } 449 }
422} 450}
423 451
424void gen_headers(const std::string& prefix, const std::vector< soc_t >& socs) 452void gen_headers(const std::string& prefix, const std::vector< soc_t >& socs, char const *author, char const *hwprefix)
425{ 453{
426 for(size_t i = 0; i < socs.size(); i++) 454 for(size_t i = 0; i < socs.size(); i++)
427 { 455 {
@@ -429,7 +457,7 @@ void gen_headers(const std::string& prefix, const std::vector< soc_t >& socs)
429 std::string dir = prefix; 457 std::string dir = prefix;
430 if(g_gen_selector) 458 if(g_gen_selector)
431 dir += "/" + socs[i].name; 459 dir += "/" + socs[i].name;
432 gen_soc_headers(dir, socs[i]); 460 gen_soc_headers(dir, socs[i], author, hwprefix);
433 } 461 }
434} 462}
435 463
@@ -446,13 +474,13 @@ general_dev_list_t build_general_dev_list(const std::vector< soc_t >& socs)
446} 474}
447 475
448void gen_select_header(const std::string& filename, const std::string& dev, 476void gen_select_header(const std::string& filename, const std::string& dev,
449 const std::vector< std::string >& socs, const std::vector< xml_ver_t >& ver) 477 const std::vector< std::string >& socs, const std::vector< xml_ver_t >& ver, char const *author)
450{ 478{
451 std::string guard = "__SELECT__" + toupper(dev) + "__H__"; 479 std::string guard = "__SELECT__" + toupper(dev) + "__H__";
452 FILE *f = fopen(filename.c_str(), "w"); 480 FILE *f = fopen(filename.c_str(), "w");
453 if(f == NULL) 481 if(f == NULL)
454 error("Cannot open file %s\n", filename.c_str()); 482 error("Cannot open file %s\n", filename.c_str());
455 fprint_copyright(f, ver); 483 fprint_copyright(f, ver, author);
456 fprint_include_guard_ex(f, true, guard); 484 fprint_include_guard_ex(f, true, guard);
457 if(g_macro_filename.size() > 0) 485 if(g_macro_filename.size() > 0)
458 fprintf(f, "#include \"%s\"\n", g_macro_filename.c_str()); 486 fprintf(f, "#include \"%s\"\n", g_macro_filename.c_str());
@@ -474,7 +502,7 @@ void gen_select_header(const std::string& filename, const std::string& dev,
474 fclose(f); 502 fclose(f);
475} 503}
476 504
477void gen_selectors(const std::string& prefix, const std::vector< soc_t >& socs) 505void gen_selectors(const std::string& prefix, const std::vector< soc_t >& socs, char const *author)
478{ 506{
479 printf("Generate select headers: use directory %s\n", prefix.c_str()); 507 printf("Generate select headers: use directory %s\n", prefix.c_str());
480 general_dev_list_t map = build_general_dev_list(socs); 508 general_dev_list_t map = build_general_dev_list(socs);
@@ -489,7 +517,7 @@ void gen_selectors(const std::string& prefix, const std::vector< soc_t >& socs)
489 ver.push_back(std::make_pair(socs[soc_nr].name, socs[soc_nr].dev[dev_in_soc_nr].version)); 517 ver.push_back(std::make_pair(socs[soc_nr].name, socs[soc_nr].dev[dev_in_soc_nr].version));
490 names.push_back(socs[soc_nr].name); 518 names.push_back(socs[soc_nr].name);
491 } 519 }
492 gen_select_header(prefix + "/regs-" + it->first + ".h", it->first, names, ver); 520 gen_select_header(prefix + "/regs-" + it->first + ".h", it->first, names, ver, author);
493 } 521 }
494} 522}
495 523
@@ -510,7 +538,7 @@ void gen_macro_list(FILE *f, const std::string& prefix, int count, int nr_digits
510 } 538 }
511} 539}
512 540
513void gen_macro(const std::string& filename, bool variadic) 541void gen_macro(const std::string& filename, bool variadic, char const *author, char const *hwprefix)
514{ 542{
515 printf("Generate %smacro header: use %s\n", variadic ? "": "non-variadic ", 543 printf("Generate %smacro header: use %s\n", variadic ? "": "non-variadic ",
516 filename.c_str()); 544 filename.c_str());
@@ -518,7 +546,7 @@ void gen_macro(const std::string& filename, bool variadic)
518 FILE *f = fopen(filename.c_str(), "w"); 546 FILE *f = fopen(filename.c_str(), "w");
519 if(f == NULL) 547 if(f == NULL)
520 error("Cannot open file %s\n", filename.c_str()); 548 error("Cannot open file %s\n", filename.c_str());
521 fprint_copyright(f); 549 fprint_copyright(f, author);
522 fprint_include_guard_ex(f, true, guard); 550 fprint_include_guard_ex(f, true, guard);
523 fprintf(f, "\n"); 551 fprintf(f, "\n");
524 552
@@ -537,33 +565,33 @@ void gen_macro(const std::string& filename, bool variadic)
537 const int MAX_NARGS = 32; 565 const int MAX_NARGS = 32;
538 566
539 fprintf(f, "\ 567 fprintf(f, "\
540#define BF_SET(reg, field) "REG_WRITE"(HW_##reg##_SET, BM_##reg##_##field)\n\ 568#define BF_SET(reg, field) "REG_WRITE"(%1$s##reg##_SET, BM_##reg##_##field)\n\
541#define BF_CLR(reg, field) "REG_WRITE"(HW_##reg##_CLR, BM_##reg##_##field)\n\ 569#define BF_CLR(reg, field) "REG_WRITE"(%1$s##reg##_CLR, BM_##reg##_##field)\n\
542#define BF_TOG(reg, field) "REG_WRITE"(HW_##reg##_TOG, BM_##reg##_##field)\n\ 570#define BF_TOG(reg, field) "REG_WRITE"(%1$s##reg##_TOG, BM_##reg##_##field)\n\
543\n\ 571\n\
544#define BF_SETV(reg, field, v) "REG_WRITE"(HW_##reg##_SET, BF_##reg##_##field(v))\n\ 572#define BF_SETV(reg, field, v) "REG_WRITE"(%1$s##reg##_SET, BF_##reg##_##field(v))\n\
545#define BF_CLRV(reg, field, v) "REG_WRITE"(HW_##reg##_CLR, BF_##reg##_##field(v))\n\ 573#define BF_CLRV(reg, field, v) "REG_WRITE"(%1$s##reg##_CLR, BF_##reg##_##field(v))\n\
546#define BF_TOGV(reg, field, v) "REG_WRITE"(HW_##reg##_TOG, BF_##reg##_##field(v))\n\ 574#define BF_TOGV(reg, field, v) "REG_WRITE"(%1$s##reg##_TOG, BF_##reg##_##field(v))\n\
547\n\ 575\n\
548#define BF_RDX(val, reg, field) (("REG_READ"(val) & BM_##reg##_##field) >> BP_##reg##_##field)\n\ 576#define BF_RDX(val, reg, field) (("REG_READ"(val) & BM_##reg##_##field) >> BP_##reg##_##field)\n\
549#define BF_RD(reg, field) BF_RDX("REG_READ"(HW_##reg), reg, field)\n\ 577#define BF_RD(reg, field) BF_RDX("REG_READ"(%1$s##reg), reg, field)\n\
550#define BF_WRX(val, reg, field, v) "REG_WRITE"(val, ("REG_READ"(val) & ~BM_##reg##_##field) | (((v) << BP_##reg##_##field) & BM_##reg##_##field))\n\ 578#define BF_WRX(val, reg, field, v) "REG_WRITE"(val, ("REG_READ"(val) & ~BM_##reg##_##field) | (((v) << BP_##reg##_##field) & BM_##reg##_##field))\n\
551#define BF_WR(reg, field, v) BF_WRX(HW_##reg, reg, field, v)\n\ 579#define BF_WR(reg, field, v) BF_WRX(%1$s##reg, reg, field, v)\n\
552#define BF_WR_V(reg, field, sy) BF_WR(reg, field, BV_##reg##_##field##__##sy)\n\ 580#define BF_WR_V(reg, field, sy) BF_WR(reg, field, BV_##reg##_##field##__##sy)\n\
553#define BF_WR_VX(val, reg, field, sy) BF_WRX(val, reg, field, BV_##reg##_##field##__##sy)\n\ 581#define BF_WR_VX(val, reg, field, sy) BF_WRX(val, reg, field, BV_##reg##_##field##__##sy)\n\
554\n\ 582\n\
555#define BF_SETn(reg, n, field) "REG_WRITE"(HW_##reg##_SET(n), BM_##reg##_##field)\n\ 583#define BF_SETn(reg, n, field) "REG_WRITE"(%1$s##reg##_SET(n), BM_##reg##_##field)\n\
556#define BF_CLRn(reg, n, field) "REG_WRITE"(HW_##reg##_CLR(n), BM_##reg##_##field)\n\ 584#define BF_CLRn(reg, n, field) "REG_WRITE"(%1$s##reg##_CLR(n), BM_##reg##_##field)\n\
557#define BF_TOGn(reg, n, field) "REG_WRITE"(HW_##reg##_TOG(n), BM_##reg##_##field)\n\ 585#define BF_TOGn(reg, n, field) "REG_WRITE"(%1$s##reg##_TOG(n), BM_##reg##_##field)\n\
558\n\ 586\n\
559#define BF_SETVn(reg, n, field, v) "REG_WRITE"(HW_##reg##_SET(n), BF_##reg##_##field(v))\n\ 587#define BF_SETVn(reg, n, field, v) "REG_WRITE"(%1$s##reg##_SET(n), BF_##reg##_##field(v))\n\
560#define BF_CLRVn(reg, n, field, v) "REG_WRITE"(HW_##reg##_CLR(n), BF_##reg##_##field(v))\n\ 588#define BF_CLRVn(reg, n, field, v) "REG_WRITE"(%1$s##reg##_CLR(n), BF_##reg##_##field(v))\n\
561#define BF_TOGVn(reg, n, field, v) "REG_WRITE"(HW_##reg##_TOG(n), BF_##reg##_##field(v))\n\ 589#define BF_TOGVn(reg, n, field, v) "REG_WRITE"(%1$s##reg##_TOG(n), BF_##reg##_##field(v))\n\
562\n\ 590\n\
563#define BF_RDn(reg, n, field) BF_RDX(HW_##reg(n), reg, field)\n\ 591#define BF_RDn(reg, n, field) BF_RDX(%1$s##reg(n), reg, field)\n\
564#define BF_WRn(reg, n, field, v) BF_WRX(HW_##reg(n), reg, field, v)\n\ 592#define BF_WRn(reg, n, field, v) BF_WRX(%1$s##reg(n), reg, field, v)\n\
565#define BF_WRn_V(reg, n, field, sy) BF_WRn(reg, n, field, BV_##reg##_##field##__##sy)\n\ 593#define BF_WRn_V(reg, n, field, sy) BF_WRn(reg, n, field, BV_##reg##_##field##__##sy)\n\
566\n"); 594\n", hwprefix);
567 595
568 for(int nargs = 1; nargs <= MAX_NARGS; nargs++) 596 for(int nargs = 1; nargs <= MAX_NARGS; nargs++)
569 { 597 {
@@ -612,17 +640,21 @@ void usage()
612{ 640{
613 printf("usage: headergen [options] <desc files...> <output directory>\n"); 641 printf("usage: headergen [options] <desc files...> <output directory>\n");
614 printf("options:\n"); 642 printf("options:\n");
615 printf(" -?/--help Dispaly this help\n"); 643 printf(" -?/--help Dispaly this help\n");
616 printf(" -s/--selector Always produce selector files\n"); 644 printf(" -s/--selector Always produce selector files\n");
617 printf(" -m/--no-macro Do not generate a macro file with helpers\n"); 645 printf(" -m/--no-macro Do not generate a macro file with helpers\n");
618 printf(" -i/--no-include Do not include the macro file in the headers\n"); 646 printf(" -i/--no-include Do not include the macro file in the headers\n");
619 printf(" -v/--no-variadic Do not generate variadic macros\n"); 647 printf(" -v/--no-variadic Do not generate variadic macros\n");
648 printf(" -p/--reg-prefix \"prefix\" Prefix register names\n");
649 printf(" -a/--author \"Author\" Set author name in preamble\n");
650 printf("\n");
620 printf("Default option is to generate a macro file with variadic macros.\n"); 651 printf("Default option is to generate a macro file with variadic macros.\n");
621 printf("Default option is to include the macro file in the headers.\n"); 652 printf("Default option is to include the macro file in the headers.\n");
622 printf("Default option is to generate selector files only for two or more socs.\n"); 653 printf("Default option is to generate selector files only for two or more socs.\n");
623 printf("Default option is to create one subdirectory per soc, except if no\n"); 654 printf("Default option is to create one subdirectory per soc, except if no\n");
624 printf("selector files are needed. The subdirectories will be created if\n"); 655 printf("selector files are needed. The subdirectories will be created if necessary.\n");
625 printf("necessary.\n"); 656 printf("Default option is to not prefix register names\n");
657 printf("Default option is \"Unknown Author\" for author in preamble\n");
626 exit(1); 658 exit(1);
627} 659}
628 660
@@ -632,6 +664,9 @@ int main(int argc, char **argv)
632 bool no_variadic = false; 664 bool no_variadic = false;
633 bool no_macro = false; 665 bool no_macro = false;
634 bool no_include = false; 666 bool no_include = false;
667 char const *author = "Unknown Author";
668 char const *hwprefix = "";
669
635 if(argc <= 1) 670 if(argc <= 1)
636 usage(); 671 usage();
637 672
@@ -644,10 +679,12 @@ int main(int argc, char **argv)
644 {"no-macro", no_argument, 0, 'm'}, 679 {"no-macro", no_argument, 0, 'm'},
645 {"no-include", no_argument, 0, 'i'}, 680 {"no-include", no_argument, 0, 'i'},
646 {"no-variadic", no_argument, 0, 'v'}, 681 {"no-variadic", no_argument, 0, 'v'},
682 {"reg-prefix", required_argument, 0, 'p'},
683 {"author", required_argument, 0, 'a'},
647 {0, 0, 0, 0} 684 {0, 0, 0, 0}
648 }; 685 };
649 686
650 int c = getopt_long(argc, argv, "?smiv", long_options, NULL); 687 int c = getopt_long(argc, argv, "?smivp:a:", long_options, NULL);
651 if(c == -1) 688 if(c == -1)
652 break; 689 break;
653 switch(c) 690 switch(c)
@@ -669,6 +706,12 @@ int main(int argc, char **argv)
669 case 'v': 706 case 'v':
670 no_variadic = true; 707 no_variadic = true;
671 break; 708 break;
709 case 'a' :
710 author = optarg;
711 break;
712 case 'p' :
713 hwprefix = optarg;
714 break;
672 default: 715 default:
673 abort(); 716 abort();
674 } 717 }
@@ -691,16 +734,16 @@ int main(int argc, char **argv)
691 if(!no_macro) 734 if(!no_macro)
692 { 735 {
693 g_macro_filename = std::string(argv[argc - 1]) + "/regs-macro.h"; 736 g_macro_filename = std::string(argv[argc - 1]) + "/regs-macro.h";
694 gen_macro(g_macro_filename, !no_variadic); 737 gen_macro(g_macro_filename, !no_variadic, author, hwprefix);
695 g_macro_filename = "regs-macro.h"; 738 g_macro_filename = "regs-macro.h";
696 if(no_include) 739 if(no_include)
697 g_macro_filename.clear(); 740 g_macro_filename.clear();
698 } 741 }
699 if(g_gen_selector) 742 if(g_gen_selector)
700 { 743 {
701 gen_selectors(argv[argc - 1], socs); 744 gen_selectors(argv[argc - 1], socs, author);
702 g_macro_filename.clear(); 745 g_macro_filename.clear();
703 } 746 }
704 gen_headers(argv[argc - 1], socs); 747 gen_headers(argv[argc - 1], socs, author, hwprefix);
705 return 0; 748 return 0;
706} \ No newline at end of file 749}