Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | #!/import/bw/tools/local/perl-5.8.0/bin/perl |
2 | ||
3 | eval 'exec /import/bw/tools/local/perl-5.8.0/bin/perl -S $0 ${1+"$@"}' | |
4 | if 0; # not running under some shell | |
5 | ||
6 | use strict; | |
7 | use warnings; | |
8 | ||
9 | use Midas; | |
10 | use Midas::Error; | |
11 | ||
12 | my $status = midas(@ARGV); | |
13 | ||
14 | if($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 | ||
31 | exit($status); | |
32 | ||
33 | ############################################################################## | |
34 | ||
35 | __END__ | |
36 | ||
37 | =head1 NAME | |
38 | ||
39 | midas - assembles diags (Midas Is a Diag ASsembler) | |
40 | ||
41 | =head1 SYNOPSIS | |
42 | ||
43 | midas [options] <diag_name> | |
44 | ||
45 | =head1 DESCRIPTION | |
46 | ||
47 | This program builds assembly diags. It is substantially more involved | |
48 | than simply assembling the diag because it also has to link the diag, | |
49 | program the MMU, and generate several output files. | |
50 | ||
51 | The diag specified on the command line will be built. Pretty much | |
52 | everything else is configurable. | |
53 | ||
54 | =head2 Options | |
55 | ||
56 | The following are the options you need to get started: | |
57 | ||
58 | =over 4 | |
59 | ||
60 | =item -h | |
61 | ||
62 | Display man page. | |
63 | ||
64 | =item -verbose [level] / -noverbose (abbreviated -v / -nov) | |
65 | ||
66 | Sets verbosity level (default=2). -noverbose (or -nov) is a synonym | |
67 | for -verbose 0, which means to generate no output in the absence of | |
68 | errors. The highest level of verbosity currently defined is 3. | |
69 | ||
70 | =item -version | |
71 | ||
72 | Return version information and exit. | |
73 | ||
74 | =item -format | |
75 | ||
76 | Display help on the diag format and exit. | |
77 | ||
78 | =item -config E<lt>fileE<gt> | |
79 | ||
80 | Use this file as the config file instead of the one that is | |
81 | distributed with Midas. | |
82 | ||
83 | =item -project E<lt>projectE<gt> | |
84 | ||
85 | Use this project for project-specific configuration. Default is the | |
86 | environment variable $PROJECT. Legal values are BW and N2. | |
87 | ||
88 | =back | |
89 | ||
90 | =head2 Common Options | |
91 | ||
92 | The following are the commonly-used options: | |
93 | ||
94 | =over 4 | |
95 | ||
96 | =item -diag_root E<lt>pathE<gt> | |
97 | ||
98 | Use the specified path as a base for finding standard include files. | |
99 | Default is $DV_ROOT. | |
100 | ||
101 | =item -build_dir E<lt>pathE<gt> | |
102 | ||
103 | Path (absolute or relative to where command is invoked) to directory | |
104 | where temporary files are generated and the build is done. Default is | |
105 | './build'. | |
106 | ||
107 | =item -dest_dir E<lt>pathE<gt> | |
108 | ||
109 | Path (absolute or relative to where command is invoked) of where to | |
110 | store output files. Default is '.'. | |
111 | ||
112 | =item -find_root E<lt>dirE<gt> | |
113 | ||
114 | Interpret the diag on the command-line as the name of a diag to search | |
115 | for. It does a breadth-first search under the specified directory. | |
116 | The default behavior is not to do any search, but to assume that the | |
117 | specified diag is a full or relative path to the file. | |
118 | ||
119 | =item -find | |
120 | ||
121 | This is a shortcut for "-find_root E<lt>diag_rootE<gt>/verif/diag". | |
122 | ||
123 | =item -mmu E<lt>mmu_typeE<gt> | |
124 | ||
125 | Generate programming for the specified MMU. Recognized options are | |
126 | "ultra2", "niagara", "niagara2", and "rock". Default is | |
127 | project-specific: "niagara" for Niagara-1 and "niagara2" for | |
128 | Niagara-2. | |
129 | ||
130 | =item -ttefmt E<lt>tte_formatE<gt> | |
131 | ||
132 | Specifies TTE format for those MMUs that require it. May be "sun4u" | |
133 | or "sun4v". Default is project-specific: "sun4v" for Niagara-1 and | |
134 | Niagara-2. | |
135 | ||
136 | =item -tsbtagfmt E<lt>tsbtagfmtE<gt> | |
137 | ||
138 | Specifies 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 | ||
143 | Build the diag, even if it looks like we have the same input as before | |
144 | and the same args as before. | |
145 | ||
146 | =item -copy_products / -nocopy_products | |
147 | ||
148 | By default, the product files generated in the build directory are | |
149 | hard-linked to the destination directory. The reason they are | |
150 | hard-linked and not copied is for speed. If the hard link fails, it | |
151 | will fall back to a copy in case the directories are on different | |
152 | physical disks. If -copy_products is given, however, it will always | |
153 | do a copy, not a hard link. Default is project-specific: | |
154 | -nocopy_products for Niagara-1. | |
155 | ||
156 | =item -E | |
157 | ||
158 | Stop after the preprocessing stage. | |
159 | ||
160 | =item -cleanup / -nocleanup | |
161 | ||
162 | If -cleanup is enabled, then after a successful build, the build | |
163 | directory is erased if and only if the build directory was created by | |
164 | this invocation of midas. Default is project-specific: -cleanup for | |
165 | Niagara-1. | |
166 | ||
167 | =item -force_cleanup / -noforce_cleanup | |
168 | ||
169 | If -cleanup is enabled, but this invocation of midas did not create | |
170 | the build directory, -force_cleanup will remove the build directory | |
171 | anyway. 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 | ||
175 | Add a define to the preprocessing line. Option may be repeated. | |
176 | ||
177 | =item -stddef / -nostddef | |
178 | ||
179 | Include standard preprocessor definitions on command-line. -nostddef | |
180 | disables these. Default is -stddef, but no standard symbols are | |
181 | currently defined. | |
182 | ||
183 | =item -IE<lt>dirE<gt> | |
184 | ||
185 | Add a directory to the include path used by cpp and m4. Path should | |
186 | be absolute or relative to the directory where midas was invoked. | |
187 | Option may be repeated. | |
188 | ||
189 | =item -stdinc / -nostdinc | |
190 | ||
191 | With -stdinc, the standard include paths are used during preprocessing | |
192 | (both cpp and m4). -nostdinc disables these. Default is -stdinc. | |
193 | The standard include directories are the directory where midas was | |
194 | invoked, the build directory and | |
195 | E<lt>diag_rootE<gt>/verif/diag/assembly/include (keep in mind that | |
196 | E<lt>diag_rootE<gt> defaults to $DV_ROOT). | |
197 | ||
198 | =item -include_build / -noinclude_build | |
199 | ||
200 | This option is only meaningful with -nostdinc. If standard includes | |
201 | are switched off, -include_build will add the build directory back to | |
202 | the include path. Default is -noinclude_build. | |
203 | ||
204 | =item -include_start / -noinclude_start | |
205 | ||
206 | This option is only meaningful with -nostdinc. If standard includes | |
207 | are switched off, -include_start will add the start directory (the | |
208 | directory where midas was invoked) back to the include path. | |
209 | Default is -noinclude_start. | |
210 | ||
211 | =item -LE<lt>dirE<gt> | |
212 | ||
213 | Add a directory to the search path when looking for object files in a | |
214 | MIDAS_OBJ directive. Option may be repeated. | |
215 | ||
216 | =item -CE<lt>dirE<gt> | |
217 | ||
218 | Add a directory to the search path when looking for C source files in | |
219 | a MIDAS_CC directive. Option may be repeated. | |
220 | ||
221 | =item -pal_diag_args E<lt>argsE<gt> | |
222 | ||
223 | If the diag is run through pal, give these arguments to the pal diag. | |
224 | Option may be repeated. Note that these arguements are given to the | |
225 | diag, 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 | ||
232 | When doing work that can be done in parallel (such as assembling a | |
233 | bunch of files), use E<lt>num_threadsE<gt> to do it. Default is | |
234 | project-specific: 3 for Niagara-1. | |
235 | ||
236 | =item -print_errors / -noprint_errors | |
237 | ||
238 | If -noprint_errors is defined, then generation of error messages is | |
239 | turned off. When used with -verbose 0, midas is completly silent. | |
240 | This is probalby only useful for the test harness (which is why the | |
241 | switch is there). | |
242 | ||
243 | =item -copy_products / -nocopy_products | |
244 | ||
245 | If this is set, then copy files from the build directory to the | |
246 | starting directory. With -nocopy_products, the files are hard linked | |
247 | instead. If it tries to create a hard link and fails, it will fall | |
248 | back to a copy. Default is -nocopy_products. | |
249 | ||
250 | =item -compress_image / -nocompress_image | |
251 | ||
252 | If -compress_image is enabled (as it is by default), then allow | |
253 | compressed mem.images to be generated. By default, all MMU-generated | |
254 | blocks are compressed when written to mem.image, meaning that instead | |
255 | of initializing unused sections to zero, they are simply | |
256 | uninitialized. The -nocompress_image is equivalent to explicitly | |
257 | putting a 'compressimage=0' in all attr_text/attr_data blocks. | |
258 | ||
259 | =item -env_zero / -noenv_zero | |
260 | ||
261 | When compressing blocks, if -env_zero is enabled the blocks will | |
262 | contain '// zero_image' directives to the environment. These | |
263 | directives are supported only by Niagara, and they are used to | |
264 | backdoor initialize large tracts of memory to zero. If -noenv_zero is | |
265 | used, then compression will simply leave the data uninitialized. | |
266 | ||
267 | ||
268 | =item -default_radix E<lt>decimal|hexE<gt> | |
269 | ||
270 | Radix 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 | ||
275 | If -gen_all_tsbs is given, then all TSBs that are defined are written | |
276 | to the memory image. If -nogen_all_tsbs, then generate only the TSBs | |
277 | that are used. Default is project-specific: -nogen_all_tsbs for | |
278 | Niagara-1. | |
279 | ||
280 | =item -allow_tsb_conflicts / -noallow_tsb_conflicts | |
281 | ||
282 | If -allow_tsb_conflicts is enabled, then it is legal to have mutiple | |
283 | virtual address map to the same entry in a TSB. A linked-list will be | |
284 | created to hold all entries. With -noallow_tsb_conflicts (which is | |
285 | the default for N1), collisions in the TSB can only happen with the | |
286 | save VA but different contexts. Default is project-specific. | |
287 | ||
288 | =item -allow_empty_sections / -noallow_empty_sections | |
289 | ||
290 | If TEXT_VA is specified, then at least one attr_text block for the | |
291 | section has to be specified, and the same is true for DATA_VA and | |
292 | attr_data blocks. If -allow_empty_sections is specified, then midas | |
293 | will allow you to specify a TEXT_VA(DATA_VA) for the section, even if | |
294 | the section has no attr_text(attr_data) blocks. Of course, any | |
295 | text(data) in such a section will be ignored. Default is | |
296 | project-specific: -noallow_empty_sections for Niagara-1. | |
297 | ||
298 | =item -allow_duplicate_tags / -noallow_duplicate_tags | |
299 | ||
300 | When adding to a TSB link list, it is an error to add the same tag | |
301 | twice. -allow_duplicate_tags suspends the error check. Default is | |
302 | project-specific: -noallow_duplicate_tags for Niagara-1. | |
303 | ||
304 | =item -allow_illegal_page_sizes / -noallow_illegal_page_sizes | |
305 | ||
306 | If -allow_illegal_page_sizes, then tte_size attributes are not checked | |
307 | for valid values, though they are still checked against the width of | |
308 | the field. For instance, in the Niagara MMU, there are 3 page bits, | |
309 | so values can be specified 0-7. However, the only legal values for | |
310 | Niagara are 0, 1, 3, and 5, and unless -allow_illegal_page_sizes is in | |
311 | effect, setting page bits of 2, 4, 6, or 7 will cause an error. The | |
312 | default is project-specific: -noallow_illegal_page_sizes for | |
313 | Niagara-1. | |
314 | ||
315 | =item -allow_misalgined_tsb_base / -noallow_misaligned_tsb_base | |
316 | ||
317 | If -allow_misaligned_tsb_base is set, then a TSB base address need not | |
318 | be aligned with the TSB size. Real software will never do this, but I | |
319 | want it to be possible in diags. If an unalgined address is specified | |
320 | as the base and -allow_misaligned_tsb_base is specified, then midas | |
321 | will 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 | ||
327 | Prints a one-line description for the midas error code. Then exits | |
328 | with status 0. | |
329 | ||
330 | =back | |
331 | ||
332 | =head2 Configuring Commands | |
333 | ||
334 | midas runs several commands in the course of its operation. Several | |
335 | of these can be configured. The configurable commands are: pal, cpp, | |
336 | m4, 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 | ||
342 | When -std_E<lt>commandE<gt>_args is enabled, the standard set of | |
343 | arguments 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 | ||
348 | Add 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 | ||
352 | Use E<lt>custom_commandE<gt> to run the specifed E<lt>commandE<gt> | |
353 | instead of the standard version. | |
354 | ||
355 | =back | |
356 | ||
357 | =head3 Example | |
358 | ||
359 | For instance, to add -foo to the link line, use my_cpp to preprocess, and | |
360 | not 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 | ||
367 | There are several generated files, and they all have default names. | |
368 | You can configure the names of many of the files with the following | |
369 | option. | |
370 | ||
371 | =over 4 | |
372 | ||
373 | =item -file E<lt>tagE<gt>=E<lt>nameE<gt> | |
374 | ||
375 | Cause midas to name the file whose tag is E<lt>tagE<gt> to be named | |
376 | E<lt>nameE<gt> instead of the default. E<lt>nameE<gt> is treated as | |
377 | the name of a file in the build directory. | |
378 | ||
379 | =back | |
380 | ||
381 | The list of valid tags for the -file option are: | |
382 | ||
383 | =over 4 | |
384 | ||
385 | =item src | |
386 | ||
387 | Local version of the original source code for the diag. Default is 'diag.src'. | |
388 | ||
389 | =item s | |
390 | ||
391 | Assembly portion of diag before any preprocessing. Default is 'diag.s'. | |
392 | ||
393 | =item pl | |
394 | ||
395 | Perl portion of the diag. Deafult is 'diag.pl'. | |
396 | ||
397 | =item cpp | |
398 | ||
399 | Output of the C preprocessor. Deafult is 'diag.cpp'. | |
400 | ||
401 | =item m4 | |
402 | ||
403 | Output of the m4 preprocessor. Default is 'diag.m4'. | |
404 | ||
405 | =item ldscr | |
406 | ||
407 | Linker script. Default is 'diag.ls_scr'. | |
408 | ||
409 | =item exe | |
410 | ||
411 | Linked executable. Default is 'diag*.exe' where * is | |
412 | application name. | |
413 | ||
414 | =item image | |
415 | ||
416 | Verilog memory image. Default is 'mem.image'. | |
417 | ||
418 | =item events | |
419 | ||
420 | Events file. Default is 'diag.ev'. | |
421 | ||
422 | =item symtab | |
423 | ||
424 | Symbol table. Default is 'symbol.tbl'. | |
425 | ||
426 | =item goldfinger | |
427 | ||
428 | Specification to goldfinger on how to create memory image. Default is | |
429 | 'diag.goldfinger'. | |
430 | ||
431 | =item directives | |
432 | ||
433 | File to contain midas directives after section splitting. Default is | |
434 | 'diag.midas'. | |
435 | ||
436 | =item cmdfile | |
437 | ||
438 | File to stash the midas command-line. Default is '.midas_args'. | |
439 | ||
440 | =item oldcmdfile | |
441 | ||
442 | File to move old command-line options. Default is '.midas_args.old'. | |
443 | ||
444 | =item oldm4 | |
445 | ||
446 | File to stash m4 output of previous run. Default is '.midas.diag.m4.old'. | |
447 | ||
448 | =back | |
449 | ||
450 | =head2 Running Specific Phases | |
451 | ||
452 | The build process is broken into phases: setup, preprocess, | |
453 | sectioning, assemble, link, postprocess, copydest, cleanup. The | |
454 | default behavior is to run all phases. You can, however, restrict | |
455 | operation to a selected set of phases. | |
456 | ||
457 | =over 4 | |
458 | ||
459 | =item -start_phase E<lt>phase_nameE<gt> | |
460 | ||
461 | Start with the named phase and run all subsequent phase. | |
462 | ||
463 | =item -phase E<lt>phase_nameE<gt> | |
464 | ||
465 | Run the specified phase. If any -phase or -start_phase option exists, | |
466 | then by default all phases are off (except for the ones that -phase | |
467 | and -start_phase switch on). You can have multiple -phase options. | |
468 | ||
469 | =item -E | |
470 | ||
471 | This option (mentioned above, which runs the preprocessor only) is just a | |
472 | shortcut for "-phase setup -phase preprocess"). | |
473 | ||
474 | =back | |
475 | ||
476 | Keep in mind that running selected phases is caveat emptor. There are | |
477 | cases where phases expect data or files from previous phases. You may | |
478 | get lucky, but don't blame me if it doesn't work. | |
479 | ||
480 | =head2 Errors | |
481 | ||
482 | When midas is unable to run correctly it will exit with one of the | |
483 | folllowing 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 | ||
572 | Jeff Gibson E<lt>jeff.gibson@sun.comE<gt> | |
573 | ||
574 | =head1 SEE ALSO | |
575 | ||
576 | Midas(3), goldfinger(1). | |
577 |