Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / bin / midasformat
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 Pod::Usage;
8use File::Temp qw(tempfile);
9use Midas::MMU::TTEFormat;
10
11my ($ofh, $filename) = tempfile(".midasformat.XXXX", UNLINK=>1);
12
13my $src = $0;
14open(SRC, "<$src") || die "Can't open '$src': $!\n";
15while(<SRC>) {
16 my $line = $_;
17
18 if($line =~ /^\%\%TTE\s*DATA\s*(\S+)\s*(\S+)/) {
19 my ($mmu, $format) = ($1, $2);
20
21 if(exists $TSB_DATA_FORMAT{$mmu}{$format}) {
22
23 foreach my $key (keys %{$TSB_DATA_FORMAT{$mmu}{$format}}) {
24 my $rec = $TSB_DATA_FORMAT{$mmu}{$format}{$key};
25
26
27 my $bits = ($rec->{hi} == $rec->{lo}) ?
28 "$rec->{hi}" :"$rec->{hi}:$rec->{lo}";
29
30 printf $ofh "=item TTE_%-6s Bits %5s ", $key, $bits;
31
32 if(defined $rec->{descr}) {
33 print $ofh "$rec->{descr}\n";
34 print $ofh "\n";
35 }
36
37 print $ofh "\n";
38
39 }
40 }
41 } else {
42 print $ofh $line;
43 }
44}
45close SRC;
46
47pod2usage(-verbose => 2,
48 -exitval => 0,
49 -input => $filename);
50
51exit(0);
52
53__END__
54
55=head1 NAME
56
57midasformat - Format for diags recognized by B<midas>
58
59=head1 DESCRIPTION
60
61This document describes the format of diags that can be assembled by
62B<midas>. Note that this is not a guide for writing diags, since it
63makes no assumptions about the contents of project-standard include
64files or boot code.
65
66=head2 Source Languages
67
68B<Midas> can assemble diags in the following formats:
69
70=over 4
71
72=item Augmented Assembly
73
74The main supported source language, denoted with a .s extension on the
75source file, is an augmented SPARC assembly file. By "augmented", we
76refer to several directives used to program the MMU. These directives
77are interpreted by B<midas>, and their presence means that the raw diag,
78even though it ends in .s, would not be acceptable input to a standard
79assembler.
80
81An assembly diag should be one file, though it may #include others. A
82diag may also contain a perl script, used by the simulation framework
83to do postprocessing on the diag's output. B<Midas> scans a diag for the
84symbol "__PERL__" on a line by itself. If it finds such a symbol,
85then everything after the __PERL__ line is taken to be a perl script
86and is not assembled.
87
88=item PAL (perl augmented language)
89
90A diag that ends in a .pal extension is assumed to be written in PAL
91(perl augmented language). The diag is run through the PAL
92preprocessor, and the output of PAL should be an augmented assembly
93file as described above. B<Midas> takes care of running the PAL
94preprocesing phase if the diag ends in .pal. Since PAL and assembly
95diags are treated identically after PAL preprocessing, the remainder
96of the this document discusses only assembly diags.
97
98=item C
99
100The top-level diag file is always an augmented assembly file (or a PAL
101script that generated an augmented assembly file), but there are
102directives to include C programs in a diag. See the L</"High Level
103Languages"> section.
104
105=item Object files (.o) and Library files (.a)
106
107As with C files, raw object (.o) files and static library (.a) files
108may be included in a diag. See the L</"High Level Languages">
109section.
110
111=item Linked Executables
112
113These can be included as-is in a diag. See the L</"APPLICATION">
114section.
115
116=back
117
118=head2 Output Files
119
120The following output files are generated by B<midas>: (the names of the
121output files can be reconfigured, but these are the default names)
122
123=over 4
124
125=item F<mem.image>
126
127The F<mem.image> file is the main output of B<midas>. It contains the
128initial contents of physical memory in a verilog memory-image format.
129The format consists lines containing "@E<lt>physical_addressE<gt>",
130followed by lines of data to write at that address.
131
132=item F<diag.ev>
133
134This is an event file generated for vera. Any assembly line that
135contains a comment that begins with "$EV" will generate an entry in
136this file. I<XXX - this format should be documented further.>
137
138=item F<symbol.tbl>
139
140This file contains 4 columns: symbol_name, virtual_addres, real
141address, and physical_address. It exists to support the simulation
142framework so it can lookup addresses for symbol names. If any of the
143addresses are inappropriate (such as real address for unmapped
144sections), it will be represented by 'X'.
145
146=item F<diag.pl>
147
148This is a perl script extracted from the diag (i.e., the code after
149the "__PERL__" directive). It is used by the simulation framework to
150do diag-specific post-processing.
151
152=item F<diag*.exe>
153
154This is the linked executable built by B<midas> (the * is the name of
155the application, if there is a non-default application). It is not
156used by the simulation framework, but it can be useful, for instance,
157for disassembly.
158
159=back
160
161=head1 BUILD PROCESS
162
163This section is an overview of how a diag is processed to produce
164F<mem.image>.
165
166=head2 Preprocessing
167
168Diags are run through several preprocessing steps that enable complex
169macro environments to perform diag setup. Such macro environments are
170not part of B<midas> and are therefore beyond the scope of this document.
171
172=over 4
173
174=item Split perl and assembly
175
176The first preprocessing step is to split the diag into assembly and
177perl parts. B<Midas> assumes that the diag is entirely assembly
178unless it encounters the symbol "__PERL__" on a line by itself. If it
179sees this symbol, then everything after it assumed to be a perl
180script. The output of this phase are files in the build directory:
181F<diag.s> and, if necessary, F<diag.pl>.
182
183=item B<cpp>
184
185The next step is to run the diag through the C preprocessor. Most
186diags will #include their boot code and perhaps some project-specific
187definitions. Diags can also #define symbols before including the boot
188code to configure its operation. Note that this is a Sun, not a GNU,
189preprocessor, which means that GNU extensions to cpp (such as
190preprocessor directives where the '#' isn't in column 1) cannot be
191used. For information the default include path, consult the B<midas>
192man page. The output of this stage is a file in the build directory
193called F<diag.cpp>.
194
195=item B<m4>
196
197After B<cpp>, the diag is processed by B<m4>. This allows macro
198preprocessing that is substantially more powerful than what is
199possible with B<cpp>. The content of these macros is
200project-specific. The version of B<m4> used by B<midas> is special in
201that it was compiled to allow 64-bit arithmetic via the C<mpeval>
202directive. The output of this stage is a file in the build directory
203called F<diag.m4>.
204
205=item Sectioning
206
207A diag is made up of sections. Each section may contain a text, data,
208bss or other segments. The defining characteristic of a section is
209that each segment is contiguous in the virtual address space (i.e.,
210the text segment is contiguous and so is the data segment, but they
211need not be contiguous with each other). A section begins with a
212C<SECTION> directive at the beginning of a line. The C<SECTION> line
213defines the section's name and optionally some parameters. Any data
214or code appearing after a C<SECTION> directive belongs to that
215section, until the next C<SECTION> directive is encountered. Any code
216or data before the first C<SECTION> directive is part of the first
217section.
218
219If a SECTION line appears for a section that has previously been
220defined, the meaning is to append to the existing section. It is
221illegal to have SECTION-line arguments for any but the first
222definition of a section. Note that it simply appends to the existing
223section, so be sure to begin your appended version with a .text or
224.data assembly directive, as appropriate.
225
226
227Sections are linked at a specific, user-defined address. Linker
228scripts require that each section be in a separte file. The
229sectioning phase, therefore, extracts the C<SECTION> directives from
230the assembly file and writes "pure" assembly files for each section.
231By "pure", we mean that these files have no B<midas>-specific
232directives and can therefore be assembled directly.
233
234The output of this phase are a series of files in the build directory,
235one for each section. Their names are
236F<secE<lt>numE<gt>.E<lt>secnameE<gt>.s>. The sectioning phase also
237produces the file 'diag.midas' which contains all of the midas
238directives. Midas then parses this file, and leaves the others to the
239assembler.
240
241=back
242
243=head2 Assembly
244
245Each section written by the sectioning phase above is assembled via
246the GNU assembler. The output is a .o file.
247
248=head2 Link executable
249
250All object files are linked, using the GNU loader. Each section is
251linked at the virtual address defined in its section header. The
252output of this phase is F<diag.exe>.
253
254=head2 PostProcessing
255
256After the diag is linked, the following postprocessing is done:
257
258=over 4
259
260=item Generate F<mem.image>
261
262Generation of F<mem.image> is done a section at a time, not by simply
263disassembling F<diag.exe>. The reason is that F<mem.image> should
264represent the initial contents of physical memory, which may or may
265not be a simple dump of the text and data segments for each section.
266For most diags, this will simply be a hex dump of F<diag.exe> (with
267the sections linked at the appropriate physical addresses, as defined
268by the section header). How exactly the MMU constructs F<mem.image>
269is controlled by the section header, which is described in detail in
270the next section. Generation of F<mem.image> is handled by
271B<goldfinger>.
272
273=item Generate F<symbol.tbl>
274
275To generate the symbol table, the F<diag.exe> file is examined to find
276virtual addresses for each symbol. The MMU is then used to do the
277virtual-to-physical translation and write the F<symbol.tbl> file.
278Generation of F<symbol.tbl> is handled by B<goldfinger>.
279
280=item Generate F<diag.ev>
281
282The F<diag.ev> file is generated by examining the diag source for
283comments containing C<$EV>. These are then cross-referenced with
284F<symbol.tbl> to producde F<diag.ev>.
285
286=back
287
288=head1 DIAG FORMAT
289
290A diag consists of applications and sections within those
291applications. Diags may also contain TSBs.
292
293=head2 APPLICATION
294
295An application begins with:
296
297 APPLICATION <name> [FILE=<filename>]
298
299An application defines a single linked executable. All SECTIONs that
300follow are linked into this application. A linked executable is just
301an intermediate file in F<mem.image> generation, so an APPLICATION
302directive affects only relocation and the scope of labels. All diags
303have at least one application, even if none is defined, since all
304diags are treated as if their first line were:
305
306 APPLICATION default
307
308If the optional filename is given, then that file is taken as the
309linked executable to use. The link path is searched to find a file by
310this name. This is how you can include a linked executable that was
311not generated by B<midas>.
312
313=head3 goldfinger_cmd blocks
314
315There is currently no way to specify address translations and
316F<mem.image> contents for applications that midas does not generate.
317As the tool matures, I plan to invent an interface. In the meantime,
318you can include a goldfinger_cmd block. Such a block begins a line
319with "goldfinger_cmd" and an open curly-brace. It ends with the
320closed-curly. The contents of the block are not interpreted B<midas>
321at all. They are simply copied into F<diag.goldfinger> inside the
322currently open application.
323
324An example:
325
326 goldfinger_cmd {
327 BLOCK .main_text_0
328 SECTION_NAME = ".MAIN";
329 SEGMENT_NAME = "text";
330 LINK_SECTION = "sec7.maint";
331 SRC_FILE = "diag.m4";
332 SRC_LINE = 5398;
333 COMPRESS = 0;
334 VA = 0x0000000020000000;
335 RA = 0x0130000000;
336 PA = 0x1130000000;
337 IN_IMAGE = 1;
338 BLOCK_TSB part_0_i_ctx_nonzero_ps0_tsb
339 page_size = 8192;
340 va_index_bits = 21 : 13;
341 tag_addr_bits = 63 : 13;
342 data_addr_bits = 39 : 13;
343 tag_base = 0x0000000000000044;
344 data_base = 0x8000000000000440;
345 END BLOCK_TSB
346 END BLOCK
347 }
348
349Note that until the tool matures, the B<midas>-B<goldfinger> interface
350may change, so this syntax is deprecated, but it can be useful in a
351pinch.
352
353
354=head2 SECTION Definitions
355
356A SECTION defines a region of the diag that may contain up to 3
357segments: text, data, and bss. Each of these segments is contiguous
358in the virtual address space (but not necessarily in the real or
359physical address spaces). Note that the B<midas> terminology is
360different from the B<ELF> terminology. Each segment in B<midas>
361terminology corresponds to an B<ELF> section.
362
363 SECTION <name> [section_args]
364
365When a section directive is encountered, all assembly code (and data)
366that follows is placed in that section, until the next SECTION
367directive is encountered.
368
369The C<SECTION> header affects the text and data segments that follow
370it, until another C<SECTION> header is reached. As a special case,
371all code and data in the assembly file before the first C<SECTION>
372header belongs to the first section. A SECTION line may be split
373across multiple lines of input by escaping the newline with a \.
374
375The section_args should define the virtual addresses at which to link
376the various segments. This is done by a comma-separated list such as:
377
378 SECTION .MAIN TEXT_VA=0x20000000, DATA_VA=0x60000000, \
379 BSS_VA=0x68030000
380
381Any of the virtual addresses may be ommitted, but if they are, that
382segment will not be included in the link. The *_VA symbols are all
383case-insensitive. The addresses themselves are assumed to be 64-bit
384decimal numbers, unless they start with 0x (in which case they are
38564-bit hex numbers).
386
387See the section on L<"ADDRESS TRANSLATIONS"> for details on how
388address translations can be specified for the segments in a section.
389Note that unless address translations are specified, there is no
390physical address to place segments in the F<mem.image> file!
391
392=head2 TSB OBJECT DEFINITIONS
393
394A TSB object is decared with the following syntax:
395
396 MIDAS_TSB <name> <register> [args]
397
398This defines a TSB with the specified name, which is initialized by
399the config register E<lt>registerE<gt>. It will be instantiated in
400the memory image if any attr block tries to use it. All MMU types get
401a base address and TSB size from the config register as defined in
402their PRM. Niagara-2, in addition, parses a page size (same meaning
403as the page_size optional argument below) and sun4u/sun4v, which will
404be used instead of the global default for ttefmt. Note that if you
405provide the optional arguments page_size and/or ttefmt for Niagara-2,
406the optional arguments will override the config register.
407
408The optional args can be:
409
410=over 4
411
412=item link=E<lt>nameE<gt>
413
414Use the specified name as a link area. This is used in the case of
415TSB collisions to hold a linked list. There must be MIDAS_TSB_LINK
416declaration by this name.
417
418=item force_ctx_zero
419
420If this is specified, then any entries added to this TSB will have
421context bits of zero, regardless of how they are specified in the attr blocks.
422
423=item page_size=E<lt>codedSizeE<gt>
424
425This defines a default page size for all entries that are added to the
426TSB. This will be used if no TTE_Size_Ptr values are given for the
427entries. The coded size is the same encoding used in the TTE_Size
428field.
429
430=item way=E<lt>wayE<gt>
431
432If a TSB is split (which only applies to the "ultra2" and "niagara"
433MMU types), this is specified to midas by creating two TSBs that have
434the same value of the config register with the split bit set. Midas
435treats each half of the TSB separately. This makes it easy for diags
436to control which half of the split TSB gets each translation. The way
437definition on the TSB line tells midas which half of the split TSB
438applies to this definition. The only legal settings are "way=0" and
439"way=1". If way is set to zero, the TSB is configured just as if it
440were not split. If way is set to one, then the base address is
441modifed internally so that it starts after the way=0 TSB would end.
442The way setting is ignored if the TSB is not split or if the MMU type
443does not support split TSBs. It is the responsibility of the diag
444writer to make sure that the two halves of a split TSB are configured
445in a compatible fashion (both sides having split bit on and the same
446base address).
447
448=item ttefmt=E<lt>formatE<gt>
449
450Sets the format for this TSB to the specified format (either sun4u or
451sun4v). This setting will be used instead of the default value of
452-ttefmt.
453
454=back
455
456=head2 TSB_LINK OBJECT DEFINITIONS
457
458A TSB_LINK object is an area used to store linked lists in the case of
459collisions in the TSB. Multiple TSBs can share a TSB_LINK. The
460syntax is:
461
462 MIDAS_TSB_LINK <name> <pa>
463
464This declares a TSB_LINK object that will start at the specified PA.
465It will be instantiated in the memory image if any TSB that uses it is
466instantiated.
467
468
469=head2 ADDRESS TRANSLATIONS
470
471Address translations are created by attr_ blocks. The name of the
472block defines the segment on which the block operates. They syntax is:
473
474 attr_<segment_name> {
475 name|section=<name>,
476 <key>=<val>, <key>=<val>,
477 <key>=<val>
478 ...
479 }
480
481The E<lt>segment_nameE<gt> may be "text", "data", or "bss". Each attr
482block must specify which SECTION they belong to. They do this by
483setting name= or section= inside the block. This means the attr block
484itself may appear anywhere in the diag, not necessarily lexically
485inside the section. The blocks are matched to the sections by name,
486which is case-insensitive.
487
488The contents of the block are a list of key=value pairs (name|section=
489just being a special case). These pairs can be separated by commas
490and/or newlines. Key names are case-insensitive. A TSB name may
491appear as a key with no value. If any other key appears with no
492=value, the value is assumed to be 1.
493
494An example of an attr block is:
495
496 attr_text {
497 Name = .TRAPS,
498 RA = 0x120000,
499 PA = 0x1000120000,
500 part_0_i_ctx_zero_ps0_tsb,
501 TTE_Context=0, TTE_V=1, TTE_Size=0,
502 TTE_NFO=0, TTE_IE=0, TTE_Soft2=0, TTE_Diag=0,
503 TTE_Soft=0, TTE_L=0, TTE_CP=1, TTE_CV=0,
504 TTE_E=0, TTE_P=1, TTE_W=1
505 }
506
507An attr block has two purposes: setting up TSB mappings and writing to
508F<mem.image>. It therefore needs to contain enough information to:
509
510=over 4
511
512=item Select a subset of the segment
513
514An attr block need not define the same translation for an entire
515segment, and it may define a subset of the segment on which to
516operated.
517
518=item Physical address
519
520This defines where to write the segment (or segment subset) in the
521F<mem.image>.
522
523=item Define TSB parameters
524
525These include a list of TSBs that should contain translations for this
526section, an RA (real address) that should be included in the TSB, and
527TTE elements. The exact details may be processor-specific. It is
528controlled by the mmu type. Note that for MMUs that do not have
529two-level address translation (i.e., "ultra2"), there is no RA, so PA
530is used for TSBs instead.
531
532
533=back
534
535=head3 Selecting a subset
536
537Selecting a subset consits of defining a starting and stopping virtual
538address for the block.
539
540=head4 Defining the starting virtual address
541
542=over 4
543
544=item start_label
545
546If the key C<start_label> exists it must be a label inside the
547segment. It is used as the beginning of the attr block. It must be a
548page-aligned address unless the block is not being entered into a TSB.
549
550=item VA
551
552The attr block may explicitly define a starting virtual address using
553the tag C<VA>. It is an error if this virtual address is not a
554page-aligned address within the segment (if the block is not writing a
555TSB entry the alignment contraint is relaxed). For this reason, the
556start_label syntax is the preferred one for most diags.
557
558=item I<default>
559
560If neither VA nor start_label are specified for an attr block, the
561starting VA for the segment is used.
562
563=back
564
565=head4 Defining the ending virtual address
566
567There are three ways to define the ending address for an attr block.
568
569=over 4
570
571=item end_label
572
573If C<end_label> is defined, it must be label inside the segment (and
574of course, it must appear after the starting VA). The C<attr_text>
575definiton ends at the address of the label. The address need not be
576page-aligned.
577
578=item end_va
579
580The attr block may explicitly define an ending virtual address. It is
581an error if this address is not part of this segment. If the special
582attribute C<uninitialized> is used (see below), then end_va may be
583specified past the end of the segment. The C<uninitialized> attribute
584implies C<tsbonly> (i.e., data is written to the TSB but not to the
585memory image).
586
587=item I<default>
588
589If neither end_label nor end_va are specified, then the attr block
590lasts until the end of the section.
591
592=back
593
594=head3 Physical address
595
596An attr block must have one of the following keys to define the
597physical address. The physical address is used to write F<mem.image>
598
599=over 4
600
601=item PA
602
603The physical address is specified with the tag "PA". It should be set
604to an address, and the subset of the segment will be written to the
605F<mem.image> file at that physical address. It is an error to write
606to the same physical address twice in the same diag.
607
608=item tsbonly
609
610This special key tells the attr block not to write anything to
611F<mem.image>. It can be used if you want to create TSB entries but do
612not want to overwrite something to F<mem.image>. If the key "PA" is
613included, it is used only for symbol table generation.
614
615=item uninitialized
616
617This is exactly the same as tsbonly, except that normally the "end_va"
618key is checked to make sure that it is contained in the segment.
619Using uninitialized instead of tsbonly suspends that check.
620
621=item hypervisor (or bypass on "ultra2" MMU)
622
623The special tag "hypervisor" tells the attr block bypass both VA to RA
624translation and RA to PA tranlation. The segment will be completely
625unmapped. Therefore, it will not generate any TSB mappings, and it
626will write to F<mem.image> at PA=VA (actually, it generates a PA from
627as many low bits of the VA as will fit in a PA). It is used for
628segments where the MMU is off. For mmus that have only one level of
629address translation (i.e., "ultra2"), the key "hypervisor" does not
630exist, but "bypass" has the same meaning.
631
632=item compressimage
633
634This does not control the address, but it does affect how F<mem.image>
635creation is done. If compressimage is given in an attr block then
636lines of zeros are suppressed in F<mem.image> generation. Each
637aligned 32-byte chunk is compared against 0. If all bits are 0, then
638it is not written to mem.image. If the global -env_zero switch is
639enabled (on by default in Niagara-1), then a backdoor mechanism is
640used to initialize the memory to zero in the environment. Otherwise,
641it is left uninitialized. If the environment does not intialize all
642memory to zero, then this can actually change the meaning of
643mem.image, since it makes zero-ed memory uninitialized, rather than
644intialized to zero. If the flag -nocompress_image is given to
645B<midas>, then no blocks are compressed, regardless of compressimage
646tags.
647
648=head3 TSB parameters
649
650The following parameters should be set in each attr block (unless it
651contains the "hypervisor" key described above, or the "bypass" key for
652"ultra2"):
653
654=over 4
655
656=item RA
657
658This defines the real address (middle of the 3-address scheme). It is
659the address to be written to the TSB data. It must be page-aligned.
660In the "ultra2" MMU, there is no RA, so the PA gets double-duty: PA is
661used both for mem.image generation and for TSB data.
662
663=item bypass
664
665This directive means to bypass VA to RA translation. In an MMU with
666two levels of address translation (like niagara), it simply sets RA=VA
667(actually, as many low bits of VA as will fit). It is an error to
668specify both RA and bypass. In an MMU with one level of translation
669("ultra2"), it means to bypass all address translation, so its
670function is similar to the hypervisor directive described above.
671
672=item E<lt>tsb_nameE<gt>
673
674Any tsb names that are listed (and there may be more than one) will
675cause the attr block to add the subset to those TSBs. The tsb_names
676must be defined somewhere in the diag with a MIDAS_TSB directive.
677
678=item notsb
679
680Tells the attr block not to do any TSB generation. If RA is provided,
681it is simply used in the symbol table.
682
683=back
684
685Unless notsb is defined or the section is completely unmapped (bypass
686for "ultra2" or hypervisor for other MMUs), the attr block will be
687writing TSB entries. The following parameters are used to set the
688appropriate bits of the TSB entry. How exactly the TSB entries are
689formed is mmu-specific. Check the PRM for your processor. The
690default value for TTE_V (valid) is 1. The default value for all other
691fields is 0.
692
693=head3 MMU-Specific TTE Settings
694
695The fields in the TSB tag and data depend on the MMU type and the
696currently configured ttefmt setting (sun4u or sun4v). The ttefmt is
697can be contralled by the TSBs (which is always the case in Niagara-2)
698or by the global default set by -ttefmt. The MMU specific settings
699are described below. The default for each TTE setting is 0, except
700for TTE_V (valid), which defaults to 1. All TTE tags are
701case-insensitive.
702
703=head4 Ultrasparc II MMU "ultra2"
704
705The ultra2 MMU type supports only the sun4u TTE data format.
706
707=over 4
708
709=item TTE_G Tag: 1 bit Global
710
711=item TTE_Context Tag:13 bits Context
712
713%%TTE DATA ultra2 sun4u
714
715=back
716
717=head4 Niagara MMU "niagara"
718
719The niagara MMU supports both the sun4u and sun4v TTE data formats.
720
721For sun4u, the following fields are valid:
722
723=over 4
724
725=item TTE_Context Tag:13 bits Context
726
727%%TTE DATA niagara sun4u
728
729=back
730
731The following fields are valid for sun4v:
732
733=over 4
734
735=item TTE_Context Tag:13 bits Context
736
737%%TTE DATA niagara sun4v
738
739=back
740
741=head4 Niagara2 MMU "niagara2"
742
743The niagara2 MMU supports both the sun4u and sun4v TTE data format.
744
745For sun4u, the following fields are valid:
746
747=over 4
748
749=item TTE_Context Tag:13 bits Context
750
751%%TTE DATA niagara2 sun4u
752
753=back
754
755The following fields are valid for sun4v:
756
757=over 4
758
759=item TTE_Context Tag:13 bits Context
760
761%%TTE DATA niagara2 sun4v
762
763=back
764
765=head4 Rock MMU "rock"
766
767The rock MMU supports only the sun4v data format.
768
769=over 4
770
771=item TTE_Context Tag:13 bits Context
772
773%%TTE DATA rock sun4v
774
775=back
776
777There are a few special cases to be aware of:
778
779=over 4
780
781=item TTE_Size
782
783This is the size bits field to use in the TSB entry. It is also used
784to calculate the number of pages the attr block will create. The attr
785block will create as many pages as it needs to to span the section.
786The TTE_Size field controls the size of these pages. See the PRM for
787the exact coding of page size in TTE_Size. For Niagara, Niagara-2,
788and Rock, the encoding is:
789
790=over 4
791
792=item 0 -> 8 kB
793
794=item 1 -> 64 kB
795
796=item 2 -> 512 kB (illegal on Niagara and Niagara-2)
797
798=item 3 -> 4 MB
799
800=item 5 -> 256 MB
801
802=item 6 -> 2 GB (illegal on Niagara and Niagara-2)
803
804=item 7 -> 16 GB (illegal on Niagara and Niagara-2)
805
806=back
807
808The "ultra2" MMU only has a 2-bit size field, so it supports page
809sizes 0-3 (which are also 8 kB - 4 MB).
810
811Note that when the above sections state that VA, RA, and PA must be
812page-aligned when adding them to a TSB, this is where the page size
813comes from.
814
815=item TTE_Size_Ptr
816
817The page size is used in the formula to calculate a TSB pointer. The
818page size used for pointer calculation is controlled by a hardware
819register, but B<midas> needs to set up the TSBs statically. By
820default, the attr block with use TTE_Size when it computes the TSB
821index (or the TSB page_size parameter/Niagara-2 TSB config, if one is
822defined), as well as for the uses above. If you set TTE_Size_Ptr,
823however, it will use this as the page size setting when computing the
824TSB index. Use this whenever you wish to have a different setting for
825TTE_Size than the hardware will have in its config register.
826
827=back
828
829
830=head2 High Level Languages
831
832The output of compilers of high-level languages may be inserted into midas.
833
834=head3 Object files
835
836The midas directive:
837
838 MIDAS_OBJ FILE=<something.o>
839
840may be placed inside any section. That object file will be linked
841with the assembly output for the section and will share its attr
842blocks. No special interpretation is done on the contents of the
843object file - the text, data, and bss segments are simply linked in
844with the output of the assembler for that section. The search path
845for .o files is controlled by the -L switch. The default path is the
846starting directory, and E<lt>diag_rootE<gt>/verif/diag.
847
848=head3 Library files
849
850The midas directive:
851
852 MIDAS_LIB FILE=<something.a>
853
854Works just like a MIDAS_OBJ directive, except that it includes a
855library in the link. Note that the library must be static (i.e., a .a
856file, and not a .so file), because there is no runtime linker in the
857diag environment. Other than the file format, the difference between
858a library file and an object file, is that an object file will include
859all text/data/bss from the file, but linking with a library file will
860cause only those symbols that are actually used to be included.
861
862Library files will also search the same link path as object files.
863
864=head3 C files
865
866Simiar to object files, C language files may be included with the
867directive:
868
869 MIDAS_CC FILE=<something.c> [OUTPUT=<something.o>] [ARGS=-O2]
870
871The OUTPUT and ARGS tags are optional, but the FILE tag is mandatory.
872The search path for the C source file is controleld by the -C switch,
873and the default is the starting directory, then
874E<lt>diag_rootE<gt>/verif/diag/c. The ARGS tag (which must appear
875last, since the args last until the end of the line) is arguments to
876gcc. You must not use the -o or -c switches, since midas will provide
877its own. If "-S" is supplied to gcc through the ARGS tag, then gcc -S
878will be used to create an assembly file in the Sectioning phase, which
879will then be assembled like all the other assembly files in the
880Assembly phase. If -S is not present, then nothing is done in the
881Sectioning phase (except for finding the C file and copying it to the
882build directory). Rather, gcc is used to compile the C file directly
883to an object file during the assembly phase. The object file,
884generated either by gcc or by the of assembling of gcc -S, is then
885linked in with the rest of the section. Once the object file is
886generated, it is treated just as a MIDAS_OBJ directive.
887
888=head4 Stack
889
890Compiled C code expects the system to set up a stack for it before it
891runs. Template files are provided for this purpose. Be sure to use
892them or have some solution for setting up the stack if you are working
893with compiled code.
894
895=head1 AUTHOR
896
897Jeff Gibson E<lt>jeff.gibson@sun.comE<gt>
898
899=head1 SEE ALSO
900
901B<midas>(1), tre_perldoc Midas, B<pal>(1), B<goldfinger>(1).
902