Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | # ========== Copyright Header Begin ========================================== |
2 | # | |
3 | # OpenSPARC T2 Processor File: Configure.pm | |
4 | # Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved | |
5 | # 4150 Network Circle, Santa Clara, California 95054, U.S.A. | |
6 | # | |
7 | # * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
8 | # | |
9 | # This program is free software; you can redistribute it and/or modify | |
10 | # it under the terms of the GNU General Public License as published by | |
11 | # the Free Software Foundation; version 2 of the License. | |
12 | # | |
13 | # This program is distributed in the hope that it will be useful, | |
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | # GNU General Public License for more details. | |
17 | # | |
18 | # You should have received a copy of the GNU General Public License | |
19 | # along with this program; if not, write to the Free Software | |
20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | # | |
22 | # For the avoidance of doubt, and except that if any non-GPL license | |
23 | # choice is available it will apply instead, Sun elects to use only | |
24 | # the General Public License version 2 (GPLv2) at this time for any | |
25 | # software where a choice of GPL license versions is made | |
26 | # available with the language indicating that GPLv2 or any later version | |
27 | # may be used, or where a choice of which version of the GPL is applied is | |
28 | # otherwise unspecified. | |
29 | # | |
30 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
31 | # CA 95054 USA or visit www.sun.com if you need additional information or | |
32 | # have any questions. | |
33 | # | |
34 | # ========== Copyright Header End ============================================ | |
35 | # -*- perl -*- | |
36 | ||
37 | package Midas::Configure; | |
38 | use strict; | |
39 | ||
40 | use File::Spec; | |
41 | use Data::Dumper; | |
42 | ||
43 | use Midas::Paths; | |
44 | use Midas::Globals; | |
45 | use Midas::Error; | |
46 | ||
47 | require Midas::Command; | |
48 | ||
49 | require Exporter; | |
50 | our @ISA = qw(Exporter); | |
51 | our @EXPORT = qw(configure init_config add_cpp_defines); | |
52 | our @EXPORT_OK = qw(); | |
53 | ||
54 | ||
55 | my %default_config = | |
56 | ( | |
57 | verbose => 1, | |
58 | ||
59 | cpp_includes => { | |
60 | diagroot => ['verif/diag/assembly/include'], | |
61 | startdir => ['.'], | |
62 | builddir => ['.'], | |
63 | abs => [], | |
64 | }, | |
65 | cpp_defines => [ 'GOLDFINGER=1' | |
66 | ], | |
67 | m4_includes => { | |
68 | diagroot => [], | |
69 | startdir => ['.'], | |
70 | builddir => ['.'], | |
71 | abs => [], | |
72 | }, | |
73 | ||
74 | addphdr => 0, | |
75 | ||
76 | cleanup => 1, | |
77 | force_cleanup => 0, | |
78 | ||
79 | link_paths => { | |
80 | diagroot => ['verif/diag'], | |
81 | startdir => ['.'], | |
82 | builddir => [], | |
83 | abs => [], | |
84 | }, | |
85 | ||
86 | csrc_includes => { | |
87 | diagroot => ['verif/diag/c'], | |
88 | startdir => ['.'], | |
89 | builddir => [], | |
90 | abs => [], | |
91 | }, | |
92 | ||
93 | c_includes => { | |
94 | diagroot => ['verif/diag/c/include'], | |
95 | startdir => ['.'], | |
96 | builddir => ['.'], | |
97 | abs => [], | |
98 | }, | |
99 | ||
100 | # Default build directory (this is used as a default for the State | |
101 | # version, which is the one that really gets used). Can be full | |
102 | # path or relative to starting directory. | |
103 | ||
104 | build_dir => './build', | |
105 | ||
106 | # Full path or relative to build_dir | |
107 | local_src => 'diag.src', | |
108 | local_s => 'diag.s', | |
109 | local_pl => 'diag.pl', | |
110 | local_cpp => 'diag.cpp', | |
111 | local_m4 => 'diag.m4', | |
112 | local_ldscr => 'diag*.ld_scr', | |
113 | local_exe => 'diag*.exe', | |
114 | local_image => 'mem.image', | |
115 | local_events => 'diag.ev', | |
116 | local_symtab => 'symbol.tbl', | |
117 | local_goldfinger => 'diag.goldfinger', | |
118 | local_directives => 'diag.midas', | |
119 | ||
120 | local_cmdfile => '.midas_args', | |
121 | local_oldcmdfile => '.midas_args.old', | |
122 | local_oldm4 => '.midas.diag.m4.old', | |
123 | ||
124 | intermed_files => [qw(local_src local_s local_pl local_cpp local_m4 | |
125 | local_ldscr local_goldfinger local_directives | |
126 | sec*.s sec*.o | |
127 | )], | |
128 | ||
129 | force_build => 0, | |
130 | ||
131 | allow_tsb_conflicts => 0, | |
132 | allow_empty_sections => 0, | |
133 | allow_illegal_page_sizes => 0, | |
134 | allow_duplicate_tags => 0, | |
135 | allow_misaligned_tsb_base => 0, | |
136 | gen_all_tsbs => 0, | |
137 | compress_image => 1, | |
138 | env_zero => 1, | |
139 | build_threads => 3, | |
140 | ||
141 | goldfinger_cmd => 'goldfinger', | |
142 | goldfinger_version => '1.07', | |
143 | ||
144 | default_radix => 'decimal', | |
145 | ||
146 | product_files => { | |
147 | required => [qw(local_s local_image local_events | |
148 | local_symtab local_exe)], | |
149 | optional => [qw(local_pl)], | |
150 | clean => [qw(local_image local_events | |
151 | local_symtab local_exe)], | |
152 | }, | |
153 | copy_products => 0, | |
154 | ||
155 | cat_cmd => 'gcat', | |
156 | diff_cmd => 'diff', | |
157 | ||
158 | ||
159 | # If 1, use only full paths. Otherwise use relative paths wherever | |
160 | # possible to make output more clear. | |
161 | full_paths => 0, | |
162 | ||
163 | # Default MMU type | |
164 | mmu_type => 'niagara', | |
165 | ttefmt => 'sun4v', | |
166 | tsbtagfmt => 'tagaccess', | |
167 | ||
168 | ||
169 | pal_cmd => 'pal', | |
170 | pal_opt => [], | |
171 | pal_diag_args => [], | |
172 | ||
173 | cpp_cmd => 'bw_cpp', | |
174 | cpp_opt => ['-B -P'], | |
175 | ||
176 | m4_cmd => 'bw_m4', | |
177 | m4_opt => [], | |
178 | ||
179 | as_cmd => 'g_as', | |
180 | as_opt => ['-xarch=v9b'], | |
181 | ||
182 | ld_cmd => 'g_ld', | |
183 | ld_opt => ['-b elf64-sparc', '-no-warn-mismatch', | |
184 | '--no-check-sections'], | |
185 | ||
186 | gcc_cmd => 'gcc', | |
187 | gcc_opt => ['-m64', '-nostdinc', '-fno-common', '-fno-builtin'], | |
188 | ||
189 | perl_cmd => 'perl', | |
190 | ); | |
191 | ||
192 | ||
193 | ############################################################################## | |
194 | ||
195 | sub init_config { | |
196 | my $def_config= \%default_config; | |
197 | ||
198 | Midas::Command::chat "init_config, project is $PROJECT.\n"; | |
199 | my $dumper = Data::Dumper->new([$def_config]); | |
200 | ||
201 | $dumper->Purity(1)->Deepcopy(1); | |
202 | my $new_config = eval "no strict; " . $dumper->Dump; | |
203 | ||
204 | Midas::Command::fatal("Deepcopy of config failed!: $@\n", M_CODE) if $@; | |
205 | ||
206 | %CONFIG = %{ $new_config }; | |
207 | ||
208 | { | |
209 | package Config_Sandbox; | |
210 | our %PROJ_CONFIG; | |
211 | unless(my $return = do $Midas::Globals::CONFIG_FILE) { | |
212 | Midas::Command::chat | |
213 | ("WARNING! Can't parse config file ". | |
214 | "'$Midas::Globals::CONFIG_FILE': $@\n". | |
215 | "Using defaults.\n", 1) if $@; | |
216 | Midas::Command::chat | |
217 | ("WARNING! Can't find config file ". | |
218 | "'$Midas::Globals::CONFIG_FILE': $!\n". | |
219 | "Using defaults.\n", 1) unless defined $return; | |
220 | } else { | |
221 | if(exists $PROJ_CONFIG{$Midas::Globals::PROJECT}) { | |
222 | Midas::Command::chat | |
223 | ("Setting project defaults for project ". | |
224 | "'$Midas::Globals::PROJECT'.\n"); | |
225 | foreach my $key (keys %{ $PROJ_CONFIG{$Midas::Globals::PROJECT} } ) { | |
226 | $Midas::Globals::CONFIG{$key} = | |
227 | $PROJ_CONFIG{$Midas::Globals::PROJECT}{$key}; | |
228 | } | |
229 | } else { | |
230 | Midas::Command::chat("WARNING! No project config for project ". | |
231 | "'$Midas::Globals::PROJECT'.\n". | |
232 | "Using defaults.\n", 1); | |
233 | } | |
234 | } | |
235 | } | |
236 | ||
237 | ||
238 | (my $MAJOR_VERSION = $Midas::VERSION) =~ s/\..*$//; | |
239 | (my $MINOR_VERSION = $Midas::VERSION) =~ s/^.*\.//; | |
240 | ||
241 | add_cpp_defines( | |
242 | "MIDAS_VERSION=$Midas::VERSION", | |
243 | "MIDAS_MAJOR_VERS=$MAJOR_VERSION", | |
244 | "MIDAS_MINOR_VERS=$MINOR_VERSION" | |
245 | ); | |
246 | ||
247 | # Make Path's version of full_paths a *reference* to the Configure version. | |
248 | # This way, when one changes, they both change. Ditto for verbose. | |
249 | Midas::Paths::configure(full_paths => \$CONFIG{full_paths}); | |
250 | Midas::Command::configure(verbose => \$CONFIG{verbose}); | |
251 | } | |
252 | ||
253 | ############################################################################## | |
254 | ||
255 | sub configure { | |
256 | my %args = @_; | |
257 | ||
258 | foreach my $key (keys %args) { | |
259 | $CONFIG{$key} = $args{$key}; | |
260 | } | |
261 | ||
262 | return %CONFIG; | |
263 | } | |
264 | ||
265 | ############################################################################## | |
266 | ||
267 | sub add_cpp_includes { | |
268 | my @includes = @_; | |
269 | $CONFIG{cpp_includes}{abs} = [] unless exists $CONFIG{cpp_includes}{abs}; | |
270 | unshift @{$CONFIG{cpp_includes}{abs}}, @includes; | |
271 | } | |
272 | ||
273 | ############################################################################## | |
274 | ||
275 | sub add_m4_includes { | |
276 | my @includes = @_; | |
277 | $CONFIG{m4_includes}{abs} = [] unless exists $CONFIG{m4_includes}{abs}; | |
278 | unshift @{$CONFIG{m4_includes}{abs}}, @includes; | |
279 | } | |
280 | ||
281 | ############################################################################## | |
282 | ||
283 | sub add_link_includes { | |
284 | my @includes = @_; | |
285 | $CONFIG{link_path}{abs} = [] unless exists $CONFIG{link_path}{abs}; | |
286 | unshift @{$CONFIG{link_path}{abs}}, @includes; | |
287 | } | |
288 | ||
289 | ############################################################################## | |
290 | ||
291 | sub add_csrc_includes { | |
292 | my @includes = @_; | |
293 | $CONFIG{csrc_includes}{abs} = [] unless exists $CONFIG{csrc_includes}{abs}; | |
294 | unshift @{$CONFIG{csrc_includes}{abs}}, @includes; | |
295 | } | |
296 | ||
297 | ############################################################################## | |
298 | ||
299 | sub add_cpp_defines { | |
300 | my @defines = @_; | |
301 | push @{$CONFIG{cpp_defines}}, @defines; | |
302 | } | |
303 | ||
304 | ############################################################################## | |
305 | ||
306 | sub add_pal_diag_args { | |
307 | my @args = @_; | |
308 | push @{$CONFIG{pal_diag_args}}, @args; | |
309 | } | |
310 | ||
311 | ############################################################################## | |
312 | ||
313 | sub append_configuration { | |
314 | my %args = @_; | |
315 | foreach my $key (keys %args) { | |
316 | if(ref $CONFIG{$key}) { | |
317 | if(ref $CONFIG{$key} eq 'ARRAY') { | |
318 | push @{$CONFIG{$key}}, @{$args{$key}}; | |
319 | } else { | |
320 | Midas::Command::fatal | |
321 | ("Only know how to append configuration to arrays (not $key).\n"); | |
322 | } | |
323 | } else { | |
324 | Midas::Command::fatal("Can't append to scalar key $key\n", M_CODE); | |
325 | } | |
326 | } | |
327 | } | |
328 | ||
329 | ############################################################################## | |
330 | ############################################################################## | |
331 | 1; |