Changeset 16fd5a9 in rtems
- Timestamp:
- 08/15/06 21:02:55 (17 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 67eede5
- Parents:
- 5f88544
- Location:
- tools/cpu/nios2
- Files:
-
- 5 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/cpu/nios2/ChangeLog
r5f88544 r16fd5a9 1 2006-08-15 Kolja Waschk <kawk@telos.de> 2 3 * linkcmds.c, linkcmds.h, memory.c, memory.h, sample.ptf: New files. 4 * bridges.c: corrected detection of bridged connections 5 * clocks.c: removed a printf 6 * linkcmds.[ch] new files, added output of linker script 7 * Makefile.am: added new files 8 * memory.[ch]: new files, detection of memory in SOPC configuration 9 * nios2gen.c: updated command line parsing and output control 10 * output.[ch]: improved output of BSP header file 11 * ptf.[ch]: added ptf_dump_ptf_item and small fixes 12 * sample.ptf: new file, sample configuration for nios2gen 13 * README: updated 14 1 15 2006-08-10 Joel Sherrill <joel@oarcorp.com> 2 16 -
tools/cpu/nios2/Makefile.am
r5f88544 r16fd5a9 12 12 clocks.c clocks.h \ 13 13 output.c output.h \ 14 linkcmds.c linkcmds.h \ 15 memory.c memory.h \ 14 16 ptf.h ptf.c 15 17 -
tools/cpu/nios2/README
r5f88544 r16fd5a9 1 1 $Id$ 2 3 As an output from SOPC Builder you get a file with extension ".ptf" that fully4 describes the SOPC, including all CPUs, memory and integrated peripherals.5 6 It is structured as7 8 9 10 2 11 3 nios2gen: 12 4 Tool to generate BSP data for boards utilizing NIOS2 soft core processor. 13 5 14 Specify the PTF and name of the CPU (if there are more than one). 6 ================================= 7 What it does 8 9 It creates a sopc.h and linkcmds file for RTEMS nios2 BSPs from one or more inputs: 10 11 1. SOPC System Description PTF 12 13 As an output from SOPC Builder you get a file with extension ".ptf" that fully 14 describes the SOPC, including all CPUs, memory and integrated peripherals. 15 (PTF simply means "plain-text file"). 16 17 2. BSP Configuration PTF 18 19 This file, using the same format as the SOPC System Description PTF, describes 20 which components of the SOPC shall be used by the BSP. For example, there may 21 be several timers, but a BSP wants at least one named "CLOCK" and optionally 22 another named "TIMER". This mapping can be specified in the BSP. 23 24 ================================= 25 Contents of the configuration PTF 26 27 There can be definitions of ... 28 29 HEADER: This is written to sopc.h before anything else. Example: 30 31 HEADER = " 32 #ifndef __SOPC_H 33 #define __SOPC_H 1 34 "; 35 36 EPILOG: This is written to sopc.h after anything else. Example: 37 38 EPILOG = " 39 #endif 40 "; 41 42 CLOCKS section: Used to specify names for clocks to be used in definitions in 43 the sopc.h. The default name (if none is specified here) is the uppercased name 44 as in the system description PTF. Specify the name you want on the left, the 45 name in the sopc PTF on the right! Example: 46 47 CLOCKS 48 { 49 GLOBAL_CLOCK = "sys_clk"; 50 } 51 52 MODULES section: Same as clocks but for modules / peripherals. As a special definition, 53 if the PTF contains more than one nios2 CPU, it /must/ define a CPU to use. Example to 54 select cpu_0 and rename timer_0 to CLOCK and timer_1 to TIMER: 55 56 MODULES 57 { 58 CPU = "cpu_0"; 59 CLOCK = "timer_0"; 60 TIMER = "timer_1"; 61 } 62 63 CLASS xyz sections: These specify what you want in the sopc.h, and how the definitions 64 shall be named. Actually, the CLASS xyz should look exactly like the corresponding MODULE 65 specification in the system description PTF of modules belonging to that class; e.g. a 66 a JTAG UART is originally described like this: 67 68 MODULE jtag_uart_0 69 { 70 class = "altera_avalon_jtag_uart"; 71 class_version = "1.0"; 72 iss_model_name = "altera_avalon_jtag_uart"; 73 SLAVE avalon_jtag_slave 74 { 75 SYSTEM_BUILDER_INFO 76 { 77 Bus_Type = "avalon"; 78 Is_Printable_Device = "1"; 79 Address_Alignment = "native"; 80 Address_Width = "1"; 81 Data_Width = "32"; 82 Has_IRQ = "1"; 83 Read_Wait_States = "peripheral_controlled"; 84 Write_Wait_States = "peripheral_controlled"; 85 JTAG_Hub_Base_Id = "0x04006E"; 86 JTAG_Hub_Instance_Id = "0"; 87 MASTERED_BY cpu_0/data_master 88 { 89 priority = "1"; 90 } 91 IRQ_MASTER cpu_0/data_master 92 { 93 IRQ_Number = "2"; 94 } 95 Base_Address = "0x08000000"; 96 } 97 } 98 ... 99 } 100 101 If you want to have definitions about its base address and irq number in your sopc.h, 102 define a CLASS for altera_avalon_jtag_uart that matches the MODULE description above, 103 but instead of values for the items you specify names to be used in your sopc.h (You 104 can omit items from the MODULE as you like, but the section nesting must match; and 105 section names (such as avalon_jtag_slave for the SLAVE section) also have to match) 106 107 CLASS altera_avalon_jtag_uart 108 { 109 SLAVE avalon_jtag_slave 110 { 111 SYSTEM_BUILDER_INFO 112 { 113 Base_Address = "BASE_ADDR"; 114 IRQ_MASTER { IRQ_Number = "IRQ"; } 115 } 116 } 117 } 118 119 The output for jtag_uart_0 will be: 120 121 #define JTAG_UART_BASE_ADDR 0x021208D0 122 #define JTAG_UART_IRQ 1 123 124 There are some values with special meaning to nios2gen, 125 126 N2G_CLOCKREF_CLOCK: This should be used whereever the value in the SOPC PTF 127 specifies the name of a clock. nios2gen will use whatever you configured for 128 the selected clock in your CLOCKS section. 129 130 N2G_CLOCKREF_DEVICE: This should be used whereever the value in the SOPC PTF 131 specifies the name of a module. nios2gen will use whatever you configured for 132 the selected module in your MODULES section. 133 134 Additionally, you can specify items in your CLASSes so that nios2gen will include 135 constant definitions in the sopc.h whenever such CLASS is present. The format is 136 137 N2G_DEFINE_xyz = "123" 138 139 and will result in 140 141 #define MODULENAME_xyz 123 15 142 16 143 … … 18 145 19 146 147 148 -
tools/cpu/nios2/bridges.c
r5f88544 r16fd5a9 30 30 */ 31 31 32 #include <string.h> 33 #include <stdlib.h> 34 32 35 #include "ptf.h" 33 36 #include "bridges.h" … … 41 44 bus_bridge_pair *bbp; 42 45 43 curr_master = dev_master; 44 while(curr_master != NULL) 46 if(strcmp(cpu_master, dev_master) == 0) return 1; /* cpu directly masters dev */ 47 48 for(bbp = bridges; bbp != NULL; bbp=bbp->next) 45 49 { 46 /* Does cpu_master master curr_master? */ 47 if(strcmp(cpu_master, curr_master) == 0) return 1; /* yes, cpu_masters cm */ 48 49 /* No, cm is attached to a bridge? */ 50 bbp = bridges; 51 while(bbp != NULL) 50 if(strcmp(cpu_master, bbp->mastered_by) == 0 && 51 is_bridged(bbp->bridges_to, dev_master, bridges)) 52 52 { 53 if(strcmp(bbp->bridges_to, curr_master) == 0) 54 { 55 curr_master = bbp->mastered_by; 56 break; 57 }; 58 bbp = bbp->next; 59 }; 60 if(bbp == NULL) curr_master = NULL; 53 return 1; /* cpu masters dev via bridge */ 54 } 61 55 }; 62 56 -
tools/cpu/nios2/clocks.c
r5f88544 r16fd5a9 24 24 25 25 new_clock->freq = strtoul(pi->item[pi->level]->value, 0, 0); 26 printf("freq = %lu (%s?)\n", new_clock->freq, pi->item[pi->level]->value);27 26 28 27 new_clock->cfgname = NULL; -
tools/cpu/nios2/nios2gen.c
r5f88544 r16fd5a9 17 17 #include "clocks.h" 18 18 #include "devices.h" 19 #include "memory.h" 19 20 #include "output.h" 21 #include "linkcmds.h" 22 23 #define NIOS2GEN_PACKAGE PACKAGE 24 #define NIOS2GEN_VERSION VERSION 25 26 #include "getopt.h" 20 27 21 28 /********************************************************/ … … 65 72 } 66 73 67 void usage() 68 { 69 printf( 70 "Usage: nios2gen [PTFFILE]\n" 71 "Generate BSP data based upon PTF file from SOPC Builder.\n" 72 "\n" 73 "Please specify the name of a nios2gen PTF file that describes where to\n" 74 "find the system description PTF from SOPC Builder on the command line.\n" 75 ); 76 } 77 78 void version() 79 { 80 printf( 81 "RTEMS/NIOS nios2gen\n" 74 /********************************************************/ 75 76 void version(FILE *f) 77 { 78 fprintf(f, 79 "nios2gen (" __DATE__ ")\n" 82 80 " Copyright (c) 2006 Kolja Waschk rtemsdev/ixo.de\n" 83 81 "\n" … … 85 83 " found in the file LICENSE in this distribution or at\n" 86 84 " http://www.rtems.com/license/LICENSE.\n" 85 , VERSION 87 86 ); 87 } 88 89 void usage (FILE *f, char *errmsg) 90 { 91 char *info = "Purpose:\n Create RTEMS nios2 BSP configuration from Altera SOPC description\n"; 92 if(errmsg) info=errmsg; 93 version(f); 94 fprintf(f,"\n%s\nUsage: nios2gen [OPTIONS] <SOPC PTF> [CONFIG PTF] [CONFIG PTF]...\n", info); 95 fprintf(f," -h --help Print help and exit\n"); 96 fprintf(f," -V --version Print version and exit\n"); 97 fprintf(f," -bFILENAME --bspheader=FILENAME Output BSP configuration header file (default='sopc.h')\n"); 98 fprintf(f," -B --no-bspheader Do not output BSP configuration header file\n"); 99 fprintf(f," -lFILENAME --linkcmds=FILENAME Output linker script (default='linkcmds')\n"); 100 fprintf(f," -L --no-linkcmds Do not output linker script\n"); 101 fprintf(f," -pFILENAME --parsed=FILENAME Output PTF contents as long list (default: don't)\n"); 102 fprintf(f," -P --no-parsed Do not output PTF contents as long list\n"); 103 fprintf(f," -q --quiet Do not print progress info to stdout\n\n"); 104 fprintf(f,"Using \"-\" as the FILENAME means standard output (stdout).\n"); 88 105 } 89 106 … … 97 114 bus_bridge_pair *bridges; 98 115 clock_desc *clocks; 99 100 if (argc<2) 101 { 102 usage(); 116 memory_desc *memory; 117 118 int verbose = 1; 119 int output_order = 127; 120 char *parsed_filename = NULL; 121 int output_parsed = 0; 122 char *bspheader_filename = "sopc.h"; 123 int output_bspheader = 1; 124 char *linkcmds_filename = "linkcmds"; 125 int output_linkcmds = 2; 126 127 optarg = 0; 128 optind = 1; 129 opterr = 1; 130 optopt = '?'; 131 132 if(argc > 126) 133 { 134 usage(stderr,"Too many commandline arguments!\n"); 135 return -1; 136 }; 137 138 while(1) 139 { 140 int c, long_index = 0; 141 static char *optstring = "hVBb:Ll:Pp:q"; 142 143 static struct option long_options[] = 144 { 145 { "help", 0, NULL, 'h' }, 146 { "version", 0, NULL, 'V' }, 147 { "no-bspheader", 0, NULL, 'B' }, 148 { "bspheader", 1, NULL, 'b' }, 149 { "no-linkcmds", 0, NULL, 'L' }, 150 { "linkcmds", 1, NULL, 'l' }, 151 { "no-parsed", 0, NULL, 'P' }, 152 { "parsed", 1, NULL, 'p' }, 153 { "quiet", 0, NULL, 'q' }, 154 { NULL, 0, NULL, 0 } 155 }; 156 157 c = getopt_long (argc, argv, optstring, long_options, &long_index); 158 159 if(c == -1) break; /* Exit from while(1) loop */ 160 161 switch(c) 162 { 163 case 'q': /* Be quiet */ 164 verbose = 0; 165 break; 166 167 case 'h': /* Print help and exit */ 168 usage(stdout,NULL); 169 return 0; 170 171 case 'V': /* Print version and exit */ 172 version(stdout); 173 return 0; 174 175 case 'B': /* Do not output BSP configuration header file */ 176 output_bspheader = 0; 177 break; 178 179 case 'b': /* Output BSP configuration header file */ 180 bspheader_filename = optarg; 181 output_bspheader = output_order; 182 output_order--; 183 break; 184 185 case 'L': /* Do not output linker script */ 186 output_linkcmds = 0; 187 break; 188 189 case 'l': /* Output linker script */ 190 linkcmds_filename = optarg; 191 output_linkcmds = output_order; 192 output_order--; 193 break; 194 195 case 'P': /* Do not output PTF contents */ 196 output_parsed = 0; 197 break; 198 199 case 'p': /* Output PTF contents as long list */ 200 parsed_filename = optarg; 201 output_parsed = output_order; 202 output_order--; 203 break; 204 205 case 0: 206 case '?': 103 207 return -1; 104 }; 105 106 if ( !strcmp(argv[1], "--help") || !strcmp(argv[1],"-?") ) { 107 usage(); 108 return 0; 109 }; 110 111 if ( !strcmp(argv[1], "--version") ) { 112 version(); 113 return 0; 114 }; 115 116 cfg = ptf_parse_file(argv[1]); 117 if(cfg == NULL) 118 { 119 fprintf(stderr, "Couldn't parse '%s'.\n", argv[1]); 208 209 default: 210 fprintf(stderr, "%s: unknown option: %c\n", NIOS2GEN_PACKAGE, c); 211 }; 212 }; 213 214 if(optind >= argc) 215 { 216 usage(stderr,"No PTF specified!\n"); 120 217 return -1; 121 218 }; 122 219 123 printf("Successfully read config PTF file %s.\n", argv[1]); 124 125 /********************************************************/ 220 /********************************************************/ 221 222 sopc = ptf_parse_file(argv[optind]); 223 if(sopc == NULL) 224 { 225 fprintf(stderr, "Could not parse system description PTF '%s'.\n", argv[optind]); 226 return -1; 227 }; 228 229 if(verbose) printf("Successfully read SOPC PTF file %s.\n", argv[optind]); 230 231 /********************************************************/ 232 233 cfg = NULL; 234 235 for(optind++;optind<argc;optind++) 236 { 237 struct ptf *morecfg = ptf_parse_file(argv[optind]); 238 239 if(morecfg == NULL) 240 { 241 fprintf(stderr, "Couldn't parse '%s'.\n", argv[optind]); 242 return -1; 243 }; 244 245 if(verbose) printf("Successfully read config PTF file %s.\n", argv[optind]); 246 247 cfg = ptf_concat(cfg, morecfg); 248 }; 249 250 /********************************************************/ 251 /* Pull in include files specified in the configs; */ 252 /* Only one level is read; included files are not */ 253 /* checked for further INCLUDEs */ 126 254 127 255 { … … 132 260 133 261 /********************************************************/ 134 135 {136 struct ptf *p;137 struct ptf sopc_ptf_item = { item, "SOPC_PTF", 0, 0, 0 };138 struct ptf_item sopc_ptf_spec = { 1, &sopc_ptf_item };139 ptf_match(cfg, &sopc_ptf_spec, store_ptf_ptr, &p);140 141 if(p == NULL)142 {143 fprintf(stderr, "Missing 'SOPC_PTF' filename in %s!\n", argv[1]);144 return -1;145 };146 147 sopc = ptf_parse_file(p->value);148 if(sopc == NULL)149 {150 fprintf(stderr, "Could not parse SOPC_PTF '%s'.\n", p->value);151 return -1;152 };153 154 printf("Successfully read SOPC PTF file %s.\n", p->value);155 };156 157 /********************************************************/158 262 /* Find CPU */ 159 263 160 printf("Looking for usable CPUs...\n"); 161 264 if(verbose) printf("Looking for usable CPUs...\n"); 265 266 /* Check if a CPU has been specified in the config PTF */ 162 267 { 163 268 struct ptf modules = { section, "MODULES", 0, 0, 0 }; … … 168 273 }; 169 274 275 /* Look for CPUs in system description PTF */ 170 276 { 171 277 int cpu_count; … … 181 287 if(cpu_count > 1) 182 288 { 183 printf("There is more than one CPU. Please specify the one\n");184 printf("you want to use with this BSP in your config file.\n");185 printf("The available CPUs are named as follows:\n");289 fprintf(stderr, "There is more than one CPU. Please specify the one\n"); 290 fprintf(stderr, "you want to use with this BSP in your config file.\n"); 291 fprintf(stderr, "The available CPUs are named as follows:\n"); 186 292 ptf_match(sopc, &class_spec, printf_ptf_value, " %s\n"); 187 293 return -1; … … 190 296 if(cpu_count == 0) 191 297 { 192 printf("There is no NIOS2 cpu in the system.\n");298 fprintf(stderr, "There is no NIOS2 cpu in the system.\n"); 193 299 return -1; 194 300 } 195 301 }; 196 302 197 printf("Using NIOS II CPU '%s'.\n", cpu->value); 198 printf("Only modules mastered by this CPU are considered now.\n"); 303 if(verbose) 304 { 305 printf("Using NIOS II CPU '%s'.\n", cpu->value); 306 printf("Only modules mastered by this CPU are considered now.\n"); 307 }; 308 309 /********************************************************/ 310 /* Find Bridges */ 311 312 if(verbose) printf("Looking for bus bridges...\n"); 313 314 bridges = find_bridges(sopc); 315 316 if(verbose) 317 { 318 if(bridges) 319 { 320 bus_bridge_pair *bbp; 321 for(bbp = bridges; bbp; bbp=bbp->next) 322 { 323 printf("Found bridge: %s\n", bbp->mastered_by); 324 printf(" \\_%s\n", bbp->bridges_to); 325 }; 326 } 327 else 328 { 329 printf("No bridges present.\n"); 330 }; 331 }; 199 332 200 333 /********************************************************/ 201 334 /* Find clocks */ 202 335 203 printf("Looking for clock definitions...\n");336 if(verbose) printf("Looking for clock definitions...\n"); 204 337 205 338 clocks = find_clocks(sopc, cfg); 206 339 207 if(clocks) 208 { 209 clock_desc *cs; 210 for(cs = clocks; cs; cs = cs->next) 211 { 212 printf("Found clock: %s (%lu Hz)\n", cs->name, cs->freq); 213 }; 214 } 215 else 216 { 217 printf("No clocks present.\n"); 218 }; 219 220 /********************************************************/ 221 /* Find Bridges */ 222 223 printf("Looking for bus bridges...\n"); 224 225 bridges = find_bridges(sopc); 226 227 if(bridges) 228 { 229 bus_bridge_pair *bbp; 230 for(bbp = bridges; bbp; bbp=bbp->next) 231 { 232 printf("Found bridge: %s\n", bbp->mastered_by); 233 printf(" \\_%s\n", bbp->bridges_to); 234 }; 235 } 236 else 237 { 238 printf("No bridges present.\n"); 340 if(verbose) 341 { 342 if(clocks) 343 { 344 clock_desc *cs; 345 for(cs = clocks; cs; cs = cs->next) 346 { 347 printf("Found clock \"%s\" (%lu Hz), naming it %s\n", cs->name, cs->freq, cs->cfgname); 348 }; 349 } 350 else 351 { 352 printf("No clocks present.\n"); 353 }; 239 354 }; 240 355 … … 242 357 /* Find other devices available to the selected CPU */ 243 358 359 if(verbose) printf("Looking for devices...\n"); 360 244 361 devices = find_devices(sopc, cfg, cpu, bridges); 245 362 246 fwrite_header_file(stdout, cfg, devices, clocks); 247 248 // ptf_printf(stdout, ptf, ""); 249 // ptf_printf(stdout, cfg, ""); 363 if(verbose) 364 { 365 if(devices) 366 { 367 device_desc *dd; 368 for(dd = devices; dd; dd=dd->next) 369 { 370 printf("Found device \"%s\", naming it %s\n", dd->ptf->value, dd->cfgname); 371 }; 372 } 373 else 374 { 375 printf("No devices present.\n"); 376 }; 377 }; 378 379 /********************************************************/ 380 /* Find out which devices are actually memory */ 381 382 if(verbose) printf("Looking for memory...\n"); 383 384 memory = find_memory(devices); 385 386 if(verbose) 387 { 388 if(memory) 389 { 390 memory_desc *md; 391 for(md = memory; md; md=md->next) 392 { 393 printf("Found memory in \"%s\", base=0x%08X, size=%lu bytes\n", 394 md->dev->cfgname, 395 md->base, md->size); 396 }; 397 } 398 else 399 { 400 printf("None of the devices seems to provide memory?!\n"); 401 }; 402 }; 403 404 405 /********************************************************/ 406 /* Output files in the order they were specified 407 on the command line */ 408 409 { 410 int i; 411 for(i=0;i<3;i++) 412 { 413 if(output_bspheader>0 414 && output_bspheader>=output_linkcmds 415 && output_bspheader>=output_parsed) 416 { 417 output_bspheader = 0; 418 if(bspheader_filename == NULL || (bspheader_filename[0]=='-' && bspheader_filename[1]==0)) 419 { 420 fwrite_header_file(stdout, cfg, devices, clocks); 421 } 422 else 423 { 424 FILE *f = fopen(bspheader_filename, "w"); 425 if(!f) 426 { 427 perror(bspheader_filename); 428 return -1; 429 } 430 else 431 { 432 fwrite_header_file(f, cfg, devices, clocks); 433 fclose(f); 434 } 435 } 436 }; 437 if(output_linkcmds>0 438 && output_linkcmds>=output_bspheader 439 && output_linkcmds>=output_parsed) 440 { 441 output_linkcmds = 0; 442 if(linkcmds_filename == NULL || (linkcmds_filename[0]=='-' && linkcmds_filename[1]==0)) 443 { 444 fwrite_linkcmds_file(stdout, cfg, cpu, devices, memory); 445 } 446 else 447 { 448 FILE *f = fopen(linkcmds_filename, "w"); 449 if(!f) 450 { 451 perror(linkcmds_filename); 452 return -1; 453 } 454 else 455 { 456 fwrite_linkcmds_file(f, cfg, cpu, devices, memory); 457 fclose(f); 458 } 459 } 460 }; 461 if(output_parsed>0 462 && output_parsed>=output_linkcmds 463 && output_parsed>=output_bspheader) 464 { 465 output_parsed = 0; 466 if(parsed_filename == NULL || (parsed_filename[0]=='-' && parsed_filename[1]==0)) 467 { 468 ptf_printf(stdout, sopc, ""); 469 } 470 else 471 { 472 FILE *f = fopen(parsed_filename, "w"); 473 if(!f) 474 { 475 perror(parsed_filename); 476 return -1; 477 } 478 else 479 { 480 ptf_printf(f, sopc, ""); 481 fclose(f); 482 } 483 } 484 }; 485 } 486 }; 487 488 if(verbose) printf("Done.\n"); 250 489 251 490 return 0; -
tools/cpu/nios2/output.c
r5f88544 r16fd5a9 151 151 struct ptf_item matchaclass = { 1, &aclass }; 152 152 153 struct ptf header = { item, "HEADER", 0, 0, 0 }; 154 struct ptf_item matchheader = { 1, &header }; 153 struct ptf bspsect = { section, "BSPHEADER", 0, 0, 0 }; 154 struct ptf leadtext = { item, "LEADTEXT", 0, 0, 0 }; 155 struct ptf_item matchleadtext = { 2, &bspsect, &leadtext }; 155 156 156 157 struct ptf epilog = { item, "EPILOG", 0, 0, 0 }; 157 struct ptf_item matchepilog = { 1, &epilog };158 struct ptf_item matchepilog = { 2, &bspsect, &epilog }; 158 159 159 160 out_desc dinfo; … … 163 164 dinfo.devices = devices; 164 165 165 ptf_match(cfg, &match header, fwrite_value, file);166 ptf_match(cfg, &matchleadtext, fwrite_value, file); 166 167 167 168 if(clocks) … … 178 179 for(dinfo.dev = devices; dinfo.dev; dinfo.dev=dinfo.dev->next) 179 180 { 180 fprintf(file, "\n");181 /* fprintf(file, "\n#define SOPC_HAS_%s 1\n", dinfo.dev->cfgname); */ 181 182 182 183 p = ptf_find(dinfo.dev->ptf, &pi, item, "class", 0); … … 192 193 } 193 194 194 195 195 -
tools/cpu/nios2/output.h
r5f88544 r16fd5a9 20 20 #include "devices.h" 21 21 22 void fwrite_value(struct ptf_item *pi, void *arg); 22 23 void fwrite_header_file(FILE *file, struct ptf *cfg, device_desc *devices, clock_desc *clocks); 23 24 -
tools/cpu/nios2/ptf.c
r5f88544 r16fd5a9 10 10 11 11 #include <stdio.h> 12 #include <string.h> 12 13 #include <errno.h> 13 14 #include "ptf.h" … … 365 366 default: 366 367 #if DEBUG&DEBUG_EXPECTATIONS 367 printf("Expectation: %d (? ??)\n", state->expectation);368 printf("Expectation: %d (?)\n", state->expectation); 368 369 #endif 369 370 … … 507 508 508 509 return state.tree; 510 } 511 512 /***************************************************************************/ 513 514 struct ptf *ptf_concat(struct ptf *a, struct ptf *b) 515 { 516 struct ptf *leaf = a; 517 518 if(!a) return b; 519 if(!b) return a; 520 521 for(leaf = a; leaf->next != NULL; leaf = leaf->next); 522 leaf->next = b; 523 return a; 524 } 525 526 /***************************************************************************/ 527 528 void ptf_dump_ptf_item(FILE *f, struct ptf_item *pi) 529 { 530 int i; 531 fprintf(f, "level=%d in %p\n", pi->level, pi); 532 for(i=pi->level;i>=0;i--) 533 { 534 if(pi->item[i] != NULL) 535 { 536 fprintf(f, " %d: %s name=%s value=%s\n", 537 i, 538 pi->item[i]->type == item ? "item":"section", 539 pi->item[i]->name, 540 pi->item[i]->value); 541 } 542 else 543 { 544 fprintf(f, " %d: NULL\n"); 545 } 546 fflush(f); 547 } 509 548 } 510 549 … … 533 572 if(leaf->value != NULL && leaf->value[0] != 0) 534 573 { 535 strcat(new_prefix, " _");574 strcat(new_prefix, ":"); 536 575 strcat(new_prefix, leaf->value); 537 576 }; 538 577 strcat(new_prefix, "/"); 539 578 fputs(new_prefix, s); 540 fputs("\ r\n", s);579 fputs("\n", s); 541 580 ptf_printf(s, leaf->sub, new_prefix); 542 581 break; … … 549 588 fputs(leaf->name, s); 550 589 fputs(" = \"", s); 551 for(c=leaf->value; *c; c++) 552 { 553 if(*c=='\\' || *c=='"') putc('\\', s); 554 putc(*c, s); 555 }; 556 fprintf(s, "\"\r\n"); 590 if(leaf->value == NULL) 591 { 592 fputs("(NULL)", s); 593 } 594 else 595 { 596 for(c=leaf->value; *c; c++) 597 { 598 if(*c=='\\' || *c=='"') putc('\\', s); 599 putc(*c, s); 600 }; 601 } 602 fprintf(s, "\"\n"); 557 603 break; 558 604 }; -
tools/cpu/nios2/ptf.h
r5f88544 r16fd5a9 41 41 42 42 struct ptf *ptf_parse_file(char *filename); 43 struct ptf *ptf_concat(struct ptf *a, struct ptf *b); 43 44 struct ptf *ptf_alloc_item(ptf_item_type t, char *name, char *value); 44 45 void ptf_printf(FILE *s, struct ptf *tree, char *prefix); 46 void ptf_dump_ptf_item(FILE *s, struct ptf_item *pi); 45 47 46 48 struct ptf *ptf_find(
Note: See TracChangeset
for help on using the changeset viewer.