# ========== Copyright Header Begin ==========================================
# OpenSPARC T2 Processor File: State.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 ============================================
our @EXPORT = qw(init_state);
##############################################################################
$diag_root = $ENV{DV_ROOT
} unless defined $diag_root;
$start_dir = getcwd
unless defined $start_dir;
$dest_dir = getcwd
unless defined $start_dir;
$diag_root = File
::Spec
->rel2abs($diag_root, getcwd
);
$start_dir = File
::Spec
->rel2abs($start_dir, getcwd
);
$dest_dir = File
::Spec
->rel2abs($dest_dir, getcwd
);
my $state = Midas
::State
->new(start_dir
=> $start_dir,
$state->set_build_dir($state->get_build_dir());
$ENV{DIAG_ROOT
} = $diag_root;
$ENV{START_DIR
} = $start_dir;
$ENV{DEST_DIR
} = $dest_dir;
##############################################################################
$this = fields
::new
($this);
foreach my $key (keys %args) {
$this->{$key} = $args{$key};
##############################################################################
$this->{start_dir
} = '.';
$this->{build_dir
} = undef;
$this->{diag_root
} = $ENV{DV_ROOT
};
$this->{created_build_dir
} = 0;
$this->{skipping_build
} = 0;
##############################################################################
my $build = $this->{build_dir
};
$build = $CONFIG{build_dir
};
my $build_abs = File
::Spec
->rel2abs($build, $this->{start_dir
});
if(grep /^\-abs$/, @args) {
return compact_path
($build_abs);
##############################################################################
my $build = File
::Spec
->rel2abs($build_dir, $this->{start_dir
});
$this->{build_dir
} = $build;
return $this->{build_dir
};
##############################################################################
my $start_dir = $this->{start_dir
};
if(grep /^\-abs$/, @args) {
return compact_path
$start_dir;
##############################################################################
my $dest_dir = $this->{dest_dir
};
if(grep /^\-abs$/, @args) {
return compact_path
$dest_dir;
##############################################################################
$this->{dest_dir
} = File
::Spec
->rel2abs($dest_dir);
##############################################################################
sub get_created_build_dir
{
return $this->{created_build_dir
};
##############################################################################
sub set_created_build_dir
{
$val = 1 unless defined $val;
$this->{created_build_dir
} = $val;
return $this->{created_build_dir
};
##############################################################################
return $this->{diag_root
};
##############################################################################
fatal
"Tried to get mmu of specified type $type when an mmu already ".
"exists!\n", M_CODE
if defined $type && defined $this->{mmu
};
return $this->{mmu
} if defined $this->{mmu
};
my $mmu = create_mmu
( defined $type ?
$type : $CONFIG{mmu_type
} );
##############################################################################
##############################################################################
$this->{skipping_build
} = $bool if defined $bool;
return $this->{skipping_build
};
##############################################################################
return $this->{tsbs
}{$name} if exists $this->{tsbs
}{$name};
##############################################################################
return $this->{tsblinks
}{$name} if exists $this->{tsblinks
}{$name};
##############################################################################