1# Copyright (c) 2006-2007 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright
9# notice, this list of conditions and the following disclaimer in the
10# documentation and/or other materials provided with the distribution;
11# neither the name of the copyright holders nor the names of its
12# contributors may be used to endorse or promote products derived from
13# this software without specific prior written permission.
14#
15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26#
27# Authors: Ali Saidi
28
29from __future__ import print_function
30from __future__ import absolute_import
31
32from .SysPaths import script, disk, binary
33from os import environ as env
34from m5.defines import buildEnv
35
36class SysConfig:
37    def __init__(self, script=None, mem=None, disk=None, rootdev=None,
38                 os_type='linux'):
39        self.scriptname = script
40        self.diskname = disk
41        self.memsize = mem
42        self.root = rootdev
43        self.ostype = os_type
44
45    def script(self):
46        if self.scriptname:
47            return script(self.scriptname)
48        else:
49            return ''
50
51    def mem(self):
52        if self.memsize:
53            return self.memsize
54        else:
55            return '128MB'
56
57    def disk(self):
58        if self.diskname:
59            return disk(self.diskname)
60        elif buildEnv['TARGET_ISA'] == 'alpha':
61            return env.get('LINUX_IMAGE', disk('linux-latest.img'))
62        elif buildEnv['TARGET_ISA'] == 'x86':
63            return env.get('LINUX_IMAGE', disk('x86root.img'))
64        elif buildEnv['TARGET_ISA'] == 'arm':
65            return env.get('LINUX_IMAGE', disk('linux-aarch32-ael.img'))
66        elif buildEnv['TARGET_ISA'] == 'sparc':
67            return env.get('LINUX_IMAGE', disk('disk.s10hw2'))
68        else:
69            print("Don't know what default disk image to use for %s ISA" %
70                buildEnv['TARGET_ISA'])
71            exit(1)
72
73    def rootdev(self):
74        if self.root:
75            return self.root
76        else:
77            return '/dev/sda1'
78
79    def os_type(self):
80        return self.ostype
81
82# Benchmarks are defined as a key in a dict which is a list of SysConfigs
83# The first defined machine is the test system, the others are driving systems
84
85Benchmarks = {
86    'PovrayBench':  [SysConfig('povray-bench.rcS', '512MB', 'povray.img')],
87    'PovrayAutumn': [SysConfig('povray-autumn.rcS', '512MB', 'povray.img')],
88
89    'NetperfStream':    [SysConfig('netperf-stream-client.rcS'),
90                         SysConfig('netperf-server.rcS')],
91    'NetperfStreamUdp': [SysConfig('netperf-stream-udp-client.rcS'),
92                         SysConfig('netperf-server.rcS')],
93    'NetperfUdpLocal':  [SysConfig('netperf-stream-udp-local.rcS')],
94    'NetperfStreamNT':  [SysConfig('netperf-stream-nt-client.rcS'),
95                         SysConfig('netperf-server.rcS')],
96    'NetperfMaerts':    [SysConfig('netperf-maerts-client.rcS'),
97                         SysConfig('netperf-server.rcS')],
98    'SurgeStandard':    [SysConfig('surge-server.rcS', '512MB'),
99                         SysConfig('surge-client.rcS', '256MB')],
100    'SurgeSpecweb':     [SysConfig('spec-surge-server.rcS', '512MB'),
101                         SysConfig('spec-surge-client.rcS', '256MB')],
102    'Nhfsstone':        [SysConfig('nfs-server-nhfsstone.rcS', '512MB'),
103                         SysConfig('nfs-client-nhfsstone.rcS')],
104    'Nfs':              [SysConfig('nfs-server.rcS', '900MB'),
105                         SysConfig('nfs-client-dbench.rcS')],
106    'NfsTcp':           [SysConfig('nfs-server.rcS', '900MB'),
107                         SysConfig('nfs-client-tcp.rcS')],
108    'IScsiInitiator':   [SysConfig('iscsi-client.rcS', '512MB'),
109                         SysConfig('iscsi-server.rcS', '512MB')],
110    'IScsiTarget':      [SysConfig('iscsi-server.rcS', '512MB'),
111                         SysConfig('iscsi-client.rcS', '512MB')],
112    'Validation':       [SysConfig('iscsi-server.rcS', '512MB'),
113                         SysConfig('iscsi-client.rcS', '512MB')],
114    'Ping':             [SysConfig('ping-server.rcS',),
115                         SysConfig('ping-client.rcS')],
116
117    'ValAccDelay':      [SysConfig('devtime.rcS', '512MB')],
118    'ValAccDelay2':     [SysConfig('devtimewmr.rcS', '512MB')],
119    'ValMemLat':        [SysConfig('micro_memlat.rcS', '512MB')],
120    'ValMemLat2MB':     [SysConfig('micro_memlat2mb.rcS', '512MB')],
121    'ValMemLat8MB':     [SysConfig('micro_memlat8mb.rcS', '512MB')],
122    'ValMemLat':        [SysConfig('micro_memlat8.rcS', '512MB')],
123    'ValTlbLat':        [SysConfig('micro_tlblat.rcS', '512MB')],
124    'ValSysLat':        [SysConfig('micro_syscall.rcS', '512MB')],
125    'ValCtxLat':        [SysConfig('micro_ctx.rcS', '512MB')],
126    'ValStream':        [SysConfig('micro_stream.rcS', '512MB')],
127    'ValStreamScale':   [SysConfig('micro_streamscale.rcS', '512MB')],
128    'ValStreamCopy':    [SysConfig('micro_streamcopy.rcS', '512MB')],
129
130    'MutexTest':        [SysConfig('mutex-test.rcS', '128MB')],
131    'ArmAndroid-GB':    [SysConfig('null.rcS', '256MB',
132                    'ARMv7a-Gingerbread-Android.SMP.mouse.nolock.clean.img',
133                    None, 'android-gingerbread')],
134    'bbench-gb':        [SysConfig('bbench-gb.rcS', '256MB',
135                            'ARMv7a-Gingerbread-Android.SMP.mouse.nolock.img',
136                            None, 'android-gingerbread')],
137    'ArmAndroid-ICS':   [SysConfig('null.rcS', '256MB',
138                            'ARMv7a-ICS-Android.SMP.nolock.clean.img',
139                            None, 'android-ics')],
140    'bbench-ics':       [SysConfig('bbench-ics.rcS', '256MB',
141                            'ARMv7a-ICS-Android.SMP.nolock.img',
142                            None, 'android-ics')]
143}
144
145benchs = list(Benchmarks.keys())
146benchs.sort()
147DefinedBenchmarks = ", ".join(benchs)
148