Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / bin / midas
CommitLineData
86530b38
AT
1#!/import/bw/tools/local/perl-5.8.0/bin/perl
2
3eval 'exec /import/bw/tools/local/perl-5.8.0/bin/perl -S $0 ${1+"$@"}'
4 if 0; # not running under some shell
5
6use strict;
7use warnings;
8
9use Midas;
10use Midas::Error;
11
12my $status = midas(@ARGV);
13
14if($status == M_ARGERR) {
15
16 my $code = qq{
17 use Pod::Usage;
18
19 pod2usage(-exitval => $status,
20 -verbose => 1);
21
22 };
23
24 eval $code;
25 if($@) {
26 print STDERR "Midas having trouble reporting argument error.\n";
27 exit -1;
28 }
29}
30
31exit($status);
32
33##############################################################################
34
35__END__
36
37=head1 NAME
38
39midas - assembles diags (Midas Is a Diag ASsembler)
40
41=head1 SYNOPSIS
42
43midas [options] <diag_name>
44
45=head1 DESCRIPTION
46
47This program builds assembly diags. It is substantially more involved
48than simply assembling the diag because it also has to link the diag,
49program the MMU, and generate several output files.
50
51The diag specified on the command line will be built. Pretty much
52everything else is configurable.
53
54=head2 Options
55
56The following are the options you need to get started:
57
58=over 4
59
60=item -h
61
62Display man page.
63
64=item -verbose [level] / -noverbose (abbreviated -v / -nov)
65
66Sets verbosity level (default=2). -noverbose (or -nov) is a synonym
67for -verbose 0, which means to generate no output in the absence of
68errors. The highest level of verbosity currently defined is 3.
69
70=item -version
71
72Return version information and exit.
73
74=item -format
75
76Display help on the diag format and exit.
77
78=item -config E<lt>fileE<gt>
79
80Use this file as the config file instead of the one that is
81distributed with Midas.
82
83=item -project E<lt>projectE<gt>
84
85Use this project for project-specific configuration. Default is the
86environment variable $PROJECT. Legal values are BW and N2.
87
88=back
89
90=head2 Common Options
91
92The following are the commonly-used options:
93
94=over 4
95
96=item -diag_root E<lt>pathE<gt>
97
98Use the specified path as a base for finding standard include files.
99Default is $DV_ROOT.
100
101=item -build_dir E<lt>pathE<gt>
102
103Path (absolute or relative to where command is invoked) to directory
104where temporary files are generated and the build is done. Default is
105'./build'.
106
107=item -dest_dir E<lt>pathE<gt>
108
109Path (absolute or relative to where command is invoked) of where to
110store output files. Default is '.'.
111
112=item -find_root E<lt>dirE<gt>
113
114Interpret the diag on the command-line as the name of a diag to search
115for. It does a breadth-first search under the specified directory.
116The default behavior is not to do any search, but to assume that the
117specified diag is a full or relative path to the file.
118
119=item -find
120
121This is a shortcut for "-find_root E<lt>diag_rootE<gt>/verif/diag".
122
123=item -mmu E<lt>mmu_typeE<gt>
124
125Generate programming for the specified MMU. Recognized options are
126"ultra2", "niagara", "niagara2", and "rock". Default is
127project-specific: "niagara" for Niagara-1 and "niagara2" for
128Niagara-2.
129
130=item -ttefmt E<lt>tte_formatE<gt>
131
132Specifies TTE format for those MMUs that require it. May be "sun4u"
133or "sun4v". Default is project-specific: "sun4v" for Niagara-1 and
134Niagara-2.
135
136=item -tsbtagfmt E<lt>tsbtagfmtE<gt>
137
138Specifies the format of the TSB tag. Legal values are 'tagaccess' and
139'tagtarget'. Default is project-specific: 'tagaccess' for Niagara-1 and 'tagtarget' for Niagara-2.
140
141=item -force_build or -f
142
143Build the diag, even if it looks like we have the same input as before
144and the same args as before.
145
146=item -copy_products / -nocopy_products
147
148By default, the product files generated in the build directory are
149hard-linked to the destination directory. The reason they are
150hard-linked and not copied is for speed. If the hard link fails, it
151will fall back to a copy in case the directories are on different
152physical disks. If -copy_products is given, however, it will always
153do a copy, not a hard link. Default is project-specific:
154-nocopy_products for Niagara-1.
155
156=item -E
157
158Stop after the preprocessing stage.
159
160=item -cleanup / -nocleanup
161
162If -cleanup is enabled, then after a successful build, the build
163directory is erased if and only if the build directory was created by
164this invocation of midas. Default is project-specific: -cleanup for
165Niagara-1.
166
167=item -force_cleanup / -noforce_cleanup
168
169If -cleanup is enabled, but this invocation of midas did not create
170the build directory, -force_cleanup will remove the build directory
171anyway. Default is project-specific: -noforce_cleanup for Niagara-1.
172
173=item -DE<lt>symbolE<gt> or -DE<lt>symbolE<gt>=E<lt>valueE<gt>
174
175Add a define to the preprocessing line. Option may be repeated.
176
177=item -stddef / -nostddef
178
179Include standard preprocessor definitions on command-line. -nostddef
180disables these. Default is -stddef, but no standard symbols are
181currently defined.
182
183=item -IE<lt>dirE<gt>
184
185Add a directory to the include path used by cpp and m4. Path should
186be absolute or relative to the directory where midas was invoked.
187Option may be repeated.
188
189=item -stdinc / -nostdinc
190
191With -stdinc, the standard include paths are used during preprocessing
192(both cpp and m4). -nostdinc disables these. Default is -stdinc.
193The standard include directories are the directory where midas was
194invoked, the build directory and
195E<lt>diag_rootE<gt>/verif/diag/assembly/include (keep in mind that
196E<lt>diag_rootE<gt> defaults to $DV_ROOT).
197
198=item -include_build / -noinclude_build
199
200This option is only meaningful with -nostdinc. If standard includes
201are switched off, -include_build will add the build directory back to
202the include path. Default is -noinclude_build.
203
204=item -include_start / -noinclude_start
205
206This option is only meaningful with -nostdinc. If standard includes
207are switched off, -include_start will add the start directory (the
208directory where midas was invoked) back to the include path.
209Default is -noinclude_start.
210
211=item -LE<lt>dirE<gt>
212
213Add a directory to the search path when looking for object files in a
214MIDAS_OBJ directive. Option may be repeated.
215
216=item -CE<lt>dirE<gt>
217
218Add a directory to the search path when looking for C source files in
219a MIDAS_CC directive. Option may be repeated.
220
221=item -pal_diag_args E<lt>argsE<gt>
222
223If the diag is run through pal, give these arguments to the pal diag.
224Option may be repeated. Note that these arguements are given to the
225diag, not pal itself. For instance, "midas -pal_args -abc mydiag.pal
226-pal_diag_args def -pal_diag_args ghi" will run the pal command-line
227"pal -abc mydiag.pal def ghi".
228
229
230=item -build_threads E<lt>num_threadsE<gt>
231
232When doing work that can be done in parallel (such as assembling a
233bunch of files), use E<lt>num_threadsE<gt> to do it. Default is
234project-specific: 3 for Niagara-1.
235
236=item -print_errors / -noprint_errors
237
238If -noprint_errors is defined, then generation of error messages is
239turned off. When used with -verbose 0, midas is completly silent.
240This is probalby only useful for the test harness (which is why the
241switch is there).
242
243=item -copy_products / -nocopy_products
244
245If this is set, then copy files from the build directory to the
246starting directory. With -nocopy_products, the files are hard linked
247instead. If it tries to create a hard link and fails, it will fall
248back to a copy. Default is -nocopy_products.
249
250=item -compress_image / -nocompress_image
251
252If -compress_image is enabled (as it is by default), then allow
253compressed mem.images to be generated. By default, all MMU-generated
254blocks are compressed when written to mem.image, meaning that instead
255of initializing unused sections to zero, they are simply
256uninitialized. The -nocompress_image is equivalent to explicitly
257putting a 'compressimage=0' in all attr_text/attr_data blocks.
258
259=item -env_zero / -noenv_zero
260
261When compressing blocks, if -env_zero is enabled the blocks will
262contain '// zero_image' directives to the environment. These
263directives are supported only by Niagara, and they are used to
264backdoor initialize large tracts of memory to zero. If -noenv_zero is
265used, then compression will simply leave the data uninitialized.
266
267
268=item -default_radix E<lt>decimal|hexE<gt>
269
270Radix to assume for all parameters that do not explicitly start with
271'0x'. Default is 'decimal'.
272
273=item -gen_all_tsbs / -nogen_all_tsbs
274
275If -gen_all_tsbs is given, then all TSBs that are defined are written
276to the memory image. If -nogen_all_tsbs, then generate only the TSBs
277that are used. Default is project-specific: -nogen_all_tsbs for
278Niagara-1.
279
280=item -allow_tsb_conflicts / -noallow_tsb_conflicts
281
282If -allow_tsb_conflicts is enabled, then it is legal to have mutiple
283virtual address map to the same entry in a TSB. A linked-list will be
284created to hold all entries. With -noallow_tsb_conflicts (which is
285the default for N1), collisions in the TSB can only happen with the
286save VA but different contexts. Default is project-specific.
287
288=item -allow_empty_sections / -noallow_empty_sections
289
290If TEXT_VA is specified, then at least one attr_text block for the
291section has to be specified, and the same is true for DATA_VA and
292attr_data blocks. If -allow_empty_sections is specified, then midas
293will allow you to specify a TEXT_VA(DATA_VA) for the section, even if
294the section has no attr_text(attr_data) blocks. Of course, any
295text(data) in such a section will be ignored. Default is
296project-specific: -noallow_empty_sections for Niagara-1.
297
298=item -allow_duplicate_tags / -noallow_duplicate_tags
299
300When adding to a TSB link list, it is an error to add the same tag
301twice. -allow_duplicate_tags suspends the error check. Default is
302project-specific: -noallow_duplicate_tags for Niagara-1.
303
304=item -allow_illegal_page_sizes / -noallow_illegal_page_sizes
305
306If -allow_illegal_page_sizes, then tte_size attributes are not checked
307for valid values, though they are still checked against the width of
308the field. For instance, in the Niagara MMU, there are 3 page bits,
309so values can be specified 0-7. However, the only legal values for
310Niagara are 0, 1, 3, and 5, and unless -allow_illegal_page_sizes is in
311effect, setting page bits of 2, 4, 6, or 7 will cause an error. The
312default is project-specific: -noallow_illegal_page_sizes for
313Niagara-1.
314
315=item -allow_misalgined_tsb_base / -noallow_misaligned_tsb_base
316
317If -allow_misaligned_tsb_base is set, then a TSB base address need not
318be aligned with the TSB size. Real software will never do this, but I
319want it to be possible in diags. If an unalgined address is specified
320as the base and -allow_misaligned_tsb_base is specified, then midas
321will forcibly align the address. Default should be
322-noallow_misaligned_tsb_base for all projects.
323
324
325=item -errcode E<lt>error_codeE<gt>
326
327Prints a one-line description for the midas error code. Then exits
328with status 0.
329
330=back
331
332=head2 Configuring Commands
333
334midas runs several commands in the course of its operation. Several
335of these can be configured. The configurable commands are: pal, cpp,
336m4, gcc, as, and ld. Each configurable command has 3 associated options:
337
338=over 4
339
340=item -std_E<lt>commandE<gt>_args / -nostd_E<lt>commandE<gt>_args
341
342When -std_E<lt>commandE<gt>_args is enabled, the standard set of
343arguments for E<lt>commandE<gt> are used. Default is
344-std_E<lt>commandE<gt>_args
345
346=item -E<lt>commandE<gt>_args E<lt>argsE<gt>
347
348Add E<lt>argsE<gt> to the argument list for the specified E<lt>commandE<gt>.
349
350=item -E<lt>commandE<gt>_cmd E<lt>custom_commandE<gt>
351
352Use E<lt>custom_commandE<gt> to run the specifed E<lt>commandE<gt>
353instead of the standard version.
354
355=back
356
357=head3 Example
358
359For instance, to add -foo to the link line, use my_cpp to preprocess, and
360not use any standard assembler options, use:
361
362 midas -ld_args -foo -cpp_cmd my_cpp -nostd_as_args mydiag.s
363
364
365=head2 Configuring Filenames
366
367There are several generated files, and they all have default names.
368You can configure the names of many of the files with the following
369option.
370
371=over 4
372
373=item -file E<lt>tagE<gt>=E<lt>nameE<gt>
374
375Cause midas to name the file whose tag is E<lt>tagE<gt> to be named
376E<lt>nameE<gt> instead of the default. E<lt>nameE<gt> is treated as
377the name of a file in the build directory.
378
379=back
380
381The list of valid tags for the -file option are:
382
383=over 4
384
385=item src
386
387Local version of the original source code for the diag. Default is 'diag.src'.
388
389=item s
390
391Assembly portion of diag before any preprocessing. Default is 'diag.s'.
392
393=item pl
394
395Perl portion of the diag. Deafult is 'diag.pl'.
396
397=item cpp
398
399Output of the C preprocessor. Deafult is 'diag.cpp'.
400
401=item m4
402
403Output of the m4 preprocessor. Default is 'diag.m4'.
404
405=item ldscr
406
407Linker script. Default is 'diag.ls_scr'.
408
409=item exe
410
411Linked executable. Default is 'diag*.exe' where * is
412application name.
413
414=item image
415
416Verilog memory image. Default is 'mem.image'.
417
418=item events
419
420Events file. Default is 'diag.ev'.
421
422=item symtab
423
424Symbol table. Default is 'symbol.tbl'.
425
426=item goldfinger
427
428Specification to goldfinger on how to create memory image. Default is
429'diag.goldfinger'.
430
431=item directives
432
433File to contain midas directives after section splitting. Default is
434'diag.midas'.
435
436=item cmdfile
437
438File to stash the midas command-line. Default is '.midas_args'.
439
440=item oldcmdfile
441
442File to move old command-line options. Default is '.midas_args.old'.
443
444=item oldm4
445
446File to stash m4 output of previous run. Default is '.midas.diag.m4.old'.
447
448=back
449
450=head2 Running Specific Phases
451
452The build process is broken into phases: setup, preprocess,
453sectioning, assemble, link, postprocess, copydest, cleanup. The
454default behavior is to run all phases. You can, however, restrict
455operation to a selected set of phases.
456
457=over 4
458
459=item -start_phase E<lt>phase_nameE<gt>
460
461Start with the named phase and run all subsequent phase.
462
463=item -phase E<lt>phase_nameE<gt>
464
465Run the specified phase. If any -phase or -start_phase option exists,
466then by default all phases are off (except for the ones that -phase
467and -start_phase switch on). You can have multiple -phase options.
468
469=item -E
470
471This option (mentioned above, which runs the preprocessor only) is just a
472shortcut for "-phase setup -phase preprocess").
473
474=back
475
476Keep in mind that running selected phases is caveat emptor. There are
477cases where phases expect data or files from previous phases. You may
478get lucky, but don't blame me if it doesn't work.
479
480=head2 Errors
481
482When midas is unable to run correctly it will exit with one of the
483folllowing error codes.
484
485=over 4
486
487
488=item M_NOERROR (#0): No error.
489
490
491=item M_MISC (#1): Miscellaneous error
492
493=item M_CODE (#2): Error in midas code.
494
495=item M_DIR (#3): Directory error.
496
497=item M_FILE (#4): File error.
498
499=item M_CMDFAIL (#5): Command failed.
500
501=item M_SECSYNTAX (#6): Error in section syntax.
502
503=item M_ATTRSYNTAX (#7): Error in attr syntax.
504
505=item M_MISSINGPARAM (#8): Missing parameter.
506
507=item M_ILLEGALPARAM (#9): Illegal parameter.
508
509=item M_OUTOFRANGE (#10): Out of range.
510
511=item M_NOTNUM (#11): Not a number.
512
513=item M_VACOLLIDE (#12): VA collision.
514
515=item M_PACOLLIDE (#13): PA collision.
516
517=item M_DIRECTIVESYNTAX (#14): Directive syntax error.
518
519=item M_GENFAIL (#15): File generation failed.
520
521=item M_ASMFAIL (#16): Assembler failed.
522
523=item M_CCFAIL (#17): C compiler failed.
524
525=item M_LINKFAIL (#18): Linker failed.
526
527=item M_CPPFAIL (#19): CPP failed.
528
529=item M_M4FAIL (#20): M4 preprocessor failed.
530
531=item M_BADCONFIG (#21): Bad configuration.
532
533=item M_EVENTERR (#22): Event parsing error.
534
535=item M_ARGERR (#23): Argument error.
536
537=item M_NOSEC (#24): Undefined section.
538
539=item M_BADTSB (#25): Bad TSB.
540
541=item M_BADALIGN (#26): Bad Alignment.
542
543=item M_EMPTYSECTION (#27): Empty section.
544
545=item M_TSBSYNTAX (#28): Error in tsb syntax.
546
547=item M_APPSYNTAX (#29): Error in app syntax.'
548
549=item M_MEMORY (#30): Memory error.
550
551=item M_GOLDFINGERPARSE (#31): Goldfinger parse error.
552
553=item M_GOLDFINGERARG (#32): Goldfinger arg error.
554
555=item M_ELF (#33): ELF error.
556
557=item M_BADLABEL (#34): Bad label.
558
559=item M_GOLDFINGERMISC (#35): Uncategorized goldfinger error.
560
561=item M_GOLDFINGERVERSION (#36): Bad version of goldfinger
562
563=item M_DUPLICATETAG (#37): Duplicate tags in TSB
564
565=item M_BLOCKSYNTAX (#38): Error defining goldfinger BLOCK
566
567
568=back
569
570=head1 AUTHOR
571
572Jeff Gibson E<lt>jeff.gibson@sun.comE<gt>
573
574=head1 SEE ALSO
575
576 Midas(3), goldfinger(1).
577