use TRELoad
'BitFieldTie';
###############################################################################
$this = fields
::new
($this);
$this->{force_ctx_zero
} = undef;
$this->{page_size
} = undef;
foreach my $key (keys %args) {
$this->{$key} = $args{$key};
###############################################################################
my $srcfile_start = $srcfile;
my $srcline_start = $srcline;
fatal
"Badly formatted TSB line=$srcline, file=$srcfile:\n$_", M_TSBSYNTAX
unless /^\s*MIDAS_TSB\s*(\S+)\s*((0[xX])?([\da-fA-F]+))\s*(.*)\s*$/;
my $reg_bf = string2bf
($register, 64);
fatal
"TSB config register '$register' is not a number at file=$srcfile, line=$srcline\n", M_NOTNUM
unless defined $reg_bf;
my $force_ctx_zero = undef;
if($rest =~ s/force_ctx_zero//i) {
if($rest =~ s/link\s*=\s*(\S+)//i) {
if($rest =~ s/page_size\s*=\s*(\d+)//i) {
if($rest =~ s/way\s*=\s*(\d+)//i) {
if($rest =~ s/ttefmt\s*=(\S+)//i) {
if($ttefmt ne 'sun4u' and $ttefmt ne 'sun4v') {
fatal
"Illegal ttefmt '$1' on TSB line line=$srcline, file=$srcfile.\n",
tsblinkname
=> $tsblinkname,
config_register
=> $reg_bf,
srcfile
=> $srcfile_start,
srcline
=> $srcline_start,
$this->config_from_register($mmu);
$this->{force_ctx_zero
} = $force_ctx_zero if defined $force_ctx_zero;
$this->{page_size
} = $page_size if defined $page_size;
$this->{ttefmt
} = $ttefmt if defined $ttefmt;
$this->{way
} = hex($way) if defined $way;
if($this->{is_split
} and not defined $this->{way
}) {
fatal
"TSB '$tsbname' is split but does not\n".
" line=$srcline, file=$srcfile.\n", M_TSBSYNTAX
;
if(defined $this->{way
} and not ($this->{way
} == 0 or $this->{way
} == 1)) {
fatal
"TSB '$tsbname' defines way that isn't\n".
" line=$srcline, file=$srcfile.\n", M_TSBSYNTAX
;
if($this->{is_split
} and $this->{way
} == 1) {
my $newBase = BitFieldTie
->new($PASIZE, $this->{base
});
my $offset = $this->{numentries
} * 16; # 16 bytes per entry
$this->{base
} = $newBase;
###############################################################################
sub config_from_register
{
my $base = BitFieldTie
->new($PASIZE, $this->{config_register
});
$base->store(12, 0, 0); # zero out bits 12:0;
$this->{sizebits
} = $this->{config_register
}->extract(3,0);
$this->{is_split
} = $this->{config_register
}->extract(12);
$this->{numentries
} = 512 * (1 << $this->{sizebits
});
my $base_lo = 13 + $this->{sizebits
};
my $overlap = $base->extract($base_lo, 13);
if($CONFIG{allow_misaligned_tsb_base
}) {
$base->store($base_lo, 13, 0);
fatal
"TSB '$this->{name}' has base $base, which\n".
" is misaligned for size=$this->{sizebits}\n" .
" Illegal unless -allow_misalgined_tsb_base is defined.\n" .
" line=$this->{srcline}, file=$this->{srcfile}\n",
###############################################################################
return $this->{ttefmt
} if defined $this->{ttefmt
};
###############################################################################
if(defined $this->{tsblinkobj
}) {
$this->{tsblinkobj
}->touch();
###############################################################################
return $this->{touched
} || $CONFIG{gen_all_tsbs
};
###############################################################################
return $this->{force_ctx_zero
};
###############################################################################
return $this->{tsblinkname
};
###############################################################################
$this->{tsblinkobj
} = $obj;
###############################################################################
return $this->{page_size
};
###############################################################################
sub write_to_goldfinger_file
{
$indent = '' unless defined $indent;
print $ofh "${indent}TSB $this->{name}\n";
print $ofh "${indent} src_file = \"$this->{srcfile}\";\n";
print $ofh "${indent} src_line = $this->{srcline};\n";
print $ofh "${indent} start_addr = 0x$this->{base};\n";
print $ofh "${indent} size_bits = $this->{sizebits};\n";
print $ofh "${indent} split = $this->{is_split};\n";
print $ofh "${indent} num_entries = $this->{numentries};\n";
print $ofh "${indent} link_area = $this->{tsblinkname};\n"
if defined $this->{tsblinkname
};
print $ofh "${indent}END TSB\n";
###############################################################################
###############################################################################
###############################################################################
use TRELoad
'BitFieldTie';
###############################################################################
$this = fields
::new
($this);
foreach my $key (keys %args) {
$this->{$key} = $args{$key};
###############################################################################
my $srcfile_start = $srcfile;
my $srcline_start = $srcline;
fatal
"Badly formatted TSB_LINK line=$srcline, file=$srcfile:\n$_",
unless /^\s*MIDAS_TSB_LINK\s*(\S+)\s*((0[xX])?([\da-fA-F]+))\s*$/;
my $addr_bf = string2bf
($addr, $PASIZE);
fatal
"TSB_LINK addr '$addr' is not a number at ".
"file=$srcfile, line=$srcline\n", M_NOTNUM
unless defined $addr_bf;
my $this = Midas
::TSBLink
->new
srcfile
=> $srcfile_start,
srcline
=> $srcline_start,
###############################################################################
###############################################################################
return $this->{touched
} || $CONFIG{gen_all_tsbs
};
###############################################################################
$this->{length} = $length_bf;
###############################################################################
sub write_to_goldfinger_file
{
$indent = '' unless defined $indent;
print $ofh "${indent}TSB_LINK $this->{name}\n";
print $ofh "${indent} src_file = \"$this->{srcfile}\";\n";
print $ofh "${indent} src_line = $this->{srcline};\n";
print $ofh "${indent} start_addr = 0x$this->{base};\n";
print $ofh "${indent}END TSB_LINK\n";
###############################################################################
###############################################################################