# ========== Copyright Header Begin ==========================================
# OpenSPARC T2 Processor File: Application.pm
# Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
# 4150 Network Circle, Santa Clara, California 95054, U.S.A.
# * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# For the avoidance of doubt, and except that if any non-GPL license
# choice is available it will apply instead, Sun elects to use only
# the General Public License version 2 (GPLv2) at this time for any
# software where a choice of GPL license versions is made
# available with the language indicating that GPLv2 or any later version
# may be used, or where a choice of which version of the GPL is applied is
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# ========== Copyright Header End ============================================
package Midas
::Application
;
use Midas
::Preprocess
':all';
use fields
qw(name filetag sections srcfile srcline args
is_linked external_path goldfinger_cmds
##############################################################################
$this = fields
::new
($this);
foreach my $key (keys %args) {
$this->{$key} = $args{$key};
$this->parse_args() if defined $this->{args
};
##############################################################################
$this->{sections
} = [] unless defined $this->{sections
};
$this->{goldfinger_cmds
} = [] unless defined $this->{goldfinger_cmds
};
##############################################################################
##############################################################################
my $args = $this->{args
};
my @args = split /,/, $args;
foreach my $arg (@args) {
if($args =~ /FILE\=(\S+)/i) {
$this->{external_path
} = $1;
$this->copy_external_to_build_dir();
##############################################################################
return 0 if @
{$this->{sections
}};
return 0 if $this->{is_linked
};
##############################################################################
sub copy_external_to_build_dir
{
my @search = get_includes
($CONFIG{link_paths
});
my $local_exe = path_to_build_file
($this->exe_name(), $STATE);
foreach my $testdir (@search) {
my $testfile = File
::Spec
->catfile($testdir, $this->{external_path
});
chat
"Copying $testfile to $local_exe\n";
copy
($testfile, $local_exe);
fatal
"Couldn't find \"$this->{external_path}\" in search path: @search\n",
##############################################################################
return '' if($this->name() eq 'default');
my $tag = lc $this->{name
};
##############################################################################
return $this->{is_linked
};
##############################################################################
return $this->expand_file($CONFIG{local_exe
});
##############################################################################
return $this->expand_file($CONFIG{local_ldscr
});
##############################################################################
my $name = $this->{name
};
my $filetag = $this->filetag();
$filetag = '.' . $filetag unless ($filetag =~ /^\./ or $filetag eq '');
$file =~ s/\*/${filetag}/;
##############################################################################
my $appname = $this->{name
};
my $secname = $section->{name
};
my $srcfile = $section->{srcfile
};
my $srcline = $section->{srcline
};
fatal
"Application $appname cannot contain SECTIONs\n" .
"($secname at file=$srcfile, line=$srcline\n", M_SECSYNTAX
;
push @
{$this->{sections
}}, $section;
##############################################################################
push @
{$this->{goldfinger_cmds
}}, $cmdstring;
##############################################################################
return @
{ $this->{sections
} };
##############################################################################
sub write_to_goldfinger
{
my $app_name = $this->name();
my $exe_name = $this->exe_name();
my $exe = path_to_build_file
($exe_name, $STATE);
my $srcfile = $this->{srcfile
};
my $srcline = $this->{srcline
};
print $fh "APP $app_name\n";
print $fh " ELF_FILE = \"$exe\";\n";
print $fh " SRC_FILE = \"$srcfile\";\n" if defined $srcfile;
print $fh " SRC_LINE = $srcline;\n" if defined $srcline;
my @sections = $this->get_sec_list();
foreach my $section (@sections) {
foreach my $seg (Midas
::Segment
->all_names()) {
my @attrs = $section->get_segment_attrs($seg);
my $linkname = $section->get_segment_link_name($seg);
foreach my $attr (@attrs) {
$attr->write_to_goldfinger($seg, $linkname, $fh);
foreach my $cmd (@
{$this->{goldfinger_cmds
}}) {
##############################################################################
chat
"App: $this->{name}\n", 3;
foreach my $sec (@
{$this->{sections
}}) {
$str .= " Section: \"$sec->{name}\" ";
my @link_attrs = $sec->get_link_attrs();
foreach my $seg (Midas
::Segment
->all_names()) {
my $va = $link_attrs[0]->get_segment_va($seg);
$str .= "${seg}_va=$va " if defined $va;
chat
"$str\n", 3 if $str =~ /\S/;
##############################################################################