use Midas
::MMU
::TTEFormat
;
# Needs to be a require so it happens AFTER 'use fields'.
# This is because of a circularity in the inclusions
require Midas
::MMU
::Ultra2
;
require Midas
::MMU
::Niagara
;
require Midas
::MMU
::Niagara2
;
require Midas
::MMU
::Rock
;
our @EXPORT = qw(create_mmu);
use fields
qw(type vasize pasize mapattr_type tsb_type tsblink_type);
##############################################################################
$mmu = Midas
::MMU
::Niagara
->new(%args);
} elsif($type eq 'niagara2') {
$mmu = Midas
::MMU
::Niagara2
->new(%args);
} elsif($type eq 'rock') {
$mmu = Midas
::MMU
::Rock
->new(%args);
} elsif($type eq 'ultra2' or $type eq 'ultrasparc2') {
$mmu = Midas
::MMU
::Ultra2
->new(%args);
fatal
"No such mmu type \"$type\"\n", M_BADCONFIG
;
$VASIZE = $mmu->{vasize
};
$RASIZE = exists $mmu->{rasize
} ?
$mmu->{rasize
} : $mmu->{pasize
};
$PASIZE = $mmu->{pasize
};
##############################################################################
$this = fields
::new
($this);
foreach my $key (keys %args) {
$this->{$key} = $args{$key};
$this->{mapattr_type
} = 'Midas::MMU::SunSectionAttrs';
$this->{tsb_type
} = 'Midas::TSB';
$this->{tsblink_type
} = 'Midas::TSBLink';
##############################################################################
%MapAttr_Settable = map { $_ => 1 } $this->{mapattr_type
}->settable();
my $fieldhash = get_union_tte_field_hash
( $this->{type
} );
foreach my $key (keys %$fieldhash) {
$MapAttr_Settable{$key} = 1;
my $fhash_ref = $this->{mapattr_type
}->get_field_size_hash();
foreach my $key (keys %$fieldhash) {
$fhash_ref->{$key} = $fieldhash->{$key};
foreach my $field (keys %$fhash_ref) {
my $width = $fhash_ref->{$field};
my $range_bf = BitFieldTie
->new(64, 1);
$range_bf->left_shift($width);
$MapAttr_FieldMax{$field} = $range_bf;
$MapAttr_FieldWidth{$field} = $width;
##############################################################################
$this->{vasize
} = 64 unless defined $this->{vasize
};
$this->{pasize
} = 64 unless defined $this->{pasize
};
$this->{type
} = 'generic' unless defined $this->{type
};
##############################################################################
sub create_attrs_object
{
return Midas
::AttrBlock
::LinkAttrs
->new()
if((lc $type) eq 'link');
return $this->{mapattr_type
}->new(segment
=> Midas
::Segment
->new($type),
mmutype
=> $this->{type
},
if Midas
::Segment
->is_segment_name($type);
fatal
"Can't create_attrs_object of type $type with abstract superclass ".
##############################################################################
return $this->{tsb_type
}->new(@args);
##############################################################################
sub create_tsb_object_from_line
{
$this->{tsb_type
}->new_from_line($startline, $fh, $srcfile, $srcline, $this);
##############################################################################
sub create_tsb_link_object
{
return $this->{tsblink_type
}->new(@args);
##############################################################################
sub create_tsb_link_object_from_line
{
$this->{tsblink_type
}->new_from_line($startline, $fh, $srcfile, $srcline,
##############################################################################
##############################################################################
sub parse_section_attrs
{
my $segstring = join '|', map { "($_)" } Midas
::Segment
->all_names();
if(/^\s*attr_($segstring|(link))\s*\{/) {
$attrs = $this->create_attrs_object($attr_type);
$attrs->{srcfile
} = $srcfile;
$attrs->{srcline
} = $srcline;
my @attrs = split /,/, $_;
foreach my $attr (@attrs) {
if($attr =~ /(\S+)=(\S+)/) {
if($attrs->is_settable($1)) {
$attrs->set_attr($1, $2);
$attrs->attr_fatal("No such attribute '$1'", M_ILLEGALPARAM
);
} elsif($attr =~ /(\S+)/) {
if($attrs->is_settable($1)) {
$attrs->attr_fatal("No such attribute '$1'", M_ILLEGALPARAM
);
fatal
"Error parsing section attributes: file=$srcfile line=$srcline:\n$_",
$attrs->set_end_file_line($srcfile, $srcline);
##############################################################################